@payloadcms/storage-r2 3.60.0-canary.1 → 3.60.0-canary.10

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/dist/index.js CHANGED
@@ -50,7 +50,8 @@ function r2StorageInternal({ bucket }) {
50
50
  }),
51
51
  staticHandler: getHandler({
52
52
  bucket,
53
- collection
53
+ collection,
54
+ prefix
54
55
  })
55
56
  };
56
57
  };
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, UploadCollectionSlug } from 'payload'\n\nimport { cloudStoragePlugin } from '@payloadcms/plugin-cloud-storage'\n\nimport type { R2Bucket } from './types.js'\n\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\n\nexport interface R2StorageOptions {\n bucket: R2Bucket\n /**\n * Collection options to apply the R2 adapter to.\n */\n collections: Partial<Record<UploadCollectionSlug, Omit<CollectionOptions, 'adapter'> | true>>\n enabled?: boolean\n}\n\ntype R2StoragePlugin = (r2StorageArgs: R2StorageOptions) => Plugin\n\nexport const r2Storage: R2StoragePlugin =\n (r2StorageOptions) =>\n (incomingConfig: Config): Config => {\n const adapter = r2StorageInternal(r2StorageOptions)\n\n const isPluginDisabled = r2StorageOptions.enabled === false\n\n if (isPluginDisabled) {\n return incomingConfig\n }\n\n // Add adapter to each collection option object\n const collectionsWithAdapter: CloudStoragePluginOptions['collections'] = Object.entries(\n r2StorageOptions.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 r2StorageInternal({ bucket }: R2StorageOptions): Adapter {\n return ({ collection, prefix }): GeneratedAdapter => {\n return {\n name: 'r2',\n handleDelete: getHandleDelete({ bucket }),\n handleUpload: getHandleUpload({\n bucket,\n collection,\n prefix,\n }),\n staticHandler: getHandler({ bucket, collection }),\n }\n }\n}\n"],"names":["cloudStoragePlugin","getHandleDelete","getHandleUpload","getHandler","r2Storage","r2StorageOptions","incomingConfig","adapter","r2StorageInternal","isPluginDisabled","enabled","collectionsWithAdapter","Object","entries","collections","reduce","acc","slug","collOptions","config","map","collection","upload","disableLocalStorage","bucket","prefix","name","handleDelete","handleUpload","staticHandler"],"mappings":"AAQA,SAASA,kBAAkB,QAAQ,mCAAkC;AAIrE,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAa/C,OAAO,MAAMC,YACX,CAACC,mBACD,CAACC;QACC,MAAMC,UAAUC,kBAAkBH;QAElC,MAAMI,mBAAmBJ,iBAAiBK,OAAO,KAAK;QAEtD,IAAID,kBAAkB;YACpB,OAAOH;QACT;QAEA,+CAA+C;QAC/C,MAAMK,yBAAmEC,OAAOC,OAAO,CACrFR,iBAAiBS,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;oBAC3CX;gBACF;YACF,CAAA,GACA,CAAC;QAGH,gFAAgF;QAChF,MAAMY,SAAS;YACb,GAAGb,cAAc;YACjBQ,aAAa,AAACR,CAAAA,eAAeQ,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,SAASX,kBAAkB,EAAEgB,MAAM,EAAoB;IACrD,OAAO,CAAC,EAAEH,UAAU,EAAEI,MAAM,EAAE;QAC5B,OAAO;YACLC,MAAM;YACNC,cAAc1B,gBAAgB;gBAAEuB;YAAO;YACvCI,cAAc1B,gBAAgB;gBAC5BsB;gBACAH;gBACAI;YACF;YACAI,eAAe1B,WAAW;gBAAEqB;gBAAQH;YAAW;QACjD;IACF;AACF"}
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 { cloudStoragePlugin } from '@payloadcms/plugin-cloud-storage'\n\nimport type { R2Bucket } from './types.js'\n\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\n\nexport interface R2StorageOptions {\n bucket: R2Bucket\n /**\n * Collection options to apply the R2 adapter to.\n */\n collections: Partial<Record<UploadCollectionSlug, Omit<CollectionOptions, 'adapter'> | true>>\n enabled?: boolean\n}\n\ntype R2StoragePlugin = (r2StorageArgs: R2StorageOptions) => Plugin\n\nexport const r2Storage: R2StoragePlugin =\n (r2StorageOptions) =>\n (incomingConfig: Config): Config => {\n const adapter = r2StorageInternal(r2StorageOptions)\n\n const isPluginDisabled = r2StorageOptions.enabled === false\n\n if (isPluginDisabled) {\n return incomingConfig\n }\n\n // Add adapter to each collection option object\n const collectionsWithAdapter: CloudStoragePluginOptions['collections'] = Object.entries(\n r2StorageOptions.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 r2StorageInternal({ bucket }: R2StorageOptions): Adapter {\n return ({ collection, prefix }): GeneratedAdapter => {\n return {\n name: 'r2',\n handleDelete: getHandleDelete({ bucket }),\n handleUpload: getHandleUpload({\n bucket,\n collection,\n prefix,\n }),\n staticHandler: getHandler({ bucket, collection, prefix }),\n }\n }\n}\n"],"names":["cloudStoragePlugin","getHandleDelete","getHandleUpload","getHandler","r2Storage","r2StorageOptions","incomingConfig","adapter","r2StorageInternal","isPluginDisabled","enabled","collectionsWithAdapter","Object","entries","collections","reduce","acc","slug","collOptions","config","map","collection","upload","disableLocalStorage","bucket","prefix","name","handleDelete","handleUpload","staticHandler"],"mappings":"AAQA,SAASA,kBAAkB,QAAQ,mCAAkC;AAIrE,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAa/C,OAAO,MAAMC,YACX,CAACC,mBACD,CAACC;QACC,MAAMC,UAAUC,kBAAkBH;QAElC,MAAMI,mBAAmBJ,iBAAiBK,OAAO,KAAK;QAEtD,IAAID,kBAAkB;YACpB,OAAOH;QACT;QAEA,+CAA+C;QAC/C,MAAMK,yBAAmEC,OAAOC,OAAO,CACrFR,iBAAiBS,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;oBAC3CX;gBACF;YACF,CAAA,GACA,CAAC;QAGH,gFAAgF;QAChF,MAAMY,SAAS;YACb,GAAGb,cAAc;YACjBQ,aAAa,AAACR,CAAAA,eAAeQ,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,SAASX,kBAAkB,EAAEgB,MAAM,EAAoB;IACrD,OAAO,CAAC,EAAEH,UAAU,EAAEI,MAAM,EAAE;QAC5B,OAAO;YACLC,MAAM;YACNC,cAAc1B,gBAAgB;gBAAEuB;YAAO;YACvCI,cAAc1B,gBAAgB;gBAC5BsB;gBACAH;gBACAI;YACF;YACAI,eAAe1B,WAAW;gBAAEqB;gBAAQH;gBAAYI;YAAO;QACzD;IACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/storage-r2",
3
- "version": "3.60.0-canary.1",
3
+ "version": "3.60.0-canary.10",
4
4
  "description": "Payload storage adapter for Cloudflare R2",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -37,13 +37,13 @@
37
37
  "dist"
38
38
  ],
39
39
  "dependencies": {
40
- "@payloadcms/plugin-cloud-storage": "3.60.0-canary.1"
40
+ "@payloadcms/plugin-cloud-storage": "3.60.0-canary.10"
41
41
  },
42
42
  "devDependencies": {
43
- "payload": "3.60.0-canary.1"
43
+ "payload": "3.60.0-canary.10"
44
44
  },
45
45
  "peerDependencies": {
46
- "payload": "3.60.0-canary.1"
46
+ "payload": "3.60.0-canary.10"
47
47
  },
48
48
  "engines": {
49
49
  "node": "^18.20.2 || >=20.9.0"