payload 3.0.0-beta.67 → 3.0.0-beta.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/RichText.d.ts +4 -4
- package/dist/admin/RichText.d.ts.map +1 -1
- package/dist/admin/RichText.js.map +1 -1
- package/dist/auth/baseFields/email.js +1 -1
- package/dist/auth/baseFields/email.js.map +1 -1
- package/dist/auth/operations/resetPassword.js +1 -1
- package/dist/auth/operations/resetPassword.js.map +1 -1
- package/dist/auth/strategies/jwt.d.ts.map +1 -1
- package/dist/auth/strategies/jwt.js +29 -0
- package/dist/auth/strategies/jwt.js.map +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.d.ts.map +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.js +1 -1
- package/dist/auth/strategies/local/incrementLoginAttempts.js.map +1 -1
- package/dist/auth/strategies/local/register.d.ts +2 -2
- package/dist/auth/strategies/local/register.d.ts.map +1 -1
- package/dist/auth/strategies/local/register.js.map +1 -1
- package/dist/bin/generateTypes.js +2 -2
- package/dist/bin/generateTypes.js.map +1 -1
- package/dist/collections/config/client.d.ts.map +1 -1
- package/dist/collections/config/client.js +1 -0
- package/dist/collections/config/client.js.map +1 -1
- package/dist/collections/config/defaults.d.ts +4 -69
- package/dist/collections/config/defaults.d.ts.map +1 -1
- package/dist/collections/config/defaults.js.map +1 -1
- package/dist/collections/config/reservedFieldNames.d.ts +15 -0
- package/dist/collections/config/reservedFieldNames.d.ts.map +1 -0
- package/dist/collections/config/reservedFieldNames.js +104 -0
- package/dist/collections/config/reservedFieldNames.js.map +1 -0
- package/dist/collections/config/reservedFieldNames.spec.js +148 -0
- package/dist/collections/config/reservedFieldNames.spec.js.map +1 -0
- package/dist/collections/config/sanitize.d.ts.map +1 -1
- package/dist/collections/config/sanitize.js +13 -9
- package/dist/collections/config/sanitize.js.map +1 -1
- package/dist/collections/config/types.d.ts +2 -2
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/dataloader.d.ts.map +1 -1
- package/dist/collections/dataloader.js.map +1 -1
- package/dist/collections/operations/create.d.ts.map +1 -1
- package/dist/collections/operations/create.js.map +1 -1
- package/dist/collections/operations/deleteByID.d.ts.map +1 -1
- package/dist/collections/operations/deleteByID.js.map +1 -1
- package/dist/collections/operations/duplicate.js.map +1 -1
- package/dist/collections/operations/update.js.map +1 -1
- package/dist/collections/operations/updateByID.js.map +1 -1
- package/dist/config/client.d.ts.map +1 -1
- package/dist/config/client.js +26 -26
- package/dist/config/client.js.map +1 -1
- package/dist/config/sanitize.d.ts.map +1 -1
- package/dist/config/sanitize.js +6 -7
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/types.d.ts +7 -5
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/database/migrations/getPredefinedMigration.d.ts.map +1 -1
- package/dist/database/migrations/getPredefinedMigration.js +5 -2
- package/dist/database/migrations/getPredefinedMigration.js.map +1 -1
- package/dist/errors/APIError.d.ts +1 -0
- package/dist/errors/APIError.d.ts.map +1 -1
- package/dist/errors/APIError.js +3 -0
- package/dist/errors/APIError.js.map +1 -1
- package/dist/errors/ValidationError.d.ts +1 -0
- package/dist/errors/ValidationError.d.ts.map +1 -1
- package/dist/errors/ValidationError.js +3 -0
- package/dist/errors/ValidationError.js.map +1 -1
- package/dist/errors/index.d.ts +2 -2
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +2 -2
- package/dist/errors/index.js.map +1 -1
- package/dist/exports/components/utilities.d.ts +2 -0
- package/dist/exports/components/utilities.d.ts.map +1 -0
- package/dist/exports/components/utilities.js +2 -0
- package/dist/exports/components/utilities.js.map +1 -0
- package/dist/exports/shared.d.ts +3 -2
- package/dist/exports/shared.d.ts.map +1 -1
- package/dist/exports/shared.js +3 -2
- package/dist/exports/shared.js.map +1 -1
- package/dist/fields/config/client.d.ts.map +1 -1
- package/dist/fields/config/sanitize.d.ts +3 -2
- package/dist/fields/config/sanitize.d.ts.map +1 -1
- package/dist/fields/config/sanitize.js +8 -16
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/fields/config/sanitize.spec.js +1 -17
- package/dist/fields/config/sanitize.spec.js.map +1 -1
- package/dist/fields/config/types.d.ts +1 -0
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/getDefaultValue.d.ts +5 -5
- package/dist/fields/getDefaultValue.d.ts.map +1 -1
- package/dist/fields/getDefaultValue.js +4 -6
- package/dist/fields/getDefaultValue.js.map +1 -1
- package/dist/fields/hooks/afterChange/index.d.ts +6 -6
- package/dist/fields/hooks/afterChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/index.js +2 -2
- package/dist/fields/hooks/afterChange/index.js.map +1 -1
- package/dist/fields/hooks/afterChange/promise.d.ts +7 -7
- package/dist/fields/hooks/afterChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/promise.js.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.d.ts +7 -7
- package/dist/fields/hooks/afterChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/afterRead/index.d.ts +4 -4
- package/dist/fields/hooks/afterRead/index.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/index.js +2 -2
- package/dist/fields/hooks/afterRead/index.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.d.ts +3 -3
- package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js +2 -2
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.d.ts +3 -3
- package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/afterRead/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeChange/cloneDataFromOriginalDoc.d.ts +2 -1
- package/dist/fields/hooks/beforeChange/cloneDataFromOriginalDoc.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/cloneDataFromOriginalDoc.js.map +1 -1
- package/dist/fields/hooks/beforeChange/getExistingRowDoc.d.ts +2 -1
- package/dist/fields/hooks/beforeChange/getExistingRowDoc.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/getExistingRowDoc.js.map +1 -1
- package/dist/fields/hooks/beforeChange/index.d.ts +6 -6
- package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/index.js +2 -2
- package/dist/fields/hooks/beforeChange/index.js.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.d.ts +7 -7
- package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.js +3 -7
- package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts +7 -7
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.d.ts +5 -5
- package/dist/fields/hooks/beforeValidate/index.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/index.js +2 -2
- package/dist/fields/hooks/beforeValidate/index.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.d.ts +3 -3
- package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/promise.js +2 -2
- package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts +3 -3
- package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeValidate/traverseFields.js.map +1 -1
- package/dist/fields/mergeBaseFields.d.ts.map +1 -1
- package/dist/fields/mergeBaseFields.js +2 -2
- package/dist/fields/mergeBaseFields.js.map +1 -1
- package/dist/fields/validations.d.ts.map +1 -1
- package/dist/globals/operations/findOne.d.ts.map +1 -1
- package/dist/globals/operations/findOne.js.map +1 -1
- package/dist/globals/operations/findVersionByID.d.ts.map +1 -1
- package/dist/globals/operations/findVersionByID.js +2 -1
- package/dist/globals/operations/findVersionByID.js.map +1 -1
- package/dist/globals/operations/findVersions.js.map +1 -1
- package/dist/globals/operations/update.d.ts.map +1 -1
- package/dist/globals/operations/update.js +2 -1
- package/dist/globals/operations/update.js.map +1 -1
- package/dist/index.d.ts +11 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -12
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +8 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/uploads/cropImage.d.ts +4 -1
- package/dist/uploads/cropImage.d.ts.map +1 -1
- package/dist/uploads/cropImage.js +8 -2
- package/dist/uploads/cropImage.js.map +1 -1
- package/dist/uploads/generateFileData.d.ts.map +1 -1
- package/dist/uploads/generateFileData.js +12 -3
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/uploads/imageResizer.d.ts +3 -1
- package/dist/uploads/imageResizer.d.ts.map +1 -1
- package/dist/uploads/imageResizer.js +29 -20
- package/dist/uploads/imageResizer.js.map +1 -1
- package/dist/uploads/optionallyAppendMetadata.d.ts +12 -0
- package/dist/uploads/optionallyAppendMetadata.d.ts.map +1 -0
- package/dist/uploads/optionallyAppendMetadata.js +15 -0
- package/dist/uploads/optionallyAppendMetadata.js.map +1 -0
- package/dist/uploads/types.d.ts +12 -0
- package/dist/uploads/types.d.ts.map +1 -1
- package/dist/uploads/types.js.map +1 -1
- package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
- package/dist/utilities/configToJSONSchema.js +105 -72
- package/dist/utilities/configToJSONSchema.js.map +1 -1
- package/dist/utilities/createLocalReq.d.ts.map +1 -1
- package/dist/utilities/createLocalReq.js +2 -1
- package/dist/utilities/createLocalReq.js.map +1 -1
- package/dist/utilities/deepCopyObject.d.ts +18 -1
- package/dist/utilities/deepCopyObject.d.ts.map +1 -1
- package/dist/utilities/deepCopyObject.js +147 -16
- package/dist/utilities/deepCopyObject.js.map +1 -1
- package/dist/utilities/deepMerge.d.ts +18 -1
- package/dist/utilities/deepMerge.d.ts.map +1 -1
- package/dist/utilities/deepMerge.js +38 -13
- package/dist/utilities/deepMerge.js.map +1 -1
- package/dist/utilities/isPlainObject.d.ts +1 -1
- package/dist/utilities/isPlainObject.d.ts.map +1 -1
- package/dist/utilities/isPlainObject.js +4 -18
- package/dist/utilities/isPlainObject.js.map +1 -1
- package/dist/utilities/logger.d.ts +5 -7
- package/dist/utilities/logger.d.ts.map +1 -1
- package/dist/utilities/logger.js +4 -7
- package/dist/utilities/logger.js.map +1 -1
- package/dist/utilities/telemetry/events/adminInit.d.ts.map +1 -1
- package/dist/utilities/telemetry/events/adminInit.js.map +1 -1
- package/dist/versions/baseFields.d.ts.map +1 -1
- package/dist/versions/baseFields.js +1 -0
- package/dist/versions/baseFields.js.map +1 -1
- package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts.map +1 -1
- package/dist/versions/drafts/replaceWithDraftIfAvailable.js +2 -1
- package/dist/versions/drafts/replaceWithDraftIfAvailable.js.map +1 -1
- package/dist/versions/enforceMaxVersions.d.ts.map +1 -1
- package/dist/versions/enforceMaxVersions.js +2 -0
- package/dist/versions/enforceMaxVersions.js.map +1 -1
- package/dist/versions/saveVersion.js +2 -2
- package/dist/versions/saveVersion.js.map +1 -1
- package/package.json +5 -7
- package/dist/collections/config/schema.d.ts +0 -4
- package/dist/collections/config/schema.d.ts.map +0 -1
- package/dist/collections/config/schema.js +0 -191
- package/dist/collections/config/schema.js.map +0 -1
- package/dist/config/schema.d.ts +0 -5
- package/dist/config/schema.d.ts.map +0 -1
- package/dist/config/schema.js +0 -179
- package/dist/config/schema.js.map +0 -1
- package/dist/config/shared/adminViewSchema.d.ts +0 -3
- package/dist/config/shared/adminViewSchema.d.ts.map +0 -1
- package/dist/config/shared/adminViewSchema.js +0 -11
- package/dist/config/shared/adminViewSchema.js.map +0 -1
- package/dist/config/shared/componentSchema.d.ts +0 -16
- package/dist/config/shared/componentSchema.d.ts.map +0 -1
- package/dist/config/shared/componentSchema.js +0 -27
- package/dist/config/shared/componentSchema.js.map +0 -1
- package/dist/config/shared/openGraphSchema.d.ts +0 -3
- package/dist/config/shared/openGraphSchema.d.ts.map +0 -1
- package/dist/config/shared/openGraphSchema.js +0 -16
- package/dist/config/shared/openGraphSchema.js.map +0 -1
- package/dist/config/validate.d.ts +0 -4
- package/dist/config/validate.d.ts.map +0 -1
- package/dist/config/validate.js +0 -89
- package/dist/config/validate.js.map +0 -1
- package/dist/fields/config/schema.d.ts +0 -29
- package/dist/fields/config/schema.d.ts.map +0 -1
- package/dist/fields/config/schema.js +0 -508
- package/dist/fields/config/schema.js.map +0 -1
- package/dist/globals/config/schema.d.ts +0 -4
- package/dist/globals/config/schema.d.ts.map +0 -1
- package/dist/globals/config/schema.js +0 -79
- package/dist/globals/config/schema.js.map +0 -1
- package/dist/utilities/combineMerge.d.ts +0 -2
- package/dist/utilities/combineMerge.d.ts.map +0 -1
- package/dist/utilities/combineMerge.js +0 -16
- package/dist/utilities/combineMerge.js.map +0 -1
- package/dist/utilities/convertData.d.ts +0 -5
- package/dist/utilities/convertData.d.ts.map +0 -1
- package/dist/utilities/convertData.js +0 -16
- package/dist/utilities/convertData.js.map +0 -1
- package/dist/utilities/getCSSVariable.d.ts +0 -3
- package/dist/utilities/getCSSVariable.d.ts.map +0 -1
- package/dist/utilities/getCSSVariable.js +0 -3
- package/dist/utilities/getCSSVariable.js.map +0 -1
- package/dist/utilities/overwriteMerge.d.ts +0 -3
- package/dist/utilities/overwriteMerge.d.ts.map +0 -1
- package/dist/utilities/overwriteMerge.js +0 -4
- package/dist/utilities/overwriteMerge.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/afterRead/promise.ts"],"sourcesContent":["import type { RichTextAdapter } from '../../../admin/RichText.js'\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { MissingEditorProp } from '../../../errors/index.js'\nimport { fieldAffectsData, tabHasName } from '../../config/types.js'\nimport getValueWithDefault from '../../getDefaultValue.js'\nimport { getFieldPaths } from '../../getFieldPaths.js'\nimport { relationshipPopulationPromise } from './relationshipPopulationPromise.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n currentDepth: number\n depth: number\n doc: Record<string, unknown>\n draft: boolean\n fallbackLocale: null | string\n field: Field | TabAsField\n /**\n * fieldPromises are used for things like field hooks. They should be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n global: SanitizedGlobalConfig | null\n locale: null | string\n overrideAccess: boolean\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 populationPromises: Promise<void>[]\n req: PayloadRequest\n showHiddenFields: boolean\n siblingDoc: Record<string, unknown>\n triggerAccessControl?: boolean\n triggerHooks?: boolean\n}\n\n// This function is responsible for the following actions, in order:\n// - Remove hidden fields from response\n// - Flatten locales into requested locale\n// - Sanitize outgoing data (point field, etc.)\n// - Execute field hooks\n// - Execute read access control\n// - Populate relationships\n\nexport const promise = async ({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentPath,\n parentSchemaPath,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl = true,\n triggerHooks = true,\n}: Args): Promise<void> => {\n const { path: fieldPath, schemaPath: fieldSchemaPath } = getFieldPaths({\n field,\n parentPath,\n parentSchemaPath,\n })\n\n if (\n fieldAffectsData(field) &&\n field.hidden &&\n typeof siblingDoc[field.name] !== 'undefined' &&\n !showHiddenFields\n ) {\n delete siblingDoc[field.name]\n }\n\n const shouldHoistLocalizedValue =\n flattenLocales &&\n fieldAffectsData(field) &&\n typeof siblingDoc[field.name] === 'object' &&\n siblingDoc[field.name] !== null &&\n field.localized &&\n locale !== 'all' &&\n req.payload.config.localization\n\n if (shouldHoistLocalizedValue) {\n // replace actual value with localized value before sanitizing\n // { [locale]: fields } -> fields\n const value = siblingDoc[field.name][locale]\n\n let hoistedValue = value\n\n if (fallbackLocale && fallbackLocale !== locale) {\n const fallbackValue = siblingDoc[field.name][fallbackLocale]\n const isNullOrUndefined = typeof value === 'undefined' || value === null\n\n if (fallbackValue) {\n switch (field.type) {\n case 'text':\n case 'textarea': {\n if (value === '' || isNullOrUndefined) {\n hoistedValue = fallbackValue\n }\n break\n }\n\n default: {\n if (isNullOrUndefined) {\n hoistedValue = fallbackValue\n }\n break\n }\n }\n }\n }\n\n siblingDoc[field.name] = hoistedValue\n }\n\n // Sanitize outgoing field value\n switch (field.type) {\n case 'group': {\n // Fill groups with empty objects so fields with hooks within groups can populate\n // themselves virtually as necessary\n if (typeof siblingDoc[field.name] === 'undefined') {\n siblingDoc[field.name] = {}\n }\n\n break\n }\n case 'tabs': {\n field.tabs.forEach((tab) => {\n if (\n tabHasName(tab) &&\n (typeof siblingDoc[tab.name] === 'undefined' || siblingDoc[tab.name] === null)\n ) {\n siblingDoc[tab.name] = {}\n }\n })\n\n break\n }\n\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n if (typeof field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n // Rich Text fields should use afterRead hooks to do population. The previous editor.populationPromises have been renamed to editor.graphQLPopulationPromises\n break\n }\n\n case 'point': {\n const pointDoc = siblingDoc[field.name] as Record<string, unknown>\n if (Array.isArray(pointDoc?.coordinates) && pointDoc.coordinates.length === 2) {\n siblingDoc[field.name] = pointDoc.coordinates\n } else {\n siblingDoc[field.name] = undefined\n }\n\n break\n }\n\n default: {\n break\n }\n }\n\n if (fieldAffectsData(field)) {\n // Execute hooks\n if (triggerHooks && field.hooks?.afterRead) {\n await field.hooks.afterRead.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const shouldRunHookOnAllLocales =\n field.localized &&\n (locale === 'all' || !flattenLocales) &&\n typeof siblingDoc[field.name] === 'object'\n\n if (shouldRunHookOnAllLocales) {\n const hookPromises = Object.entries(siblingDoc[field.name]).map(([locale, value]) =>\n (async () => {\n const hookedValue = await currentHook({\n collection,\n context,\n data: doc,\n field,\n findMany,\n global,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: siblingDoc,\n value,\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name][locale] = hookedValue\n }\n })(),\n )\n\n await Promise.all(hookPromises)\n } else {\n const hookedValue = await currentHook({\n collection,\n context,\n data: doc,\n field,\n findMany,\n global,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: siblingDoc,\n value: siblingDoc[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }\n }, Promise.resolve())\n }\n\n // Execute access control\n let allowDefaultValue = true\n if (triggerAccessControl && field.access && field.access.read) {\n const result = overrideAccess\n ? true\n : await field.access.read({\n id: doc.id as number | string,\n data: doc,\n doc,\n req,\n siblingData: siblingDoc,\n })\n\n if (!result) {\n allowDefaultValue = false\n delete siblingDoc[field.name]\n }\n }\n\n // Set defaultValue on the field for globals being returned without being first created\n // or collection documents created prior to having a default\n if (\n allowDefaultValue &&\n typeof siblingDoc[field.name] === 'undefined' &&\n typeof field.defaultValue !== 'undefined'\n ) {\n siblingDoc[field.name] = await getValueWithDefault({\n defaultValue: field.defaultValue,\n locale,\n user: req.user,\n value: siblingDoc[field.name],\n })\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n populationPromises.push(\n relationshipPopulationPromise({\n currentDepth,\n depth,\n draft,\n fallbackLocale,\n field,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n siblingDoc,\n }),\n )\n }\n }\n\n switch (field.type) {\n case 'group': {\n let groupDoc = siblingDoc[field.name] as Record<string, unknown>\n if (typeof siblingDoc[field.name] !== 'object') groupDoc = {}\n\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: groupDoc,\n triggerAccessControl,\n triggerHooks,\n })\n\n break\n }\n\n case 'array': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n rows.forEach((row, i) => {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: [...fieldPath, i],\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: row || {},\n triggerAccessControl,\n triggerHooks,\n })\n })\n } else if (!shouldHoistLocalizedValue && typeof rows === 'object' && rows !== null) {\n Object.values(rows).forEach((localeRows) => {\n if (Array.isArray(localeRows)) {\n localeRows.forEach((row, i) => {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: [...fieldPath, i],\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: row || {},\n triggerAccessControl,\n triggerHooks,\n })\n })\n }\n })\n } else {\n siblingDoc[field.name] = []\n }\n break\n }\n\n case 'blocks': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n rows.forEach((row, i) => {\n const block = field.blocks.find((blockType) => blockType.slug === row.blockType)\n\n if (block) {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: block.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: [...fieldPath, i],\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: row || {},\n triggerAccessControl,\n triggerHooks,\n })\n }\n })\n } else if (!shouldHoistLocalizedValue && typeof rows === 'object' && rows !== null) {\n Object.values(rows).forEach((localeRows) => {\n if (Array.isArray(localeRows)) {\n localeRows.forEach((row, i) => {\n const block = field.blocks.find((blockType) => blockType.slug === row.blockType)\n\n if (block) {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: block.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: [...fieldPath, i],\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: row || {},\n triggerAccessControl,\n triggerHooks,\n })\n }\n })\n }\n })\n } else {\n siblingDoc[field.name] = []\n }\n\n break\n }\n\n case 'row':\n case 'collapsible': {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl,\n triggerHooks,\n })\n\n break\n }\n\n case 'tab': {\n let tabDoc = siblingDoc\n if (tabHasName(field)) {\n tabDoc = siblingDoc[field.name] as Record<string, unknown>\n if (typeof siblingDoc[field.name] !== 'object') tabDoc = {}\n }\n\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: tabDoc,\n triggerAccessControl,\n triggerHooks,\n })\n\n break\n }\n\n case 'tabs': {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl,\n triggerHooks,\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?.afterRead?.length) {\n await editor.hooks.afterRead.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const shouldRunHookOnAllLocales =\n field.localized &&\n (locale === 'all' || !flattenLocales) &&\n typeof siblingDoc[field.name] === 'object'\n\n if (shouldRunHookOnAllLocales) {\n const hookPromises = Object.entries(siblingDoc[field.name]).map(([locale, value]) =>\n (async () => {\n const hookedValue = await currentHook({\n collection,\n context,\n currentDepth,\n data: doc,\n depth,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingData: siblingDoc,\n triggerAccessControl,\n triggerHooks,\n value,\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name][locale] = hookedValue\n }\n })(),\n )\n\n await Promise.all(hookPromises)\n } else {\n const hookedValue = await currentHook({\n collection,\n context,\n currentDepth,\n data: doc,\n depth,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingData: siblingDoc,\n triggerAccessControl,\n triggerHooks,\n value: siblingDoc[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }\n }, Promise.resolve())\n }\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","fieldAffectsData","tabHasName","getValueWithDefault","getFieldPaths","relationshipPopulationPromise","traverseFields","promise","collection","context","currentDepth","depth","doc","draft","fallbackLocale","field","fieldPromises","findMany","flattenLocales","global","locale","overrideAccess","parentPath","parentSchemaPath","populationPromises","req","showHiddenFields","siblingDoc","triggerAccessControl","triggerHooks","path","fieldPath","schemaPath","fieldSchemaPath","hidden","name","shouldHoistLocalizedValue","localized","payload","config","localization","value","hoistedValue","fallbackValue","isNullOrUndefined","type","tabs","forEach","tab","editor","Error","pointDoc","Array","isArray","coordinates","length","undefined","hooks","afterRead","reduce","priorHook","currentHook","shouldRunHookOnAllLocales","hookPromises","Object","entries","map","hookedValue","data","operation","originalDoc","siblingData","Promise","all","resolve","allowDefaultValue","access","read","result","id","defaultValue","user","push","groupDoc","fields","rows","row","i","values","localeRows","block","blocks","find","blockType","slug","tabDoc"],"mappings":"AAMA,SAASA,iBAAiB,QAAQ,2BAA0B;AAC5D,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,wBAAuB;AACpE,OAAOC,yBAAyB,2BAA0B;AAC1D,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,6BAA6B,QAAQ,qCAAoC;AAClF,SAASC,cAAc,QAAQ,sBAAqB;AAoCpD,oEAAoE;AACpE,uCAAuC;AACvC,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AIgC,gBAAgBX,WAAW;gCAC7B7B,UAAU,CAACZ,MAAMoB,IAAI,CAAC,GAAGgC;4BAC3B;wBACF;oBACF,GAAGK,QAAQE,OAAO;gBACpB;gBACA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/afterRead/promise.ts"],"sourcesContent":["import type { RichTextAdapter } from '../../../admin/RichText.js'\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { JsonObject, PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { MissingEditorProp } from '../../../errors/index.js'\nimport { fieldAffectsData, tabHasName } from '../../config/types.js'\nimport { getDefaultValue } from '../../getDefaultValue.js'\nimport { getFieldPaths } from '../../getFieldPaths.js'\nimport { relationshipPopulationPromise } from './relationshipPopulationPromise.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n currentDepth: number\n depth: number\n doc: JsonObject\n draft: boolean\n fallbackLocale: null | string\n field: Field | TabAsField\n /**\n * fieldPromises are used for things like field hooks. They should be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n findMany: boolean\n flattenLocales: boolean\n global: SanitizedGlobalConfig | null\n locale: null | string\n overrideAccess: boolean\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 populationPromises: Promise<void>[]\n req: PayloadRequest\n showHiddenFields: boolean\n siblingDoc: JsonObject\n triggerAccessControl?: boolean\n triggerHooks?: boolean\n}\n\n// This function is responsible for the following actions, in order:\n// - Remove hidden fields from response\n// - Flatten locales into requested locale\n// - Sanitize outgoing data (point field, etc.)\n// - Execute field hooks\n// - Execute read access control\n// - Populate relationships\n\nexport const promise = async ({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentPath,\n parentSchemaPath,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl = true,\n triggerHooks = true,\n}: Args): Promise<void> => {\n const { path: fieldPath, schemaPath: fieldSchemaPath } = getFieldPaths({\n field,\n parentPath,\n parentSchemaPath,\n })\n\n if (\n fieldAffectsData(field) &&\n field.hidden &&\n typeof siblingDoc[field.name] !== 'undefined' &&\n !showHiddenFields\n ) {\n delete siblingDoc[field.name]\n }\n\n const shouldHoistLocalizedValue =\n flattenLocales &&\n fieldAffectsData(field) &&\n typeof siblingDoc[field.name] === 'object' &&\n siblingDoc[field.name] !== null &&\n field.localized &&\n locale !== 'all' &&\n req.payload.config.localization\n\n if (shouldHoistLocalizedValue) {\n // replace actual value with localized value before sanitizing\n // { [locale]: fields } -> fields\n const value = siblingDoc[field.name][locale]\n\n let hoistedValue = value\n\n if (fallbackLocale && fallbackLocale !== locale) {\n const fallbackValue = siblingDoc[field.name][fallbackLocale]\n const isNullOrUndefined = typeof value === 'undefined' || value === null\n\n if (fallbackValue) {\n switch (field.type) {\n case 'text':\n case 'textarea': {\n if (value === '' || isNullOrUndefined) {\n hoistedValue = fallbackValue\n }\n break\n }\n\n default: {\n if (isNullOrUndefined) {\n hoistedValue = fallbackValue\n }\n break\n }\n }\n }\n }\n\n siblingDoc[field.name] = hoistedValue\n }\n\n // Sanitize outgoing field value\n switch (field.type) {\n case 'group': {\n // Fill groups with empty objects so fields with hooks within groups can populate\n // themselves virtually as necessary\n if (typeof siblingDoc[field.name] === 'undefined') {\n siblingDoc[field.name] = {}\n }\n\n break\n }\n case 'tabs': {\n field.tabs.forEach((tab) => {\n if (\n tabHasName(tab) &&\n (typeof siblingDoc[tab.name] === 'undefined' || siblingDoc[tab.name] === null)\n ) {\n siblingDoc[tab.name] = {}\n }\n })\n\n break\n }\n\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n if (typeof field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n // Rich Text fields should use afterRead hooks to do population. The previous editor.populationPromises have been renamed to editor.graphQLPopulationPromises\n break\n }\n\n case 'point': {\n const pointDoc = siblingDoc[field.name] as Record<string, unknown>\n if (Array.isArray(pointDoc?.coordinates) && pointDoc.coordinates.length === 2) {\n siblingDoc[field.name] = pointDoc.coordinates\n } else {\n siblingDoc[field.name] = undefined\n }\n\n break\n }\n\n default: {\n break\n }\n }\n\n if (fieldAffectsData(field)) {\n // Execute hooks\n if (triggerHooks && field.hooks?.afterRead) {\n await field.hooks.afterRead.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const shouldRunHookOnAllLocales =\n field.localized &&\n (locale === 'all' || !flattenLocales) &&\n typeof siblingDoc[field.name] === 'object'\n\n if (shouldRunHookOnAllLocales) {\n const hookPromises = Object.entries(siblingDoc[field.name]).map(([locale, value]) =>\n (async () => {\n const hookedValue = await currentHook({\n collection,\n context,\n data: doc,\n field,\n findMany,\n global,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: siblingDoc,\n value,\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name][locale] = hookedValue\n }\n })(),\n )\n\n await Promise.all(hookPromises)\n } else {\n const hookedValue = await currentHook({\n collection,\n context,\n data: doc,\n field,\n findMany,\n global,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: siblingDoc,\n value: siblingDoc[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }\n }, Promise.resolve())\n }\n\n // Execute access control\n let allowDefaultValue = true\n if (triggerAccessControl && field.access && field.access.read) {\n const result = overrideAccess\n ? true\n : await field.access.read({\n id: doc.id as number | string,\n data: doc,\n doc,\n req,\n siblingData: siblingDoc,\n })\n\n if (!result) {\n allowDefaultValue = false\n delete siblingDoc[field.name]\n }\n }\n\n // Set defaultValue on the field for globals being returned without being first created\n // or collection documents created prior to having a default\n if (\n allowDefaultValue &&\n typeof siblingDoc[field.name] === 'undefined' &&\n typeof field.defaultValue !== 'undefined'\n ) {\n siblingDoc[field.name] = await getDefaultValue({\n defaultValue: field.defaultValue,\n locale,\n user: req.user,\n value: siblingDoc[field.name],\n })\n }\n\n if (field.type === 'relationship' || field.type === 'upload') {\n populationPromises.push(\n relationshipPopulationPromise({\n currentDepth,\n depth,\n draft,\n fallbackLocale,\n field,\n locale,\n overrideAccess,\n req,\n showHiddenFields,\n siblingDoc,\n }),\n )\n }\n }\n\n switch (field.type) {\n case 'group': {\n let groupDoc = siblingDoc[field.name] as JsonObject\n if (typeof siblingDoc[field.name] !== 'object') groupDoc = {}\n\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: groupDoc,\n triggerAccessControl,\n triggerHooks,\n })\n\n break\n }\n\n case 'array': {\n const rows = siblingDoc[field.name] as JsonObject\n\n if (Array.isArray(rows)) {\n rows.forEach((row, i) => {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: [...fieldPath, i],\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: row || {},\n triggerAccessControl,\n triggerHooks,\n })\n })\n } else if (!shouldHoistLocalizedValue && typeof rows === 'object' && rows !== null) {\n Object.values(rows).forEach((localeRows) => {\n if (Array.isArray(localeRows)) {\n localeRows.forEach((row, i) => {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: [...fieldPath, i],\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: (row as JsonObject) || {},\n triggerAccessControl,\n triggerHooks,\n })\n })\n }\n })\n } else {\n siblingDoc[field.name] = []\n }\n break\n }\n\n case 'blocks': {\n const rows = siblingDoc[field.name]\n\n if (Array.isArray(rows)) {\n rows.forEach((row, i) => {\n const block = field.blocks.find(\n (blockType) => blockType.slug === (row as JsonObject).blockType,\n )\n\n if (block) {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: block.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: [...fieldPath, i],\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: (row as JsonObject) || {},\n triggerAccessControl,\n triggerHooks,\n })\n }\n })\n } else if (!shouldHoistLocalizedValue && typeof rows === 'object' && rows !== null) {\n Object.values(rows).forEach((localeRows) => {\n if (Array.isArray(localeRows)) {\n localeRows.forEach((row, i) => {\n const block = field.blocks.find(\n (blockType) => blockType.slug === (row as JsonObject).blockType,\n )\n\n if (block) {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: block.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: [...fieldPath, i],\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: (row as JsonObject) || {},\n triggerAccessControl,\n triggerHooks,\n })\n }\n })\n }\n })\n } else {\n siblingDoc[field.name] = []\n }\n\n break\n }\n\n case 'row':\n case 'collapsible': {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl,\n triggerHooks,\n })\n\n break\n }\n\n case 'tab': {\n let tabDoc = siblingDoc\n if (tabHasName(field)) {\n tabDoc = siblingDoc[field.name] as JsonObject\n if (typeof siblingDoc[field.name] !== 'object') tabDoc = {}\n }\n\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc: tabDoc,\n triggerAccessControl,\n triggerHooks,\n })\n\n break\n }\n\n case 'tabs': {\n traverseFields({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl,\n triggerHooks,\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?.afterRead?.length) {\n await editor.hooks.afterRead.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const shouldRunHookOnAllLocales =\n field.localized &&\n (locale === 'all' || !flattenLocales) &&\n typeof siblingDoc[field.name] === 'object'\n\n if (shouldRunHookOnAllLocales) {\n const hookPromises = Object.entries(siblingDoc[field.name]).map(([locale, value]) =>\n (async () => {\n const hookedValue = await currentHook({\n collection,\n context,\n currentDepth,\n data: doc,\n depth,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingData: siblingDoc,\n triggerAccessControl,\n triggerHooks,\n value,\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name][locale] = hookedValue\n }\n })(),\n )\n\n await Promise.all(hookPromises)\n } else {\n const hookedValue = await currentHook({\n collection,\n context,\n currentDepth,\n data: doc,\n depth,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n operation: 'read',\n originalDoc: doc,\n overrideAccess,\n path: fieldPath,\n populationPromises,\n req,\n schemaPath: fieldSchemaPath,\n showHiddenFields,\n siblingData: siblingDoc,\n triggerAccessControl,\n triggerHooks,\n value: siblingDoc[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingDoc[field.name] = hookedValue\n }\n }\n }, Promise.resolve())\n }\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","fieldAffectsData","tabHasName","getDefaultValue","getFieldPaths","relationshipPopulationPromise","traverseFields","promise","collection","context","currentDepth","depth","doc","draft","fallbackLocale","field","fieldPromises","findMany","flattenLocales","global","locale","overrideAccess","parentPath","parentSchemaPath","populationPromises","req","showHiddenFields","siblingDoc","triggerAccessControl","triggerHooks","path","fieldPath","schemaPath","fieldSchemaPath","hidden","name","shouldHoistLocalizedValue","localized","payload","config","localization","value","hoistedValue","fallbackValue","isNullOrUndefined","type","tabs","forEach","tab","editor","Error","pointDoc","Array","isArray","coordinates","length","undefined","hooks","afterRead","reduce","priorHook","currentHook","shouldRunHookOnAllLocales","hookPromises","Object","entries","map","hookedValue","data","operation","originalDoc","siblingData","Promise","all","resolve","allowDefaultValue","access","read","result","id","defaultValue","user","push","groupDoc","fields","rows","row","i","values","local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V;wBACpB,OAAO;4BACL,MAAMI,cAAc,MAAMN,YAAY;gCACpCrD;gCACAC;gCACAC;gCACA0D,MAAMxD;gCACND;gCACAE;gCACAC;gCACAC;gCACAC;gCACAC;gCACAC;gCACAC;gCACAC;gCACAiD,WAAW;gCACXC,aAAa1D;gCACbS;gCACAS,MAAMC;gCACNP;gCACAC;gCACAO,YAAYC;gCACZP;gCACA6C,aAAa5C;gCACbC;gCACAC;gCACAY,OAAOd,UAAU,CAACZ,MAAMoB,IAAI,CAAC;4BAC/B;4BAEA,IAAIgC,gBAAgBX,WAAW;gCAC7B7B,UAAU,CAACZ,MAAMoB,IAAI,CAAC,GAAGgC;4BAC3B;wBACF;oBACF,GAAGK,QAAQE,OAAO;gBACpB;gBACA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
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 = {
|
|
6
6
|
collection: SanitizedCollectionConfig | null;
|
|
7
7
|
context: RequestContext;
|
|
8
8
|
currentDepth: number;
|
|
9
9
|
depth: number;
|
|
10
|
-
doc:
|
|
10
|
+
doc: JsonObject;
|
|
11
11
|
draft: boolean;
|
|
12
12
|
fallbackLocale: null | string;
|
|
13
13
|
/**
|
|
@@ -25,7 +25,7 @@ type Args = {
|
|
|
25
25
|
req: PayloadRequest;
|
|
26
26
|
schemaPath: string[];
|
|
27
27
|
showHiddenFields: boolean;
|
|
28
|
-
siblingDoc:
|
|
28
|
+
siblingDoc: JsonObject;
|
|
29
29
|
triggerAccessControl?: boolean;
|
|
30
30
|
triggerHooks?: boolean;
|
|
31
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterRead/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterRead/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACzF,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,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,UAAU,CAAA;IACf,KAAK,EAAE,OAAO,CAAA;IACd,cAAc,EAAE,IAAI,GAAG,MAAM,CAAA;IAC7B;;OAEG;IACH,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IAC9B,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,QAAQ,EAAE,OAAO,CAAA;IACjB,cAAc,EAAE,OAAO,CAAA;IACvB,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAA;IACpC,MAAM,EAAE,IAAI,GAAG,MAAM,CAAA;IACrB,cAAc,EAAE,OAAO,CAAA;IACvB,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IACzB,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IACnC,GAAG,EAAE,cAAc,CAAA;IACnB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,gBAAgB,EAAE,OAAO,CAAA;IACzB,UAAU,EAAE,UAAU,CAAA;IACtB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAED,eAAO,MAAM,cAAc,4QAuBxB,IAAI,KAAG,IA6BT,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/afterRead/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { 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 currentDepth: number\n depth: number\n doc:
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/afterRead/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { JsonObject, 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 currentDepth: number\n depth: number\n doc: JsonObject\n draft: boolean\n fallbackLocale: null | string\n /**\n * fieldPromises are used for things like field hooks. They should be awaited before awaiting populationPromises\n */\n fieldPromises: Promise<void>[]\n fields: (Field | TabAsField)[]\n findMany: boolean\n flattenLocales: boolean\n global: SanitizedGlobalConfig | null\n locale: null | string\n overrideAccess: boolean\n path: (number | string)[]\n populationPromises: Promise<void>[]\n req: PayloadRequest\n schemaPath: string[]\n showHiddenFields: boolean\n siblingDoc: JsonObject\n triggerAccessControl?: boolean\n triggerHooks?: boolean\n}\n\nexport const traverseFields = ({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n fieldPromises,\n fields,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n path,\n populationPromises,\n req,\n schemaPath,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl = true,\n triggerHooks = true,\n}: Args): void => {\n fields.forEach((field) => {\n fieldPromises.push(\n promise({\n collection,\n context,\n currentDepth,\n depth,\n doc,\n draft,\n fallbackLocale,\n field,\n fieldPromises,\n findMany,\n flattenLocales,\n global,\n locale,\n overrideAccess,\n parentPath: path,\n parentSchemaPath: schemaPath,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n triggerAccessControl,\n triggerHooks,\n }),\n )\n })\n}\n"],"names":["promise","traverseFields","collection","context","currentDepth","depth","doc","draft","fallbackLocale","fieldPromises","fields","findMany","flattenLocales","global","locale","overrideAccess","path","populationPromises","req","schemaPath","showHiddenFields","siblingDoc","triggerAccessControl","triggerHooks","forEach","field","push","parentPath","parentSchemaPath"],"mappings":"AAKA,SAASA,OAAO,QAAQ,eAAc;AA8BtC,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,UAAU,EACVC,OAAO,EACPC,YAAY,EACZC,KAAK,EACLC,GAAG,EACHC,KAAK,EACLC,cAAc,EACdC,aAAa,EACbC,MAAM,EACNC,QAAQ,EACRC,cAAc,EACdC,MAAM,EACNC,MAAM,EACNC,cAAc,EACdC,IAAI,EACJC,kBAAkB,EAClBC,GAAG,EACHC,UAAU,EACVC,gBAAgB,EAChBC,UAAU,EACVC,uBAAuB,IAAI,EAC3BC,eAAe,IAAI,EACd;IACLb,OAAOc,OAAO,CAAC,CAACC;QACdhB,cAAciB,IAAI,CAChB1B,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAiB;YACAhB;YACAE;YACAC;YACAC;YACAC;YACAC;YACAY,YAAYX;YACZY,kBAAkBT;YAClBF;YACAC;YACAE;YACAC;YACAC;YACAC;QACF;IAEJ;AACF,EAAC"}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { JsonArray, JsonObject } from '../../../types/index.js';
|
|
2
|
+
export declare const cloneDataFromOriginalDoc: (originalDocData: JsonArray | JsonObject) => JsonArray | JsonObject;
|
|
2
3
|
//# sourceMappingURL=cloneDataFromOriginalDoc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloneDataFromOriginalDoc.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeChange/cloneDataFromOriginalDoc.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,
|
|
1
|
+
{"version":3,"file":"cloneDataFromOriginalDoc.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeChange/cloneDataFromOriginalDoc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEpE,eAAO,MAAM,wBAAwB,oBAClB,SAAS,GAAG,UAAU,KACtC,SAAS,GAAG,UAkBd,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/beforeChange/cloneDataFromOriginalDoc.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/beforeChange/cloneDataFromOriginalDoc.ts"],"sourcesContent":["import type { JsonArray, JsonObject } from '../../../types/index.js'\n\nexport const cloneDataFromOriginalDoc = (\n originalDocData: JsonArray | JsonObject,\n): JsonArray | JsonObject => {\n if (Array.isArray(originalDocData)) {\n return originalDocData.map((row) => {\n if (typeof row === 'object' && row != null) {\n return {\n ...row,\n }\n }\n\n return row\n })\n }\n\n if (typeof originalDocData === 'object' && originalDocData !== null) {\n return { ...originalDocData }\n }\n\n return originalDocData\n}\n"],"names":["cloneDataFromOriginalDoc","originalDocData","Array","isArray","map","row"],"mappings":"AAEA,OAAO,MAAMA,2BAA2B,CACtCC;IAEA,IAAIC,MAAMC,OAAO,CAACF,kBAAkB;QAClC,OAAOA,gBAAgBG,GAAG,CAAC,CAACC;YAC1B,IAAI,OAAOA,QAAQ,YAAYA,OAAO,MAAM;gBAC1C,OAAO;oBACL,GAAGA,GAAG;gBACR;YACF;YAEA,OAAOA;QACT;IACF;IAEA,IAAI,OAAOJ,oBAAoB,YAAYA,oBAAoB,MAAM;QACnE,OAAO;YAAE,GAAGA,eAAe;QAAC;IAC9B;IAEA,OAAOA;AACT,EAAC"}
|
|
@@ -4,5 +4,6 @@
|
|
|
4
4
|
* this is an existing row, so it should be merged.
|
|
5
5
|
* Otherwise, return an empty object.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
import type { JsonObject } from '../../../types/index.js';
|
|
8
|
+
export declare const getExistingRowDoc: (incomingRow: JsonObject, existingRows?: unknown) => JsonObject;
|
|
8
9
|
//# sourceMappingURL=getExistingRowDoc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getExistingRowDoc.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeChange/getExistingRowDoc.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"getExistingRowDoc.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeChange/getExistingRowDoc.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEzD,eAAO,MAAM,iBAAiB,gBAAiB,UAAU,iBAAiB,OAAO,KAAG,UAcnF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/beforeChange/getExistingRowDoc.ts"],"sourcesContent":["/**\n * If there is an incoming row id,\n * and it matches the existing sibling doc id,\n * this is an existing row, so it should be merged.\n * Otherwise, return an empty object.\n */\n\nexport const getExistingRowDoc = (
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/beforeChange/getExistingRowDoc.ts"],"sourcesContent":["/**\n * If there is an incoming row id,\n * and it matches the existing sibling doc id,\n * this is an existing row, so it should be merged.\n * Otherwise, return an empty object.\n */\nimport type { JsonObject } from '../../../types/index.js'\n\nexport const getExistingRowDoc = (incomingRow: JsonObject, existingRows?: unknown): JsonObject => {\n if (incomingRow.id && Array.isArray(existingRows)) {\n const matchedExistingRow = existingRows.find((existingRow) => {\n if (typeof existingRow === 'object' && 'id' in existingRow) {\n if (existingRow.id === incomingRow.id) return existingRow\n }\n\n return false\n })\n\n if (matchedExistingRow) return matchedExistingRow\n }\n\n return {}\n}\n"],"names":["getExistingRowDoc","incomingRow","existingRows","id","Array","isArray","matchedExistingRow","find","existingRow"],"mappings":"AAAA;;;;;CAKC,GAGD,OAAO,MAAMA,oBAAoB,CAACC,aAAyBC;IACzD,IAAID,YAAYE,EAAE,IAAIC,MAAMC,OAAO,CAACH,eAAe;QACjD,MAAMI,qBAAqBJ,aAAaK,IAAI,CAAC,CAACC;YAC5C,IAAI,OAAOA,gBAAgB,YAAY,QAAQA,aAAa;gBAC1D,IAAIA,YAAYL,EAAE,KAAKF,YAAYE,EAAE,EAAE,OAAOK;YAChD;YAEA,OAAO;QACT;QAEA,IAAIF,oBAAoB,OAAOA;IACjC;IAEA,OAAO,CAAC;AACV,EAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
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';
|
|
4
|
-
type Args<T> = {
|
|
3
|
+
import type { JsonObject, Operation, PayloadRequest, RequestContext } from '../../../types/index.js';
|
|
4
|
+
type Args<T extends JsonObject> = {
|
|
5
5
|
collection: SanitizedCollectionConfig | null;
|
|
6
6
|
context: RequestContext;
|
|
7
|
-
data:
|
|
8
|
-
doc:
|
|
9
|
-
docWithLocales:
|
|
7
|
+
data: T;
|
|
8
|
+
doc: T;
|
|
9
|
+
docWithLocales: JsonObject;
|
|
10
10
|
duplicate?: boolean;
|
|
11
11
|
global: SanitizedGlobalConfig | null;
|
|
12
12
|
id?: number | string;
|
|
@@ -23,6 +23,6 @@ type Args<T> = {
|
|
|
23
23
|
* - beforeDuplicate hooks (if duplicate)
|
|
24
24
|
* - Unflatten locales. The input `data` is the normal document for one locale. The output result will become the document with locales.
|
|
25
25
|
*/
|
|
26
|
-
export declare const beforeChange: <T extends
|
|
26
|
+
export declare const beforeChange: <T extends JsonObject>({ id, collection, context, data: incomingData, doc, docWithLocales, duplicate, global, operation, req, skipValidation, }: Args<T>) => Promise<T>;
|
|
27
27
|
export {};
|
|
28
28
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeChange/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,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeChange/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,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAMpG,KAAK,IAAI,CAAC,CAAC,SAAS,UAAU,IAAI;IAChC,UAAU,EAAE,yBAAyB,GAAG,IAAI,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,CAAC,CAAA;IACP,GAAG,EAAE,CAAC,CAAA;IACN,cAAc,EAAE,UAAU,CAAA;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAA;IACpC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,SAAS,EAAE,SAAS,CAAA;IACpB,GAAG,EAAE,cAAc,CAAA;IACnB,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB,CAAA;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,GAAU,CAAC,SAAS,UAAU,4HAYpD,IAAI,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CA4CrB,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ValidationError } from '../../../errors/index.js';
|
|
2
|
-
import {
|
|
2
|
+
import { deepCopyObjectSimple } from '../../../utilities/deepCopyObject.js';
|
|
3
3
|
import { traverseFields } from './traverseFields.js';
|
|
4
4
|
/**
|
|
5
5
|
* This function is responsible for the following actions, in order:
|
|
@@ -10,7 +10,7 @@ import { traverseFields } from './traverseFields.js';
|
|
|
10
10
|
* - beforeDuplicate hooks (if duplicate)
|
|
11
11
|
* - Unflatten locales. The input `data` is the normal document for one locale. The output result will become the document with locales.
|
|
12
12
|
*/ export const beforeChange = async ({ id, collection, context, data: incomingData, doc, docWithLocales, duplicate = false, global, operation, req, skipValidation })=>{
|
|
13
|
-
const data =
|
|
13
|
+
const data = deepCopyObjectSimple(incomingData);
|
|
14
14
|
const mergeLocaleActions = [];
|
|
15
15
|
const errors = [];
|
|
16
16
|
await traverseFields({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/beforeChange/index.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'\n\nimport { ValidationError } from '../../../errors/index.js'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/beforeChange/index.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'\n\nimport { ValidationError } from '../../../errors/index.js'\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 docWithLocales: JsonObject\n duplicate?: boolean\n global: SanitizedGlobalConfig | null\n id?: number | string\n operation: Operation\n req: PayloadRequest\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 * - beforeDuplicate hooks (if duplicate)\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 beforeChange = async <T extends JsonObject>({\n id,\n collection,\n context,\n data: incomingData,\n doc,\n docWithLocales,\n duplicate = false,\n global,\n operation,\n req,\n skipValidation,\n}: Args<T>): Promise<T> => {\n const data = deepCopyObjectSimple(incomingData)\n const mergeLocaleActions = []\n const errors: { field: string; message: string }[] = []\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: collection?.fields || global?.fields,\n global,\n mergeLocaleActions,\n operation,\n path: [],\n req,\n schemaPath: [],\n siblingData: data,\n siblingDoc: doc,\n siblingDocWithLocales: docWithLocales,\n skipValidation,\n })\n\n if (errors.length > 0) {\n throw new ValidationError(\n {\n collection: collection?.slug,\n errors,\n global: global?.slug,\n },\n req.t,\n )\n }\n\n await mergeLocaleActions.reduce(async (priorAction, action) => {\n await priorAction\n await action()\n }, Promise.resolve())\n\n return data\n}\n"],"names":["ValidationError","deepCopyObjectSimple","traverseFields","beforeChange","id","collection","context","data","incomingData","doc","docWithLocales","duplicate","global","operation","req","skipValidation","mergeLocaleActions","errors","fields","path","schemaPath","siblingData","siblingDoc","siblingDocWithLocales","length","slug","t","reduce","priorAction","action","Promise","resolve"],"mappings":"AAIA,SAASA,eAAe,QAAQ,2BAA0B;AAC1D,SAASC,oBAAoB,QAAQ,uCAAsC;AAC3E,SAASC,cAAc,QAAQ,sBAAqB;AAgBpD;;;;;;;;CAQC,GACD,OAAO,MAAMC,eAAe,OAA6B,EACvDC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,MAAMC,YAAY,EAClBC,GAAG,EACHC,cAAc,EACdC,YAAY,KAAK,EACjBC,MAAM,EACNC,SAAS,EACTC,GAAG,EACHC,cAAc,EACN;IACR,MAAMR,OAAON,qBAAqBO;IAClC,MAAMQ,qBAAqB,EAAE;IAC7B,MAAMC,SAA+C,EAAE;IAEvD,MAAMf,eAAe;QACnBE;QACAC;QACAC;QACAC;QACAE;QACAC;QACAC;QACAM;QACAC,QAAQb,YAAYa,UAAUN,QAAQM;QACtCN;QACAI;QACAH;QACAM,MAAM,EAAE;QACRL;QACAM,YAAY,EAAE;QACdC,aAAad;QACbe,YAAYb;QACZc,uBAAuBb;QACvBK;IACF;IAEA,IAAIE,OAAOO,MAAM,GAAG,GAAG;QACrB,MAAM,IAAIxB,gBACR;YACEK,YAAYA,YAAYoB;YACxBR;YACAL,QAAQA,QAAQa;QAClB,GACAX,IAAIY,CAAC;IAET;IAEA,MAAMV,mBAAmBW,MAAM,CAAC,OAAOC,aAAaC;QAClD,MAAMD;QACN,MAAMC;IACR,GAAGC,QAAQC,OAAO;IAElB,OAAOxB;AACT,EAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
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:
|
|
9
|
-
doc:
|
|
10
|
-
docWithLocales:
|
|
8
|
+
data: JsonObject;
|
|
9
|
+
doc: JsonObject;
|
|
10
|
+
docWithLocales: JsonObject;
|
|
11
11
|
duplicate: boolean;
|
|
12
12
|
errors: {
|
|
13
13
|
field: string;
|
|
@@ -27,9 +27,9 @@ type Args = {
|
|
|
27
27
|
*/
|
|
28
28
|
parentSchemaPath: string[];
|
|
29
29
|
req: PayloadRequest;
|
|
30
|
-
siblingData:
|
|
31
|
-
siblingDoc:
|
|
32
|
-
siblingDocWithLocales?:
|
|
30
|
+
siblingData: JsonObject;
|
|
31
|
+
siblingDoc: JsonObject;
|
|
32
|
+
siblingDocWithLocales?: JsonObject;
|
|
33
33
|
skipValidation: boolean;
|
|
34
34
|
};
|
|
35
35
|
export declare const promise: ({ id, collection, context, data, doc, docWithLocales, duplicate, errors, field, global, mergeLocaleActions, operation, parentPath, parentSchemaPath, req, siblingData, siblingDoc, siblingDocWithLocales, skipValidation, }: Args) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeChange/promise.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeChange/promise.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACr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} from '../../../errors/index.js';
|
|
2
|
+
import { deepMergeWithSourceArrays } from '../../../utilities/deepMerge.js';
|
|
3
3
|
import { fieldAffectsData, tabHasName } from '../../config/types.js';
|
|
4
4
|
import { getFieldPaths } from '../../getFieldPaths.js';
|
|
5
5
|
import { beforeDuplicate } from './beforeDuplicate.js';
|
|
@@ -75,18 +75,14 @@ export const promise = async ({ id, collection, context, data, doc, docWithLocal
|
|
|
75
75
|
const validationResult = await field.validate(valueToValidate, {
|
|
76
76
|
...field,
|
|
77
77
|
id,
|
|
78
|
-
data:
|
|
79
|
-
arrayMerge: (_, source)=>source
|
|
80
|
-
}),
|
|
78
|
+
data: deepMergeWithSourceArrays(doc, data),
|
|
81
79
|
jsonError,
|
|
82
80
|
operation,
|
|
83
81
|
preferences: {
|
|
84
82
|
fields: {}
|
|
85
83
|
},
|
|
86
84
|
req,
|
|
87
|
-
siblingData:
|
|
88
|
-
arrayMerge: (_, source)=>source
|
|
89
|
-
})
|
|
85
|
+
siblingData: deepMergeWithSourceArrays(siblingDoc, siblingData)
|
|
90
86
|
});
|
|
91
87
|
if (typeof validationResult === 'string') {
|
|
92
88
|
errors.push({
|
|
@@ -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,MAA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;oBACAC,gBAAgBM;gBAClB;gBAEA;YACF;QAEA,KAAK;YAAY;gBACf,IAAI,CAAChB,OAAO4F,QAAQ;oBAClB,MAAM,IAAI5G,kBAAkBgB,OAAO,8HAA8H;;gBACnK;gBACA,IAAI,OAAOA,OAAO4F,WAAW,YAAY;oBACvC,MAAM,IAAIC,MAAM;gBAClB;gBAEA,MAAMD,SAA0B5F,OAAO4F;gBAEvC,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,EAC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AC;oBACAC;oBACAoB,MAAMC;oBACNlB;oBACAmB,YAAYC;oBACZnB;oBACAC;oBACAC;oBACAC,gBAAgBM;gBAClB;gBAEA;YACF;QAEA,KAAK;YAAY;gBACf,IAAI,CAAChB,OAAOyF,QAAQ;oBAClB,MAAM,IAAI1G,kBAAkBiB,OAAO,8HAA8H;;gBACnK;gBACA,IAAI,OAAOA,OAAOyF,WAAW,YAAY;oBACvC,MAAM,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:
|
|
8
|
+
data: JsonObject;
|
|
9
9
|
/**
|
|
10
10
|
* The original data (not modified by any hooks)
|
|
11
11
|
*/
|
|
12
|
-
doc:
|
|
12
|
+
doc: JsonObject;
|
|
13
13
|
/**
|
|
14
14
|
* The original data with locales (not modified by any hooks)
|
|
15
15
|
*/
|
|
16
|
-
docWithLocales:
|
|
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:
|
|
30
|
+
siblingData: JsonObject;
|
|
31
31
|
/**
|
|
32
32
|
* The original siblingData (not modified by any hooks)
|
|
33
33
|
*/
|
|
34
|
-
siblingDoc:
|
|
34
|
+
siblingDoc: JsonObject;
|
|
35
35
|
/**
|
|
36
36
|
* The original siblingData with locales (not modified by any hooks)
|
|
37
37
|
*/
|
|
38
|
-
siblingDocWithLocales:
|
|
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;
|
|
1
|
+
{"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/be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,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:
|
|
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"}
|