payload 3.0.0-beta.13 → 3.0.0-beta.15

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.
Files changed (51) hide show
  1. package/dist/admin/RichText.d.ts +11 -8
  2. package/dist/admin/RichText.d.ts.map +1 -1
  3. package/dist/admin/RichText.js.map +1 -1
  4. package/dist/collections/config/client.d.ts +1 -0
  5. package/dist/collections/config/client.d.ts.map +1 -1
  6. package/dist/collections/config/types.d.ts +6 -0
  7. package/dist/collections/config/types.d.ts.map +1 -1
  8. package/dist/collections/config/types.js.map +1 -1
  9. package/dist/exports/utilities.d.ts +3 -0
  10. package/dist/exports/utilities.d.ts.map +1 -1
  11. package/dist/exports/utilities.js +3 -0
  12. package/dist/exports/utilities.js.map +1 -1
  13. package/dist/fields/config/sanitize.d.ts.map +1 -1
  14. package/dist/fields/config/sanitize.js +25 -8
  15. package/dist/fields/config/sanitize.js.map +1 -1
  16. package/dist/fields/config/types.d.ts +4 -1
  17. package/dist/fields/config/types.d.ts.map +1 -1
  18. package/dist/fields/config/types.js.map +1 -1
  19. package/dist/fields/hooks/afterRead/promise.d.ts +3 -0
  20. package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
  21. package/dist/fields/hooks/afterRead/promise.js +4 -16
  22. package/dist/fields/hooks/afterRead/promise.js.map +1 -1
  23. package/dist/fields/hooks/afterRead/traverseFields.d.ts +3 -0
  24. package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
  25. package/dist/fields/hooks/afterRead/traverseFields.js.map +1 -1
  26. package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
  27. package/dist/fields/hooks/beforeChange/promise.js +3 -1
  28. package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
  29. package/dist/fields/hooks/beforeChange/traverseFields.d.ts +12 -0
  30. package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
  31. package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
  32. package/dist/fields/hooks/beforeValidate/promise.d.ts +6 -0
  33. package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
  34. package/dist/fields/hooks/beforeValidate/promise.js +2 -0
  35. package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
  36. package/dist/fields/hooks/beforeValidate/traverseFields.d.ts +6 -0
  37. package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
  38. package/dist/fields/hooks/beforeValidate/traverseFields.js.map +1 -1
  39. package/dist/preferences/requestHandlers/delete.d.ts.map +1 -1
  40. package/dist/preferences/requestHandlers/delete.js +12 -0
  41. package/dist/preferences/requestHandlers/delete.js.map +1 -1
  42. package/dist/preferences/requestHandlers/findOne.d.ts.map +1 -1
  43. package/dist/preferences/requestHandlers/findOne.js +12 -0
  44. package/dist/preferences/requestHandlers/findOne.js.map +1 -1
  45. package/dist/preferences/requestHandlers/update.d.ts.map +1 -1
  46. package/dist/preferences/requestHandlers/update.js +12 -0
  47. package/dist/preferences/requestHandlers/update.js.map +1 -1
  48. package/dist/types/index.d.ts +3 -0
  49. package/dist/types/index.d.ts.map +1 -1
  50. package/dist/types/index.js.map +1 -1
  51. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/promise.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { fieldAffectsData, tabHasName, valueIsValueWithRelation } from '../../config/types.js'\nimport getValueWithDefault from '../../getDefaultValue.js'\nimport { cloneDataFromOriginalDoc } from '../beforeChange/cloneDataFromOriginalDoc.js'\nimport { getExistingRowDoc } from '../beforeChange/getExistingRowDoc.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args<T> = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: T\n doc: T\n field: Field | TabAsField\n global: SanitizedGlobalConfig | null\n id?: number | string\n operation: 'create' | 'update'\n overrideAccess: boolean\n req: PayloadRequest\n siblingData: Record<string, unknown>\n siblingDoc: Record<string, unknown>\n}\n\n// This function is responsible for the following actions, in order:\n// - Sanitize incoming data\n// - Execute field hooks\n// - Execute field access control\n// - Merge original document data into incoming data\n// - Compute default values for undefined fields\n\nexport const promise = async <T>({\n id,\n collection,\n context,\n data,\n doc,\n field,\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n}: Args<T>): Promise<void> => {\n if (fieldAffectsData(field)) {\n if (field.name === 'id') {\n if (field.type === 'number' && typeof siblingData[field.name] === 'string') {\n const value = siblingData[field.name] as string\n\n siblingData[field.name] = parseFloat(value)\n }\n\n if (\n field.type === 'text' &&\n typeof siblingData[field.name]?.toString === 'function' &&\n typeof siblingData[field.name] !== 'string'\n ) {\n siblingData[field.name] = siblingData[field.name].toString()\n }\n }\n\n // Sanitize incoming data\n switch (field.type) {\n case 'number': {\n if (typeof siblingData[field.name] === 'string') {\n const value = siblingData[field.name] as string\n const trimmed = value.trim()\n siblingData[field.name] = trimmed.length === 0 ? null : parseFloat(trimmed)\n }\n\n break\n }\n\n case 'point': {\n if (Array.isArray(siblingData[field.name])) {\n siblingData[field.name] = (siblingData[field.name] as string[]).map((coordinate, i) => {\n if (typeof coordinate === 'string') {\n const value = siblingData[field.name][i] as string\n const trimmed = value.trim()\n return trimmed.length === 0 ? null : parseFloat(trimmed)\n }\n return coordinate\n })\n }\n\n break\n }\n\n case 'checkbox': {\n if (siblingData[field.name] === 'true') siblingData[field.name] = true\n if (siblingData[field.name] === 'false') siblingData[field.name] = false\n if (siblingData[field.name] === '') siblingData[field.name] = false\n\n break\n }\n\n case 'richText': {\n if (typeof siblingData[field.name] === 'string') {\n try {\n const richTextJSON = JSON.parse(siblingData[field.name] as string)\n siblingData[field.name] = richTextJSON\n } catch {\n // Disregard this data as it is not valid.\n // Will be reported to user by field validation\n }\n }\n\n break\n }\n\n case 'relationship':\n case 'upload': {\n if (\n siblingData[field.name] === '' ||\n siblingData[field.name] === 'none' ||\n siblingData[field.name] === 'null' ||\n siblingData[field.name] === null\n ) {\n if (field.type === 'relationship' && field.hasMany === true) {\n siblingData[field.name] = []\n } else {\n siblingData[field.name] = null\n }\n }\n\n const value = siblingData[field.name]\n\n if (Array.isArray(field.relationTo)) {\n if (Array.isArray(value)) {\n value.forEach((relatedDoc: { relationTo: string; value: unknown }, i) => {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === relatedDoc.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name][i] = {\n ...relatedDoc,\n value: parseFloat(relatedDoc.value as string),\n }\n }\n })\n }\n if (\n field.type === 'relationship' &&\n field.hasMany !== true &&\n valueIsValueWithRelation(value)\n ) {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === value.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name] = { ...value, value: parseFloat(value.value as string) }\n }\n }\n } else {\n if (Array.isArray(value)) {\n value.forEach((relatedDoc: unknown, i) => {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === field.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name][i] = parseFloat(relatedDoc as string)\n }\n })\n }\n if (field.type === 'relationship' && field.hasMany !== true && value) {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === field.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name] = parseFloat(value as string)\n }\n }\n }\n break\n }\n\n case 'array':\n case 'blocks': {\n // Handle cases of arrays being intentionally set to 0\n if (siblingData[field.name] === '0' || siblingData[field.name] === 0) {\n siblingData[field.name] = []\n }\n\n break\n }\n\n default: {\n break\n }\n }\n\n // Execute hooks\n if (field.hooks?.beforeValidate) {\n await field.hooks.beforeValidate.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n field,\n global,\n operation,\n originalDoc: doc,\n req,\n siblingData,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n\n // Execute access control\n if (field.access && field.access[operation]) {\n const result = overrideAccess\n ? true\n : await field.access[operation]({ id, data, doc, req, siblingData })\n\n if (!result) {\n delete siblingData[field.name]\n }\n }\n\n if (typeof siblingData[field.name] === 'undefined') {\n // If no incoming data, but existing document data is found, merge it in\n if (typeof siblingDoc[field.name] !== 'undefined') {\n siblingData[field.name] = cloneDataFromOriginalDoc(siblingDoc[field.name])\n\n // Otherwise compute default value\n } else if (typeof field.defaultValue !== 'undefined') {\n siblingData[field.name] = await getValueWithDefault({\n defaultValue: field.defaultValue,\n locale: req.locale,\n user: req.user,\n value: siblingData[field.name],\n })\n }\n }\n }\n\n // Traverse subfields\n switch (field.type) {\n case 'group': {\n if (typeof siblingData[field.name] !== 'object') siblingData[field.name] = {}\n if (typeof siblingDoc[field.name] !== 'object') siblingDoc[field.name] = {}\n\n const groupData = siblingData[field.name] as Record<string, unknown>\n const groupDoc = siblingDoc[field.name] as Record<string, unknown>\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: groupData,\n siblingDoc: groupDoc,\n })\n\n break\n }\n\n case 'array': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row) => {\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: row,\n siblingDoc: getExistingRowDoc(row, siblingDoc[field.name]),\n }),\n )\n })\n await Promise.all(promises)\n }\n break\n }\n\n case 'blocks': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row) => {\n const rowSiblingDoc = getExistingRowDoc(row, siblingDoc[field.name])\n const blockTypeToMatch = row.blockType || rowSiblingDoc.blockType\n const block = field.blocks.find((blockType) => blockType.slug === blockTypeToMatch)\n\n if (block) {\n row.blockType = blockTypeToMatch\n\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: block.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: row,\n siblingDoc: rowSiblingDoc,\n }),\n )\n }\n })\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'row':\n case 'collapsible': {\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n })\n\n break\n }\n\n case 'tab': {\n let tabSiblingData\n let tabSiblingDoc\n if (tabHasName(field)) {\n if (typeof siblingData[field.name] !== 'object') siblingData[field.name] = {}\n if (typeof siblingDoc[field.name] !== 'object') siblingDoc[field.name] = {}\n\n tabSiblingData = siblingData[field.name] as Record<string, unknown>\n tabSiblingDoc = siblingDoc[field.name] as Record<string, unknown>\n } else {\n tabSiblingData = siblingData\n tabSiblingDoc = siblingDoc\n }\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n })\n\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["fieldAffectsData","tabHasName","valueIsValueWithRelation","getValueWithDefault","cloneDataFromOriginalDoc","getExistingRowDoc","traverseFields","promise","id","collection","context","data","doc","field","global","operation","overrideAccess","req","siblingData","siblingDoc","name","type","value","parseFloat","toString","trimmed","trim","length","Array","isArray","map","coordinate","i","richTextJSON","JSON","parse","hasMany","relationTo","forEach","relatedDoc","relatedCollection","payload","config","collections","find","slug","relationshipIDField","fields","collectionField","hooks","beforeValidate","reduce","priorHook","currentHook","hookedValue","originalDoc","undefined","Promise","resolve","access","result","defaultValue","locale","user","groupData","groupDoc","rows","promises","row","push","all","rowSiblingDoc","blockTypeToMatch","blockType","block","blocks","tabSiblingData","tabSiblingDoc","tabs","tab"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GAMpC,SAASA,gBAAgB,EAAEC,UAAU,EAAEC,wBAAwB,QAAQ,wBAAuB;AAC9F,OAAOC,yBAAyB,2BAA0B;AAC1D,SAASC,wBAAwB,QAAQ,8CAA6C;AACtF,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,cAAc,QAAQ,sBAAqB;AAiBpD,oEAAoE;AACpE,2BAA2B;AAC3B,wBAAwB;AACxB,iCAAiC;AACjC,oDAAoD;AACpD,gDAAgD;AA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eAAe;oBACnBE;oBACAC;oBACAC;oBACAC;oBACAC;oBACAmC,QAAQlC,MAAMiE,IAAI,CAAChD,GAAG,CAAC,CAACiD,MAAS,CAAA;4BAAE,GAAGA,GAAG;4BAAE1D,MAAM;wBAAM,CAAA;oBACvDP;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;gBACF;gBAEA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/promise.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { fieldAffectsData, tabHasName, valueIsValueWithRelation } from '../../config/types.js'\nimport getValueWithDefault from '../../getDefaultValue.js'\nimport { cloneDataFromOriginalDoc } from '../beforeChange/cloneDataFromOriginalDoc.js'\nimport { getExistingRowDoc } from '../beforeChange/getExistingRowDoc.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args<T> = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: T\n /**\n * The original data (not modified by any hooks)\n */\n doc: T\n field: Field | TabAsField\n global: SanitizedGlobalConfig | null\n id?: number | string\n operation: 'create' | 'update'\n overrideAccess: boolean\n req: PayloadRequest\n siblingData: Record<string, unknown>\n /**\n * The original siblingData (not modified by any hooks)\n */\n siblingDoc: Record<string, unknown>\n}\n\n// This function is responsible for the following actions, in order:\n// - Sanitize incoming data\n// - Execute field hooks\n// - Execute field access control\n// - Merge original document data into incoming data\n// - Compute default values for undefined fields\n\nexport const promise = async <T>({\n id,\n collection,\n context,\n data,\n doc,\n field,\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n}: Args<T>): Promise<void> => {\n if (fieldAffectsData(field)) {\n if (field.name === 'id') {\n if (field.type === 'number' && typeof siblingData[field.name] === 'string') {\n const value = siblingData[field.name] as string\n\n siblingData[field.name] = parseFloat(value)\n }\n\n if (\n field.type === 'text' &&\n typeof siblingData[field.name]?.toString === 'function' &&\n typeof siblingData[field.name] !== 'string'\n ) {\n siblingData[field.name] = siblingData[field.name].toString()\n }\n }\n\n // Sanitize incoming data\n switch (field.type) {\n case 'number': {\n if (typeof siblingData[field.name] === 'string') {\n const value = siblingData[field.name] as string\n const trimmed = value.trim()\n siblingData[field.name] = trimmed.length === 0 ? null : parseFloat(trimmed)\n }\n\n break\n }\n\n case 'point': {\n if (Array.isArray(siblingData[field.name])) {\n siblingData[field.name] = (siblingData[field.name] as string[]).map((coordinate, i) => {\n if (typeof coordinate === 'string') {\n const value = siblingData[field.name][i] as string\n const trimmed = value.trim()\n return trimmed.length === 0 ? null : parseFloat(trimmed)\n }\n return coordinate\n })\n }\n\n break\n }\n\n case 'checkbox': {\n if (siblingData[field.name] === 'true') siblingData[field.name] = true\n if (siblingData[field.name] === 'false') siblingData[field.name] = false\n if (siblingData[field.name] === '') siblingData[field.name] = false\n\n break\n }\n\n case 'richText': {\n if (typeof siblingData[field.name] === 'string') {\n try {\n const richTextJSON = JSON.parse(siblingData[field.name] as string)\n siblingData[field.name] = richTextJSON\n } catch {\n // Disregard this data as it is not valid.\n // Will be reported to user by field validation\n }\n }\n\n break\n }\n\n case 'relationship':\n case 'upload': {\n if (\n siblingData[field.name] === '' ||\n siblingData[field.name] === 'none' ||\n siblingData[field.name] === 'null' ||\n siblingData[field.name] === null\n ) {\n if (field.type === 'relationship' && field.hasMany === true) {\n siblingData[field.name] = []\n } else {\n siblingData[field.name] = null\n }\n }\n\n const value = siblingData[field.name]\n\n if (Array.isArray(field.relationTo)) {\n if (Array.isArray(value)) {\n value.forEach((relatedDoc: { relationTo: string; value: unknown }, i) => {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === relatedDoc.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name][i] = {\n ...relatedDoc,\n value: parseFloat(relatedDoc.value as string),\n }\n }\n })\n }\n if (\n field.type === 'relationship' &&\n field.hasMany !== true &&\n valueIsValueWithRelation(value)\n ) {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === value.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name] = { ...value, value: parseFloat(value.value as string) }\n }\n }\n } else {\n if (Array.isArray(value)) {\n value.forEach((relatedDoc: unknown, i) => {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === field.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name][i] = parseFloat(relatedDoc as string)\n }\n })\n }\n if (field.type === 'relationship' && field.hasMany !== true && value) {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === field.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name] = parseFloat(value as string)\n }\n }\n }\n break\n }\n\n case 'array':\n case 'blocks': {\n // Handle cases of arrays being intentionally set to 0\n if (siblingData[field.name] === '0' || siblingData[field.name] === 0) {\n siblingData[field.name] = []\n }\n\n break\n }\n\n default: {\n break\n }\n }\n\n // Execute hooks\n if (field.hooks?.beforeValidate) {\n await field.hooks.beforeValidate.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n field,\n global,\n operation,\n originalDoc: doc,\n overrideAccess,\n previousSiblingDoc: siblingDoc,\n req,\n siblingData,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n\n // Execute access control\n if (field.access && field.access[operation]) {\n const result = overrideAccess\n ? true\n : await field.access[operation]({ id, data, doc, req, siblingData })\n\n if (!result) {\n delete siblingData[field.name]\n }\n }\n\n if (typeof siblingData[field.name] === 'undefined') {\n // If no incoming data, but existing document data is found, merge it in\n if (typeof siblingDoc[field.name] !== 'undefined') {\n siblingData[field.name] = cloneDataFromOriginalDoc(siblingDoc[field.name])\n\n // Otherwise compute default value\n } else if (typeof field.defaultValue !== 'undefined') {\n siblingData[field.name] = await getValueWithDefault({\n defaultValue: field.defaultValue,\n locale: req.locale,\n user: req.user,\n value: siblingData[field.name],\n })\n }\n }\n }\n\n // Traverse subfields\n switch (field.type) {\n case 'group': {\n if (typeof siblingData[field.name] !== 'object') siblingData[field.name] = {}\n if (typeof siblingDoc[field.name] !== 'object') siblingDoc[field.name] = {}\n\n const groupData = siblingData[field.name] as Record<string, unknown>\n const groupDoc = siblingDoc[field.name] as Record<string, unknown>\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: groupData,\n siblingDoc: groupDoc,\n })\n\n break\n }\n\n case 'array': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row) => {\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: row,\n siblingDoc: getExistingRowDoc(row, siblingDoc[field.name]),\n }),\n )\n })\n await Promise.all(promises)\n }\n break\n }\n\n case 'blocks': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row) => {\n const rowSiblingDoc = getExistingRowDoc(row, siblingDoc[field.name])\n const blockTypeToMatch = row.blockType || rowSiblingDoc.blockType\n const block = field.blocks.find((blockType) => blockType.slug === blockTypeToMatch)\n\n if (block) {\n row.blockType = blockTypeToMatch\n\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: block.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: row,\n siblingDoc: rowSiblingDoc,\n }),\n )\n }\n })\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'row':\n case 'collapsible': {\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n })\n\n break\n }\n\n case 'tab': {\n let tabSiblingData\n let tabSiblingDoc\n if (tabHasName(field)) {\n if (typeof siblingData[field.name] !== 'object') siblingData[field.name] = {}\n if (typeof siblingDoc[field.name] !== 'object') siblingDoc[field.name] = {}\n\n tabSiblingData = siblingData[field.name] as Record<string, unknown>\n tabSiblingDoc = siblingDoc[field.name] as Record<string, unknown>\n } else {\n tabSiblingData = siblingData\n tabSiblingDoc = siblingDoc\n }\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n })\n\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["fieldAffectsData","tabHasName","valueIsValueWithRelation","getValueWithDefault","cloneDataFromOriginalDoc","getExistingRowDoc","traverseFields","promise","id","collection","context","data","doc","field","global","operation","overrideAccess","req","siblingData","siblingDoc","name","type","value","parseFloat","toString","trimmed","trim","length","Array","isArray","map","coordinate","i","richTextJSON","JSON","parse","hasMany","relationTo","forEach","relatedDoc","relatedCollection","payload","config","collections","find","slug","relationshipIDField","fields","collectionField","hooks","beforeValidate","reduce","priorHook","currentHook","hookedValue","originalDoc","previousSiblingDoc","undefined","Promise","resolve","access","result","defaultValue","locale","user","groupData","groupDoc","rows","promises","row","push","all","rowSiblingDoc","blockTypeToMatch","blockType","block","blocks","tabSiblingData","tabSiblingDoc","tabs","tab"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GAMpC,SAASA,gBAAgB,EAAEC,UAAU,EAAEC,wBAAwB,QAAQ,wBAAuB;AAC9F,OAAOC,yBAAyB,2BAA0B;AAC1D,SAASC,wBAAwB,QAAQ,8CAA6C;AACtF,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,cAAc,QAAQ,sBAAqB;AAuBpD,oEAAoE;AACpE,2BAA2B;AAC3B,wBAAwB;AACxB,iCAAiC;AACjC,oDAAoD;AACpD,gDAAgD;AAEhD,OAAO,MAAMC,UAAU,OAAU,EAC/BC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,GAAG,EACHC,WAAW,EACXC,UAAU,EACF;IACR,IAAInB,iBAAiBa,QAAQ;QAC3B,IAAIA,MAAMO,IAAI,KAAK,MAAM;YACvB,IAAIP,MAAMQ,IAAI,KAAK,YAAY,OAAOH,WAAW,CAACL,MAAMO,IAAI,CAAC,KAAK,UAAU;gBAC1E,MAAME,QAAQJ,WAAW,CAACL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AQa,GAAG,CAACH;gBACpB;gBAEA;YACF;QAEA,KAAK;QACL,KAAK;YAAe;gBAClB,MAAM9D,eAAe;oBACnBE;oBACAC;oBACAC;oBACAC;oBACAC;oBACAmC,QAAQlC,MAAMkC,MAAM;oBACpBjC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;gBACF;gBAEA;YACF;QAEA,KAAK;YAAO;gBACV,IAAI0D;gBACJ,IAAIC;gBACJ,IAAI7E,WAAWY,QAAQ;oBACrB,IAAI,OAAOK,WAAW,CAACL,MAAMO,IAAI,CAAC,KAAK,UAAUF,WAAW,CAACL,MAAMO,IAAI,CAAC,GAAG,CAAC;oBAC5E,IAAI,OAAOD,UAAU,CAACN,MAAMO,IAAI,CAAC,KAAK,UAAUD,UAAU,CAACN,MAAMO,IAAI,CAAC,GAAG,CAAC;oBAE1EyD,iBAAiB3D,WAAW,CAACL,MAAMO,IAAI,CAAC;oBACxC0D,gBAAgB3D,UAAU,CAACN,MAAMO,IAAI,CAAC;gBACxC,OAAO;oBACLyD,iBAAiB3D;oBACjB4D,gBAAgB3D;gBAClB;gBAEA,MAAMb,eAAe;oBACnBE;oBACAC;oBACAC;oBACAC;oBACAC;oBACAmC,QAAQlC,MAAMkC,MAAM;oBACpBjC;oBACAC;oBACAC;oBACAC;oBACAC,aAAa2D;oBACb1D,YAAY2D;gBACd;gBAEA;YACF;QAEA,KAAK;YAAQ;gBACX,MAAMxE,eAAe;oBACnBE;oBACAC;oBACAC;oBACAC;oBACAC;oBACAmC,QAAQlC,MAAMkE,IAAI,CAACjD,GAAG,CAAC,CAACkD,MAAS,CAAA;4BAAE,GAAGA,GAAG;4BAAE3D,MAAM;wBAAM,CAAA;oBACvDP;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;gBACF;gBAEA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
