@payloadcms/storage-uploadthing 3.0.0-beta.94 → 3.0.0-beta.96

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":"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,aAqE5C,CAAA"}
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"}
@@ -28,7 +28,9 @@ export const getHandler = ({ utApi })=>{
28
28
  or
29
29
  }
30
30
  });
31
- if (result) retrievedDoc = result;
31
+ if (result) {
32
+ retrievedDoc = result;
33
+ }
32
34
  }
33
35
  if (!retrievedDoc) {
34
36
  return new Response(null, {
@@ -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;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J,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"}
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-beta.94",
3
+ "version": "3.0.0-beta.96",
4
4
  "description": "Payload storage adapter for uploadthing",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -25,13 +25,13 @@
25
25
  ],
26
26
  "dependencies": {
27
27
  "uploadthing": "^6.10.1",
28
- "@payloadcms/plugin-cloud-storage": "3.0.0-beta.94"
28
+ "@payloadcms/plugin-cloud-storage": "3.0.0-beta.96"
29
29
  },
30
30
  "devDependencies": {
31
- "payload": "3.0.0-beta.94"
31
+ "payload": "3.0.0-beta.96"
32
32
  },
33
33
  "peerDependencies": {
34
- "payload": "3.0.0-beta.94"
34
+ "payload": "3.0.0-beta.96"
35
35
  },
36
36
  "engines": {
37
37
  "node": "^18.20.2 || >=20.9.0"
@@ -41,6 +41,8 @@
41
41
  "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
42
  "build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
43
43
  "build:types": "tsc --emitDeclarationOnly --outDir dist",
44
- "clean": "rimraf {dist,*.tsbuildinfo}"
44
+ "clean": "rimraf {dist,*.tsbuildinfo}",
45
+ "lint": "eslint .",
46
+ "lint:fix": "eslint . --fix"
45
47
  }
46
48
  }