payload 3.21.0 → 3.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/admin/forms/Form.d.ts +7 -0
  2. package/dist/admin/forms/Form.d.ts.map +1 -1
  3. package/dist/admin/forms/Form.js.map +1 -1
  4. package/dist/auth/strategies/local/generatePasswordSaltHash.d.ts.map +1 -1
  5. package/dist/auth/strategies/local/generatePasswordSaltHash.js +1 -0
  6. package/dist/auth/strategies/local/generatePasswordSaltHash.js.map +1 -1
  7. package/dist/config/types.d.ts +8 -0
  8. package/dist/config/types.d.ts.map +1 -1
  9. package/dist/config/types.js.map +1 -1
  10. package/dist/fields/config/types.d.ts +32 -3
  11. package/dist/fields/config/types.d.ts.map +1 -1
  12. package/dist/fields/config/types.js.map +1 -1
  13. package/dist/fields/hooks/afterChange/promise.d.ts +5 -1
  14. package/dist/fields/hooks/afterChange/promise.d.ts.map +1 -1
  15. package/dist/fields/hooks/afterChange/promise.js +8 -1
  16. package/dist/fields/hooks/afterChange/promise.js.map +1 -1
  17. package/dist/fields/hooks/afterChange/traverseFields.d.ts +5 -1
  18. package/dist/fields/hooks/afterChange/traverseFields.d.ts.map +1 -1
  19. package/dist/fields/hooks/afterChange/traverseFields.js +2 -1
  20. package/dist/fields/hooks/afterChange/traverseFields.js.map +1 -1
  21. package/dist/fields/hooks/afterRead/promise.d.ts +5 -1
  22. package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
  23. package/dist/fields/hooks/afterRead/promise.js +12 -1
  24. package/dist/fields/hooks/afterRead/promise.js.map +1 -1
  25. package/dist/fields/hooks/afterRead/traverseFields.d.ts +5 -1
  26. package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
  27. package/dist/fields/hooks/afterRead/traverseFields.js +2 -1
  28. package/dist/fields/hooks/afterRead/traverseFields.js.map +1 -1
  29. package/dist/fields/hooks/beforeChange/promise.d.ts +5 -1
  30. package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
  31. package/dist/fields/hooks/beforeChange/promise.js +13 -2
  32. package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
  33. package/dist/fields/hooks/beforeChange/traverseFields.d.ts +5 -1
  34. package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
  35. package/dist/fields/hooks/beforeChange/traverseFields.js +2 -1
  36. package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
  37. package/dist/fields/hooks/beforeDuplicate/promise.d.ts +5 -1
  38. package/dist/fields/hooks/beforeDuplicate/promise.d.ts.map +1 -1
  39. package/dist/fields/hooks/beforeDuplicate/promise.js +13 -1
  40. package/dist/fields/hooks/beforeDuplicate/promise.js.map +1 -1
  41. package/dist/fields/hooks/beforeDuplicate/traverseFields.d.ts +5 -1
  42. package/dist/fields/hooks/beforeDuplicate/traverseFields.d.ts.map +1 -1
  43. package/dist/fields/hooks/beforeDuplicate/traverseFields.js +2 -1
  44. package/dist/fields/hooks/beforeDuplicate/traverseFields.js.map +1 -1
  45. package/dist/fields/hooks/beforeValidate/promise.d.ts +5 -1
  46. package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
  47. package/dist/fields/hooks/beforeValidate/promise.js +9 -1
  48. package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
  49. package/dist/fields/hooks/beforeValidate/traverseFields.d.ts +5 -1
  50. package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
  51. package/dist/fields/hooks/beforeValidate/traverseFields.js +2 -1
  52. package/dist/fields/hooks/beforeValidate/traverseFields.js.map +1 -1
  53. package/dist/fields/validations.d.ts.map +1 -1
  54. package/dist/fields/validations.js +2 -1
  55. package/dist/fields/validations.js.map +1 -1
  56. package/dist/globals/operations/update.d.ts.map +1 -1
  57. package/dist/globals/operations/update.js +4 -0
  58. package/dist/globals/operations/update.js.map +1 -1
  59. package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
  60. package/dist/utilities/configToJSONSchema.js +3 -1
  61. package/dist/utilities/configToJSONSchema.js.map +1 -1
  62. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/fields/hooks/afterChange/promise.ts"],"sourcesContent":["import type { RichTextAdapter } from '../../../admin/RichText.js'\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { RequestContext } from '../../../index.js'\nimport type { JsonObject, PayloadRequest } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { MissingEditorProp } from '../../../errors/index.js'\nimport { fieldAffectsData, tabHasName } from '../../config/types.js'\nimport { getFieldPathsModified as getFieldPaths } from '../../getFieldPaths.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n data: JsonObject\n doc: JsonObject\n field: Field | TabAsField\n fieldIndex: number\n global: null | SanitizedGlobalConfig\n operation: 'create' | 'update'\n parentIndexPath: string\n parentPath: string\n parentSchemaPath: string\n previousDoc: JsonObject\n previousSiblingDoc: JsonObject\n req: PayloadRequest\n siblingData: JsonObject\n siblingDoc: JsonObject\n}\n\n// This function is responsible for the following actions, in order:\n// - Execute field hooks\n\nexport const promise = async ({\n collection,\n context,\n data,\n doc,\n field,\n fieldIndex,\n global,\n operation,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n previousDoc,\n previousSiblingDoc,\n req,\n siblingData,\n siblingDoc,\n}: Args): Promise<void> => {\n const { indexPath, path, schemaPath } = getFieldPaths({\n field,\n index: fieldIndex,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n })\n\n const pathSegments = path ? path.split('.') : []\n const schemaPathSegments = schemaPath ? schemaPath.split('.') : []\n const indexPathSegments = indexPath ? indexPath.split('-').filter(Boolean)?.map(Number) : []\n\n if (fieldAffectsData(field)) {\n // Execute hooks\n if (field.hooks?.afterChange) {\n await field.hooks.afterChange.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n field,\n global,\n indexPath: indexPathSegments,\n operation,\n originalDoc: doc,\n path: pathSegments,\n previousDoc,\n previousSiblingDoc,\n previousValue: previousDoc[field.name],\n req,\n schemaPath: schemaPathSegments,\n siblingData,\n value: siblingDoc[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n }\n\n // Traverse subfields\n switch (field.type) {\n case 'array': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row, rowIndex) => {\n promises.push(\n traverseFields({\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: '',\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: previousDoc?.[field.name]?.[rowIndex] || ({} as JsonObject),\n req,\n siblingData: siblingData?.[field.name]?.[rowIndex] || {},\n siblingDoc: row ? { ...row } : {},\n }),\n )\n })\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'blocks': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n\n rows.forEach((row, rowIndex) => {\n const block = field.blocks.find(\n (blockType) => blockType.slug === (row as JsonObject).blockType,\n )\n\n if (block) {\n promises.push(\n traverseFields({\n collection,\n context,\n data,\n doc,\n fields: block.fields,\n global,\n operation,\n parentIndexPath: '',\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath + '.' + block.slug,\n previousDoc,\n previousSiblingDoc: previousDoc?.[field.name]?.[rowIndex] || ({} as JsonObject),\n req,\n siblingData: siblingData?.[field.name]?.[rowIndex] || {},\n siblingDoc: row ? { ...row } : {},\n }),\n )\n }\n })\n\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'collapsible':\n case 'row': {\n await traverseFields({\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: indexPath,\n parentPath,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: { ...previousSiblingDoc },\n req,\n siblingData: siblingData || {},\n siblingDoc: { ...siblingDoc },\n })\n\n break\n }\n\n case 'group': {\n await traverseFields({\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: '',\n parentPath: path,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: previousDoc[field.name] as JsonObject,\n req,\n siblingData: (siblingData?.[field.name] as JsonObject) || {},\n siblingDoc: siblingDoc[field.name] as JsonObject,\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\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?.afterChange?.length) {\n await editor.hooks.afterChange.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n field,\n global,\n indexPath: indexPathSegments,\n operation,\n originalDoc: doc,\n path: pathSegments,\n previousDoc,\n previousSiblingDoc,\n previousValue: previousDoc[field.name],\n req,\n schemaPath: schemaPathSegments,\n siblingData,\n value: siblingDoc[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n break\n }\n\n case 'tab': {\n let tabSiblingData = siblingData\n let tabSiblingDoc = siblingDoc\n let tabPreviousSiblingDoc = siblingDoc\n\n const isNamedTab = tabHasName(field)\n\n if (isNamedTab) {\n tabSiblingData = (siblingData[field.name] as JsonObject) ?? {}\n tabSiblingDoc = (siblingDoc[field.name] as JsonObject) ?? {}\n tabPreviousSiblingDoc = (previousDoc[field.name] as JsonObject) ?? {}\n }\n\n await traverseFields({\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: isNamedTab ? '' : indexPath,\n parentPath: isNamedTab ? path : parentPath,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: tabPreviousSiblingDoc,\n req,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n collection,\n context,\n data,\n doc,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n operation,\n parentIndexPath: indexPath,\n parentPath: path,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: { ...previousSiblingDoc },\n req,\n siblingData: siblingData || {},\n siblingDoc: { ...siblingDoc },\n })\n\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","fieldAffectsData","tabHasName","getFieldPathsModified","getFieldPaths","traverseFields","promise","collection","context","data","doc","field","fieldIndex","global","operation","parentIndexPath","parentPath","parentSchemaPath","previousDoc","previousSiblingDoc","req","siblingData","siblingDoc","indexPath","path","schemaPath","index","pathSegments","split","schemaPathSegments","indexPathSegments","filter","Boolean","map","Number","hooks","afterChange","reduce","priorHook","currentHook","hookedValue","originalDoc","previousValue","name","value","undefined","Promise","resolve","type","rows","Array","isArray","promises","forEach","row","rowIndex","push","fields","all","block","blocks","find","blockType","slug","editor","Error","length","tabSiblingData","tabSiblingDoc","tabPreviousSiblingDoc","isNamedTab","tabs","tab"],"mappings":"AAOA,SAASA,iBAAiB,QAAQ,2BAA0B;AAC5D,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,wBAAuB;AACpE,SAASC,yBAAyBC,aAAa,QAAQ,yBAAwB;AAC/E,SAASC,cAAc,QAAQ,sBAAqB;AAqBpD,oEAAoE;AACpE,wBAAwB;AAExB,OAAO,MAAMC,UAAU,OAAO,EAC5BC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,KAAK,EACLC,UAAU,EACVC,MAAM,EACNC,SAAS,EACTC,eAAe,EACfC,UAAU,EACVC,gBAAgB,EAChBC,WAAW,EACXC,kBAAkB,E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AAaA,eAAe,CAAC;oBAC7BC,YAAY;wBAAE,GAAGA,UAAU;oBAAC;gBAC9B;gBAEA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/fields/hooks/afterChange/promise.ts"],"sourcesContent":["import type { RichTextAdapter } from '../../../admin/RichText.js'\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { RequestContext } from '../../../index.js'\nimport type { JsonObject, PayloadRequest } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { MissingEditorProp } from '../../../errors/index.js'\nimport { fieldAffectsData, tabHasName } from '../../config/types.js'\nimport { getFieldPathsModified as getFieldPaths } from '../../getFieldPaths.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n /**\n * Data of the nearest parent block. If no parent block exists, this will be the `undefined`\n */\n blockData?: JsonObject\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n data: JsonObject\n doc: JsonObject\n field: Field | TabAsField\n fieldIndex: number\n global: null | SanitizedGlobalConfig\n operation: 'create' | 'update'\n parentIndexPath: string\n parentPath: string\n parentSchemaPath: string\n previousDoc: JsonObject\n previousSiblingDoc: JsonObject\n req: PayloadRequest\n siblingData: JsonObject\n siblingDoc: JsonObject\n}\n\n// This function is responsible for the following actions, in order:\n// - Execute field hooks\n\nexport const promise = async ({\n blockData,\n collection,\n context,\n data,\n doc,\n field,\n fieldIndex,\n global,\n operation,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n previousDoc,\n previousSiblingDoc,\n req,\n siblingData,\n siblingDoc,\n}: Args): Promise<void> => {\n const { indexPath, path, schemaPath } = getFieldPaths({\n field,\n index: fieldIndex,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n })\n\n const pathSegments = path ? path.split('.') : []\n const schemaPathSegments = schemaPath ? schemaPath.split('.') : []\n const indexPathSegments = indexPath ? indexPath.split('-').filter(Boolean)?.map(Number) : []\n\n if (fieldAffectsData(field)) {\n // Execute hooks\n if (field.hooks?.afterChange) {\n await field.hooks.afterChange.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n blockData,\n collection,\n context,\n data,\n field,\n global,\n indexPath: indexPathSegments,\n operation,\n originalDoc: doc,\n path: pathSegments,\n previousDoc,\n previousSiblingDoc,\n previousValue: previousDoc[field.name],\n req,\n schemaPath: schemaPathSegments,\n siblingData,\n value: siblingDoc[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n }\n\n // Traverse subfields\n switch (field.type) {\n case 'array': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row, rowIndex) => {\n promises.push(\n traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: '',\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: previousDoc?.[field.name]?.[rowIndex] || ({} as JsonObject),\n req,\n siblingData: siblingData?.[field.name]?.[rowIndex] || {},\n siblingDoc: row ? { ...row } : {},\n }),\n )\n })\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'blocks': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n\n rows.forEach((row, rowIndex) => {\n const block = field.blocks.find(\n (blockType) => blockType.slug === (row as JsonObject).blockType,\n )\n\n if (block) {\n promises.push(\n traverseFields({\n blockData: siblingData?.[field.name]?.[rowIndex],\n collection,\n context,\n data,\n doc,\n fields: block.fields,\n global,\n operation,\n parentIndexPath: '',\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath + '.' + block.slug,\n previousDoc,\n previousSiblingDoc: previousDoc?.[field.name]?.[rowIndex] || ({} as JsonObject),\n req,\n siblingData: siblingData?.[field.name]?.[rowIndex] || {},\n siblingDoc: row ? { ...row } : {},\n }),\n )\n }\n })\n\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'collapsible':\n case 'row': {\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: indexPath,\n parentPath,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: { ...previousSiblingDoc },\n req,\n siblingData: siblingData || {},\n siblingDoc: { ...siblingDoc },\n })\n\n break\n }\n\n case 'group': {\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: '',\n parentPath: path,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: previousDoc[field.name] as JsonObject,\n req,\n siblingData: (siblingData?.[field.name] as JsonObject) || {},\n siblingDoc: siblingDoc[field.name] as JsonObject,\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\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?.afterChange?.length) {\n await editor.hooks.afterChange.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n field,\n global,\n indexPath: indexPathSegments,\n operation,\n originalDoc: doc,\n path: pathSegments,\n previousDoc,\n previousSiblingDoc,\n previousValue: previousDoc[field.name],\n req,\n schemaPath: schemaPathSegments,\n siblingData,\n value: siblingDoc[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n break\n }\n\n case 'tab': {\n let tabSiblingData = siblingData\n let tabSiblingDoc = siblingDoc\n let tabPreviousSiblingDoc = siblingDoc\n\n const isNamedTab = tabHasName(field)\n\n if (isNamedTab) {\n tabSiblingData = (siblingData[field.name] as JsonObject) ?? {}\n tabSiblingDoc = (siblingDoc[field.name] as JsonObject) ?? {}\n tabPreviousSiblingDoc = (previousDoc[field.name] as JsonObject) ?? {}\n }\n\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n parentIndexPath: isNamedTab ? '' : indexPath,\n parentPath: isNamedTab ? path : parentPath,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: tabPreviousSiblingDoc,\n req,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n blockData,\n collection,\n context,\n data,\n doc,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n operation,\n parentIndexPath: indexPath,\n parentPath: path,\n parentSchemaPath: schemaPath,\n previousDoc,\n previousSiblingDoc: { ...previousSiblingDoc },\n req,\n siblingData: siblingData || {},\n siblingDoc: { ...siblingDoc },\n })\n\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","fieldAffectsData","tabHasName","getFieldPathsModified","getFieldPaths","traverseFields","promise","blockData","collection","context","data","doc","field","fieldIndex","global","operation","parentIndexPath","parentPath","parentSchemaPath","previousDoc","previousSiblingDoc","req","siblingData","siblingDoc","indexPath","path","schemaPath","index","pathSegments","split","schemaPathSegments","indexPathSegments","filter","Boolean","map","Number","hooks","afterChange","reduce","priorHook","currentHook","hookedValue","originalDoc","previousValue","name","value","undefined","Promise","resolve","type","rows","Array","isArray","promises","forEach","row","rowIndex","push","fields","all","block","blocks","find","blockType","slug","editor","Error","length","tabSiblingData","tabSiblingDoc","tabPreviousSiblingDoc","isNamedTab","tabs","tab"],"mappings":"AAOA,SAASA,iBAAiB,QAAQ,2BAA0B;AAC5D,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,wBAAuB;AACpE,SAASC,yBAAyBC,aAAa,QAAQ,yBAAwB;AAC/E,SAASC,cAAc,QAAQ,sBAAqB;AAyBpD,oEAAoE;AACpE,wBAAwB;AAExB,OA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,MAAMhE,eAAe;oBACnBE;oBACAC;oBACAC;oBACAC;oBACAC;oBACA+C,QAAQ9C,MAAM4D,IAAI,CAACtC,GAAG,CAAC,CAACuC,MAAS,CAAA;4BAAE,GAAGA,GAAG;4BAAExB,MAAM;wBAAM,CAAA;oBACvDnC;oBACAC;oBACAC,iBAAiBQ;oBACjBP,YAAYQ;oBACZP,kBAAkBQ;oBAClBP;oBACAC,oBAAoB;wBAAE,GAAGA,kBAAkB;oBAAC;oBAC5CC;oBACAC,aAAaA,eAAe,CAAC;oBAC7BC,YAAY;wBAAE,GAAGA,UAAU;oBAAC;gBAC9B;gBAEA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
