payload 3.0.0-beta.67 → 3.0.0-beta.68

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 (223) hide show
  1. package/dist/admin/RichText.d.ts +4 -4
  2. package/dist/admin/RichText.d.ts.map +1 -1
  3. package/dist/admin/RichText.js.map +1 -1
  4. package/dist/auth/operations/resetPassword.js +1 -1
  5. package/dist/auth/operations/resetPassword.js.map +1 -1
  6. package/dist/auth/strategies/jwt.d.ts.map +1 -1
  7. package/dist/auth/strategies/jwt.js +29 -0
  8. package/dist/auth/strategies/jwt.js.map +1 -1
  9. package/dist/auth/strategies/local/incrementLoginAttempts.d.ts.map +1 -1
  10. package/dist/auth/strategies/local/incrementLoginAttempts.js +1 -1
  11. package/dist/auth/strategies/local/incrementLoginAttempts.js.map +1 -1
  12. package/dist/auth/strategies/local/register.d.ts +2 -2
  13. package/dist/auth/strategies/local/register.d.ts.map +1 -1
  14. package/dist/auth/strategies/local/register.js.map +1 -1
  15. package/dist/bin/generateTypes.js +2 -2
  16. package/dist/bin/generateTypes.js.map +1 -1
  17. package/dist/collections/config/client.d.ts.map +1 -1
  18. package/dist/collections/config/defaults.d.ts +4 -69
  19. package/dist/collections/config/defaults.d.ts.map +1 -1
  20. package/dist/collections/config/defaults.js.map +1 -1
  21. package/dist/collections/config/reservedFieldNames.d.ts +15 -0
  22. package/dist/collections/config/reservedFieldNames.d.ts.map +1 -0
  23. package/dist/collections/config/reservedFieldNames.js +104 -0
  24. package/dist/collections/config/reservedFieldNames.js.map +1 -0
  25. package/dist/collections/config/reservedFieldNames.spec.js +148 -0
  26. package/dist/collections/config/reservedFieldNames.spec.js.map +1 -0
  27. package/dist/collections/config/sanitize.d.ts.map +1 -1
  28. package/dist/collections/config/sanitize.js +13 -9
  29. package/dist/collections/config/sanitize.js.map +1 -1
  30. package/dist/collections/config/types.d.ts +2 -2
  31. package/dist/collections/config/types.d.ts.map +1 -1
  32. package/dist/collections/config/types.js.map +1 -1
  33. package/dist/collections/dataloader.d.ts.map +1 -1
  34. package/dist/collections/dataloader.js.map +1 -1
  35. package/dist/collections/operations/create.d.ts.map +1 -1
  36. package/dist/collections/operations/create.js.map +1 -1
  37. package/dist/collections/operations/deleteByID.d.ts.map +1 -1
  38. package/dist/collections/operations/deleteByID.js.map +1 -1
  39. package/dist/collections/operations/duplicate.js.map +1 -1
  40. package/dist/collections/operations/update.js.map +1 -1
  41. package/dist/collections/operations/updateByID.js.map +1 -1
  42. package/dist/config/client.d.ts.map +1 -1
  43. package/dist/config/client.js +26 -26
  44. package/dist/config/client.js.map +1 -1
  45. package/dist/config/sanitize.d.ts.map +1 -1
  46. package/dist/config/sanitize.js +4 -7
  47. package/dist/config/sanitize.js.map +1 -1
  48. package/dist/config/types.d.ts +3 -4
  49. package/dist/config/types.d.ts.map +1 -1
  50. package/dist/config/types.js.map +1 -1
  51. package/dist/errors/APIError.d.ts +1 -0
  52. package/dist/errors/APIError.d.ts.map +1 -1
  53. package/dist/errors/APIError.js +3 -0
  54. package/dist/errors/APIError.js.map +1 -1
  55. package/dist/errors/ValidationError.d.ts +1 -0
  56. package/dist/errors/ValidationError.d.ts.map +1 -1
  57. package/dist/errors/ValidationError.js +3 -0
  58. package/dist/errors/ValidationError.js.map +1 -1
  59. package/dist/errors/index.d.ts +2 -2
  60. package/dist/errors/index.d.ts.map +1 -1
  61. package/dist/errors/index.js +2 -2
  62. package/dist/errors/index.js.map +1 -1
  63. package/dist/exports/shared.d.ts +3 -2
  64. package/dist/exports/shared.d.ts.map +1 -1
  65. package/dist/exports/shared.js +3 -2
  66. package/dist/exports/shared.js.map +1 -1
  67. package/dist/fields/config/sanitize.d.ts +3 -2
  68. package/dist/fields/config/sanitize.d.ts.map +1 -1
  69. package/dist/fields/config/sanitize.js +8 -16
  70. package/dist/fields/config/sanitize.js.map +1 -1
  71. package/dist/fields/config/sanitize.spec.js +1 -17
  72. package/dist/fields/config/sanitize.spec.js.map +1 -1
  73. package/dist/fields/getDefaultValue.d.ts +5 -5
  74. package/dist/fields/getDefaultValue.d.ts.map +1 -1
  75. package/dist/fields/getDefaultValue.js +4 -6
  76. package/dist/fields/getDefaultValue.js.map +1 -1
  77. package/dist/fields/hooks/afterChange/index.d.ts +6 -6
  78. package/dist/fields/hooks/afterChange/index.d.ts.map +1 -1
  79. package/dist/fields/hooks/afterChange/index.js +2 -2
  80. package/dist/fields/hooks/afterChange/index.js.map +1 -1
  81. package/dist/fields/hooks/afterChange/promise.d.ts +7 -7
  82. package/dist/fields/hooks/afterChange/promise.d.ts.map +1 -1
  83. package/dist/fields/hooks/afterChange/promise.js.map +1 -1
  84. package/dist/fields/hooks/afterChange/traverseFields.d.ts +7 -7
  85. package/dist/fields/hooks/afterChange/traverseFields.d.ts.map +1 -1
  86. package/dist/fields/hooks/afterChange/traverseFields.js.map +1 -1
  87. package/dist/fields/hooks/afterRead/index.d.ts +4 -4
  88. package/dist/fields/hooks/afterRead/index.d.ts.map +1 -1
  89. package/dist/fields/hooks/afterRead/index.js +2 -2
  90. package/dist/fields/hooks/afterRead/index.js.map +1 -1
  91. package/dist/fields/hooks/afterRead/promise.d.ts +3 -3
  92. package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
  93. package/dist/fields/hooks/afterRead/promise.js +2 -2
  94. package/dist/fields/hooks/afterRead/promise.js.map +1 -1
  95. package/dist/fields/hooks/afterRead/traverseFields.d.ts +3 -3
  96. package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
  97. package/dist/fields/hooks/afterRead/traverseFields.js.map +1 -1
  98. package/dist/fields/hooks/beforeChange/cloneDataFromOriginalDoc.d.ts +2 -1
  99. package/dist/fields/hooks/beforeChange/cloneDataFromOriginalDoc.d.ts.map +1 -1
  100. package/dist/fields/hooks/beforeChange/cloneDataFromOriginalDoc.js.map +1 -1
  101. package/dist/fields/hooks/beforeChange/getExistingRowDoc.d.ts +2 -1
  102. package/dist/fields/hooks/beforeChange/getExistingRowDoc.d.ts.map +1 -1
  103. package/dist/fields/hooks/beforeChange/getExistingRowDoc.js.map +1 -1
  104. package/dist/fields/hooks/beforeChange/index.d.ts +6 -6
  105. package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
  106. package/dist/fields/hooks/beforeChange/index.js +2 -2
  107. package/dist/fields/hooks/beforeChange/index.js.map +1 -1
  108. package/dist/fields/hooks/beforeChange/promise.d.ts +7 -7
  109. package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
  110. package/dist/fields/hooks/beforeChange/promise.js +3 -7
  111. package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
  112. package/dist/fields/hooks/beforeChange/traverseFields.d.ts +7 -7
  113. package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
  114. package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
  115. package/dist/fields/hooks/beforeValidate/index.d.ts +5 -5
  116. package/dist/fields/hooks/beforeValidate/index.d.ts.map +1 -1
  117. package/dist/fields/hooks/beforeValidate/index.js +2 -2
  118. package/dist/fields/hooks/beforeValidate/index.js.map +1 -1
  119. package/dist/fields/hooks/beforeValidate/promise.d.ts +3 -3
  120. package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
  121. package/dist/fields/hooks/beforeValidate/promise.js +2 -2
  122. package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
  123. package/dist/fields/hooks/beforeValidate/traverseFields.d.ts +3 -3
  124. package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
  125. package/dist/fields/hooks/beforeValidate/traverseFields.js.map +1 -1
  126. package/dist/fields/mergeBaseFields.d.ts.map +1 -1
  127. package/dist/fields/mergeBaseFields.js +2 -2
  128. package/dist/fields/mergeBaseFields.js.map +1 -1
  129. package/dist/globals/operations/findOne.d.ts.map +1 -1
  130. package/dist/globals/operations/findOne.js.map +1 -1
  131. package/dist/globals/operations/findVersionByID.d.ts.map +1 -1
  132. package/dist/globals/operations/findVersionByID.js +2 -1
  133. package/dist/globals/operations/findVersionByID.js.map +1 -1
  134. package/dist/globals/operations/findVersions.js.map +1 -1
  135. package/dist/globals/operations/update.d.ts.map +1 -1
  136. package/dist/globals/operations/update.js +2 -1
  137. package/dist/globals/operations/update.js.map +1 -1
  138. package/dist/index.d.ts +11 -10
  139. package/dist/index.d.ts.map +1 -1
  140. package/dist/index.js +8 -12
  141. package/dist/index.js.map +1 -1
  142. package/dist/types/index.d.ts +8 -2
  143. package/dist/types/index.d.ts.map +1 -1
  144. package/dist/types/index.js.map +1 -1
  145. package/dist/uploads/imageResizer.d.ts.map +1 -1
  146. package/dist/uploads/imageResizer.js +16 -18
  147. package/dist/uploads/imageResizer.js.map +1 -1
  148. package/dist/utilities/deepCopyObject.d.ts +18 -1
  149. package/dist/utilities/deepCopyObject.d.ts.map +1 -1
  150. package/dist/utilities/deepCopyObject.js +147 -16
  151. package/dist/utilities/deepCopyObject.js.map +1 -1
  152. package/dist/utilities/deepMerge.d.ts +18 -1
  153. package/dist/utilities/deepMerge.d.ts.map +1 -1
  154. package/dist/utilities/deepMerge.js +38 -13
  155. package/dist/utilities/deepMerge.js.map +1 -1
  156. package/dist/utilities/isPlainObject.d.ts +1 -1
  157. package/dist/utilities/isPlainObject.d.ts.map +1 -1
  158. package/dist/utilities/isPlainObject.js +4 -18
  159. package/dist/utilities/isPlainObject.js.map +1 -1
  160. package/dist/utilities/logger.d.ts +5 -7
  161. package/dist/utilities/logger.d.ts.map +1 -1
  162. package/dist/utilities/logger.js +4 -7
  163. package/dist/utilities/logger.js.map +1 -1
  164. package/dist/utilities/telemetry/events/adminInit.d.ts.map +1 -1
  165. package/dist/utilities/telemetry/events/adminInit.js.map +1 -1
  166. package/dist/versions/baseFields.d.ts.map +1 -1
  167. package/dist/versions/baseFields.js +1 -0
  168. package/dist/versions/baseFields.js.map +1 -1
  169. package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts.map +1 -1
  170. package/dist/versions/drafts/replaceWithDraftIfAvailable.js +2 -1
  171. package/dist/versions/drafts/replaceWithDraftIfAvailable.js.map +1 -1
  172. package/dist/versions/saveVersion.d.ts.map +1 -1
  173. package/dist/versions/saveVersion.js +2 -2
  174. package/dist/versions/saveVersion.js.map +1 -1
  175. package/package.json +5 -7
  176. package/dist/collections/config/schema.d.ts +0 -4
  177. package/dist/collections/config/schema.d.ts.map +0 -1
  178. package/dist/collections/config/schema.js +0 -191
  179. package/dist/collections/config/schema.js.map +0 -1
  180. package/dist/config/schema.d.ts +0 -5
  181. package/dist/config/schema.d.ts.map +0 -1
  182. package/dist/config/schema.js +0 -179
  183. package/dist/config/schema.js.map +0 -1
  184. package/dist/config/shared/adminViewSchema.d.ts +0 -3
  185. package/dist/config/shared/adminViewSchema.d.ts.map +0 -1
  186. package/dist/config/shared/adminViewSchema.js +0 -11
  187. package/dist/config/shared/adminViewSchema.js.map +0 -1
  188. package/dist/config/shared/componentSchema.d.ts +0 -16
  189. package/dist/config/shared/componentSchema.d.ts.map +0 -1
  190. package/dist/config/shared/componentSchema.js +0 -27
  191. package/dist/config/shared/componentSchema.js.map +0 -1
  192. package/dist/config/shared/openGraphSchema.d.ts +0 -3
  193. package/dist/config/shared/openGraphSchema.d.ts.map +0 -1
  194. package/dist/config/shared/openGraphSchema.js +0 -16
  195. package/dist/config/shared/openGraphSchema.js.map +0 -1
  196. package/dist/config/validate.d.ts +0 -4
  197. package/dist/config/validate.d.ts.map +0 -1
  198. package/dist/config/validate.js +0 -89
  199. package/dist/config/validate.js.map +0 -1
  200. package/dist/fields/config/schema.d.ts +0 -29
  201. package/dist/fields/config/schema.d.ts.map +0 -1
  202. package/dist/fields/config/schema.js +0 -508
  203. package/dist/fields/config/schema.js.map +0 -1
  204. package/dist/globals/config/schema.d.ts +0 -4
  205. package/dist/globals/config/schema.d.ts.map +0 -1
  206. package/dist/globals/config/schema.js +0 -79
  207. package/dist/globals/config/schema.js.map +0 -1
  208. package/dist/utilities/combineMerge.d.ts +0 -2
  209. package/dist/utilities/combineMerge.d.ts.map +0 -1
  210. package/dist/utilities/combineMerge.js +0 -16
  211. package/dist/utilities/combineMerge.js.map +0 -1
  212. package/dist/utilities/convertData.d.ts +0 -5
  213. package/dist/utilities/convertData.d.ts.map +0 -1
  214. package/dist/utilities/convertData.js +0 -16
  215. package/dist/utilities/convertData.js.map +0 -1
  216. package/dist/utilities/getCSSVariable.d.ts +0 -3
  217. package/dist/utilities/getCSSVariable.d.ts.map +0 -1
  218. package/dist/utilities/getCSSVariable.js +0 -3
  219. package/dist/utilities/getCSSVariable.js.map +0 -1
  220. package/dist/utilities/overwriteMerge.d.ts +0 -3
  221. package/dist/utilities/overwriteMerge.d.ts.map +0 -1
  222. package/dist/utilities/overwriteMerge.js +0 -4
  223. package/dist/utilities/overwriteMerge.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/fields/hooks/beforeChange/promise.ts"],"sourcesContent":["import merge from 'deepmerge'\n\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 { Operation, PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, FieldHookArgs, TabAsField, ValidateOptions } from '../../config/types.js'\n\nimport { MissingEditorProp } from '../../../errors/index.js'\nimport { fieldAffectsData, tabHasName } from '../../config/types.js'\nimport { getFieldPaths } from '../../getFieldPaths.js'\nimport { beforeDuplicate } from './beforeDuplicate.js'\nimport { getExistingRowDoc } from './getExistingRowDoc.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: Record<string, unknown>\n doc: Record<string, unknown>\n docWithLocales: Record<string, unknown>\n duplicate: boolean\n errors: { field: string; message: string }[]\n field: Field | TabAsField\n global: SanitizedGlobalConfig | null\n id?: number | string\n mergeLocaleActions: (() => Promise<void>)[]\n operation: Operation\n /**\n * The parent's path.\n */\n parentPath: (number | string)[]\n /**\n * The parent's schemaPath (path without indexes).\n */\n parentSchemaPath: string[]\n req: PayloadRequest\n siblingData: Record<string, unknown>\n siblingDoc: Record<string, unknown>\n siblingDocWithLocales?: Record<string, unknown>\n skipValidation: boolean\n}\n\n// This function is responsible for the following actions, in order:\n// - Run condition\n// - Execute field hooks\n// - Validate data\n// - Transform data for storage\n// - beforeDuplicate hooks (if duplicate)\n// - Unflatten locales\n\nexport const promise = async ({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n field,\n global,\n mergeLocaleActions,\n operation,\n parentPath,\n parentSchemaPath,\n req,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n skipValidation,\n}: Args): Promise<void> => {\n const passesCondition = field.admin?.condition\n ? Boolean(field.admin.condition(data, siblingData, { user: req.user }))\n : true\n let skipValidationFromHere = skipValidation || !passesCondition\n const { localization } = req.payload.config\n const defaultLocale = localization ? localization?.defaultLocale : 'en'\n const operationLocale = req.locale || defaultLocale\n\n const { path: fieldPath, schemaPath: fieldSchemaPath } = getFieldPaths({\n field,\n parentPath,\n parentSchemaPath,\n })\n\n if (fieldAffectsData(field)) {\n // skip validation if the field is localized and the incoming data is null\n if (field.localized && operationLocale !== defaultLocale) {\n if (['array', 'blocks'].includes(field.type) && siblingData[field.name] === null) {\n skipValidationFromHere = true\n }\n }\n\n // Execute hooks\n if (field.hooks?.beforeChange) {\n await field.hooks.beforeChange.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 path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingDoc[field.name],\n req,\n schemaPath: parentSchemaPath,\n siblingData,\n siblingDocWithLocales,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n\n // Validate\n if (!skipValidationFromHere && field.validate) {\n const valueToValidate = siblingData[field.name]\n let jsonError: object\n\n if (field.type === 'json' && typeof siblingData[field.name] === 'string') {\n try {\n JSON.parse(siblingData[field.name] as string)\n } catch (e) {\n jsonError = e\n }\n }\n\n const validationResult = await field.validate(valueToValidate, {\n ...field,\n id,\n data: merge(doc, data, { arrayMerge: (_, source) => source }),\n jsonError,\n operation,\n preferences: { fields: {} },\n req,\n siblingData: merge(siblingDoc, siblingData, { arrayMerge: (_, source) => source }),\n } as ValidateOptions<any, any, { jsonError: object }>)\n\n if (typeof validationResult === 'string') {\n errors.push({\n field: fieldPath.join('.'),\n message: validationResult,\n })\n }\n }\n\n const beforeDuplicateArgs: FieldHookArgs = {\n collection,\n context,\n data,\n field,\n global: undefined,\n path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingDoc[field.name],\n req,\n schemaPath: parentSchemaPath,\n siblingData,\n siblingDocWithLocales,\n value: siblingData[field.name],\n }\n\n // Push merge locale action if applicable\n if (localization && field.localized) {\n mergeLocaleActions.push(async () => {\n const localeData = await localization.localeCodes.reduce(\n async (localizedValuesPromise: Promise<Record<string, unknown>>, locale) => {\n const localizedValues = await localizedValuesPromise\n let fieldValue =\n locale === req.locale\n ? siblingData[field.name]\n : siblingDocWithLocales?.[field.name]?.[locale]\n\n if (duplicate && field.hooks?.beforeDuplicate?.length) {\n beforeDuplicateArgs.value = fieldValue\n fieldValue = await beforeDuplicate(beforeDuplicateArgs)\n }\n\n // const result = await localizedValues\n // update locale value if it's not undefined\n if (typeof fieldValue !== 'undefined') {\n return {\n ...localizedValues,\n [locale]: fieldValue,\n }\n }\n\n return localizedValuesPromise\n },\n Promise.resolve({}),\n )\n\n // If there are locales with data, set the data\n if (Object.keys(localeData).length > 0) {\n siblingData[field.name] = localeData\n }\n })\n } else if (duplicate && field.hooks?.beforeDuplicate?.length) {\n mergeLocaleActions.push(async () => {\n siblingData[field.name] = await beforeDuplicate(beforeDuplicateArgs)\n })\n }\n }\n\n switch (field.type) {\n case 'point': {\n // Transform point data for storage\n if (\n Array.isArray(siblingData[field.name]) &&\n siblingData[field.name][0] !== null &&\n siblingData[field.name][1] !== null\n ) {\n siblingData[field.name] = {\n type: 'Point',\n coordinates: [\n parseFloat(siblingData[field.name][0]),\n parseFloat(siblingData[field.name][1]),\n ],\n }\n }\n\n break\n }\n\n case 'group': {\n if (typeof siblingData[field.name] !== 'object') siblingData[field.name] = {}\n if (typeof siblingDoc[field.name] !== 'object') siblingDoc[field.name] = {}\n if (typeof siblingDocWithLocales[field.name] !== 'object')\n siblingDocWithLocales[field.name] = {}\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: field.fields,\n global,\n mergeLocaleActions,\n operation,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: siblingData[field.name] as Record<string, unknown>,\n siblingDoc: siblingDoc[field.name] as Record<string, unknown>,\n siblingDocWithLocales: siblingDocWithLocales[field.name] as Record<string, unknown>,\n skipValidation: skipValidationFromHere,\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 docWithLocales,\n duplicate,\n errors,\n fields: field.fields,\n global,\n mergeLocaleActions,\n operation,\n path: [...fieldPath, i],\n req,\n schemaPath: fieldSchemaPath,\n siblingData: row,\n siblingDoc: getExistingRowDoc(row, siblingDoc[field.name]),\n siblingDocWithLocales: getExistingRowDoc(row, siblingDocWithLocales[field.name]),\n skipValidation: skipValidationFromHere,\n }),\n )\n })\n\n await Promise.all(promises)\n }\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 rowSiblingDocWithLocales = getExistingRowDoc(row, siblingDocWithLocales[field.name])\n\n const blockTypeToMatch = row.blockType || rowSiblingDoc.blockType\n const block = field.blocks.find((blockType) => blockType.slug === blockTypeToMatch)\n\n if (block) {\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: block.fields,\n global,\n mergeLocaleActions,\n operation,\n path: [...fieldPath, i],\n req,\n schemaPath: fieldSchemaPath,\n siblingData: row,\n siblingDoc: rowSiblingDoc,\n siblingDocWithLocales: rowSiblingDocWithLocales,\n skipValidation: skipValidationFromHere,\n }),\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 docWithLocales,\n duplicate,\n errors,\n fields: field.fields,\n global,\n mergeLocaleActions,\n operation,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n skipValidation: skipValidationFromHere,\n })\n\n break\n }\n\n case 'tab': {\n let tabSiblingData = siblingData\n let tabSiblingDoc = siblingDoc\n let tabSiblingDocWithLocales = siblingDocWithLocales\n\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 if (typeof siblingDocWithLocales[field.name] !== 'object')\n siblingDocWithLocales[field.name] = {}\n\n tabSiblingData = siblingData[field.name] as Record<string, unknown>\n tabSiblingDoc = siblingDoc[field.name] as Record<string, unknown>\n tabSiblingDocWithLocales = siblingDocWithLocales[field.name] as Record<string, unknown>\n }\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: field.fields,\n global,\n mergeLocaleActions,\n operation,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n siblingDocWithLocales: tabSiblingDocWithLocales,\n skipValidation: skipValidationFromHere,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n mergeLocaleActions,\n operation,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n skipValidation: skipValidationFromHere,\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?.beforeChange?.length) {\n await editor.hooks.beforeChange.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n docWithLocales,\n duplicate,\n errors,\n field,\n global,\n mergeLocaleActions,\n operation,\n originalDoc: doc,\n path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingDoc[field.name],\n req,\n schemaPath: parentSchemaPath,\n siblingData,\n siblingDocWithLocales,\n skipValidation,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["merge","MissingEditorProp","fieldAffectsData","tabHasName","getFieldPaths","beforeDuplicate","getExistingRowDoc","traverseFields","promise","id","collection","context","data","doc","docWithLocales","duplicate","errors","field","global","mergeLocaleActions","operation","parentPath","parentSchemaPath","req","siblingData","siblingDoc","siblingDocWithLocales","skipValidation","passesCondition","admin","condition","Boolean","user","skipValidationFromHere","localization","payload","config","defaultLocale","operationLocale","locale","path","fieldPath","schemaPath","fieldSchemaPath","localized","includes","type","name","hooks","beforeChange","reduce","priorHook","currentHook","hookedValue","originalDoc","previousSiblingDoc","previousValue","value","undefined","Promise","resolve","validate","valueToValidate","jsonError","JSON","parse","e","validationResult","arrayMerge","_","source","preferences","fields","push","join","message","beforeDuplicateArgs","localeData","localeCodes","localizedValuesPromise","localizedValues","fieldValue","length","Object","keys","Array","isArray","coordinates","parseFloat","rows","promises","forEach","row","i","all","rowSiblingDoc","rowSiblingDocWithLocales","blockTypeToMatch","blockType","block","blocks","find","slug","tabSiblingData","tabSiblingDoc","tabSiblingDocWithLocales","tabs","map","tab","editor","Error"],"mappings":"AAAA,OAAOA,WAAW,YAAW;AAQ7B,SAASC,iBAAiB,QAAQ,2BAA0B;AAC5D,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,wBAAuB;AACpE,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,cAAc,QAAQ,sBAAqB;AA8BpD,oEAAoE;AACpE,kBAAkB;AAClB,wBAAwB;AACxB,kBAAkB;AAClB,+BAA+B;AAC/B,yCAAyC;AACzC,sBAAsB;AAEtB,OAAO,MAAMC,UAAU,OAAO,EAC5BC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,cAAc,EACdC,SAAS,EACTC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,kBAAkB,EAClBC,SAAS,EACTC,UAAU,EACVC,gBAAgB,EAChBC,GAAG,EACHC,WAAW,EACXC,UAAU,EACVC,qBAAqB,EACrBC,cAAc,EACT;IACL,MAAMC,kBAAkBX,MAAMY,KAAK,EAAEC,YACjCC,QAAQd,MAAMY,KAAK,CAACC,SAAS,CAAClB,MAAMY,aAAa;QAAEQ,MAAMT,IAAIS,IAAI;IAAC,MAClE;IACJ,IAAIC,yBAAyBN,kBAAkB,CAACC;IAChD,MAAM,EAAEM,YAAY,EAAE,GAAGX,IAAIY,OAAO,CAACC,MAAM;IAC3C,MAAMC,gBAAgBH,eAAeA,cAAcG,gBAAgB;IACnE,MAAMC,kBAAkBf,IAAIgB,MAAM,IAAIF;IAEtC,MAAM,EAAEG,MAAMC,SAAS,EAAE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IAAIA,QAAQ7D,OAAOC,cAAciC,QAAQ;oBACvC,MAAM2B,OAAO7D,KAAK,CAACC,YAAY,CAACC,MAAM,CAAC,OAAOC,WAAWC;wBACvD,MAAMD;wBAEN,MAAME,cAAc,MAAMD,YAAY;4BACpC1C;4BACAC;4BACAC;4BACAE;4BACAC;4BACAC;4BACAC;4BACAC;4BACAC;4BACAC;4BACAkC,aAAazC;4BACb2B,MAAMC;4BACNc,oBAAoB9B;4BACpB+B,eAAe/B,UAAU,CAACR,MAAM8B,IAAI,CAAC;4BACrCxB;4BACAmB,YAAYpB;4BACZE;4BACAE;4BACAC;4BACA8B,OAAOjC,WAAW,CAACP,MAAM8B,IAAI,CAAC;wBAChC;wBAEA,IAAIM,gBAAgBK,WAAW;4BAC7BlC,WAAW,CAACP,MAAM8B,IAAI,CAAC,GAAGM;wBAC5B;oBACF,GAAGM,QAAQC,OAAO;gBACpB;gBAEA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/fields/hooks/beforeChange/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 { JsonObject, Operation, PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, FieldHookArgs, TabAsField, ValidateOptions } from '../../config/types.js'\n\nimport { MissingEditorProp } from '../../../errors/index.js'\nimport { deepMergeWithSourceArrays } from '../../../utilities/deepMerge.js'\nimport { fieldAffectsData, tabHasName } from '../../config/types.js'\nimport { getFieldPaths } from '../../getFieldPaths.js'\nimport { beforeDuplicate } from './beforeDuplicate.js'\nimport { getExistingRowDoc } from './getExistingRowDoc.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: JsonObject\n doc: JsonObject\n docWithLocales: JsonObject\n duplicate: boolean\n errors: { field: string; message: string }[]\n field: Field | TabAsField\n global: SanitizedGlobalConfig | null\n id?: number | string\n mergeLocaleActions: (() => Promise<void>)[]\n operation: Operation\n /**\n * The parent's path.\n */\n parentPath: (number | string)[]\n /**\n * The parent's schemaPath (path without indexes).\n */\n parentSchemaPath: string[]\n req: PayloadRequest\n siblingData: JsonObject\n siblingDoc: JsonObject\n siblingDocWithLocales?: JsonObject\n skipValidation: boolean\n}\n\n// This function is responsible for the following actions, in order:\n// - Run condition\n// - Execute field hooks\n// - Validate data\n// - Transform data for storage\n// - beforeDuplicate hooks (if duplicate)\n// - Unflatten locales\n\nexport const promise = async ({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n field,\n global,\n mergeLocaleActions,\n operation,\n parentPath,\n parentSchemaPath,\n req,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n skipValidation,\n}: Args): Promise<void> => {\n const passesCondition = field.admin?.condition\n ? Boolean(field.admin.condition(data, siblingData, { user: req.user }))\n : true\n let skipValidationFromHere = skipValidation || !passesCondition\n const { localization } = req.payload.config\n const defaultLocale = localization ? localization?.defaultLocale : 'en'\n const operationLocale = req.locale || defaultLocale\n\n const { path: fieldPath, schemaPath: fieldSchemaPath } = getFieldPaths({\n field,\n parentPath,\n parentSchemaPath,\n })\n\n if (fieldAffectsData(field)) {\n // skip validation if the field is localized and the incoming data is null\n if (field.localized && operationLocale !== defaultLocale) {\n if (['array', 'blocks'].includes(field.type) && siblingData[field.name] === null) {\n skipValidationFromHere = true\n }\n }\n\n // Execute hooks\n if (field.hooks?.beforeChange) {\n await field.hooks.beforeChange.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 path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingDoc[field.name],\n req,\n schemaPath: parentSchemaPath,\n siblingData,\n siblingDocWithLocales,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n\n // Validate\n if (!skipValidationFromHere && field.validate) {\n const valueToValidate = siblingData[field.name]\n let jsonError: object\n\n if (field.type === 'json' && typeof siblingData[field.name] === 'string') {\n try {\n JSON.parse(siblingData[field.name] as string)\n } catch (e) {\n jsonError = e\n }\n }\n\n const validationResult = await field.validate(valueToValidate, {\n ...field,\n id,\n data: deepMergeWithSourceArrays(doc, data),\n jsonError,\n operation,\n preferences: { fields: {} },\n req,\n siblingData: deepMergeWithSourceArrays(siblingDoc, siblingData),\n } as ValidateOptions<any, any, { jsonError: object }>)\n\n if (typeof validationResult === 'string') {\n errors.push({\n field: fieldPath.join('.'),\n message: validationResult,\n })\n }\n }\n\n const beforeDuplicateArgs: FieldHookArgs = {\n collection,\n context,\n data,\n field,\n global: undefined,\n path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingDoc[field.name],\n req,\n schemaPath: parentSchemaPath,\n siblingData,\n siblingDocWithLocales,\n value: siblingData[field.name],\n }\n\n // Push merge locale action if applicable\n if (localization && field.localized) {\n mergeLocaleActions.push(async () => {\n const localeData = await localization.localeCodes.reduce(\n async (localizedValuesPromise: Promise<JsonObject>, locale) => {\n const localizedValues = await localizedValuesPromise\n let fieldValue =\n locale === req.locale\n ? siblingData[field.name]\n : siblingDocWithLocales?.[field.name]?.[locale]\n\n if (duplicate && field.hooks?.beforeDuplicate?.length) {\n beforeDuplicateArgs.value = fieldValue\n fieldValue = await beforeDuplicate(beforeDuplicateArgs)\n }\n\n // const result = await localizedValues\n // update locale value if it's not undefined\n if (typeof fieldValue !== 'undefined') {\n return {\n ...localizedValues,\n [locale]: fieldValue,\n }\n }\n\n return localizedValuesPromise\n },\n Promise.resolve({}),\n )\n\n // If there are locales with data, set the data\n if (Object.keys(localeData).length > 0) {\n siblingData[field.name] = localeData\n }\n })\n } else if (duplicate && field.hooks?.beforeDuplicate?.length) {\n mergeLocaleActions.push(async () => {\n siblingData[field.name] = await beforeDuplicate(beforeDuplicateArgs)\n })\n }\n }\n\n switch (field.type) {\n case 'point': {\n // Transform point data for storage\n if (\n Array.isArray(siblingData[field.name]) &&\n siblingData[field.name][0] !== null &&\n siblingData[field.name][1] !== null\n ) {\n siblingData[field.name] = {\n type: 'Point',\n coordinates: [\n parseFloat(siblingData[field.name][0]),\n parseFloat(siblingData[field.name][1]),\n ],\n }\n }\n\n break\n }\n\n case 'group': {\n if (typeof siblingData[field.name] !== 'object') siblingData[field.name] = {}\n if (typeof siblingDoc[field.name] !== 'object') siblingDoc[field.name] = {}\n if (typeof siblingDocWithLocales[field.name] !== 'object')\n siblingDocWithLocales[field.name] = {}\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: field.fields,\n global,\n mergeLocaleActions,\n operation,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: siblingData[field.name] as JsonObject,\n siblingDoc: siblingDoc[field.name] as JsonObject,\n siblingDocWithLocales: siblingDocWithLocales[field.name] as JsonObject,\n skipValidation: skipValidationFromHere,\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 docWithLocales,\n duplicate,\n errors,\n fields: field.fields,\n global,\n mergeLocaleActions,\n operation,\n path: [...fieldPath, i],\n req,\n schemaPath: fieldSchemaPath,\n siblingData: row as JsonObject,\n siblingDoc: getExistingRowDoc(row as JsonObject, siblingDoc[field.name]),\n siblingDocWithLocales: getExistingRowDoc(\n row as JsonObject,\n siblingDocWithLocales[field.name],\n ),\n skipValidation: skipValidationFromHere,\n }),\n )\n })\n\n await Promise.all(promises)\n }\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 as JsonObject, siblingDoc[field.name])\n const rowSiblingDocWithLocales = getExistingRowDoc(\n row as JsonObject,\n siblingDocWithLocales[field.name],\n )\n\n const blockTypeToMatch = (row as JsonObject).blockType || rowSiblingDoc.blockType\n const block = field.blocks.find((blockType) => blockType.slug === blockTypeToMatch)\n\n if (block) {\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: block.fields,\n global,\n mergeLocaleActions,\n operation,\n path: [...fieldPath, i],\n req,\n schemaPath: fieldSchemaPath,\n siblingData: row as JsonObject,\n siblingDoc: rowSiblingDoc,\n siblingDocWithLocales: rowSiblingDocWithLocales,\n skipValidation: skipValidationFromHere,\n }),\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 docWithLocales,\n duplicate,\n errors,\n fields: field.fields,\n global,\n mergeLocaleActions,\n operation,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n skipValidation: skipValidationFromHere,\n })\n\n break\n }\n\n case 'tab': {\n let tabSiblingData = siblingData\n let tabSiblingDoc = siblingDoc\n let tabSiblingDocWithLocales = siblingDocWithLocales\n\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 if (typeof siblingDocWithLocales[field.name] !== 'object')\n siblingDocWithLocales[field.name] = {}\n\n tabSiblingData = siblingData[field.name] as JsonObject\n tabSiblingDoc = siblingDoc[field.name] as JsonObject\n tabSiblingDocWithLocales = siblingDocWithLocales[field.name] as JsonObject\n }\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: field.fields,\n global,\n mergeLocaleActions,\n operation,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n siblingDocWithLocales: tabSiblingDocWithLocales,\n skipValidation: skipValidationFromHere,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n mergeLocaleActions,\n operation,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n skipValidation: skipValidationFromHere,\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?.beforeChange?.length) {\n await editor.hooks.beforeChange.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n docWithLocales,\n duplicate,\n errors,\n field,\n global,\n mergeLocaleActions,\n operation,\n originalDoc: doc,\n path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingDoc[field.name],\n req,\n schemaPath: parentSchemaPath,\n siblingData,\n siblingDocWithLocales,\n skipValidation,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","deepMergeWithSourceArrays","fieldAffectsData","tabHasName","getFieldPaths","beforeDuplicate","getExistingRowDoc","traverseFields","promise","id","collection","context","data","doc","docWithLocales","duplicate","errors","field","global","mergeLocaleActions","operation","parentPath","parentSchemaPath","req","siblingData","siblingDoc","siblingDocWithLocales","skipValidation","passesCondition","admin","condition","Boolean","user","skipValidationFromHere","localization","payload","config","defaultLocale","operationLocale","locale","path","fieldPath","schemaPath","fieldSchemaPath","localized","includes","type","name","hooks","beforeChange","reduce","priorHook","currentHook","hookedValue","originalDoc","previousSiblingDoc","previousValue","value","undefined","Promise","resolve","validate","valueToValidate","jsonError","JSON","parse","e","validationResult","preferences","fields","push","join","message","beforeDuplicateArgs","localeData","localeCodes","localizedValuesPromise","localizedValues","fieldValue","length","Object","keys","Array","isArray","coordinates","parseFloat","rows","promises","forEach","row","i","all","rowSiblingDoc","rowSiblingDocWithLocales","blockTypeToMatch","blockType","block","blocks","find","slug","tabSiblingData","tabSiblingDoc","tabSiblingDocWithLocales","tabs","map","tab","editor","Error"],"mappings":"AAMA,SAASA,iBAAiB,QAAQ,2BAA0B;AAC5D,SAASC,yBAAyB,QAAQ,kCAAiC;AAC3E,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,wBAAuB;AACpE,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,cAAc,QAAQ,sBAAqB;AA8BpD,oEAAoE;AACpE,kBAAkB;AAClB,wBAAwB;AACxB,kBAAkB;AAClB,+BAA+B;AAC/B,yCAAyC;AACzC,sBAAsB;AAEtB,OAAO,MAAMC,UAAU,OAAO,EAC5BC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,cAAc,EACdC,SAAS,EACTC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,kBAAkB,EAClBC,SAAS,EACTC,UAAU,EACVC,gBAAgB,EAChBC,GAAG,EACHC,WAAW,EACXC,UAAU,EACVC,qBAAqB,EACrBC,cAAc,EACT;IACL,MAAMC,kBAAkBX,MAAMY,KAAK,EAAEC,YACjCC,QAAQd,MAAMY,KAAK,CAACC,SAAS,CAAClB,MAAMY,aAAa;QAAEQ,MAAMT,IAAIS,IAAI;IAAC,MAClE;IACJ,IAAIC,yBAAyBN,kBAAkB,CAACC;IAChD,MAAM,EAAEM,YAAY,EAAE,G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AM,IAAIC,MAAM;gBAClB;gBAEA,MAAMD,SAA0BzF,OAAOyF;gBAEvC,IAAIA,QAAQ1D,OAAOC,cAAc8B,QAAQ;oBACvC,MAAM2B,OAAO1D,KAAK,CAACC,YAAY,CAACC,MAAM,CAAC,OAAOC,WAAWC;wBACvD,MAAMD;wBAEN,MAAME,cAAc,MAAMD,YAAY;4BACpC1C;4BACAC;4BACAC;4BACAE;4BACAC;4BACAC;4BACAC;4BACAC;4BACAC;4BACAC;4BACAkC,aAAazC;4BACb2B,MAAMC;4BACNc,oBAAoB9B;4BACpB+B,eAAe/B,UAAU,CAACR,MAAM8B,IAAI,CAAC;4BACrCxB;4BACAmB,YAAYpB;4BACZE;4BACAE;4BACAC;4BACA8B,OAAOjC,WAAW,CAACP,MAAM8B,IAAI,CAAC;wBAChC;wBAEA,IAAIM,gBAAgBK,WAAW;4BAC7BlC,WAAW,CAACP,MAAM8B,IAAI,CAAC,GAAGM;wBAC5B;oBACF,GAAGM,QAAQC,OAAO;gBACpB;gBAEA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
