@payloadcms/plugin-cloud-storage 3.0.0-beta.19 → 3.0.0-beta.20
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.
- package/README.md +1 -104
- package/dist/adapters/azure/index.d.ts +5 -0
- package/dist/adapters/azure/index.d.ts.map +1 -1
- package/dist/adapters/azure/index.js +6 -1
- package/dist/adapters/azure/index.js.map +1 -1
- package/dist/adapters/gcs/index.d.ts +5 -0
- package/dist/adapters/gcs/index.d.ts.map +1 -1
- package/dist/adapters/gcs/index.js +6 -1
- package/dist/adapters/gcs/index.js.map +1 -1
- package/dist/adapters/s3/index.d.ts +5 -0
- package/dist/adapters/s3/index.d.ts.map +1 -1
- package/dist/adapters/s3/index.js +6 -1
- package/dist/adapters/s3/index.js.map +1 -1
- package/dist/adapters/vercelBlob/index.d.ts +5 -0
- package/dist/adapters/vercelBlob/index.d.ts.map +1 -1
- package/dist/adapters/vercelBlob/index.js +6 -1
- package/dist/adapters/vercelBlob/index.js.map +1 -1
- package/dist/hooks/afterDelete.js +4 -2
- package/dist/hooks/afterDelete.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +1 -0
- package/dist/plugin.js.map +1 -1
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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
|
-
**NOTE:** If you are using Payload 3.0 and one of the following storage services, you
|
|
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
7
|
| Service | Package |
|
|
8
8
|
| -------------------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
@@ -95,109 +95,6 @@ This plugin is configurable to work across many different Payload collections. A
|
|
|
95
95
|
| `prefix` | `string` | Set to `media/images` to upload files inside `media/images` folder in the bucket. |
|
|
96
96
|
| `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. |
|
|
97
97
|
|
|
98
|
-
### Azure Blob Storage Adapter
|
|
99
|
-
|
|
100
|
-
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`.
|
|
101
|
-
|
|
102
|
-
From there, create the adapter, passing in all of its required properties:
|
|
103
|
-
|
|
104
|
-
```js
|
|
105
|
-
import { azureBlobStorageAdapter } from '@payloadcms/plugin-cloud-storage/azure'
|
|
106
|
-
|
|
107
|
-
const adapter = azureBlobStorageAdapter({
|
|
108
|
-
connectionString: process.env.AZURE_STORAGE_CONNECTION_STRING,
|
|
109
|
-
containerName: process.env.AZURE_STORAGE_CONTAINER_NAME,
|
|
110
|
-
allowContainerCreate: process.env.AZURE_STORAGE_ALLOW_CONTAINER_CREATE === 'true',
|
|
111
|
-
baseURL: process.env.AZURE_STORAGE_ACCOUNT_BASEURL,
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
// Now you can pass this adapter to the plugin
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### S3 Adapter
|
|
118
|
-
|
|
119
|
-
To use the S3 adapter, some peer dependencies need to be installed:
|
|
120
|
-
|
|
121
|
-
`yarn add @aws-sdk/client-s3 @aws-sdk/lib-storage aws-crt`.
|
|
122
|
-
|
|
123
|
-
From there, create the adapter, passing in all of its required properties:
|
|
124
|
-
|
|
125
|
-
```js
|
|
126
|
-
import { s3Adapter } from '@payloadcms/plugin-cloud-storage/s3'
|
|
127
|
-
|
|
128
|
-
const adapter = s3Adapter({
|
|
129
|
-
config: {
|
|
130
|
-
credentials: {
|
|
131
|
-
accessKeyId: process.env.S3_ACCESS_KEY_ID,
|
|
132
|
-
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY,
|
|
133
|
-
},
|
|
134
|
-
region: process.env.S3_REGION,
|
|
135
|
-
// ... Other S3 configuration
|
|
136
|
-
},
|
|
137
|
-
bucket: process.env.S3_BUCKET,
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
// Now you can pass this adapter to the plugin
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
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.
|
|
144
|
-
|
|
145
|
-
Other S3 Client configuration is documented [here](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3/interfaces/s3clientconfig.html).
|
|
146
|
-
|
|
147
|
-
Any upload over 50MB will automatically be uploaded using S3's multi-part upload.
|
|
148
|
-
|
|
149
|
-
#### Other S3-Compatible Storage
|
|
150
|
-
|
|
151
|
-
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.
|
|
152
|
-
|
|
153
|
-
```js
|
|
154
|
-
import { s3Adapter } from '@payloadcms/plugin-cloud-storage/s3'
|
|
155
|
-
|
|
156
|
-
const adapter = s3Adapter({
|
|
157
|
-
config: {
|
|
158
|
-
endpoint: process.env.S3_ENDPOINT, // Configure for your provider
|
|
159
|
-
// ...
|
|
160
|
-
},
|
|
161
|
-
// ...
|
|
162
|
-
})
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
### GCS Adapter
|
|
166
|
-
|
|
167
|
-
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`.
|
|
168
|
-
|
|
169
|
-
From there, create the adapter, passing in all of its required properties:
|
|
170
|
-
|
|
171
|
-
```js
|
|
172
|
-
import { gcsAdapter } from '@payloadcms/plugin-cloud-storage/gcs'
|
|
173
|
-
|
|
174
|
-
const adapter = gcsAdapter({
|
|
175
|
-
options: {
|
|
176
|
-
// you can choose any method for authentication, and authorization which is being provided by `@google-cloud/storage`
|
|
177
|
-
keyFilename: './gcs-credentials.json',
|
|
178
|
-
//OR
|
|
179
|
-
credentials: JSON.parse(process.env.GCS_CREDENTIALS || '{}'), // this env variable will have stringify version of your credentials.json file
|
|
180
|
-
},
|
|
181
|
-
bucket: process.env.GCS_BUCKET,
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
// Now you can pass this adapter to the plugin
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
### Vercel Blob Adapter
|
|
188
|
-
|
|
189
|
-
To use the Vercel Blob adapter, you need to have `@vercel/blob` installed in your project dependencies.
|
|
190
|
-
|
|
191
|
-
```ts
|
|
192
|
-
import { vercelBlobAdapter } from '@payloadcms/plugin-cloud-storage/vercelBlob'
|
|
193
|
-
|
|
194
|
-
const adapter = vercelBlobAdapter({
|
|
195
|
-
token: process.env.BLOB_READ_WRITE_TOKEN || '',
|
|
196
|
-
})
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
Credit to @JarvisPrestidge for the original implementation of this plugin.
|
|
200
|
-
|
|
201
98
|
### Payload Access Control
|
|
202
99
|
|
|
203
100
|
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.
|
|
@@ -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,
|
|
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
|
-
|
|
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":"
|
|
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"],"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;;;;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"}
|
|
@@ -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,
|
|
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
|
-
|
|
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":"
|
|
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"],"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;;;;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"}
|
|
@@ -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,
|
|
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"}
|
|
@@ -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
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Use [`@payloadcms/storage-s3`](https://www.npmjs.com/package/@payloadcms/storage-s3) instead.
|
|
8
|
+
*
|
|
9
|
+
* This adapter has been superceded by `@payloadcms/storage-s3` and will be removed in Payload 3.0.
|
|
10
|
+
*/ export const s3Adapter = ({ acl, bucket, config = {} })=>({ collection, prefix })=>{
|
|
7
11
|
if (!AWS) {
|
|
8
12
|
throw new Error('The packages @aws-sdk/client-s3, @aws-sdk/lib-storage and aws-crt are not installed, but are required for the plugin-cloud-storage S3 adapter. Please install them.');
|
|
9
13
|
}
|
|
@@ -22,6 +26,7 @@ export const s3Adapter = ({ acl, bucket, config = {} })=>({ collection, prefix }
|
|
|
22
26
|
return storageClient;
|
|
23
27
|
};
|
|
24
28
|
return {
|
|
29
|
+
name: 's3',
|
|
25
30
|
generateURL: getGenerateURL({
|
|
26
31
|
bucket,
|
|
27
32
|
config
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/s3/index.ts"],"sourcesContent":["import * as AWS from '@aws-sdk/client-s3'\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-read'\n /**\n * Bucket name to upload files to.\n *\n * Must follow [AWS S3 bucket naming conventions](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html).\n */\n bucket: string\n /**\n * AWS S3 client configuration. Highly dependent on your AWS setup.\n *\n * [AWS.S3ClientConfig Docs](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3/interfaces/s3clientconfig.html)\n */\n config: AWS.S3ClientConfig\n}\n\nexport const s3Adapter =\n ({ acl, bucket, config = {} }: Args): Adapter =>\n ({ collection, prefix }): GeneratedAdapter => {\n if (!AWS) {\n throw new Error(\n 'The packages @aws-sdk/client-s3, @aws-sdk/lib-storage and aws-crt are not installed, but are required for the plugin-cloud-storage S3 adapter. Please install them.',\n )\n }\n let storageClient: AWS.S3 | null = null\n const getStorageClient: () => AWS.S3 = () => {\n if (storageClient) return storageClient\n try {\n storageClient = new AWS.S3(config)\n } catch (error) {\n if (/is not a constructor$/.test(error.message)) {\n throw new Error(\n 'The packages @aws-sdk/client-s3, @aws-sdk/lib-storage and aws-crt are not installed, but are required for the plugin-cloud-storage S3 adapter. Please install them.',\n )\n }\n // Re-throw other unexpected errors.\n throw error\n }\n return storageClient\n }\n\n return {\n generateURL: getGenerateURL({ bucket, config }),\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":["AWS","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","s3Adapter","acl","bucket","config","collection","prefix","Error","storageClient","getStorageClient","S3","error","test","message","generateURL","handleDelete","handleUpload","staticHandler"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/adapters/s3/index.ts"],"sourcesContent":["import * as AWS from '@aws-sdk/client-s3'\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-read'\n /**\n * Bucket name to upload files to.\n *\n * Must follow [AWS S3 bucket naming conventions](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html).\n */\n bucket: string\n /**\n * AWS S3 client configuration. Highly dependent on your AWS setup.\n *\n * [AWS.S3ClientConfig Docs](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3/interfaces/s3clientconfig.html)\n */\n config: AWS.S3ClientConfig\n}\n\n/**\n * @deprecated Use [`@payloadcms/storage-s3`](https://www.npmjs.com/package/@payloadcms/storage-s3) instead.\n *\n * This adapter has been superceded by `@payloadcms/storage-s3` and will be removed in Payload 3.0.\n */\nexport const s3Adapter =\n ({ acl, bucket, config = {} }: Args): Adapter =>\n ({ collection, prefix }): GeneratedAdapter => {\n if (!AWS) {\n throw new Error(\n 'The packages @aws-sdk/client-s3, @aws-sdk/lib-storage and aws-crt are not installed, but are required for the plugin-cloud-storage S3 adapter. Please install them.',\n )\n }\n let storageClient: AWS.S3 | null = null\n const getStorageClient: () => AWS.S3 = () => {\n if (storageClient) return storageClient\n try {\n storageClient = new AWS.S3(config)\n } catch (error) {\n if (/is not a constructor$/.test(error.message)) {\n throw new Error(\n 'The packages @aws-sdk/client-s3, @aws-sdk/lib-storage and aws-crt are not installed, but are required for the plugin-cloud-storage S3 adapter. Please install them.',\n )\n }\n // Re-throw other unexpected errors.\n throw error\n }\n return storageClient\n }\n\n return {\n name: 's3',\n generateURL: getGenerateURL({ bucket, config }),\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":["AWS","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","s3Adapter","acl","bucket","config","collection","prefix","Error","storageClient","getStorageClient","S3","error","test","message","name","generateURL","handleDelete","handleUpload","staticHandler"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,YAAYA,SAAS,qBAAoB;AAIzC,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAkB/C;;;;CAIC,GACD,OAAO,MAAMC,YACX,CAAC,EAAEC,GAAG,EAAEC,MAAM,EAAEC,SAAS,CAAC,CAAC,EAAQ,GACnC,CAAC,EAAEC,UAAU,EAAEC,MAAM,EAAE;QACrB,IAAI,CAACV,KAAK;YACR,MAAM,IAAIW,MACR;QAEJ;QACA,IAAIC,gBAA+B;QACnC,MAAMC,mBAAiC;YACrC,IAAID,eAAe,OAAOA;YAC1B,IAAI;gBACFA,gBAAgB,IAAIZ,IAAIc,EAAE,CAACN;YAC7B,EAAE,OAAOO,OAAO;gBACd,IAAI,wBAAwBC,IAAI,CAACD,MAAME,OAAO,GAAG;oBAC/C,MAAM,IAAIN,MACR;gBAEJ;gBACA,oCAAoC;gBACpC,MAAMI;YACR;YACA,OAAOH;QACT;QAEA,OAAO;YACLM,MAAM;YACNC,aAAalB,eAAe;gBAAEM;gBAAQC;YAAO;YAC7CY,cAAclB,gBAAgB;gBAAEK;gBAAQM;YAAiB;YACzDQ,cAAclB,gBAAgB;gBAC5BG;gBACAC;gBACAE;gBACAI;gBACAH;YACF;YACAY,eAAelB,WAAW;gBAAEG;gBAAQE;gBAAYI;YAAiB;QACnE;IACF,EAAC"}
|
|
@@ -28,5 +28,10 @@ export interface VercelBlobAdapterUploadOptions {
|
|
|
28
28
|
*/
|
|
29
29
|
cacheControlMaxAge?: number;
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated Use [`@payloadcms/storage-vercel-blob`](https://www.npmjs.com/package/@payloadcms/storage-vercel-blob) instead.
|
|
33
|
+
*
|
|
34
|
+
* This adapter has been superceded by `@payloadcms/storage-vercel-blob` and will be removed in Payload 3.0.
|
|
35
|
+
*/
|
|
31
36
|
export declare const vercelBlobAdapter: ({ options, token }: VercelBlobAdapterArgs) => Adapter;
|
|
32
37
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/vercelBlob/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,wCAAwC,CAAA;AAOvF,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,8BAA8B,CAAA;IAExC;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,8BAA8B;IAC7C;;;;OAIG;IACH,MAAM,CAAC,EAAE,QAAQ,CAAA;IACjB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAQD,eAAO,MAAM,iBAAiB,uBACF,qBAAqB,KAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/vercelBlob/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,wCAAwC,CAAA;AAOvF,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,8BAA8B,CAAA;IAExC;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,8BAA8B;IAC7C;;;;OAIG;IACH,MAAM,CAAC,EAAE,QAAQ,CAAA;IACjB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAC5B;AAQD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,uBACF,qBAAqB,KAAG,OAoCjD,CAAA"}
|
|
@@ -7,7 +7,11 @@ const defaultUploadOptions = {
|
|
|
7
7
|
addRandomSuffix: false,
|
|
8
8
|
cacheControlMaxAge: 60 * 60 * 24 * 365
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Use [`@payloadcms/storage-vercel-blob`](https://www.npmjs.com/package/@payloadcms/storage-vercel-blob) instead.
|
|
12
|
+
*
|
|
13
|
+
* This adapter has been superceded by `@payloadcms/storage-vercel-blob` and will be removed in Payload 3.0.
|
|
14
|
+
*/ export const vercelBlobAdapter = ({ options = {}, token })=>({ collection, prefix })=>{
|
|
11
15
|
if (!token) {
|
|
12
16
|
throw new Error('The token argument is required for the Vercel Blob adapter.');
|
|
13
17
|
}
|
|
@@ -22,6 +26,7 @@ export const vercelBlobAdapter = ({ options = {}, token })=>({ collection, prefi
|
|
|
22
26
|
};
|
|
23
27
|
const baseUrl = `https://${storeId}.${access}.blob.vercel-storage.com`;
|
|
24
28
|
return {
|
|
29
|
+
name: 'vercel-blob',
|
|
25
30
|
generateURL: getGenerateUrl({
|
|
26
31
|
baseUrl,
|
|
27
32
|
prefix
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/adapters/vercelBlob/index.ts"],"sourcesContent":["import type { Adapter, GeneratedAdapter } from '@payloadcms/plugin-cloud-storage/types'\n\nimport { getGenerateUrl } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getStaticHandler } from './staticHandler.js'\n\nexport interface VercelBlobAdapterArgs {\n options?: VercelBlobAdapterUploadOptions\n\n /**\n * Vercel Blob storage read/write token\n *\n * Usually process.env.BLOB_READ_WRITE_TOKEN set by Vercel\n */\n token: string\n}\n\nexport interface VercelBlobAdapterUploadOptions {\n /**\n * Access control level\n *\n * @default 'public'\n */\n access?: 'public'\n /**\n * Add a random suffix to the uploaded file name\n *\n * @default false\n */\n addRandomSuffix?: boolean\n /**\n * Cache-Control max-age in seconds\n *\n * @default 31536000 (1 year)\n */\n cacheControlMaxAge?: number\n}\n\nconst defaultUploadOptions: VercelBlobAdapterUploadOptions = {\n access: 'public',\n addRandomSuffix: false,\n cacheControlMaxAge: 60 * 60 * 24 * 365, // 1 year\n}\n\nexport const vercelBlobAdapter =\n ({ options = {}, token }: VercelBlobAdapterArgs): Adapter =>\n ({ collection, prefix }): GeneratedAdapter => {\n if (!token) {\n throw new Error('The token argument is required for the Vercel Blob adapter.')\n }\n\n // Parse storeId from token\n const storeId = token.match(/^vercel_blob_rw_([a-z\\d]+)_[a-z\\d]+$/i)?.[1].toLowerCase()\n\n if (!storeId) {\n throw new Error(\n 'Invalid token format for Vercel Blob adapter. Should be vercel_blob_rw_<store_id>_<random_string>.',\n )\n }\n\n const { access, addRandomSuffix, cacheControlMaxAge } = {\n ...defaultUploadOptions,\n ...options,\n }\n\n const baseUrl = `https://${storeId}.${access}.blob.vercel-storage.com`\n\n return {\n generateURL: getGenerateUrl({ baseUrl, prefix }),\n handleDelete: getHandleDelete({ baseUrl, prefix, token }),\n handleUpload: getHandleUpload({\n access,\n addRandomSuffix,\n baseUrl,\n cacheControlMaxAge,\n prefix,\n token,\n }),\n staticHandler: getStaticHandler({ baseUrl, token }, collection),\n }\n }\n"],"names":["getGenerateUrl","getHandleDelete","getHandleUpload","getStaticHandler","defaultUploadOptions","access","addRandomSuffix","cacheControlMaxAge","vercelBlobAdapter","options","token","collection","prefix","Error","storeId","match","toLowerCase","baseUrl","generateURL","handleDelete","handleUpload","staticHandler"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/adapters/vercelBlob/index.ts"],"sourcesContent":["import type { Adapter, GeneratedAdapter } from '@payloadcms/plugin-cloud-storage/types'\n\nimport { getGenerateUrl } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getStaticHandler } from './staticHandler.js'\n\nexport interface VercelBlobAdapterArgs {\n options?: VercelBlobAdapterUploadOptions\n\n /**\n * Vercel Blob storage read/write token\n *\n * Usually process.env.BLOB_READ_WRITE_TOKEN set by Vercel\n */\n token: string\n}\n\nexport interface VercelBlobAdapterUploadOptions {\n /**\n * Access control level\n *\n * @default 'public'\n */\n access?: 'public'\n /**\n * Add a random suffix to the uploaded file name\n *\n * @default false\n */\n addRandomSuffix?: boolean\n /**\n * Cache-Control max-age in seconds\n *\n * @default 31536000 (1 year)\n */\n cacheControlMaxAge?: number\n}\n\nconst defaultUploadOptions: VercelBlobAdapterUploadOptions = {\n access: 'public',\n addRandomSuffix: false,\n cacheControlMaxAge: 60 * 60 * 24 * 365, // 1 year\n}\n\n/**\n * @deprecated Use [`@payloadcms/storage-vercel-blob`](https://www.npmjs.com/package/@payloadcms/storage-vercel-blob) instead.\n *\n * This adapter has been superceded by `@payloadcms/storage-vercel-blob` and will be removed in Payload 3.0.\n */\nexport const vercelBlobAdapter =\n ({ options = {}, token }: VercelBlobAdapterArgs): Adapter =>\n ({ collection, prefix }): GeneratedAdapter => {\n if (!token) {\n throw new Error('The token argument is required for the Vercel Blob adapter.')\n }\n\n // Parse storeId from token\n const storeId = token.match(/^vercel_blob_rw_([a-z\\d]+)_[a-z\\d]+$/i)?.[1].toLowerCase()\n\n if (!storeId) {\n throw new Error(\n 'Invalid token format for Vercel Blob adapter. Should be vercel_blob_rw_<store_id>_<random_string>.',\n )\n }\n\n const { access, addRandomSuffix, cacheControlMaxAge } = {\n ...defaultUploadOptions,\n ...options,\n }\n\n const baseUrl = `https://${storeId}.${access}.blob.vercel-storage.com`\n\n return {\n name: 'vercel-blob',\n generateURL: getGenerateUrl({ baseUrl, prefix }),\n handleDelete: getHandleDelete({ baseUrl, prefix, token }),\n handleUpload: getHandleUpload({\n access,\n addRandomSuffix,\n baseUrl,\n cacheControlMaxAge,\n prefix,\n token,\n }),\n staticHandler: getStaticHandler({ baseUrl, token }, collection),\n }\n }\n"],"names":["getGenerateUrl","getHandleDelete","getHandleUpload","getStaticHandler","defaultUploadOptions","access","addRandomSuffix","cacheControlMaxAge","vercelBlobAdapter","options","token","collection","prefix","Error","storeId","match","toLowerCase","baseUrl","name","generateURL","handleDelete","handleUpload","staticHandler"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAEA,SAASA,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,gBAAgB,QAAQ,qBAAoB;AAkCrD,MAAMC,uBAAuD;IAC3DC,QAAQ;IACRC,iBAAiB;IACjBC,oBAAoB,KAAK,KAAK,KAAK;AACrC;AAEA;;;;CAIC,GACD,OAAO,MAAMC,oBACX,CAAC,EAAEC,UAAU,CAAC,CAAC,EAAEC,KAAK,EAAyB,GAC/C,CAAC,EAAEC,UAAU,EAAEC,MAAM,EAAE;QACrB,IAAI,CAACF,OAAO;YACV,MAAM,IAAIG,MAAM;QAClB;QAEA,2BAA2B;QAC3B,MAAMC,UAAUJ,MAAMK,KAAK,CAAC,0CAA0C,CAAC,EAAE,CAACC;QAE1E,IAAI,CAACF,SAAS;YACZ,MAAM,IAAID,MACR;QAEJ;QAEA,MAAM,EAAER,MAAM,EAAEC,eAAe,EAAEC,kBAAkB,EAAE,GAAG;YACtD,GAAGH,oBAAoB;YACvB,GAAGK,OAAO;QACZ;QAEA,MAAMQ,UAAU,CAAC,QAAQ,EAAEH,QAAQ,CAAC,EAAET,OAAO,wBAAwB,CAAC;QAEtE,OAAO;YACLa,MAAM;YACNC,aAAanB,eAAe;gBAAEiB;gBAASL;YAAO;YAC9CQ,cAAcnB,gBAAgB;gBAAEgB;gBAASL;gBAAQF;YAAM;YACvDW,cAAcnB,gBAAgB;gBAC5BG;gBACAC;gBACAW;gBACAV;gBACAK;gBACAF;YACF;YACAY,eAAenB,iBAAiB;gBAAEc;gBAASP;YAAM,GAAGC;QACtD;IACF,EAAC"}
|
|
@@ -15,8 +15,10 @@ export const getAfterDeleteHook = ({ adapter, collection })=>{
|
|
|
15
15
|
});
|
|
16
16
|
await Promise.all(promises);
|
|
17
17
|
} catch (err) {
|
|
18
|
-
req.payload.logger.error(
|
|
19
|
-
|
|
18
|
+
req.payload.logger.error({
|
|
19
|
+
err,
|
|
20
|
+
msg: `There was an error while deleting files corresponding to the ${collection.labels?.singular} with ID ${doc.id}.`
|
|
21
|
+
});
|
|
20
22
|
}
|
|
21
23
|
return doc;
|
|
22
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/afterDelete.ts"],"sourcesContent":["import type { FileData, TypeWithID } from 'payload/types'\nimport type { CollectionAfterDeleteHook, CollectionConfig } from 'payload/types'\n\nimport type { GeneratedAdapter, TypeWithPrefix } from '../types.js'\n\ninterface Args {\n adapter: GeneratedAdapter\n collection: CollectionConfig\n}\n\nexport const getAfterDeleteHook = ({\n adapter,\n collection,\n}: Args): CollectionAfterDeleteHook<FileData & TypeWithID & TypeWithPrefix> => {\n return async ({ doc, req }) => {\n try {\n const filesToDelete: string[] = [\n doc.filename,\n ...Object.values(doc?.sizes || []).map((resizedFileData) => resizedFileData?.filename),\n ]\n\n const promises = filesToDelete.map(async (filename) => {\n if (filename) await adapter.handleDelete({ collection, doc, filename, req })\n })\n\n await Promise.all(promises)\n } catch (err: unknown) {\n req.payload.logger.error(\n `There was an error while deleting files corresponding to the ${collection.labels?.singular} with ID ${doc.id}
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/afterDelete.ts"],"sourcesContent":["import type { FileData, TypeWithID } from 'payload/types'\nimport type { CollectionAfterDeleteHook, CollectionConfig } from 'payload/types'\n\nimport type { GeneratedAdapter, TypeWithPrefix } from '../types.js'\n\ninterface Args {\n adapter: GeneratedAdapter\n collection: CollectionConfig\n}\n\nexport const getAfterDeleteHook = ({\n adapter,\n collection,\n}: Args): CollectionAfterDeleteHook<FileData & TypeWithID & TypeWithPrefix> => {\n return async ({ doc, req }) => {\n try {\n const filesToDelete: string[] = [\n doc.filename,\n ...Object.values(doc?.sizes || []).map((resizedFileData) => resizedFileData?.filename),\n ]\n\n const promises = filesToDelete.map(async (filename) => {\n if (filename) await adapter.handleDelete({ collection, doc, filename, req })\n })\n\n await Promise.all(promises)\n } catch (err: unknown) {\n req.payload.logger.error({\n err,\n msg: `There was an error while deleting files corresponding to the ${collection.labels?.singular} with ID ${doc.id}.`,\n })\n }\n return doc\n }\n}\n"],"names":["getAfterDeleteHook","adapter","collection","doc","req","filesToDelete","filename","Object","values","sizes","map","resizedFileData","promises","handleDelete","Promise","all","err","payload","logger","error","msg","labels","singular","id"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAUA,OAAO,MAAMA,qBAAqB,CAAC,EACjCC,OAAO,EACPC,UAAU,EACL;IACL,OAAO,OAAO,EAAEC,GAAG,EAAEC,GAAG,EAAE;QACxB,IAAI;YACF,MAAMC,gBAA0B;gBAC9BF,IAAIG,QAAQ;mBACTC,OAAOC,MAAM,CAACL,KAAKM,SAAS,EAAE,EAAEC,GAAG,CAAC,CAACC,kBAAoBA,iBAAiBL;aAC9E;YAED,MAAMM,WAAWP,cAAcK,GAAG,CAAC,OAAOJ;gBACxC,IAAIA,UAAU,MAAML,QAAQY,YAAY,CAAC;oBAAEX;oBAAYC;oBAAKG;oBAAUF;gBAAI;YAC5E;YAEA,MAAMU,QAAQC,GAAG,CAACH;QACpB,EAAE,OAAOI,KAAc;YACrBZ,IAAIa,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC;gBACvBH;gBACAI,KAAK,CAAC,6DAA6D,EAAElB,WAAWmB,MAAM,EAAEC,SAAS,SAAS,EAAEnB,IAAIoB,EAAE,CAAC,CAAC,CAAC;YACvH;QACF;QACA,OAAOpB;IACT;AACF,EAAC"}
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAe/C,eAAO,MAAM,YAAY,kBACP,aAAa,sBACZ,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAe/C,eAAO,MAAM,YAAY,kBACP,aAAa,sBACZ,MAAM,KAAG,MA4EzB,CAAA"}
|
package/dist/plugin.js
CHANGED
|
@@ -62,6 +62,7 @@ export const cloudStorage = (pluginOptions)=>(incomingConfig)=>{
|
|
|
62
62
|
},
|
|
63
63
|
upload: {
|
|
64
64
|
...typeof existingCollection.upload === 'object' ? existingCollection.upload : {},
|
|
65
|
+
adapter: adapter.name,
|
|
65
66
|
disableLocalStorage: typeof options.disableLocalStorage === 'boolean' ? options.disableLocalStorage : true,
|
|
66
67
|
handlers
|
|
67
68
|
}
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import type { Config } from 'payload/config'\n\nimport type { PluginOptions } from './types.js'\n\nimport { getFields } from './fields/getFields.js'\nimport { getAfterDeleteHook } from './hooks/afterDelete.js'\nimport { getBeforeChangeHook } from './hooks/beforeChange.js'\n\n// This plugin extends all targeted collections by offloading uploaded files\n// to cloud storage instead of solely storing files locally.\n\n// It is based on an adapter approach, where adapters can be written for any cloud provider.\n// Adapters are responsible for providing four actions that this plugin will use:\n// 1. handleUpload, 2. handleDelete, 3. generateURL, 4. staticHandler\n\n// Optionally, the adapter can specify any Webpack config overrides if they are necessary.\n\nexport const cloudStorage =\n (pluginOptions: PluginOptions) =>\n (incomingConfig: Config): Config => {\n const { collections: allCollectionOptions, enabled } = pluginOptions\n const config = { ...incomingConfig }\n\n // Return early if disabled. Only webpack config mods are applied.\n if (enabled === false) {\n return config\n }\n\n const initFunctions: Array<() => void> = []\n\n return {\n ...config,\n collections: (config.collections || []).map((existingCollection) => {\n const options = allCollectionOptions[existingCollection.slug]\n\n if (options?.adapter) {\n const adapter = options.adapter({\n collection: existingCollection,\n prefix: options.prefix,\n })\n\n if (adapter.onInit) initFunctions.push(adapter.onInit)\n\n const fields = getFields({\n adapter,\n collection: existingCollection,\n disablePayloadAccessControl: options.disablePayloadAccessControl,\n generateFileURL: options.generateFileURL,\n prefix: options.prefix,\n })\n\n const handlers = [\n ...(typeof existingCollection.upload === 'object' &&\n Array.isArray(existingCollection.upload.handlers)\n ? existingCollection.upload.handlers\n : []),\n ]\n\n if (!options.disablePayloadAccessControl) {\n handlers.push(adapter.staticHandler)\n }\n\n return {\n ...existingCollection,\n fields,\n hooks: {\n ...(existingCollection.hooks || {}),\n afterDelete: [\n ...(existingCollection.hooks?.afterDelete || []),\n getAfterDeleteHook({ adapter, collection: existingCollection }),\n ],\n beforeChange: [\n ...(existingCollection.hooks?.beforeChange || []),\n getBeforeChangeHook({ adapter, collection: existingCollection }),\n ],\n },\n upload: {\n ...(typeof existingCollection.upload === 'object' ? existingCollection.upload : {}),\n disableLocalStorage:\n typeof options.disableLocalStorage === 'boolean'\n ? options.disableLocalStorage\n : true,\n handlers,\n },\n }\n }\n\n return existingCollection\n }),\n onInit: async (payload) => {\n initFunctions.forEach((fn) => fn())\n if (config.onInit) await config.onInit(payload)\n },\n }\n }\n"],"names":["getFields","getAfterDeleteHook","getBeforeChangeHook","cloudStorage","pluginOptions","incomingConfig","collections","allCollectionOptions","enabled","config","initFunctions","map","existingCollection","options","slug","adapter","collection","prefix","onInit","push","fields","disablePayloadAccessControl","generateFileURL","handlers","upload","Array","isArray","staticHandler","hooks","afterDelete","beforeChange","disableLocalStorage","payload","forEach","fn"],"rangeMappings":"
|
|
1
|
+
{"version":3,"sources":["../src/plugin.ts"],"sourcesContent":["import type { Config } from 'payload/config'\n\nimport type { PluginOptions } from './types.js'\n\nimport { getFields } from './fields/getFields.js'\nimport { getAfterDeleteHook } from './hooks/afterDelete.js'\nimport { getBeforeChangeHook } from './hooks/beforeChange.js'\n\n// This plugin extends all targeted collections by offloading uploaded files\n// to cloud storage instead of solely storing files locally.\n\n// It is based on an adapter approach, where adapters can be written for any cloud provider.\n// Adapters are responsible for providing four actions that this plugin will use:\n// 1. handleUpload, 2. handleDelete, 3. generateURL, 4. staticHandler\n\n// Optionally, the adapter can specify any Webpack config overrides if they are necessary.\n\nexport const cloudStorage =\n (pluginOptions: PluginOptions) =>\n (incomingConfig: Config): Config => {\n const { collections: allCollectionOptions, enabled } = pluginOptions\n const config = { ...incomingConfig }\n\n // Return early if disabled. Only webpack config mods are applied.\n if (enabled === false) {\n return config\n }\n\n const initFunctions: Array<() => void> = []\n\n return {\n ...config,\n collections: (config.collections || []).map((existingCollection) => {\n const options = allCollectionOptions[existingCollection.slug]\n\n if (options?.adapter) {\n const adapter = options.adapter({\n collection: existingCollection,\n prefix: options.prefix,\n })\n\n if (adapter.onInit) initFunctions.push(adapter.onInit)\n\n const fields = getFields({\n adapter,\n collection: existingCollection,\n disablePayloadAccessControl: options.disablePayloadAccessControl,\n generateFileURL: options.generateFileURL,\n prefix: options.prefix,\n })\n\n const handlers = [\n ...(typeof existingCollection.upload === 'object' &&\n Array.isArray(existingCollection.upload.handlers)\n ? existingCollection.upload.handlers\n : []),\n ]\n\n if (!options.disablePayloadAccessControl) {\n handlers.push(adapter.staticHandler)\n }\n\n return {\n ...existingCollection,\n fields,\n hooks: {\n ...(existingCollection.hooks || {}),\n afterDelete: [\n ...(existingCollection.hooks?.afterDelete || []),\n getAfterDeleteHook({ adapter, collection: existingCollection }),\n ],\n beforeChange: [\n ...(existingCollection.hooks?.beforeChange || []),\n getBeforeChangeHook({ adapter, collection: existingCollection }),\n ],\n },\n upload: {\n ...(typeof existingCollection.upload === 'object' ? existingCollection.upload : {}),\n adapter: adapter.name,\n disableLocalStorage:\n typeof options.disableLocalStorage === 'boolean'\n ? options.disableLocalStorage\n : true,\n handlers,\n },\n }\n }\n\n return existingCollection\n }),\n onInit: async (payload) => {\n initFunctions.forEach((fn) => fn())\n if (config.onInit) await config.onInit(payload)\n },\n }\n }\n"],"names":["getFields","getAfterDeleteHook","getBeforeChangeHook","cloudStorage","pluginOptions","incomingConfig","collections","allCollectionOptions","enabled","config","initFunctions","map","existingCollection","options","slug","adapter","collection","prefix","onInit","push","fields","disablePayloadAccessControl","generateFileURL","handlers","upload","Array","isArray","staticHandler","hooks","afterDelete","beforeChange","name","disableLocalStorage","payload","forEach","fn"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,SAAS,QAAQ,wBAAuB;AACjD,SAASC,kBAAkB,QAAQ,yBAAwB;AAC3D,SAASC,mBAAmB,QAAQ,0BAAyB;AAE7D,4EAA4E;AAC5E,4DAA4D;AAE5D,4FAA4F;AAC5F,iFAAiF;AACjF,qEAAqE;AAErE,0FAA0F;AAE1F,OAAO,MAAMC,eACX,CAACC,gBACD,CAACC;QACC,MAAM,EAAEC,aAAaC,oB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B,oBAAoB;oCAAEa;oCAASC,YAAYJ;gCAAmB;6BAC/D;wBACH;wBACAY,QAAQ;4BACN,GAAI,OAAOZ,mBAAmBY,MAAM,KAAK,WAAWZ,mBAAmBY,MAAM,GAAG,CAAC,CAAC;4BAClFT,SAASA,QAAQgB,IAAI;4BACrBC,qBACE,OAAOnB,QAAQmB,mBAAmB,KAAK,YACnCnB,QAAQmB,mBAAmB,GAC3B;4BACNT;wBACF;oBACF;gBACF;gBAEA,OAAOX;YACT;YACAM,QAAQ,OAAOe;gBACbvB,cAAcwB,OAAO,CAAC,CAACC,KAAOA;gBAC9B,IAAI1B,OAAOS,MAAM,EAAE,MAAMT,OAAOS,MAAM,CAACe;YACzC;QACF;IACF,EAAC"}
|
package/dist/types.d.ts
CHANGED
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAE7E,MAAM,WAAW,IAAI;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE;IAChC,UAAU,EAAE,gBAAgB,CAAA;IAC5B,IAAI,EAAE,GAAG,CAAA;IACT,IAAI,EAAE,IAAI,CAAA;IACV,GAAG,EAAE,sBAAsB,CAAA;CAC5B,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAA;AAE1B,MAAM,WAAW,cAAc;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OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAA;AAE9B,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAA;IACvB,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,2BAA2B,CAAC,EAAE,IAAI,CAAA;IAClC,eAAe,CAAC,EAAE,eAAe,CAAA;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;IAC9C;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { FileData, ImageSize } from 'payload/types'\nimport type { TypeWithID } from 'payload/types'\nimport type { CollectionConfig, PayloadRequestWithData } from 'payload/types'\n\nexport interface File {\n buffer: Buffer\n filename: string\n filesize: number\n mimeType: string\n tempFilePath?: string\n}\n\nexport type HandleUpload = (args: {\n collection: CollectionConfig\n data: any\n file: File\n req: PayloadRequestWithData\n}) => Promise<void> | void\n\nexport interface TypeWithPrefix {\n prefix?: string\n}\n\nexport type HandleDelete = (args: {\n collection: CollectionConfig\n doc: TypeWithID & FileData & TypeWithPrefix\n filename: string\n req: PayloadRequestWithData\n}) => Promise<void> | void\n\nexport type GenerateURL = (args: {\n collection: CollectionConfig\n filename: string\n prefix?: string\n}) => Promise<string> | string\n\nexport type StaticHandler = (\n req: PayloadRequestWithData,\n args: { params: { collection: string; filename: string } },\n) => Promise<Response> | Response\n\nexport interface GeneratedAdapter {\n generateURL: GenerateURL\n handleDelete: HandleDelete\n handleUpload: HandleUpload\n onInit?: () => void\n staticHandler: StaticHandler\n}\n\nexport type Adapter = (args: { collection: CollectionConfig; prefix?: string }) => GeneratedAdapter\n\nexport type GenerateFileURL = (args: {\n collection: CollectionConfig\n filename: string\n prefix?: string\n size?: ImageSize\n}) => Promise<string> | string\n\nexport interface CollectionOptions {\n adapter: Adapter | null\n disableLocalStorage?: boolean\n disablePayloadAccessControl?: true\n generateFileURL?: GenerateFileURL\n prefix?: string\n}\n\nexport interface PluginOptions {\n collections: Record<string, CollectionOptions>\n /**\n * Whether or not to enable the plugin\n *\n * Default: true\n */\n enabled?: boolean\n}\n"],"names":[],"rangeMappings":"","mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { FileData, ImageSize } from 'payload/types'\nimport type { TypeWithID } from 'payload/types'\nimport type { CollectionConfig, PayloadRequestWithData } from 'payload/types'\n\nexport interface File {\n buffer: Buffer\n filename: string\n filesize: number\n mimeType: string\n tempFilePath?: string\n}\n\nexport type HandleUpload = (args: {\n collection: CollectionConfig\n data: any\n file: File\n req: PayloadRequestWithData\n}) => Promise<void> | void\n\nexport interface TypeWithPrefix {\n prefix?: string\n}\n\nexport type HandleDelete = (args: {\n collection: CollectionConfig\n doc: TypeWithID & FileData & TypeWithPrefix\n filename: string\n req: PayloadRequestWithData\n}) => Promise<void> | void\n\nexport type GenerateURL = (args: {\n collection: CollectionConfig\n filename: string\n prefix?: string\n}) => Promise<string> | string\n\nexport type StaticHandler = (\n req: PayloadRequestWithData,\n args: { params: { collection: string; filename: string } },\n) => Promise<Response> | Response\n\nexport interface GeneratedAdapter {\n generateURL: GenerateURL\n handleDelete: HandleDelete\n handleUpload: HandleUpload\n name: string\n onInit?: () => void\n staticHandler: StaticHandler\n}\n\nexport type Adapter = (args: { collection: CollectionConfig; prefix?: string }) => GeneratedAdapter\n\nexport type GenerateFileURL = (args: {\n collection: CollectionConfig\n filename: string\n prefix?: string\n size?: ImageSize\n}) => Promise<string> | string\n\nexport interface CollectionOptions {\n adapter: Adapter | null\n disableLocalStorage?: boolean\n disablePayloadAccessControl?: true\n generateFileURL?: GenerateFileURL\n prefix?: string\n}\n\nexport interface PluginOptions {\n collections: Record<string, CollectionOptions>\n /**\n * Whether or not to enable the plugin\n *\n * Default: true\n */\n enabled?: boolean\n}\n"],"names":[],"rangeMappings":"","mappings":"AAmEA,WAQC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-cloud-storage",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.20",
|
|
4
4
|
"description": "The official cloud storage plugin for Payload CMS",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@google-cloud/storage": "^7.7.0",
|
|
46
46
|
"@types/find-node-modules": "^2.1.2",
|
|
47
47
|
"@vercel/blob": "^0.22.3",
|
|
48
|
-
"payload": "3.0.0-beta.
|
|
48
|
+
"payload": "3.0.0-beta.20"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@aws-sdk/client-s3": "^3.525.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@azure/storage-blob": "^12.11.0",
|
|
55
55
|
"@google-cloud/storage": "^7.7.0",
|
|
56
56
|
"@vercel/blob": "^0.22.3",
|
|
57
|
-
"payload": "3.0.0-beta.
|
|
57
|
+
"payload": "3.0.0-beta.20"
|
|
58
58
|
},
|
|
59
59
|
"peerDependenciesMeta": {
|
|
60
60
|
"@aws-sdk/client-s3": {
|