@payloadcms/storage-azure 3.26.0-canary.bbb3083 → 3.27.0-canary.ecc3f49
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.map +1 -1
- package/dist/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
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;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,oBAAoB,EAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAE7F;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAA;IAExB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAA;IAErB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,KAAK,kBAAkB,GAAG,CAAC,gBAAgB,EAAE,mBAAmB,KAAK,MAAM,CAAA;AAE3E,eAAO,MAAM,YAAY,EAAE,
|
|
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;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,oBAAoB,EAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAE7F;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAA;IAExB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAA;IAErB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,KAAK,kBAAkB,GAAG,CAAC,gBAAgB,EAAE,mBAAmB,KAAK,MAAM,CAAA;AAE3E,eAAO,MAAM,YAAY,EAAE,kBAqExB,CAAA;AA4BH,OAAO,EAAE,oBAAoB,IAAI,gBAAgB,EAAE,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -7,18 +7,16 @@ import { getHandleUpload } from './handleUpload.js';
|
|
|
7
7
|
import { getHandler } from './staticHandler.js';
|
|
8
8
|
import { getStorageClient as getStorageClientFunc } from './utils/getStorageClient.js';
|
|
9
9
|
export const azureStorage = (azureStorageOptions)=>(incomingConfig)=>{
|
|
10
|
-
if (azureStorageOptions.enabled === false) {
|
|
11
|
-
return incomingConfig;
|
|
12
|
-
}
|
|
13
10
|
const getStorageClient = ()=>getStorageClientFunc({
|
|
14
11
|
connectionString: azureStorageOptions.connectionString,
|
|
15
12
|
containerName: azureStorageOptions.containerName
|
|
16
13
|
});
|
|
14
|
+
const isPluginDisabled = azureStorageOptions.enabled === false;
|
|
17
15
|
initClientUploads({
|
|
18
16
|
clientHandler: '@payloadcms/storage-azure/client#AzureClientUploadHandler',
|
|
19
17
|
collections: azureStorageOptions.collections,
|
|
20
18
|
config: incomingConfig,
|
|
21
|
-
enabled:
|
|
19
|
+
enabled: !isPluginDisabled && Boolean(azureStorageOptions.clientUploads),
|
|
22
20
|
serverHandler: getGenerateSignedURLHandler({
|
|
23
21
|
access: typeof azureStorageOptions.clientUploads === 'object' ? azureStorageOptions.clientUploads.access : undefined,
|
|
24
22
|
collections: azureStorageOptions.collections,
|
|
@@ -27,6 +25,9 @@ export const azureStorage = (azureStorageOptions)=>(incomingConfig)=>{
|
|
|
27
25
|
}),
|
|
28
26
|
serverHandlerPath: '/storage-azure-generate-signed-url'
|
|
29
27
|
});
|
|
28
|
+
if (isPluginDisabled) {
|
|
29
|
+
return incomingConfig;
|
|
30
|
+
}
|
|
30
31
|
const adapter = azureStorageInternal(getStorageClient, azureStorageOptions);
|
|
31
32
|
// Add adapter to each collection option object
|
|
32
33
|
const collectionsWithAdapter = Object.entries(azureStorageOptions.collections).reduce((acc, [slug, collOptions])=>({
|
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
|
|
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 { allowContainerCreate, baseURL, connectionString, containerName }: 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 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,oB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GAAG,CAAC,CAAC;wBAClEC,qBAAqB;oBACvB;gBACF;YACF;QACF;QAEA,OAAOrC,mBAAmB;YACxBiB,aAAaU;QACf,GAAGT;IACL,EAAC;AAEH,SAASQ,qBACPnB,gBAAuC,EACvC,EAAE+B,oBAAoB,EAAEC,OAAO,EAAE3B,gBAAgB,EAAEC,aAAa,EAAuB;IAEvF,MAAM2B,6BAA6B;QACjC,KAAKhC,qBAAqB;YAAEI;YAAkBC;QAAc,GAAG4B,iBAAiB,CAAC;YAC/EnB,QAAQ;QACV;IACF;IAEA,OAAO,CAAC,EAAEa,UAAU,EAAEO,MAAM,EAAE;QAC5B,OAAO;YACLC,MAAM;YACNC,aAAazC,eAAe;gBAAEoC;gBAAS1B;YAAc;YACrDgC,cAAczC,gBAAgB;gBAAE+B;gBAAY5B;YAAiB;YAC7DuC,cAAczC,gBAAgB;gBAC5B8B;gBACA5B;gBACAmC;YACF;YACAK,eAAezC,WAAW;gBAAE6B;gBAAY5B;YAAiB;YACzD,GAAI+B,wBAAwB;gBAAEU,QAAQR;YAA2B,CAAC;QACpE;IACF;AACF;AAEA,SAAShC,wBAAwBD,gBAAgB,GAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/storage-azure",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.27.0-canary.ecc3f49",
|
|
4
4
|
"description": "Payload storage adapter for Azure Blob Storage",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
"@azure/abort-controller": "^1.1.0",
|
|
40
40
|
"@azure/storage-blob": "^12.11.0",
|
|
41
41
|
"range-parser": "^1.2.1",
|
|
42
|
-
"@payloadcms/plugin-cloud-storage": "3.
|
|
42
|
+
"@payloadcms/plugin-cloud-storage": "3.27.0-canary.ecc3f49"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/range-parser": "^1.2.7",
|
|
46
|
-
"payload": "3.
|
|
46
|
+
"payload": "3.27.0-canary.ecc3f49"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"payload": "3.
|
|
49
|
+
"payload": "3.27.0-canary.ecc3f49"
|
|
50
50
|
},
|
|
51
51
|
"engines": {
|
|
52
52
|
"node": "^18.20.2 || >=20.9.0"
|