@payloadcms/storage-azure 3.25.0-canary.fd53f68 → 3.26.0-canary.bbb3083

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/README.md CHANGED
@@ -14,6 +14,7 @@ pnpm add @payloadcms/storage-azure
14
14
 
15
15
  - Configure the `collections` object to specify which collections should use the Azure Blob Storage adapter. The slug _must_ match one of your existing collection slugs.
16
16
  - When enabled, this package will automatically set `disableLocalStorage` to `true` for each collection.
17
+ - When deploying to Vercel, server uploads are limited with 4.5MB. Set `clientUploads` to `true` to do uploads directly on the client. You must allow CORS PUT method to your website.
17
18
 
18
19
  ```ts
19
20
  import { azureStorage } from '@payloadcms/storage-azure'
@@ -49,3 +50,4 @@ export default buildConfig({
49
50
  | `baseURL` | Base URL for the Azure Blob storage account | |
50
51
  | `connectionString` | Azure Blob storage connection string | |
51
52
  | `containerName` | Azure Blob storage container name | |
53
+ | `clientUploads` | Do uploads directly on the client to bypass limits on Vercel. | |
@@ -0,0 +1,9 @@
1
+ export declare const AzureClientUploadHandler: ({ children, collectionSlug, enabled, extra, prefix, serverHandlerPath, }: {
2
+ children: import("react").ReactNode;
3
+ collectionSlug: import("packages/payload/src/index.js").UploadCollectionSlug;
4
+ enabled?: boolean;
5
+ extra: Record<string, unknown>;
6
+ prefix?: string;
7
+ serverHandlerPath: string;
8
+ }) => import("react").JSX.Element;
9
+ //# sourceMappingURL=AzureClientUploadHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AzureClientUploadHandler.d.ts","sourceRoot":"","sources":["../../src/client/AzureClientUploadHandler.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,wBAAwB;;;;;;;aAyBjB,OAEpB,aAAE,CAAA"}
@@ -0,0 +1,31 @@
1
+ 'use client';
2
+ import { createClientUploadHandler } from '@payloadcms/plugin-cloud-storage/client';
3
+ export const AzureClientUploadHandler = createClientUploadHandler({
4
+ handler: async ({ apiRoute, collectionSlug, file, prefix, serverHandlerPath, serverURL })=>{
5
+ const response = await fetch(`${serverURL}${apiRoute}${serverHandlerPath}`, {
6
+ body: JSON.stringify({
7
+ collectionSlug,
8
+ filename: file.name,
9
+ mimeType: file.type
10
+ }),
11
+ credentials: 'include',
12
+ method: 'POST'
13
+ });
14
+ const { url } = await response.json();
15
+ await fetch(url, {
16
+ body: file,
17
+ headers: {
18
+ 'Content-Length': file.size.toString(),
19
+ 'Content-Type': file.type,
20
+ // Required for azure
21
+ 'x-ms-blob-type': 'BlockBlob'
22
+ },
23
+ method: 'PUT'
24
+ });
25
+ return {
26
+ prefix
27
+ };
28
+ }
29
+ });
30
+
31
+ //# sourceMappingURL=AzureClientUploadHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/AzureClientUploadHandler.ts"],"sourcesContent":["'use client'\nimport { createClientUploadHandler } from '@payloadcms/plugin-cloud-storage/client'\n\nexport const AzureClientUploadHandler = createClientUploadHandler({\n handler: async ({ apiRoute, collectionSlug, file, prefix, serverHandlerPath, serverURL }) => {\n const response = await fetch(`${serverURL}${apiRoute}${serverHandlerPath}`, {\n body: JSON.stringify({\n collectionSlug,\n filename: file.name,\n mimeType: file.type,\n }),\n credentials: 'include',\n method: 'POST',\n })\n\n const { url } = await response.json()\n\n await fetch(url, {\n body: file,\n headers: {\n 'Content-Length': file.size.toString(),\n 'Content-Type': file.type,\n // Required for azure\n 'x-ms-blob-type': 'BlockBlob',\n },\n method: 'PUT',\n })\n\n return { prefix }\n },\n})\n"],"names":["createClientUploadHandler","AzureClientUploadHandler","handler","apiRoute","collectionSlug","file","prefix","serverHandlerPath","serverURL","response","fetch","body","JSON","stringify","filename","name","mimeType","type","credentials","method","url","json","headers","size","toString"],"mappings":"AAAA;AACA,SAASA,yBAAyB,QAAQ,0CAAyC;AAEnF,OAAO,MAAMC,2BAA2BD,0BAA0B;IAChEE,SAAS,OAAO,EAAEC,QAAQ,EAAEC,cAAc,EAAEC,IAAI,EAAEC,MAAM,EAAEC,iBAAiB,EAAEC,SAAS,EAAE;QACtF,MAAMC,WAAW,MAAMC,MAAM,GAAGF,YAAYL,WAAWI,mBAAmB,EAAE;YAC1EI,MAAMC,KAAKC,SAAS,CAAC;gBACnBT;gBACAU,UAAUT,KAAKU,IAAI;gBACnBC,UAAUX,KAAKY,IAAI;YACrB;YACAC,aAAa;YACbC,QAAQ;QACV;QAEA,MAAM,EAAEC,GAAG,EAAE,GAAG,MAAMX,SAASY,IAAI;QAEnC,MAAMX,MAAMU,KAAK;YACfT,MAAMN;YACNiB,SAAS;gBACP,kBAAkBjB,KAAKkB,IAAI,CAACC,QAAQ;gBACpC,gBAAgBnB,KAAKY,IAAI;gBACzB,qBAAqB;gBACrB,kBAAkB;YACpB;YACAE,QAAQ;QACV;QAEA,OAAO;YAAEb;QAAO;IAClB;AACF,GAAE"}
@@ -0,0 +1,2 @@
1
+ export { AzureClientUploadHandler } from '../client/AzureClientUploadHandler.js';
2
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/exports/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { AzureClientUploadHandler } from '../client/AzureClientUploadHandler.js';
2
+
3
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export { AzureClientUploadHandler } from '../client/AzureClientUploadHandler.js'\n"],"names":["AzureClientUploadHandler"],"mappings":"AAAA,SAASA,wBAAwB,QAAQ,wCAAuC"}
@@ -0,0 +1,13 @@
1
+ import type { ContainerClient } from '@azure/storage-blob';
2
+ import type { ClientUploadsAccess } from '@payloadcms/plugin-cloud-storage/types';
3
+ import type { PayloadHandler } from 'payload';
4
+ import type { AzureStorageOptions } from './index.js';
5
+ interface Args {
6
+ access?: ClientUploadsAccess;
7
+ collections: AzureStorageOptions['collections'];
8
+ containerName: string;
9
+ getStorageClient: () => ContainerClient;
10
+ }
11
+ export declare const getGenerateSignedURLHandler: ({ access, collections, containerName, getStorageClient, }: Args) => PayloadHandler;
12
+ export {};
13
+ //# sourceMappingURL=generateSignedURL.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateSignedURL.d.ts","sourceRoot":"","sources":["../src/generateSignedURL.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAA8B,MAAM,qBAAqB,CAAA;AACtF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAA;AACjF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAM7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAErD,UAAU,IAAI;IACZ,MAAM,CAAC,EAAE,mBAAmB,CAAA;IAC5B,WAAW,EAAE,mBAAmB,CAAC,aAAa,CAAC,CAAA;IAC/C,aAAa,EAAE,MAAM,CAAA;IACrB,gBAAgB,EAAE,MAAM,eAAe,CAAA;CACxC;AAID,eAAO,MAAM,2BAA2B,8DAKrC,IAAI,KAAG,cAqCT,CAAA"}
@@ -0,0 +1,38 @@
1
+ import { BlobSASPermissions, generateBlobSASQueryParameters } from '@azure/storage-blob';
2
+ import path from 'path';
3
+ import { APIError, Forbidden } from 'payload';
4
+ const defaultAccess = ({ req })=>!!req.user;
5
+ export const getGenerateSignedURLHandler = ({ access = defaultAccess, collections, containerName, getStorageClient })=>{
6
+ return async (req)=>{
7
+ if (!req.json) {
8
+ throw new APIError('Unreachable');
9
+ }
10
+ const { collectionSlug, filename, mimeType } = await req.json();
11
+ const collectionS3Config = collections[collectionSlug];
12
+ if (!collectionS3Config) {
13
+ throw new APIError(`Collection ${collectionSlug} was not found in S3 options`);
14
+ }
15
+ const prefix = typeof collectionS3Config === 'object' && collectionS3Config.prefix || '';
16
+ if (!await access({
17
+ collectionSlug,
18
+ req
19
+ })) {
20
+ throw new Forbidden();
21
+ }
22
+ const fileKey = path.posix.join(prefix, filename);
23
+ const blobClient = getStorageClient().getBlobClient(fileKey);
24
+ const sasToken = generateBlobSASQueryParameters({
25
+ blobName: fileKey,
26
+ containerName,
27
+ contentType: mimeType,
28
+ expiresOn: new Date(Date.now() + 30 * 60 * 1000),
29
+ permissions: BlobSASPermissions.parse('w'),
30
+ startsOn: new Date()
31
+ }, getStorageClient().credential);
32
+ return Response.json({
33
+ url: `${blobClient.url}?${sasToken.toString()}`
34
+ });
35
+ };
36
+ };
37
+
38
+ //# sourceMappingURL=generateSignedURL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/generateSignedURL.ts"],"sourcesContent":["import type { ContainerClient, StorageSharedKeyCredential } from '@azure/storage-blob'\nimport type { ClientUploadsAccess } from '@payloadcms/plugin-cloud-storage/types'\nimport type { PayloadHandler } from 'payload'\n\nimport { BlobSASPermissions, generateBlobSASQueryParameters } from '@azure/storage-blob'\nimport path from 'path'\nimport { APIError, Forbidden } from 'payload'\n\nimport type { AzureStorageOptions } from './index.js'\n\ninterface Args {\n access?: ClientUploadsAccess\n collections: AzureStorageOptions['collections']\n containerName: string\n getStorageClient: () => ContainerClient\n}\n\nconst defaultAccess: Args['access'] = ({ req }) => !!req.user\n\nexport const getGenerateSignedURLHandler = ({\n access = defaultAccess,\n collections,\n containerName,\n getStorageClient,\n}: Args): PayloadHandler => {\n return async (req) => {\n if (!req.json) {\n throw new APIError('Unreachable')\n }\n\n const { collectionSlug, filename, mimeType } = await req.json()\n\n const collectionS3Config = collections[collectionSlug]\n if (!collectionS3Config) {\n throw new APIError(`Collection ${collectionSlug} was not found in S3 options`)\n }\n\n const prefix = (typeof collectionS3Config === 'object' && collectionS3Config.prefix) || ''\n\n if (!(await access({ collectionSlug, req }))) {\n throw new Forbidden()\n }\n\n const fileKey = path.posix.join(prefix, filename)\n\n const blobClient = getStorageClient().getBlobClient(fileKey)\n\n const sasToken = generateBlobSASQueryParameters(\n {\n blobName: fileKey,\n containerName,\n contentType: mimeType,\n expiresOn: new Date(Date.now() + 30 * 60 * 1000),\n permissions: BlobSASPermissions.parse('w'),\n startsOn: new Date(),\n },\n getStorageClient().credential as StorageSharedKeyCredential,\n )\n\n return Response.json({ url: `${blobClient.url}?${sasToken.toString()}` })\n }\n}\n"],"names":["BlobSASPermissions","generateBlobSASQueryParameters","path","APIError","Forbidden","defaultAccess","req","user","getGenerateSignedURLHandler","access","collections","containerName","getStorageClient","json","collectionSlug","filename","mimeType","collectionS3Config","prefix","fileKey","posix","join","blobClient","getBlobClient","sasToken","blobName","contentType","expiresOn","Date","now","permissions","parse","startsOn","credential","Response","url","toString"],"mappings":"AAIA,SAASA,kBAAkB,EAAEC,8BAA8B,QAAQ,sBAAqB;AACxF,OAAOC,UAAU,OAAM;AACvB,SAASC,QAAQ,EAAEC,SAAS,QAAQ,UAAS;AAW7C,MAAMC,gBAAgC,CAAC,EAAEC,GAAG,EAAE,GAAK,CAAC,CAACA,IAAIC,IAAI;AAE7D,OAAO,MAAMC,8BAA8B,CAAC,EAC1CC,SAASJ,aAAa,EACtBK,WAAW,EACXC,aAAa,EACbC,gBAAgB,EACX;IACL,OAAO,OAAON;QACZ,IAAI,CAACA,IAAIO,IAAI,EAAE;YACb,MAAM,IAAIV,SAAS;QACrB;QAEA,MAAM,EAAEW,cAAc,EAAEC,QAAQ,EAAEC,QAAQ,EAAE,GAAG,MAAMV,IAAIO,IAAI;QAE7D,MAAMI,qBAAqBP,WAAW,CAACI,eAAe;QACtD,IAAI,CAACG,oBAAoB;YACvB,MAAM,IAAId,SAAS,CAAC,WAAW,EAAEW,eAAe,4BAA4B,CAAC;QAC/E;QAEA,MAAMI,SAAS,AAAC,OAAOD,uBAAuB,YAAYA,mBAAmBC,MAAM,IAAK;QAExF,IAAI,CAAE,MAAMT,OAAO;YAAEK;YAAgBR;QAAI,IAAK;YAC5C,MAAM,IAAIF;QACZ;QAEA,MAAMe,UAAUjB,KAAKkB,KAAK,CAACC,IAAI,CAACH,QAAQH;QAExC,MAAMO,aAAaV,mBAAmBW,aAAa,CAACJ;QAEpD,MAAMK,WAAWvB,+BACf;YACEwB,UAAUN;YACVR;YACAe,aAAaV;YACbW,WAAW,IAAIC,KAAKA,KAAKC,GAAG,KAAK,KAAK,KAAK;YAC3CC,aAAa9B,mBAAmB+B,KAAK,CAAC;YACtCC,UAAU,IAAIJ;QAChB,GACAhB,mBAAmBqB,UAAU;QAG/B,OAAOC,SAASrB,IAAI,CAAC;YAAEsB,KAAK,GAAGb,WAAWa,GAAG,CAAC,CAAC,EAAEX,SAASY,QAAQ,IAAI;QAAC;IACzE;AACF,EAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CollectionOptions } from '@payloadcms/plugin-cloud-storage/types';
1
+ import type { ClientUploadsConfig, CollectionOptions } from '@payloadcms/plugin-cloud-storage/types';
2
2
  import type { Plugin, UploadCollectionSlug } from 'payload';
3
3
  import { getStorageClient as getStorageClientFunc } from './utils/getStorageClient.js';
4
4
  export type AzureStorageOptions = {
@@ -12,6 +12,10 @@ export type AzureStorageOptions = {
12
12
  * Base URL for the Azure Blob storage account
13
13
  */
14
14
  baseURL: string;
15
+ /**
16
+ * Do uploads directly on the client to bypass limits on Vercel. You must allow CORS PUT method to your website.
17
+ */
18
+ clientUploads?: ClientUploadsConfig;
15
19
  /**
16
20
  * Collection options to apply the Azure Blob adapter to.
17
21
  */
@@ -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;AAQnE,OAAO,EAAE,gBAAgB,IAAI,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAEtF,MAAM,MAAM,mBAAmB,GAAG;IAChC;;;;OAIG;IACH,oBAAo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AAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,KAAK,kBAAkB,GAAG,CAAC,gBAAgB,EAAE,mBAAmB,KAAK,MAAM,CAAA;AAE3E,eAAO,MAAM,YAAY,EAAE,kBAmExB,CAAA;AA4BH,OAAO,EAAE,oBAAoB,IAAI,gBAAgB,EAAE,CAAA"}
package/dist/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { cloudStoragePlugin } from '@payloadcms/plugin-cloud-storage';
2
+ import { initClientUploads } from '@payloadcms/plugin-cloud-storage/utilities';
3
+ import { getGenerateSignedURLHandler } from './generateSignedURL.js';
2
4
  import { getGenerateURL } from './generateURL.js';
3
5
  import { getHandleDelete } from './handleDelete.js';
4
6
  import { getHandleUpload } from './handleUpload.js';
@@ -8,7 +10,24 @@ export const azureStorage = (azureStorageOptions)=>(incomingConfig)=>{
8
10
  if (azureStorageOptions.enabled === false) {
9
11
  return incomingConfig;
10
12
  }
11
- const adapter = azureStorageInternal(azureStorageOptions);
13
+ const getStorageClient = ()=>getStorageClientFunc({
14
+ connectionString: azureStorageOptions.connectionString,
15
+ containerName: azureStorageOptions.containerName
16
+ });
17
+ initClientUploads({
18
+ clientHandler: '@payloadcms/storage-azure/client#AzureClientUploadHandler',
19
+ collections: azureStorageOptions.collections,
20
+ config: incomingConfig,
21
+ enabled: !!azureStorageOptions.clientUploads,
22
+ serverHandler: getGenerateSignedURLHandler({
23
+ access: typeof azureStorageOptions.clientUploads === 'object' ? azureStorageOptions.clientUploads.access : undefined,
24
+ collections: azureStorageOptions.collections,
25
+ containerName: azureStorageOptions.containerName,
26
+ getStorageClient
27
+ }),
28
+ serverHandlerPath: '/storage-azure-generate-signed-url'
29
+ });
30
+ const adapter = azureStorageInternal(getStorageClient, azureStorageOptions);
12
31
  // Add adapter to each collection option object
13
32
  const collectionsWithAdapter = Object.entries(azureStorageOptions.collections).reduce((acc, [slug, collOptions])=>({
14
33
  ...acc,
@@ -37,7 +56,7 @@ export const azureStorage = (azureStorageOptions)=>(incomingConfig)=>{
37
56
  collections: collectionsWithAdapter
38
57
  })(config);
39
58
  };
40
- function azureStorageInternal({ allowContainerCreate, baseURL, connectionString, containerName }) {
59
+ function azureStorageInternal(getStorageClient, { allowContainerCreate, baseURL, connectionString, containerName }) {
41
60
  const createContainerIfNotExists = ()=>{
42
61
  void getStorageClientFunc({
43
62
  connectionString,
@@ -46,10 +65,6 @@ function azureStorageInternal({ allowContainerCreate, baseURL, connectionString,
46
65
  access: 'blob'
47
66
  });
48
67
  };
49
- const getStorageClient = ()=>getStorageClientFunc({
50
- connectionString,
51
- containerName
52
- });
53
68
  return ({ collection, prefix })=>{
54
69
  return {
55
70
  name: 'azure',
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 { 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 * 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 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 const createContainerIfNotExists = () => {\n void getStorageClientFunc({ connectionString, containerName }).createIfNotExists({\n access: 'blob',\n })\n }\n\n const getStorageClient = () => getStorageClientFunc({ connectionString, containerName })\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","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","getStorageClient","getStorageClientFunc","azureStorage","azureStorageOptions","incomingConfig","enabled","adapter","azureStorageInternal","collectionsWithAdapter","Object","entries","collections","reduce","acc","slug","collOptions","config","map","collection","upload","disableLocalStorage","allowContainerCreate","baseURL","connectionString","containerName","createContainerIfNotExists","createIfNotExists","access","prefix","name","generateURL","handleDelete","handleUpload","staticHandler","onInit"],"mappings":"AAQA,SAASA,kBAAkB,QAAQ,mCAAkC;AAErE,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;AAwCtF,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,OAAOzB,mBAAmB;YACxBgB,aAAaH;QACf,GAAGQ;IACL,EAAC;AAEH,SAAST,qBAAqB,EAC5Bc,oBAAoB,EACpBC,OAAO,EACPC,gBAAgB,EAChBC,aAAa,EACO;IACpB,MAAMC,6BAA6B;QACjC,KAAKxB,qBAAqB;YAAEsB;YAAkBC;QAAc,GAAGE,iBAAiB,CAAC;YAC/EC,QAAQ;QACV;IACF;IAEA,MAAM3B,mBAAmB,IAAMC,qBAAqB;YAAEsB;YAAkBC;QAAc;IAEtF,OAAO,CAAC,EAAEN,UAAU,EAAEU,MAAM,EAAE;QAC5B,OAAO;YACLC,MAAM;YACNC,aAAalC,eAAe;gBAAE0B;gBAASE;YAAc;YACrDO,cAAclC,gBAAgB;gBAAEqB;gBAAYlB;YAAiB;YAC7DgC,cAAclC,gBAAgB;gBAC5BoB;gBACAlB;gBACA4B;YACF;YACAK,eAAelC,WAAW;gBAAEmB;gBAAYlB;YAAiB;YACzD,GAAIqB,wBAAwB;gBAAEa,QAAQT;YAA2B,CAAC;QACpE;IACF;AACF;AAEA,SAASxB,wBAAwBD,gBAAgB,GAAE"}
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 if (azureStorageOptions.enabled === false) {\n return incomingConfig\n }\n\n const getStorageClient = () =>\n getStorageClientFunc({\n connectionString: azureStorageOptions.connectionString,\n containerName: azureStorageOptions.containerName,\n })\n\n initClientUploads({\n clientHandler: '@payloadcms/storage-azure/client#AzureClientUploadHandler',\n collections: azureStorageOptions.collections,\n config: incomingConfig,\n enabled: !!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 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","enabled","connectionString","containerName","clientHandler","collections","config","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;AA6CtF,OAAO,MAAMC,eACX,CAACC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AaS;QACf,GAAGR;IACL,EAAC;AAEH,SAASO,qBACPjB,gBAAuC,EACvC,EAAE6B,oBAAoB,EAAEC,OAAO,EAAExB,gBAAgB,EAAEC,aAAa,EAAuB;IAEvF,MAAMwB,6BAA6B;QACjC,KAAK9B,qBAAqB;YAAEK;YAAkBC;QAAc,GAAGyB,iBAAiB,CAAC;YAC/EnB,QAAQ;QACV;IACF;IAEA,OAAO,CAAC,EAAEa,UAAU,EAAEO,MAAM,EAAE;QAC5B,OAAO;YACLC,MAAM;YACNC,aAAavC,eAAe;gBAAEkC;gBAASvB;YAAc;YACrD6B,cAAcvC,gBAAgB;gBAAE6B;gBAAY1B;YAAiB;YAC7DqC,cAAcvC,gBAAgB;gBAC5B4B;gBACA1B;gBACAiC;YACF;YACAK,eAAevC,WAAW;gBAAE2B;gBAAY1B;YAAiB;YACzD,GAAI6B,wBAAwB;gBAAEU,QAAQR;YAA2B,CAAC;QACpE;IACF;AACF;AAEA,SAAS9B,wBAAwBD,gBAAgB,GAAE"}
@@ -2,9 +2,10 @@ import { getFilePrefix } from '@payloadcms/plugin-cloud-storage/utilities';
2
2
  import path from 'path';
3
3
  import { getRangeFromHeader } from './utils/getRangeFromHeader.js';
4
4
  export const getHandler = ({ collection, getStorageClient })=>{
5
- return async (req, { params: { filename } })=>{
5
+ return async (req, { params: { clientUploadContext, filename } })=>{
6
6
  try {
7
7
  const prefix = await getFilePrefix({
8
+ clientUploadContext,
8
9
  collection,
9
10
  filename,
10
11
  req
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/staticHandler.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\nimport type { StaticHandler } from '@payloadcms/plugin-cloud-storage/types'\nimport type { CollectionConfig } from 'payload'\n\nimport { getFilePrefix } from '@payloadcms/plugin-cloud-storage/utilities'\nimport path from 'path'\n\nimport { getRangeFromHeader } from './utils/getRangeFromHeader.js'\n\ninterface Args {\n collection: CollectionConfig\n getStorageClient: () => ContainerClient\n}\n\nexport const getHandler = ({ collection, getStorageClient }: Args): StaticHandler => {\n return async (req, { params: { filename } }) => {\n try {\n const prefix = await getFilePrefix({ collection, filename, req })\n const blockBlobClient = getStorageClient().getBlockBlobClient(\n path.posix.join(prefix, filename),\n )\n\n const { end, start } = await getRangeFromHeader(\n blockBlobClient,\n String(req.headers.get('range')),\n )\n\n const blob = await blockBlobClient.download(start, end)\n\n const response = blob._response\n\n const etagFromHeaders = req.headers.get('etag') || req.headers.get('if-none-match')\n const objectEtag = response.headers.get('etag')\n\n if (etagFromHeaders && etagFromHeaders === objectEtag) {\n return new Response(null, {\n headers: new Headers({\n ...response.headers.rawHeaders(),\n }),\n status: 304,\n })\n }\n\n // Manually create a ReadableStream for the web from a Node.js stream.\n const readableStream = new ReadableStream({\n start(controller) {\n const nodeStream = blob.readableStreamBody\n if (!nodeStream) {\n throw new Error('No readable stream body')\n }\n\n nodeStream.on('data', (chunk) => {\n controller.enqueue(new Uint8Array(chunk))\n })\n nodeStream.on('end', () => {\n controller.close()\n })\n nodeStream.on('error', (err) => {\n controller.error(err)\n })\n },\n })\n\n return new Response(readableStream, {\n headers: response.headers.rawHeaders(),\n status: response.status,\n })\n } catch (err: unknown) {\n req.payload.logger.error(err)\n return new Response('Internal Server Error', { status: 500 })\n }\n }\n}\n"],"names":["getFilePrefix","path","getRangeFromHeader","getHandler","collection","getStorageClient","req","params","filename","prefix","blockBlobClient","getBlockBlobClient","posix","join","end","start","String","headers","get","blob","download","response","_response","etagFromHeaders","objectEtag","Response","Headers","rawHeaders","status","readableStream","ReadableStream","controller","nodeStream","readableStreamBody","Error","on","chunk","enqueue","Uint8Array","close","err","error","payload","logger"],"mappings":"AAIA,SAASA,aAAa,QAAQ,6CAA4C;AAC1E,OAAOC,UAAU,OAAM;AAEvB,SAASC,kBAAkB,QAAQ,gCAA+B;AAOlE,OAAO,MAAMC,aAAa,CAAC,EAAEC,UAAU,EAAEC,gBAAgB,EAAQ;IAC/D,OAAO,OAAOC,KAAK,EAAEC,QA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MAAM;YACzB;QACF,EAAE,OAAOY,KAAc;YACrBlC,IAAIoC,OAAO,CAACC,MAAM,CAACF,KAAK,CAACD;YACzB,OAAO,IAAIf,SAAS,yBAAyB;gBAAEG,QAAQ;YAAI;QAC7D;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../src/staticHandler.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\nimport type { StaticHandler } from '@payloadcms/plugin-cloud-storage/types'\nimport type { CollectionConfig } from 'payload'\n\nimport { getFilePrefix } from '@payloadcms/plugin-cloud-storage/utilities'\nimport path from 'path'\n\nimport { getRangeFromHeader } from './utils/getRangeFromHeader.js'\n\ninterface Args {\n collection: CollectionConfig\n getStorageClient: () => ContainerClient\n}\n\nexport const getHandler = ({ collection, getStorageClient }: Args): StaticHandler => {\n return async (req, { params: { clientUploadContext, filename } }) => {\n try {\n const prefix = await getFilePrefix({ clientUploadContext, collection, filename, req })\n const blockBlobClient = getStorageClient().getBlockBlobClient(\n path.posix.join(prefix, filename),\n )\n\n const { end, start } = await getRangeFromHeader(\n blockBlobClient,\n String(req.headers.get('range')),\n )\n\n const blob = await blockBlobClient.download(start, end)\n\n const response = blob._response\n\n const etagFromHeaders = req.headers.get('etag') || req.headers.get('if-none-match')\n const objectEtag = response.headers.get('etag')\n\n if (etagFromHeaders && etagFromHeaders === objectEtag) {\n return new Response(null, {\n headers: new Headers({\n ...response.headers.rawHeaders(),\n }),\n status: 304,\n })\n }\n\n // Manually create a ReadableStream for the web from a Node.js stream.\n const readableStream = new ReadableStream({\n start(controller) {\n const nodeStream = blob.readableStreamBody\n if (!nodeStream) {\n throw new Error('No readable stream body')\n }\n\n nodeStream.on('data', (chunk) => {\n controller.enqueue(new Uint8Array(chunk))\n })\n nodeStream.on('end', () => {\n controller.close()\n })\n nodeStream.on('error', (err) => {\n controller.error(err)\n })\n },\n })\n\n return new Response(readableStream, {\n headers: response.headers.rawHeaders(),\n status: response.status,\n })\n } catch (err: unknown) {\n req.payload.logger.error(err)\n return new Response('Internal Server Error', { status: 500 })\n }\n }\n}\n"],"names":["getFilePrefix","path","getRangeFromHeader","getHandler","collection","getStorageClient","req","params","clientUploadContext","filename","prefix","blockBlobClient","getBlockBlobClient","posix","join","end","start","String","headers","get","blob","download","response","_response","etagFromHeaders","objectEtag","Response","Headers","rawHeaders","status","readableStream","ReadableStream","controller","nodeStream","readableStreamBody","Error","on","chunk","enqueue","Uint8Array","close","err","error","payload","logger"],"mappings":"AAIA,SAASA,aAAa,QAAQ,6CAA4C;AAC1E,OAAOC,UAAU,OAAM;AAEvB,SAASC,kBAAkB,QAAQ,gCAA+B;AAOlE,OAAO,MAAMC,aAAa,CAAC,EAAEC,UAAU,EAAEC,gBAAgB,EAAQ;IAC/D,OAAO,OAAOC,KAAK,EAAEC,QAAQ,EAAEC,mBAAmB,EAAEC,QAAQ,EAAE,EAAE;QAC9D,IAAI;YACF,MAAMC,SAAS,MAAMV,cAAc;gBAAEQ;gBAAqBJ;gBAAYK;gBAAUH;YAAI;YACpF,MAAMK,kBAAkBN,mBAAmBO,kBAAkB,CAC3DX,KAAKY,KAAK,CAACC,IAAI,CAACJ,QAAQD;YAG1B,MAAM,EAAEM,GAAG,EAAEC,KAAK,EAAE,GAAG,MAAMd,mBAC3BS,iBACAM,OAAOX,IAAIY,OAAO,CAACC,GAAG,CAAC;YAGzB,MAAMC,OAAO,MAAMT,gBAAgBU,QAAQ,CAACL,OAAOD;YAEnD,MAAMO,WAAWF,KAAKG,SAAS;YAE/B,MAAMC,kBAAkBlB,IAAIY,OAAO,CAACC,GAAG,CAAC,WAAWb,IAAIY,OAAO,CAACC,GAAG,CAAC;YACnE,MAAMM,aAAaH,SAASJ,OAAO,CAACC,GAAG,CAAC;YAExC,IAAIK,mBAAmBA,oBAAoBC,YAAY;gBACrD,OAAO,IAAIC,SAAS,MAAM;oBACxBR,SAAS,IAAIS,QAAQ;wBACnB,GAAGL,SAASJ,OAAO,CAACU,UAAU,EAAE;oBAClC;oBACAC,QAAQ;gBACV;YACF;YAEA,sEAAsE;YACtE,MAAMC,iBAAiB,IAAIC,eAAe;gBACxCf,OAAMgB,UAAU;oBACd,MAAMC,aAAab,KAAKc,kBAAkB;oBAC1C,IAAI,CAACD,YAAY;wBACf,MAAM,IAAIE,MAAM;oBAClB;oBAEAF,WAAWG,EAAE,CAAC,QAAQ,CAACC;wBACrBL,WAAWM,OAAO,CAAC,IAAIC,WAAWF;oBACpC;oBACAJ,WAAWG,EAAE,CAAC,OAAO;wBACnBJ,WAAWQ,KAAK;oBAClB;oBACAP,WAAWG,EAAE,CAAC,SAAS,CAACK;wBACtBT,WAAWU,KAAK,CAACD;oBACnB;gBACF;YACF;YAEA,OAAO,IAAIf,SAASI,gBAAgB;gBAClCZ,SAASI,SAASJ,OAAO,CAACU,UAAU;gBACpCC,QAAQP,SAASO,MAAM;YACzB;QACF,EAAE,OAAOY,KAAc;YACrBnC,IAAIqC,OAAO,CAACC,MAAM,CAACF,KAAK,CAACD;YACzB,OAAO,IAAIf,SAAS,yBAAyB;gBAAEG,QAAQ;YAAI;QAC7D;IACF;AACF,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/storage-azure",
3
- "version": "3.25.0-canary.fd53f68",
3
+ "version": "3.26.0-canary.bbb3083",
4
4
  "description": "Payload storage adapter for Azure Blob Storage",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -23,6 +23,11 @@
23
23
  "import": "./dist/index.js",
24
24
  "types": "./dist/index.d.ts",
25
25
  "default": "./dist/index.js"
26
+ },
27
+ "./client": {
28
+ "import": "./dist/exports/client.js",
29
+ "types": "./dist/exports/client.d.ts",
30
+ "default": "./dist/exports/client.js"
26
31
  }
27
32
  },
28
33
  "main": "./dist/index.js",
@@ -34,14 +39,14 @@
34
39
  "@azure/abort-controller": "^1.1.0",
35
40
  "@azure/storage-blob": "^12.11.0",
36
41
  "range-parser": "^1.2.1",
37
- "@payloadcms/plugin-cloud-storage": "3.25.0-canary.fd53f68"
42
+ "@payloadcms/plugin-cloud-storage": "3.26.0-canary.bbb3083"
38
43
  },
39
44
  "devDependencies": {
40
45
  "@types/range-parser": "^1.2.7",
41
- "payload": "3.25.0-canary.fd53f68"
46
+ "payload": "3.26.0-canary.bbb3083"
42
47
  },
43
48
  "peerDependencies": {
44
- "payload": "3.25.0-canary.fd53f68"
49
+ "payload": "3.26.0-canary.bbb3083"
45
50
  },
46
51
  "engines": {
47
52
  "node": "^18.20.2 || >=20.9.0"