Repository: toeverything/AFFiNE
File: packages/backend/server/src/base/storage/providers/index.ts (TypeScript)

Code before:
        config: S3ConfigSchema,
      },
    },
    {
      type: 'object',
      properties: {
        provider: {
          type: 'string',
          enum: ['cloudflare-r2'],
        },
        bucket: {
          type: 'string',
        },
        config: {
          ...S3ConfigSchema,
          properties: {
            ...S3ConfigSchema.properties,
            accountId: {
              type: 'string' as const,
              description:
                'The account id for the cloudflare r2 storage provider.',
            },
            signDomain: {
              type: 'string' as const,
              description:
                'The presigned domain for the cloudflare r2 storage provider.\nsee https://developers.cloudflare.com/waf/custom-rules/use-cases/configure-token-authentication/ to configure it.\nExample value: "https://storage.example.com"\nExample rule: is_timed_hmac_valid_v0("your_secret", http.request.uri, 10800, http.request.timestamp.sec, 6)',
            },
            signKey: {
              type: 'string' as const,
              description:
                'The presigned key for the cloudflare r2 storage provider.',
            },
          },
        },
      },
    },
  ],
};

export type * from './provider';
export { autoMetadata, toBuffer } from './utils';


Review comment (suggestion):
```
usePresignedURL: {
  enabled: boolean
  signKey?: string
  urlPrefix?: string
}
```

Code after:
        config: S3ConfigSchema,
      },
    },
    {
      type: 'object',
      properties: {
        provider: {
          type: 'string',
          enum: ['cloudflare-r2'],
        },
        bucket: {
          type: 'string',
        },
        config: {
          ...S3ConfigSchema,
          properties: {
            ...S3ConfigSchema.properties,
            accountId: {
              type: 'string' as const,
              description:
                'The account id for the cloudflare r2 storage provider.',
            },
            usePresignedURL: {
              type: 'object' as const,
              description:
                'The presigned url config for the cloudflare r2 storage provider.',
              properties: {
                enabled: {
                  type: 'boolean' as const,
                  description:
                    'Whether to use presigned url for the cloudflare r2 storage provider.',
                },
                urlPrefix: {
                  type: 'string' as const,
                  description:
                    'The presigned url prefix for the cloudflare r2 storage provider.\nsee https://developers.cloudflare.com/waf/custom-rules/use-cases/configure-token-authentication/ to configure it.\nExample value: "https://storage.example.com"\nExample rule: is_timed_hmac_valid_v0("your_secret", http.request.uri, 10800, http.request.timestamp.sec, 6)',
                },
                signKey: {
                  type: 'string' as const,
                  description:
                    'The presigned key for the cloudflare r2 storage provider.',
                },
              },
            },
          },
        },
      },
    },
  ],
};