@payloadcms/storage-s3 3.0.0-canary.ff8c8fd → 3.0.0
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/LICENSE.md +17 -17
- package/README.md +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +14 -5
package/LICENSE.md
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2018-
|
|
4
|
-
Portions Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
Copyright (c) 2018-2024 Payload CMS, Inc. <info@payloadcms.com>
|
|
5
4
|
|
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
7
|
-
of this software and associated documentation files (the
|
|
8
|
-
in the Software without restriction, including
|
|
9
|
-
to use, copy, modify, merge, publish,
|
|
10
|
-
copies of the Software, and to
|
|
11
|
-
furnished to do so, subject to
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
12
|
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
|
14
|
-
copies or substantial portions of the Software.
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
15
|
|
|
16
|
-
THE SOFTWARE IS PROVIDED
|
|
17
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
|
|
22
|
-
SOFTWARE.
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CollectionOptions } from '@payloadcms/plugin-cloud-storage/types';
|
|
2
|
-
import type { Plugin } from 'payload';
|
|
2
|
+
import type { Plugin, UploadCollectionSlug } from 'payload';
|
|
3
3
|
import * as AWS from '@aws-sdk/client-s3';
|
|
4
4
|
export type S3StorageOptions = {
|
|
5
5
|
/**
|
|
@@ -15,7 +15,7 @@ export type S3StorageOptions = {
|
|
|
15
15
|
/**
|
|
16
16
|
* Collection options to apply the S3 adapter to.
|
|
17
17
|
*/
|
|
18
|
-
collections: Record<
|
|
18
|
+
collections: Partial<Record<UploadCollectionSlug, Omit<CollectionOptions, 'adapter'> | true>>;
|
|
19
19
|
/**
|
|
20
20
|
* AWS S3 client configuration. Highly dependent on your AWS setup.
|
|
21
21
|
*
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,iBAAiB,EAElB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,KAAK,EAAU,MAAM,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,iBAAiB,EAElB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,KAAK,EAAU,MAAM,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAEnE,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAA;AAQzC,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IAEH,GAAG,CAAC,EAAE,SAAS,GAAG,aAAa,CAAA;IAC/B;;;;OAIG;IAEH,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,oBAAoB,EAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAC7F;;;;OAIG;IACH,MAAM,EAAE,GAAG,CAAC,cAAc,CAAA;IAE1B;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAE7B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,KAAK,eAAe,GAAG,CAAC,aAAa,EAAE,gBAAgB,KAAK,MAAM,CAAA;AAElE,eAAO,MAAM,SAAS,EAAE,eA4CrB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -41,7 +41,9 @@ function s3StorageInternal({ acl, bucket, config = {} }) {
|
|
|
41
41
|
return ({ collection, prefix })=>{
|
|
42
42
|
let storageClient = null;
|
|
43
43
|
const getStorageClient = ()=>{
|
|
44
|
-
if (storageClient)
|
|
44
|
+
if (storageClient) {
|
|
45
|
+
return storageClient;
|
|
46
|
+
}
|
|
45
47
|
storageClient = new AWS.S3(config);
|
|
46
48
|
return storageClient;
|
|
47
49
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type {\n Adapter,\n PluginOptions as CloudStoragePluginOptions,\n CollectionOptions,\n GeneratedAdapter,\n} from '@payloadcms/plugin-cloud-storage/types'\nimport type { Config, Plugin } from 'payload'\n\nimport * as AWS from '@aws-sdk/client-s3'\nimport { cloudStoragePlugin } from '@payloadcms/plugin-cloud-storage'\n\nimport { getGenerateURL } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\n\nexport type S3StorageOptions = {\n /**\n * Access control list for uploaded files.\n */\n\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\n bucket: string\n\n /**\n * Collection options to apply the S3 adapter to.\n */\n collections: Record<
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type {\n Adapter,\n PluginOptions as CloudStoragePluginOptions,\n CollectionOptions,\n GeneratedAdapter,\n} from '@payloadcms/plugin-cloud-storage/types'\nimport type { Config, Plugin, UploadCollectionSlug } from 'payload'\n\nimport * as AWS from '@aws-sdk/client-s3'\nimport { cloudStoragePlugin } from '@payloadcms/plugin-cloud-storage'\n\nimport { getGenerateURL } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\n\nexport type S3StorageOptions = {\n /**\n * Access control list for uploaded files.\n */\n\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\n bucket: string\n\n /**\n * Collection options to apply the S3 adapter to.\n */\n collections: Partial<Record<UploadCollectionSlug, Omit<CollectionOptions, 'adapter'> | true>>\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 * Whether or not to disable local storage\n *\n * @default true\n */\n disableLocalStorage?: boolean\n\n /**\n * Whether or not to enable the plugin\n *\n * Default: true\n */\n enabled?: boolean\n}\n\ntype S3StoragePlugin = (storageS3Args: S3StorageOptions) => Plugin\n\nexport const s3Storage: S3StoragePlugin =\n (s3StorageOptions: S3StorageOptions) =>\n (incomingConfig: Config): Config => {\n if (s3StorageOptions.enabled === false) {\n return incomingConfig\n }\n\n const adapter = s3StorageInternal(s3StorageOptions)\n\n // Add adapter to each collection option object\n const collectionsWithAdapter: CloudStoragePluginOptions['collections'] = Object.entries(\n s3StorageOptions.collections,\n ).reduce(\n (acc, [slug, collOptions]) => ({\n ...acc,\n [slug]: {\n ...(collOptions === true ? {} : collOptions),\n adapter,\n },\n }),\n {} as Record<string, CollectionOptions>,\n )\n\n // Set disableLocalStorage: true for collections specified in the plugin options\n const config = {\n ...incomingConfig,\n collections: (incomingConfig.collections || []).map((collection) => {\n if (!collectionsWithAdapter[collection.slug]) {\n return collection\n }\n\n return {\n ...collection,\n upload: {\n ...(typeof collection.upload === 'object' ? collection.upload : {}),\n disableLocalStorage: true,\n },\n }\n }),\n }\n\n return cloudStoragePlugin({\n collections: collectionsWithAdapter,\n })(config)\n }\n\nfunction s3StorageInternal({ acl, bucket, config = {} }: S3StorageOptions): Adapter {\n return ({ collection, prefix }): GeneratedAdapter => {\n let storageClient: AWS.S3 | null = null\n const getStorageClient: () => AWS.S3 = () => {\n if (storageClient) {\n return storageClient\n }\n storageClient = new AWS.S3(config)\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}\n"],"names":["AWS","cloudStoragePlugin","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","s3Storage","s3StorageOptions","incomingConfig","enabled","adapter","s3StorageInternal","collectionsWithAdapter","Object","entries","collections","reduce","acc","slug","collOptions","config","map","collection","upload","disableLocalStorage","acl","bucket","prefix","storageClient","getStorageClient","S3","name","generateURL","handleDelete","handleUpload","staticHandler"],"mappings":"AAQA,YAAYA,SAAS,qBAAoB;AACzC,SAASC,kBAAkB,QAAQ,mCAAkC;AAErE,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AA4C/C,OAAO,MAAMC,YACX,CAACC,mBACD,CAACC;QACC,IAAID,iBAAiBE,OAAO,KAAK,OAAO;YACtC,OAAOD;QACT;QAEA,MAAME,UAAUC,kBAAkBJ;QAElC,+CAA+C;QAC/C,MAAMK,yBAAmEC,OAAOC,OAAO,CACrFP,iBAAiBQ,WAAW,EAC5BC,MAAM,CACN,CAACC,KAAK,CAACC,MAAMC,YAAY,GAAM,CAAA;gBAC7B,GAAGF,GAAG;gBACN,CAACC,KAAK,EAAE;oBACN,GAAIC,gBAAgB,OAAO,CAAC,IAAIA,WAAW;oBAC3CT;gBACF;YACF,CAAA,GACA,CAAC;QAGH,gFAAgF;QAChF,MAAMU,SAAS;YACb,GAAGZ,cAAc;YACjBO,aAAa,AAACP,CAAAA,eAAeO,WAAW,IAAI,EAAE,AAAD,EAAGM,GAAG,CAAC,CAACC;gBACnD,IAAI,CAACV,sBAAsB,CAACU,WAAWJ,IAAI,CAAC,EAAE;oBAC5C,OAAOI;gBACT;gBAEA,OAAO;oBACL,GAAGA,UAAU;oBACbC,QAAQ;wBACN,GAAI,OAAOD,WAAWC,MAAM,KAAK,WAAWD,WAAWC,MAAM,GAAG,CAAC,CAAC;wBAClEC,qBAAqB;oBACvB;gBACF;YACF;QACF;QAEA,OAAOvB,mBAAmB;YACxBc,aAAaH;QACf,GAAGQ;IACL,EAAC;AAEH,SAAST,kBAAkB,EAAEc,GAAG,EAAEC,MAAM,EAAEN,SAAS,CAAC,CAAC,EAAoB;IACvE,OAAO,CAAC,EAAEE,UAAU,EAAEK,MAAM,EAAE;QAC5B,IAAIC,gBAA+B;QACnC,MAAMC,mBAAiC;YACrC,IAAID,eAAe;gBACjB,OAAOA;YACT;YACAA,gBAAgB,IAAI5B,IAAI8B,EAAE,CAACV;YAC3B,OAAOQ;QACT;QAEA,OAAO;YACLG,MAAM;YACNC,aAAa9B,eAAe;gBAAEwB;gBAAQN;YAAO;YAC7Ca,cAAc9B,gBAAgB;gBAAEuB;gBAAQG;YAAiB;YACzDK,cAAc9B,gBAAgB;gBAC5BqB;gBACAC;gBACAJ;gBACAO;gBACAF;YACF;YACAQ,eAAe9B,WAAW;gBAAEqB;gBAAQJ;gBAAYO;YAAiB;QACnE;IACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/storage-s3",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Payload storage adapter for Amazon S3",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -10,6 +10,13 @@
|
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
|
|
13
|
+
"maintainers": [
|
|
14
|
+
{
|
|
15
|
+
"name": "Payload",
|
|
16
|
+
"email": "info@payloadcms.com",
|
|
17
|
+
"url": "https://payloadcms.com"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
13
20
|
"type": "module",
|
|
14
21
|
"exports": {
|
|
15
22
|
".": {
|
|
@@ -26,13 +33,13 @@
|
|
|
26
33
|
"dependencies": {
|
|
27
34
|
"@aws-sdk/client-s3": "^3.614.0",
|
|
28
35
|
"@aws-sdk/lib-storage": "^3.614.0",
|
|
29
|
-
"@payloadcms/plugin-cloud-storage": "3.0.0
|
|
36
|
+
"@payloadcms/plugin-cloud-storage": "3.0.0"
|
|
30
37
|
},
|
|
31
38
|
"devDependencies": {
|
|
32
|
-
"payload": "3.0.0
|
|
39
|
+
"payload": "3.0.0"
|
|
33
40
|
},
|
|
34
41
|
"peerDependencies": {
|
|
35
|
-
"payload": "3.0.0
|
|
42
|
+
"payload": "3.0.0"
|
|
36
43
|
},
|
|
37
44
|
"engines": {
|
|
38
45
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -42,6 +49,8 @@
|
|
|
42
49
|
"build:clean": "find . \\( -type d \\( -name build -o -name dist -o -name .cache \\) -o -type f -name tsconfig.tsbuildinfo \\) -exec rm -rf {} + && pnpm build",
|
|
43
50
|
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
44
51
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
45
|
-
"clean": "rimraf {dist,*.tsbuildinfo}"
|
|
52
|
+
"clean": "rimraf {dist,*.tsbuildinfo}",
|
|
53
|
+
"lint": "eslint .",
|
|
54
|
+
"lint:fix": "eslint . --fix"
|
|
46
55
|
}
|
|
47
56
|
}
|