payload 3.0.0-beta.45 → 3.0.0-beta.46

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 (75) hide show
  1. package/dist/admin/RichText.d.ts +117 -17
  2. package/dist/admin/RichText.d.ts.map +1 -1
  3. package/dist/admin/RichText.js.map +1 -1
  4. package/dist/auth/operations/forgotPassword.d.ts.map +1 -1
  5. package/dist/auth/operations/forgotPassword.js +1 -2
  6. package/dist/auth/operations/forgotPassword.js.map +1 -1
  7. package/dist/auth/sendVerificationEmail.d.ts.map +1 -1
  8. package/dist/auth/sendVerificationEmail.js +1 -2
  9. package/dist/auth/sendVerificationEmail.js.map +1 -1
  10. package/dist/bin/generateTypes.d.ts.map +1 -1
  11. package/dist/bin/generateTypes.js +9 -0
  12. package/dist/bin/generateTypes.js.map +1 -1
  13. package/dist/collections/operations/create.d.ts.map +1 -1
  14. package/dist/collections/operations/create.js +1 -2
  15. package/dist/collections/operations/create.js.map +1 -1
  16. package/dist/fields/config/sanitize.d.ts.map +1 -1
  17. package/dist/fields/config/sanitize.js +0 -15
  18. package/dist/fields/config/sanitize.js.map +1 -1
  19. package/dist/fields/config/schema.js +1 -1
  20. package/dist/fields/config/schema.js.map +1 -1
  21. package/dist/fields/config/types.d.ts +14 -2
  22. package/dist/fields/config/types.d.ts.map +1 -1
  23. package/dist/fields/config/types.js.map +1 -1
  24. package/dist/fields/getFieldPaths.d.ts +10 -0
  25. package/dist/fields/getFieldPaths.d.ts.map +1 -0
  26. package/dist/fields/getFieldPaths.js +45 -0
  27. package/dist/fields/getFieldPaths.js.map +1 -0
  28. package/dist/fields/hooks/afterChange/index.d.ts +6 -0
  29. package/dist/fields/hooks/afterChange/index.d.ts.map +1 -1
  30. package/dist/fields/hooks/afterChange/index.js +2 -0
  31. package/dist/fields/hooks/afterChange/index.js.map +1 -1
  32. package/dist/fields/hooks/afterChange/promise.d.ts +9 -1
  33. package/dist/fields/hooks/afterChange/promise.d.ts.map +1 -1
  34. package/dist/fields/hooks/afterChange/promise.js +67 -3
  35. package/dist/fields/hooks/afterChange/promise.js.map +1 -1
  36. package/dist/fields/hooks/afterChange/traverseFields.d.ts +3 -1
  37. package/dist/fields/hooks/afterChange/traverseFields.d.ts.map +1 -1
  38. package/dist/fields/hooks/afterChange/traverseFields.js +3 -1
  39. package/dist/fields/hooks/afterChange/traverseFields.js.map +1 -1
  40. package/dist/fields/hooks/afterRead/index.d.ts +1 -1
  41. package/dist/fields/hooks/afterRead/index.d.ts.map +1 -1
  42. package/dist/fields/hooks/afterRead/index.js +3 -1
  43. package/dist/fields/hooks/afterRead/index.js.map +1 -1
  44. package/dist/fields/hooks/afterRead/promise.d.ts +9 -1
  45. package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
  46. package/dist/fields/hooks/afterRead/promise.js +129 -25
  47. package/dist/fields/hooks/afterRead/promise.js.map +1 -1
  48. package/dist/fields/hooks/afterRead/traverseFields.d.ts +3 -1
  49. package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
  50. package/dist/fields/hooks/afterRead/traverseFields.js +3 -1
  51. package/dist/fields/hooks/afterRead/traverseFields.js.map +1 -1
  52. package/dist/fields/hooks/beforeChange/index.d.ts +1 -1
  53. package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
  54. package/dist/fields/hooks/beforeChange/index.js +3 -2
  55. package/dist/fields/hooks/beforeChange/index.js.map +1 -1
  56. package/dist/fields/hooks/beforeChange/promise.d.ts +9 -2
  57. package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
  58. package/dist/fields/hooks/beforeChange/promise.js +77 -10
  59. package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
  60. package/dist/fields/hooks/beforeChange/traverseFields.d.ts +4 -3
  61. package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
  62. package/dist/fields/hooks/beforeChange/traverseFields.js +4 -3
  63. package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
  64. package/dist/fields/hooks/beforeValidate/index.d.ts.map +1 -1
  65. package/dist/fields/hooks/beforeValidate/index.js +2 -0
  66. package/dist/fields/hooks/beforeValidate/index.js.map +1 -1
  67. package/dist/fields/hooks/beforeValidate/promise.d.ts +3 -1
  68. package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
  69. package/dist/fields/hooks/beforeValidate/promise.js +69 -4
  70. package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
  71. package/dist/fields/hooks/beforeValidate/traverseFields.d.ts +3 -1
  72. package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
  73. package/dist/fields/hooks/beforeValidate/traverseFields.js +3 -1
  74. package/dist/fields/hooks/beforeValidate/traverseFields.js.map +1 -1
  75. 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 { PayloadRequestWithData, 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: PayloadRequestWithData\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,cAA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4BAAE,GAAGA,GAAG;4BAAE3D,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 { RichTextAdapter } from '../../../admin/RichText.js'\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequestWithData, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { MissingEditorProp } from '../../../errors/index.js'\nimport { fieldAffectsData, tabHasName, valueIsValueWithRelation } from '../../config/types.js'\nimport getValueWithDefault from '../../getDefaultValue.js'\nimport { getFieldPaths } from '../../getFieldPaths.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 parentPath: (number | string)[]\n parentSchemaPath: string[]\n req: PayloadRequestWithData\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 parentPath,\n parentSchemaPath,\n req,\n siblingData,\n siblingDoc,\n}: Args<T>): Promise<void> => {\n const { path: fieldPath, schemaPath: fieldSchemaPath } = getFieldPaths({\n field,\n parentPath,\n parentSchemaPath,\n })\n\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 path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingData[field.name],\n req,\n schemaPath: fieldSchemaPath,\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 path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\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, i) => {\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 path: [...fieldPath, i],\n req,\n schemaPath: fieldSchemaPath,\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, i) => {\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 path: [...fieldPath, i],\n req,\n schemaPath: fieldSchemaPath,\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 path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\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 path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\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 path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n siblingDoc,\n })\n\n break\n }\n\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n if (typeof field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n const editor: RichTextAdapter = field?.editor\n\n if (editor?.hooks?.beforeValidate?.length) {\n await editor.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 path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingData[field.name],\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","fieldAffectsData","tabHasName","valueIsValueWithRelation","getValueWithDefault","getFieldPaths","cloneDataFromOriginalDoc","getExistingRowDoc","traverseFields","promise","id","collection","context","data","doc","field","global","operation","overrideAccess","parentPath","parentSchemaPath","req","siblingData","siblingDoc","path","fieldPath","schemaPath","fieldSchemaPath","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","previousValue","undefined","Promise","resolve","access","result","defaultValue","locale","user","groupData","groupDoc","rows","promises","row","push","all","rowSiblingDoc","blockTypeToMatch","blockType","block","blocks","tabSiblingData","tabSiblingDoc","tabs","tab","editor","Error"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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C;oBACAyC,QAAQxC,MAAMyE,IAAI,CAAClD,GAAG,CAAC,CAACmD,MAAS,CAAA;4BAAE,GAAGA,GAAG;4BAAE5D,MAAM;wBAAM,CAAA;oBACvDb;oBACAC;oBACAC;oBACAM,MAAMC;oBACNJ;oBACAK,YAAYC;oBACZL;oBACAC;gBACF;gBAEA;YACF;QAEA,KAAK;YAAY;gBACf,IAAI,CAACR,OAAO2E,QAAQ;oBAClB,MAAM,IAAI1F,kBAAkBe,OAAO,8HAA8H;;gBACnK;gBACA,IAAI,OAAOA,OAAO2E,WAAW,YAAY;oBACvC,MAAM,IAAIC,MAAM;gBAClB;gBAEA,MAAMD,SAA0B3E,OAAO2E;gBAEvC,IAAIA,QAAQjC,OAAOC,gBAAgBvB,QAAQ;oBACzC,MAAMuD,OAAOjC,KAAK,CAACC,cAAc,CAACC,MAAM,CAAC,OAAOC,WAAWC;wBACzD,MAAMD;wBAEN,MAAME,cAAc,MAAMD,YAAY;4BACpClD;4BACAC;4BACAC;4BACAE;4BACAC;4BACAC;4BACA8C,aAAajD;4BACbI;4BACAM,MAAMC;4BACNuC,oBAAoBzC;4BACpB0C,eAAe3C,WAAW,CAACP,MAAMa,IAAI,CAAC;4BACtCP;4BACAK,YAAYC;4BACZL;4BACAQ,OAAOR,WAAW,CAACP,MAAMa,IAAI,CAAC;wBAChC;wBAEA,IAAIkC,gBAAgBI,WAAW;4BAC7B5C,WAAW,CAACP,MAAMa,IAAI,CAAC,GAAGkC;wBAC5B;oBACF,GAAGK,QAAQC,OAAO;gBACpB;gBACA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
@@ -15,13 +15,15 @@ type Args<T> = {
15
15
  id?: number | string;
16
16
  operation: 'create' | 'update';
17
17
  overrideAccess: boolean;
18
+ path: (number | string)[];
18
19
  req: PayloadRequestWithData;
20
+ schemaPath: string[];
19
21
  siblingData: Record<string, unknown>;
20
22
  /**
21
23
  * The original siblingData (not modified by any hooks)
22
24
  */
23
25
  siblingDoc: Record<string, unknown>;
24
26
  };
25
- export declare const traverseFields: <T>({ id, collection, context, data, doc, fields, global, operation, overrideAccess, req, siblingData, siblingDoc, }: Args<T>) => Promise<void>;
27
+ export declare const traverseFields: <T>({ id, collection, context, data, doc, fields, global, operation, overrideAccess, path, req, schemaPath, siblingData, siblingDoc, }: Args<T>) => Promise<void>;
26
28
  export {};
27
29
  //# sourceMappingURL=traverseFields.d.ts.map
@@ -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,sBAAsB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACrF,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,sBAAsB,CAAA;IAC3B,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
+ {"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,sBAAsB,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACrF,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,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IACzB,GAAG,EAAE,sBAAsB,CAAA;IAC3B,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,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,0IAexB,KAAK,CAAC,CAAC,KAAG,QAAQ,IAAI,CAuBxB,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { promise } from './promise.js';
2
- export const traverseFields = async ({ id, collection, context, data, doc, fields, global, operation, overrideAccess, req, siblingData, siblingDoc })=>{
2
+ export const traverseFields = async ({ id, collection, context, data, doc, fields, global, operation, overrideAccess, path, req, schemaPath, siblingData, siblingDoc })=>{
3
3
  const promises = [];
4
4
  fields.forEach((field)=>{
5
5
  promises.push(promise({
@@ -12,6 +12,8 @@ export const traverseFields = async ({ id, collection, context, data, doc, field
12
12
  global,
13
13
  operation,
14
14
  overrideAccess,
15
+ parentPath: path,
16
+ parentSchemaPath: schemaPath,
15
17
  req,
16
18
  siblingData,
17
19
  siblingDoc
@@ -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 { PayloadRequestWithData, 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: PayloadRequestWithData\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
+ {"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 { PayloadRequestWithData, 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 path: (number | string)[]\n req: PayloadRequestWithData\n schemaPath: string[]\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 path,\n req,\n schemaPath,\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 parentPath: path,\n parentSchemaPath: schemaPath,\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","path","req","schemaPath","siblingData","siblingDoc","promises","forEach","field","push","parentPath","parentSchemaPath","Promise","all"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,OAAO,QAAQ,eAAc;AAyBtC,OAAO,MAAMC,iBAAiB,OAAU,EACtCC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,MAAM,EACNC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,IAAI,EACJC,GAAG,EACHC,UAAU,EACVC,WAAW,EACXC,UAAU,EACF;IACR,MAAMC,WAAW,EAAE;IACnBT,OAAOU,OAAO,CAAC,CAACC;QACdF,SAASG,IAAI,CACXnB,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAC;YACAY;YACAV;YACAC;YACAC;YACAU,YAAYT;YACZU,kBAAkBR;YAClBD;YACAE;YACAC;QACF;IAEJ;IACA,MAAMO,QAAQC,GAAG,CAACP;AACpB,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload",
3
- "version": "3.0.0-beta.45",
3
+ "version": "3.0.0-beta.46",
4
4
  "description": "Node, React, Headless CMS and Application Framework built on Next.js",
5
5
  "keywords": [
6
6
  "admin panel",
@@ -94,7 +94,7 @@
94
94
  "scmp": "2.1.0",
95
95
  "ts-essentials": "7.0.3",
96
96
  "uuid": "^9.0.1",
97
- "@payloadcms/translations": "3.0.0-beta.45"
97
+ "@payloadcms/translations": "3.0.0-beta.46"
98
98
  },
99
99
  "devDependencies": {
100
100
  "@monaco-editor/react": "4.5.1",