@payloadcms/storage-uploadthing 3.0.0-canary.fb81f02 → 3.0.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/LICENSE.md +17 -17
- package/README.md +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/staticHandler.d.ts.map +1 -1
- package/dist/staticHandler.js +3 -1
- package/dist/staticHandler.js.map +1 -1
- package/package.json +15 -6
package/LICENSE.md
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2018-
|
|
4
|
-
Portions Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
Copyright (c) 2018-2024 Payload CMS, Inc. <info@payloadcms.com>
|
|
5
4
|
|
|
6
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
7
|
-
of this software and associated documentation files (the
|
|
8
|
-
in the Software without restriction, including
|
|
9
|
-
to use, copy, modify, merge, publish,
|
|
10
|
-
copies of the Software, and to
|
|
11
|
-
furnished to do so, subject to
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
12
|
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
|
14
|
-
copies or substantial portions of the Software.
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
15
|
|
|
16
|
-
THE SOFTWARE IS PROVIDED
|
|
17
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
|
|
22
|
-
SOFTWARE.
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ This package provides a way to use [uploadthing](https://uploadthing.com) with P
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
pnpm add @
|
|
8
|
+
pnpm add @payloadcms/storage-uploadthing
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
@@ -20,10 +20,10 @@ export default buildConfig({
|
|
|
20
20
|
plugins: [
|
|
21
21
|
uploadthingStorage({
|
|
22
22
|
collections: {
|
|
23
|
-
|
|
23
|
+
media: true,
|
|
24
24
|
},
|
|
25
25
|
options: {
|
|
26
|
-
|
|
26
|
+
token: process.env.UPLOADTHING_TOKEN,
|
|
27
27
|
acl: 'public-read',
|
|
28
28
|
},
|
|
29
29
|
}),
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { CollectionOptions } from '@payloadcms/plugin-cloud-storage/types';
|
|
2
|
-
import type { Plugin } from 'payload';
|
|
2
|
+
import type { Plugin, UploadCollectionSlug } from 'payload';
|
|
3
3
|
import type { UTApiOptions } from 'uploadthing/types';
|
|
4
4
|
export type UploadthingStorageOptions = {
|
|
5
5
|
/**
|
|
6
6
|
* Collection options to apply the adapter to.
|
|
7
7
|
*/
|
|
8
|
-
collections: Record<
|
|
8
|
+
collections: Partial<Record<UploadCollectionSlug, Omit<CollectionOptions, 'adapter'> | true>>;
|
|
9
9
|
/**
|
|
10
10
|
* Whether or not to enable the plugin
|
|
11
11
|
*
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,EAAiB,MAAM,EAAE,MAAM,SAAS,CAAA;
|
|
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,EAAiB,MAAM,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAUrD,MAAM,MAAM,yBAAyB,GAAG;IACtC;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,oBAAoB,EAAE,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAE7F;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB;;OAEG;IACH,OAAO,EAAE;QACP;;WAEG;QACH,GAAG,CAAC,EAAE,GAAG,CAAA;KACV,GAAG,YAAY,CAAA;CACjB,CAAA;AAED,KAAK,iBAAiB,GAAG,CAAC,yBAAyB,EAAE,yBAAyB,KAAK,MAAM,CAAA;AAEzF,+FAA+F;AAC/F,MAAM,MAAM,GAAG,GAAG,SAAS,GAAG,aAAa,CAAA;AAE3C,eAAO,MAAM,kBAAkB,EAAE,iBAuD9B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ export const uploadthingStorage = (uploadthingStorageOptions)=>(incomingConfig)=
|
|
|
12
12
|
if (!uploadthingStorageOptions.options.acl) {
|
|
13
13
|
uploadthingStorageOptions.options.acl = 'public-read';
|
|
14
14
|
}
|
|
15
|
-
const adapter = uploadthingInternal(uploadthingStorageOptions
|
|
15
|
+
const adapter = uploadthingInternal(uploadthingStorageOptions);
|
|
16
16
|
// Add adapter to each collection option object
|
|
17
17
|
const collectionsWithAdapter = Object.entries(uploadthingStorageOptions.collections).reduce((acc, [slug, collOptions])=>({
|
|
18
18
|
...acc,
|
|
@@ -45,7 +45,7 @@ export const uploadthingStorage = (uploadthingStorageOptions)=>(incomingConfig)=
|
|
|
45
45
|
collections: collectionsWithAdapter
|
|
46
46
|
})(config);
|
|
47
47
|
};
|
|
48
|
-
function uploadthingInternal(options
|
|
48
|
+
function uploadthingInternal(options) {
|
|
49
49
|
const fields = [
|
|
50
50
|
{
|
|
51
51
|
name: '_key',
|
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, Field, Plugin } from 'payload'\nimport type { UTApiOptions } from 'uploadthing/types'\n\nimport { cloudStoragePlugin } from '@payloadcms/plugin-cloud-storage'\nimport { UTApi } from 'uploadthing/server'\n\nimport { generateURL } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\n\nexport type UploadthingStorageOptions = {\n /**\n * Collection options to apply the adapter to.\n */\n collections: Record<
|
|
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, Field, Plugin, UploadCollectionSlug } from 'payload'\nimport type { UTApiOptions } from 'uploadthing/types'\n\nimport { cloudStoragePlugin } from '@payloadcms/plugin-cloud-storage'\nimport { UTApi } from 'uploadthing/server'\n\nimport { generateURL } from './generateURL.js'\nimport { getHandleDelete } from './handleDelete.js'\nimport { getHandleUpload } from './handleUpload.js'\nimport { getHandler } from './staticHandler.js'\n\nexport type UploadthingStorageOptions = {\n /**\n * Collection options to apply the adapter to.\n */\n collections: Partial<Record<UploadCollectionSlug, Omit<CollectionOptions, 'adapter'> | true>>\n\n /**\n * Whether or not to enable the plugin\n *\n * Default: true\n */\n enabled?: boolean\n\n /**\n * Uploadthing Options\n */\n options: {\n /**\n * @default 'public-read'\n */\n acl?: ACL\n } & UTApiOptions\n}\n\ntype UploadthingPlugin = (uploadthingStorageOptions: UploadthingStorageOptions) => Plugin\n\n/** NOTE: not synced with uploadthing's internal types. Need to modify if more options added */\nexport type ACL = 'private' | 'public-read'\n\nexport const uploadthingStorage: UploadthingPlugin =\n (uploadthingStorageOptions: UploadthingStorageOptions) =>\n (incomingConfig: Config): Config => {\n if (uploadthingStorageOptions.enabled === false) {\n return incomingConfig\n }\n\n // Default ACL to public-read\n if (!uploadthingStorageOptions.options.acl) {\n uploadthingStorageOptions.options.acl = 'public-read'\n }\n\n const adapter = uploadthingInternal(uploadthingStorageOptions)\n\n // Add adapter to each collection option object\n const collectionsWithAdapter: CloudStoragePluginOptions['collections'] = Object.entries(\n uploadthingStorageOptions.collections,\n ).reduce(\n (acc, [slug, collOptions]) => ({\n ...acc,\n [slug]: {\n ...(collOptions === true ? {} : collOptions),\n\n // Disable payload access control if the ACL is public-read or not set\n // ...(uploadthingStorageOptions.options.acl === 'public-read'\n // ? { disablePayloadAccessControl: true }\n // : {}),\n\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 uploadthingInternal(options: UploadthingStorageOptions): Adapter {\n const fields: Field[] = [\n {\n name: '_key',\n type: 'text',\n admin: {\n hidden: true,\n },\n },\n ]\n\n return (): GeneratedAdapter => {\n const {\n options: { acl = 'public-read', ...utOptions },\n } = options\n\n const utApi = new UTApi(utOptions)\n\n return {\n name: 'uploadthing',\n fields,\n generateURL,\n handleDelete: getHandleDelete({ utApi }),\n handleUpload: getHandleUpload({ acl, utApi }),\n staticHandler: getHandler({ utApi }),\n }\n }\n}\n"],"names":["cloudStoragePlugin","UTApi","generateURL","getHandleDelete","getHandleUpload","getHandler","uploadthingStorage","uploadthingStorageOptions","incomingConfig","enabled","options","acl","adapter","uploadthingInternal","collectionsWithAdapter","Object","entries","collections","reduce","acc","slug","collOptions","config","map","collection","upload","disableLocalStorage","fields","name","type","admin","hidden","utOptions","utApi","handleDelete","handleUpload","staticHandler"],"mappings":"AASA,SAASA,kBAAkB,QAAQ,mCAAkC;AACrE,SAASC,KAAK,QAAQ,qBAAoB;AAE1C,SAASC,WAAW,QAAQ,mBAAkB;AAC9C,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,QAAQ,qBAAoB;AA+B/C,OAAO,MAAMC,qBACX,CAACC,4BACD,CAACC;QACC,IAAID,0BAA0BE,OAAO,KAAK,OAAO;YAC/C,OAAOD;QACT;QAEA,6BAA6B;QAC7B,IAAI,CAACD,0BAA0BG,OAAO,CAACC,GAAG,EAAE;YAC1CJ,0BAA0BG,OAAO,CAACC,GAAG,GAAG;QAC1C;QAEA,MAAMC,UAAUC,oBAAoBN;QAEpC,+CAA+C;QAC/C,MAAMO,yBAAmEC,OAAOC,OAAO,CACrFT,0BAA0BU,WAAW,EACrCC,MAAM,CACN,CAACC,KAAK,CAACC,MAAMC,YAAY,GAAM,CAAA;gBAC7B,GAAGF,GAAG;gBACN,CAACC,KAAK,EAAE;oBACN,GAAIC,gBAAgB,OAAO,CAAC,IAAIA,WAAW;oBAE3C,sEAAsE;oBACtE,8DAA8D;oBAC9D,4CAA4C;oBAC5C,WAAW;oBAEXT;gBACF;YACF,CAAA,GACA,CAAC;QAGH,gFAAgF;QAChF,MAAMU,SAAS;YACb,GAAGd,cAAc;YACjBS,aAAa,AAACT,CAAAA,eAAeS,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,OAAO1B,mBAAmB;YACxBiB,aAAaH;QACf,GAAGQ;IACL,EAAC;AAEH,SAAST,oBAAoBH,OAAkC;IAC7D,MAAMiB,SAAkB;QACtB;YACEC,MAAM;YACNC,MAAM;YACNC,OAAO;gBACLC,QAAQ;YACV;QACF;KACD;IAED,OAAO;QACL,MAAM,EACJrB,SAAS,EAAEC,MAAM,aAAa,EAAE,GAAGqB,WAAW,EAC/C,GAAGtB;QAEJ,MAAMuB,QAAQ,IAAIhC,MAAM+B;QAExB,OAAO;YACLJ,MAAM;YACND;YACAzB;YACAgC,cAAc/B,gBAAgB;gBAAE8B;YAAM;YACtCE,cAAc/B,gBAAgB;gBAAEO;gBAAKsB;YAAM;YAC3CG,eAAe/B,WAAW;gBAAE4B;YAAM;QACpC;IACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"staticHandler.d.ts","sourceRoot":"","sources":["../src/staticHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AAE3E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAI/C,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED,eAAO,MAAM,UAAU,cAAe,IAAI,KAAG,
|
|
1
|
+
{"version":3,"file":"staticHandler.d.ts","sourceRoot":"","sources":["../src/staticHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAA;AAE3E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAI/C,KAAK,IAAI,GAAG;IACV,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED,eAAO,MAAM,UAAU,cAAe,IAAI,KAAG,aAuE5C,CAAA"}
|
package/dist/staticHandler.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/staticHandler.ts"],"sourcesContent":["import type { StaticHandler } from '@payloadcms/plugin-cloud-storage/types'\nimport type { Where } from 'payload'\nimport type { UTApi } from 'uploadthing/server'\n\nimport { getKeyFromFilename } from './utilities.js'\n\ntype Args = {\n utApi: UTApi\n}\n\nexport const getHandler = ({ utApi }: Args): StaticHandler => {\n return async (req, { doc, params: { collection, filename } }) => {\n try {\n const collectionConfig = req.payload.collections[collection]?.config\n let retrievedDoc = doc\n\n if (!retrievedDoc) {\n const or: Where[] = [\n {\n filename: {\n equals: filename,\n },\n },\n ]\n\n if (collectionConfig.upload.imageSizes) {\n collectionConfig.upload.imageSizes.forEach(({ name }) => {\n or.push({\n [`sizes.${name}.filename`]: {\n equals: filename,\n },\n })\n })\n }\n\n const result = await req.payload.db.findOne({\n collection,\n req,\n where: { or },\n })\n\n if (result) retrievedDoc = result\n }\n\n if (!retrievedDoc) {\n return new Response(null, { status: 404, statusText: 'Not Found' })\n }\n\n const key = getKeyFromFilename(retrievedDoc, filename)\n if (!key) {\n return new Response(null, { status: 404, statusText: 'Not Found' })\n }\n\n const { url: signedURL } = await utApi.getSignedURL(key)\n\n if (!signedURL) {\n return new Response(null, { status: 404, statusText: 'Not Found' })\n }\n\n const response = await fetch(signedURL)\n\n if (!response.ok) {\n return new Response(null, { status: 404, statusText: 'Not Found' })\n }\n\n const blob = await response.blob()\n\n return new Response(blob, {\n headers: new Headers({\n 'Content-Length': String(blob.size),\n 'Content-Type': blob.type,\n }),\n status: 200,\n })\n } catch (err) {\n req.payload.logger.error({ err, msg: 'Unexpected error in staticHandler' })\n return new Response('Internal Server Error', { status: 500 })\n }\n }\n}\n"],"names":["getKeyFromFilename","getHandler","utApi","req","doc","params","collection","filename","collectionConfig","payload","collections","config","retrievedDoc","or","equals","upload","imageSizes","forEach","name","push","result","db","findOne","where","Response","status","statusText","key","url","signedURL","getSignedURL","response","fetch","ok","blob","headers","Headers","String","size","type","err","logger","error","msg"],"mappings":"AAIA,SAASA,kBAAkB,QAAQ,iBAAgB;AAMnD,OAAO,MAAMC,aAAa,CAAC,EAAEC,KAAK,EAAQ;IACxC,OAAO,OAAOC,KAAK,EAAEC,GAAG,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,QAAQ,EAAE,EAAE;QAC1D,IAAI;YACF,MAAMC,mBAAmBL,IAAIM,OAAO,CAACC,WAAW,CAACJ,WAAW,EAAEK;YAC9D,IAAIC,eAAeR;YAEnB,IAAI,CAACQ,cAAc;gBACjB,MAAMC,KAAc;oBAClB;wBACEN,UAAU;4BACRO,QAAQP;wBACV;oBACF;iBACD;gBAED,IAAIC,iBAAiBO,MAAM,CAACC,UAAU,EAAE;oBACtCR,iBAAiBO,MAAM,CAACC,UAAU,CAACC,OAAO,CAAC,CAAC,EAAEC,IAAI,EAAE;wBAClDL,GAAGM,IAAI,CAAC;4BACN,CAAC,CAAC,MAAM,EAAED,KAAK,SAAS,CAAC,CAAC,EAAE;gCAC1BJ,QAAQP;4BACV;wBACF;oBACF;gBACF;gBAEA,MAAMa,SAAS,MAAMjB,IAAIM,OAAO,CAACY,EAAE,CAACC,OAAO,CAAC;oBAC1ChB;oBACAH;oBACAoB,OAAO;wBAAEV;oBAAG;gBACd;gBAEA,IAAIO,
|
|
1
|
+
{"version":3,"sources":["../src/staticHandler.ts"],"sourcesContent":["import type { StaticHandler } from '@payloadcms/plugin-cloud-storage/types'\nimport type { Where } from 'payload'\nimport type { UTApi } from 'uploadthing/server'\n\nimport { getKeyFromFilename } from './utilities.js'\n\ntype Args = {\n utApi: UTApi\n}\n\nexport const getHandler = ({ utApi }: Args): StaticHandler => {\n return async (req, { doc, params: { collection, filename } }) => {\n try {\n const collectionConfig = req.payload.collections[collection]?.config\n let retrievedDoc = doc\n\n if (!retrievedDoc) {\n const or: Where[] = [\n {\n filename: {\n equals: filename,\n },\n },\n ]\n\n if (collectionConfig.upload.imageSizes) {\n collectionConfig.upload.imageSizes.forEach(({ name }) => {\n or.push({\n [`sizes.${name}.filename`]: {\n equals: filename,\n },\n })\n })\n }\n\n const result = await req.payload.db.findOne({\n collection,\n req,\n where: { or },\n })\n\n if (result) {\n retrievedDoc = result\n }\n }\n\n if (!retrievedDoc) {\n return new Response(null, { status: 404, statusText: 'Not Found' })\n }\n\n const key = getKeyFromFilename(retrievedDoc, filename)\n if (!key) {\n return new Response(null, { status: 404, statusText: 'Not Found' })\n }\n\n const { url: signedURL } = await utApi.getSignedURL(key)\n\n if (!signedURL) {\n return new Response(null, { status: 404, statusText: 'Not Found' })\n }\n\n const response = await fetch(signedURL)\n\n if (!response.ok) {\n return new Response(null, { status: 404, statusText: 'Not Found' })\n }\n\n const blob = await response.blob()\n\n return new Response(blob, {\n headers: new Headers({\n 'Content-Length': String(blob.size),\n 'Content-Type': blob.type,\n }),\n status: 200,\n })\n } catch (err) {\n req.payload.logger.error({ err, msg: 'Unexpected error in staticHandler' })\n return new Response('Internal Server Error', { status: 500 })\n }\n }\n}\n"],"names":["getKeyFromFilename","getHandler","utApi","req","doc","params","collection","filename","collectionConfig","payload","collections","config","retrievedDoc","or","equals","upload","imageSizes","forEach","name","push","result","db","findOne","where","Response","status","statusText","key","url","signedURL","getSignedURL","response","fetch","ok","blob","headers","Headers","String","size","type","err","logger","error","msg"],"mappings":"AAIA,SAASA,kBAAkB,QAAQ,iBAAgB;AAMnD,OAAO,MAAMC,aAAa,CAAC,EAAEC,KAAK,EAAQ;IACxC,OAAO,OAAOC,KAAK,EAAEC,GAAG,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,QAAQ,EAAE,EAAE;QAC1D,IAAI;YACF,MAAMC,mBAAmBL,IAAIM,OAAO,CAACC,WAAW,CAACJ,WAAW,EAAEK;YAC9D,IAAIC,eAAeR;YAEnB,IAAI,CAACQ,cAAc;gBACjB,MAAMC,KAAc;oBAClB;wBACEN,UAAU;4BACRO,QAAQP;wBACV;oBACF;iBACD;gBAED,IAAIC,iBAAiBO,MAAM,CAACC,UAAU,EAAE;oBACtCR,iBAAiBO,MAAM,CAACC,UAAU,CAACC,OAAO,CAAC,CAAC,EAAEC,IAAI,EAAE;wBAClDL,GAAGM,IAAI,CAAC;4BACN,CAAC,CAAC,MAAM,EAAED,KAAK,SAAS,CAAC,CAAC,EAAE;gCAC1BJ,QAAQP;4BACV;wBACF;oBACF;gBACF;gBAEA,MAAMa,SAAS,MAAMjB,IAAIM,OAAO,CAACY,EAAE,CAACC,OAAO,CAAC;oBAC1ChB;oBACAH;oBACAoB,OAAO;wBAAEV;oBAAG;gBACd;gBAEA,IAAIO,QAAQ;oBACVR,eAAeQ;gBACjB;YACF;YAEA,IAAI,CAACR,cAAc;gBACjB,OAAO,IAAIY,SAAS,MAAM;oBAAEC,QAAQ;oBAAKC,YAAY;gBAAY;YACnE;YAEA,MAAMC,MAAM3B,mBAAmBY,cAAcL;YAC7C,IAAI,CAACoB,KAAK;gBACR,OAAO,IAAIH,SAAS,MAAM;oBAAEC,QAAQ;oBAAKC,YAAY;gBAAY;YACnE;YAEA,MAAM,EAAEE,KAAKC,SAAS,EAAE,GAAG,MAAM3B,MAAM4B,YAAY,CAACH;YAEpD,IAAI,CAACE,WAAW;gBACd,OAAO,IAAIL,SAAS,MAAM;oBAAEC,QAAQ;oBAAKC,YAAY;gBAAY;YACnE;YAEA,MAAMK,WAAW,MAAMC,MAAMH;YAE7B,IAAI,CAACE,SAASE,EAAE,EAAE;gBAChB,OAAO,IAAIT,SAAS,MAAM;oBAAEC,QAAQ;oBAAKC,YAAY;gBAAY;YACnE;YAEA,MAAMQ,OAAO,MAAMH,SAASG,IAAI;YAEhC,OAAO,IAAIV,SAASU,MAAM;gBACxBC,SAAS,IAAIC,QAAQ;oBACnB,kBAAkBC,OAAOH,KAAKI,IAAI;oBAClC,gBAAgBJ,KAAKK,IAAI;gBAC3B;gBACAd,QAAQ;YACV;QACF,EAAE,OAAOe,KAAK;YACZrC,IAAIM,OAAO,CAACgC,MAAM,CAACC,KAAK,CAAC;gBAAEF;gBAAKG,KAAK;YAAoC;YACzE,OAAO,IAAInB,SAAS,yBAAyB;gBAAEC,QAAQ;YAAI;QAC7D;IACF;AACF,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/storage-uploadthing",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Payload storage adapter for uploadthing",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -10,6 +10,13 @@
|
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
|
|
13
|
+
"maintainers": [
|
|
14
|
+
{
|
|
15
|
+
"name": "Payload",
|
|
16
|
+
"email": "info@payloadcms.com",
|
|
17
|
+
"url": "https://payloadcms.com"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
13
20
|
"type": "module",
|
|
14
21
|
"exports": {
|
|
15
22
|
".": {
|
|
@@ -24,14 +31,14 @@
|
|
|
24
31
|
"dist"
|
|
25
32
|
],
|
|
26
33
|
"dependencies": {
|
|
27
|
-
"uploadthing": "
|
|
28
|
-
"@payloadcms/plugin-cloud-storage": "3.0.0
|
|
34
|
+
"uploadthing": "7.3.0",
|
|
35
|
+
"@payloadcms/plugin-cloud-storage": "3.0.0"
|
|
29
36
|
},
|
|
30
37
|
"devDependencies": {
|
|
31
|
-
"payload": "3.0.0
|
|
38
|
+
"payload": "3.0.0"
|
|
32
39
|
},
|
|
33
40
|
"peerDependencies": {
|
|
34
|
-
"payload": "3.0.0
|
|
41
|
+
"payload": "3.0.0"
|
|
35
42
|
},
|
|
36
43
|
"engines": {
|
|
37
44
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -41,6 +48,8 @@
|
|
|
41
48
|
"build:clean": "find . \\( -type d \\( -name build -o -name dist -o -name .cache \\) -o -type f -name tsconfig.tsbuildinfo \\) -exec rm -rf {} + && pnpm build",
|
|
42
49
|
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
43
50
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
44
|
-
"clean": "rimraf {dist,*.tsbuildinfo}"
|
|
51
|
+
"clean": "rimraf {dist,*.tsbuildinfo}",
|
|
52
|
+
"lint": "eslint .",
|
|
53
|
+
"lint:fix": "eslint . --fix"
|
|
45
54
|
}
|
|
46
55
|
}
|