@payloadcms/storage-azure 3.0.0-beta.22 → 3.0.0-beta.24

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
@@ -1,5 +1,5 @@
1
1
  import { BlobServiceClient } from '@azure/storage-blob';
2
- import { cloudStorage } from '@payloadcms/plugin-cloud-storage';
2
+ import { cloudStoragePlugin } from '@payloadcms/plugin-cloud-storage';
3
3
  import { getGenerateURL } from './generateURL.js';
4
4
  import { getHandleDelete } from './handleDelete.js';
5
5
  import { getHandleUpload } from './handleUpload.js';
@@ -33,7 +33,7 @@ export const azureStorage = (azureStorageOptions)=>(incomingConfig)=>{
33
33
  };
34
34
  })
35
35
  };
36
- return cloudStorage({
36
+ return cloudStoragePlugin({
37
37
  collections: collectionsWithAdapter
38
38
  })(config);
39
39
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\nimport type {\n Adapter,\n PluginOptions as CloudStoragePluginOptions,\n CollectionOptions,\n GeneratedAdapter,\n} from '@payloadcms/plugin-cloud-storage/types'\nimport type { Config, Plugin } from 'payload/config'\n\nimport { BlobServiceClient } from '@azure/storage-blob'\nimport { cloudStorage } 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 AzureStorageOptions = {\n /**\n * Whether or not to allow the container to be created if it does not exist\n *\n * @default false\n */\n allowContainerCreate: boolean\n\n /**\n * Base URL for the Azure Blob storage account\n */\n baseURL: string\n\n /**\n * Collection options to apply the Azure Blob adapter to.\n */\n collections: Record<string, Omit<CollectionOptions, 'adapter'> | true>\n\n /**\n * Azure Blob storage connection string\n */\n connectionString: string\n\n /**\n * Azure Blob storage container name\n */\n containerName: string\n\n /**\n * Whether or not to enable the plugin\n *\n * Default: true\n */\n enabled?: boolean\n}\n\ntype AzureStoragePlugin = (azureStorageArgs: AzureStorageOptions) => Plugin\n\nexport const azureStorage: AzureStoragePlugin =\n (azureStorageOptions: AzureStorageOptions) =>\n (incomingConfig: Config): Config => {\n if (azureStorageOptions.enabled === false) {\n return incomingConfig\n }\n\n const adapter = azureStorageInternal(azureStorageOptions)\n\n // Add adapter to each collection option object\n const collectionsWithAdapter: CloudStoragePluginOptions['collections'] = Object.entries(\n azureStorageOptions.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 cloudStorage({\n collections: collectionsWithAdapter,\n })(config)\n }\n\nfunction azureStorageInternal({\n allowContainerCreate,\n baseURL,\n connectionString,\n containerName,\n}: AzureStorageOptions): Adapter {\n let storageClient: ContainerClient | null = null\n const getStorageClient = () => {\n if (storageClient) return storageClient\n\n const blobServiceClient = BlobServiceClient.fromConnectionString(connectionString)\n storageClient = blobServiceClient.getContainerClient(containerName)\n return storageClient\n }\n\n const createContainerIfNotExists = () => {\n void 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","cloudStorage","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","azureStorage","azureStorageOptions","incomingConfig","enabled","adapter","azureStorageInternal","collectionsWithAdapter","Object","entries","collections","reduce","acc","slug","collOptions","config","map","collection","upload","disableLocalStorage","allowContainerCreate","baseURL","connectionString","containerName","storageClient","getStorageClient","blobServiceClient","fromConnectionString","getContainerClient","createContainerIfNotExists","createIfNotExists","access","prefix","name","generateURL","handleDelete","handleUpload","staticHandler","onInit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AASA,SAASA,iBAAiB,QAAQ,sBAAqB;AACvD,SAASC,YAAY,QAAQ,mCAAkC;AAE/D,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAwC/C,OAAO,MAAMC,eACX,CAACC,sBACD,CAACC;QACC,IAAID,oBAAoBE,OAAO,KAAK,OAAO;YACzC,OAAOD;QACT;QAEA,MAAME,UAAUC,qBAAqBJ;QAErC,+CAA+C;QAC/C,MAAMK,yBAAmEC,OAAOC,OAAO,CACrFP,oBAAoBQ,WAAW,EAC/BC,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,aAAa;YAClBc,aAAaH;QACf,GAAGQ;IACL,EAAC;AAEH,SAAST,qBAAqB,EAC5Bc,oBAAoB,EACpBC,OAAO,EACPC,gBAAgB,EAChBC,aAAa,EACO;IACpB,IAAIC,gBAAwC;IAC5C,MAAMC,mBAAmB;QACvB,IAAID,eAAe,OAAOA;QAE1B,MAAME,oBAAoB/B,kBAAkBgC,oBAAoB,CAACL;QACjEE,gBAAgBE,kBAAkBE,kBAAkB,CAACL;QACrD,OAAOC;IACT;IAEA,MAAMK,6BAA6B;QACjC,KAAKJ,mBAAmBK,iBAAiB,CAAC;YAAEC,QAAQ;QAAO;IAC7D;IAEA,OAAO,CAAC,EAAEd,UAAU,EAAEe,MAAM,EAAE;QAC5B,OAAO;YACLC,MAAM;YACNC,aAAarC,eAAe;gBAAEwB;gBAASE;YAAc;YACrDY,cAAcrC,gBAAgB;gBAAEmB;gBAAYQ;YAAiB;YAC7DW,cAAcrC,gBAAgB;gBAC5BkB;gBACAQ;gBACAO;YACF;YACAK,eAAerC,WAAW;gBAAEiB;gBAAYQ;YAAiB;YACzD,GAAIL,wBAAwB;gBAAEkB,QAAQT;YAA2B,CAAC;QACpE;IACF;AACF"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\nimport type {\n Adapter,\n PluginOptions as CloudStoragePluginOptions,\n CollectionOptions,\n GeneratedAdapter,\n} from '@payloadcms/plugin-cloud-storage/types'\nimport type { Config, Plugin } from 'payload/config'\n\nimport { BlobServiceClient } from '@azure/storage-blob'\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 AzureStorageOptions = {\n /**\n * Whether or not to allow the container to be created if it does not exist\n *\n * @default false\n */\n allowContainerCreate: boolean\n\n /**\n * Base URL for the Azure Blob storage account\n */\n baseURL: string\n\n /**\n * Collection options to apply the Azure Blob adapter to.\n */\n collections: Record<string, Omit<CollectionOptions, 'adapter'> | true>\n\n /**\n * Azure Blob storage connection string\n */\n connectionString: string\n\n /**\n * Azure Blob storage container name\n */\n containerName: string\n\n /**\n * Whether or not to enable the plugin\n *\n * Default: true\n */\n enabled?: boolean\n}\n\ntype AzureStoragePlugin = (azureStorageArgs: AzureStorageOptions) => Plugin\n\nexport const azureStorage: AzureStoragePlugin =\n (azureStorageOptions: AzureStorageOptions) =>\n (incomingConfig: Config): Config => {\n if (azureStorageOptions.enabled === false) {\n return incomingConfig\n }\n\n const adapter = azureStorageInternal(azureStorageOptions)\n\n // Add adapter to each collection option object\n const collectionsWithAdapter: CloudStoragePluginOptions['collections'] = Object.entries(\n azureStorageOptions.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 azureStorageInternal({\n allowContainerCreate,\n baseURL,\n connectionString,\n containerName,\n}: AzureStorageOptions): Adapter {\n let storageClient: ContainerClient | null = null\n const getStorageClient = () => {\n if (storageClient) return storageClient\n\n const blobServiceClient = BlobServiceClient.fromConnectionString(connectionString)\n storageClient = blobServiceClient.getContainerClient(containerName)\n return storageClient\n }\n\n const createContainerIfNotExists = () => {\n void 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","cloudStoragePlugin","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","azureStorage","azureStorageOptions","incomingConfig","enabled","adapter","azureStorageInternal","collectionsWithAdapter","Object","entries","collections","reduce","acc","slug","collOptions","config","map","collection","upload","disableLocalStorage","allowContainerCreate","baseURL","connectionString","containerName","storageClient","getStorageClient","blobServiceClient","fromConnectionString","getContainerClient","createContainerIfNotExists","createIfNotExists","access","prefix","name","generateURL","handleDelete","handleUpload","staticHandler","onInit"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AASA,SAASA,iBAAiB,QAAQ,sBAAqB;AACvD,SAASC,kBAAkB,QAAQ,mCAAkC;AAErE,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAwC/C,OAAO,MAAMC,eACX,CAACC,sBACD,CAACC;QACC,IAAID,oBAAoBE,OAAO,KAAK,OAAO;YACzC,OAAOD;QACT;QAEA,MAAME,UAAUC,qBAAqBJ;QAErC,+CAA+C;QAC/C,MAAMK,yBAAmEC,OAAOC,OAAO,CACrFP,oBAAoBQ,WAAW,EAC/BC,MAAM,CACN,CAACC,KAAK,CAACC,MAAMC,YAAY,GAAM,CAAA;gBA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2B,CAAC;QACpE;IACF;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/storage-azure",
3
- "version": "3.0.0-beta.22",
3
+ "version": "3.0.0-beta.24",
4
4
  "description": "Payload storage adapter for Azure Blob Storage",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -27,14 +27,14 @@
27
27
  "@azure/abort-controller": "^1.1.0",
28
28
  "@azure/storage-blob": "^12.11.0",
29
29
  "range-parser": "^1.2.1",
30
- "@payloadcms/plugin-cloud-storage": "3.0.0-beta.22"
30
+ "@payloadcms/plugin-cloud-storage": "3.0.0-beta.24"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/range-parser": "^1.2.7",
34
- "payload": "3.0.0-beta.22"
34
+ "payload": "3.0.0-beta.24"
35
35
  },
36
36
  "peerDependencies": {
37
- "payload": "3.0.0-beta.22"
37
+ "payload": "3.0.0-beta.24"
38
38
  },
39
39
  "engines": {
40
40
  "node": ">=18.20.2"