@payloadcms/storage-azure 3.62.0-internal.7fb5145 → 3.62.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 +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/getStorageClient.d.ts +1 -1
- package/dist/utils/getStorageClient.d.ts.map +1 -1
- package/dist/utils/getStorageClient.js +7 -5
- package/dist/utils/getStorageClient.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -12,6 +12,13 @@ export type AzureStorageOptions = {
|
|
|
12
12
|
* Base URL for the Azure Blob storage account
|
|
13
13
|
*/
|
|
14
14
|
baseURL: string;
|
|
15
|
+
/**
|
|
16
|
+
* Optional cache key to identify the Azure Blob storage client instance.
|
|
17
|
+
* If not provided, a default key will be used.
|
|
18
|
+
*
|
|
19
|
+
* @default `azure:containerName`
|
|
20
|
+
*/
|
|
21
|
+
clientCacheKey?: string;
|
|
15
22
|
/**
|
|
16
23
|
* Do uploads directly on the client to bypass limits on Vercel. You must allow CORS PUT method to your website.
|
|
17
24
|
*/
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,mBAAmB,EAEnB,iBAAiB,EAElB,MAAM,wCAAwC,CAAA;AAC/C,OAAO,KAAK,EAAU,MAAM,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAUnE,OAAO,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAEtF,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;OAIG;IACH,oBAAoB,EAAE,OAAO,CAAA;IAE7B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,aAAa,CAAC,EAAE,mBAAmB,CAAA;IAEnC;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OAAO,CAAA;CAClB,CAAA;AAED,KAAK,kBAAkB,GAAG,CAAC,gBAAgB,EAAE,mBAAmB,KAAK,MAAM,CAAA;AAE3E,eAAO,MAAM,YAAY,EAAE,kBAqExB,CAAA;AAmCH,OAAO,EAAE,oBAAoB,IAAI,gBAAgB,EAAE,CAAA"}
|
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 ClientUploadsConfig,\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'\nimport { initClientUploads } from '@payloadcms/plugin-cloud-storage/utilities'\n\nimport { getGenerateSignedURLHandler } from './generateSignedURL.js'\nimport { getGenerateURL } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\nimport { getStorageClient as getStorageClientFunc } from './utils/getStorageClient.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 * Do uploads directly on the client to bypass limits on Vercel. You must allow CORS PUT method to your website.\n */\n clientUploads?: ClientUploadsConfig\n\n /**\n * Collection options to apply the Azure Blob adapter to.\n */\n collections: Partial<Record<UploadCollectionSlug, 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 const getStorageClient = () =>\n getStorageClientFunc({\n connectionString: azureStorageOptions.connectionString,\n containerName: azureStorageOptions.containerName,\n })\n\n const isPluginDisabled = azureStorageOptions.enabled === false\n\n initClientUploads({\n clientHandler: '@payloadcms/storage-azure/client#AzureClientUploadHandler',\n collections: azureStorageOptions.collections,\n config: incomingConfig,\n enabled: !isPluginDisabled && Boolean(azureStorageOptions.clientUploads),\n serverHandler: getGenerateSignedURLHandler({\n access:\n typeof azureStorageOptions.clientUploads === 'object'\n ? azureStorageOptions.clientUploads.access\n : undefined,\n collections: azureStorageOptions.collections,\n containerName: azureStorageOptions.containerName,\n getStorageClient,\n }),\n serverHandlerPath: '/storage-azure-generate-signed-url',\n })\n\n if (isPluginDisabled) {\n return incomingConfig\n }\n\n const adapter = azureStorageInternal(getStorageClient, 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 getStorageClient: () => ContainerClient,\n {\n allowContainerCreate,\n baseURL,\n clientUploads,\n connectionString,\n containerName,\n }: AzureStorageOptions,\n): Adapter {\n const createContainerIfNotExists = () => {\n void getStorageClientFunc({ connectionString, containerName }).createIfNotExists({\n access: 'blob',\n })\n }\n\n return ({ collection, prefix }): GeneratedAdapter => {\n return {\n name: 'azure',\n clientUploads,\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\nexport { getStorageClientFunc as getStorageClient }\n"],"names":["cloudStoragePlugin","initClientUploads","getGenerateSignedURLHandler","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","getStorageClient","getStorageClientFunc","azureStorage","azureStorageOptions","incomingConfig","connectionString","containerName","isPluginDisabled","enabled","clientHandler","collections","config","Boolean","clientUploads","serverHandler","access","undefined","serverHandlerPath","adapter","azureStorageInternal","collectionsWithAdapter","Object","entries","reduce","acc","slug","collOptions","map","collection","upload","disableLocalStorage","allowContainerCreate","baseURL","createContainerIfNotExists","createIfNotExists","prefix","name","generateURL","handleDelete","handleUpload","staticHandler","onInit"],"mappings":"AAUA,SAASA,kBAAkB,QAAQ,mCAAkC;AACrE,SAASC,iBAAiB,QAAQ,6CAA4C;AAE9E,SAASC,2BAA2B,QAAQ,yBAAwB;AACpE,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,oBAAoBC,oBAAoB,QAAQ,8BAA6B;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\nimport type {\n Adapter,\n ClientUploadsConfig,\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'\nimport { initClientUploads } from '@payloadcms/plugin-cloud-storage/utilities'\n\nimport { getGenerateSignedURLHandler } from './generateSignedURL.js'\nimport { getGenerateURL } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\nimport { getStorageClient as getStorageClientFunc } from './utils/getStorageClient.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 * Optional cache key to identify the Azure Blob storage client instance.\n * If not provided, a default key will be used.\n *\n * @default `azure:containerName`\n */\n clientCacheKey?: string\n\n /**\n * Do uploads directly on the client to bypass limits on Vercel. You must allow CORS PUT method to your website.\n */\n clientUploads?: ClientUploadsConfig\n\n /**\n * Collection options to apply the Azure Blob adapter to.\n */\n collections: Partial<Record<UploadCollectionSlug, 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 const getStorageClient = () =>\n getStorageClientFunc({\n connectionString: azureStorageOptions.connectionString,\n containerName: azureStorageOptions.containerName,\n })\n\n const isPluginDisabled = azureStorageOptions.enabled === false\n\n initClientUploads({\n clientHandler: '@payloadcms/storage-azure/client#AzureClientUploadHandler',\n collections: azureStorageOptions.collections,\n config: incomingConfig,\n enabled: !isPluginDisabled && Boolean(azureStorageOptions.clientUploads),\n serverHandler: getGenerateSignedURLHandler({\n access:\n typeof azureStorageOptions.clientUploads === 'object'\n ? azureStorageOptions.clientUploads.access\n : undefined,\n collections: azureStorageOptions.collections,\n containerName: azureStorageOptions.containerName,\n getStorageClient,\n }),\n serverHandlerPath: '/storage-azure-generate-signed-url',\n })\n\n if (isPluginDisabled) {\n return incomingConfig\n }\n\n const adapter = azureStorageInternal(getStorageClient, 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 getStorageClient: () => ContainerClient,\n {\n allowContainerCreate,\n baseURL,\n clientUploads,\n connectionString,\n containerName,\n }: AzureStorageOptions,\n): Adapter {\n const createContainerIfNotExists = () => {\n void getStorageClientFunc({ connectionString, containerName }).createIfNotExists({\n access: 'blob',\n })\n }\n\n return ({ collection, prefix }): GeneratedAdapter => {\n return {\n name: 'azure',\n clientUploads,\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\nexport { getStorageClientFunc as getStorageClient }\n"],"names":["cloudStoragePlugin","initClientUploads","getGenerateSignedURLHandler","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","getStorageClient","getStorageClientFunc","azureStorage","azureStorageOptions","incomingConfig","connectionString","containerName","isPluginDisabled","enabled","clientHandler","collections","config","Boolean","clientUploads","serverHandler","access","undefined","serverHandlerPath","adapter","azureStorageInternal","collectionsWithAdapter","Object","entries","reduce","acc","slug","collOptions","map","collection","upload","disableLocalStorage","allowContainerCreate","baseURL","createContainerIfNotExists","createIfNotExists","prefix","name","generateURL","handleDelete","handleUpload","staticHandler","onInit"],"mappings":"AAUA,SAASA,kBAAkB,QAAQ,mCAAkC;AACrE,SAASC,iBAAiB,QAAQ,6CAA4C;AAE9E,SAASC,2BAA2B,QAAQ,yBAAwB;AACpE,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,oBAAoBC,oBAAoB,QAAQ,8BAA6B;AAqDtF,OAAO,MAAMC,eACX,CAACC,sBACD,CAACC;QACC,MAAMJ,mBAAmB,IACvBC,qBAAqB;gBACnBI,kBAAkBF,oBAAoBE,gBAAgB;gBACtDC,eAAeH,oBAAoBG,aAAa;YAClD;QAEF,MAAMC,mBAAmBJ,oBAAoBK,OAAO,KAAK;QAEzDd,kBAAkB;YAChBe,eAAe;YACfC,aAAaP,oBAAoBO,WAAW;YAC5CC,QAAQP;YACRI,SAAS,CAACD,oBAAoBK,QAAQT,oBAAoBU,aAAa;YACvEC,eAAenB,4BAA4B;gBACzCoB,QACE,OAAOZ,oBAAoBU,aAAa,KAAK,WACzCV,oBAAoBU,aAAa,CAACE,MAAM,GACxCC;gBACNN,aAAaP,oBAAoBO,WAAW;gBAC5CJ,eAAeH,oBAAoBG,aAAa;gBAChDN;YACF;YACAiB,mBAAmB;QACrB;QAEA,IAAIV,kBAAkB;YACpB,OAAOH;QACT;QAEA,MAAMc,UAAUC,qBAAqBnB,kBAAkBG;QAEvD,+CAA+C;QAC/C,MAAMiB,yBAAmEC,OAAOC,OAAO,CACrFnB,oBAAoBO,WAAW,EAC/Ba,MAAM,CACN,CAACC,KA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@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { ContainerClient } from '@azure/storage-blob';
|
|
2
2
|
import type { AzureStorageOptions } from '../index.js';
|
|
3
|
-
export declare function getStorageClient(options: Pick<AzureStorageOptions, 'connectionString' | 'containerName'>): ContainerClient;
|
|
3
|
+
export declare function getStorageClient(options: Pick<AzureStorageOptions, 'clientCacheKey' | 'connectionString' | 'containerName'>): ContainerClient;
|
|
4
4
|
//# sourceMappingURL=getStorageClient.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getStorageClient.d.ts","sourceRoot":"","sources":["../../src/utils/getStorageClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAI1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"getStorageClient.d.ts","sourceRoot":"","sources":["../../src/utils/getStorageClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAI1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAKtD,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,gBAAgB,GAAG,kBAAkB,GAAG,eAAe,CAAC,GAC1F,eAAe,CAcjB"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { BlobServiceClient } from '@azure/storage-blob';
|
|
2
|
-
|
|
2
|
+
// Cache the Azure Blob storage clients in a map so that multiple instances are not overriding each other in the case of different configurations used per collection
|
|
3
|
+
const azureClients = new Map();
|
|
3
4
|
export function getStorageClient(options) {
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
const cacheKey = options.clientCacheKey || `azure:${options.containerName}`;
|
|
6
|
+
if (azureClients.has(cacheKey)) {
|
|
7
|
+
return azureClients.get(cacheKey);
|
|
6
8
|
}
|
|
7
9
|
const { connectionString, containerName } = options;
|
|
8
10
|
const blobServiceClient = BlobServiceClient.fromConnectionString(connectionString);
|
|
9
|
-
|
|
10
|
-
return
|
|
11
|
+
azureClients.set(cacheKey, blobServiceClient.getContainerClient(containerName));
|
|
12
|
+
return azureClients.get(cacheKey);
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
//# sourceMappingURL=getStorageClient.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/getStorageClient.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\n\nimport { BlobServiceClient } from '@azure/storage-blob'\n\nimport type { AzureStorageOptions } from '../index.js'\n\
|
|
1
|
+
{"version":3,"sources":["../../src/utils/getStorageClient.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\n\nimport { BlobServiceClient } from '@azure/storage-blob'\n\nimport type { AzureStorageOptions } from '../index.js'\n\n// Cache the Azure Blob storage clients in a map so that multiple instances are not overriding each other in the case of different configurations used per collection\nconst azureClients = new Map<string, ContainerClient>()\n\nexport function getStorageClient(\n options: Pick<AzureStorageOptions, 'clientCacheKey' | 'connectionString' | 'containerName'>,\n): ContainerClient {\n const cacheKey = options.clientCacheKey || `azure:${options.containerName}`\n\n if (azureClients.has(cacheKey)) {\n return azureClients.get(cacheKey)!\n }\n\n const { connectionString, containerName } = options\n\n const blobServiceClient = BlobServiceClient.fromConnectionString(connectionString)\n\n azureClients.set(cacheKey, blobServiceClient.getContainerClient(containerName))\n\n return azureClients.get(cacheKey)!\n}\n"],"names":["BlobServiceClient","azureClients","Map","getStorageClient","options","cacheKey","clientCacheKey","containerName","has","get","connectionString","blobServiceClient","fromConnectionString","set","getContainerClient"],"mappings":"AAEA,SAASA,iBAAiB,QAAQ,sBAAqB;AAIvD,qKAAqK;AACrK,MAAMC,eAAe,IAAIC;AAEzB,OAAO,SAASC,iBACdC,OAA2F;IAE3F,MAAMC,WAAWD,QAAQE,cAAc,IAAI,CAAC,MAAM,EAAEF,QAAQG,aAAa,EAAE;IAE3E,IAAIN,aAAaO,GAAG,CAACH,WAAW;QAC9B,OAAOJ,aAAaQ,GAAG,CAACJ;IAC1B;IAEA,MAAM,EAAEK,gBAAgB,EAAEH,aAAa,EAAE,GAAGH;IAE5C,MAAMO,oBAAoBX,kBAAkBY,oBAAoB,CAACF;IAEjET,aAAaY,GAAG,CAACR,UAAUM,kBAAkBG,kBAAkB,CAACP;IAEhE,OAAON,aAAaQ,GAAG,CAACJ;AAC1B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/storage-azure",
|
|
3
|
-
"version": "3.62.0
|
|
3
|
+
"version": "3.62.0",
|
|
4
4
|
"description": "Payload storage adapter for Azure Blob Storage",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
"@azure/abort-controller": "^1.1.0",
|
|
41
41
|
"@azure/storage-blob": "^12.11.0",
|
|
42
42
|
"range-parser": "^1.2.1",
|
|
43
|
-
"@payloadcms/plugin-cloud-storage": "3.62.0
|
|
43
|
+
"@payloadcms/plugin-cloud-storage": "3.62.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/range-parser": "^1.2.7",
|
|
47
|
-
"payload": "3.62.0
|
|
47
|
+
"payload": "3.62.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"payload": "3.62.0
|
|
50
|
+
"payload": "3.62.0"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|
|
53
53
|
"node": "^18.20.2 || >=20.9.0"
|