@payloadcms/plugin-cloud-storage 3.0.0-beta.7 → 3.0.0-canary.0017c67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +15 -126
  2. package/azure.d.ts +2 -0
  3. package/azure.js +3 -0
  4. package/dist/adapters/azure/generateURL.js.map +1 -1
  5. package/dist/adapters/azure/handleDelete.d.ts +1 -1
  6. package/dist/adapters/azure/handleDelete.d.ts.map +1 -1
  7. package/dist/adapters/azure/handleDelete.js.map +1 -1
  8. package/dist/adapters/azure/handleUpload.d.ts +1 -1
  9. package/dist/adapters/azure/handleUpload.d.ts.map +1 -1
  10. package/dist/adapters/azure/handleUpload.js.map +1 -1
  11. package/dist/adapters/azure/index.d.ts +5 -0
  12. package/dist/adapters/azure/index.d.ts.map +1 -1
  13. package/dist/adapters/azure/index.js +6 -1
  14. package/dist/adapters/azure/index.js.map +1 -1
  15. package/dist/adapters/azure/staticHandler.d.ts +1 -1
  16. package/dist/adapters/azure/staticHandler.d.ts.map +1 -1
  17. package/dist/adapters/azure/staticHandler.js +3 -2
  18. package/dist/adapters/azure/staticHandler.js.map +1 -1
  19. package/dist/adapters/gcs/generateURL.js.map +1 -1
  20. package/dist/adapters/gcs/handleDelete.js.map +1 -1
  21. package/dist/adapters/gcs/handleUpload.d.ts +1 -1
  22. package/dist/adapters/gcs/handleUpload.d.ts.map +1 -1
  23. package/dist/adapters/gcs/handleUpload.js.map +1 -1
  24. package/dist/adapters/gcs/index.d.ts +5 -0
  25. package/dist/adapters/gcs/index.d.ts.map +1 -1
  26. package/dist/adapters/gcs/index.js +6 -1
  27. package/dist/adapters/gcs/index.js.map +1 -1
  28. package/dist/adapters/gcs/staticHandler.d.ts +1 -1
  29. package/dist/adapters/gcs/staticHandler.d.ts.map +1 -1
  30. package/dist/adapters/gcs/staticHandler.js +3 -2
  31. package/dist/adapters/gcs/staticHandler.js.map +1 -1
  32. package/dist/adapters/s3/generateURL.js.map +1 -1
  33. package/dist/adapters/s3/handleDelete.js.map +1 -1
  34. package/dist/adapters/s3/handleUpload.d.ts +1 -1
  35. package/dist/adapters/s3/handleUpload.d.ts.map +1 -1
  36. package/dist/adapters/s3/handleUpload.js.map +1 -1
  37. package/dist/adapters/s3/index.d.ts +5 -0
  38. package/dist/adapters/s3/index.d.ts.map +1 -1
  39. package/dist/adapters/s3/index.js +6 -1
  40. package/dist/adapters/s3/index.js.map +1 -1
  41. package/dist/adapters/s3/staticHandler.d.ts +1 -1
  42. package/dist/adapters/s3/staticHandler.d.ts.map +1 -1
  43. package/dist/adapters/s3/staticHandler.js +3 -2
  44. package/dist/adapters/s3/staticHandler.js.map +1 -1
  45. package/dist/adapters/vercelBlob/generateURL.js.map +1 -1
  46. package/dist/adapters/vercelBlob/handleDelete.js.map +1 -1
  47. package/dist/adapters/vercelBlob/handleUpload.js.map +1 -1
  48. package/dist/adapters/vercelBlob/index.d.ts +5 -0
  49. package/dist/adapters/vercelBlob/index.d.ts.map +1 -1
  50. package/dist/adapters/vercelBlob/index.js +6 -1
  51. package/dist/adapters/vercelBlob/index.js.map +1 -1
  52. package/dist/adapters/vercelBlob/staticHandler.d.ts +1 -1
  53. package/dist/adapters/vercelBlob/staticHandler.d.ts.map +1 -1
  54. package/dist/adapters/vercelBlob/staticHandler.js +1 -0
  55. package/dist/adapters/vercelBlob/staticHandler.js.map +1 -1
  56. package/dist/admin/fields/getFields.d.ts +1 -1
  57. package/dist/admin/fields/getFields.d.ts.map +1 -1
  58. package/dist/admin/fields/getFields.js.map +1 -1
  59. package/dist/admin/index.d.ts +1 -1
  60. package/dist/admin/index.d.ts.map +1 -1
  61. package/dist/admin/index.js.map +1 -1
  62. package/dist/exports/azure.js.map +1 -1
  63. package/dist/exports/gcs.js.map +1 -1
  64. package/dist/exports/s3.js.map +1 -1
  65. package/dist/exports/utilities.js.map +1 -1
  66. package/dist/exports/vercelBlob.js.map +1 -1
  67. package/dist/fields/getFields.d.ts +1 -1
  68. package/dist/fields/getFields.d.ts.map +1 -1
  69. package/dist/fields/getFields.js +3 -1
  70. package/dist/fields/getFields.js.map +1 -1
  71. package/dist/hooks/afterDelete.d.ts +1 -2
  72. package/dist/hooks/afterDelete.d.ts.map +1 -1
  73. package/dist/hooks/afterDelete.js +4 -2
  74. package/dist/hooks/afterDelete.js.map +1 -1
  75. package/dist/hooks/afterRead.d.ts +1 -1
  76. package/dist/hooks/afterRead.d.ts.map +1 -1
  77. package/dist/hooks/afterRead.js +1 -0
  78. package/dist/hooks/afterRead.js.map +1 -1
  79. package/dist/hooks/beforeChange.d.ts +1 -2
  80. package/dist/hooks/beforeChange.d.ts.map +1 -1
  81. package/dist/hooks/beforeChange.js +4 -1
  82. package/dist/hooks/beforeChange.js.map +1 -1
  83. package/dist/index.d.ts +1 -1
  84. package/dist/index.d.ts.map +1 -1
  85. package/dist/index.js +1 -1
  86. package/dist/index.js.map +1 -1
  87. package/dist/plugin.d.ts +2 -2
  88. package/dist/plugin.d.ts.map +1 -1
  89. package/dist/plugin.js +2 -1
  90. package/dist/plugin.js.map +1 -1
  91. package/dist/types.d.ts +15 -8
  92. package/dist/types.d.ts.map +1 -1
  93. package/dist/types.js.map +1 -1
  94. package/dist/utilities/getFilePrefix.d.ts +4 -3
  95. package/dist/utilities/getFilePrefix.d.ts.map +1 -1
  96. package/dist/utilities/getFilePrefix.js +1 -3
  97. package/dist/utilities/getFilePrefix.js.map +1 -1
  98. package/dist/utilities/getIncomingFiles.d.ts +2 -2
  99. package/dist/utilities/getIncomingFiles.d.ts.map +1 -1
  100. package/dist/utilities/getIncomingFiles.js.map +1 -1
  101. package/dist/utilities/getRangeFromHeader.d.ts.map +1 -1
  102. package/dist/utilities/getRangeFromHeader.js.map +1 -1
  103. package/gcs.d.ts +2 -0
  104. package/gcs.js +3 -0
  105. package/package.json +63 -43
  106. package/s3.d.ts +2 -0
  107. package/s3.js +3 -0
  108. package/src/index.ts +0 -1
package/README.md CHANGED
@@ -2,30 +2,30 @@
2
2
 
3
3
  This repository contains the officially supported Payload Cloud Storage plugin. It extends Payload to allow you to store all uploaded media in third-party permanent storage.
4
4
 
5
- #### Requirements
5
+ **NOTE:** If you are using Payload 3.0 and one of the following storage services, you should use one of following packages instead of this one:
6
6
 