@@ -1,19 +1,19 @@
1
1
  import type { SanitizedCollectionConfig } from '../../../collections/config/types.js';
2
2
  import type { SanitizedGlobalConfig } from '../../../globals/config/types.js';
3
- import type { Operation, PayloadRequest, RequestContext } from '../../../types/index.js';
3
+ import type { JsonObject, Operation, PayloadRequest, RequestContext } from '../../../types/index.js';
4
4
  import type { Field, TabAsField } from '../../config/types.js';
5
5
  type Args = {
6
6
  collection: SanitizedCollectionConfig | null;
7
7
  context: RequestContext;
8
- data: Record<string, unknown>;
8
+ data: JsonObject;
9
9
  /**
10
10
  * The original data (not modified by any hooks)
11
11
  */
12
- doc: Record<string, unknown>;
12
+ doc: JsonObject;
13
13
  /**
14
14
  * The original data with locales (not modified by any hooks)
15
15
  */
16
- docWithLocales: Record<string, unknown>;
16
+ docWithLocales: JsonObject;
17
17
  duplicate: boolean;
18
18
  errors: {
19
19
  field: string;
@@ -27,15 +27,15 @@ type Args = {
27
27
  path: (number | string)[];
28
28
  req: PayloadRequest;
29
29
  schemaPath: string[];
30
- siblingData: Record<string, unknown>;
30
+ siblingData: JsonObject;
31
31
  /**
32
32
  * The original siblingData (not modified by any hooks)
33
33
  */
34
- siblingDoc: Record<string, unknown>;
34
+ siblingDoc: JsonObject;
35
35
  /**
36
36
  * The original siblingData with locales (not modified by any hooks)
37
37
  */
38
- siblingDocWithLocales: Record<string, unknown>;
38
+ siblingDocWithLocales: JsonObject;
39
39
  skipValidation?: boolean;
40
40
  };
41
41
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeChange/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,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxF,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAI9D,KAAK,IAAI,GAAG;IACV,UAAU,EAAE,yBAAyB,GAAG,IAAI,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC5B;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACvC,SAAS,EAAE,OAAO,CAAA;IAClB,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAC5C,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,MA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,cAAc,EAAE,UAAU,CAAA;IAC1B,SAAS,EAAE,OAAO,CAAA;IAClB,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAC5C,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,kBAAkB,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAA;IAC3C,SAAS,EAAE,SAAS,CAAA;IACpB,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IACzB,GAAG,EAAE,cAAc,CAAA;IACnB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,WAAW,EAAE,UAAU,CAAA;IACvB;;OAEG;IACH,UAAU,EAAE,UAAU,CAAA;IACtB;;OAEG;IACH,qBAAqB,EAAE,UAAU,CAAA;IACjC,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,qNAoBxB,IAAI,KAAG,OAAO,CAAC,IAAI,CA8BrB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/fields/hooks/beforeChange/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { Operation, PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: Record<string, unknown>\n /**\n * The original data (not modified by any hooks)\n */\n doc: Record<string, unknown>\n /**\n * The original data with locales (not modified by any hooks)\n */\n docWithLocales: Record<string, unknown>\n duplicate: boolean\n errors: { field: string; message: string }[]\n fields: (Field | TabAsField)[]\n global: SanitizedGlobalConfig | null\n id?: number | string\n mergeLocaleActions: (() => Promise<void>)[]\n operation: Operation\n path: (number | string)[]\n req: PayloadRequest\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 * The original siblingData with locales (not modified by any hooks)\n */\n siblingDocWithLocales: Record<string, unknown>\n skipValidation?: boolean\n}\n\n/**\n * This function is responsible for the following actions, in order:\n * - Run condition\n * - Execute field hooks\n * - Validate data\n * - Transform data for storage\n * - Unflatten locales. The input `data` is the normal document for one locale. The output result will become the document with locales.\n */\nexport const traverseFields = async ({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields,\n global,\n mergeLocaleActions,\n operation,\n path,\n req,\n schemaPath,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n skipValidation,\n}: Args): Promise<void> => {\n const promises = []\n\n fields.forEach((field) => {\n promises.push(\n promise({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n field,\n global,\n mergeLocaleActions,\n operation,\n parentPath: path,\n parentSchemaPath: schemaPath,\n req,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n skipValidation,\n }),\n )\n })\n\n await Promise.all(promises)\n}\n"],"names":["promise","traverseFields","id","collection","context","data","doc","docWithLocales","duplicate","errors","fields","global","mergeLocaleActions","operation","path","req","schemaPath","siblingData","siblingDoc","siblingDocWithLocales","skipValidation","promises","forEach","field","push","parentPath","parentSchemaPath","Promise","all"],"mappings":"AAKA,SAASA,OAAO,QAAQ,eAAc;AAoCtC;;;;;;;CAOC,GACD,OAAO,MAAMC,iBAAiB,OAAO,EACnCC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,cAAc,EACdC,SAAS,EACTC,MAAM,EACNC,MAAM,EACNC,MAAM,EACNC,kBAAkB,EAClBC,SAAS,EACTC,IAAI,EACJC,GAAG,EACHC,UAAU,EACVC,WAAW,EACXC,UAAU,EACVC,qBAAqB,EACrBC,cAAc,EACT;IACL,MAAMC,WAAW,EAAE;IAEnBX,OAAOY,OAAO,CAAC,CAACC;QACdF,SAASG,IAAI,CACXxB,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAc;YACAZ;YACAC;YACAC;YACAY,YAAYX;YACZY,kBAAkBV;YAClBD;YACAE;YACAC;YACAC;YACAC;QACF;IAEJ;IAEA,MAAMO,QAAQC,GAAG,CAACP;AACpB,EAAC"}
1
+ {"version":3,"sources":["../../../../src/fields/hooks/beforeChange/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { JsonObject, Operation, PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: JsonObject\n /**\n * The original data (not modified by any hooks)\n */\n doc: JsonObject\n /**\n * The original data with locales (not modified by any hooks)\n */\n docWithLocales: JsonObject\n duplicate: boolean\n errors: { field: string; message: string }[]\n fields: (Field | TabAsField)[]\n global: SanitizedGlobalConfig | null\n id?: number | string\n mergeLocaleActions: (() => Promise<void>)[]\n operation: Operation\n path: (number | string)[]\n req: PayloadRequest\n schemaPath: string[]\n siblingData: JsonObject\n /**\n * The original siblingData (not modified by any hooks)\n */\n siblingDoc: JsonObject\n /**\n * The original siblingData with locales (not modified by any hooks)\n */\n siblingDocWithLocales: JsonObject\n skipValidation?: boolean\n}\n\n/**\n * This function is responsible for the following actions, in order:\n * - Run condition\n * - Execute field hooks\n * - Validate data\n * - Transform data for storage\n * - Unflatten locales. The input `data` is the normal document for one locale. The output result will become the document with locales.\n */\nexport const traverseFields = async ({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields,\n global,\n mergeLocaleActions,\n operation,\n path,\n req,\n schemaPath,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n skipValidation,\n}: Args): Promise<void> => {\n const promises = []\n\n fields.forEach((field) => {\n promises.push(\n promise({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n field,\n global,\n mergeLocaleActions,\n operation,\n parentPath: path,\n parentSchemaPath: schemaPath,\n req,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n skipValidation,\n }),\n )\n })\n\n await Promise.all(promises)\n}\n"],"names":["promise","traverseFields","id","collection","context","data","doc","docWithLocales","duplicate","errors","fields","global","mergeLocaleActions","operation","path","req","schemaPath","siblingData","siblingDoc","siblingDocWithLocales","skipValidation","promises","forEach","field","push","parentPath","parentSchemaPath","Promise","all"],"mappings":"AAKA,SAASA,OAAO,QAAQ,eAAc;AAoCtC;;;;;;;CAOC,GACD,OAAO,MAAMC,iBAAiB,OAAO,EACnCC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,cAAc,EACdC,SAAS,EACTC,MAAM,EACNC,MAAM,EACNC,MAAM,EACNC,kBAAkB,EAClBC,SAAS,EACTC,IAAI,EACJC,GAAG,EACHC,UAAU,EACVC,WAAW,EACXC,UAAU,EACVC,qBAAqB,EACrBC,cAAc,EACT;IACL,MAAMC,WAAW,EAAE;IAEnBX,OAAOY,OAAO,CAAC,CAACC;QACdF,SAASG,IAAI,CACXxB,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAc;YACAZ;YACAC;YACAC;YACAY,YAAYX;YACZY,kBAAkBV;YAClBD;YACAE;YACAC;YACAC;YACAC;QACF;IAEJ;IAEA,MAAMO,QAAQC,GAAG,CAACP;AACpB,EAAC"}
@@ -1,11 +1,11 @@
1
1
  import type { SanitizedCollectionConfig } from '../../../collections/config/types.js';
2
2
  import type { SanitizedGlobalConfig } from '../../../globals/config/types.js';
3
- import type { PayloadRequest, RequestContext } from '../../../types/index.js';
4
- type Args<T> = {
3
+ import type { JsonObject, PayloadRequest, RequestContext } from '../../../types/index.js';
4
+ type Args<T extends JsonObject> = {
5
5
  collection: SanitizedCollectionConfig | null;
6
6
  context: RequestContext;
7
- data: Record<string, unknown> | T;
8
- doc?: Record<string, unknown> | T;
7
+ data: T;
8
+ doc?: T;
9
9
  duplicate?: boolean;
10
10
  global: SanitizedGlobalConfig | null;
11
11
  id?: number | string;
@@ -21,6 +21,6 @@ type Args<T> = {
21
21
  * - Merge original document data into incoming data
22
22
  * - Compute default values for undefined fields
23
23
  */
24
- export declare const beforeValidate: <T extends Record<string, unknown>>({ id, collection, context, data: incomingData, doc, global, operation, overrideAccess, req, }: Args<T>) => Promise<T>;
24
+ export declare const beforeValidate: <T extends JsonObject>({ id, collection, context, data: incomingData, doc, global, operation, overrideAccess, req, }: Args<T>) => Promise<T>;
25
25
  export {};
26
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeValidate/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAK7E,KAAK,IAAI,CAAC,CAAC,IAAI;IACb,UAAU,EAAE,yBAAyB,GAAG,IAAI,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IACjC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,EAAE,q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4 @@
1
- import { deepCopyObject } from '../../../utilities/deepCopyObject.js';
1
+ import { deepCopyObjectSimple } from '../../../utilities/deepCopyObject.js';
2
2
  import { traverseFields } from './traverseFields.js';
3
3
  /**
4
4
  * This function is responsible for the following actions, in order:
@@ -8,7 +8,7 @@ import { traverseFields } from './traverseFields.js';
8
8
  * - Merge original document data into incoming data
9
9
  * - Compute default values for undefined fields
10
10
  */ export const beforeValidate = async ({ id, collection, context, data: incomingData, doc, global, operation, overrideAccess, req })=>{
11
- const data = deepCopyObject(incomingData);
11
+ const data = deepCopyObjectSimple(incomingData);
12
12
  await traverseFields({
13
13
  id,
14
14
  collection,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/index.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequest, RequestContext } from '../../../types/index.js'\n\nimport { deepCopyObject } from '../../../utilities/deepCopyObject.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args<T> = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: Record<string, unknown> | T\n doc?: Record<string, unknown> | T\n duplicate?: boolean\n global: SanitizedGlobalConfig | null\n id?: number | string\n operation: 'create' | 'update'\n overrideAccess: boolean\n req: PayloadRequest\n}\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 beforeValidate = async <T extends Record<string, unknown>>({\n id,\n collection,\n context,\n data: incomingData,\n doc,\n global,\n operation,\n overrideAccess,\n req,\n}: Args<T>): Promise<T> => {\n const data = deepCopyObject(incomingData)\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: collection?.fields || global?.fields,\n global,\n operation,\n overrideAccess,\n path: [],\n req,\n schemaPath: [],\n siblingData: data,\n siblingDoc: doc,\n })\n\n return data\n}\n"],"names":["deepCopyObject","traverseFields","beforeValidate","id","collection","context","data","incomingData","doc","global","operation","overrideAccess","req","fields","path","schemaPath","siblingData","siblingDoc"],"mappings":"AAIA,SAASA,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,sBAAqB;AAepD;;;;;;;CAOC,GACD,OAAO,MAAMC,iBAAiB,OAA0C,EACtEC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,MAAMC,YAAY,EAClBC,GAAG,EACHC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,GAAG,EACK;IACR,MAAMN,OAAON,eAAeO;IAE5B,MAAMN,eAAe;QACnBE;QACAC;QACAC;QACAC;QACAE;QACAK,QAAQT,YAAYS,UAAUJ,QAAQI;QACtCJ;QACAC;QACAC;QACAG,MAAM,EAAE;QACRF;QACAG,YAAY,EAAE;QACdC,aAAaV;QACbW,YAAYT;IACd;IAEA,OAAOF;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/index.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { JsonObject, PayloadRequest, RequestContext } from '../../../types/index.js'\n\nimport { deepCopyObjectSimple } from '../../../utilities/deepCopyObject.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args<T extends JsonObject> = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: T\n doc?: T\n duplicate?: boolean\n global: SanitizedGlobalConfig | null\n id?: number | string\n operation: 'create' | 'update'\n overrideAccess: boolean\n req: PayloadRequest\n}\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 beforeValidate = async <T extends JsonObject>({\n id,\n collection,\n context,\n data: incomingData,\n doc,\n global,\n operation,\n overrideAccess,\n req,\n}: Args<T>): Promise<T> => {\n const data = deepCopyObjectSimple(incomingData)\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: collection?.fields || global?.fields,\n global,\n operation,\n overrideAccess,\n path: [],\n req,\n schemaPath: [],\n siblingData: data,\n siblingDoc: doc,\n })\n\n return data\n}\n"],"names":["deepCopyObjectSimple","traverseFields","beforeValidate","id","collection","context","data","incomingData","doc","global","operation","overrideAccess","req","fields","path","schemaPath","siblingData","siblingDoc"],"mappings":"AAIA,SAASA,oBAAoB,QAAQ,uCAAsC;AAC3E,SAASC,cAAc,QAAQ,sBAAqB;AAepD;;;;;;;CAOC,GACD,OAAO,MAAMC,iBAAiB,OAA6B,EACzDC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,MAAMC,YAAY,EAClBC,GAAG,EACHC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,GAAG,EACK;IACR,MAAMN,OAAON,qBAAqBO;IAElC,MAAMN,eAAe;QACnBE;QACAC;QACAC;QACAC;QACAE;QACAK,QAAQT,YAAYS,UAAUJ,QAAQI;QACtCJ;QACAC;QACAC;QACAG,MAAM,EAAE;QACRF;QACAG,YAAY,EAAE;QACdC,aAAaV;QACbW,YAAYT;IACd;IAEA,OAAOF;AACT,EAAC"}
@@ -1,6 +1,6 @@
1
1
  import type { SanitizedCollectionConfig } from '../../../collections/config/types.js';
2
2
  import type { SanitizedGlobalConfig } from '../../../globals/config/types.js';
3
- import type { PayloadRequest, RequestContext } from '../../../types/index.js';
3
+ import type { JsonObject, PayloadRequest, RequestContext } from '../../../types/index.js';
4
4
  import type { Field, TabAsField } from '../../config/types.js';
5
5
  type Args<T> = {
6
6
  collection: SanitizedCollectionConfig | null;
@@ -18,11 +18,11 @@ type Args<T> = {
18
18
  parentPath: (number | string)[];
19
19
  parentSchemaPath: string[];
20
20
  req: PayloadRequest;
21
- siblingData: Record<string, unknown>;
21
+ siblingData: JsonObject;
22
22
  /**
23
23
  * The original siblingData (not modified by any hooks)
24
24
  */
25
- siblingDoc: Record<string, unknown>;
25
+ siblingDoc: JsonObject;
26
26
  };
27
27
  export declare const promise: <T>({ id, collection, context, data, doc, field, global, operation, overrideAccess, parentPath, parentSchemaPath, req, siblingData, siblingDoc, }: Args<T>) => Promise<void>;
28
28
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeValidate/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,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7E,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAU9D,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,KAAK,EAAE,KAAK,GAAG,UAAU,CAAA;IACzB,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,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IAC/B,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,GAAG,EAAE,cAAc,CAAA;IACnB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC,CAAA;AASD,eAAO,MAAM,OAAO,GAAU,CAAC,iJAe5B,IAAI,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,IAAI,CA8bxB,CAAA"}
1
+ {"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeValidate/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,UAAU,EAAa,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACpG,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAU9D,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,KAAK,EAAE,KAAK,GAAG,UAAU,CAAA;IACzB,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,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IAC/B,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,GAAG,EAAE,cAAc,CAAA;IACnB,WAAW,EAAE,UAAU,CAAA;IACvB;;OAEG;IACH,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AASD,eAAO,MAAM,OAAO,GAAU,CAAC,iJAe5B,IAAI,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,IAAI,CA8bxB,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { MissingEditorProp } from '../../../errors/index.js';
2
2
  import { fieldAffectsData, tabHasName, valueIsValueWithRelation } from '../../config/types.js';
3
- import getValueWithDefault from '../../getDefaultValue.js';
3
+ import { getDefaultValue } from '../../getDefaultValue.js';
4
4
  import { getFieldPaths } from '../../getFieldPaths.js';
5
5
  import { cloneDataFromOriginalDoc } from '../beforeChange/cloneDataFromOriginalDoc.js';
6
6
  import { getExistingRowDoc } from '../beforeChange/getExistingRowDoc.js';
@@ -185,7 +185,7 @@ export const promise = async ({ id, collection, context, data, doc, field, globa
185
185
  siblingData[field.name] = cloneDataFromOriginalDoc(siblingDoc[field.name]);
186
186
  // Otherwise compute default value
187
187
  } else if (typeof field.defaultValue !== 'undefined') {
188
- siblingData[field.name] = await getValueWithDefault({
188
+ siblingData[field.name] = await getDefaultValue({
189
189
  defaultValue: field.defaultValue,
190
190
  locale: req.locale,
191
191
  user: req.user,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/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 { PayloadRequest, 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: PayloadRequest\n siblingData: Record<string, unknown>\n /**\n * The original siblingData (not modified by any hooks)\n */\n siblingDoc: Record<string, unknown>\n}\n\n// This function is responsible for the following actions, in order:\n// - Sanitize incoming data\n// - Execute field hooks\n// - Execute field access control\n// - Merge original document data into incoming data\n// - Compute default values for undefined fields\n\nexport const promise = async <T>({\n id,\n collection,\n context,\n data,\n doc,\n field,\n global,\n operation,\n overrideAccess,\n 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"],"mappings":"AAMA,SAASA,iBAAiB,QAAQ,2BAA0B;AAC5D,SAASC,gBAAgB,EAAEC,UAAU,EAAEC,wBAAwB,QAAQ,wBAAuB;AAC9F,OAAOC,yBAAyB,2BAA0B;AAC1D,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,wBAAwB,QAAQ,8CAA6C;AACtF,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,cAAc,QAAQ,sBAAqB;AAyBpD,oEAAoE;AACpE,2BAA2B;AAC3B,wBAAwB;AACxB,iCAAiC;AACjC,oDAAoD;AACpD,gDAAgD;AAEhD,OAAO,MAAMC,UAAU,OAAU,EAC/BC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,UAAU,EACVC,gBAAgB,EAChBC,GAAG,EACHC,WAAW,EACXC,UAAU,EACF;IACR,MAAM,EAAEC,MAAMC,SAAS,EAAEC,YAAYC,eAAe,EAAE,GAAGtB,cAAc;QACrEU;QACAI;QACAC;IACF;IAEA,IAAInB,iBAAiBc,QAAQ;QAC3B,IAAIA,MAAMa,IAAI,KAAK,MAAM;YACvB,IAAIb,MAAMc,IAAI,KAAK,YAAY,OAAOP,WAAW,CAACP,MAAMa,IAAI,CAAC,KAAK,UAAU;gBAC1E,MAAME,QAAQR,WAAW,CAACP,MAAMa,IAAI,CAAC;gBAErCN,WAAW,CAACP,MAAMa,IAAI,CAAC,GAAGG,WAAWD;YACvC;YAEA,IACEf,MAAMc,IAAI,KAAK,UACf,OAAOP,WAAW,CAACP,MAAMa,IAAI,CAAC,EAAEI,aAAa,cAC7C,OAAOV,WAAW,C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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"}
1
+ {"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/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 { JsonObject, JsonValue, PayloadRequest, 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 { getDefaultValue } 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: PayloadRequest\n siblingData: JsonObject\n /**\n * The original siblingData (not modified by any hooks)\n */\n siblingDoc: JsonObject\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: JsonValue }, 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] as any)\n\n // Otherwise compute default value\n } else if (typeof field.defaultValue !== 'undefined') {\n siblingData[field.name] = await getDefaultValue({\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 as JsonObject,\n siblingDoc: groupDoc as JsonObject,\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 as JsonObject,\n siblingDoc: getExistingRowDoc(row as JsonObject, 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 as JsonObject, siblingDoc[field.name])\n const blockTypeToMatch = (row as JsonObject).blockType || rowSiblingDoc.blockType\n const block = field.blocks.find((blockType) => blockType.slug === blockTypeToMatch)\n\n if (block) {\n ;(row as JsonObject).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 as JsonObject,\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","getDefaultValue","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"],"mappings":"AAMA,SAASA,iBAAiB,QAAQ,2BAA0B;AAC5D,SAASC,gBAAgB,EAAEC,UAAU,EAAEC,wBAAwB,QAAQ,wBAAuB;AAC9F,SAASC,eAAe,QAAQ,2BAA0B;AAC1D,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,wBAAwB,QAAQ,8CAA6C;AACtF,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,cAAc,QAAQ,sBAAqB;AAyBpD,oEAAoE;AACpE,2BAA2B;AAC3B,wBAAwB;AACxB,iCAAiC;AACjC,oDAAoD;AACpD,gDAAgD;AAEhD,OAAO,MAAMC,UAAU,OAAU,EAC/BC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,UAAU,EACVC,gBAAgB,EAChBC,GAAG,EACHC,WAAW,EACXC,UAAU,EACF;IACR,MAAM,EAAEC,MAAMC,SAAS,EAAEC,YAAYC,eAAe,EAAE,GAAGtB,cAAc;QACrEU;QACAI;QACAC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ig } from '../../../collections/config/types.js';
2
2
  import type { SanitizedGlobalConfig } from '../../../globals/config/types.js';
3
- import type { PayloadRequest, RequestContext } from '../../../types/index.js';
3
+ import type { JsonObject, PayloadRequest, RequestContext } from '../../../types/index.js';
4
4
  import type { Field, TabAsField } from '../../config/types.js';
5
5
  type Args<T> = {
6
6
  collection: SanitizedCollectionConfig | null;
@@ -18,11 +18,11 @@ type Args<T> = {
18
18
  path: (number | string)[];
19
19
  req: PayloadRequest;
20
20
  schemaPath: string[];
21
- siblingData: Record<string, unknown>;
21
+ siblingData: JsonObject;
22
22
  /**
23
23
  * The original siblingData (not modified by any hooks)
24
24
  */
25
- siblingDoc: Record<string, unknown>;
25
+ siblingDoc: JsonObject;
26
26
  };
27
27
  export declare const traverseFields: <T>({ id, collection, context, data, doc, fields, global, operation, overrideAccess, path, req, schemaPath, siblingData, siblingDoc, }: Args<T>) => Promise<void>;
28
28
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeValidate/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7E,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAI9D,KAAK,IAAI,CAAC,CAAC,IAAI;IACb,UAAU,EAAE,yBAAyB,GAAG,IAAI,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,CAAC,CAAA;IACP;;OAEG;IACH,GAAG,EAAE,CAAC,CAAA;IACN,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAA;IACpC,E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CAAA;IAC9B,cAAc,EAAE,OAAO,CAAA;IACvB,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IACzB,GAAG,EAAE,cAAc,CAAA;IACnB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,WAAW,EAAE,UAAU,CAAA;IACvB;;OAEG;IACH,UAAU,EAAE,UAAU,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,cAAc,GAAU,CAAC,sIAenC,IAAI,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,IAAI,CAuBxB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args<T> = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: T\n /**\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: PayloadRequest\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"],"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"}
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 { JsonObject, PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args<T> = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: T\n /**\n * The original data (not modified by any hooks)\n */\n doc: T\n fields: (Field | TabAsField)[]\n global: SanitizedGlobalConfig | null\n id?: number | string\n operation: 'create' | 'update'\n overrideAccess: boolean\n path: (number | string)[]\n req: PayloadRequest\n schemaPath: string[]\n siblingData: JsonObject\n /**\n * The original siblingData (not modified by any hooks)\n */\n siblingDoc: JsonObject\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"],"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"mergeBaseFields.d.ts","sourceRoot":"","sources":["../../src/fields/mergeBaseFields.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAsB,MAAM,mBAAmB,CAAA;AAIlE,QAAA,MAAM,eAAe,WAAY,KAAK,EAAE,cAAc,KAAK,EAAE,KAAG,KAAK,EAqCpE,CAAA;AAED,eAAe,eAAe,CAAA"}
1
+ {"version":3,"file":"mergeBaseFields.d.ts","sourceRoot":"","sources":["../../src/fields/mergeBaseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAsB,MAAM,mBAAmB,CAAA;AAKlE,QAAA,MAAM,eAAe,WAAY,KAAK,EAAE,cAAc,KAAK,EAAE,KAAG,KAAK,EAqCpE,CAAA;AAED,eAAe,eAAe,CAAA"}
@@ -1,4 +1,4 @@
1
- import merge from 'deepmerge';
1
+ import { deepMergeWithReactComponents } from '../utilities/deepMerge.js';
2
2
  import { fieldAffectsData, fieldHasSubFields } from './config/types.js';
3
3
  const mergeBaseFields = (fields, baseFields)=>{
4
4
  const mergedFields = [
@@ -19,7 +19,7 @@ const mergeBaseFields = (fields, baseFields)=>{
19
19
  ...match
20
20
  };
21
21
  mergedFields.splice(matchedIndex, 1);
22
- const mergedField = merge(baseField, matchCopy);
22
+ const mergedField = deepMergeWithReactComponents(baseField, matchCopy);
23
23
  if (fieldHasSubFields(baseField) && fieldHasSubFields(matchCopy)) {
24
24
  mergedField.fields = mergeBaseFields(matchCopy.fields, baseField.fields);
25
25
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/fields/mergeBaseFields.ts"],"sourcesContent":["import merge from 'deepmerge'\n\nimport type { Field, FieldWithSubFields } from './config/types.js'\n\nimport { fieldAffectsData, fieldHasSubFields } from './config/types.js'\n\nconst mergeBaseFields = (fields: Field[], baseFields: Field[]): Field[] => {\n const mergedFields = [...(fields || [])]\n\n baseFields.forEach((baseField) => {\n let matchedIndex = null\n\n if (fieldAffectsData(baseField)) {\n const match = mergedFields.find((field, i) => {\n if (fieldAffectsData(field) && field.name === baseField.name) {\n matchedIndex = i\n return true\n }\n\n return false\n })\n\n if (match) {\n const matchCopy: Field = { ...match }\n mergedFields.splice(matchedIndex, 1)\n\n const mergedField = merge<Field>(baseField, matchCopy)\n\n if (fieldHasSubFields(baseField) && fieldHasSubFields(matchCopy)) {\n ;(mergedField as FieldWithSubFields).fields = mergeBaseFields(\n matchCopy.fields,\n baseField.fields,\n )\n }\n\n mergedFields.push(mergedField)\n } else {\n mergedFields.push(baseField)\n }\n }\n })\n\n return mergedFields\n}\n\nexport default mergeBaseFields\n"],"names":["merge","fieldAffectsData","fieldHasSubFields","mergeBaseFields","fields","baseFields","mergedFields","forEach","baseField","matchedIndex","match","find","field","i","name","matchCopy","splice","mergedField","push"],"mappings":"AAAA,OAAOA,WAAW,YAAW;AAI7B,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,oBAAmB;AAEvE,MAAMC,kBAAkB,CAACC,QAAiBC;IACxC,MAAMC,eAAe;WAAKF,UAAU,EAAE;KAAE;IAExCC,WAAWE,OAAO,CAAC,CAACC;QAClB,IAAIC,eAAe;QAEnB,IAAIR,iBAAiBO,YAAY;YAC/B,MAAME,QAAQJ,aAAaK,IAAI,CAAC,CAACC,OAAOC;gBACtC,IAAIZ,iBAAiBW,UAAUA,MAAME,IAAI,KAAKN,UAAUM,IAAI,EAAE;oBAC5DL,eAAeI;oBACf,OAAO;gBACT;gBAEA,OAAO;YACT;YAEA,IAAIH,OAAO;gBACT,MAAMK,YAAmB;oBAAE,GAAGL,KAAK;gBAAC;gBACpCJ,aAAaU,MAAM,CAACP,cAAc;gBAElC,MAAMQ,cAAcjB,MAAaQ,WAAWO;gBAE5C,IAAIb,kBAAkBM,cAAcN,kBAAkBa,YAAY;oBAC9DE,YAAmCb,MAAM,GAAGD,gBAC5CY,UAAUX,MAAM,EAChBI,UAAUJ,MAAM;gBAEpB;gBAEAE,aAAaY,IAAI,CAACD;YACpB,OAAO;gBACLX,aAAaY,IAAI,CAACV;YACpB;QACF;IACF;IAEA,OAAOF;AACT;AAEA,eAAeH,gBAAe"}
1
+ {"version":3,"sources":["../../src/fields/mergeBaseFields.ts"],"sourcesContent":["import type { Field, FieldWithSubFields } from './config/types.js'\n\nimport { deepMergeWithReactComponents } from '../utilities/deepMerge.js'\nimport { fieldAffectsData, fieldHasSubFields } from './config/types.js'\n\nconst mergeBaseFields = (fields: Field[], baseFields: Field[]): Field[] => {\n const mergedFields = [...(fields || [])]\n\n baseFields.forEach((baseField) => {\n let matchedIndex = null\n\n if (fieldAffectsData(baseField)) {\n const match = mergedFields.find((field, i) => {\n if (fieldAffectsData(field) && field.name === baseField.name) {\n matchedIndex = i\n return true\n }\n\n return false\n })\n\n if (match) {\n const matchCopy: Field = { ...match }\n mergedFields.splice(matchedIndex, 1)\n\n const mergedField = deepMergeWithReactComponents<Field>(baseField, matchCopy)\n\n if (fieldHasSubFields(baseField) && fieldHasSubFields(matchCopy)) {\n ;(mergedField as FieldWithSubFields).fields = mergeBaseFields(\n matchCopy.fields,\n baseField.fields,\n )\n }\n\n mergedFields.push(mergedField)\n } else {\n mergedFields.push(baseField)\n }\n }\n })\n\n return mergedFields\n}\n\nexport default mergeBaseFields\n"],"names":["deepMergeWithReactComponents","fieldAffectsData","fieldHasSubFields","mergeBaseFields","fields","baseFields","mergedFields","forEach","baseField","matchedIndex","match","find","field","i","name","matchCopy","splice","mergedField","push"],"mappings":"AAEA,SAASA,4BAA4B,QAAQ,4BAA2B;AACxE,SAASC,gBAAgB,EAAEC,iBAAiB,QAAQ,oBAAmB;AAEvE,MAAMC,kBAAkB,CAACC,QAAiBC;IACxC,MAAMC,eAAe;WAAKF,UAAU,EAAE;KAAE;IAExCC,WAAWE,OAAO,CAAC,CAACC;QAClB,IAAIC,eAAe;QAEnB,IAAIR,iBAAiBO,YAAY;YAC/B,MAAME,QAAQJ,aAAaK,IAAI,CAAC,CAACC,OAAOC;gBACtC,IAAIZ,iBAAiBW,UAAUA,MAAME,IAAI,KAAKN,UAAUM,IAAI,EAAE;oBAC5DL,eAAeI;oBACf,OAAO;gBACT;gBAEA,OAAO;YACT;YAEA,IAAIH,OAAO;gBACT,MAAMK,YAAmB;oBAAE,GAAGL,KAAK;gBAAC;gBACpCJ,aAAaU,MAAM,CAACP,cAAc;gBAElC,MAAMQ,cAAcjB,6BAAoCQ,WAAWO;gBAEnE,IAAIb,kBAAkBM,cAAcN,kBAAkBa,YAAY;oBAC9DE,YAAmCb,MAAM,GAAGD,gBAC5CY,UAAUX,MAAM,EAChBI,UAAUJ,MAAM;gBAEpB;gBAEAE,aAAaY,IAAI,CAACD;YACpB,OAAO;gBACLX,aAAaY,IAAI,CAACV;YACpB;QACF;IACF;IAEA,OAAOF;AACT;AAEA,eAAeH,gBAAe"}
@@ -1 +1 @@
1
- {"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/findOne.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAS,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAS/D,KAAK,IAAI,GAAG;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,YAAY,EAAE,qBAAqB,CAAA;IACnC,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAU,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAChE,IAAI,KACT,OAAO,CAAC,CAAC,CAuHX,CAAA"}
1
+ {"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../../../src/globals/operations/findOne.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAS,MAAM,sBAAsB,CAAA;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAS/D,KAAK,IAAI,GAAG;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,YAAY,EAAE,qBAAqB,CAAA;IACnC,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED,eAAO,MAAM,gBAAgB,GAAU,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,QAChE,IAAI,KACT,OAAO,CAAC,CAAC,CAuHX,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/globals/operations/findOne.ts"],"sourcesContent":["import type { AccessResult } from '../../config/types.js'\nimport type { GeneratedTypes } from '../../index.js'\nimport type { PayloadRequest, Where } from '../../types/index.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport replaceWithDraftIfAvailable from '../../versions/drafts/replaceWithDraftIfAvailable.js'\n\ntype Args = {\n depth?: number\n draft?: boolean\n globalConfig: SanitizedGlobalConfig\n overrideAccess?: boolean\n req: PayloadRequest\n showHiddenFields?: boolean\n slug: string\n}\n\nexport const findOneOperation = async <T extends Record<string, unknown>>(\n args: Args,\n): Promise<T> => {\n const {\n slug,\n depth,\n draft: draftEnabled = false,\n globalConfig,\n overrideAccess = false,\n req: { fallbackLocale, locale },\n req,\n showHiddenFields,\n } = args\n\n try {\n const shouldCommit = await initTransaction(req)\n\n // /////////////////////////////////////\n // Retrieve and execute access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess({ req }, globalConfig.access.read)\n }\n\n // /////////////////////////////////////\n // Perform database operation\n // /////////////////////////////////////\n\n let doc = await req.payload.db.findGlobal({\n slug,\n locale,\n req,\n where: overrideAccess ? undefined : (accessResult as Where),\n })\n if (!doc) {\n doc = {}\n }\n\n // /////////////////////////////////////\n // Replace document with draft if available\n // /////////////////////////////////////\n\n if (globalConfig.versions?.drafts && draftEnabled) {\n doc = await replaceWithDraftIfAvailable({\n accessResult,\n doc,\n entity: globalConfig,\n entityType: 'global',\n overrideAccess,\n req,\n })\n }\n\n // /////////////////////////////////////\n // Execute before global hook\n // /////////////////////////////////////\n\n await globalConfig.hooks.beforeRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n doc =\n (await hook({\n context: req.context,\n doc,\n global: globalConfig,\n req,\n })) || doc\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // Execute field-level hooks and access\n // /////////////////////////////////////\n\n doc = await afterRead({\n collection: null,\n context: req.context,\n depth,\n doc,\n draft: draftEnabled,\n fallbackLocale,\n global: globalConfig,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // Execute after global hook\n // /////////////////////////////////////\n\n await globalConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n doc =\n (await hook({\n context: req.context,\n doc,\n global: globalConfig,\n req,\n })) || doc\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n if (shouldCommit) await commitTransaction(req)\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return doc\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","afterRead","commitTransaction","initTransaction","killTransaction","replaceWithDraftIfAvailable","findOneOperation","args","slug","depth","draft","draftEnabled","globalConfig","overrideAccess","req","fallbackLocale","locale","showHiddenFields","shouldCommit","accessResult","access","read","doc","payload","db","findGlobal","where","undefined","versions","drafts","entity","entityType","hooks","beforeRead","reduce","priorHook","hook","context","global","Promise","resolve","collection","error"],"mappings":"AAKA,OAAOA,mBAAmB,8BAA6B;AACvD,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,OAAOC,iCAAiC,uDAAsD;AAY9F,OAAO,MAAMC,mBAAmB,OAC9BC;IAEA,MAAM,EACJC,IAAI,EACJC,KAAK,EACLC,OAAOC,eAAe,KAAK,EAC3BC,YAAY,EACZC,iBAAiB,KAAK,EACtBC,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B,KAAK,CAAC/B,SAAS,CAACiC,MAAM,CAAC,OAAOC,WAAWC;YAC1D,MAAMD;YAENb,MACE,AAAC,MAAMc,KAAK;gBACVC,SAASvB,IAAIuB,OAAO;gBACpBf;gBACAgB,QAAQ1B;gBACRE;YACF,MAAOQ;QACX,GAAGiB,QAAQC,OAAO;QAElB,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,IAAItB,cAAc,MAAMhB,kBAAkBY;QAE1C,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,OAAOQ;IACT,EAAE,OAAOoB,OAAgB;QACvB,MAAMtC,gBAAgBU;QACtB,MAAM4B;IACR;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/globals/operations/findOne.ts"],"sourcesContent":["import type { AccessResult } from '../../config/types.js'\nimport type { PayloadRequest, Where } from '../../types/index.js'\nimport type { SanitizedGlobalConfig } from '../config/types.js'\n\nimport executeAccess from '../../auth/executeAccess.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport replaceWithDraftIfAvailable from '../../versions/drafts/replaceWithDraftIfAvailable.js'\n\ntype Args = {\n depth?: number\n draft?: boolean\n globalConfig: SanitizedGlobalConfig\n overrideAccess?: boolean\n req: PayloadRequest\n showHiddenFields?: boolean\n slug: string\n}\n\nexport const findOneOperation = async <T extends Record<string, unknown>>(\n args: Args,\n): Promise<T> => {\n const {\n slug,\n depth,\n draft: draftEnabled = false,\n globalConfig,\n overrideAccess = false,\n req: { fallbackLocale, locale },\n req,\n showHiddenFields,\n } = args\n\n try {\n const shouldCommit = await initTransaction(req)\n\n // /////////////////////////////////////\n // Retrieve and execute access\n // /////////////////////////////////////\n\n let accessResult: AccessResult\n\n if (!overrideAccess) {\n accessResult = await executeAccess({ req }, globalConfig.access.read)\n }\n\n // /////////////////////////////////////\n // Perform database operation\n // /////////////////////////////////////\n\n let doc = await req.payload.db.findGlobal({\n slug,\n locale,\n req,\n where: overrideAccess ? undefined : (accessResult as Where),\n })\n if (!doc) {\n doc = {}\n }\n\n // /////////////////////////////////////\n // Replace document with draft if available\n // /////////////////////////////////////\n\n if (globalConfig.versions?.drafts && draftEnabled) {\n doc = await replaceWithDraftIfAvailable({\n accessResult,\n doc,\n entity: globalConfig,\n entityType: 'global',\n overrideAccess,\n req,\n })\n }\n\n // /////////////////////////////////////\n // Execute before global hook\n // /////////////////////////////////////\n\n await globalConfig.hooks.beforeRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n doc =\n (await hook({\n context: req.context,\n doc,\n global: globalConfig,\n req,\n })) || doc\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // Execute field-level hooks and access\n // /////////////////////////////////////\n\n doc = await afterRead({\n collection: null,\n context: req.context,\n depth,\n doc,\n draft: draftEnabled,\n fallbackLocale,\n global: globalConfig,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n })\n\n // /////////////////////////////////////\n // Execute after global hook\n // /////////////////////////////////////\n\n await globalConfig.hooks.afterRead.reduce(async (priorHook, hook) => {\n await priorHook\n\n doc =\n (await hook({\n context: req.context,\n doc,\n global: globalConfig,\n req,\n })) || doc\n }, Promise.resolve())\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n if (shouldCommit) await commitTransaction(req)\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n return doc\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","afterRead","commitTransaction","initTransaction","killTransaction","replaceWithDraftIfAvailable","findOneOperation","args","slug","depth","draft","draftEnabled","globalConfig","overrideAccess","req","fallbackLocale","locale","showHiddenFields","shouldCommit","accessResult","access","read","doc","payload","db","findGlobal","where","undefined","versions","drafts","entity","entityType","hooks","beforeRead","reduce","priorHook","hook","context","global","Promise","resolve","collection","error"],"mappings":"AAIA,OAAOA,mBAA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