@@ -6,6 +6,9 @@ type Args<T> = {
6
6
  collection: SanitizedCollectionConfig | null;
7
7
  context: RequestContext;
8
8
  data: T;
9
+ /**
10
+ * The original data (not modified by any hooks)
11
+ */
9
12
  doc: T;
10
13
  fields: (Field | TabAsField)[];
11
14
  global: SanitizedGlobalConfig | null;
@@ -14,6 +17,9 @@ type Args<T> = {
14
17
  overrideAccess: boolean;
15
18
  req: PayloadRequest;
16
19
  siblingData: Record<string, unknown>;
20
+ /**
21
+ * The original siblingData (not modified by any hooks)
22
+ */
17
23
  siblingDoc: Record<string, unknown>;
18
24
  };
19
25
  export declare const traverseFields: <T>({ id, collection, context, data, doc, fields, global, operation, overrideAccess, req, siblingData, siblingDoc, }: Args<T>) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeValidate/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7E,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAI9D,KAAK,IAAI,CAAC,CAAC,IAAI;IACb,UAAU,EAAE,yBAAyB,GAAG,IAAI,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,CAAC,CAAA;IACP,GAAG,EAAE,CAAC,CAAA;IACN,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAA;IACpC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;IACnB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,cAAc,wHAaxB,KAAK,CAAC,CAAC,KAAG,QAAQ,IAAI,CAqBxB,CAAA"}
1
+ {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeValidate/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7E,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAI9D,KAAK,IAAI,CAAC,CAAC,IAAI;IACb,UAAU,EAAE,yBAAyB,GAAG,IAAI,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,CAAC,CAAA;IACP;;OAEG;IACH,GAAG,EAAE,CAAC,CAAA;IACN,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAA;IACpC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;IACnB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,cAAc,wHAaxB,KAAK,CAAC,CAAC,KAAG,QAAQ,IAAI,CAqBxB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args<T> = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: T\n doc: T\n fields: (Field | TabAsField)[]\n global: SanitizedGlobalConfig | null\n id?: number | string\n operation: 'create' | 'update'\n overrideAccess: boolean\n req: PayloadRequest\n siblingData: Record<string, unknown>\n siblingDoc: Record<string, unknown>\n}\n\nexport const traverseFields = async <T>({\n id,\n collection,\n context,\n data,\n doc,\n fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n}: Args<T>): Promise<void> => {\n const promises = []\n fields.forEach((field) => {\n promises.push(\n promise({\n id,\n collection,\n context,\n data,\n doc,\n field,\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n }),\n )\n })\n await Promise.all(promises)\n}\n"],"names":["promise","traverseFields","id","collection","context","data","doc","fields","global","operation","overrideAccess","req","siblingData","siblingDoc","promises","forEach","field","push","Promise","all"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,OAAO,QAAQ,eAAc;AAiBtC,OAAO,MAAMC,iBAAiB,OAAU,EACtCC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,MAAM,EACNC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,GAAG,EACHC,WAAW,EACXC,UAAU,EACF;IACR,MAAMC,WAAW,EAAE;IACnBP,OAAOQ,OAAO,CAAC,CAACC;QACdF,SAASG,IAAI,CACXjB,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAC;YACAU;YACAR;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;IAEJ;IACA,MAAMK,QAAQC,GAAG,CAACL;AACpB,EAAC"}
1
+ {"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args<T> = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: T\n /**\n * The original data (not modified by any hooks)\n */\n doc: T\n fields: (Field | TabAsField)[]\n global: SanitizedGlobalConfig | null\n id?: number | string\n operation: 'create' | 'update'\n overrideAccess: boolean\n req: PayloadRequest\n siblingData: Record<string, unknown>\n /**\n * The original siblingData (not modified by any hooks)\n */\n siblingDoc: Record<string, unknown>\n}\n\nexport const traverseFields = async <T>({\n id,\n collection,\n context,\n data,\n doc,\n fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n}: Args<T>): Promise<void> => {\n const promises = []\n fields.forEach((field) => {\n promises.push(\n promise({\n id,\n collection,\n context,\n data,\n doc,\n field,\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n }),\n )\n })\n await Promise.all(promises)\n}\n"],"names":["promise","traverseFields","id","collection","context","data","doc","fields","global","operation","overrideAccess","req","siblingData","siblingDoc","promises","forEach","field","push","Promise","all"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,OAAO,QAAQ,eAAc;AAuBtC,OAAO,MAAMC,iBAAiB,OAAU,EACtCC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,MAAM,EACNC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,GAAG,EACHC,WAAW,EACXC,UAAU,EACF;IACR,MAAMC,WAAW,EAAE;IACnBP,OAAOQ,OAAO,CAAC,CAACC;QACdF,SAASG,IAAI,CACXjB,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAC;YACAU;YACAR;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;IAEJ;IACA,MAAMK,QAAQC,GAAG,CAACL;AACpB,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/preferences/requestHandlers/delete.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAI3D,eAAO,MAAM,aAAa,EAAE,cAgB3B,CAAA"}
1
+ {"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../../src/preferences/requestHandlers/delete.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAI3D,eAAO,MAAM,aAAa,EAAE,cA+B3B,CAAA"}
@@ -1,6 +1,18 @@
1
1
  import httpStatus from 'http-status';
2
2
  import deleteOperation from '../operations/delete.js';
3
3
  export const deleteHandler = async (req)=>{
4
+ // We cannot import the addDataAndFileToRequest utility here from the 'next' package because of dependency issues
5
+ // However that utility should be used where possible instead of manually appending the data
6
+ let data;
7
+ try {
8
+ data = await req.json();
9
+ } catch (error) {
10
+ data = {};
11
+ }
12
+ if (data) {
13
+ req.data = data;
14
+ req.json = ()=>Promise.resolve(data);
15
+ }
4
16
  const result = await deleteOperation({
5
17
  key: req.routeParams?.key,
6
18
  req,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/preferences/requestHandlers/delete.ts"],"sourcesContent":["import httpStatus from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport deleteOperation from '../operations/delete.js'\n\nexport const deleteHandler: PayloadHandler = async (req): Promise<Response> => {\n const result = await deleteOperation({\n key: req.routeParams?.key as string,\n req,\n user: req.user,\n })\n\n return Response.json(\n {\n ...result,\n message: req.t('general:deletedSuccessfully'),\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","deleteOperation","deleteHandler","req","result","key","routeParams","user","Response","json","message","t","status","OK"],"rangeMappings":";;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AAIpC,OAAOC,qBAAqB,0BAAyB;AAErD,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,MAAMC,SAAS,MAAMH,gBAAgB;QACnCI,KAAKF,IAAIG,WAAW,EAAED;QACtBF;QACAI,MAAMJ,IAAII,IAAI;IAChB;IAEA,OAAOC,SAASC,IAAI,CAClB;QACE,GAAGL,MAAM;QACTM,SAASP,IAAIQ,CAAC,CAAC;IACjB,GACA;QACEC,QAAQZ,WAAWa,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../src/preferences/requestHandlers/delete.ts"],"sourcesContent":["import httpStatus from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport deleteOperation from '../operations/delete.js'\n\nexport const deleteHandler: PayloadHandler = async (req): Promise<Response> => {\n // We cannot import the addDataAndFileToRequest utility here from the 'next' package because of dependency issues\n // However that utility should be used where possible instead of manually appending the data\n let data\n\n try {\n data = await req.json()\n } catch (error) {\n data = {}\n }\n\n if (data) {\n req.data = data\n req.json = () => Promise.resolve(data)\n }\n\n const result = await deleteOperation({\n key: req.routeParams?.key as string,\n req,\n user: req.user,\n })\n\n return Response.json(\n {\n ...result,\n message: req.t('general:deletedSuccessfully'),\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","deleteOperation","deleteHandler","req","data","json","error","Promise","resolve","result","key","routeParams","user","Response","message","t","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AAIpC,OAAOC,qBAAqB,0BAAyB;AAErD,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,iHAAiH;IACjH,4FAA4F;IAC5F,IAAIC;IAEJ,IAAI;QACFA,OAAO,MAAMD,IAAIE,IAAI;IACvB,EAAE,OAAOC,OAAO;QACdF,OAAO,CAAC;IACV;IAEA,IAAIA,MAAM;QACRD,IAAIC,IAAI,GAAGA;QACXD,IAAIE,IAAI,GAAG,IAAME,QAAQC,OAAO,CAACJ;IACnC;IAEA,MAAMK,SAAS,MAAMR,gBAAgB;QACnCS,KAAKP,IAAIQ,WAAW,EAAED;QACtBP;QACAS,MAAMT,IAAIS,IAAI;IAChB;IAEA,OAAOC,SAASR,IAAI,CAClB;QACE,GAAGI,MAAM;QACTK,SAASX,IAAIY,CAAC,CAAC;IACjB,GACA;QACEC,QAAQhB,WAAWiB,EAAE;IACvB;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../../../src/preferences/requestHandlers/findOne.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAI3D,eAAO,MAAM,eAAe,EAAE,cAoB7B,CAAA"}
1
+ {"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../../../src/preferences/requestHandlers/findOne.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAI3D,eAAO,MAAM,eAAe,EAAE,cAmC7B,CAAA"}
@@ -1,6 +1,18 @@
1
1
  import httpStatus from 'http-status';
2
2
  import findOne from '../operations/findOne.js';
3
3
  export const findByIDHandler = async (req)=>{
4
+ // We cannot import the addDataAndFileToRequest utility here from the 'next' package because of dependency issues
5
+ // However that utility should be used where possible instead of manually appending the data
6
+ let data;
7
+ try {
8
+ data = await req.json();
9
+ } catch (error) {
10
+ data = {};
11
+ }
12
+ if (data) {
13
+ req.data = data;
14
+ req.json = ()=>Promise.resolve(data);
15
+ }
4
16
  const result = await findOne({
5
17
  key: req.routeParams?.key,
6
18
  req,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/preferences/requestHandlers/findOne.ts"],"sourcesContent":["import httpStatus from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport findOne from '../operations/findOne.js'\n\nexport const findByIDHandler: PayloadHandler = async (req): Promise<Response> => {\n const result = await findOne({\n key: req.routeParams?.key as string,\n req,\n user: req.user,\n })\n\n return Response.json(\n {\n ...(result\n ? result\n : {\n message: req.t('general:notFound'),\n value: null,\n }),\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","findOne","findByIDHandler","req","result","key","routeParams","user","Response","json","message","t","value","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AAIpC,OAAOC,aAAa,2BAA0B;AAE9C,OAAO,MAAMC,kBAAkC,OAAOC;IACpD,MAAMC,SAAS,MAAMH,QAAQ;QAC3BI,KAAKF,IAAIG,WAAW,EAAED;QACtBF;QACAI,MAAMJ,IAAII,IAAI;IAChB;IAEA,OAAOC,SAASC,IAAI,CAClB;QACE,GAAIL,SACAA,SACA;YACEM,SAASP,IAAIQ,CAAC,CAAC;YACfC,OAAO;QACT,CAAC;IACP,GACA;QACEC,QAAQb,WAAWc,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../src/preferences/requestHandlers/findOne.ts"],"sourcesContent":["import httpStatus from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport findOne from '../operations/findOne.js'\n\nexport const findByIDHandler: PayloadHandler = async (req): Promise<Response> => {\n // We cannot import the addDataAndFileToRequest utility here from the 'next' package because of dependency issues\n // However that utility should be used where possible instead of manually appending the data\n let data\n\n try {\n data = await req.json()\n } catch (error) {\n data = {}\n }\n\n if (data) {\n req.data = data\n req.json = () => Promise.resolve(data)\n }\n\n const result = await findOne({\n key: req.routeParams?.key as string,\n req,\n user: req.user,\n })\n\n return Response.json(\n {\n ...(result\n ? result\n : {\n message: req.t('general:notFound'),\n value: null,\n }),\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","findOne","findByIDHandler","req","data","json","error","Promise","resolve","result","key","routeParams","user","Response","message","t","value","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AAIpC,OAAOC,aAAa,2BAA0B;AAE9C,OAAO,MAAMC,kBAAkC,OAAOC;IACpD,iHAAiH;IACjH,4FAA4F;IAC5F,IAAIC;IAEJ,IAAI;QACFA,OAAO,MAAMD,IAAIE,IAAI;IACvB,EAAE,OAAOC,OAAO;QACdF,OAAO,CAAC;IACV;IAEA,IAAIA,MAAM;QACRD,IAAIC,IAAI,GAAGA;QACXD,IAAIE,IAAI,GAAG,IAAME,QAAQC,OAAO,CAACJ;IACnC;IAEA,MAAMK,SAAS,MAAMR,QAAQ;QAC3BS,KAAKP,IAAIQ,WAAW,EAAED;QACtBP;QACAS,MAAMT,IAAIS,IAAI;IAChB;IAEA,OAAOC,SAASR,IAAI,CAClB;QACE,GAAII,SACAA,SACA;YACEK,SAASX,IAAIY,CAAC,CAAC;YACfC,OAAO;QACT,CAAC;IACP,GACA;QACEC,QAAQjB,WAAWkB,EAAE;IACvB;AAEJ,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/preferences/requestHandlers/update.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAI3D,eAAO,MAAM,aAAa,EAAE,cAmB3B,CAAA"}
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/preferences/requestHandlers/update.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAI3D,eAAO,MAAM,aAAa,EAAE,cAkC3B,CAAA"}
@@ -1,6 +1,18 @@
1
1
  import httpStatus from 'http-status';
2
2
  import update from '../operations/update.js';
3
3
  export const updateHandler = async (req)=>{
4
+ // We cannot import the addDataAndFileToRequest utility here from the 'next' package because of dependency issues
5
+ // However that utility should be used where possible instead of manually appending the data
6
+ let data;
7
+ try {
8
+ data = await req.json();
9
+ } catch (error) {
10
+ data = {};
11
+ }
12
+ if (data) {
13
+ req.data = data;
14
+ req.json = ()=>Promise.resolve(data);
15
+ }
4
16
  const payloadRequest = req;
5
17
  const doc = await update({
6
18
  key: req.routeParams?.key,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/preferences/requestHandlers/update.ts"],"sourcesContent":["import httpStatus from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport update from '../operations/update.js'\n\nexport const updateHandler: PayloadHandler = async (req) => {\n const payloadRequest = req\n\n const doc = await update({\n key: req.routeParams?.key as string,\n req: payloadRequest,\n user: payloadRequest?.user,\n value: payloadRequest.data.value || payloadRequest.data,\n })\n\n return Response.json(\n {\n doc,\n message: payloadRequest.t('general:updatedSuccessfully'),\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","update","updateHandler","req","payloadRequest","doc","key","routeParams","user","value","data","Response","json","message","t","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AAIpC,OAAOC,YAAY,0BAAyB;AAE5C,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,MAAMC,iBAAiBD;IAEvB,MAAME,MAAM,MAAMJ,OAAO;QACvBK,KAAKH,IAAII,WAAW,EAAED;QACtBH,KAAKC;QACLI,MAAMJ,gBAAgBI;QACtBC,OAAOL,eAAeM,IAAI,CAACD,KAAK,IAAIL,eAAeM,IAAI;IACzD;IAEA,OAAOC,SAASC,IAAI,CAClB;QACEP;QACAQ,SAAST,eAAeU,CAAC,CAAC;IAC5B,GACA;QACEC,QAAQf,WAAWgB,EAAE;IACvB;AAEJ,EAAC"}
1
+ {"version":3,"sources":["../../../src/preferences/requestHandlers/update.ts"],"sourcesContent":["import httpStatus from 'http-status'\n\nimport type { PayloadHandler } from '../../config/types.js'\n\nimport update from '../operations/update.js'\n\nexport const updateHandler: PayloadHandler = async (req) => {\n // We cannot import the addDataAndFileToRequest utility here from the 'next' package because of dependency issues\n // However that utility should be used where possible instead of manually appending the data\n let data\n\n try {\n data = await req.json()\n } catch (error) {\n data = {}\n }\n\n if (data) {\n req.data = data\n req.json = () => Promise.resolve(data)\n }\n\n const payloadRequest = req\n\n const doc = await update({\n key: req.routeParams?.key as string,\n req: payloadRequest,\n user: payloadRequest?.user,\n value: payloadRequest.data.value || payloadRequest.data,\n })\n\n return Response.json(\n {\n doc,\n message: payloadRequest.t('general:updatedSuccessfully'),\n },\n {\n status: httpStatus.OK,\n },\n )\n}\n"],"names":["httpStatus","update","updateHandler","req","data","json","error","Promise","resolve","payloadRequest","doc","key","routeParams","user","value","Response","message","t","status","OK"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,OAAOA,gBAAgB,cAAa;AAIpC,OAAOC,YAAY,0BAAyB;AAE5C,OAAO,MAAMC,gBAAgC,OAAOC;IAClD,iHAAiH;IACjH,4FAA4F;IAC5F,IAAIC;IAEJ,IAAI;QACFA,OAAO,MAAMD,IAAIE,IAAI;IACvB,EAAE,OAAOC,OAAO;QACdF,OAAO,CAAC;IACV;IAEA,IAAIA,MAAM;QACRD,IAAIC,IAAI,GAAGA;QACXD,IAAIE,IAAI,GAAG,IAAME,QAAQC,OAAO,CAACJ;IACnC;IAEA,MAAMK,iBAAiBN;IAEvB,MAAMO,MAAM,MAAMT,OAAO;QACvBU,KAAKR,IAAIS,WAAW,EAAED;QACtBR,KAAKM;QACLI,MAAMJ,gBAAgBI;QACtBC,OAAOL,eAAeL,IAAI,CAACU,KAAK,IAAIL,eAAeL,IAAI;IACzD;IAEA,OAAOW,SAASV,IAAI,CAClB;QACEK;QACAM,SAASP,eAAeQ,CAAC,CAAC;IAC5B,GACA;QACEC,QAAQlB,WAAWmB,EAAE;IACvB;AAEJ,EAAC"}
@@ -92,4 +92,7 @@ export type VersionOperations = 'readVersions';
92
92
  export type AuthOperations = 'unlock';
93
93
  export type AllOperations = AuthOperations | Operation | VersionOperations;
94
94
  export declare function docHasTimestamps(doc: any): doc is TypeWithTimestamps;
95
+ export type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N;
96
+ export type IsAny<T> = IfAny<T, true, false>;
97
+ export type ReplaceAny<T, DefaultType> = IsAny<T> extends true ? DefaultType : T;
95
98
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,KAAK,UAAU,MAAM,YAAY,CAAA;AAGxC,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AACpF,OAAO,KAAK,OAAO,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AACpD,YAAY,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,aAAa,CAAA;AAErD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,CAAC,CAAC,EAAE,MAAM,CAAA;QACV,CAAC,CAAC,EAAE,MAAM,CAAA;KACX,CAAA;IACD,UAAU,CAAC,EAAE;QACX,CAAC,CAAC,EAAE,MAAM,CAAA;QACV,CAAC,CAAC,EAAE,MAAM,CAAA;KACX,CAAA;CACF,CAAA;AAED,MAAM,MAAM,oBAAoB,CAAC,CAAC,GAAG,OAAO,IAAI;IAC9C,OAAO,EAAE,cAAc,CAAA;IACvB,iCAAiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,mGAAmG;IACnG,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,IAAI,CAAC,EAAE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,GAAG,GAAG,CAAA;AAE1B,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAA;AAC/D,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAA;AAC9C,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAA;AACrC,MAAM,MAAM,aAAa,GAAG,cAAc,GAAG,SAAS,GAAG,iBAAiB,CAAA;AAE1E,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,kBAAkB,CAEpE;AAED,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AACpD,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;AAC5C,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,WAAW,IAAI,KAAK,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,CAAC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["import type { I18n, TFunction } from '@payloadcms/translations'\nimport type DataLoader from 'dataloader'\n\nimport type { User } from '../auth/types.js'\nimport type { TypeWithID, TypeWithTimestamps } from '../collections/config/types.js'\nimport type payload from '../index.js'\nimport type { GeneratedTypes } from '../index.js'\nimport type { validOperators } from './constants.js'\nexport type { Payload as Payload } from '../index.js'\n\nexport type UploadEdits = {\n crop?: {\n height?: number\n width?: number\n x?: number\n y?: number\n }\n focalPoint?: {\n x?: number\n y?: number\n }\n}\n\nexport type CustomPayloadRequest<U = unknown> = {\n context: RequestContext\n /** Data from the request body */\n data?: Record<string, unknown>\n /** The locale that should be used for a field when it is not translated to the requested locale */\n fallbackLocale?: string\n /**\n * The files that were uploaded during this request\n */\n file?: {\n data: Buffer\n mimetype: string\n name: string\n size: number\n tempFilePath?: string\n }\n i18n: I18n\n /**\n * The requested locale if specified\n * Only available for localized collections\n */\n locale?: GeneratedTypes['locale']\n /**\n * The payload object\n */\n payload: typeof payload\n /**\n * The context in which the request is being made\n */\n payloadAPI: 'GraphQL' | 'REST' | 'local'\n /** Optimized document loader */\n payloadDataLoader?: DataLoader<string, TypeWithID>\n /** Resized versions of the image that was uploaded during this request */\n payloadUploadSizes?: Record<string, Buffer>\n /** Query params on the request */\n query: Record<string, unknown>\n /** The route parameters\n * @example\n * /:collection/:id -> /posts/123\n * { collection: 'posts', id: '123' }\n */\n routeParams?: Record<string, unknown>\n /** Translate function - duplicate of i18n.t */\n t: TFunction\n /**\n * Identifier for the database transaction for interactions in a single, all-or-nothing operation.\n */\n transactionID?: number | string\n /**\n * Used to ensure consistency when multiple operations try to create a transaction concurrently on the same request\n */\n transactionIDPromise?: Promise<void>\n /** The signed in user */\n user: (U & GeneratedTypes['user']) | null\n} & Pick<\n URL,\n 'hash' | 'host' | 'href' | 'origin' | 'pathname' | 'port' | 'protocol' | 'search' | 'searchParams'\n>\nexport type PayloadRequest<U = unknown> = Partial<Request> &\n Required<Pick<Request, 'headers'>> &\n CustomPayloadRequest<U>\nexport interface RequestContext {\n [key: string]: unknown\n}\n\nexport type Operator = (typeof validOperators)[number]\n\nexport type WhereField = {\n [key in Operator]?: unknown\n}\n\nexport type Where = {\n [key: string]: Where[] | WhereField\n and?: Where[]\n or?: Where[]\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Document = any\n\nexport type Operation = 'create' | 'delete' | 'read' | 'update'\nexport type VersionOperations = 'readVersions'\nexport type AuthOperations = 'unlock'\nexport type AllOperations = AuthOperations | Operation | VersionOperations\n\nexport function docHasTimestamps(doc: any): doc is TypeWithTimestamps {\n return doc?.createdAt && doc?.updatedAt\n}\n"],"names":["docHasTimestamps","doc","createdAt","updatedAt"],"rangeMappings":";;","mappings":"AA4GA,OAAO,SAASA,iBAAiBC,GAAQ;IACvC,OAAOA,KAAKC,aAAaD,KAAKE;AAChC"}
1
+ {"version":3,"sources":["../../src/types/index.ts"],"sourcesContent":["import type { I18n, TFunction } from '@payloadcms/translations'\nimport type DataLoader from 'dataloader'\n\nimport type { User } from '../auth/types.js'\nimport type { TypeWithID, TypeWithTimestamps } from '../collections/config/types.js'\nimport type payload from '../index.js'\nimport type { GeneratedTypes } from '../index.js'\nimport type { validOperators } from './constants.js'\nexport type { Payload as Payload } from '../index.js'\n\nexport type UploadEdits = {\n crop?: {\n height?: number\n width?: number\n x?: number\n y?: number\n }\n focalPoint?: {\n x?: number\n y?: number\n }\n}\n\nexport type CustomPayloadRequest<U = unknown> = {\n context: RequestContext\n /** Data from the request body */\n data?: Record<string, unknown>\n /** The locale that should be used for a field when it is not translated to the requested locale */\n fallbackLocale?: string\n /**\n * The files that were uploaded during this request\n */\n file?: {\n data: Buffer\n mimetype: string\n name: string\n size: number\n tempFilePath?: string\n }\n i18n: I18n\n /**\n * The requested locale if specified\n * Only available for localized collections\n */\n locale?: GeneratedTypes['locale']\n /**\n * The payload object\n */\n payload: typeof payload\n /**\n * The context in which the request is being made\n */\n payloadAPI: 'GraphQL' | 'REST' | 'local'\n /** Optimized document loader */\n payloadDataLoader?: DataLoader<string, TypeWithID>\n /** Resized versions of the image that was uploaded during this request */\n payloadUploadSizes?: Record<string, Buffer>\n /** Query params on the request */\n query: Record<string, unknown>\n /** The route parameters\n * @example\n * /:collection/:id -> /posts/123\n * { collection: 'posts', id: '123' }\n */\n routeParams?: Record<string, unknown>\n /** Translate function - duplicate of i18n.t */\n t: TFunction\n /**\n * Identifier for the database transaction for interactions in a single, all-or-nothing operation.\n */\n transactionID?: number | string\n /**\n * Used to ensure consistency when multiple operations try to create a transaction concurrently on the same request\n */\n transactionIDPromise?: Promise<void>\n /** The signed in user */\n user: (U & GeneratedTypes['user']) | null\n} & Pick<\n URL,\n 'hash' | 'host' | 'href' | 'origin' | 'pathname' | 'port' | 'protocol' | 'search' | 'searchParams'\n>\nexport type PayloadRequest<U = unknown> = Partial<Request> &\n Required<Pick<Request, 'headers'>> &\n CustomPayloadRequest<U>\nexport interface RequestContext {\n [key: string]: unknown\n}\n\nexport type Operator = (typeof validOperators)[number]\n\nexport type WhereField = {\n [key in Operator]?: unknown\n}\n\nexport type Where = {\n [key: string]: Where[] | WhereField\n and?: Where[]\n or?: Where[]\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type Document = any\n\nexport type Operation = 'create' | 'delete' | 'read' | 'update'\nexport type VersionOperations = 'readVersions'\nexport type AuthOperations = 'unlock'\nexport type AllOperations = AuthOperations | Operation | VersionOperations\n\nexport function docHasTimestamps(doc: any): doc is TypeWithTimestamps {\n return doc?.createdAt && doc?.updatedAt\n}\n\nexport type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N // This is a commonly used trick to detect 'any'\nexport type IsAny<T> = IfAny<T, true, false>\nexport type ReplaceAny<T, DefaultType> = IsAny<T> extends true ? DefaultType : T\n"],"names":["docHasTimestamps","doc","createdAt","updatedAt"],"rangeMappings":";;","mappings":"AA4GA,OAAO,SAASA,iBAAiBC,GAAQ;IACvC,OAAOA,KAAKC,aAAaD,KAAKE;AAChC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload",
3
- "version": "3.0.0-beta.13",
3
+ "version": "3.0.0-beta.15",
4
4
  "description": "Node, React and MongoDB Headless CMS and Application Framework",
5
5
  "license": "MIT",
6
6
  "main": "./dist/index.js",
@@ -50,7 +50,7 @@
50
50
  "scheduler": "0.23.0",
51
51
  "scmp": "2.1.0",
52
52
  "uuid": "^9.0.1",
53
- "@payloadcms/translations": "3.0.0-beta.13"
53
+ "@payloadcms/translations": "3.0.0-beta.15"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "@swc/core": "^1.4.13",