payload 3.73.0-internal.783bc97 → 3.73.0-internal.e61e2ce
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/database/migrations/getPredefinedMigration.d.ts.map +1 -1
- package/dist/database/migrations/getPredefinedMigration.js +4 -2
- package/dist/database/migrations/getPredefinedMigration.js.map +1 -1
- package/dist/database/types.d.ts +9 -0
- package/dist/database/types.d.ts.map +1 -1
- package/dist/database/types.js.map +1 -1
- package/dist/index.bundled.d.ts +21 -10
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +0 -8
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/addDataAndFileToRequest.d.ts.map +1 -1
- package/dist/utilities/addDataAndFileToRequest.js +2 -7
- package/dist/utilities/addDataAndFileToRequest.js.map +1 -1
- package/package.json +2 -2
|
@@ -34,13 +34,8 @@ import { processMultipartFormdata } from '../uploads/fetchAPI-multipart/index.js
|
|
|
34
34
|
if (error) {
|
|
35
35
|
throw new APIError(error.message);
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
req.files = files;
|
|
40
|
-
// Backwards compatibility: set req.file for standard upload collections
|
|
41
|
-
if (files.file) {
|
|
42
|
-
req.file = files.file;
|
|
43
|
-
}
|
|
37
|
+
if (files?.file) {
|
|
38
|
+
req.file = files.file;
|
|
44
39
|
}
|
|
45
40
|
if (fields?._payload && typeof fields._payload === 'string') {
|
|
46
41
|
req.data = JSON.parse(fields._payload);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utilities/addDataAndFileToRequest.ts"],"sourcesContent":["import type { PayloadRequest } from '../types/index.js'\n\nimport { APIError } from '../errors/APIError.js'\nimport { processMultipartFormdata } from '../uploads/fetchAPI-multipart/index.js'\n\ntype AddDataAndFileToRequest = (req: PayloadRequest) => Promise<void>\n\n/**\n * Mutates the Request, appending 'data' and 'file' if found\n */\nexport const addDataAndFileToRequest: AddDataAndFileToRequest = async (req) => {\n const { body, headers, method, payload } = req\n\n if (method && ['PATCH', 'POST', 'PUT'].includes(method.toUpperCase()) && body) {\n const [contentType] = (headers.get('Content-Type') || '').split(';', 1)\n const bodyByteSize = parseInt(req.headers.get('Content-Length') || '0', 10)\n\n if (contentType === 'application/json') {\n let data = {}\n try {\n const text = await req.text?.()\n data = text ? JSON.parse(text) : {}\n } catch (error) {\n req.payload.logger.error(error)\n } finally {\n req.data = data\n // @ts-expect-error attach json method to request\n req.json = () => Promise.resolve(data)\n }\n } else if (bodyByteSize && contentType?.includes('multipart/')) {\n const { error, fields, files } = await processMultipartFormdata({\n options: {\n ...(payload.config.bodyParser || {}),\n ...(payload.config.upload || {}),\n },\n request: req as Request,\n })\n\n if (error) {\n throw new APIError(error.message)\n }\n\n
|
|
1
|
+
{"version":3,"sources":["../../src/utilities/addDataAndFileToRequest.ts"],"sourcesContent":["import type { PayloadRequest } from '../types/index.js'\n\nimport { APIError } from '../errors/APIError.js'\nimport { processMultipartFormdata } from '../uploads/fetchAPI-multipart/index.js'\n\ntype AddDataAndFileToRequest = (req: PayloadRequest) => Promise<void>\n\n/**\n * Mutates the Request, appending 'data' and 'file' if found\n */\nexport const addDataAndFileToRequest: AddDataAndFileToRequest = async (req) => {\n const { body, headers, method, payload } = req\n\n if (method && ['PATCH', 'POST', 'PUT'].includes(method.toUpperCase()) && body) {\n const [contentType] = (headers.get('Content-Type') || '').split(';', 1)\n const bodyByteSize = parseInt(req.headers.get('Content-Length') || '0', 10)\n\n if (contentType === 'application/json') {\n let data = {}\n try {\n const text = await req.text?.()\n data = text ? JSON.parse(text) : {}\n } catch (error) {\n req.payload.logger.error(error)\n } finally {\n req.data = data\n // @ts-expect-error attach json method to request\n req.json = () => Promise.resolve(data)\n }\n } else if (bodyByteSize && contentType?.includes('multipart/')) {\n const { error, fields, files } = await processMultipartFormdata({\n options: {\n ...(payload.config.bodyParser || {}),\n ...(payload.config.upload || {}),\n },\n request: req as Request,\n })\n\n if (error) {\n throw new APIError(error.message)\n }\n\n if (files?.file) {\n req.file = files.file\n }\n\n if (fields?._payload && typeof fields._payload === 'string') {\n req.data = JSON.parse(fields._payload)\n }\n\n if (!req.file && fields?.file && typeof fields?.file === 'string') {\n const { clientUploadContext, collectionSlug, filename, mimeType, size } = JSON.parse(\n fields.file,\n )\n const uploadConfig = req.payload.collections[collectionSlug]!.config.upload\n\n if (!uploadConfig.handlers) {\n throw new APIError('uploadConfig.handlers is not present for ' + collectionSlug)\n }\n\n let response: null | Response = null\n let error: unknown\n\n for (const handler of uploadConfig.handlers) {\n try {\n const result = await handler(req, {\n doc: null!,\n params: {\n clientUploadContext, // Pass additional specific to adapters context returned from UploadHandler, then staticHandler can use them.\n collection: collectionSlug,\n filename,\n },\n })\n if (result) {\n response = result\n }\n // If we couldn't get the file from that handler, save the error and try other.\n } catch (err) {\n error = err\n }\n }\n\n if (!response) {\n if (error) {\n payload.logger.error(error)\n }\n\n throw new APIError('Expected response from the upload handler.')\n }\n\n req.file = {\n name: filename,\n clientUploadContext,\n data: Buffer.from(await response.arrayBuffer()),\n mimetype: response.headers.get('Content-Type') || mimeType,\n size,\n }\n }\n }\n }\n}\n"],"names":["APIError","processMultipartFormdata","addDataAndFileToRequest","req","body","headers","method","payload","includes","toUpperCase","contentType","get","split","bodyByteSize","parseInt","data","text","JSON","parse","error","logger","json","Promise","resolve","fields","files","options","config","bodyParser","upload","request","message","file","_payload","clientUploadContext","collectionSlug","filename","mimeType","size","uploadConfig","collections","handlers","response","handler","result","doc","params","collection","err","name","Buffer","from","arrayBuffer","mimetype"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,wBAAwB,QAAQ,yCAAwC;AAIjF;;CAEC,GACD,OAAO,MAAMC,0BAAmD,OAAOC;IACrE,MAAM,EAAEC,IAAI,EAAEC,OAAO,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EA,IAAI,CAAC9B,IAAI6B,IAAI,IAAIR,QAAQQ,QAAQ,OAAOR,QAAQQ,SAAS,UAAU;gBACjE,MAAM,EAAEE,mBAAmB,EAAEC,cAAc,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,IAAI,EAAE,GAAGrB,KAAKC,KAAK,CAClFM,OAAOQ,IAAI;gBAEb,MAAMO,eAAepC,IAAII,OAAO,CAACiC,WAAW,CAACL,eAAe,CAAER,MAAM,CAACE,MAAM;gBAE3E,IAAI,CAACU,aAAaE,QAAQ,EAAE;oBAC1B,MAAM,IAAIzC,SAAS,8CAA8CmC;gBACnE;gBAEA,IAAIO,WAA4B;gBAChC,IAAIvB;gBAEJ,KAAK,MAAMwB,WAAWJ,aAAaE,QAAQ,CAAE;oBAC3C,IAAI;wBACF,MAAMG,SAAS,MAAMD,QAAQxC,KAAK;4BAChC0C,KAAK;4BACLC,QAAQ;gCACNZ;gCACAa,YAAYZ;gCACZC;4BACF;wBACF;wBACA,IAAIQ,QAAQ;4BACVF,WAAWE;wBACb;oBACA,+EAA+E;oBACjF,EAAE,OAAOI,KAAK;wBACZ7B,QAAQ6B;oBACV;gBACF;gBAEA,IAAI,CAACN,UAAU;oBACb,IAAIvB,OAAO;wBACTZ,QAAQa,MAAM,CAACD,KAAK,CAACA;oBACvB;oBAEA,MAAM,IAAInB,SAAS;gBACrB;gBAEAG,IAAI6B,IAAI,GAAG;oBACTiB,MAAMb;oBACNF;oBACAnB,MAAMmC,OAAOC,IAAI,CAAC,MAAMT,SAASU,WAAW;oBAC5CC,UAAUX,SAASrC,OAAO,CAACM,GAAG,CAAC,mBAAmB0B;oBAClDC;gBACF;YACF;QACF;IACF;AACF,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload",
|
|
3
|
-
"version": "3.73.0-internal.
|
|
3
|
+
"version": "3.73.0-internal.e61e2ce",
|
|
4
4
|
"description": "Node, React, Headless CMS and Application Framework built on Next.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"admin panel",
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"undici": "7.18.2",
|
|
117
117
|
"uuid": "10.0.0",
|
|
118
118
|
"ws": "^8.16.0",
|
|
119
|
-
"@payloadcms/translations": "3.73.0-internal.
|
|
119
|
+
"@payloadcms/translations": "3.73.0-internal.e61e2ce"
|
|
120
120
|
},
|
|
121
121
|
"devDependencies": {
|
|
122
122
|
"@hyrious/esbuild-plugin-commonjs": "0.2.6",
|