@@ -4,6 +4,10 @@ import type { RequestContext } from '../../../index.js';
4
4
  import type { JsonObject, PayloadRequest } from '../../../types/index.js';
5
5
  import type { Field, TabAsField } from '../../config/types.js';
6
6
  type Args = {
7
+ /**
8
+ * Data of the nearest parent block. If no parent block exists, this will be the `undefined`
9
+ */
10
+ blockData?: JsonObject;
7
11
  collection: null | SanitizedCollectionConfig;
8
12
  context: RequestContext;
9
13
  data: JsonObject;
@@ -20,6 +24,6 @@ type Args = {
20
24
  siblingData: JsonObject;
21
25
  siblingDoc: JsonObject;
22
26
  };
23
- export declare const traverseFields: ({ collection, context, data, doc, fields, global, operation, parentIndexPath, parentPath, parentSchemaPath, previousDoc, previousSiblingDoc, req, siblingData, siblingDoc, }: Args) => Promise<void>;
27
+ export declare const traverseFields: ({ blockData, collection, context, data, doc, fields, global, operation, parentIndexPath, parentPath, parentSchemaPath, previousDoc, previousSiblingDoc, req, siblingData, siblingDoc, }: Args) => Promise<void>;
24
28
  export {};
25
29
  //# sourceMappingURL=traverseFields.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterChange/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAs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,yBAAyB,CAAA;AACzE,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAI9D,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,SAAS,CAAC,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,IAAI,GAAG,yBAAyB,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,UAAU,CAAA;IAChB,GAAG,EAAE,UAAU,CAAA;IACf,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,MAAM,EAAE,IAAI,GAAG,qBAAqB,CAAA;IACpC,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,eAAe,EAAE,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;IACxB,WAAW,EAAE,UAAU,CAAA;IACvB,kBAAkB,EAAE,UAAU,CAAA;IAC9B,GAAG,EAAE,cAAc,CAAA;IACnB,WAAW,EAAE,UAAU,CAAA;IACvB,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,cAAc,4LAiBxB,IAAI,KAAG,OAAO,CAAC,IAAI,CA4BrB,CAAA"}
@@ -1,8 +1,9 @@
1
1
  import { promise } from './promise.js';
2
- export const traverseFields = async ({ collection, context, data, doc, fields, global, operation, parentIndexPath, parentPath, parentSchemaPath, previousDoc, previousSiblingDoc, req, siblingData, siblingDoc })=>{
2
+ export const traverseFields = async ({ blockData, collection, context, data, doc, fields, global, operation, parentIndexPath, parentPath, parentSchemaPath, previousDoc, previousSiblingDoc, req, siblingData, siblingDoc })=>{
3
3
  const promises = [];
4
4
  fields.forEach((field, fieldIndex)=>{
5
5
  promises.push(promise({
6
+ blockData,
6
7
  collection,
7
8
  context,
8
9
  data,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/fields/hooks/afterChange/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { RequestContext } from '../../../index.js'\nimport type { JsonObject, PayloadRequest } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args = {\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n data: JsonObject\n doc: JsonObject\n fields: (Field | TabAsField)[]\n global: null | SanitizedGlobalConfig\n operation: 'create' | 'update'\n parentIndexPath: string\n parentPath: string\n parentSchemaPath: string\n previousDoc: JsonObject\n previousSiblingDoc: JsonObject\n req: PayloadRequest\n siblingData: JsonObject\n siblingDoc: JsonObject\n}\n\nexport const traverseFields = async ({\n collection,\n context,\n data,\n doc,\n fields,\n global,\n operation,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n previousDoc,\n previousSiblingDoc,\n req,\n siblingData,\n siblingDoc,\n}: Args): Promise<void> => {\n const promises = []\n\n fields.forEach((field, fieldIndex) => {\n promises.push(\n promise({\n collection,\n context,\n data,\n doc,\n field,\n fieldIndex,\n global,\n operation,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n previousDoc,\n previousSiblingDoc,\n req,\n siblingData,\n siblingDoc,\n }),\n )\n })\n\n await Promise.all(promises)\n}\n"],"names":["promise","traverseFields","collection","context","data","doc","fields","global","operation","parentIndexPath","parentPath","parentSchemaPath","previousDoc","previousSiblingDoc","req","siblingData","siblingDoc","promises","forEach","field","fieldIndex","push","Promise","all"],"mappings":"AAMA,SAASA,OAAO,QAAQ,eAAc;AAoBtC,OAAO,MAAMC,iBAAiB,OAAO,EACnCC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,MAAM,EACNC,MAAM,EACNC,SAAS,EACTC,eAAe,EACfC,UAAU,EACVC,gBAAgB,EAChBC,WAAW,EACXC,kBAAkB,EAClBC,GAAG,EACHC,WAAW,EACXC,UAAU,EACL;IACL,MAAMC,WAAW,EAAE;IAEnBX,OAAOY,OAAO,CAAC,CAACC,OAAOC;QACrBH,SAASI,IAAI,CACXrB,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAc;YACAC;YACAb;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;IAEJ;IAEA,MAAMM,QAAQC,GAAG,CAACN;AACpB,EAAC"}
1
+ {"version":3,"sources":["../../../../src/fields/hooks/afterChange/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { RequestContext } from '../../../index.js'\nimport type { JsonObject, PayloadRequest } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args = {\n /**\n * Data of the nearest parent block. If no parent block exists, this will be the `undefined`\n */\n blockData?: JsonObject\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n data: JsonObject\n doc: JsonObject\n fields: (Field | TabAsField)[]\n global: null | SanitizedGlobalConfig\n operation: 'create' | 'update'\n parentIndexPath: string\n parentPath: string\n parentSchemaPath: string\n previousDoc: JsonObject\n previousSiblingDoc: JsonObject\n req: PayloadRequest\n siblingData: JsonObject\n siblingDoc: JsonObject\n}\n\nexport const traverseFields = async ({\n blockData,\n collection,\n context,\n data,\n doc,\n fields,\n global,\n operation,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n previousDoc,\n previousSiblingDoc,\n req,\n siblingData,\n siblingDoc,\n}: Args): Promise<void> => {\n const promises = []\n\n fields.forEach((field, fieldIndex) => {\n promises.push(\n promise({\n blockData,\n collection,\n context,\n data,\n doc,\n field,\n fieldIndex,\n global,\n operation,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n previousDoc,\n previousSiblingDoc,\n req,\n siblingData,\n siblingDoc,\n }),\n )\n })\n\n await Promise.all(promises)\n}\n"],"names":["promise","traverseFields","blockData","collection","context","data","doc","fields","global","operation","parentIndexPath","parentPath","parentSchemaPath","previousDoc","previousSiblingDoc","req","siblingData","siblingDoc","promises","forEach","field","fieldIndex","push","Promise","all"],"mappings":"AAMA,SAASA,OAAO,QAAQ,eAAc;AAwBtC,OAAO,MAAMC,iBAAiB,OAAO,EACnCC,SAAS,EACTC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,MAAM,EACNC,MAAM,EACNC,SAAS,EACTC,eAAe,EACfC,UAAU,EACVC,gBAAgB,EAChBC,WAAW,EACXC,kBAAkB,EAClBC,GAAG,EACHC,WAAW,EACXC,UAAU,EACL;IACL,MAAMC,WAAW,EAAE;IAEnBX,OAAOY,OAAO,CAAC,CAACC,OAAOC;QACrBH,SAASI,IAAI,CACXtB,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAC;YACAc;YACAC;YACAb;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;IAEJ;IAEA,MAAMM,QAAQC,GAAG,CAACN;AACpB,EAAC"}
@@ -4,6 +4,10 @@ import type { RequestContext } from '../../../index.js';
4
4
  import type { JsonObject, PayloadRequest, PopulateType, SelectMode, SelectType } from '../../../types/index.js';
5
5
  import type { Field, TabAsField } from '../../config/types.js';
6
6
  type Args = {
7
+ /**
8
+ * Data of the nearest parent block. If no parent block exists, this will be the `undefined`
9
+ */
10
+ blockData?: JsonObject;
7
11
  collection: null | SanitizedCollectionConfig;
8
12
  context: RequestContext;
9
13
  currentDepth: number;
@@ -35,6 +39,6 @@ type Args = {
35
39
  triggerAccessControl?: boolean;
36
40
  triggerHooks?: boolean;
37
41
  };
38
- export declare const promise: ({ collection, context, currentDepth, depth, doc, draft, fallbackLocale, field, fieldIndex, fieldPromises, findMany, flattenLocales, global, locale, overrideAccess, parentIndexPath, parentPath, parentSchemaPath, populate, populationPromises, req, select, selectMode, showHiddenFields, siblingDoc, triggerAccessControl, triggerHooks, }: Args) => Promise<void>;
42
+ export declare const promise: ({ blockData, collection, context, currentDepth, depth, doc, draft, fallbackLocale, field, fieldIndex, fieldPromises, findMany, flattenLocales, global, locale, overrideAccess, parentIndexPath, parentPath, parentSchemaPath, populate, populationPromises, req, select, selectMode, showHiddenFields, siblingDoc, triggerAccessControl, triggerHooks, }: Args) => Promise<void>;
39
43
  export {};
40
44
  //# sourceMappingURL=promise.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterRead/promise.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,YAAY,EACZ,UAAU,EACV,UAAU,EACX,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAS9D,KAAK,IAAI,GAAG;IACV,UAAU,EAAE,IAAI,GAAG,yBAAyB,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,UAAU,CAAA;IACf,KAAK,EAAE,OAAO,CAAA;IACd,cAAc,EAAE,IAAI,GAAG,MAAM,CAAA;IAC7B,KAAK,EAAE,KAAK,GAAG,UAAU,CAAA;IACzB,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IAC9B,QAAQ,EAAE,OAAO,CAAA;IACjB,cAAc,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,IAAI,GAAG,qBAAqB,CAAA;IACpC,MAAM,EAAE,IAAI,GAAG,MAAM,CAAA;IACrB,cAAc,EAAE,OAAO,CAAA;IACvB,eAAe,EAAE,M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A;IAC7B,KAAK,EAAE,KAAK,GAAG,UAAU,CAAA;IACzB,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IAC9B,QAAQ,EAAE,OAAO,CAAA;IACjB,cAAc,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,IAAI,GAAG,qBAAqB,CAAA;IACpC,MAAM,EAAE,IAAI,GAAG,MAAM,CAAA;IACrB,cAAc,EAAE,OAAO,CAAA;IACvB,eAAe,EAAE,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IACnC,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,gBAAgB,EAAE,OAAO,CAAA;IACzB,UAAU,EAAE,UAAU,CAAA;IACtB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAUD,eAAO,MAAM,OAAO,6VA6BjB,IAAI,KAAG,OAAO,CAAC,IAAI,CAkuBrB,CAAA"}
@@ -11,7 +11,7 @@ import { traverseFields } from './traverseFields.js';
11
11
  // - Execute field hooks
12
12
  // - Execute read access control
13
13
  // - Populate relationships
14
- export const promise = async ({ collection, context, currentDepth, depth, doc, draft, fallbackLocale, field, fieldIndex, fieldPromises, findMany, flattenLocales, global, locale, overrideAccess, parentIndexPath, parentPath, parentSchemaPath, populate, populationPromises, req, select, selectMode, showHiddenFields, siblingDoc, triggerAccessControl = true, triggerHooks = true })=>{
14
+ export const promise = async ({ blockData, collection, context, currentDepth, depth, doc, draft, fallbackLocale, field, fieldIndex, fieldPromises, findMany, flattenLocales, global, locale, overrideAccess, parentIndexPath, parentPath, parentSchemaPath, populate, populationPromises, req, select, selectMode, showHiddenFields, siblingDoc, triggerAccessControl = true, triggerHooks = true })=>{
15
15
  const { indexPath, path, schemaPath } = getFieldPaths({
16
16
  field,
17
17
  index: fieldIndex,
@@ -126,6 +126,7 @@ export const promise = async ({ collection, context, currentDepth, depth, doc, d
126
126
  if (shouldRunHookOnAllLocales) {
127
127
  const hookPromises = Object.entries(siblingDoc[field.name]).map(([locale, value])=>(async ()=>{
128
128
  const hookedValue = await currentHook({
129
+ blockData,
129
130
  collection,
130
131
  context,
131
132
  currentDepth,
@@ -153,6 +154,7 @@ export const promise = async ({ collection, context, currentDepth, depth, doc, d
153
154
  await Promise.all(hookPromises);
154
155
  } else {
155
156
  const hookedValue = await currentHook({
157
+ blockData,
156
158
  collection,
157
159
  context,
158
160
  currentDepth,
@@ -184,6 +186,7 @@ export const promise = async ({ collection, context, currentDepth, depth, doc, d
184
186
  if (triggerAccessControl && field.access && field.access.read) {
185
187
  const result = overrideAccess ? true : await field.access.read({
186
188
  id: doc.id,
189
+ blockData,
187
190
  data: doc,
188
191
  doc,
189
192
  req,
@@ -235,6 +238,7 @@ export const promise = async ({ collection, context, currentDepth, depth, doc, d
235
238
  if (Array.isArray(rows)) {
236
239
  rows.forEach((row, rowIndex)=>{
237
240
  traverseFields({
241
+ blockData,
238
242
  collection,
239
243
  context,
240
244
  currentDepth,
@@ -268,6 +272,7 @@ export const promise = async ({ collection, context, currentDepth, depth, doc, d
268
272
  if (Array.isArray(localeRows)) {
269
273
  localeRows.forEach((row, rowIndex)=>{
270
274
  traverseFields({
275
+ blockData,
271
276
  collection,
272
277
  context,
273
278
  currentDepth,
@@ -336,6 +341,7 @@ export const promise = async ({ collection, context, currentDepth, depth, doc, d
336
341
  const blockSelect = blocksSelect?.[block.slug];
337
342
  if (block) {
338
343
  traverseFields({
344
+ blockData: row,
339
345
  collection,
340
346
  context,
341
347
  currentDepth,
@@ -372,6 +378,7 @@ export const promise = async ({ collection, context, currentDepth, depth, doc, d
372
378
  const block = field.blocks.find((blockType)=>blockType.slug === row.blockType);
373
379
  if (block) {
374
380
  traverseFields({
381
+ blockData: row,
375
382
  collection,
376
383
  context,
377
384
  currentDepth,
@@ -410,6 +417,7 @@ export const promise = async ({ collection, context, currentDepth, depth, doc, d
410
417
  case 'row':
411
418
  {
412
419
  traverseFields({
420
+ blockData,
413
421
  collection,
414
422
  context,
415
423
  currentDepth,
@@ -447,6 +455,7 @@ export const promise = async ({ collection, context, currentDepth, depth, doc, d
447
455
  }
448
456
  const groupSelect = select?.[field.name];
449
457
  traverseFields({
458
+ blockData,
450
459
  collection,
451
460
  context,
452
461
  currentDepth,
@@ -581,6 +590,7 @@ export const promise = async ({ collection, context, currentDepth, depth, doc, d
581
590
  tabSelect = select;
582
591
  }
583
592
  traverseFields({
593
+ blockData,
584
594
  collection,
585
595
  context,
586
596
  currentDepth,
@@ -613,6 +623,7 @@ export const promise = async ({ collection, context, currentDepth, depth, doc, d
613
623
  case 'tabs':
614
624
  {
615
625
  traverseFields({
626
+ blockData,
616
627
  collection,
617
628
  context,
618
629
  currentDepth,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/fields/hooks/afterRead/promise.ts"],"sourcesContent":["import type { RichTextAdapter } from '../../../admin/RichText.js'\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { RequestContext } from '../../../index.js'\nimport type {\n JsonObject,\n PayloadRequest,\n PopulateType,\n SelectMode,\n SelectType,\n} from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { MissingEditorProp } from '../../../errors/index.js'\nimport { fieldAffectsData, tabHasName } from '../../config/types.js'\nimport { getDefaultValue } from '../../getDefaultValue.js'\nimport { getFieldPathsModified as getFieldPaths } from '../../getFieldPaths.js'\nimport { relationshipPopulationPromise } from './relationshipPopulationPromise.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n currentDepth: number\n depth: number\n doc: JsonObject\n draft: boolean\n fallbackLocale: null | string\n field: Field | TabAsField\n fieldIndex: number\n /**\n * fieldPromises are used for things like field hooks. They should be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n global: null | SanitizedGlobalConfig\n locale: null | string\n overrideAccess: boolean\n parentIndexPath: string\n parentPath: string\n parentSchemaPath: string\n populate?: PopulateType\n populationPromises: Promise<void>[]\n req: PayloadRequest\n select?: SelectType\n selectMode?: SelectMode\n showHiddenFields: boolean\n siblingDoc: JsonObject\n triggerAccessControl?: boolean\n triggerHooks?: boolean\n}\n\n// This function is responsible for the following actions, in order:\n// - Remove hidden fields from response\n// - Flatten locales into requested locale\n// - Sanitize outgoing data (point field, etc.)\n// - Execute field hooks\n// - Execute read access control\n// - Populate relationships\n\nexport const promise = async ({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n field,\n fieldIndex,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n populate,\n populationPromises,\n req,\n select,\n selectMode,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl = true,\n triggerHooks = true,\n}: Args): Promise<void> => {\n const { indexPath, path, schemaPath } = getFieldPaths({\n field,\n index: fieldIndex,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n })\n\n const pathSegments = path ? path.split('.') : []\n const schemaPathSegments = schemaPath ? schemaPath.split('.') : []\n const indexPathSegments = indexPath ? indexPath.split('-').filter(Boolean)?.map(Number) : []\n\n if (\n fieldAffectsData(field) &&\n field.hidden &&\n typeof siblingDoc[field.name] !== 'undefined' &&\n !showHiddenFields\n ) {\n delete siblingDoc[field.name]\n }\n\n // Strip unselected fields\n if (fieldAffectsData(field) && select && selectMode) {\n if (selectMode === 'include') {\n if (!select[field.name]) {\n delete siblingDoc[field.name]\n return\n }\n }\n\n if (selectMode === 'exclude') {\n if (select[field.name] === false) {\n delete siblingDoc[field.name]\n return\n }\n }\n }\n\n const shouldHoistLocalizedValue =\n flattenLocales &&\n fieldAffectsData(field) &&\n typeof siblingDoc[field.name] === 'object' &&\n siblingDoc[field.name] !== null &&\n field.localized &&\n locale !== 'all' &&\n req.payload.config.localization\n\n if (shouldHoistLocalizedValue) {\n // replace actual value with localized value before sanitizing\n // { [locale]: fields } -> fields\n const value = siblingDoc[field.name][locale]\n\n let hoistedValue = value\n\n if (fallbackLocale && fallbackLocale !== locale) {\n const fallbackValue = siblingDoc[field.name][fallbackLocale]\n const isNullOrUndefined = typeof value === 'undefined' || value === null\n\n if (fallbackValue) {\n switch (field.type) {\n case 'text':\n case 'textarea': {\n if (value === '' || isNullOrUndefined) {\n hoistedValue = fallbackValue\n }\n break\n }\n\n default: {\n if (isNullOrUndefined) {\n hoistedValue = fallbackValue\n }\n break\n }\n }\n }\n }\n\n siblingDoc[field.name] = hoistedValue\n }\n\n // Sanitize outgoing field value\n switch (field.type) {\n case 'group': {\n // Fill groups with empty objects so fields with hooks within groups can populate\n // themselves virtually as necessary\n if (typeof siblingDoc[field.name] === 'undefined') {\n siblingDoc[field.name] = {}\n }\n\n break\n }\n case 'point': {\n const pointDoc = siblingDoc[field.name] as Record<string, unknown>\n if (Array.isArray(pointDoc?.coordinates) && pointDoc.coordinates.length === 2) {\n siblingDoc[field.name] = pointDoc.coordinates\n } else {\n siblingDoc[field.name] = undefined\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 // Rich Text fields should use afterRead hooks to do population. The previous editor.populationPromises have been renamed to editor.graphQLPopulationPromises\n break\n }\n\n case 'tabs': {\n field.tabs.forEach((tab) => {\n if (\n tabHasName(tab) &&\n (typeof siblingDoc[tab.name] === 'undefined' || siblingDoc[tab.name] === null)\n ) {\n siblingDoc[tab.name] = {}\n }\n })\n\n break\n }\n\n default: {\n break\n }\n }\n\n if (fieldAffectsData(field)) {\n // Execute hooks\n if (triggerHooks && field.hooks?.afterRead) {\n await field.hooks.afterRead.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const shouldRunHookOnAllLocales =\n field.localized &&\n (locale === 'all' || !flattenLocales) &&\n typeof siblingDoc[field.name] === 'object'\n\n if (shouldRunHookOnAllLocales) {\n const hookPromises = Object.entries(siblingDoc[field.name]).map(([locale, value]) =>\n (async () => {\n const hookedValue = await currentHook({\n collection,\n context,\n currentDepth,\n data: doc,\n depth,\n draft,\n field,\n findMany,\n global,\n indexPath: indexPathSegments,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: pathSegments,\n req,\n schemaPath: schemaPathSegments,\n showHiddenFields,\n siblingData: siblingDoc,\n value,\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name][locale] = hookedValue\n }\n })(),\n )\n\n await Promise.all(hookPromises)\n } else {\n const hookedValue = await currentHook({\n collection,\n context,\n currentDepth,\n data: doc,\n depth,\n draft,\n field,\n findMany,\n global,\n indexPath: indexPathSegments,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: pathSegments,\n req,\n schemaPath: schemaPathSegments,\n showHiddenFields,\n siblingData: siblingDoc,\n value: siblingDoc[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }\n }, Promise.resolve())\n }\n\n // Execute access control\n let allowDefaultValue = true\n if (triggerAccessControl && field.access && field.access.read) {\n const result = overrideAccess\n ? true\n : await field.access.read({\n id: doc.id as number | string,\n data: doc,\n doc,\n req,\n siblingData: siblingDoc,\n })\n\n if (!result) {\n allowDefaultValue = false\n delete siblingDoc[field.name]\n }\n }\n\n // Set defaultValue on the field for globals being returned without being first created\n // or collection documents created prior to having a default\n if (\n allowDefaultValue &&\n typeof siblingDoc[field.name] === 'undefined' &&\n typeof field.defaultValue !== 'undefined'\n ) {\n siblingDoc[field.name] = await getDefaultValue({\n defaultValue: field.defaultValue,\n locale,\n req,\n user: req.user,\n value: siblingDoc[field.name],\n })\n }\n\n if (field.type === 'relationship' || field.type === 'upload' || field.type === 'join') {\n populationPromises.push(\n relationshipPopulationPromise({\n currentDepth,\n depth,\n draft,\n fallbackLocale,\n field,\n locale,\n overrideAccess,\n populate,\n req,\n showHiddenFields,\n siblingDoc,\n }),\n )\n }\n }\n\n switch (field.type) {\n case 'array': {\n const rows = siblingDoc[field.name] as JsonObject\n\n let arraySelect = select?.[field.name]\n\n if (selectMode === 'include' && typeof arraySelect === 'object') {\n arraySelect = {\n ...arraySelect,\n id: true,\n }\n }\n\n if (Array.isArray(rows)) {\n rows.forEach((row, rowIndex) => {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath: '',\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath,\n populate,\n populationPromises,\n req,\n select: typeof arraySelect === 'object' ? arraySelect : undefined,\n selectMode,\n showHiddenFields,\n siblingDoc: row || {},\n triggerAccessControl,\n triggerHooks,\n })\n })\n } else if (!shouldHoistLocalizedValue && typeof rows === 'object' && rows !== null) {\n Object.values(rows).forEach((localeRows) => {\n if (Array.isArray(localeRows)) {\n localeRows.forEach((row, rowIndex) => {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath: '',\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath,\n populate,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc: (row as JsonObject) || {},\n triggerAccessControl,\n triggerHooks,\n })\n })\n }\n })\n } else {\n siblingDoc[field.name] = []\n }\n break\n }\n\n case 'blocks': {\n const rows = siblingDoc[field.name]\n\n let blocksSelect = select?.[field.name]\n\n if (Array.isArray(rows)) {\n rows.forEach((row, rowIndex) => {\n const block = field.blocks.find(\n (blockType) => blockType.slug === (row as JsonObject).blockType,\n )\n\n let blockSelectMode = selectMode\n\n if (typeof blocksSelect === 'object') {\n blocksSelect = {\n ...blocksSelect,\n }\n\n // sanitize blocks: {cta: false} to blocks: {cta: {id: true, blockType: true}}\n if (selectMode === 'exclude' && blocksSelect[block.slug] === false) {\n blockSelectMode = 'include'\n blocksSelect[block.slug] = {\n id: true,\n blockType: true,\n }\n } else if (selectMode === 'include') {\n if (!blocksSelect[block.slug]) {\n blocksSelect[block.slug] = {}\n }\n\n if (typeof blocksSelect[block.slug] === 'object') {\n blocksSelect[block.slug] = {\n ...(blocksSelect[block.slug] as object),\n }\n\n blocksSelect[block.slug]['id'] = true\n blocksSelect[block.slug]['blockType'] = true\n }\n }\n }\n\n const blockSelect = blocksSelect?.[block.slug]\n\n if (block) {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: block.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath: '',\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath + '.' + block.slug,\n populate,\n populationPromises,\n req,\n select: typeof blockSelect === 'object' ? blockSelect : undefined,\n selectMode: blockSelectMode,\n showHiddenFields,\n siblingDoc: (row as JsonObject) || {},\n triggerAccessControl,\n triggerHooks,\n })\n }\n })\n } else if (!shouldHoistLocalizedValue && typeof rows === 'object' && rows !== null) {\n Object.values(rows).forEach((localeRows) => {\n if (Array.isArray(localeRows)) {\n localeRows.forEach((row, rowIndex) => {\n const block = field.blocks.find(\n (blockType) => blockType.slug === (row as JsonObject).blockType,\n )\n\n if (block) {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: block.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath: '',\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath + '.' + block.slug,\n populate,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc: (row as JsonObject) || {},\n triggerAccessControl,\n triggerHooks,\n })\n }\n })\n }\n })\n } else {\n siblingDoc[field.name] = []\n }\n\n break\n }\n\n case 'collapsible':\n case 'row': {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath: indexPath,\n parentPath,\n parentSchemaPath: schemaPath,\n populate,\n populationPromises,\n req,\n select,\n selectMode,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl,\n triggerHooks,\n })\n\n break\n }\n\n case 'group': {\n let groupDoc = siblingDoc[field.name] as JsonObject\n\n if (typeof siblingDoc[field.name] !== 'object') {\n groupDoc = {}\n }\n\n const groupSelect = select?.[field.name]\n\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath: '',\n parentPath: path,\n parentSchemaPath: schemaPath,\n populate,\n populationPromises,\n req,\n select: typeof groupSelect === 'object' ? groupSelect : undefined,\n selectMode,\n showHiddenFields,\n siblingDoc: groupDoc,\n triggerAccessControl,\n triggerHooks,\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\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?.afterRead?.length) {\n await editor.hooks.afterRead.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const shouldRunHookOnAllLocales =\n field.localized &&\n (locale === 'all' || !flattenLocales) &&\n typeof siblingDoc[field.name] === 'object'\n\n if (shouldRunHookOnAllLocales) {\n const hookPromises = Object.entries(siblingDoc[field.name]).map(([locale, value]) =>\n (async () => {\n const hookedValue = await currentHook({\n collection,\n context,\n currentDepth,\n data: doc,\n depth,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n indexPath: indexPathSegments,\n locale,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: pathSegments,\n populate,\n populationPromises,\n req,\n schemaPath: schemaPathSegments,\n showHiddenFields,\n siblingData: siblingDoc,\n triggerAccessControl,\n triggerHooks,\n value,\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name][locale] = hookedValue\n }\n })(),\n )\n\n await Promise.all(hookPromises)\n } else {\n const hookedValue = await currentHook({\n collection,\n context,\n currentDepth,\n data: doc,\n depth,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n indexPath: indexPathSegments,\n locale,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: pathSegments,\n populate,\n populationPromises,\n req,\n schemaPath: schemaPathSegments,\n showHiddenFields,\n siblingData: siblingDoc,\n triggerAccessControl,\n triggerHooks,\n value: siblingDoc[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }\n }, Promise.resolve())\n }\n break\n }\n\n case 'tab': {\n let tabDoc = siblingDoc\n let tabSelect: SelectType | undefined\n\n const isNamedTab = tabHasName(field)\n\n if (isNamedTab) {\n tabDoc = siblingDoc[field.name] as JsonObject\n\n if (typeof siblingDoc[field.name] !== 'object') {\n tabDoc = {}\n }\n\n if (typeof select?.[field.name] === 'object') {\n tabSelect = select?.[field.name] as SelectType\n }\n } else {\n tabSelect = select\n }\n\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath: isNamedTab ? '' : indexPath,\n parentPath: isNamedTab ? path : parentPath,\n parentSchemaPath: schemaPath,\n populate,\n populationPromises,\n req,\n select: tabSelect,\n selectMode,\n showHiddenFields,\n siblingDoc: tabDoc,\n triggerAccessControl,\n triggerHooks,\n })\n\n break\n }\n\n case 'tabs': {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath: indexPath,\n parentPath: path,\n parentSchemaPath: schemaPath,\n populate,\n populationPromises,\n req,\n select,\n selectMode,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl,\n triggerHooks,\n })\n\n break\n }\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","fieldAffectsData","tabHasName","getDefaultValue","getFieldPathsModified","getFieldPaths","relationshipPopulationPromise","traverseFields","promise","collection","context","currentDepth","depth","doc","draft","fallbackLocale","field","fieldIndex","fieldPromises","findMany","flattenLocales","global","locale","overrideAccess","parentIndexPath","parentPath","parentSchemaPath","populate","populationPromises","req","select","selectMode","showHiddenFields","siblingDoc","triggerAccessControl","triggerHooks","indexPath","path","schemaPath","index","pathSegments","split","schemaPathSegments","indexPathSegments","filter","Boolean","map","Number","hidden","name","shouldHoistLocalizedValue","localized","payload","config","localization","value","hoistedValue","fallbackValue","isNullOrUndefined","type","pointDoc","Array","isArray","coordinates","length","undefined","editor","Error","tabs","forEach","tab","hooks","afterRead","reduce","priorHook","currentHook","shouldRunHookOnAllLocales","hookPromises","Object","entries","hookedValue","data","operation","originalDoc","siblingData","Promise","all","resolve","allowDefaultValue","access","read","result","id","defaultValue","user","push","rows","arraySelect","row","rowIndex","fields","values","localeRows","blocksSelect","block","blocks","find","blockType","slug","blockSelectMode","blockSelect","groupDoc","groupSelect","tabDoc","tabSelect","isNamedTab"],"mappings":"AAaA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,MAAMoF,MAAM;oBACpBjF;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC,iBAAiB2F,aAAa,KAAK/E;oBACnCX,YAAY0F,aAAa9E,OAAOZ;oBAChCC,kBAAkBY;oBAClBX;oBACAC;oBACAC;oBACAC,QAAQoF;oBACRnF;oBACAC;oBACAC,YAAYgF;oBACZ/E;oBACAC;gBACF;gBAEA;YACF;QAEA,KAAK;YAAQ;gBACX5B,eAAe;oBACbE;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAG;oBACAkF,QAAQpF,MAAMoD,IAAI,CAACtB,GAAG,CAAC,CAACwB,MAAS,CAAA;4BAAE,GAAGA,GAAG;4BAAEX,MAAM;wBAAM,CAAA;oBACvDxC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC,iBAAiBY;oBACjBX,YAAYY;oBACZX,kBAAkBY;oBAClBX;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;gBACF;gBAEA;YACF;QACA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/fields/hooks/afterRead/promise.ts"],"sourcesContent":["import type { RichTextAdapter } from '../../../admin/RichText.js'\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { RequestContext } from '../../../index.js'\nimport type {\n JsonObject,\n PayloadRequest,\n PopulateType,\n SelectMode,\n SelectType,\n} from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { MissingEditorProp } from '../../../errors/index.js'\nimport { fieldAffectsData, tabHasName } from '../../config/types.js'\nimport { getDefaultValue } from '../../getDefaultValue.js'\nimport { getFieldPathsModified as getFieldPaths } from '../../getFieldPaths.js'\nimport { relationshipPopulationPromise } from './relationshipPopulationPromise.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n /**\n * Data of the nearest parent block. If no parent block exists, this will be the `undefined`\n */\n blockData?: JsonObject\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n currentDepth: number\n depth: number\n doc: JsonObject\n draft: boolean\n fallbackLocale: null | string\n field: Field | TabAsField\n fieldIndex: number\n /**\n * fieldPromises are used for things like field hooks. They should be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n global: null | SanitizedGlobalConfig\n locale: null | string\n overrideAccess: boolean\n parentIndexPath: string\n parentPath: string\n parentSchemaPath: string\n populate?: PopulateType\n populationPromises: Promise<void>[]\n req: PayloadRequest\n select?: SelectType\n selectMode?: SelectMode\n showHiddenFields: boolean\n siblingDoc: JsonObject\n triggerAccessControl?: boolean\n triggerHooks?: boolean\n}\n\n// This function is responsible for the following actions, in order:\n// - Remove hidden fields from response\n// - Flatten locales into requested locale\n// - Sanitize outgoing data (point field, etc.)\n// - Execute field hooks\n// - Execute read access control\n// - Populate relationships\n\nexport const promise = async ({\n blockData,\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n field,\n fieldIndex,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n populate,\n populationPromises,\n req,\n select,\n selectMode,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl = true,\n triggerHooks = true,\n}: Args): Promise<void> => {\n const { indexPath, path, schemaPath } = getFieldPaths({\n field,\n index: fieldIndex,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n })\n\n const pathSegments = path ? path.split('.') : []\n const schemaPathSegments = schemaPath ? schemaPath.split('.') : []\n const indexPathSegments = indexPath ? indexPath.split('-').filter(Boolean)?.map(Number) : []\n\n if (\n fieldAffectsData(field) &&\n field.hidden &&\n typeof siblingDoc[field.name] !== 'undefined' &&\n !showHiddenFields\n ) {\n delete siblingDoc[field.name]\n }\n\n // Strip unselected fields\n if (fieldAffectsData(field) && select && selectMode) {\n if (selectMode === 'include') {\n if (!select[field.name]) {\n delete siblingDoc[field.name]\n return\n }\n }\n\n if (selectMode === 'exclude') {\n if (select[field.name] === false) {\n delete siblingDoc[field.name]\n return\n }\n }\n }\n\n const shouldHoistLocalizedValue =\n flattenLocales &&\n fieldAffectsData(field) &&\n typeof siblingDoc[field.name] === 'object' &&\n siblingDoc[field.name] !== null &&\n field.localized &&\n locale !== 'all' &&\n req.payload.config.localization\n\n if (shouldHoistLocalizedValue) {\n // replace actual value with localized value before sanitizing\n // { [locale]: fields } -> fields\n const value = siblingDoc[field.name][locale]\n\n let hoistedValue = value\n\n if (fallbackLocale && fallbackLocale !== locale) {\n const fallbackValue = siblingDoc[field.name][fallbackLocale]\n const isNullOrUndefined = typeof value === 'undefined' || value === null\n\n if (fallbackValue) {\n switch (field.type) {\n case 'text':\n case 'textarea': {\n if (value === '' || isNullOrUndefined) {\n hoistedValue = fallbackValue\n }\n break\n }\n\n default: {\n if (isNullOrUndefined) {\n hoistedValue = fallbackValue\n }\n break\n }\n }\n }\n }\n\n siblingDoc[field.name] = hoistedValue\n }\n\n // Sanitize outgoing field value\n switch (field.type) {\n case 'group': {\n // Fill groups with empty objects so fields with hooks within groups can populate\n // themselves virtually as necessary\n if (typeof siblingDoc[field.name] === 'undefined') {\n siblingDoc[field.name] = {}\n }\n\n break\n }\n case 'point': {\n const pointDoc = siblingDoc[field.name] as Record<string, unknown>\n if (Array.isArray(pointDoc?.coordinates) && pointDoc.coordinates.length === 2) {\n siblingDoc[field.name] = pointDoc.coordinates\n } else {\n siblingDoc[field.name] = undefined\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 // Rich Text fields should use afterRead hooks to do population. The previous editor.populationPromises have been renamed to editor.graphQLPopulationPromises\n break\n }\n\n case 'tabs': {\n field.tabs.forEach((tab) => {\n if (\n tabHasName(tab) &&\n (typeof siblingDoc[tab.name] === 'undefined' || siblingDoc[tab.name] === null)\n ) {\n siblingDoc[tab.name] = {}\n }\n })\n\n break\n }\n\n default: {\n break\n }\n }\n\n if (fieldAffectsData(field)) {\n // Execute hooks\n if (triggerHooks && field.hooks?.afterRead) {\n await field.hooks.afterRead.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const shouldRunHookOnAllLocales =\n field.localized &&\n (locale === 'all' || !flattenLocales) &&\n typeof siblingDoc[field.name] === 'object'\n\n if (shouldRunHookOnAllLocales) {\n const hookPromises = Object.entries(siblingDoc[field.name]).map(([locale, value]) =>\n (async () => {\n const hookedValue = await currentHook({\n blockData,\n collection,\n context,\n currentDepth,\n data: doc,\n depth,\n draft,\n field,\n findMany,\n global,\n indexPath: indexPathSegments,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: pathSegments,\n req,\n schemaPath: schemaPathSegments,\n showHiddenFields,\n siblingData: siblingDoc,\n value,\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name][locale] = hookedValue\n }\n })(),\n )\n\n await Promise.all(hookPromises)\n } else {\n const hookedValue = await currentHook({\n blockData,\n collection,\n context,\n currentDepth,\n data: doc,\n depth,\n draft,\n field,\n findMany,\n global,\n indexPath: indexPathSegments,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: pathSegments,\n req,\n schemaPath: schemaPathSegments,\n showHiddenFields,\n siblingData: siblingDoc,\n value: siblingDoc[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }\n }, Promise.resolve())\n }\n\n // Execute access control\n let allowDefaultValue = true\n if (triggerAccessControl && field.access && field.access.read) {\n const result = overrideAccess\n ? true\n : await field.access.read({\n id: doc.id as number | string,\n blockData,\n data: doc,\n doc,\n req,\n siblingData: siblingDoc,\n })\n\n if (!result) {\n allowDefaultValue = false\n delete siblingDoc[field.name]\n }\n }\n\n // Set defaultValue on the field for globals being returned without being first created\n // or collection documents created prior to having a default\n if (\n allowDefaultValue &&\n typeof siblingDoc[field.name] === 'undefined' &&\n typeof field.defaultValue !== 'undefined'\n ) {\n siblingDoc[field.name] = await getDefaultValue({\n defaultValue: field.defaultValue,\n locale,\n req,\n user: req.user,\n value: siblingDoc[field.name],\n })\n }\n\n if (field.type === 'relationship' || field.type === 'upload' || field.type === 'join') {\n populationPromises.push(\n relationshipPopulationPromise({\n currentDepth,\n depth,\n draft,\n fallbackLocale,\n field,\n locale,\n overrideAccess,\n populate,\n req,\n showHiddenFields,\n siblingDoc,\n }),\n )\n }\n }\n\n switch (field.type) {\n case 'array': {\n const rows = siblingDoc[field.name] as JsonObject\n\n let arraySelect = select?.[field.name]\n\n if (selectMode === 'include' && typeof arraySelect === 'object') {\n arraySelect = {\n ...arraySelect,\n id: true,\n }\n }\n\n if (Array.isArray(rows)) {\n rows.forEach((row, rowIndex) => {\n traverseFields({\n blockData,\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath: '',\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath,\n populate,\n populationPromises,\n req,\n select: typeof arraySelect === 'object' ? arraySelect : undefined,\n selectMode,\n showHiddenFields,\n siblingDoc: row || {},\n triggerAccessControl,\n triggerHooks,\n })\n })\n } else if (!shouldHoistLocalizedValue && typeof rows === 'object' && rows !== null) {\n Object.values(rows).forEach((localeRows) => {\n if (Array.isArray(localeRows)) {\n localeRows.forEach((row, rowIndex) => {\n traverseFields({\n blockData,\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath: '',\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath,\n populate,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc: (row as JsonObject) || {},\n triggerAccessControl,\n triggerHooks,\n })\n })\n }\n })\n } else {\n siblingDoc[field.name] = []\n }\n break\n }\n\n case 'blocks': {\n const rows = siblingDoc[field.name]\n\n let blocksSelect = select?.[field.name]\n\n if (Array.isArray(rows)) {\n rows.forEach((row, rowIndex) => {\n const block = field.blocks.find(\n (blockType) => blockType.slug === (row as JsonObject).blockType,\n )\n\n let blockSelectMode = selectMode\n\n if (typeof blocksSelect === 'object') {\n blocksSelect = {\n ...blocksSelect,\n }\n\n // sanitize blocks: {cta: false} to blocks: {cta: {id: true, blockType: true}}\n if (selectMode === 'exclude' && blocksSelect[block.slug] === false) {\n blockSelectMode = 'include'\n blocksSelect[block.slug] = {\n id: true,\n blockType: true,\n }\n } else if (selectMode === 'include') {\n if (!blocksSelect[block.slug]) {\n blocksSelect[block.slug] = {}\n }\n\n if (typeof blocksSelect[block.slug] === 'object') {\n blocksSelect[block.slug] = {\n ...(blocksSelect[block.slug] as object),\n }\n\n blocksSelect[block.slug]['id'] = true\n blocksSelect[block.slug]['blockType'] = true\n }\n }\n }\n\n const blockSelect = blocksSelect?.[block.slug]\n\n if (block) {\n traverseFields({\n blockData: row,\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: block.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath: '',\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath + '.' + block.slug,\n populate,\n populationPromises,\n req,\n select: typeof blockSelect === 'object' ? blockSelect : undefined,\n selectMode: blockSelectMode,\n showHiddenFields,\n siblingDoc: (row as JsonObject) || {},\n triggerAccessControl,\n triggerHooks,\n })\n }\n })\n } else if (!shouldHoistLocalizedValue && typeof rows === 'object' && rows !== null) {\n Object.values(rows).forEach((localeRows) => {\n if (Array.isArray(localeRows)) {\n localeRows.forEach((row, rowIndex) => {\n const block = field.blocks.find(\n (blockType) => blockType.slug === (row as JsonObject).blockType,\n )\n\n if (block) {\n traverseFields({\n blockData: row,\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: block.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath: '',\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath + '.' + block.slug,\n populate,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc: (row as JsonObject) || {},\n triggerAccessControl,\n triggerHooks,\n })\n }\n })\n }\n })\n } else {\n siblingDoc[field.name] = []\n }\n\n break\n }\n\n case 'collapsible':\n case 'row': {\n traverseFields({\n blockData,\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath: indexPath,\n parentPath,\n parentSchemaPath: schemaPath,\n populate,\n populationPromises,\n req,\n select,\n selectMode,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl,\n triggerHooks,\n })\n\n break\n }\n\n case 'group': {\n let groupDoc = siblingDoc[field.name] as JsonObject\n\n if (typeof siblingDoc[field.name] !== 'object') {\n groupDoc = {}\n }\n\n const groupSelect = select?.[field.name]\n\n traverseFields({\n blockData,\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath: '',\n parentPath: path,\n parentSchemaPath: schemaPath,\n populate,\n populationPromises,\n req,\n select: typeof groupSelect === 'object' ? groupSelect : undefined,\n selectMode,\n showHiddenFields,\n siblingDoc: groupDoc,\n triggerAccessControl,\n triggerHooks,\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\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?.afterRead?.length) {\n await editor.hooks.afterRead.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const shouldRunHookOnAllLocales =\n field.localized &&\n (locale === 'all' || !flattenLocales) &&\n typeof siblingDoc[field.name] === 'object'\n\n if (shouldRunHookOnAllLocales) {\n const hookPromises = Object.entries(siblingDoc[field.name]).map(([locale, value]) =>\n (async () => {\n const hookedValue = await currentHook({\n collection,\n context,\n currentDepth,\n data: doc,\n depth,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n indexPath: indexPathSegments,\n locale,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: pathSegments,\n populate,\n populationPromises,\n req,\n schemaPath: schemaPathSegments,\n showHiddenFields,\n siblingData: siblingDoc,\n triggerAccessControl,\n triggerHooks,\n value,\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name][locale] = hookedValue\n }\n })(),\n )\n\n await Promise.all(hookPromises)\n } else {\n const hookedValue = await currentHook({\n collection,\n context,\n currentDepth,\n data: doc,\n depth,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n indexPath: indexPathSegments,\n locale,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: pathSegments,\n populate,\n populationPromises,\n req,\n schemaPath: schemaPathSegments,\n showHiddenFields,\n siblingData: siblingDoc,\n triggerAccessControl,\n triggerHooks,\n value: siblingDoc[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }\n }, Promise.resolve())\n }\n break\n }\n\n case 'tab': {\n let tabDoc = siblingDoc\n let tabSelect: SelectType | undefined\n\n const isNamedTab = tabHasName(field)\n\n if (isNamedTab) {\n tabDoc = siblingDoc[field.name] as JsonObject\n\n if (typeof siblingDoc[field.name] !== 'object') {\n tabDoc = {}\n }\n\n if (typeof select?.[field.name] === 'object') {\n tabSelect = select?.[field.name] as SelectType\n }\n } else {\n tabSelect = select\n }\n\n traverseFields({\n blockData,\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath: isNamedTab ? '' : indexPath,\n parentPath: isNamedTab ? path : parentPath,\n parentSchemaPath: schemaPath,\n populate,\n populationPromises,\n req,\n select: tabSelect,\n selectMode,\n showHiddenFields,\n siblingDoc: tabDoc,\n triggerAccessControl,\n triggerHooks,\n })\n\n break\n }\n\n case 'tabs': {\n traverseFields({\n blockData,\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath: indexPath,\n parentPath: path,\n parentSchemaPath: schemaPath,\n populate,\n populationPromises,\n req,\n select,\n selectMode,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl,\n triggerHooks,\n })\n\n break\n }\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","fieldAffectsData","tabHasName","getDefaultValue","getFieldPathsModified","getFieldPaths","relationshipPopulationPromise","traverseFields","promise","blockData","collection","context","currentDepth","depth","doc","draft","fallbackLocale","field","fieldIndex","fieldPromises","findMany","flattenLocales","global","locale","overrideAccess","parentIndexPath","parentPath","parentSchemaPath","populate","populationPromises","req","select","selectMode","showHiddenFields","siblingDoc","triggerAccessControl","triggerHooks","indexPath","path","schemaPath","index","pathSegments","split","schemaPathSegments","indexPathSegments","filter","Boolean","map","Number","hidden","name","shouldHoistLocalizedValue","localized","payload","config","localization","value","hoistedValue","fallbackValue","isNullOrUndefined","type","pointDoc","Array","isArray","coordinates","length","undefined","editor","Error","tabs","forEach","tab","hooks","afterRead","reduce","priorHook","currentHook","shouldRunHookOnAllLocales","hookPromises","Object","entries","hookedValue","data","operation","originalDoc","siblingData","Promise","all","resolve","allowDefaultValue","access","read","result","id","defaultValue","user","push","rows","arraySelect","row","rowIndex","fields","values","localeRows","blocksSelect","block","blocks","find","blockType","slug","blockSelectMode","blockSelect","groupDoc","groupSelect","tabDoc","tabSelect","isNamedTab"],"mappings":"AAaA,SAASA,iBAAiB,QAAQ,2BAA0B;AAC5D,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,wBAAuB;AACpE,SAASC,eAAe,QAAQ,2BAA0B;AAC1D,SAASC,yBAAyBC,aAAa,QAAQ,yBAAwB;AAC/E,SAASC,6BAA6B,QAAQ,qCAAoC;AAClF,SAASC,cAAc,QAAQ,sBAAqB;AAuCpD,oEAAoE;AACpE,uCAAuC;AACvC,0CAA0C;AAC1C,+CAA+C;AAC/C,wBAAwB;AACxB,gCAAgC;AAChC,2BAA2B;AAE3B,OAAO,MAAMC,UAAU,OAAO,EAC5BC,SAAS,EACTC,UAAU,EACVC,OAAO,EACPC,YAAY,EACZC,KAAK,EACLC,GAAG,EACHC,KAAK,EACLC,cAAc,EACdC,KAAK,EACLC,UAAU,EACVC,aAAa,EACbC,QAAQ,EACRC,cAAc,EACdC,MAAM,EACNC,MAAM,EACNC,cAAc,EACdC,eAAe,EACfC,UAAU,EACVC,gBAAgB,EAChBC,QAAQ,EACRC,kBAAkB,EAClBC,GAAG,EACHC,MAAM,EACNC,UAAU,EACVC,gBAAgB,EAChBC,UAAU,EACVC,uBAAuB,IAAI,EAC3BC,eAAe,IAAI,EACd;IACL,MAAM,EAAEC,SAAS,EAAEC,IAAI,EAAEC,UAAU,EAAE,GAAGlC,cAAc;QACpDY;QACAuB,OAAOtB;QACPO;QACAC;QACAC;IACF;IAEA,MAAMc,eAAeH,OAAOA,KAAKI,KAAK,CAAC,OAAO,EAAE;IAChD,MAAMC,qBAAqBJ,aAAaA,WAAWG,KAAK,CAAC,OAAO,EAAE;IAClE,MAAME,oBAAoBP,YAAYA,UAAUK,KAAK,CAAC,KAAKG,MAAM,CAACC,UAAUC,IAAIC,UAAU,EAAE;IAE5F,IACE/C,iBAAiBgB,UACjBA,MAAMgC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,MAAMiC,IAAI,CAAC,KAAK,UAAU;wBAC5CiE,YAAYpF,QAAQ,CAACd,MAAMiC,IAAI,CAAC;oBAClC;gBACF,OAAO;oBACLiE,YAAYpF;gBACd;gBAEAxB,eAAe;oBACbE;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAG;oBACAkF,QAAQpF,MAAMoF,MAAM;oBACpBjF;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC,iBAAiB2F,aAAa,KAAK/E;oBACnCX,YAAY0F,aAAa9E,OAAOZ;oBAChCC,kBAAkBY;oBAClBX;oBACAC;oBACAC;oBACAC,QAAQoF;oBACRnF;oBACAC;oBACAC,YAAYgF;oBACZ/E;oBACAC;gBACF;gBAEA;YACF;QAEA,KAAK;YAAQ;gBACX7B,eAAe;oBACbE;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAG;oBACAkF,QAAQpF,MAAMoD,IAAI,CAACtB,GAAG,CAAC,CAACwB,MAAS,CAAA;4BAAE,GAAGA,GAAG;4BAAEX,MAAM;wBAAM,CAAA;oBACvDxC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC,iBAAiBY;oBACjBX,YAAYY;oBACZX,kBAAkBY;oBAClBX;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;gBACF;gBAEA;YACF;QACA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
@@ -4,6 +4,10 @@ import type { RequestContext } from '../../../index.js';
4
4
  import type { JsonObject, PayloadRequest, PopulateType, SelectMode, SelectType } from '../../../types/index.js';
5
5
  import type { Field, TabAsField } from '../../config/types.js';
6
6
  type Args = {
7
+ /**
8
+ * Data of the nearest parent block. If no parent block exists, this will be the `undefined`
9
+ */
10
+ blockData?: JsonObject;
7
11
  collection: null | SanitizedCollectionConfig;
8
12
  context: RequestContext;
9
13
  currentDepth: number;
@@ -34,6 +38,6 @@ type Args = {
34
38
  triggerAccessControl?: boolean;
35
39
  triggerHooks?: boolean;
36
40
  };
37
- export declare const traverseFields: ({ collection, context, currentDepth, depth, doc, draft, fallbackLocale, fieldPromises, fields, findMany, flattenLocales, global, locale, overrideAccess, parentIndexPath, parentPath, parentSchemaPath, populate, populationPromises, req, select, selectMode, showHiddenFields, siblingDoc, triggerAccessControl, triggerHooks, }: Args) => void;
41
+ export declare const traverseFields: ({ blockData, collection, context, currentDepth, depth, doc, draft, fallbackLocale, fieldPromises, fields, findMany, flattenLocales, global, locale, overrideAccess, parentIndexPath, parentPath, parentSchemaPath, populate, populationPromises, req, select, selectMode, showHiddenFields, siblingDoc, triggerAccessControl, triggerHooks, }: Args) => void;
38
42
  export {};
39
43
  //# sourceMappingURL=traverseFields.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterRead/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,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,YAAY,EACZ,UAAU,EACV,UAAU,EACX,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAI9D,KAAK,IAAI,GAAG;IACV,UAAU,EAAE,IAAI,GAAG,yBAAyB,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,UAAU,CAAA;IACf,KAAK,EAAE,OAAO,CAAA;IACd,cAAc,EAAE,IAAI,GAAG,MAAM,CAAA;IAC7B;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IAC9B,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,QAAQ,EAAE,OAAO,CAAA;IACjB,cAAc,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,IAAI,GAAG,qBAAqB,CAAA;IACpC,MAAM,EAAE,IAAI,GAAG,MAAM,CAAA;IACrB,cAAc,EAAE,OAAO,CAAA;IACvB,eAAe,EAAE,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IACnC,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,gBAAgB,EAAE,OAAO,CAAA;IACzB,UAAU,EAAE,UAAU,CAAA;IACtB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,cAAc,uUA2BxB,IAAI,KAAG,IAkCT,CAAA"}
1
+ {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterRead/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,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EACV,UAAU,EACV,cAAc,EACd,YAAY,EACZ,UAAU,EACV,UAAU,EACX,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAI9D,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,SAAS,CAAC,EAAE,UAAU,CAAA;IACtB,UAAU,EAAE,IAAI,GAAG,yBAAyB,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,UAAU,CAAA;IACf,KAAK,EAAE,OAAO,CAAA;IACd,cAAc,EAAE,IAAI,GAAG,MAAM,CAAA;IAC7B;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IAC9B,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,QAAQ,EAAE,OAAO,CAAA;IACjB,cAAc,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,IAAI,GAAG,qBAAqB,CAAA;IACpC,MAAM,EAAE,IAAI,GAAG,MAAM,CAAA;IACrB,cAAc,EAAE,OAAO,CAAA;IACvB,eAAe,EAAE,MAAM,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IACnC,GAAG,EAAE,cAAc,CAAA;IACnB,MAAM,CAAC,EAAE,UAAU,CAAA;IACnB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,gBAAgB,EAAE,OAAO,CAAA;IACzB,UAAU,EAAE,UAAU,CAAA;IACtB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,cAAc,kVA4BxB,IAAI,KAAG,IAmCT,CAAA"}
@@ -1,7 +1,8 @@
1
1
  import { promise } from './promise.js';
2
- export const traverseFields = ({ collection, context, currentDepth, depth, doc, draft, fallbackLocale, fieldPromises, fields, findMany, flattenLocales, global, locale, overrideAccess, parentIndexPath, parentPath, parentSchemaPath, populate, populationPromises, req, select, selectMode, showHiddenFields, siblingDoc, triggerAccessControl = true, triggerHooks = true })=>{
2
+ export const traverseFields = ({ blockData, collection, context, currentDepth, depth, doc, draft, fallbackLocale, fieldPromises, fields, findMany, flattenLocales, global, locale, overrideAccess, parentIndexPath, parentPath, parentSchemaPath, populate, populationPromises, req, select, selectMode, showHiddenFields, siblingDoc, triggerAccessControl = true, triggerHooks = true })=>{
3
3
  fields.forEach((field, fieldIndex)=>{
4
4
  fieldPromises.push(promise({
5
+ blockData,
5
6
  collection,
6
7
  context,
7
8
  currentDepth,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/fields/hooks/afterRead/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { RequestContext } from '../../../index.js'\nimport type {\n JsonObject,\n PayloadRequest,\n PopulateType,\n SelectMode,\n SelectType,\n} from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args = {\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n currentDepth: number\n depth: number\n doc: JsonObject\n draft: boolean\n fallbackLocale: null | string\n /**\n * fieldPromises are used for things like field hooks. They should be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n fields: (Field | TabAsField)[]\n findMany: boolean\n flattenLocales: boolean\n global: null | SanitizedGlobalConfig\n locale: null | string\n overrideAccess: boolean\n parentIndexPath: string\n parentPath: string\n parentSchemaPath: string\n populate?: PopulateType\n populationPromises: Promise<void>[]\n req: PayloadRequest\n select?: SelectType\n selectMode?: SelectMode\n showHiddenFields: boolean\n siblingDoc: JsonObject\n triggerAccessControl?: boolean\n triggerHooks?: boolean\n}\n\nexport const traverseFields = ({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n populate,\n populationPromises,\n req,\n select,\n selectMode,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl = true,\n triggerHooks = true,\n}: Args): void => {\n fields.forEach((field, fieldIndex) => {\n fieldPromises.push(\n promise({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n field,\n fieldIndex,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n populate,\n populationPromises,\n req,\n select,\n selectMode,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl,\n triggerHooks,\n }),\n )\n })\n}\n"],"names":["promise","traverseFields","collection","context","currentDepth","depth","doc","draft","fallbackLocale","fieldPromises","fields","findMany","flattenLocales","global","locale","overrideAccess","parentIndexPath","parentPath","parentSchemaPath","populate","populationPromises","req","select","selectMode","showHiddenFields","siblingDoc","triggerAccessControl","triggerHooks","forEach","field","fieldIndex","push"],"mappings":"AAYA,SAASA,OAAO,QAAQ,eAAc;AAkCtC,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,UAAU,EACVC,OAAO,EACPC,YAAY,EACZC,KAAK,EACLC,GAAG,EACHC,KAAK,EACLC,cAAc,EACdC,aAAa,EACbC,MAAM,EACNC,QAAQ,EACRC,cAAc,EACdC,MAAM,EACNC,MAAM,EACNC,cAAc,EACdC,eAAe,EACfC,UAAU,EACVC,gBAAgB,EAChBC,QAAQ,EACRC,kBAAkB,EAClBC,GAAG,EACHC,MAAM,EACNC,UAAU,EACVC,gBAAgB,EAChBC,UAAU,EACVC,uBAAuB,IAAI,EAC3BC,eAAe,IAAI,EACd;IACLjB,OAAOkB,OAAO,CAAC,CAACC,OAAOC;QACrBrB,cAAcsB,IAAI,CAChB/B,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAqB;YACAC;YACArB;YACAE;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;IAEJ;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/fields/hooks/afterRead/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { RequestContext } from '../../../index.js'\nimport type {\n JsonObject,\n PayloadRequest,\n PopulateType,\n SelectMode,\n SelectType,\n} from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args = {\n /**\n * Data of the nearest parent block. If no parent block exists, this will be the `undefined`\n */\n blockData?: JsonObject\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n currentDepth: number\n depth: number\n doc: JsonObject\n draft: boolean\n fallbackLocale: null | string\n /**\n * fieldPromises are used for things like field hooks. They should be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n fields: (Field | TabAsField)[]\n findMany: boolean\n flattenLocales: boolean\n global: null | SanitizedGlobalConfig\n locale: null | string\n overrideAccess: boolean\n parentIndexPath: string\n parentPath: string\n parentSchemaPath: string\n populate?: PopulateType\n populationPromises: Promise<void>[]\n req: PayloadRequest\n select?: SelectType\n selectMode?: SelectMode\n showHiddenFields: boolean\n siblingDoc: JsonObject\n triggerAccessControl?: boolean\n triggerHooks?: boolean\n}\n\nexport const traverseFields = ({\n blockData,\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n populate,\n populationPromises,\n req,\n select,\n selectMode,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl = true,\n triggerHooks = true,\n}: Args): void => {\n fields.forEach((field, fieldIndex) => {\n fieldPromises.push(\n promise({\n blockData,\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n field,\n fieldIndex,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n populate,\n populationPromises,\n req,\n select,\n selectMode,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl,\n triggerHooks,\n }),\n )\n })\n}\n"],"names":["promise","traverseFields","blockData","collection","context","currentDepth","depth","doc","draft","fallbackLocale","fieldPromises","fields","findMany","flattenLocales","global","locale","overrideAccess","parentIndexPath","parentPath","parentSchemaPath","populate","populationPromises","req","select","selectMode","showHiddenFields","siblingDoc","triggerAccessControl","triggerHooks","forEach","field","fieldIndex","push"],"mappings":"AAYA,SAASA,OAAO,QAAQ,eAAc;AAsCtC,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,SAAS,EACTC,UAAU,EACVC,OAAO,EACPC,YAAY,EACZC,KAAK,EACLC,GAAG,EACHC,KAAK,EACLC,cAAc,EACdC,aAAa,EACbC,MAAM,EACNC,QAAQ,EACRC,cAAc,EACdC,MAAM,EACNC,MAAM,EACNC,cAAc,EACdC,eAAe,EACfC,UAAU,EACVC,gBAAgB,EAChBC,QAAQ,EACRC,kBAAkB,EAClBC,GAAG,EACHC,MAAM,EACNC,UAAU,EACVC,gBAAgB,EAChBC,UAAU,EACVC,uBAAuB,IAAI,EAC3BC,eAAe,IAAI,EACd;IACLjB,OAAOkB,OAAO,CAAC,CAACC,OAAOC;QACrBrB,cAAcsB,IAAI,CAChBhC,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAqB;YACAC;YACArB;YACAE;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;IAEJ;AACF,EAAC"}
@@ -5,6 +5,10 @@ import type { RequestContext } from '../../../index.js';
5
5
  import type { JsonObject, Operation, PayloadRequest } from '../../../types/index.js';
6
6
  import type { Field, TabAsField } from '../../config/types.js';
7
7
  type Args = {
8
+ /**
9
+ * Data of the nearest parent block. If no parent block exists, this will be the `undefined`
10
+ */
11
+ blockData?: JsonObject;
8
12
  collection: null | SanitizedCollectionConfig;
9
13
  context: RequestContext;
10
14
  data: JsonObject;
@@ -26,6 +30,6 @@ type Args = {
26
30
  siblingDocWithLocales?: JsonObject;
27
31
  skipValidation: boolean;
28
32
  };
29
- export declare const promise: ({ id, collection, context, data, doc, docWithLocales, errors, field, fieldIndex, global, mergeLocaleActions, operation, parentIndexPath, parentPath, parentSchemaPath, req, siblingData, siblingDoc, siblingDocWithLocales, skipValidation, }: Args) => Promise<void>;
33
+ export declare const promise: ({ id, blockData, collection, context, data, doc, docWithLocales, errors, field, fieldIndex, global, mergeLocaleActions, operation, parentIndexPath, parentPath, parentSchemaPath, req, siblingData, siblingDoc, siblingDocWithLocales, skipValidation, }: Args) => Promise<void>;
30
34
  export {};
31
35
  //# sourceMappingURL=promise.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeChange/promise.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACpF,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAW9D,KAAK,IAAI,GAAG;IACV,UAAU,EAAE,IAAI,GAAG,yBAAyB,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,UAAU,CAAA;IAChB,GAAG,EAAE,UAAU,CAAA;IACf,cAAc,EAAE,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