@payloadcms/plugin-cloud-storage 3.0.0-alpha.48 → 3.0.0-alpha.50

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/azure/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,gBAAgB,CAAA;AAO/D,MAAM,WAAW,IAAI;IACnB,oBAAoB,EAAE,OAAO,CAAA;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,gBAAgB,EAAE,MAAM,CAAA;IACxB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,eAAO,MAAM,uBAAuB,wEAKjC,IAAI,KAAG,OAyBT,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/azure/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,gBAAgB,CAAA;AAO/D,MAAM,WAAW,IAAI;IACnB,oBAAoB,EAAE,OAAO,CAAA;IAC7B,OAAO,EAAE,MAAM,CAAA;IACf,gBAAgB,EAAE,MAAM,CAAA;IACxB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,eAAO,MAAM,uBAAuB,wEAKjC,IAAI,KAAG,OA0CT,CAAA"}
@@ -4,10 +4,22 @@ import { getHandleDelete } from './handleDelete.js';
4
4
  import { getHandleUpload } from './handleUpload.js';
5
5
  import { getHandler } from './staticHandler.js';
6
6
  export const azureBlobStorageAdapter = ({ allowContainerCreate, baseURL, connectionString, containerName })=>{
7
+ if (!BlobServiceClient) {
8
+ throw new Error('The package @azure/storage-blob is not installed, but is required for the plugin-cloud-storage Azure adapter. Please install it.');
9
+ }
7
10
  let storageClient = null;
8
11
  const getStorageClient = ()=>{
9
12
  if (storageClient) return storageClient;
10
- const blobServiceClient = BlobServiceClient.fromConnectionString(connectionString);
13
+ let blobServiceClient = null;
14
+ try {
15
+ blobServiceClient = BlobServiceClient.fromConnectionString(connectionString);
16
+ } catch (error) {
17
+ if (/is not a constructor$/.test(error.message)) {
18
+ throw new Error('The package @azure/storage-blob is not installed, but is required for the plugin-cloud-storage Azure adapter. Please install it.');
19
+ }
20
+ // Re-throw other unexpected errors.
21
+ throw error;
22
+ }
11
23
  return storageClient = blobServiceClient.getContainerClient(containerName);
12
24
  };
13
25
  const createContainerIfNotExists = ()=>{
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/azure/index.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\n\nimport { BlobServiceClient } from '@azure/storage-blob'\n\nimport type { Adapter, GeneratedAdapter } from '../../types.js'\n\nimport { getGenerateURL } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\n\nexport interface Args {\n allowContainerCreate: boolean\n baseURL: string\n connectionString: string\n containerName: string\n}\n\nexport const azureBlobStorageAdapter = ({\n allowContainerCreate,\n baseURL,\n connectionString,\n containerName,\n}: Args): Adapter => {\n let storageClient: ContainerClient | null = null\n const getStorageClient = () => {\n if (storageClient) return storageClient\n const blobServiceClient = BlobServiceClient.fromConnectionString(connectionString)\n return (storageClient = blobServiceClient.getContainerClient(containerName))\n }\n\n const createContainerIfNotExists = () => {\n getStorageClient().createIfNotExists({ access: 'blob' })\n }\n\n return ({ collection, prefix }): GeneratedAdapter => {\n return {\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","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","azureBlobStorageAdapter","allowContainerCreate","baseURL","connectionString","containerName","storageClient","getStorageClient","blobServiceClient","fromConnectionString","getContainerClient","createContainerIfNotExists","createIfNotExists","access","collection","prefix","generateURL","handleDelete","handleUpload","staticHandler","onInit"],"mappings":"AAEA,SAASA,iBAAiB,QAAQ,sBAAqB;AAIvD,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAS/C,OAAO,MAAMC,0BAA0B,CAAC,EACtCC,oBAAoB,EACpBC,OAAO,EACPC,gBAAgB,EAChBC,aAAa,EACR;IACL,IAAIC,gBAAwC;IAC5C,MAAMC,mBAAmB;QACvB,IAAID,eAAe,OAAOA;QAC1B,MAAME,oBAAoBZ,kBAAkBa,oBAAoB,CAACL;QACjE,OAAQE,gBAAgBE,kBAAkBE,kBAAkB,CAACL;IAC/D;IAEA,MAAMM,6BAA6B;QACjCJ,mBAAmBK,iBAAiB,CAAC;YAAEC,QAAQ;QAAO;IACxD;IAEA,OAAO,CAAC,EAAEC,UAAU,EAAEC,MAAM,EAAE;QAC5B,OAAO;YACLC,aAAanB,eAAe;gBAAEM;gBAASE;YAAc;YACrDY,cAAcnB,gBAAgB;gBAAEgB;gBAAYP;YAAiB;YAC7DW,cAAcnB,gBAAgB;gBAC5Be;gBACAP;gBACAQ;YACF;YACAI,eAAenB,WAAW;gBAAEc;gBAAYP;YAAiB;YACzD,GAAIL,wBAAwB;gBAAEkB,QAAQT;YAA2B,CAAC;QACpE;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/adapters/azure/index.ts"],"sourcesContent":["import type { ContainerClient } from '@azure/storage-blob'\n\nimport { BlobServiceClient } from '@azure/storage-blob'\n\nimport type { Adapter, GeneratedAdapter } from '../../types.js'\n\nimport { getGenerateURL } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\n\nexport interface Args {\n allowContainerCreate: boolean\n baseURL: string\n connectionString: string\n containerName: string\n}\n\nexport const azureBlobStorageAdapter = ({\n allowContainerCreate,\n baseURL,\n connectionString,\n containerName,\n}: Args): Adapter => {\n if (!BlobServiceClient) {\n throw new Error(\n 'The package @azure/storage-blob is not installed, but is required for the plugin-cloud-storage Azure adapter. Please install it.',\n )\n }\n\n let storageClient: ContainerClient | null = null\n const getStorageClient = () => {\n if (storageClient) return storageClient\n let blobServiceClient = null\n try {\n blobServiceClient = BlobServiceClient.fromConnectionString(connectionString)\n } catch (error) {\n if (/is not a constructor$/.test(error.message)) {\n throw new Error(\n 'The package @azure/storage-blob is not installed, but is required for the plugin-cloud-storage Azure adapter. Please install it.',\n )\n }\n // Re-throw other unexpected errors.\n throw error\n }\n return (storageClient = blobServiceClient.getContainerClient(containerName))\n }\n\n const createContainerIfNotExists = () => {\n getStorageClient().createIfNotExists({ access: 'blob' })\n }\n\n return ({ collection, prefix }): GeneratedAdapter => {\n return {\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","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","azureBlobStorageAdapter","allowContainerCreate","baseURL","connectionString","containerName","Error","storageClient","getStorageClient","blobServiceClient","fromConnectionString","error","test","message","getContainerClient","createContainerIfNotExists","createIfNotExists","access","collection","prefix","generateURL","handleDelete","handleUpload","staticHandler","onInit"],"mappings":"AAEA,SAASA,iBAAiB,QAAQ,sBAAqB;AAIvD,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAS/C,OAAO,MAAMC,0BAA0B,CAAC,EACtCC,oBAAoB,EACpBC,OAAO,EACPC,gBAAgB,EAChBC,aAAa,EACR;IACL,IAAI,CAACT,mBAAmB;QACtB,MAAM,IAAIU,MACR;IAEJ;IAEA,IAAIC,gBAAwC;IAC5C,MAAMC,mBAAmB;QACvB,IAAID,eAAe,OAAOA;QAC1B,IAAIE,oBAAoB;QACxB,IAAI;YACFA,oBAAoBb,kBAAkBc,oBAAoB,CAACN;QAC7D,EAAE,OAAOO,OAAO;YACd,IAAI,wBAAwBC,IAAI,CAACD,MAAME,OAAO,GAAG;gBAC/C,MAAM,IAAIP,MACR;YAEJ;YACA,oCAAoC;YACpC,MAAMK;QACR;QACA,OAAQJ,gBAAgBE,kBAAkBK,kBAAkB,CAACT;IAC/D;IAEA,MAAMU,6BAA6B;QACjCP,mBAAmBQ,iBAAiB,CAAC;YAAEC,QAAQ;QAAO;IACxD;IAEA,OAAO,CAAC,EAAEC,UAAU,EAAEC,MAAM,EAAE;QAC5B,OAAO;YACLC,aAAavB,eAAe;gBAAEM;gBAASE;YAAc;YACrDgB,cAAcvB,gBAAgB;gBAAEoB;gBAAYV;YAAiB;YAC7Dc,cAAcvB,gBAAgB;gBAC5BmB;gBACAV;gBACAW;YACF;YACAI,eAAevB,WAAW;gBAAEkB;gBAAYV;YAAiB;YACzD,GAAIN,wBAAwB;gBAAEsB,QAAQT;YAA2B,CAAC;QACpE;IACF;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/gcs/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAI3D,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,gBAAgB,CAAA;AAO/D,MAAM,WAAW,IAAI;IACnB,GAAG,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,cAAc,CAAA;CACxB;AAED,eAAO,MAAM,UAAU,6BACM,IAAI,KAAG,OAsBjC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/gcs/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAI3D,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,gBAAgB,CAAA;AAO/D,MAAM,WAAW,IAAI;IACnB,GAAG,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAA;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,cAAc,CAAA;CACxB;AAED,eAAO,MAAM,UAAU,6BACM,IAAI,KAAG,OAsCjC,CAAA"}
@@ -4,10 +4,21 @@ import { getHandleDelete } from './handleDelete.js';
4
4
  import { getHandleUpload } from './handleUpload.js';
5
5
  import { getHandler } from './staticHandler.js';
6
6
  export const gcsAdapter = ({ acl, bucket, options })=>({ collection, prefix })=>{
7
+ if (!Storage) {
8
+ throw new Error('The package @google-cloud/storage is not installed, but is required for the plugin-cloud-storage GCS adapter. Please install it.');
9
+ }
7
10
  let storageClient = null;
8
11
  const getStorageClient = ()=>{
9
12
  if (storageClient) return storageClient;
10
- storageClient = new Storage(options);
13
+ try {
14
+ storageClient = new Storage(options);
15
+ } catch (error) {
16
+ if (/is not a constructor$/.test(error.message)) {
17
+ throw new Error('The package @google-cloud/storage is not installed, but is required for the plugin-cloud-storage GCS adapter. Please install it.');
18
+ }
19
+ // Re-throw other unexpected errors.
20
+ throw error;
21
+ }
11
22
  return storageClient;
12
23
  };
13
24
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/gcs/index.ts"],"sourcesContent":["import type { StorageOptions } from '@google-cloud/storage'\n\nimport { Storage } from '@google-cloud/storage'\n\nimport type { Adapter, GeneratedAdapter } from '../../types.js'\n\nimport { getGenerateURL } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\n\nexport interface Args {\n acl?: 'Private' | 'Public'\n bucket: string\n options: StorageOptions\n}\n\nexport const gcsAdapter =\n ({ acl, bucket, options }: Args): Adapter =>\n ({ collection, prefix }): GeneratedAdapter => {\n let storageClient: Storage | null = null\n\n const getStorageClient = (): Storage => {\n if (storageClient) return storageClient\n storageClient = new Storage(options)\n return storageClient\n }\n\n return {\n generateURL: getGenerateURL({ bucket, getStorageClient }),\n handleDelete: getHandleDelete({ bucket, getStorageClient }),\n handleUpload: getHandleUpload({\n acl,\n bucket,\n collection,\n getStorageClient,\n prefix,\n }),\n staticHandler: getHandler({ bucket, collection, getStorageClient }),\n }\n }\n"],"names":["Storage","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","gcsAdapter","acl","bucket","options","collection","prefix","storageClient","getStorageClient","generateURL","handleDelete","handleUpload","staticHandler"],"mappings":"AAEA,SAASA,OAAO,QAAQ,wBAAuB;AAI/C,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAQ/C,OAAO,MAAMC,aACX,CAAC,EAAEC,GAAG,EAAEC,MAAM,EAAEC,OAAO,EAAQ,GAC/B,CAAC,EAAEC,UAAU,EAAEC,MAAM,EAAE;QACrB,IAAIC,gBAAgC;QAEpC,MAAMC,mBAAmB;YACvB,IAAID,eAAe,OAAOA;YAC1BA,gBAAgB,IAAIX,QAAQQ;YAC5B,OAAOG;QACT;QAEA,OAAO;YACLE,aAAaZ,eAAe;gBAAEM;gBAAQK;YAAiB;YACvDE,cAAcZ,gBAAgB;gBAAEK;gBAAQK;YAAiB;YACzDG,cAAcZ,gBAAgB;gBAC5BG;gBACAC;gBACAE;gBACAG;gBACAF;YACF;YACAM,eAAeZ,WAAW;gBAAEG;gBAAQE;gBAAYG;YAAiB;QACnE;IACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/adapters/gcs/index.ts"],"sourcesContent":["import type { StorageOptions } from '@google-cloud/storage'\n\nimport { Storage } from '@google-cloud/storage'\n\nimport type { Adapter, GeneratedAdapter } from '../../types.js'\n\nimport { getGenerateURL } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\n\nexport interface Args {\n acl?: 'Private' | 'Public'\n bucket: string\n options: StorageOptions\n}\n\nexport const gcsAdapter =\n ({ acl, bucket, options }: Args): Adapter =>\n ({ collection, prefix }): GeneratedAdapter => {\n if (!Storage) {\n throw new Error(\n 'The package @google-cloud/storage is not installed, but is required for the plugin-cloud-storage GCS adapter. Please install it.',\n )\n }\n\n let storageClient: Storage | null = null\n\n const getStorageClient = (): Storage => {\n if (storageClient) return storageClient\n try {\n storageClient = new Storage(options)\n } catch (error) {\n if (/is not a constructor$/.test(error.message)) {\n throw new Error(\n 'The package @google-cloud/storage is not installed, but is required for the plugin-cloud-storage GCS adapter. Please install it.',\n )\n }\n // Re-throw other unexpected errors.\n throw error\n }\n return storageClient\n }\n\n return {\n generateURL: getGenerateURL({ bucket, getStorageClient }),\n handleDelete: getHandleDelete({ bucket, getStorageClient }),\n handleUpload: getHandleUpload({\n acl,\n bucket,\n collection,\n getStorageClient,\n prefix,\n }),\n staticHandler: getHandler({ bucket, collection, getStorageClient }),\n }\n }\n"],"names":["Storage","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","gcsAdapter","acl","bucket","options","collection","prefix","Error","storageClient","getStorageClient","error","test","message","generateURL","handleDelete","handleUpload","staticHandler"],"mappings":"AAEA,SAASA,OAAO,QAAQ,wBAAuB;AAI/C,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAQ/C,OAAO,MAAMC,aACX,CAAC,EAAEC,GAAG,EAAEC,MAAM,EAAEC,OAAO,EAAQ,GAC/B,CAAC,EAAEC,UAAU,EAAEC,MAAM,EAAE;QACrB,IAAI,CAACV,SAAS;YACZ,MAAM,IAAIW,MACR;QAEJ;QAEA,IAAIC,gBAAgC;QAEpC,MAAMC,mBAAmB;YACvB,IAAID,eAAe,OAAOA;YAC1B,IAAI;gBACFA,gBAAgB,IAAIZ,QAAQQ;YAC9B,EAAE,OAAOM,OAAO;gBACd,IAAI,wBAAwBC,IAAI,CAACD,MAAME,OAAO,GAAG;oBAC/C,MAAM,IAAIL,MACR;gBAEJ;gBACA,oCAAoC;gBACpC,MAAMG;YACR;YACA,OAAOF;QACT;QAEA,OAAO;YACLK,aAAahB,eAAe;gBAAEM;gBAAQM;YAAiB;YACvDK,cAAchB,gBAAgB;gBAAEK;gBAAQM;YAAiB;YACzDM,cAAchB,gBAAgB;gBAC5BG;gBACAC;gBACAE;gBACAI;gBACAH;YACF;YACAU,eAAehB,WAAW;gBAAEG;gBAAQE;gBAAYI;YAAiB;QACnE;IACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/s3/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAA;AAEzC,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,gBAAgB,CAAA;AAO/D,MAAM,WAAW,IAAI;IACnB,GAAG,CAAC,EAAE,SAAS,GAAG,aAAa,CAAA;IAC/B;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,MAAM,EAAE,GAAG,CAAC,cAAc,CAAA;CAC3B;AAED,eAAO,MAAM,SAAS,4BACW,IAAI,KAAG,OAqBrC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/s3/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,oBAAoB,CAAA;AAEzC,OAAO,KAAK,EAAE,OAAO,EAAoB,MAAM,gBAAgB,CAAA;AAO/D,MAAM,WAAW,IAAI;IACnB,GAAG,CAAC,EAAE,SAAS,GAAG,aAAa,CAAA;IAC/B;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,MAAM,EAAE,GAAG,CAAC,cAAc,CAAA;CAC3B;AAED,eAAO,MAAM,SAAS,4BACW,IAAI,KAAG,OAoCrC,CAAA"}
@@ -4,10 +4,21 @@ import { getHandleDelete } from './handleDelete.js';
4
4
  import { getHandleUpload } from './handleUpload.js';
5
5
  import { getHandler } from './staticHandler.js';
6
6
  export const s3Adapter = ({ acl, bucket, config = {} })=>({ collection, prefix })=>{
7
+ if (!AWS) {
8
+ throw new Error('The packages @aws-sdk/client-s3, @aws-sdk/lib-storage and aws-crt are not installed, but are required for the plugin-cloud-storage S3 adapter. Please install them.');
9
+ }
7
10
  let storageClient = null;
8
11
  const getStorageClient = ()=>{
9
12
  if (storageClient) return storageClient;
10
- storageClient = new AWS.S3(config);
13
+ try {
14
+ storageClient = new AWS.S3(config);
15
+ } catch (error) {
16
+ if (/is not a constructor$/.test(error.message)) {
17
+ throw new Error('The packages @aws-sdk/client-s3, @aws-sdk/lib-storage and aws-crt are not installed, but are required for the plugin-cloud-storage S3 adapter. Please install them.');
18
+ }
19
+ // Re-throw other unexpected errors.
20
+ throw error;
21
+ }
11
22
  return storageClient;
12
23
  };
13
24
  return {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/adapters/s3/index.ts"],"sourcesContent":["import * as AWS from '@aws-sdk/client-s3'\n\nimport type { Adapter, GeneratedAdapter } from '../../types.js'\n\nimport { getGenerateURL } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\n\nexport interface Args {\n acl?: 'private' | 'public-read'\n /**\n * Bucket name to upload files to.\n *\n * Must follow [AWS S3 bucket naming conventions](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html).\n */\n bucket: string\n /**\n * AWS S3 client configuration. Highly dependent on your AWS setup.\n *\n * [AWS.S3ClientConfig Docs](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3/interfaces/s3clientconfig.html)\n */\n config: AWS.S3ClientConfig\n}\n\nexport const s3Adapter =\n ({ acl, bucket, config = {} }: Args): Adapter =>\n ({ collection, prefix }): GeneratedAdapter => {\n let storageClient: AWS.S3 | null = null\n const getStorageClient: () => AWS.S3 = () => {\n if (storageClient) return storageClient\n storageClient = new AWS.S3(config)\n return storageClient\n }\n\n return {\n generateURL: getGenerateURL({ bucket, config }),\n handleDelete: getHandleDelete({ bucket, getStorageClient }),\n handleUpload: getHandleUpload({\n acl,\n bucket,\n collection,\n getStorageClient,\n prefix,\n }),\n staticHandler: getHandler({ bucket, collection, getStorageClient }),\n }\n }\n"],"names":["AWS","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","s3Adapter","acl","bucket","config","collection","prefix","storageClient","getStorageClient","S3","generateURL","handleDelete","handleUpload","staticHandler"],"mappings":"AAAA,YAAYA,SAAS,qBAAoB;AAIzC,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAkB/C,OAAO,MAAMC,YACX,CAAC,EAAEC,GAAG,EAAEC,MAAM,EAAEC,SAAS,CAAC,CAAC,EAAQ,GACnC,CAAC,EAAEC,UAAU,EAAEC,MAAM,EAAE;QACrB,IAAIC,gBAA+B;QACnC,MAAMC,mBAAiC;YACrC,IAAID,eAAe,OAAOA;YAC1BA,gBAAgB,IAAIX,IAAIa,EAAE,CAACL;YAC3B,OAAOG;QACT;QAEA,OAAO;YACLG,aAAab,eAAe;gBAAEM;gBAAQC;YAAO;YAC7CO,cAAcb,gBAAgB;gBAAEK;gBAAQK;YAAiB;YACzDI,cAAcb,gBAAgB;gBAC5BG;gBACAC;gBACAE;gBACAG;gBACAF;YACF;YACAO,eAAeb,WAAW;gBAAEG;gBAAQE;gBAAYG;YAAiB;QACnE;IACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/adapters/s3/index.ts"],"sourcesContent":["import * as AWS from '@aws-sdk/client-s3'\n\nimport type { Adapter, GeneratedAdapter } from '../../types.js'\n\nimport { getGenerateURL } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\n\nexport interface Args {\n acl?: 'private' | 'public-read'\n /**\n * Bucket name to upload files to.\n *\n * Must follow [AWS S3 bucket naming conventions](https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html).\n */\n bucket: string\n /**\n * AWS S3 client configuration. Highly dependent on your AWS setup.\n *\n * [AWS.S3ClientConfig Docs](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3/interfaces/s3clientconfig.html)\n */\n config: AWS.S3ClientConfig\n}\n\nexport const s3Adapter =\n ({ acl, bucket, config = {} }: Args): Adapter =>\n ({ collection, prefix }): GeneratedAdapter => {\n if (!AWS) {\n throw new Error(\n 'The packages @aws-sdk/client-s3, @aws-sdk/lib-storage and aws-crt are not installed, but are required for the plugin-cloud-storage S3 adapter. Please install them.',\n )\n }\n let storageClient: AWS.S3 | null = null\n const getStorageClient: () => AWS.S3 = () => {\n if (storageClient) return storageClient\n try {\n storageClient = new AWS.S3(config)\n } catch (error) {\n if (/is not a constructor$/.test(error.message)) {\n throw new Error(\n 'The packages @aws-sdk/client-s3, @aws-sdk/lib-storage and aws-crt are not installed, but are required for the plugin-cloud-storage S3 adapter. Please install them.',\n )\n }\n // Re-throw other unexpected errors.\n throw error\n }\n return storageClient\n }\n\n return {\n generateURL: getGenerateURL({ bucket, config }),\n handleDelete: getHandleDelete({ bucket, getStorageClient }),\n handleUpload: getHandleUpload({\n acl,\n bucket,\n collection,\n getStorageClient,\n prefix,\n }),\n staticHandler: getHandler({ bucket, collection, getStorageClient }),\n }\n }\n"],"names":["AWS","getGenerateURL","getHandleDelete","getHandleUpload","getHandler","s3Adapter","acl","bucket","config","collection","prefix","Error","storageClient","getStorageClient","S3","error","test","message","generateURL","handleDelete","handleUpload","staticHandler"],"mappings":"AAAA,YAAYA,SAAS,qBAAoB;AAIzC,SAASC,cAAc,QAAQ,mBAAkB;AACjD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AAkB/C,OAAO,MAAMC,YACX,CAAC,EAAEC,GAAG,EAAEC,MAAM,EAAEC,SAAS,CAAC,CAAC,EAAQ,GACnC,CAAC,EAAEC,UAAU,EAAEC,MAAM,EAAE;QACrB,IAAI,CAACV,KAAK;YACR,MAAM,IAAIW,MACR;QAEJ;QACA,IAAIC,gBAA+B;QACnC,MAAMC,mBAAiC;YACrC,IAAID,eAAe,OAAOA;YAC1B,IAAI;gBACFA,gBAAgB,IAAIZ,IAAIc,EAAE,CAACN;YAC7B,EAAE,OAAOO,OAAO;gBACd,IAAI,wBAAwBC,IAAI,CAACD,MAAME,OAAO,GAAG;oBAC/C,MAAM,IAAIN,MACR;gBAEJ;gBACA,oCAAoC;gBACpC,MAAMI;YACR;YACA,OAAOH;QACT;QAEA,OAAO;YACLM,aAAajB,eAAe;gBAAEM;gBAAQC;YAAO;YAC7CW,cAAcjB,gBAAgB;gBAAEK;gBAAQM;YAAiB;YACzDO,cAAcjB,gBAAgB;gBAC5BG;gBACAC;gBACAE;gBACAI;gBACAH;YACF;YACAW,eAAejB,WAAW;gBAAEG;gBAAQE;gBAAYI;YAAiB;QACnE;IACF,EAAC"}
package/package.json CHANGED
@@ -1,18 +1,24 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-cloud-storage",
3
3
  "description": "The official cloud storage plugin for Payload CMS",
4
- "version": "3.0.0-alpha.48",
4
+ "version": "3.0.0-alpha.50",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
7
7
  "type": "module",
8
8
  "license": "MIT",
9
+ "homepage": "https://payloadcms.com",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/payloadcms/payload.git",
13
+ "directory": "packages/plugin-cloud-storage"
14
+ },
9
15
  "peerDependencies": {
10
16
  "@aws-sdk/client-s3": "^3.525.0",
11
17
  "@aws-sdk/lib-storage": "^3.525.0",
12
18
  "@azure/abort-controller": "^1.0.0",
13
19
  "@azure/storage-blob": "^12.11.0",
14
20
  "@google-cloud/storage": "^7.7.0",
15
- "payload": "3.0.0-alpha.48"
21
+ "payload": "3.0.0-alpha.50"
16
22
  },
17
23
  "peerDependenciesMeta": {
18
24
  "@aws-sdk/client-s3": {
@@ -42,7 +48,7 @@
42
48
  "@azure/storage-blob": "^12.11.0",
43
49
  "@google-cloud/storage": "^7.7.0",
44
50
  "@types/find-node-modules": "^2.1.2",
45
- "payload": "3.0.0-alpha.48"
51
+ "payload": "3.0.0-alpha.50"
46
52
  },
47
53
  "dependencies": {
48
54
  "find-node-modules": "^2.1.3",
@@ -54,15 +60,15 @@
54
60
  "require": "./dist/index.js",
55
61
  "types": "./dist/index.d.ts"
56
62
  },
63
+ "./types": {
64
+ "import": "./dist/types.js",
65
+ "require": "./dist/types.js",
66
+ "types": "./dist/types.d.ts"
67
+ },
57
68
  "./*": {
58
69
  "import": "./dist/exports/*.js",
59
70
  "require": "./dist/exports/*.js",
60
71
  "types": "./dist/exports/*.d.ts"
61
- },
62
- "./dist/*": {
63
- "import": "./dist/*.js",
64
- "require": "./dist/*.js",
65
- "types": "./dist/*.d.ts"
66
72
  }
67
73
  },
68
74
  "publishConfig": {
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { cloudStorage } from './plugin.js'