@payloadcms/storage-r2 3.70.0-canary.8 → 3.70.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/dist/index.d.ts CHANGED
@@ -2,6 +2,16 @@ import type { CollectionOptions } from '@payloadcms/plugin-cloud-storage/types';
2
2
  import type { Plugin, UploadCollectionSlug } from 'payload';
3
3
  import type { R2Bucket } from './types.js';
4
4
  export interface R2StorageOptions {
5
+ /**
6
+ * When enabled, fields (like the prefix field) will always be inserted into
7
+ * the collection schema regardless of whether the plugin is enabled. This
8
+ * ensures a consistent schema across all environments.
9
+ *
10
+ * This will be enabled by default in Payload v4.
11
+ *
12
+ * @default false
13
+ */
14
+ alwaysInsertFields?: boolean;
5
15
  bucket: R2Bucket;
6
16
  /**
7
17
  * Collection options to apply the R2 adapter to.
@@ -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,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAInE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAM1C,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,QAAQ,CAAA;IAChB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,oBAAoB,EAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAC7F,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,KAAK,eAAe,GAAG,CAAC,aAAa,EAAE,gBAAgB,KAAK,MAAM,CAAA;AAElE,eAAO,MAAM,SAAS,EAAE,eA8CrB,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;AAInE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAM1C,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;OAQG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAE5B,MAAM,EAAE,QAAQ,CAAA;IAChB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,oBAAoB,EAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAC7F,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,KAAK,eAAe,GAAG,CAAC,aAAa,EAAE,gBAAgB,KAAK,MAAM,CAAA;AAElE,eAAO,MAAM,SAAS,EAAE,eA+CrB,CAAA"}
package/dist/index.js CHANGED
@@ -33,6 +33,7 @@ export const r2Storage = (r2StorageOptions)=>(incomingConfig)=>{
33
33
  })
34
34
  };
35
35
  return cloudStoragePlugin({
36
+ alwaysInsertFields: r2StorageOptions.alwaysInsertFields,
36
37
  collections: collectionsWithAdapter
37
38
  })(config);
38
39
  };
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, 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,S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luginOptions 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 /**\n * When enabled, fields (like the prefix field) will always be inserted into\n * the collection schema regardless of whether the plugin is enabled. This\n * ensures a consistent schema across all environments.\n *\n * This will be enabled by default in Payload v4.\n *\n * @default false\n */\n alwaysInsertFields?: boolean\n\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 alwaysInsertFields: r2StorageOptions.alwaysInsertFields,\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","alwaysInsertFields","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;AAwB/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;YACxBwB,oBAAoBnB,iBAAiBmB,kBAAkB;YACvDV,aAAaH;QACf,GAAGQ;IACL,EAAC;AAEH,SAASX,kBAAkB,EAAEiB,MAAM,EAAoB;IACrD,OAAO,CAAC,EAAEJ,UAAU,EAAEK,MAAM,EAAE;QAC5B,OAAO;YACLC,MAAM;YACNC,cAAc3B,gBAAgB;gBAAEwB;YAAO;YACvCI,cAAc3B,gBAAgB;gBAC5BuB;gBACAJ;gBACAK;YACF;YACAI,eAAe3B,WAAW;gBAAEsB;gBAAQJ;gBAAYK;YAAO;QACzD;IACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/storage-r2",
3
- "version": "3.70.0-canary.8",
3
+ "version": "3.70.0",
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.70.0-canary.8"
40
+ "@payloadcms/plugin-cloud-storage": "3.70.0"
41
41
  },
42
42
  "devDependencies": {
43
- "payload": "3.70.0-canary.8"
43
+ "payload": "3.70.0"
44
44
  },
45
45
  "peerDependencies": {
46
- "payload": "3.70.0-canary.8"
46
+ "payload": "3.70.0"
47
47
  },
48
48
  "engines": {
49
49
  "node": "^18.20.2 || >=20.9.0"