7
- - Payload version `1.0.19` or higher is required
7
+ | Service | Package |
8
+ | -------------------- | ----------------------------------------------------------------------------------------------------------------- |
9
+ | Vercel Blob | [`@payloadcms/storage-vercel-blob`](https://github.com/payloadcms/payload/tree/beta/packages/storage-vercel-blob) |
10
+ | AWS S3 | [`@payloadcms/storage-s3`](https://github.com/payloadcms/payload/tree/beta/packages/storage-s3) |
11
+ | Azure | [`@payloadcms/storage-azure`](https://github.com/payloadcms/payload/tree/beta/packages/storage-azure) |
12
+ | Google Cloud Storage | [`@payloadcms/storage-gcs`](https://github.com/payloadcms/payload/tree/beta/packages/storage-gcs) |
13
+
14
+ This package is now best used for implementing custom storage solutions or third-party storage services that do not have `@payloadcms/storage-*` packages.
8
15
 
9
16
  ## Installation
10
17
 
11
- `yarn add @payloadcms/plugin-cloud-storage` or `npm install @payloadcms/plugin-cloud-storage`
18
+ `pnpm add @payloadcms/plugin-cloud-storage`
12
19
 
13
20
  ## Usage
14
21
 
15
- Add this package into your dependencies executing this code in your command line:
16
-
17
- `yarn add @payloadcms/plugin-cloud-storage`
18
-
19
- Now install this plugin within your Payload as follows:
20
-
21
22
  ```ts
22
- import { buildConfig } from 'payload/config'
23
- import path from 'path'
24
- import { cloudStorage } from '@payloadcms/plugin-cloud-storage'
23
+ import { buildConfig } from 'payload'
24
+ import { cloudStoragePlugin } from '@payloadcms/plugin-cloud-storage'
25
25
 
26
26
  export default buildConfig({
27
27
  plugins: [
28
- cloudStorage({
28
+ cloudStoragePlugin({
29
29
  collections: {
30
30
  'my-collection-slug': {
31
31
  adapter: theAdapterToUse, // see docs for the adapter you want to use
@@ -42,7 +42,7 @@ export default buildConfig({
42
42
  The proper way to conditionally enable/disable this plugin is to use the `enabled` property.
43
43
 
44
44
  ```ts
45
- cloudStorage({
45
+ cloudStoragePlugin({
46
46
  enabled: process.env.MY_CONDITION === 'true',
47
47
  collections: {
48
48
  'my-collection-slug': {
@@ -88,127 +88,16 @@ This plugin is configurable to work across many different Payload collections. A
88
88
  | `prefix` | `string` | Set to `media/images` to upload files inside `media/images` folder in the bucket. |
89
89
  | `generateFileURL` | [GenerateFileURL](https://github.com/payloadcms/plugin-cloud-storage/blob/master/src/types.ts#L53) | Override the generated file URL with one that you create. |
90
90
 
91
- ### Azure Blob Storage Adapter
92
-
93
- To use the Azure Blob Storage adapter, you need to have `@azure/storage-blob` installed in your project dependencies. To do so, run `yarn add @azure/storage-blob`.
94
-
95
- From there, create the adapter, passing in all of its required properties:
96
-
97
- ```js
98
- import { azureBlobStorageAdapter } from '@payloadcms/plugin-cloud-storage/azure'
99
-
100
- const adapter = azureBlobStorageAdapter({
101
- connectionString: process.env.AZURE_STORAGE_CONNECTION_STRING,
102
- containerName: process.env.AZURE_STORAGE_CONTAINER_NAME,
103
- allowContainerCreate: process.env.AZURE_STORAGE_ALLOW_CONTAINER_CREATE === 'true',
104
- baseURL: process.env.AZURE_STORAGE_ACCOUNT_BASEURL,
105
- })
106
-
107
- // Now you can pass this adapter to the plugin
108
- ```
109
-
110
- ### S3 Adapter
111
-
112
- To use the S3 adapter, some peer dependencies need to be installed:
113
-
114
- `yarn add @aws-sdk/client-s3 @aws-sdk/lib-storage aws-crt`.
115
-
116
- From there, create the adapter, passing in all of its required properties:
117
-
118
- ```js
119
- import { s3Adapter } from '@payloadcms/plugin-cloud-storage/s3'
120
-
121
- const adapter = s3Adapter({
122
- config: {
123
- credentials: {
124
- accessKeyId: process.env.S3_ACCESS_KEY_ID,
125
- secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
126
- },
127
- region: process.env.S3_REGION,
128
- // ... Other S3 configuration
129
- },
130
- bucket: process.env.S3_BUCKET,
131
- })
132
-
133
- // Now you can pass this adapter to the plugin
134
- ```
135
-
136
- Note that the credentials option does not have to be used when you are using PayloadCMS on an EC2 instance that has been configured with an IAM Role with necessary permissions.
137
-
138
- Other S3 Client configuration is documented [here](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3/interfaces/s3clientconfig.html).
139
-
140
- Any upload over 50MB will automatically be uploaded using S3's multi-part upload.
141
-
142
- #### Other S3-Compatible Storage
143
-
144
- If you're running an S3-compatible object storage such as MinIO or Digital Ocean Spaces, you'll have to set the `endpoint` appropriately for the provider.
145
-
146
- ```js
147
- import { s3Adapter } from '@payloadcms/plugin-cloud-storage/s3'
148
-
149
- const adapter = s3Adapter({
150
- config: {
151
- endpoint: process.env.S3_ENDPOINT, // Configure for your provider
152
- // ...
153
- },
154
- // ...
155
- })
156
- ```
157
-
158
- ### GCS Adapter
159
-
160
- To use the GCS adapter, you need to have `@google-cloud/storage` installed in your project dependencies. To do so, run `yarn add @google-cloud/storage`.
161
-
162
- From there, create the adapter, passing in all of its required properties:
163
-
164
- ```js
165
- import { gcsAdapter } from '@payloadcms/plugin-cloud-storage/gcs'
166
-
167
- const adapter = gcsAdapter({
168
- options: {
169
- // you can choose any method for authentication, and authorization which is being provided by `@google-cloud/storage`
170
- keyFilename: './gcs-credentials.json',
171
- //OR
172
- credentials: JSON.parse(process.env.GCS_CREDENTIALS || '{}'), // this env variable will have stringify version of your credentials.json file
173
- },
174
- bucket: process.env.GCS_BUCKET,
175
- })
176
-
177
- // Now you can pass this adapter to the plugin
178
- ```
179
-
180
- ### Vercel Blob Adapter
181
-
182
- To use the Vercel Blob adapter, you need to have `@vercel/blob` installed in your project dependencies.
183
-
184
- ```ts
185
- import { vercelBlobAdapter } from '@payloadcms/plugin-cloud-storage/vercelBlob'
186
-
187
- const adapter = vercelBlobAdapter({
188
- token: process.env.BLOB_READ_WRITE_TOKEN || '',
189
- })
190
- ```
191
-
192
- Credit to @JarvisPrestidge for the original implementation of this plugin.
193
-
194
91
  ### Payload Access Control
195
92
 
196
93
  Payload ships with access control that runs _even on statically served files_. The same `read` access control property on your `upload`-enabled collections is used, and it allows you to restrict who can request your uploaded files.
197
94
 
198
95
  To preserve this feature, by default, this plugin _keeps all file URLs exactly the same_. Your file URLs won't be updated to point directly to your cloud storage source, as in that case, Payload's access control will be completely bypassed and you would need public readability on your cloud-hosted files.
199
96
 
200
- Instead, all uploads will still be reached from the default `/collectionSlug/staticURL/filename` path. This plugin will "pass through" all files that are hosted on your third-party cloud service—with the added benefit of keeping your existing access control in place.
97
+ Instead, all uploads will still be reached from the default `/:collectionSlug/file/:filename` path. This plugin will "pass through" all files that are hosted on your third-party cloud service—with the added benefit of keeping your existing access control in place.
201
98
 
202
99
  If this does not apply to you (your upload collection has `read: () => true` or similar) you can disable this functionality by setting `disablePayloadAccessControl` to `true`. When this setting is in place, this plugin will update your file URLs to point directly to your cloud host.
203
100
 
204
- ## Local development
205
-
206
- For instructions regarding how to develop with this plugin locally, [click here](https://github.com/payloadcms/plugin-cloud-storage/blob/master/docs/local-dev.md).
207
-
208
- ## Questions
209
-
210
- Please contact [Payload](mailto:dev@payloadcms.com) with any questions about using this plugin.
211
-
212
101
  ## Credit
213
102
 
214
103
  This plugin was created with significant help, and code, from [Alex Bechmann](https://github.com/alexbechmann) and [Richard VanBergen](https://github.com/richardvanbergen). Thank you!!
package/azure.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { azureBlobStorageAdapter } from './dist/adapters/azure/index.js'
2
+ //# sourceMappingURL=azure.d.ts.map
package/azure.js ADDED
@@ -0,0 +1,3 @@
1
+ export { azureBlobStorageAdapter } from './dist/adapters/azure/index.js'
2
+
3
+ //# sourceMappingURL=azure.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/azure/generateURL.ts"],"sourcesContent":["import path from 'path'\n\nimport type { GenerateURL } from '../../types.js'\n\ninterface Args {\n baseURL: string\n containerName: string\n}\n\nexport const getGenerateURL =\n ({ baseURL, containerName }: Args): GenerateURL =>\n ({ filename, prefix = '' }) => {\n return `${baseURL}/${containerName}/${path.posix.join(prefix, filename)}`\n }\n"],"names":["path","getGenerateURL","baseURL","containerName","filename","prefix","posix","join"],"rangeMappings":";;;","mappings":"AAAA,OAAOA,UAAU,OAAM;AASvB,OAAO,MAAMC,iBACX,CAAC,EAAEC,OAAO,EAAEC,aAAa,EAAQ,GACjC,CAAC,EAAEC,QAAQ,EAAEC,SAAS,EAAE,EAAE;QACxB,OAAO,CAAC,EAAEH,QAAQ,CAAC,EAAEC,cAAc,CAAC,EAAEH,KAAKM,KAAK,CAACC,IAAI,CAACF,QAAQD,UAAU,CAAC;IAC3E,EAAC"}
1
+ {"version":3,"sources":["../../../src/adapters/azure/generateURL.ts"],"sourcesContent":["import path from 'path'\n\nimport type { GenerateURL } from '../../types.js'\n\ninterface Args {\n baseURL: string\n containerName: string\n}\n\nexport const getGenerateURL =\n ({ baseURL, containerName }: Args): GenerateURL =>\n ({ filename, prefix = '' }) => {\n return `${baseURL}/${containerName}/${path.posix.join(prefix, filename)}`\n }\n"],"names":["path","getGenerateURL","baseURL","containerName","filename","prefix","posix","join"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AASvB,OAAO,MAAMC,iBACX,CAAC,EAAEC,OAAO,EAAEC,aAAa,EAAQ,GACjC,CAAC,EAAEC,QAAQ,EAAEC,SAAS,EAAE,EAAE;QACxB,OAAO,CAAC,EAAEH,QAAQ,CAAC,EAAEC,cAAc,CAAC,EAAEH,KAAKM,KAAK,CAACC,IAAI,CAACF,QAAQD,UAAU,CAAC;IAC3E,EAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { ContainerClient } from '@azure/storage-blob';
2
- import type { CollectionConfig } from 'payload/types';
2
+ import type { CollectionConfig } from 'payload';
3
3
  import type { HandleDelete } from '../../types.js';
4
4
  interface Args {
5
5
  collection: CollectionConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"handleDelete.d.ts","sourceRoot":"","sources":["../../../src/adapters/azure/handleDelete.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAIrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,UAAU,IAAI;IACZ,UAAU,EAAE,gBAAgB,CAAA;IAC5B,gBAAgB,EAAE,MAAM,eAAe,CAAA;CACxC;AAED,eAAO,MAAM,eAAe,yBAA0B,IAAI,KAAG,YAK5D,CAAA"}
1
+ {"version":3,"file":"handleDelete.d.ts","sourceRoot":"","sources":["../../../src/adapters/azure/handleDelete.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAI/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,UAAU,IAAI;IACZ,UAAU,EAAE,gBAAgB,CAAA;IAC5B,gBAAgB,EAAE,MAAM,eAAe,CAAA;CACxC;AAED,eAAO,MAAM,eAAe,yBAA0B,IAAI,KAAG,YAK5D,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/azure/handleDelete.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\nimport type { CollectionConfig } from 'payload/types'\n\nimport path from 'path'\n\nimport type { HandleDelete } from '../../types.js'\n\ninterface Args {\n collection: CollectionConfig\n getStorageClient: () => ContainerClient\n}\n\nexport const getHandleDelete = ({ getStorageClient }: Args): HandleDelete => {\n return async ({ doc: { prefix = '' }, filename }) => {\n const blockBlobClient = getStorageClient().getBlockBlobClient(path.posix.join(prefix, filename))\n await blockBlobClient.deleteIfExists()\n }\n}\n"],"names":["path","getHandleDelete","getStorageClient","doc","prefix","filename","blockBlobClient","getBlockBlobClient","posix","join","deleteIfExists"],"rangeMappings":";;;;;;","mappings":"AAGA,OAAOA,UAAU,OAAM;AASvB,OAAO,MAAMC,kBAAkB,CAAC,EAAEC,gBAAgB,EAAQ;IACxD,OAAO,OAAO,EAAEC,KAAK,EAAEC,SAAS,EAAE,EAAE,EAAEC,QAAQ,EAAE;QAC9C,MAAMC,kBAAkBJ,mBAAmBK,kBAAkB,CAACP,KAAKQ,KAAK,CAACC,IAAI,CAACL,QAAQC;QACtF,MAAMC,gBAAgBI,cAAc;IACtC;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/adapters/azure/handleDelete.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\nimport type { CollectionConfig } from 'payload'\n\nimport path from 'path'\n\nimport type { HandleDelete } from '../../types.js'\n\ninterface Args {\n collection: CollectionConfig\n getStorageClient: () => ContainerClient\n}\n\nexport const getHandleDelete = ({ getStorageClient }: Args): HandleDelete => {\n return async ({ doc: { prefix = '' }, filename }) => {\n const blockBlobClient = getStorageClient().getBlockBlobClient(path.posix.join(prefix, filename))\n await blockBlobClient.deleteIfExists()\n }\n}\n"],"names":["path","getHandleDelete","getStorageClient","doc","prefix","filename","blockBlobClient","getBlockBlobClient","posix","join","deleteIfExists"],"mappings":"AAGA,OAAOA,UAAU,OAAM;AASvB,OAAO,MAAMC,kBAAkB,CAAC,EAAEC,gBAAgB,EAAQ;IACxD,OAAO,OAAO,EAAEC,KAAK,EAAEC,SAAS,EAAE,EAAE,EAAEC,QAAQ,EAAE;QAC9C,MAAMC,kBAAkBJ,mBAAmBK,kBAAkB,CAACP,KAAKQ,KAAK,CAACC,IAAI,CAACL,QAAQC;QACtF,MAAMC,gBAAgBI,cAAc;IACtC;AACF,EAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { ContainerClient } from '@azure/storage-blob';
2
- import type { CollectionConfig } from 'payload/types';
2
+ import type { CollectionConfig } from 'payload';
3
3
  import type { HandleUpload } from '../../types.js';
4
4
  interface Args {
5
5
  collection: CollectionConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"handleUpload.d.ts","sourceRoot":"","sources":["../../../src/adapters/azure/handleUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAOrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,UAAU,IAAI;IACZ,UAAU,EAAE,gBAAgB,CAAA;IAC5B,gBAAgB,EAAE,MAAM,eAAe,CAAA;IACvC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAGD,eAAO,MAAM,eAAe,iCAAuC,IAAI,KAAG,YAyBzE,CAAA"}
1
+ {"version":3,"file":"handleUpload.d.ts","sourceRoot":"","sources":["../../../src/adapters/azure/handleUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAO/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,UAAU,IAAI;IACZ,UAAU,EAAE,gBAAgB,CAAA;IAC5B,gBAAgB,EAAE,MAAM,eAAe,CAAA;IACvC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAGD,eAAO,MAAM,eAAe,iCAAuC,IAAI,KAAG,YAyBzE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/azure/handleUpload.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\nimport type { CollectionConfig } from 'payload/types'\n\nimport { AbortController } from '@azure/abort-controller'\nimport fs from 'fs'\nimport path from 'path'\nimport { Readable } from 'stream'\n\nimport type { HandleUpload } from '../../types.js'\n\ninterface Args {\n collection: CollectionConfig\n getStorageClient: () => ContainerClient\n prefix?: string\n}\n\nconst multipartThreshold = 1024 * 1024 * 50 // 50MB\nexport const getHandleUpload = ({ getStorageClient, prefix = '' }: Args): HandleUpload => {\n return async ({ data, file }) => {\n const fileKey = path.posix.join(data.prefix || prefix, file.filename)\n\n const blockBlobClient = getStorageClient().getBlockBlobClient(fileKey)\n\n // when there are no temp files, or the upload is less than the threshold size, do not stream files\n if (!file.tempFilePath && file.buffer.length > 0 && file.buffer.length < multipartThreshold) {\n await blockBlobClient.upload(file.buffer, file.buffer.byteLength, {\n blobHTTPHeaders: { blobContentType: file.mimeType },\n })\n\n return data\n }\n\n const fileBufferOrStream: Readable = file.tempFilePath\n ? fs.createReadStream(file.tempFilePath)\n : Readable.from(file.buffer)\n\n await blockBlobClient.uploadStream(fileBufferOrStream, 4 * 1024 * 1024, 4, {\n abortSignal: AbortController.timeout(30 * 60 * 1000),\n })\n\n return data\n }\n}\n"],"names":["AbortController","fs","path","Readable","multipartThreshold","getHandleUpload","getStorageClient","prefix","data","file","fileKey","posix","join","filename","blockBlobClient","getBlockBlobClient","tempFilePath","buffer","length","upload","byteLength","blobHTTPHeaders","blobContentType","mimeType","fileBufferOrStream","createReadStream","from","uploadStream","abortSignal","timeout"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,eAAe,QAAQ,0BAAyB;AACzD,OAAOC,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AACvB,SAASC,QAAQ,QAAQ,SAAQ;AAUjC,MAAMC,qBAAqB,OAAO,OAAO,GAAG,OAAO;;AACnD,OAAO,MAAMC,kBAAkB,CAAC,EAAEC,gBAAgB,EAAEC,SAAS,EAAE,EAAQ;IACrE,OAAO,OAAO,EAAEC,IAAI,EAAEC,IAAI,EAAE;QAC1B,MAAMC,UAAUR,KAAKS,KAAK,CAACC,IAAI,CAACJ,KAAKD,MAAM,IAAIA,QAAQE,KAAKI,QAAQ;QAEpE,MAAMC,kBAAkBR,mBAAmBS,kBAAkB,CAACL;QAE9D,mGAAmG;QACnG,IAAI,CAACD,KAAKO,YAAY,IAAIP,KAAKQ,MAAM,CAACC,MAAM,GAAG,KAAKT,KAAKQ,MAAM,CAACC,MAAM,GAAGd,oBAAoB;YAC3F,MAAMU,gBAAgBK,MAAM,CAACV,KAAKQ,MAAM,EAAER,KAAKQ,MAAM,CAACG,UAAU,EAAE;gBAChEC,iBAAiB;oBAAEC,iBAAiBb,KAAKc,QAAQ;gBAAC;YACpD;YAEA,OAAOf;QACT;QAEA,MAAMgB,qBAA+Bf,KAAKO,YAAY,GAClDf,GAAGwB,gBAAgB,CAAChB,KAAKO,YAAY,IACrCb,SAASuB,IAAI,CAACjB,KAAKQ,MAAM;QAE7B,MAAMH,gBAAgBa,YAAY,CAACH,oBAAoB,IAAI,OAAO,MAAM,GAAG;YACzEI,aAAa5B,gBAAgB6B,OAAO,CAAC,KAAK,KAAK;QACjD;QAEA,OAAOrB;IACT;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/adapters/azure/handleUpload.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\nimport type { CollectionConfig } from 'payload'\n\nimport { AbortController } from '@azure/abort-controller'\nimport fs from 'fs'\nimport path from 'path'\nimport { Readable } from 'stream'\n\nimport type { HandleUpload } from '../../types.js'\n\ninterface Args {\n collection: CollectionConfig\n getStorageClient: () => ContainerClient\n prefix?: string\n}\n\nconst multipartThreshold = 1024 * 1024 * 50 // 50MB\nexport const getHandleUpload = ({ getStorageClient, prefix = '' }: Args): HandleUpload => {\n return async ({ data, file }) => {\n const fileKey = path.posix.join(data.prefix || prefix, file.filename)\n\n const blockBlobClient = getStorageClient().getBlockBlobClient(fileKey)\n\n // when there are no temp files, or the upload is less than the threshold size, do not stream files\n if (!file.tempFilePath && file.buffer.length > 0 && file.buffer.length < multipartThreshold) {\n await blockBlobClient.upload(file.buffer, file.buffer.byteLength, {\n blobHTTPHeaders: { blobContentType: file.mimeType },\n })\n\n return data\n }\n\n const fileBufferOrStream: Readable = file.tempFilePath\n ? fs.createReadStream(file.tempFilePath)\n : Readable.from(file.buffer)\n\n await blockBlobClient.uploadStream(fileBufferOrStream, 4 * 1024 * 1024, 4, {\n abortSignal: AbortController.timeout(30 * 60 * 1000),\n })\n\n return data\n }\n}\n"],"names":["AbortController","fs","path","Readable","multipartThreshold","getHandleUpload","getStorageClient","prefix","data","file","fileKey","posix","join","filename","blockBlobClient","getBlockBlobClient","tempFilePath","buffer","length","upload","byteLength","blobHTTPHeaders","blobContentType","mimeType","fileBufferOrStream","createReadStream","from","uploadStream","abortSignal","timeout"],"mappings":"AAGA,SAASA,eAAe,QAAQ,0BAAyB;AACzD,OAAOC,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AACvB,SAASC,QAAQ,QAAQ,SAAQ;AAUjC,MAAMC,qBAAqB,OAAO,OAAO,GAAG,OAAO;;AACnD,OAAO,MAAMC,kBAAkB,CAAC,EAAEC,gBAAgB,EAAEC,SAAS,EAAE,EAAQ;IACrE,OAAO,OAAO,EAAEC,IAAI,EAAEC,IAAI,EAAE;QAC1B,MAAMC,UAAUR,KAAKS,KAAK,CAACC,IAAI,CAACJ,KAAKD,MAAM,IAAIA,QAAQE,KAAKI,QAAQ;QAEpE,MAAMC,kBAAkBR,mBAAmBS,kBAAkB,CAACL;QAE9D,mGAAmG;QACnG,IAAI,CAACD,KAAKO,YAAY,IAAIP,KAAKQ,MAAM,CAACC,MAAM,GAAG,KAAKT,KAAKQ,MAAM,CAACC,MAAM,GAAGd,oBAAoB;YAC3F,MAAMU,gBAAgBK,MAAM,CAACV,KAAKQ,MAAM,EAAER,KAAKQ,MAAM,CAACG,UAAU,EAAE;gBAChEC,iBAAiB;oBAAEC,iBAAiBb,KAAKc,QAAQ;gBAAC;YACpD;YAEA,OAAOf;QACT;QAEA,MAAMgB,qBAA+Bf,KAAKO,YAAY,GAClDf,GAAGwB,gBAAgB,CAAChB,KAAKO,YAAY,IACrCb,SAASuB,IAAI,CAACjB,KAAKQ,MAAM;QAE7B,MAAMH,gBAAgBa,YAAY,CAACH,oBAAoB,IAAI,OAAO,MAAM,GAAG;YACzEI,aAAa5B,gBAAgB6B,OAAO,CAAC,KAAK,KAAK;QACjD;QAEA,OAAOrB;IACT;AACF,EAAC"}
@@ -5,5 +5,10 @@ export interface Args {
5
5
  connectionString: string;
6
6
  containerName: string;
7
7
  }
8
+ /**
9
+ * @deprecated Use [`@payloadcms/azure`](https://www.npmjs.com/package/@payloadcms/azure) instead.
10
+ *
11
+ * This adapter has been superceded by `@payloadcms/azure` and will be removed in Payload 3.0.
12
+ */
8
13
  export declare const azureBlobStorageAdapter: ({ allowContainerCreate, baseURL, connectionString, containerName, }: Args) => Adapter;
9
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/azure/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,gBAAgB,CAAA;AAO/D,MAAM,WAAW,IAAI;IACnB,oBAAoB,EAAE,OAAO,CAAA;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,gBAAgB,EAAE,MAAM,CAAA;IACxB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,eAAO,MAAM,uBAAuB,wEAKjC,IAAI,KAAG,OA0CT,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/azure/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,gBAAgB,CAAA;AAO/D,MAAM,WAAW,IAAI;IACnB,oBAAoB,EAAE,OAAO,CAAA;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,gBAAgB,EAAE,MAAM,CAAA;IACxB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,wEAKjC,IAAI,KAAG,OA2CT,CAAA"}
@@ -3,7 +3,11 @@ import { getGenerateURL } from './generateURL.js';
3
3
  import { getHandleDelete } from './handleDelete.js';
4
4
  import { getHandleUpload } from './handleUpload.js';
5
5
  import { getHandler } from './staticHandler.js';
6
- export const azureBlobStorageAdapter = ({ allowContainerCreate, baseURL, connectionString, containerName })=>{
6
+ /**
7
+ * @deprecated Use [`@payloadcms/azure`](https://www.npmjs.com/package/@payloadcms/azure) instead.
8
+ *
9
+ * This adapter has been superceded by `@payloadcms/azure` and will be removed in Payload 3.0.
10
+ */ export const azureBlobStorageAdapter = ({ allowContainerCreate, baseURL, connectionString, containerName })=>{
7
11
  if (!BlobServiceClient) {
8
12
  throw new Error('The package @azure/storage-blob is not installed, but is required for the plugin-cloud-storage Azure adapter. Please install it.');
9
13
  }
@@ -29,6 +33,7 @@ export const azureBlobStorageAdapter = ({ allowContainerCreate, baseURL, connect
29
33
  };
30
34
  return ({ collection, prefix })=>{
31
35
  return {
36
+ name: 'azure',
32
37
  generateURL: getGenerateURL({
33
38
  baseURL,
34
39
  containerName
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/azure/index.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\n\nimport { BlobServiceClient } from '@azure/storage-blob'\n\nimport type { Adapter, GeneratedAdapter } from '../../types.js'\n\nimport { getGenerateURL } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\n\nexport interface Args {\n allowContainerCreate: boolean\n baseURL: string\n connectionString: string\n containerName: string\n}\n\nexport const azureBlobStorageAdapter = ({\n allowContainerCreate,\n baseURL,\n connectionString,\n containerName,\n}: Args): Adapter => {\n if (!BlobServiceClient) {\n throw new Error(\n 'The package @azure/storage-blob is not installed, but is required for the plugin-cloud-storage Azure adapter. Please install it.',\n )\n }\n\n let storageClient: ContainerClient | null = null\n const getStorageClient = () => {\n if (storageClient) return storageClient\n let blobServiceClient = null\n try {\n blobServiceClient = BlobServiceClient.fromConnectionString(connectionString)\n } catch (error) {\n if (/is not a constructor$/.test(error.message)) {\n throw new Error(\n 'The package @azure/storage-blob is not installed, but is required for the plugin-cloud-storage Azure adapter. Please install it.',\n )\n }\n // Re-throw other unexpected errors.\n throw error\n }\n return (storageClient = blobServiceClient.getContainerClient(containerName))\n }\n\n const createContainerIfNotExists = () => {\n getStorageClient().createIfNotExists({ access: 'blob' })\n }\n\n return ({ collection, prefix }): GeneratedAdapter => {\n return {\n generateURL: getGenerateURL({ baseURL, containerName }),\n handleDelete: getHandleDelete({ collection, getStorageClient }),\n handleUpload: getHandleUpload({\n collection,\n getStorageClient,\n prefix,\n }),\n staticHandler: getHandler({ collection, getStorageClient }),\n ...(allowContainerCreate && { onInit: createContainerIfNotExists }),\n }\n }\n}\n"],"names":["BlobServiceClient","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","azureBlobStorageAdapter","allowContainerCreate","baseURL","connectionString","containerName","Error","storageClient","getStorageClient","blobServiceClient","fromConnectionString","error","test","message","getContainerClient","createContainerIfNotExists","createIfNotExists","access","collection","prefix","generateURL","handleDelete","handleUpload","staticHandler","onInit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,iBAAiB,QAAQ,sBAAqB;AAIvD,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAS/C,OAAO,MAAMC,0BAA0B,CAAC,EACtCC,oBAAoB,EACpBC,OAAO,EACPC,gBAAgB,EAChBC,aAAa,EACR;IACL,IAAI,CAACT,mBAAmB;QACtB,MAAM,IAAIU,MACR;IAEJ;IAEA,IAAIC,gBAAwC;IAC5C,MAAMC,mBAAmB;QACvB,IAAID,eAAe,OAAOA;QAC1B,IAAIE,oBAAoB;QACxB,IAAI;YACFA,oBAAoBb,kBAAkBc,oBAAoB,CAACN;QAC7D,EAAE,OAAOO,OAAO;YACd,IAAI,wBAAwBC,IAAI,CAACD,MAAME,OAAO,GAAG;gBAC/C,MAAM,IAAIP,MACR;YAEJ;YACA,oCAAoC;YACpC,MAAMK;QACR;QACA,OAAQJ,gBAAgBE,kBAAkBK,kBAAkB,CAACT;IAC/D;IAEA,MAAMU,6BAA6B;QACjCP,mBAAmBQ,iBAAiB,CAAC;YAAEC,QAAQ;QAAO;IACxD;IAEA,OAAO,CAAC,EAAEC,UAAU,EAAEC,MAAM,EAAE;QAC5B,OAAO;YACLC,aAAavB,eAAe;gBAAEM;gBAASE;YAAc;YACrDgB,cAAcvB,gBAAgB;gBAAEoB;gBAAYV;YAAiB;YAC7Dc,cAAcvB,gBAAgB;gBAC5BmB;gBACAV;gBACAW;YACF;YACAI,eAAevB,WAAW;gBAAEkB;gBAAYV;YAAiB;YACzD,GAAIN,wBAAwB;gBAAEsB,QAAQT;YAA2B,CAAC;QACpE;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/adapters/azure/index.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\n\nimport { BlobServiceClient } from '@azure/storage-blob'\n\nimport type { Adapter, GeneratedAdapter } from '../../types.js'\n\nimport { getGenerateURL } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\n\nexport interface Args {\n allowContainerCreate: boolean\n baseURL: string\n connectionString: string\n containerName: string\n}\n\n/**\n * @deprecated Use [`@payloadcms/azure`](https://www.npmjs.com/package/@payloadcms/azure) instead.\n *\n * This adapter has been superceded by `@payloadcms/azure` and will be removed in Payload 3.0.\n */\nexport const azureBlobStorageAdapter = ({\n allowContainerCreate,\n baseURL,\n connectionString,\n containerName,\n}: Args): Adapter => {\n if (!BlobServiceClient) {\n throw new Error(\n 'The package @azure/storage-blob is not installed, but is required for the plugin-cloud-storage Azure adapter. Please install it.',\n )\n }\n\n let storageClient: ContainerClient | null = null\n const getStorageClient = () => {\n if (storageClient) return storageClient\n let blobServiceClient = null\n try {\n blobServiceClient = BlobServiceClient.fromConnectionString(connectionString)\n } catch (error) {\n if (/is not a constructor$/.test(error.message)) {\n throw new Error(\n 'The package @azure/storage-blob is not installed, but is required for the plugin-cloud-storage Azure adapter. Please install it.',\n )\n }\n // Re-throw other unexpected errors.\n throw error\n }\n return (storageClient = blobServiceClient.getContainerClient(containerName))\n }\n\n const createContainerIfNotExists = () => {\n getStorageClient().createIfNotExists({ access: 'blob' })\n }\n\n return ({ collection, prefix }): GeneratedAdapter => {\n return {\n name: 'azure',\n generateURL: getGenerateURL({ baseURL, containerName }),\n handleDelete: getHandleDelete({ collection, getStorageClient }),\n handleUpload: getHandleUpload({\n collection,\n getStorageClient,\n prefix,\n }),\n staticHandler: getHandler({ collection, getStorageClient }),\n ...(allowContainerCreate && { onInit: createContainerIfNotExists }),\n }\n }\n}\n"],"names":["BlobServiceClient","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","azureBlobStorageAdapter","allowContainerCreate","baseURL","connectionString","containerName","Error","storageClient","getStorageClient","blobServiceClient","fromConnectionString","error","test","message","getContainerClient","createContainerIfNotExists","createIfNotExists","access","collection","prefix","name","generateURL","handleDelete","handleUpload","staticHandler","onInit"],"mappings":"AAEA,SAASA,iBAAiB,QAAQ,sBAAqB;AAIvD,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAS/C;;;;CAIC,GACD,OAAO,MAAMC,0BAA0B,CAAC,EACtCC,oBAAoB,EACpBC,OAAO,EACPC,gBAAgB,EAChBC,aAAa,EACR;IACL,IAAI,CAACT,mBAAmB;QACtB,MAAM,IAAIU,MACR;IAEJ;IAEA,IAAIC,gBAAwC;IAC5C,MAAMC,mBAAmB;QACvB,IAAID,eAAe,OAAOA;QAC1B,IAAIE,oBAAoB;QACxB,IAAI;YACFA,oBAAoBb,kBAAkBc,oBAAoB,CAACN;QAC7D,EAAE,OAAOO,OAAO;YACd,IAAI,wBAAwBC,IAAI,CAACD,MAAME,OAAO,GAAG;gBAC/C,MAAM,IAAIP,MACR;YAEJ;YACA,oCAAoC;YACpC,MAAMK;QACR;QACA,OAAQJ,gBAAgBE,kBAAkBK,kBAAkB,CAACT;IAC/D;IAEA,MAAMU,6BAA6B;QACjCP,mBAAmBQ,iBAAiB,CAAC;YAAEC,QAAQ;QAAO;IACxD;IAEA,OAAO,CAAC,EAAEC,UAAU,EAAEC,MAAM,EAAE;QAC5B,OAAO;YACLC,MAAM;YACNC,aAAaxB,eAAe;gBAAEM;gBAASE;YAAc;YACrDiB,cAAcxB,gBAAgB;gBAAEoB;gBAAYV;YAAiB;YAC7De,cAAcxB,gBAAgB;gBAC5BmB;gBACAV;gBACAW;YACF;YACAK,eAAexB,WAAW;gBAAEkB;gBAAYV;YAAiB;YACzD,GAAIN,wBAAwB;gBAAEuB,QAAQV;YAA2B,CAAC;QACpE;IACF;AACF,EAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { ContainerClient } from '@azure/storage-blob';
2
- import type { CollectionConfig } from 'payload/types';
2
+ import type { CollectionConfig } from 'payload';
3
3
  import type { StaticHandler } from '../../types.js';
4
4
  interface Args {
5
5
  collection: CollectionConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"staticHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/azure/staticHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAIrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAKnD,UAAU,IAAI;IACZ,UAAU,EAAE,gBAAgB,CAAA;IAC5B,gBAAgB,EAAE,MAAM,eAAe,CAAA;CACxC;AAED,eAAO,MAAM,UAAU,qCAAsC,IAAI,KAAG,aAuCnE,CAAA"}
1
+ {"version":3,"file":"staticHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/azure/staticHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAI/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAKnD,UAAU,IAAI;IACZ,UAAU,EAAE,gBAAgB,CAAA;IAC5B,gBAAgB,EAAE,MAAM,eAAe,CAAA;CACxC;AAED,eAAO,MAAM,UAAU,qCAAsC,IAAI,KAAG,aAuCnE,CAAA"}
@@ -2,13 +2,14 @@ import path from 'path';
2
2
  import { getFilePrefix } from '../../utilities/getFilePrefix.js';
3
3
  import getRangeFromHeader from '../../utilities/getRangeFromHeader.js';
4
4
  export const getHandler = ({ collection, getStorageClient })=>{
5
- return async (req, { params })=>{
5
+ return async (req, { params: { filename } })=>{
6
6
  try {
7
7
  const prefix = await getFilePrefix({
8
8
  collection,
9
+ filename,
9
10
  req
10
11
  });
11
- const blockBlobClient = getStorageClient().getBlockBlobClient(path.posix.join(prefix, params.filename));
12
+ const blockBlobClient = getStorageClient().getBlockBlobClient(path.posix.join(prefix, filename));
12
13
  const { end, start } = await getRangeFromHeader(blockBlobClient, req.headers.get('range'));
13
14
  const blob = await blockBlobClient.download(start, end);
14
15
  // eslint-disable-next-line no-underscore-dangle
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/azure/staticHandler.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\nimport type { CollectionConfig } from 'payload/types'\n\nimport path from 'path'\n\nimport type { StaticHandler } from '../../types.js'\n\nimport { getFilePrefix } from '../../utilities/getFilePrefix.js'\nimport getRangeFromHeader from '../../utilities/getRangeFromHeader.js'\n\ninterface Args {\n collection: CollectionConfig\n getStorageClient: () => ContainerClient\n}\n\nexport const getHandler = ({ collection, getStorageClient }: Args): StaticHandler => {\n return async (req, { params }) => {\n try {\n const prefix = await getFilePrefix({ collection, req })\n const blockBlobClient = getStorageClient().getBlockBlobClient(\n path.posix.join(prefix, params.filename),\n )\n\n const { end, start } = await getRangeFromHeader(blockBlobClient, req.headers.get('range'))\n\n const blob = await blockBlobClient.download(start, end)\n // eslint-disable-next-line no-underscore-dangle\n const response = blob._response\n\n // Manually create a ReadableStream for the web from a Node.js stream.\n const readableStream = new ReadableStream({\n start(controller) {\n const nodeStream = blob.readableStreamBody\n nodeStream.on('data', (chunk) => {\n controller.enqueue(new Uint8Array(chunk))\n })\n nodeStream.on('end', () => {\n controller.close()\n })\n nodeStream.on('error', (err) => {\n controller.error(err)\n })\n },\n })\n\n return new Response(readableStream, {\n headers: response.headers.rawHeaders(),\n status: response.status,\n })\n } catch (err: unknown) {\n req.payload.logger.error(err)\n return new Response('Internal Server Error', { status: 500 })\n }\n }\n}\n"],"names":["path","getFilePrefix","getRangeFromHeader","getHandler","collection","getStorageClient","req","params","prefix","blockBlobClient","getBlockBlobClient","posix","join","filename","end","start","headers","get","blob","download","response","_response","readableStream","ReadableStream","controller","nodeStream","readableStreamBody","on","chunk","enqueue","Uint8Array","close","err","error","Response","rawHeaders","status","payload","logger"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,OAAOA,UAAU,OAAM;AAIvB,SAASC,aAAa,QAAQ,mCAAkC;AAChE,OAAOC,wBAAwB,wCAAuC;AAOtE,OAAO,MAAMC,aAAa,CAAC,EAAEC,UAAU,EAAEC,gBAAgB,EAAQ;IAC/D,OAAO,OAAOC,KAAK,EAAEC,MAAM,EAAE;QAC3B,IAAI;YACF,MAAMC,SAAS,MAAMP,cAAc;gBAAEG;gBAAYE;YAAI;YACrD,MAAMG,kBAAkBJ,mBAAmBK,kBAAkB,CAC3DV,KAAKW,KAAK,CAACC,IAAI,CAACJ,QAAQD,OAAOM,QAAQ;YAGzC,MAAM,EAAEC,GAAG,EAAEC,KAAK,EAAE,GAAG,MAAMb,mBAAmBO,iBAAiBH,IAAIU,OAAO,CAACC,GAAG,CAAC;YAEjF,MAAMC,OAAO,MAAMT,gBAAgBU,QAAQ,CAACJ,OAAOD;YACnD,gDAAgD;YAChD,MAAMM,WAAWF,KAAKG,SAAS;YAE/B,sEAAsE;YACtE,MAAMC,iBAAiB,IAAIC,eAAe;gBACxCR,OAAMS,UAAU;oBACd,MAAMC,aAAaP,KAAKQ,kBAAkB;oBAC1CD,WAAWE,EAAE,CAAC,QAAQ,CAACC;wBACrBJ,WAAWK,OAAO,CAAC,IAAIC,WAAWF;oBACpC;oBACAH,WAAWE,EAAE,CAAC,OAAO;wBACnBH,WAAWO,KAAK;oBAClB;oBACAN,WAAWE,EAAE,CAAC,SAAS,CAACK;wBACtBR,WAAWS,KAAK,CAACD;oBACnB;gBACF;YACF;YAEA,OAAO,IAAIE,SAASZ,gBAAgB;gBAClCN,SAASI,SAASJ,OAAO,CAACmB,UAAU;gBACpCC,QAAQhB,SAASgB,MAAM;YACzB;QACF,EAAE,OAAOJ,KAAc;YACrB1B,IAAI+B,OAAO,CAACC,MAAM,CAACL,KAAK,CAACD;YACzB,OAAO,IAAIE,SAAS,yBAAyB;gBAAEE,QAAQ;YAAI;QAC7D;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/adapters/azure/staticHandler.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\nimport type { CollectionConfig } from 'payload'\n\nimport path from 'path'\n\nimport type { StaticHandler } from '../../types.js'\n\nimport { getFilePrefix } from '../../utilities/getFilePrefix.js'\nimport getRangeFromHeader from '../../utilities/getRangeFromHeader.js'\n\ninterface Args {\n collection: CollectionConfig\n getStorageClient: () => ContainerClient\n}\n\nexport const getHandler = ({ collection, getStorageClient }: Args): StaticHandler => {\n return async (req, { params: { filename } }) => {\n try {\n const prefix = await getFilePrefix({ collection, filename, req })\n const blockBlobClient = getStorageClient().getBlockBlobClient(\n path.posix.join(prefix, filename),\n )\n\n const { end, start } = await getRangeFromHeader(blockBlobClient, req.headers.get('range'))\n\n const blob = await blockBlobClient.download(start, end)\n // eslint-disable-next-line no-underscore-dangle\n const response = blob._response\n\n // Manually create a ReadableStream for the web from a Node.js stream.\n const readableStream = new ReadableStream({\n start(controller) {\n const nodeStream = blob.readableStreamBody\n nodeStream.on('data', (chunk) => {\n controller.enqueue(new Uint8Array(chunk))\n })\n nodeStream.on('end', () => {\n controller.close()\n })\n nodeStream.on('error', (err) => {\n controller.error(err)\n })\n },\n })\n\n return new Response(readableStream, {\n headers: response.headers.rawHeaders(),\n status: response.status,\n })\n } catch (err: unknown) {\n req.payload.logger.error(err)\n return new Response('Internal Server Error', { status: 500 })\n }\n }\n}\n"],"names":["path","getFilePrefix","getRangeFromHeader","getHandler","collection","getStorageClient","req","params","filename","prefix","blockBlobClient","getBlockBlobClient","posix","join","end","start","headers","get","blob","download","response","_response","readableStream","ReadableStream","controller","nodeStream","readableStreamBody","on","chunk","enqueue","Uint8Array","close","err","error","Response","rawHeaders","status","payload","logger"],"mappings":"AAGA,OAAOA,UAAU,OAAM;AAIvB,SAASC,aAAa,QAAQ,mCAAkC;AAChE,OAAOC,wBAAwB,wCAAuC;AAOtE,OAAO,MAAMC,aAAa,CAAC,EAAEC,UAAU,EAAEC,gBAAgB,EAAQ;IAC/D,OAAO,OAAOC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,EAAE;QACzC,IAAI;YACF,MAAMC,SAAS,MAAMR,cAAc;gBAAEG;gBAAYI;gBAAUF;YAAI;YAC/D,MAAMI,kBAAkBL,mBAAmBM,kBAAkB,CAC3DX,KAAKY,KAAK,CAACC,IAAI,CAACJ,QAAQD;YAG1B,MAAM,EAAEM,GAAG,EAAEC,KAAK,EAAE,GAAG,MAAMb,mBAAmBQ,iBAAiBJ,IAAIU,OAAO,CAACC,GAAG,CAAC;YAEjF,MAAMC,OAAO,MAAMR,gBAAgBS,QAAQ,CAACJ,OAAOD;YACnD,gDAAgD;YAChD,MAAMM,WAAWF,KAAKG,SAAS;YAE/B,sEAAsE;YACtE,MAAMC,iBAAiB,IAAIC,eAAe;gBACxCR,OAAMS,UAAU;oBACd,MAAMC,aAAaP,KAAKQ,kBAAkB;oBAC1CD,WAAWE,EAAE,CAAC,QAAQ,CAACC;wBACrBJ,WAAWK,OAAO,CAAC,IAAIC,WAAWF;oBACpC;oBACAH,WAAWE,EAAE,CAAC,OAAO;wBACnBH,WAAWO,KAAK;oBAClB;oBACAN,WAAWE,EAAE,CAAC,SAAS,CAACK;wBACtBR,WAAWS,KAAK,CAACD;oBACnB;gBACF;YACF;YAEA,OAAO,IAAIE,SAASZ,gBAAgB;gBAClCN,SAASI,SAASJ,OAAO,CAACmB,UAAU;gBACpCC,QAAQhB,SAASgB,MAAM;YACzB;QACF,EAAE,OAAOJ,KAAc;YACrB1B,IAAI+B,OAAO,CAACC,MAAM,CAACL,KAAK,CAACD;YACzB,OAAO,IAAIE,SAAS,yBAAyB;gBAAEE,QAAQ;YAAI;QAC7D;IACF;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/gcs/generateURL.ts"],"sourcesContent":["import type { Storage } from '@google-cloud/storage'\n\nimport path from 'path'\n\nimport type { GenerateURL } from '../../types.js'\n\ninterface Args {\n bucket: string\n getStorageClient: () => Storage\n}\n\nexport const getGenerateURL =\n ({ bucket, getStorageClient }: Args): GenerateURL =>\n ({ filename, prefix = '' }) => {\n return decodeURIComponent(\n getStorageClient().bucket(bucket).file(path.posix.join(prefix, filename)).publicUrl(),\n )\n }\n"],"names":["path","getGenerateURL","bucket","getStorageClient","filename","prefix","decodeURIComponent","file","posix","join","publicUrl"],"rangeMappings":";;;","mappings":"AAEA,OAAOA,UAAU,OAAM;AASvB,OAAO,MAAMC,iBACX,CAAC,EAAEC,MAAM,EAAEC,gBAAgB,EAAQ,GACnC,CAAC,EAAEC,QAAQ,EAAEC,SAAS,EAAE,EAAE;QACxB,OAAOC,mBACLH,mBAAmBD,MAAM,CAACA,QAAQK,IAAI,CAACP,KAAKQ,KAAK,CAACC,IAAI,CAACJ,QAAQD,WAAWM,SAAS;IAEvF,EAAC"}
1
+ {"version":3,"sources":["../../../src/adapters/gcs/generateURL.ts"],"sourcesContent":["import type { Storage } from '@google-cloud/storage'\n\nimport path from 'path'\n\nimport type { GenerateURL } from '../../types.js'\n\ninterface Args {\n bucket: string\n getStorageClient: () => Storage\n}\n\nexport const getGenerateURL =\n ({ bucket, getStorageClient }: Args): GenerateURL =>\n ({ filename, prefix = '' }) => {\n return decodeURIComponent(\n getStorageClient().bucket(bucket).file(path.posix.join(prefix, filename)).publicUrl(),\n )\n }\n"],"names":["path","getGenerateURL","bucket","getStorageClient","filename","prefix","decodeURIComponent","file","posix","join","publicUrl"],"mappings":"AAEA,OAAOA,UAAU,OAAM;AASvB,OAAO,MAAMC,iBACX,CAAC,EAAEC,MAAM,EAAEC,gBAAgB,EAAQ,GACnC,CAAC,EAAEC,QAAQ,EAAEC,SAAS,EAAE,EAAE;QACxB,OAAOC,mBACLH,mBAAmBD,MAAM,CAACA,QAAQK,IAAI,CAACP,KAAKQ,KAAK,CAACC,IAAI,CAACJ,QAAQD,WAAWM,SAAS;IAEvF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/gcs/handleDelete.ts"],"sourcesContent":["import type { Storage } from '@google-cloud/storage'\n\nimport path from 'path'\n\nimport type { HandleDelete } from '../../types.js'\n\ninterface Args {\n bucket: string\n getStorageClient: () => Storage\n}\n\nexport const getHandleDelete = ({ bucket, getStorageClient }: Args): HandleDelete => {\n return async ({ doc: { prefix = '' }, filename }) => {\n await getStorageClient().bucket(bucket).file(path.posix.join(prefix, filename)).delete({\n ignoreNotFound: true,\n })\n }\n}\n"],"names":["path","getHandleDelete","bucket","getStorageClient","doc","prefix","filename","file","posix","join","delete","ignoreNotFound"],"rangeMappings":";;;;;;;","mappings":"AAEA,OAAOA,UAAU,OAAM;AASvB,OAAO,MAAMC,kBAAkB,CAAC,EAAEC,MAAM,EAAEC,gBAAgB,EAAQ;IAChE,OAAO,OAAO,EAAEC,KAAK,EAAEC,SAAS,EAAE,EAAE,EAAEC,QAAQ,EAAE;QAC9C,MAAMH,mBAAmBD,MAAM,CAACA,QAAQK,IAAI,CAACP,KAAKQ,KAAK,CAACC,IAAI,CAACJ,QAAQC,WAAWI,MAAM,CAAC;YACrFC,gBAAgB;QAClB;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/adapters/gcs/handleDelete.ts"],"sourcesContent":["import type { Storage } from '@google-cloud/storage'\n\nimport path from 'path'\n\nimport type { HandleDelete } from '../../types.js'\n\ninterface Args {\n bucket: string\n getStorageClient: () => Storage\n}\n\nexport const getHandleDelete = ({ bucket, getStorageClient }: Args): HandleDelete => {\n return async ({ doc: { prefix = '' }, filename }) => {\n await getStorageClient().bucket(bucket).file(path.posix.join(prefix, filename)).delete({\n ignoreNotFound: true,\n })\n }\n}\n"],"names":["path","getHandleDelete","bucket","getStorageClient","doc","prefix","filename","file","posix","join","delete","ignoreNotFound"],"mappings":"AAEA,OAAOA,UAAU,OAAM;AASvB,OAAO,MAAMC,kBAAkB,CAAC,EAAEC,MAAM,EAAEC,gBAAgB,EAAQ;IAChE,OAAO,OAAO,EAAEC,KAAK,EAAEC,SAAS,EAAE,EAAE,EAAEC,QAAQ,EAAE;QAC9C,MAAMH,mBAAmBD,MAAM,CAACA,QAAQK,IAAI,CAACP,KAAKQ,KAAK,CAACC,IAAI,CAACJ,QAAQC,WAAWI,MAAM,CAAC;YACrFC,gBAAgB;QAClB;IACF;AACF,EAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { Storage } from '@google-cloud/storage';
2
- import type { CollectionConfig } from 'payload/types';
2
+ import type { CollectionConfig } from 'payload';
3
3
  import type { HandleUpload } from '../../types.js';
4
4
  interface Args {
5
5
  acl?: 'Private' | 'Public';
@@ -1 +1 @@
1
- {"version":3,"file":"handleUpload.d.ts","sourceRoot":"","sources":["../../../src/adapters/gcs/handleUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAIrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,UAAU,IAAI;IACZ,GAAG,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,gBAAgB,CAAA;IAC5B,gBAAgB,EAAE,MAAM,OAAO,CAAA;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,eAAO,MAAM,eAAe,+CAKzB,IAAI,KAAG,YAiBT,CAAA"}
1
+ {"version":3,"file":"handleUpload.d.ts","sourceRoot":"","sources":["../../../src/adapters/gcs/handleUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAI/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,UAAU,IAAI;IACZ,GAAG,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,gBAAgB,CAAA;IAC5B,gBAAgB,EAAE,MAAM,OAAO,CAAA;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,eAAO,MAAM,eAAe,+CAKzB,IAAI,KAAG,YAiBT,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/gcs/handleUpload.ts"],"sourcesContent":["import type { Storage } from '@google-cloud/storage'\nimport type { CollectionConfig } from 'payload/types'\n\nimport path from 'path'\n\nimport type { HandleUpload } from '../../types.js'\n\ninterface Args {\n acl?: 'Private' | 'Public'\n bucket: string\n collection: CollectionConfig\n getStorageClient: () => Storage\n prefix?: string\n}\n\nexport const getHandleUpload = ({\n acl,\n bucket,\n getStorageClient,\n prefix = '',\n}: Args): HandleUpload => {\n return async ({ data, file }) => {\n const fileKey = path.posix.join(data.prefix || prefix, file.filename)\n\n const gcsFile = getStorageClient().bucket(bucket).file(fileKey)\n await gcsFile.save(file.buffer, {\n metadata: {\n contentType: file.mimeType,\n },\n })\n\n if (acl) {\n await gcsFile[`make${acl}`]()\n }\n\n return data\n }\n}\n"],"names":["path","getHandleUpload","acl","bucket","getStorageClient","prefix","data","file","fileKey","posix","join","filename","gcsFile","save","buffer","metadata","contentType","mimeType"],"rangeMappings":";;;;;;;;;;;;;;;","mappings":"AAGA,OAAOA,UAAU,OAAM;AAYvB,OAAO,MAAMC,kBAAkB,CAAC,EAC9BC,GAAG,EACHC,MAAM,EACNC,gBAAgB,EAChBC,SAAS,EAAE,EACN;IACL,OAAO,OAAO,EAAEC,IAAI,EAAEC,IAAI,EAAE;QAC1B,MAAMC,UAAUR,KAAKS,KAAK,CAACC,IAAI,CAACJ,KAAKD,MAAM,IAAIA,QAAQE,KAAKI,QAAQ;QAEpE,MAAMC,UAAUR,mBAAmBD,MAAM,CAACA,QAAQI,IAAI,CAACC;QACvD,MAAMI,QAAQC,IAAI,CAACN,KAAKO,MAAM,EAAE;YAC9BC,UAAU;gBACRC,aAAaT,KAAKU,QAAQ;YAC5B;QACF;QAEA,IAAIf,KAAK;YACP,MAAMU,OAAO,CAAC,CAAC,IAAI,EAAEV,IAAI,CAAC,CAAC;QAC7B;QAEA,OAAOI;IACT;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/adapters/gcs/handleUpload.ts"],"sourcesContent":["import type { Storage } from '@google-cloud/storage'\nimport type { CollectionConfig } from 'payload'\n\nimport path from 'path'\n\nimport type { HandleUpload } from '../../types.js'\n\ninterface Args {\n acl?: 'Private' | 'Public'\n bucket: string\n collection: CollectionConfig\n getStorageClient: () => Storage\n prefix?: string\n}\n\nexport const getHandleUpload = ({\n acl,\n bucket,\n getStorageClient,\n prefix = '',\n}: Args): HandleUpload => {\n return async ({ data, file }) => {\n const fileKey = path.posix.join(data.prefix || prefix, file.filename)\n\n const gcsFile = getStorageClient().bucket(bucket).file(fileKey)\n await gcsFile.save(file.buffer, {\n metadata: {\n contentType: file.mimeType,\n },\n })\n\n if (acl) {\n await gcsFile[`make${acl}`]()\n }\n\n return data\n }\n}\n"],"names":["path","getHandleUpload","acl","bucket","getStorageClient","prefix","data","file","fileKey","posix","join","filename","gcsFile","save","buffer","metadata","contentType","mimeType"],"mappings":"AAGA,OAAOA,UAAU,OAAM;AAYvB,OAAO,MAAMC,kBAAkB,CAAC,EAC9BC,GAAG,EACHC,MAAM,EACNC,gBAAgB,EAChBC,SAAS,EAAE,EACN;IACL,OAAO,OAAO,EAAEC,IAAI,EAAEC,IAAI,EAAE;QAC1B,MAAMC,UAAUR,KAAKS,KAAK,CAACC,IAAI,CAACJ,KAAKD,MAAM,IAAIA,QAAQE,KAAKI,QAAQ;QAEpE,MAAMC,UAAUR,mBAAmBD,MAAM,CAACA,QAAQI,IAAI,CAACC;QACvD,MAAMI,QAAQC,IAAI,CAACN,KAAKO,MAAM,EAAE;YAC9BC,UAAU;gBACRC,aAAaT,KAAKU,QAAQ;YAC5B;QACF;QAEA,IAAIf,KAAK;YACP,MAAMU,OAAO,CAAC,CAAC,IAAI,EAAEV,IAAI,CAAC,CAAC;QAC7B;QAEA,OAAOI;IACT;AACF,EAAC"}
@@ -5,5 +5,10 @@ export interface Args {
5
5
  bucket: string;
6
6
  options: StorageOptions;
7
7
  }
8
+ /**
9
+ * @deprecated Use [`@payloadcms/storage-gcs`](https://www.npmjs.com/package/@payloadcms/storage-gcs) instead.
10
+ *
11
+ * This adapter has been superceded by `@payloadcms/storage-gcs` and will be removed in Payload 3.0.
12
+ */
8
13
  export declare const gcsAdapter: ({ acl, bucket, options }: Args) => Adapter;
9
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/gcs/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAI3D,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,gBAAgB,CAAA;AAO/D,MAAM,WAAW,IAAI;IACnB,GAAG,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,cAAc,CAAA;CACxB;AAED,eAAO,MAAM,UAAU,6BACM,IAAI,KAAG,OAsCjC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/gcs/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAI3D,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,gBAAgB,CAAA;AAO/D,MAAM,WAAW,IAAI;IACnB,GAAG,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,cAAc,CAAA;CACxB;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,6BACM,IAAI,KAAG,OAuCjC,CAAA"}
@@ -3,7 +3,11 @@ import { getGenerateURL } from './generateURL.js';
3
3
  import { getHandleDelete } from './handleDelete.js';
4
4
  import { getHandleUpload } from './handleUpload.js';
5
5
  import { getHandler } from './staticHandler.js';
6
- export const gcsAdapter = ({ acl, bucket, options })=>({ collection, prefix })=>{
6
+ /**
7
+ * @deprecated Use [`@payloadcms/storage-gcs`](https://www.npmjs.com/package/@payloadcms/storage-gcs) instead.
8
+ *
9
+ * This adapter has been superceded by `@payloadcms/storage-gcs` and will be removed in Payload 3.0.
10
+ */ export const gcsAdapter = ({ acl, bucket, options })=>({ collection, prefix })=>{
7
11
  if (!Storage) {
8
12
  throw new Error('The package @google-cloud/storage is not installed, but is required for the plugin-cloud-storage GCS adapter. Please install it.');
9
13
  }
@@ -22,6 +26,7 @@ export const gcsAdapter = ({ acl, bucket, options })=>({ collection, prefix })=>
22
26
  return storageClient;
23
27
  };
24
28
  return {
29
+ name: 'gcs',
25
30
  generateURL: getGenerateURL({
26
31
  bucket,
27
32
  getStorageClient
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/gcs/index.ts"],"sourcesContent":["import type { StorageOptions } from '@google-cloud/storage'\n\nimport { Storage } from '@google-cloud/storage'\n\nimport type { Adapter, GeneratedAdapter } from '../../types.js'\n\nimport { getGenerateURL } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\n\nexport interface Args {\n acl?: 'Private' | 'Public'\n bucket: string\n options: StorageOptions\n}\n\nexport const gcsAdapter =\n ({ acl, bucket, options }: Args): Adapter =>\n ({ collection, prefix }): GeneratedAdapter => {\n if (!Storage) {\n throw new Error(\n 'The package @google-cloud/storage is not installed, but is required for the plugin-cloud-storage GCS adapter. Please install it.',\n )\n }\n\n let storageClient: Storage | null = null\n\n const getStorageClient = (): Storage => {\n if (storageClient) return storageClient\n try {\n storageClient = new Storage(options)\n } catch (error) {\n if (/is not a constructor$/.test(error.message)) {\n throw new Error(\n 'The package @google-cloud/storage is not installed, but is required for the plugin-cloud-storage GCS adapter. Please install it.',\n )\n }\n // Re-throw other unexpected errors.\n throw error\n }\n return storageClient\n }\n\n return {\n generateURL: getGenerateURL({ bucket, getStorageClient }),\n handleDelete: getHandleDelete({ bucket, getStorageClient }),\n handleUpload: getHandleUpload({\n acl,\n bucket,\n collection,\n getStorageClient,\n prefix,\n }),\n staticHandler: getHandler({ bucket, collection, getStorageClient }),\n }\n }\n"],"names":["Storage","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","gcsAdapter","acl","bucket","options","collection","prefix","Error","storageClient","getStorageClient","error","test","message","generateURL","handleDelete","handleUpload","staticHandler"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,OAAO,QAAQ,wBAAuB;AAI/C,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAQ/C,OAAO,MAAMC,aACX,CAAC,EAAEC,GAAG,EAAEC,MAAM,EAAEC,OAAO,EAAQ,GAC/B,CAAC,EAAEC,UAAU,EAAEC,MAAM,EAAE;QACrB,IAAI,CAACV,SAAS;YACZ,MAAM,IAAIW,MACR;QAEJ;QAEA,IAAIC,gBAAgC;QAEpC,MAAMC,mBAAmB;YACvB,IAAID,eAAe,OAAOA;YAC1B,IAAI;gBACFA,gBAAgB,IAAIZ,QAAQQ;YAC9B,EAAE,OAAOM,OAAO;gBACd,IAAI,wBAAwBC,IAAI,CAACD,MAAME,OAAO,GAAG;oBAC/C,MAAM,IAAIL,MACR;gBAEJ;gBACA,oCAAoC;gBACpC,MAAMG;YACR;YACA,OAAOF;QACT;QAEA,OAAO;YACLK,aAAahB,eAAe;gBAAEM;gBAAQM;YAAiB;YACvDK,cAAchB,gBAAgB;gBAAEK;gBAAQM;YAAiB;YACzDM,cAAchB,gBAAgB;gBAC5BG;gBACAC;gBACAE;gBACAI;gBACAH;YACF;YACAU,eAAehB,WAAW;gBAAEG;gBAAQE;gBAAYI;YAAiB;QACnE;IACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/adapters/gcs/index.ts"],"sourcesContent":["import type { StorageOptions } from '@google-cloud/storage'\n\nimport { Storage } from '@google-cloud/storage'\n\nimport type { Adapter, GeneratedAdapter } from '../../types.js'\n\nimport { getGenerateURL } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\n\nexport interface Args {\n acl?: 'Private' | 'Public'\n bucket: string\n options: StorageOptions\n}\n\n/**\n * @deprecated Use [`@payloadcms/storage-gcs`](https://www.npmjs.com/package/@payloadcms/storage-gcs) instead.\n *\n * This adapter has been superceded by `@payloadcms/storage-gcs` and will be removed in Payload 3.0.\n */\nexport const gcsAdapter =\n ({ acl, bucket, options }: Args): Adapter =>\n ({ collection, prefix }): GeneratedAdapter => {\n if (!Storage) {\n throw new Error(\n 'The package @google-cloud/storage is not installed, but is required for the plugin-cloud-storage GCS adapter. Please install it.',\n )\n }\n\n let storageClient: Storage | null = null\n\n const getStorageClient = (): Storage => {\n if (storageClient) return storageClient\n try {\n storageClient = new Storage(options)\n } catch (error) {\n if (/is not a constructor$/.test(error.message)) {\n throw new Error(\n 'The package @google-cloud/storage is not installed, but is required for the plugin-cloud-storage GCS adapter. Please install it.',\n )\n }\n // Re-throw other unexpected errors.\n throw error\n }\n return storageClient\n }\n\n return {\n name: 'gcs',\n generateURL: getGenerateURL({ bucket, getStorageClient }),\n handleDelete: getHandleDelete({ bucket, getStorageClient }),\n handleUpload: getHandleUpload({\n acl,\n bucket,\n collection,\n getStorageClient,\n prefix,\n }),\n staticHandler: getHandler({ bucket, collection, getStorageClient }),\n }\n }\n"],"names":["Storage","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","gcsAdapter","acl","bucket","options","collection","prefix","Error","storageClient","getStorageClient","error","test","message","name","generateURL","handleDelete","handleUpload","staticHandler"],"mappings":"AAEA,SAASA,OAAO,QAAQ,wBAAuB;AAI/C,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAQ/C;;;;CAIC,GACD,OAAO,MAAMC,aACX,CAAC,EAAEC,GAAG,EAAEC,MAAM,EAAEC,OAAO,EAAQ,GAC/B,CAAC,EAAEC,UAAU,EAAEC,MAAM,EAAE;QACrB,IAAI,CAACV,SAAS;YACZ,MAAM,IAAIW,MACR;QAEJ;QAEA,IAAIC,gBAAgC;QAEpC,MAAMC,mBAAmB;YACvB,IAAID,eAAe,OAAOA;YAC1B,IAAI;gBACFA,gBAAgB,IAAIZ,QAAQQ;YAC9B,EAAE,OAAOM,OAAO;gBACd,IAAI,wBAAwBC,IAAI,CAACD,MAAME,OAAO,GAAG;oBAC/C,MAAM,IAAIL,MACR;gBAEJ;gBACA,oCAAoC;gBACpC,MAAMG;YACR;YACA,OAAOF;QACT;QAEA,OAAO;YACLK,MAAM;YACNC,aAAajB,eAAe;gBAAEM;gBAAQM;YAAiB;YACvDM,cAAcjB,gBAAgB;gBAAEK;gBAAQM;YAAiB;YACzDO,cAAcjB,gBAAgB;gBAC5BG;gBACAC;gBACAE;gBACAI;gBACAH;YACF;YACAW,eAAejB,WAAW;gBAAEG;gBAAQE;gBAAYI;YAAiB;QACnE;IACF,EAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { Storage } from '@google-cloud/storage';
2
- import type { CollectionConfig } from 'payload/types';
2
+ import type { CollectionConfig } from 'payload';
3
3
  import type { StaticHandler } from '../../types.js';
4
4
  interface Args {
5
5
  bucket: string;
@@ -1 +1 @@
1
- {"version":3,"file":"staticHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/gcs/staticHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAIrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAInD,UAAU,IAAI;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,gBAAgB,CAAA;IAC5B,gBAAgB,EAAE,MAAM,OAAO,CAAA;CAChC;AAED,eAAO,MAAM,UAAU,6CAA8C,IAAI,KAAG,aAqC3E,CAAA"}
1
+ {"version":3,"file":"staticHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/gcs/staticHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAI/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAInD,UAAU,IAAI;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,gBAAgB,CAAA;IAC5B,gBAAgB,EAAE,MAAM,OAAO,CAAA;CAChC;AAED,eAAO,MAAM,UAAU,6CAA8C,IAAI,KAAG,aAqC3E,CAAA"}
@@ -1,13 +1,14 @@
1
1
  import path from 'path';
2
2
  import { getFilePrefix } from '../../utilities/getFilePrefix.js';
3
3
  export const getHandler = ({ bucket, collection, getStorageClient })=>{
4
- return async (req, { params })=>{
4
+ return async (req, { params: { filename } })=>{
5
5
  try {
6
6
  const prefix = await getFilePrefix({
7
7
  collection,
8
+ filename,
8
9
  req
9
10
  });
10
- const file = getStorageClient().bucket(bucket).file(path.posix.join(prefix, params.filename));
11
+ const file = getStorageClient().bucket(bucket).file(path.posix.join(prefix, filename));
11
12
  const [metadata] = await file.getMetadata();
12
13
  // Manually create a ReadableStream for the web from a Node.js stream.
13
14
  const readableStream = new ReadableStream({
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/gcs/staticHandler.ts"],"sourcesContent":["import type { Storage } from '@google-cloud/storage'\nimport type { CollectionConfig } from 'payload/types'\n\nimport path from 'path'\n\nimport type { StaticHandler } from '../../types.js'\n\nimport { getFilePrefix } from '../../utilities/getFilePrefix.js'\n\ninterface Args {\n bucket: string\n collection: CollectionConfig\n getStorageClient: () => Storage\n}\n\nexport const getHandler = ({ bucket, collection, getStorageClient }: Args): StaticHandler => {\n return async (req, { params }) => {\n try {\n const prefix = await getFilePrefix({ collection, req })\n const file = getStorageClient().bucket(bucket).file(path.posix.join(prefix, params.filename))\n\n const [metadata] = await file.getMetadata()\n\n // Manually create a ReadableStream for the web from a Node.js stream.\n const readableStream = new ReadableStream({\n start(controller) {\n const nodeStream = file.createReadStream()\n nodeStream.on('data', (chunk) => {\n controller.enqueue(new Uint8Array(chunk))\n })\n nodeStream.on('end', () => {\n controller.close()\n })\n nodeStream.on('error', (err) => {\n controller.error(err)\n })\n },\n })\n\n return new Response(readableStream, {\n headers: new Headers({\n 'Content-Length': String(metadata.size),\n 'Content-Type': metadata.contentType,\n ETag: metadata.etag,\n }),\n status: 200,\n })\n } catch (err: unknown) {\n req.payload.logger.error(err)\n return new Response('Internal Server Error', { status: 500 })\n }\n }\n}\n"],"names":["path","getFilePrefix","getHandler","bucket","collection","getStorageClient","req","params","prefix","file","posix","join","filename","metadata","getMetadata","readableStream","ReadableStream","start","controller","nodeStream","createReadStream","on","chunk","enqueue","Uint8Array","close","err","error","Response","headers","Headers","String","size","contentType","ETag","etag","status","payload","logger"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,OAAOA,UAAU,OAAM;AAIvB,SAASC,aAAa,QAAQ,mCAAkC;AAQhE,OAAO,MAAMC,aAAa,CAAC,EAAEC,MAAM,EAAEC,UAAU,EAAEC,gBAAgB,EAAQ;IACvE,OAAO,OAAOC,KAAK,EAAEC,MAAM,EAAE;QAC3B,IAAI;YACF,MAAMC,SAAS,MAAMP,cAAc;gBAAEG;gBAAYE;YAAI;YACrD,MAAMG,OAAOJ,mBAAmBF,MAAM,CAACA,QAAQM,IAAI,CAACT,KAAKU,KAAK,CAACC,IAAI,CAACH,QAAQD,OAAOK,QAAQ;YAE3F,MAAM,CAACC,SAAS,GAAG,MAAMJ,KAAKK,WAAW;YAEzC,sEAAsE;YACtE,MAAMC,iBAAiB,IAAIC,eAAe;gBACxCC,OAAMC,UAAU;oBACd,MAAMC,aAAaV,KAAKW,gBAAgB;oBACxCD,WAAWE,EAAE,CAAC,QAAQ,CAACC;wBACrBJ,WAAWK,OAAO,CAAC,IAAIC,WAAWF;oBACpC;oBACAH,WAAWE,EAAE,CAAC,OAAO;wBACnBH,WAAWO,KAAK;oBAClB;oBACAN,WAAWE,EAAE,CAAC,SAAS,CAACK;wBACtBR,WAAWS,KAAK,CAACD;oBACnB;gBACF;YACF;YAEA,OAAO,IAAIE,SAASb,gBAAgB;gBAClCc,SAAS,IAAIC,QAAQ;oBACnB,kBAAkBC,OAAOlB,SAASmB,IAAI;oBACtC,gBAAgBnB,SAASoB,WAAW;oBACpCC,MAAMrB,SAASsB,IAAI;gBACrB;gBACAC,QAAQ;YACV;QACF,EAAE,OAAOV,KAAc;YACrBpB,IAAI+B,OAAO,CAACC,MAAM,CAACX,KAAK,CAACD;YACzB,OAAO,IAAIE,SAAS,yBAAyB;gBAAEQ,QAAQ;YAAI;QAC7D;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/adapters/gcs/staticHandler.ts"],"sourcesContent":["import type { Storage } from '@google-cloud/storage'\nimport type { CollectionConfig } from 'payload'\n\nimport path from 'path'\n\nimport type { StaticHandler } from '../../types.js'\n\nimport { getFilePrefix } from '../../utilities/getFilePrefix.js'\n\ninterface Args {\n bucket: string\n collection: CollectionConfig\n getStorageClient: () => Storage\n}\n\nexport const getHandler = ({ bucket, collection, getStorageClient }: Args): StaticHandler => {\n return async (req, { params: { filename } }) => {\n try {\n const prefix = await getFilePrefix({ collection, filename, req })\n const file = getStorageClient().bucket(bucket).file(path.posix.join(prefix, filename))\n\n const [metadata] = await file.getMetadata()\n\n // Manually create a ReadableStream for the web from a Node.js stream.\n const readableStream = new ReadableStream({\n start(controller) {\n const nodeStream = file.createReadStream()\n nodeStream.on('data', (chunk) => {\n controller.enqueue(new Uint8Array(chunk))\n })\n nodeStream.on('end', () => {\n controller.close()\n })\n nodeStream.on('error', (err) => {\n controller.error(err)\n })\n },\n })\n\n return new Response(readableStream, {\n headers: new Headers({\n 'Content-Length': String(metadata.size),\n 'Content-Type': metadata.contentType,\n ETag: metadata.etag,\n }),\n status: 200,\n })\n } catch (err: unknown) {\n req.payload.logger.error(err)\n return new Response('Internal Server Error', { status: 500 })\n }\n }\n}\n"],"names":["path","getFilePrefix","getHandler","bucket","collection","getStorageClient","req","params","filename","prefix","file","posix","join","metadata","getMetadata","readableStream","ReadableStream","start","controller","nodeStream","createReadStream","on","chunk","enqueue","Uint8Array","close","err","error","Response","headers","Headers","String","size","contentType","ETag","etag","status","payload","logger"],"mappings":"AAGA,OAAOA,UAAU,OAAM;AAIvB,SAASC,aAAa,QAAQ,mCAAkC;AAQhE,OAAO,MAAMC,aAAa,CAAC,EAAEC,MAAM,EAAEC,UAAU,EAAEC,gBAAgB,EAAQ;IACvE,OAAO,OAAOC,KAAK,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,EAAE;QACzC,IAAI;YACF,MAAMC,SAAS,MAAMR,cAAc;gBAAEG;gBAAYI;gBAAUF;YAAI;YAC/D,MAAMI,OAAOL,mBAAmBF,MAAM,CAACA,QAAQO,IAAI,CAACV,KAAKW,KAAK,CAACC,IAAI,CAACH,QAAQD;YAE5E,MAAM,CAACK,SAAS,GAAG,MAAMH,KAAKI,WAAW;YAEzC,sEAAsE;YACtE,MAAMC,iBAAiB,IAAIC,eAAe;gBACxCC,OAAMC,UAAU;oBACd,MAAMC,aAAaT,KAAKU,gBAAgB;oBACxCD,WAAWE,EAAE,CAAC,QAAQ,CAACC;wBACrBJ,WAAWK,OAAO,CAAC,IAAIC,WAAWF;oBACpC;oBACAH,WAAWE,EAAE,CAAC,OAAO;wBACnBH,WAAWO,KAAK;oBAClB;oBACAN,WAAWE,EAAE,CAAC,SAAS,CAACK;wBACtBR,WAAWS,KAAK,CAACD;oBACnB;gBACF;YACF;YAEA,OAAO,IAAIE,SAASb,gBAAgB;gBAClCc,SAAS,IAAIC,QAAQ;oBACnB,kBAAkBC,OAAOlB,SAASmB,IAAI;oBACtC,gBAAgBnB,SAASoB,WAAW;oBACpCC,MAAMrB,SAASsB,IAAI;gBACrB;gBACAC,QAAQ;YACV;QACF,EAAE,OAAOV,KAAc;YACrBpB,IAAI+B,OAAO,CAACC,MAAM,CAACX,KAAK,CAACD;YACzB,OAAO,IAAIE,SAAS,yBAAyB;gBAAEQ,QAAQ;YAAI;QAC7D;IACF;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/s3/generateURL.ts"],"sourcesContent":["import type * as AWS from '@aws-sdk/client-s3'\n\nimport path from 'path'\n\nimport type { GenerateURL } from '../../types.js'\n\ninterface Args {\n bucket: string\n config: AWS.S3ClientConfig\n}\n\nexport const getGenerateURL =\n ({ bucket, config: { endpoint } }: Args): GenerateURL =>\n ({ filename, prefix = '' }) => {\n return `${endpoint}/${bucket}/${path.posix.join(prefix, filename)}`\n }\n"],"names":["path","getGenerateURL","bucket","config","endpoint","filename","prefix","posix","join"],"rangeMappings":";;;","mappings":"AAEA,OAAOA,UAAU,OAAM;AASvB,OAAO,MAAMC,iBACX,CAAC,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,EAAQ,GACvC,CAAC,EAAEC,QAAQ,EAAEC,SAAS,EAAE,EAAE;QACxB,OAAO,CAAC,EAAEF,SAAS,CAAC,EAAEF,OAAO,CAAC,EAAEF,KAAKO,KAAK,CAACC,IAAI,CAACF,QAAQD,UAAU,CAAC;IACrE,EAAC"}
1
+ {"version":3,"sources":["../../../src/adapters/s3/generateURL.ts"],"sourcesContent":["import type * as AWS from '@aws-sdk/client-s3'\n\nimport path from 'path'\n\nimport type { GenerateURL } from '../../types.js'\n\ninterface Args {\n bucket: string\n config: AWS.S3ClientConfig\n}\n\nexport const getGenerateURL =\n ({ bucket, config: { endpoint } }: Args): GenerateURL =>\n ({ filename, prefix = '' }) => {\n return `${endpoint}/${bucket}/${path.posix.join(prefix, filename)}`\n }\n"],"names":["path","getGenerateURL","bucket","config","endpoint","filename","prefix","posix","join"],"mappings":"AAEA,OAAOA,UAAU,OAAM;AASvB,OAAO,MAAMC,iBACX,CAAC,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,EAAQ,GACvC,CAAC,EAAEC,QAAQ,EAAEC,SAAS,EAAE,EAAE;QACxB,OAAO,CAAC,EAAEF,SAAS,CAAC,EAAEF,OAAO,CAAC,EAAEF,KAAKO,KAAK,CAACC,IAAI,CAACF,QAAQD,UAAU,CAAC;IACrE,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/s3/handleDelete.ts"],"sourcesContent":["import type * as AWS from '@aws-sdk/client-s3'\n\nimport path from 'path'\n\nimport type { HandleDelete } from '../../types.js'\n\ninterface Args {\n bucket: string\n getStorageClient: () => AWS.S3\n}\n\nexport const getHandleDelete = ({ bucket, getStorageClient }: Args): HandleDelete => {\n return async ({ doc: { prefix = '' }, filename }) => {\n await getStorageClient().deleteObject({\n Bucket: bucket,\n Key: path.posix.join(prefix, filename),\n })\n }\n}\n"],"names":["path","getHandleDelete","bucket","getStorageClient","doc","prefix","filename","deleteObject","Bucket","Key","posix","join"],"rangeMappings":";;;;;;;;","mappings":"AAEA,OAAOA,UAAU,OAAM;AASvB,OAAO,MAAMC,kBAAkB,CAAC,EAAEC,MAAM,EAAEC,gBAAgB,EAAQ;IAChE,OAAO,OAAO,EAAEC,KAAK,EAAEC,SAAS,EAAE,EAAE,EAAEC,QAAQ,EAAE;QAC9C,MAAMH,mBAAmBI,YAAY,CAAC;YACpCC,QAAQN;YACRO,KAAKT,KAAKU,KAAK,CAACC,IAAI,CAACN,QAAQC;QAC/B;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/adapters/s3/handleDelete.ts"],"sourcesContent":["import type * as AWS from '@aws-sdk/client-s3'\n\nimport path from 'path'\n\nimport type { HandleDelete } from '../../types.js'\n\ninterface Args {\n bucket: string\n getStorageClient: () => AWS.S3\n}\n\nexport const getHandleDelete = ({ bucket, getStorageClient }: Args): HandleDelete => {\n return async ({ doc: { prefix = '' }, filename }) => {\n await getStorageClient().deleteObject({\n Bucket: bucket,\n Key: path.posix.join(prefix, filename),\n })\n }\n}\n"],"names":["path","getHandleDelete","bucket","getStorageClient","doc","prefix","filename","deleteObject","Bucket","Key","posix","join"],"mappings":"AAEA,OAAOA,UAAU,OAAM;AASvB,OAAO,MAAMC,kBAAkB,CAAC,EAAEC,MAAM,EAAEC,gBAAgB,EAAQ;IAChE,OAAO,OAAO,EAAEC,KAAK,EAAEC,SAAS,EAAE,EAAE,EAAEC,QAAQ,EAAE;QAC9C,MAAMH,mBAAmBI,YAAY,CAAC;YACpCC,QAAQN;YACRO,KAAKT,KAAKU,KAAK,CAACC,IAAI,CAACN,QAAQC;QAC/B;IACF;AACF,EAAC"}
@@ -1,5 +1,5 @@
1
1
  import type * as AWS from '@aws-sdk/client-s3';
2
- import type { CollectionConfig } from 'payload/types';
2
+ import type { CollectionConfig } from 'payload';
3
3
  import type { HandleUpload } from '../../types.js';
4
4
  interface Args {
5
5
  acl?: 'private' | 'public-read';
@@ -1 +1 @@
1
- {"version":3,"file":"handleUpload.d.ts","sourceRoot":"","sources":["../../../src/adapters/s3/handleUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,oBAAoB,CAAA;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAOrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,UAAU,IAAI;IACZ,GAAG,CAAC,EAAE,SAAS,GAAG,aAAa,CAAA;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,gBAAgB,CAAA;IAC5B,gBAAgB,EAAE,MAAM,GAAG,CAAC,EAAE,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAID,eAAO,MAAM,eAAe,+CAKzB,IAAI,KAAG,YAqCT,CAAA"}
1
+ {"version":3,"file":"handleUpload.d.ts","sourceRoot":"","sources":["../../../src/adapters/s3/handleUpload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,oBAAoB,CAAA;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAO/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,UAAU,IAAI;IACZ,GAAG,CAAC,EAAE,SAAS,GAAG,aAAa,CAAA;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,gBAAgB,CAAA;IAC5B,gBAAgB,EAAE,MAAM,GAAG,CAAC,EAAE,CAAA;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAID,eAAO,MAAM,eAAe,+CAKzB,IAAI,KAAG,YAqCT,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/s3/handleUpload.ts"],"sourcesContent":["import type * as AWS from '@aws-sdk/client-s3'\nimport type { CollectionConfig } from 'payload/types'\nimport type stream from 'stream'\n\nimport { Upload } from '@aws-sdk/lib-storage'\nimport fs from 'fs'\nimport path from 'path'\n\nimport type { HandleUpload } from '../../types.js'\n\ninterface Args {\n acl?: 'private' | 'public-read'\n bucket: string\n collection: CollectionConfig\n getStorageClient: () => AWS.S3\n prefix?: string\n}\n\nconst multipartThreshold = 1024 * 1024 * 50 // 50MB\n\nexport const getHandleUpload = ({\n acl,\n bucket,\n getStorageClient,\n prefix = '',\n}: Args): HandleUpload => {\n return async ({ data, file }) => {\n const fileKey = path.posix.join(data.prefix || prefix, file.filename)\n\n const fileBufferOrStream: Buffer | stream.Readable = file.tempFilePath\n ? fs.createReadStream(file.tempFilePath)\n : file.buffer\n\n if (file.buffer.length > 0 && file.buffer.length < multipartThreshold) {\n await getStorageClient().putObject({\n ACL: acl,\n Body: fileBufferOrStream,\n Bucket: bucket,\n ContentType: file.mimeType,\n Key: fileKey,\n })\n\n return data\n }\n\n const parallelUploadS3 = new Upload({\n client: getStorageClient(),\n params: {\n ACL: acl,\n Body: fileBufferOrStream,\n Bucket: bucket,\n ContentType: file.mimeType,\n Key: fileKey,\n },\n partSize: multipartThreshold,\n queueSize: 4,\n })\n\n await parallelUploadS3.done()\n\n return data\n }\n}\n"],"names":["Upload","fs","path","multipartThreshold","getHandleUpload","acl","bucket","getStorageClient","prefix","data","file","fileKey","posix","join","filename","fileBufferOrStream","tempFilePath","createReadStream","buffer","length","putObject","ACL","Body","Bucket","ContentType","mimeType","Key","parallelUploadS3","client","params","partSize","queueSize","done"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,MAAM,QAAQ,uBAAsB;AAC7C,OAAOC,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AAYvB,MAAMC,qBAAqB,OAAO,OAAO,GAAG,OAAO;;AAEnD,OAAO,MAAMC,kBAAkB,CAAC,EAC9BC,GAAG,EACHC,MAAM,EACNC,gBAAgB,EAChBC,SAAS,EAAE,EACN;IACL,OAAO,OAAO,EAAEC,IAAI,EAAEC,IAAI,EAAE;QAC1B,MAAMC,UAAUT,KAAKU,KAAK,CAACC,IAAI,CAACJ,KAAKD,MAAM,IAAIA,QAAQE,KAAKI,QAAQ;QAEpE,MAAMC,qBAA+CL,KAAKM,YAAY,GAClEf,GAAGgB,gBAAgB,CAACP,KAAKM,YAAY,IACrCN,KAAKQ,MAAM;QAEf,IAAIR,KAAKQ,MAAM,CAACC,MAAM,GAAG,KAAKT,KAAKQ,MAAM,CAACC,MAAM,GAAGhB,oBAAoB;YACrE,MAAMI,mBAAmBa,SAAS,CAAC;gBACjCC,KAAKhB;gBACLiB,MAAMP;gBACNQ,QAAQjB;gBACRkB,aAAad,KAAKe,QAAQ;gBAC1BC,KAAKf;YACP;YAEA,OAAOF;QACT;QAEA,MAAMkB,mBAAmB,IAAI3B,OAAO;YAClC4B,QAAQrB;YACRsB,QAAQ;gBACNR,KAAKhB;gBACLiB,MAAMP;gBACNQ,QAAQjB;gBACRkB,aAAad,KAAKe,QAAQ;gBAC1BC,KAAKf;YACP;YACAmB,UAAU3B;YACV4B,WAAW;QACb;QAEA,MAAMJ,iBAAiBK,IAAI;QAE3B,OAAOvB;IACT;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/adapters/s3/handleUpload.ts"],"sourcesContent":["import type * as AWS from '@aws-sdk/client-s3'\nimport type { CollectionConfig } from 'payload'\nimport type stream from 'stream'\n\nimport { Upload } from '@aws-sdk/lib-storage'\nimport fs from 'fs'\nimport path from 'path'\n\nimport type { HandleUpload } from '../../types.js'\n\ninterface Args {\n acl?: 'private' | 'public-read'\n bucket: string\n collection: CollectionConfig\n getStorageClient: () => AWS.S3\n prefix?: string\n}\n\nconst multipartThreshold = 1024 * 1024 * 50 // 50MB\n\nexport const getHandleUpload = ({\n acl,\n bucket,\n getStorageClient,\n prefix = '',\n}: Args): HandleUpload => {\n return async ({ data, file }) => {\n const fileKey = path.posix.join(data.prefix || prefix, file.filename)\n\n const fileBufferOrStream: Buffer | stream.Readable = file.tempFilePath\n ? fs.createReadStream(file.tempFilePath)\n : file.buffer\n\n if (file.buffer.length > 0 && file.buffer.length < multipartThreshold) {\n await getStorageClient().putObject({\n ACL: acl,\n Body: fileBufferOrStream,\n Bucket: bucket,\n ContentType: file.mimeType,\n Key: fileKey,\n })\n\n return data\n }\n\n const parallelUploadS3 = new Upload({\n client: getStorageClient(),\n params: {\n ACL: acl,\n Body: fileBufferOrStream,\n Bucket: bucket,\n ContentType: file.mimeType,\n Key: fileKey,\n },\n partSize: multipartThreshold,\n queueSize: 4,\n })\n\n await parallelUploadS3.done()\n\n return data\n }\n}\n"],"names":["Upload","fs","path","multipartThreshold","getHandleUpload","acl","bucket","getStorageClient","prefix","data","file","fileKey","posix","join","filename","fileBufferOrStream","tempFilePath","createReadStream","buffer","length","putObject","ACL","Body","Bucket","ContentType","mimeType","Key","parallelUploadS3","client","params","partSize","queueSize","done"],"mappings":"AAIA,SAASA,MAAM,QAAQ,uBAAsB;AAC7C,OAAOC,QAAQ,KAAI;AACnB,OAAOC,UAAU,OAAM;AAYvB,MAAMC,qBAAqB,OAAO,OAAO,GAAG,OAAO;;AAEnD,OAAO,MAAMC,kBAAkB,CAAC,EAC9BC,GAAG,EACHC,MAAM,EACNC,gBAAgB,EAChBC,SAAS,EAAE,EACN;IACL,OAAO,OAAO,EAAEC,IAAI,EAAEC,IAAI,EAAE;QAC1B,MAAMC,UAAUT,KAAKU,KAAK,CAACC,IAAI,CAACJ,KAAKD,MAAM,IAAIA,QAAQE,KAAKI,QAAQ;QAEpE,MAAMC,qBAA+CL,KAAKM,YAAY,GAClEf,GAAGgB,gBAAgB,CAACP,KAAKM,YAAY,IACrCN,KAAKQ,MAAM;QAEf,IAAIR,KAAKQ,MAAM,CAACC,MAAM,GAAG,KAAKT,KAAKQ,MAAM,CAACC,MAAM,GAAGhB,oBAAoB;YACrE,MAAMI,mBAAmBa,SAAS,CAAC;gBACjCC,KAAKhB;gBACLiB,MAAMP;gBACNQ,QAAQjB;gBACRkB,aAAad,KAAKe,QAAQ;gBAC1BC,KAAKf;YACP;YAEA,OAAOF;QACT;QAEA,MAAMkB,mBAAmB,IAAI3B,OAAO;YAClC4B,QAAQrB;YACRsB,QAAQ;gBACNR,KAAKhB;gBACLiB,MAAMP;gBACNQ,QAAQjB;gBACRkB,aAAad,KAAKe,QAAQ;gBAC1BC,KAAKf;YACP;YACAmB,UAAU3B;YACV4B,WAAW;QACb;QAEA,MAAMJ,iBAAiBK,IAAI;QAE3B,OAAOvB;IACT;AACF,EAAC"}
@@ -15,5 +15,10 @@ export interface Args {
15
15
  */
16
16
  config: AWS.S3ClientConfig;
17
17
  }
18
+ /**
19
+ * @deprecated Use [`@payloadcms/storage-s3`](https://www.npmjs.com/package/@payloadcms/storage-s3) instead.
20
+ *
21
+ * This adapter has been superceded by `@payloadcms/storage-s3` and will be removed in Payload 3.0.
22
+ */
18
23
  export declare const s3Adapter: ({ acl, bucket, config }: Args) => Adapter;
19
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/s3/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAA;AAEzC,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,gBAAgB,CAAA;AAO/D,MAAM,WAAW,IAAI;IACnB,GAAG,CAAC,EAAE,SAAS,GAAG,aAAa,CAAA;IAC/B;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,MAAM,EAAE,GAAG,CAAC,cAAc,CAAA;CAC3B;AAED,eAAO,MAAM,SAAS,4BACW,IAAI,KAAG,OAoCrC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/s3/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAA;AAEzC,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,gBAAgB,CAAA;AAO/D,MAAM,WAAW,IAAI;IACnB,GAAG,CAAC,EAAE,SAAS,GAAG,aAAa,CAAA;IAC/B;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,MAAM,EAAE,GAAG,CAAC,cAAc,CAAA;CAC3B;AAED;;;;GAIG;AACH,eAAO,MAAM,SAAS,4BACW,IAAI,KAAG,OAqCrC,CAAA"}