payload 4.0.0-beta.1 → 4.0.0-beta.3
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/auth/types.d.ts.map +1 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/cli/commands/data/utilities.d.ts +1 -1
- package/dist/cli/commands/data/utilities.d.ts.map +1 -1
- package/dist/cli/commands/data/utilities.js.map +1 -1
- package/dist/collections/config/types.d.ts +4 -1
- package/dist/collections/config/types.d.ts.map +1 -1
- package/dist/collections/config/types.js.map +1 -1
- package/dist/collections/operations/utilities/update.js.map +1 -1
- package/dist/config/sanitize.js.map +1 -1
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/database/types.d.ts +4 -0
- package/dist/database/types.d.ts.map +1 -1
- package/dist/database/types.js.map +1 -1
- package/dist/fields/config/reservedFieldNames.d.ts.map +1 -1
- package/dist/fields/config/reservedFieldNames.js.map +1 -1
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/fields/hooks/afterRead/promise.js.map +1 -1
- package/dist/fields/hooks/beforeChange/flattenValidationData.d.ts +14 -0
- package/dist/fields/hooks/beforeChange/flattenValidationData.d.ts.map +1 -0
- package/dist/fields/hooks/beforeChange/flattenValidationData.js +36 -0
- package/dist/fields/hooks/beforeChange/flattenValidationData.js.map +1 -0
- package/dist/fields/hooks/beforeChange/promise.d.ts +2 -1
- package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/promise.js +96 -22
- package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts +2 -1
- package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
- package/dist/fields/hooks/beforeChange/traverseFields.js +2 -1
- package/dist/fields/hooks/beforeChange/traverseFields.js.map +1 -1
- package/dist/globals/config/types.d.ts +2 -1
- package/dist/globals/config/types.d.ts.map +1 -1
- package/dist/globals/config/types.js.map +1 -1
- package/dist/hierarchy/addHierarchyToCollection.d.ts.map +1 -1
- package/dist/hierarchy/addHierarchyToCollection.js +32 -21
- package/dist/hierarchy/addHierarchyToCollection.js.map +1 -1
- package/dist/hierarchy/resolveHierarchyCollections.js +7 -1
- package/dist/hierarchy/resolveHierarchyCollections.js.map +1 -1
- package/dist/index.bundled.d.ts +12 -3
- package/dist/llm-instructions/getInstructionsCollection.d.ts.map +1 -1
- package/dist/llm-instructions/getInstructionsCollection.js +2 -0
- package/dist/llm-instructions/getInstructionsCollection.js.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/uploads/fileVersioning/cloudStorage.js.map +1 -1
- package/dist/uploads/formatFilesize.js +1 -1
- package/dist/uploads/formatFilesize.js.map +1 -1
- package/dist/uploads/generateFileData.js.map +1 -1
- package/dist/uploads/getFileContentRequirement.js.map +1 -1
- package/dist/utilities/entityInputSchema/validateEntityData.d.ts.map +1 -1
- package/dist/utilities/entityInputSchema/validateEntityData.js.map +1 -1
- package/dist/utilities/getVersionsConfig.js.map +1 -1
- package/dist/utilities/telemetry/conf/index.d.ts +4 -1
- package/dist/utilities/telemetry/conf/index.d.ts.map +1 -1
- package/dist/utilities/telemetry/conf/index.js.map +1 -1
- package/dist/versions/isInheritedReadVersionsAccess.js.map +1 -1
- package/package.json +21 -21
- package/skills/payload/reference/ENDPOINTS.md +3 -9
- package/skills/payload/reference/PLUGIN-DEVELOPMENT.md +3 -3
|
@@ -1 +1 @@
|
|
|
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 { ValidationFieldError } from '../../../errors/index.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { FieldOperation, JsonObject, PayloadRequest } from '../../../types/index.js'\nimport type { Block, Field, TabAsField, Validate } from '../../config/types.js'\n\nimport { MissingEditorProp } from '../../../errors/index.js'\nimport { type RequestContext, validateBlocksFilterOptions } from '../../../index.js'\nimport { deepMergeWithSourceArrays } from '../../../utilities/deepMerge.js'\nimport { getTranslatedLabel } from '../../../utilities/getTranslatedLabel.js'\nimport { fieldAffectsData, fieldShouldBeLocalized, tabHasName } from '../../config/types.js'\nimport { getFieldPaths } from '../../getFieldPaths.js'\nimport { getExistingRowDoc } from './getExistingRowDoc.js'\nimport { traverseFields } from './traverseFields.js'\n\nfunction buildFieldLabel(parentLabel: string, label: string | undefined): string {\n if (!label) {\n return parentLabel\n }\n const capitalizedLabel = label.charAt(0).toUpperCase() + label.slice(1)\n return parentLabel && capitalizedLabel\n ? `${parentLabel} > ${capitalizedLabel}`\n : capitalizedLabel || parentLabel\n}\n\ntype Args = {\n /**\n * Data of the nearest parent block. If no parent block exists, this will be the `undefined`\n */\n blockData?: JsonObject\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n data: JsonObject\n doc: JsonObject\n docWithLocales: JsonObject\n errors: ValidationFieldError[]\n field: Field | TabAsField\n fieldIndex: number\n /**\n * Built up labels of parent fields\n *\n * @example \"Group Field > Tab Field > Text Field\"\n */\n fieldLabelPath: string\n global: null | SanitizedGlobalConfig\n id?: number | string\n isValidationOperation: boolean\n mergeLocaleActions: (() => Promise<void> | void)[]\n operation: FieldOperation\n overrideAccess: boolean\n parentIndexPath: string\n parentIsLocalized: boolean\n parentPath: string\n parentSchemaPath: string\n req: PayloadRequest\n siblingData: JsonObject\n siblingDoc: JsonObject\n siblingDocWithLocales?: JsonObject\n siblingFields?: (Field | TabAsField)[]\n skipHooks: boolean\n skipValidation: boolean\n submittedTopLevelFieldNames?: ReadonlySet<string>\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 blockData,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n errors,\n field,\n fieldIndex,\n fieldLabelPath,\n global,\n isValidationOperation,\n mergeLocaleActions,\n operation,\n overrideAccess,\n parentIndexPath,\n parentIsLocalized,\n parentPath,\n parentSchemaPath,\n req,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n siblingFields,\n skipHooks,\n skipValidation,\n submittedTopLevelFieldNames,\n}: Args): Promise<void> => {\n const { indexPath, path, schemaPath } = getFieldPaths({\n field,\n index: fieldIndex,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n })\n\n const { localization } = req.payload.config\n const defaultLocale = localization ? localization?.defaultLocale : 'en'\n const operationLocale = req.locale || defaultLocale\n\n const pathSegments = path ? path.split('.') : []\n const schemaPathSegments = schemaPath ? schemaPath.split('.') : []\n const indexPathSegments = indexPath ? indexPath.split('-').filter(Boolean)?.map(Number) : []\n\n const passesCondition = field.admin?.condition\n ? Boolean(\n field.admin.condition(data, siblingData, {\n blockData: blockData!,\n operation,\n path: pathSegments,\n user: req.user,\n }),\n )\n : true\n const isOutsideSubmittedFieldScope =\n submittedTopLevelFieldNames !== undefined &&\n fieldAffectsData(field) &&\n !submittedTopLevelFieldNames.has(pathSegments[0]!)\n let skipValidationFromHere = skipValidation || isOutsideSubmittedFieldScope || !passesCondition\n\n if (fieldAffectsData(field)) {\n const shouldSkipValidationForLocalizedFallback =\n !isValidationOperation &&\n operation !== 'validate' &&\n fieldShouldBeLocalized({ field, parentIsLocalized }) &&\n operationLocale !== defaultLocale &&\n ['array', 'blocks'].includes(field.type) &&\n siblingData[field.name!] === null\n\n if (shouldSkipValidationForLocalizedFallback) {\n skipValidationFromHere = true\n }\n\n // Execute hooks\n if (!skipHooks && 'hooks' in field && field.hooks?.beforeChange) {\n for (const hook of field.hooks.beforeChange) {\n const hookedValue = await hook({\n blockData,\n collection,\n context,\n data,\n field,\n global,\n indexPath: indexPathSegments,\n operation,\n originalDoc: doc,\n overrideAccess,\n path: pathSegments,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingDoc[field.name],\n req,\n schemaPath: schemaPathSegments,\n siblingData,\n siblingDocWithLocales,\n siblingFields: siblingFields!,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }\n }\n\n if (hasInvalidFieldValueShape({ field, value: siblingData[field.name!] })) {\n errors.push({\n label: buildFieldLabel(\n fieldLabelPath,\n getTranslatedLabel(field?.label || field?.name, req.i18n),\n ),\n message: req.t('validation:invalidInput'),\n path,\n })\n return\n }\n\n // Validate\n if (!skipValidationFromHere && 'validate' in field && 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 as object\n }\n }\n\n const validateFn: Validate<object, object, object, object> = field.validate as Validate<\n object,\n object,\n object,\n object\n >\n\n const validationResult = await validateFn(valueToValidate as never, {\n ...field,\n id,\n blockData: blockData!,\n collectionSlug: collection?.slug,\n data: deepMergeWithSourceArrays(doc, data),\n event: 'submit',\n // @ts-expect-error\n jsonError,\n operation,\n overrideAccess,\n path: pathSegments,\n preferences: { fields: {} },\n previousValue: siblingDoc[field.name],\n req,\n siblingData: deepMergeWithSourceArrays(siblingDoc, siblingData),\n })\n\n if (typeof validationResult === 'string') {\n let filterOptionsError = false\n\n if (field.type === 'blocks' && field.filterOptions) {\n // Re-run filteroptions. If the validation error is due to filteroptions, we need to add error paths to all the blocks\n // that are no longer valid\n const validationResult = await validateBlocksFilterOptions({\n id,\n data,\n filterOptions: field.filterOptions,\n req,\n siblingData,\n value: siblingData[field.name],\n })\n if (validationResult?.invalidBlockSlugs?.length) {\n filterOptionsError = true\n let rowIndex = -1\n for (const block of siblingData[field.name] as JsonObject[]) {\n rowIndex++\n if (validationResult.invalidBlockSlugs.includes(block.blockType as string)) {\n const blockConfigOrSlug = field.blocks.find((blockFromField) =>\n typeof blockFromField === 'string'\n ? blockFromField === block.blockType\n : blockFromField.slug === block.blockType,\n )\n const blockConfig =\n typeof blockConfigOrSlug === 'string'\n ? req.payload.blocks[blockConfigOrSlug]\n : blockConfigOrSlug\n\n const blockLabelPath =\n field?.label === false\n ? fieldLabelPath\n : buildFieldLabel(\n fieldLabelPath,\n `${getTranslatedLabel(field?.label || field?.name, req.i18n)} > ${req.t('fields:block')} ${rowIndex + 1} (${getTranslatedLabel(blockConfig?.labels?.singular || block.blockType, req.i18n)})`,\n )\n\n errors.push({\n label: blockLabelPath,\n message: req.t('validation:invalidBlock', { block: block.blockType }),\n path: `${path}.${rowIndex}.id`,\n })\n }\n }\n }\n }\n\n if (!filterOptionsError) {\n // If the error is due to block filterOptions, we want to push the errors for each individual block, not the blocks\n // field itself => only push the error if the field is not a block field with validation failure due to filterOptions\n const fieldLabel = buildFieldLabel(\n fieldLabelPath,\n getTranslatedLabel(field?.label || field?.name, req.i18n),\n )\n\n errors.push({\n label: fieldLabel,\n message: validationResult,\n path,\n })\n }\n }\n }\n\n // Push merge locale action if applicable\n if (localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n mergeLocaleActions.push(() => {\n const localeData: Record<string, unknown> = {}\n\n for (const locale of localization.localeCodes) {\n const fieldValue =\n locale === req.locale\n ? siblingData[field.name!]\n : siblingDocWithLocales?.[field.name!]?.[locale]\n\n // update locale value if it's not undefined\n if (typeof fieldValue !== 'undefined') {\n localeData[locale] = fieldValue\n }\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 }\n }\n\n switch (field.type) {\n case 'array': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises: Promise<void>[] = []\n\n rows.forEach((row, rowIndex) => {\n promises.push(\n traverseFields({\n id,\n blockData,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n errors,\n fieldLabelPath:\n field?.label === false\n ? fieldLabelPath\n : buildFieldLabel(\n fieldLabelPath,\n `${getTranslatedLabel(field?.label || field?.name, req.i18n)} ${rowIndex + 1}`,\n ),\n fields: field.fields,\n global,\n isValidationOperation,\n mergeLocaleActions,\n operation,\n overrideAccess,\n parentIndexPath: '',\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath,\n req,\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 skipHooks,\n skipValidation: skipValidationFromHere,\n submittedTopLevelFieldNames,\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 if (Array.isArray(rows)) {\n const promises: Promise<void>[] = []\n\n rows.forEach((row, rowIndex) => {\n const rowSiblingDoc = getExistingRowDoc(row as JsonObject, siblingDoc[field.name])\n\n const rowSiblingDocWithLocales = getExistingRowDoc(\n row as JsonObject,\n siblingDocWithLocales ? siblingDocWithLocales[field.name] : {},\n )\n\n const blockTypeToMatch = (row as JsonObject).blockType || rowSiblingDoc.blockType\n\n const block: Block | undefined =\n req.payload.blocks[blockTypeToMatch] ??\n (field.blocks.find(\n (curBlock) => typeof curBlock !== 'string' && curBlock.slug === blockTypeToMatch,\n ) as Block | undefined)\n\n const blockLabelPath =\n field?.label === false\n ? fieldLabelPath\n : buildFieldLabel(\n fieldLabelPath,\n `${getTranslatedLabel(field?.label || field?.name, req.i18n)} > ${req.t('fields:block')} ${rowIndex + 1} (${getTranslatedLabel(block?.labels?.singular || blockTypeToMatch, req.i18n)})`,\n )\n\n if (block) {\n promises.push(\n traverseFields({\n id,\n blockData: row,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n errors,\n fieldLabelPath: blockLabelPath,\n\n fields: block.fields,\n global,\n isValidationOperation,\n mergeLocaleActions,\n operation,\n overrideAccess,\n parentIndexPath: '',\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath + '.' + block.slug,\n req,\n siblingData: row as JsonObject,\n siblingDoc: rowSiblingDoc,\n siblingDocWithLocales: rowSiblingDocWithLocales,\n skipHooks,\n skipValidation: skipValidationFromHere,\n submittedTopLevelFieldNames,\n }),\n )\n }\n })\n\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'collapsible':\n case 'row': {\n await traverseFields({\n id,\n blockData,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n errors,\n fieldLabelPath:\n field.type === 'row' || field?.label === false\n ? fieldLabelPath\n : buildFieldLabel(\n fieldLabelPath,\n getTranslatedLabel(field?.label || field?.type, req.i18n),\n ),\n fields: field.fields,\n global,\n isValidationOperation,\n mergeLocaleActions,\n operation,\n overrideAccess,\n parentIndexPath: indexPath,\n parentIsLocalized,\n parentPath,\n parentSchemaPath: schemaPath,\n req,\n siblingData,\n siblingDoc,\n siblingDocWithLocales: siblingDocWithLocales!,\n skipHooks,\n skipValidation: skipValidationFromHere,\n submittedTopLevelFieldNames,\n })\n\n break\n }\n\n case 'group': {\n let groupSiblingData = siblingData\n let groupSiblingDoc = siblingDoc\n let groupSiblingDocWithLocales = siblingDocWithLocales\n\n const isNamedGroup = fieldAffectsData(field)\n\n if (isNamedGroup) {\n if (typeof siblingData[field.name] !== 'object') {\n siblingData[field.name] = {}\n }\n\n if (typeof siblingDoc[field.name] !== 'object') {\n siblingDoc[field.name] = {}\n }\n\n if (typeof siblingDocWithLocales![field.name] !== 'object') {\n siblingDocWithLocales![field.name] = {}\n }\n if (typeof siblingData[field.name] !== 'object') {\n siblingData[field.name] = {}\n }\n\n if (typeof siblingDoc[field.name] !== 'object') {\n siblingDoc[field.name] = {}\n }\n\n if (typeof siblingDocWithLocales![field.name] !== 'object') {\n siblingDocWithLocales![field.name] = {}\n }\n\n groupSiblingData = siblingData[field.name] as JsonObject\n groupSiblingDoc = siblingDoc[field.name] as JsonObject\n groupSiblingDocWithLocales = siblingDocWithLocales![field.name] as JsonObject\n }\n\n const fallbackLabel = field?.label || (isNamedGroup ? field.name : field?.type)\n\n await traverseFields({\n id,\n blockData,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n errors,\n fieldLabelPath:\n field?.label === false\n ? fieldLabelPath\n : buildFieldLabel(fieldLabelPath, getTranslatedLabel(fallbackLabel, req.i18n)),\n fields: field.fields,\n global,\n isValidationOperation,\n mergeLocaleActions,\n operation,\n overrideAccess,\n parentIndexPath: isNamedGroup ? '' : indexPath,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: isNamedGroup ? path : parentPath,\n parentSchemaPath: schemaPath,\n req,\n siblingData: groupSiblingData,\n siblingDoc: groupSiblingDoc,\n siblingDocWithLocales: groupSiblingDocWithLocales!,\n skipHooks,\n skipValidation: skipValidationFromHere,\n submittedTopLevelFieldNames,\n })\n\n break\n }\n\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 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n\n if (typeof field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n const editor: RichTextAdapter = field?.editor\n\n if (!skipHooks && editor?.hooks?.beforeChange?.length) {\n for (const hook of editor.hooks.beforeChange) {\n const hookedValue = await hook({\n collection,\n context,\n data,\n docWithLocales,\n errors,\n field,\n fieldLabelPath:\n field?.label === false\n ? fieldLabelPath\n : buildFieldLabel(\n fieldLabelPath,\n getTranslatedLabel(field?.label || field?.name, req.i18n),\n ),\n global,\n indexPath: indexPathSegments,\n mergeLocaleActions,\n operation,\n originalDoc: doc,\n overrideAccess,\n parentIsLocalized,\n path: pathSegments,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingDoc[field.name],\n req,\n schemaPath: schemaPathSegments,\n siblingData,\n siblingDocWithLocales,\n skipValidation: skipValidationFromHere,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }\n }\n\n break\n }\n\n case 'tab': {\n let tabSiblingData = siblingData\n let tabSiblingDoc = siblingDoc\n let tabSiblingDocWithLocales = siblingDocWithLocales\n\n const isNamedTab = tabHasName(field)\n\n if (isNamedTab) {\n if (typeof siblingData[field.name] !== 'object') {\n siblingData[field.name] = {}\n }\n\n if (typeof siblingDoc[field.name] !== 'object') {\n siblingDoc[field.name] = {}\n }\n\n if (typeof siblingDocWithLocales![field.name] !== 'object') {\n siblingDocWithLocales![field.name] = {}\n }\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 blockData,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n errors,\n fieldLabelPath:\n field?.label === false\n ? fieldLabelPath\n : buildFieldLabel(\n fieldLabelPath,\n getTranslatedLabel(field?.label || field.name, req.i18n),\n ),\n fields: field.fields,\n global,\n isValidationOperation,\n mergeLocaleActions,\n operation,\n overrideAccess,\n parentIndexPath: isNamedTab ? '' : indexPath,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: isNamedTab ? path : parentPath,\n parentSchemaPath: schemaPath,\n req,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n siblingDocWithLocales: tabSiblingDocWithLocales!,\n skipHooks,\n skipValidation: skipValidationFromHere,\n submittedTopLevelFieldNames,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n id,\n blockData,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n errors,\n fieldLabelPath:\n field?.label === false\n ? fieldLabelPath\n : buildFieldLabel(fieldLabelPath, getTranslatedLabel(field?.label || '', req.i18n)),\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n isValidationOperation,\n mergeLocaleActions,\n operation,\n overrideAccess,\n parentIndexPath: indexPath,\n parentIsLocalized,\n parentPath: path,\n parentSchemaPath: schemaPath,\n req,\n siblingData,\n siblingDoc,\n siblingDocWithLocales: siblingDocWithLocales!,\n skipHooks,\n skipValidation: skipValidationFromHere,\n submittedTopLevelFieldNames,\n })\n\n break\n }\n\n default: {\n break\n }\n }\n}\n\nfunction hasInvalidFieldValueShape({\n field,\n value,\n}: {\n field: Field | TabAsField\n value: unknown\n}): boolean {\n if (value === null || typeof value === 'undefined' || !fieldAffectsData(field)) {\n return false\n }\n\n if (field.type === 'array' || field.type === 'blocks') {\n // Form state may use a numeric row count, while submitted values use arrays.\n return !(Array.isArray(value) || typeof value === 'number')\n }\n\n if (field.type === 'number') {\n // Only hasMany number fields may receive arrays.\n return typeof value === 'object' && !(field.hasMany && Array.isArray(value))\n }\n\n if ((field.type === 'relationship' || field.type === 'upload') && field.hasMany) {\n // HasMany relationships/uploads may receive arrays or one valid polymorphic value.\n if (typeof value !== 'object' || Array.isArray(value)) {\n return false\n }\n\n const relationshipValue = value as Record<PropertyKey, unknown>\n const valuePrototype = Object.getPrototypeOf(value)\n const isSinglePolymorphicRelationshipValue =\n Array.isArray(field.relationTo) &&\n (valuePrototype === null || valuePrototype === Object.prototype) &&\n Object.hasOwn(relationshipValue, 'relationTo') &&\n Object.hasOwn(relationshipValue, 'value') &&\n Reflect.ownKeys(relationshipValue).length === 2 &&\n typeof relationshipValue.relationTo === 'string' &&\n field.relationTo.includes(relationshipValue.relationTo) &&\n (typeof relationshipValue.value === 'string' || typeof relationshipValue.value === 'number')\n\n return !isSinglePolymorphicRelationshipValue\n }\n\n return false\n}\n"],"names":["MissingEditorProp","validateBlocksFilterOptions","deepMergeWithSourceArrays","getTranslatedLabel","fieldAffectsData","fieldShouldBeLocalized","tabHasName","getFieldPaths","getExistingRowDoc","traverseFields","buildFieldLabel","parentLabel","label","capitalizedLabel","charAt","toUpperCase","slice","promise","id","blockData","collection","context","data","doc","docWithLocales","errors","field","fieldIndex","fieldLabelPath","global","isValidationOperation","mergeLocaleActions","operation","overrideAccess","parentIndexPath","parentIsLocalized","parentPath","parentSchemaPath","req","siblingData","siblingDoc","siblingDocWithLocales","siblingFields","skipHooks","skipValidation","submittedTopLevelFieldNames","indexPath","path","schemaPath","index","localization","payload","config","defaultLocale","operationLocale","locale","pathSegments","split","schemaPathSegments","indexPathSegments","filter","Boolean","map","Number","passesCondition","admin","condition","user","isOutsideSubmittedFieldScope","undefined","has","skipValidationFromHere","shouldSkipValidationForLocalizedFallback","includes","type","name","hooks","beforeChange","hook","hookedValue","originalDoc","previousSiblingDoc","previousValue","value","hasInvalidFieldValueShape","push","i18n","message","t","validate","valueToValidate","jsonError","JSON","parse","e","validateFn","validationResult","collectionSlug","slug","event","preferences","fields","filterOptionsError","filterOptions","invalidBlockSlugs","length","rowIndex","block","blockType","blockConfigOrSlug","blocks","find","blockFromField","blockConfig","blockLabelPath","labels","singular","fieldLabel","localeData","localeCodes","fieldValue","Object","keys","rows","Array","isArray","promises","forEach","row","localized","Promise","all","rowSiblingDoc","rowSiblingDocWithLocales","blockTypeToMatch","curBlock","groupSiblingData","groupSiblingDoc","groupSiblingDocWithLocales","isNamedGroup","fallbackLabel","coordinates","parseFloat","editor","Error","tabSiblingData","tabSiblingDoc","tabSiblingDocWithLocales","isNamedTab","tabs","tab","hasMany","relationshipValue","valuePrototype","getPrototypeOf","isSinglePolymorphicRelationshipValue","relationTo","prototype","hasOwn","Reflect","ownKeys"],"mappings":"AAOA,SAASA,iBAAiB,QAAQ,2BAA0B;AAC5D,SAA8BC,2BAA2B,QAAQ,oBAAmB;AACpF,SAASC,yBAAyB,QAAQ,kCAAiC;AAC3E,SAASC,kBAAkB,QAAQ,2CAA0C;AAC7E,SAASC,gBAAgB,EAAEC,sBAAsB,EAAEC,UAAU,QA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QAAQ;QAC9E,OAAO;IACT;IAEA,IAAIA,MAAMgD,IAAI,KAAK,WAAWhD,MAAMgD,IAAI,KAAK,UAAU;QACrD,6EAA6E;QAC7E,OAAO,CAAEkD,CAAAA,MAAMC,OAAO,CAAC1C,UAAU,OAAOA,UAAU,QAAO;IAC3D;IAEA,IAAIzD,MAAMgD,IAAI,KAAK,UAAU;QAC3B,iDAAiD;QACjD,OAAO,OAAOS,UAAU,YAAY,CAAEzD,CAAAA,MAAM6H,OAAO,IAAI3B,MAAMC,OAAO,CAAC1C,MAAK;IAC5E;IAEA,IAAI,AAACzD,CAAAA,MAAMgD,IAAI,KAAK,kBAAkBhD,MAAMgD,IAAI,KAAK,QAAO,KAAMhD,MAAM6H,OAAO,EAAE;QAC/E,mFAAmF;QACnF,IAAI,OAAOpE,UAAU,YAAYyC,MAAMC,OAAO,CAAC1C,QAAQ;YACrD,OAAO;QACT;QAEA,MAAMqE,oBAAoBrE;QAC1B,MAAMsE,iBAAiBhC,OAAOiC,cAAc,CAACvE;QAC7C,MAAMwE,uCACJ/B,MAAMC,OAAO,CAACnG,MAAMkI,UAAU,KAC7BH,CAAAA,mBAAmB,QAAQA,mBAAmBhC,OAAOoC,SAAS,AAAD,KAC9DpC,OAAOqC,MAAM,CAACN,mBAAmB,iBACjC/B,OAAOqC,MAAM,CAACN,mBAAmB,YACjCO,QAAQC,OAAO,CAACR,mBAAmB/C,MAAM,KAAK,KAC9C,OAAO+C,kBAAkBI,UAAU,KAAK,YACxClI,MAAMkI,UAAU,CAACnF,QAAQ,CAAC+E,kBAAkBI,UAAU,KACrD,CAAA,OAAOJ,kBAAkBrE,KAAK,KAAK,YAAY,OAAOqE,kBAAkBrE,KAAK,KAAK,QAAO;QAE5F,OAAO,CAACwE;IACV;IAEA,OAAO;AACT"}
|
|
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 { ValidationFieldError } from '../../../errors/index.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { FieldOperation, JsonObject, PayloadRequest } from '../../../types/index.js'\nimport type { Block, Field, TabAsField, Validate } from '../../config/types.js'\n\nimport { MissingEditorProp } from '../../../errors/index.js'\nimport { type RequestContext, validateBlocksFilterOptions } from '../../../index.js'\nimport { deepMergeWithSourceArrays } from '../../../utilities/deepMerge.js'\nimport { getTranslatedLabel } from '../../../utilities/getTranslatedLabel.js'\nimport { isolateObjectProperty } from '../../../utilities/isolateObjectProperty.js'\nimport { fieldAffectsData, fieldShouldBeLocalized, tabHasName } from '../../config/types.js'\nimport { getFieldPaths } from '../../getFieldPaths.js'\nimport { flattenValidationData } from './flattenValidationData.js'\nimport { getExistingRowDoc } from './getExistingRowDoc.js'\nimport { traverseFields } from './traverseFields.js'\n\nfunction buildFieldLabel(parentLabel: string, label: string | undefined): string {\n if (!label) {\n return parentLabel\n }\n const capitalizedLabel = label.charAt(0).toUpperCase() + label.slice(1)\n return parentLabel && capitalizedLabel\n ? `${parentLabel} > ${capitalizedLabel}`\n : capitalizedLabel || parentLabel\n}\n\ntype Args = {\n /**\n * Data of the nearest parent block. If no parent block exists, this will be the `undefined`\n */\n blockData?: JsonObject\n blockFields?: Field[]\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n data: JsonObject\n doc: JsonObject\n docWithLocales: JsonObject\n errors: ValidationFieldError[]\n field: Field | TabAsField\n fieldIndex: number\n /**\n * Built up labels of parent fields\n *\n * @example \"Group Field > Tab Field > Text Field\"\n */\n fieldLabelPath: string\n global: null | SanitizedGlobalConfig\n id?: number | string\n isValidationOperation: boolean\n mergeLocaleActions: (() => Promise<void> | void)[]\n operation: FieldOperation\n overrideAccess: boolean\n parentIndexPath: string\n parentIsLocalized: boolean\n parentPath: string\n parentSchemaPath: string\n req: PayloadRequest\n siblingData: JsonObject\n siblingDoc: JsonObject\n siblingDocWithLocales?: JsonObject\n siblingFields?: (Field | TabAsField)[]\n skipHooks: boolean\n skipValidation: boolean\n submittedTopLevelFieldNames?: ReadonlySet<string>\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 blockData,\n blockFields,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n errors,\n field,\n fieldIndex,\n fieldLabelPath,\n global,\n isValidationOperation,\n mergeLocaleActions,\n operation,\n overrideAccess,\n parentIndexPath,\n parentIsLocalized,\n parentPath,\n parentSchemaPath,\n req,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n siblingFields,\n skipHooks,\n skipValidation,\n submittedTopLevelFieldNames,\n}: Args): Promise<void> => {\n const { indexPath, path, schemaPath } = getFieldPaths({\n field,\n index: fieldIndex,\n parentIndexPath,\n parentPath,\n parentSchemaPath,\n })\n\n const { localization } = req.payload.config\n const defaultLocale = localization ? localization?.defaultLocale : 'en'\n const operationLocale = req.locale || defaultLocale\n\n const pathSegments = path ? path.split('.') : []\n const schemaPathSegments = schemaPath ? schemaPath.split('.') : []\n const indexPathSegments = indexPath ? indexPath.split('-').filter(Boolean)?.map(Number) : []\n\n const passesCondition = field.admin?.condition\n ? Boolean(\n field.admin.condition(data, siblingData, {\n blockData: blockData!,\n operation,\n path: pathSegments,\n user: req.user,\n }),\n )\n : true\n const isOutsideSubmittedFieldScope =\n submittedTopLevelFieldNames !== undefined &&\n fieldAffectsData(field) &&\n !submittedTopLevelFieldNames.has(pathSegments[0]!)\n let skipValidationFromHere = skipValidation || isOutsideSubmittedFieldScope || !passesCondition\n\n if (fieldAffectsData(field)) {\n const shouldSkipValidationForLocalizedFallback =\n !isValidationOperation &&\n operation !== 'validate' &&\n fieldShouldBeLocalized({ field, parentIsLocalized }) &&\n operationLocale !== defaultLocale &&\n ['array', 'blocks'].includes(field.type) &&\n siblingData[field.name!] === null\n\n if (shouldSkipValidationForLocalizedFallback) {\n skipValidationFromHere = true\n }\n\n // Execute hooks\n if (!skipHooks && 'hooks' in field && field.hooks?.beforeChange) {\n for (const hook of field.hooks.beforeChange) {\n const hookedValue = await hook({\n blockData,\n collection,\n context,\n data,\n field,\n global,\n indexPath: indexPathSegments,\n operation,\n originalDoc: doc,\n overrideAccess,\n path: pathSegments,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingDoc[field.name],\n req,\n schemaPath: schemaPathSegments,\n siblingData,\n siblingDocWithLocales,\n siblingFields: siblingFields!,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }\n }\n\n if (hasInvalidFieldValueShape({ field, value: siblingData[field.name!] })) {\n errors.push({\n label: buildFieldLabel(\n fieldLabelPath,\n getTranslatedLabel(field?.label || field?.name, req.i18n),\n ),\n message: req.t('validation:invalidInput'),\n path,\n })\n return\n }\n\n // Validate\n if (!skipValidationFromHere && 'validate' in field && field.validate) {\n const valueToValidate = siblingData[field.name]\n\n // With `locale: 'all'` a localized scalar is a locale-keyed object; validate each locale, not the\n // wrapper. Containers (`group`/`array`/`blocks`) are excluded - per-locale child validation is a follow-up.\n const isLocaleKeyedValue =\n operationLocale === 'all' &&\n localization &&\n fieldShouldBeLocalized({ field, parentIsLocalized }) &&\n field.type !== 'group' &&\n valueToValidate !== null &&\n typeof valueToValidate === 'object' &&\n !Array.isArray(valueToValidate)\n\n const localizedValuesToValidate: { locale?: string; value: unknown }[] = isLocaleKeyedValue\n ? localization.localeCodes\n .filter((locale) => locale in (valueToValidate as JsonObject))\n .map((locale) => ({ locale, value: (valueToValidate as JsonObject)[locale] }))\n : [{ value: valueToValidate }]\n\n // No recognized locales (e.g. `{}`): validate `undefined` once so required/optional still apply.\n if (localizedValuesToValidate.length === 0) {\n localizedValuesToValidate.push({ value: undefined })\n }\n\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 as object\n }\n }\n\n const validateFn: Validate<object, object, object, object> = field.validate as Validate<\n object,\n object,\n object,\n object\n >\n\n let validationResult: string | true = true\n let failedLocale: string | undefined\n\n const validationData = deepMergeWithSourceArrays<JsonObject>(doc, data)\n const validationSiblingData = deepMergeWithSourceArrays<JsonObject>(siblingDoc, siblingData)\n\n for (const { locale, value } of localizedValuesToValidate) {\n // Scope `req.locale` to the locale being validated without mutating the shared request.\n const validationReq = locale ? isolateObjectProperty(req, 'locale') : req\n if (locale) {\n validationReq.locale = locale\n }\n\n const localeContext = locale\n ? {\n blockData:\n blockData && blockFields\n ? flattenValidationData({\n config: req.payload.config,\n data: blockData,\n fields: blockFields,\n locale,\n parentIsLocalized,\n })\n : blockData,\n data: flattenValidationData({\n config: req.payload.config,\n data: validationData,\n fields: (collection?.fields || global?.fields)!,\n locale,\n }),\n siblingData: flattenValidationData({\n config: req.payload.config,\n data: validationSiblingData,\n fields: siblingFields!,\n locale,\n parentIsLocalized,\n }),\n }\n : { blockData, data: validationData, siblingData: validationSiblingData }\n\n validationResult = await validateFn(value as never, {\n ...field,\n id,\n blockData: localeContext.blockData!,\n collectionSlug: collection?.slug,\n data: localeContext.data,\n event: 'submit',\n // @ts-expect-error generic validation options cannot infer JSON fields\n jsonError,\n operation,\n overrideAccess,\n path: pathSegments,\n preferences: { fields: {} },\n previousValue: locale\n ? (siblingDoc[field.name] as JsonObject)?.[locale]\n : siblingDoc[field.name],\n req: validationReq,\n siblingData: localeContext.siblingData,\n })\n\n if (typeof validationResult === 'string') {\n failedLocale = locale\n break\n }\n }\n\n if (typeof validationResult === 'string') {\n let filterOptionsError = false\n\n if (field.type === 'blocks' && field.filterOptions) {\n // Re-run filteroptions. If the validation error is due to filteroptions, we need to add error paths to all the blocks\n // that are no longer valid\n const validationResult = await validateBlocksFilterOptions({\n id,\n data,\n filterOptions: field.filterOptions,\n req,\n siblingData,\n value: siblingData[field.name],\n })\n if (validationResult?.invalidBlockSlugs?.length) {\n filterOptionsError = true\n let rowIndex = -1\n for (const block of siblingData[field.name] as JsonObject[]) {\n rowIndex++\n if (validationResult.invalidBlockSlugs.includes(block.blockType as string)) {\n const blockConfigOrSlug = field.blocks.find((blockFromField) =>\n typeof blockFromField === 'string'\n ? blockFromField === block.blockType\n : blockFromField.slug === block.blockType,\n )\n const blockConfig =\n typeof blockConfigOrSlug === 'string'\n ? req.payload.blocks[blockConfigOrSlug]\n : blockConfigOrSlug\n\n const blockLabelPath =\n field?.label === false\n ? fieldLabelPath\n : buildFieldLabel(\n fieldLabelPath,\n `${getTranslatedLabel(field?.label || field?.name, req.i18n)} > ${req.t('fields:block')} ${rowIndex + 1} (${getTranslatedLabel(blockConfig?.labels?.singular || block.blockType, req.i18n)})`,\n )\n\n errors.push({\n label: blockLabelPath,\n message: req.t('validation:invalidBlock', { block: block.blockType }),\n path: `${path}.${rowIndex}.id`,\n })\n }\n }\n }\n }\n\n if (!filterOptionsError) {\n // If the error is due to block filterOptions, we want to push the errors for each individual block, not the blocks\n // field itself => only push the error if the field is not a block field with validation failure due to filterOptions\n const fieldLabel = buildFieldLabel(\n fieldLabelPath,\n getTranslatedLabel(field?.label || field?.name, req.i18n),\n )\n\n errors.push({\n label: failedLocale ? `${fieldLabel} (${failedLocale})` : fieldLabel,\n message: validationResult,\n path,\n })\n }\n }\n }\n\n // Push merge locale action if applicable\n if (localization && fieldShouldBeLocalized({ field, parentIsLocalized })) {\n mergeLocaleActions.push(() => {\n const localeData: Record<string, unknown> = {}\n\n // With `locale: 'all'`, siblingData holds a locale-keyed object (`{ en, es }`) rather than a single\n // locale's value - take each submitted locale, falling back to the existing doc for ones not sent.\n const submittedValue = siblingData[field.name!]\n const isAllLocales =\n req.locale === 'all' &&\n submittedValue !== null &&\n typeof submittedValue === 'object' &&\n !Array.isArray(submittedValue)\n\n for (const locale of localization.localeCodes) {\n const existingValue = siblingDocWithLocales?.[field.name!]?.[locale]\n\n const fieldValue = isAllLocales\n ? locale in (submittedValue as Record<string, unknown>)\n ? (submittedValue as Record<string, unknown>)[locale]\n : existingValue\n : locale === req.locale\n ? submittedValue\n : existingValue\n\n // update locale value if it's not undefined\n if (typeof fieldValue !== 'undefined') {\n localeData[locale] = fieldValue\n }\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 }\n }\n\n switch (field.type) {\n case 'array': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises: Promise<void>[] = []\n\n rows.forEach((row, rowIndex) => {\n promises.push(\n traverseFields({\n id,\n blockData,\n blockFields,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n errors,\n fieldLabelPath:\n field?.label === false\n ? fieldLabelPath\n : buildFieldLabel(\n fieldLabelPath,\n `${getTranslatedLabel(field?.label || field?.name, req.i18n)} ${rowIndex + 1}`,\n ),\n fields: field.fields,\n global,\n isValidationOperation,\n mergeLocaleActions,\n operation,\n overrideAccess,\n parentIndexPath: '',\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath,\n req,\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 skipHooks,\n skipValidation: skipValidationFromHere,\n submittedTopLevelFieldNames,\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 if (Array.isArray(rows)) {\n const promises: Promise<void>[] = []\n\n rows.forEach((row, rowIndex) => {\n const rowSiblingDoc = getExistingRowDoc(row as JsonObject, siblingDoc[field.name])\n\n const rowSiblingDocWithLocales = getExistingRowDoc(\n row as JsonObject,\n siblingDocWithLocales ? siblingDocWithLocales[field.name] : {},\n )\n\n const blockTypeToMatch = (row as JsonObject).blockType || rowSiblingDoc.blockType\n\n const block: Block | undefined =\n req.payload.blocks[blockTypeToMatch] ??\n (field.blocks.find(\n (curBlock) => typeof curBlock !== 'string' && curBlock.slug === blockTypeToMatch,\n ) as Block | undefined)\n\n const blockLabelPath =\n field?.label === false\n ? fieldLabelPath\n : buildFieldLabel(\n fieldLabelPath,\n `${getTranslatedLabel(field?.label || field?.name, req.i18n)} > ${req.t('fields:block')} ${rowIndex + 1} (${getTranslatedLabel(block?.labels?.singular || blockTypeToMatch, req.i18n)})`,\n )\n\n if (block) {\n promises.push(\n traverseFields({\n id,\n blockData: row,\n blockFields: block.fields,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n errors,\n fieldLabelPath: blockLabelPath,\n\n fields: block.fields,\n global,\n isValidationOperation,\n mergeLocaleActions,\n operation,\n overrideAccess,\n parentIndexPath: '',\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: path + '.' + rowIndex,\n parentSchemaPath: schemaPath + '.' + block.slug,\n req,\n siblingData: row as JsonObject,\n siblingDoc: rowSiblingDoc,\n siblingDocWithLocales: rowSiblingDocWithLocales,\n skipHooks,\n skipValidation: skipValidationFromHere,\n submittedTopLevelFieldNames,\n }),\n )\n }\n })\n\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'collapsible':\n case 'row': {\n await traverseFields({\n id,\n blockData,\n blockFields,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n errors,\n fieldLabelPath:\n field.type === 'row' || field?.label === false\n ? fieldLabelPath\n : buildFieldLabel(\n fieldLabelPath,\n getTranslatedLabel(field?.label || field?.type, req.i18n),\n ),\n fields: field.fields,\n global,\n isValidationOperation,\n mergeLocaleActions,\n operation,\n overrideAccess,\n parentIndexPath: indexPath,\n parentIsLocalized,\n parentPath,\n parentSchemaPath: schemaPath,\n req,\n siblingData,\n siblingDoc,\n siblingDocWithLocales: siblingDocWithLocales!,\n skipHooks,\n skipValidation: skipValidationFromHere,\n submittedTopLevelFieldNames,\n })\n\n break\n }\n\n case 'group': {\n let groupSiblingData = siblingData\n let groupSiblingDoc = siblingDoc\n let groupSiblingDocWithLocales = siblingDocWithLocales\n\n const isNamedGroup = fieldAffectsData(field)\n\n if (isNamedGroup) {\n if (typeof siblingData[field.name] !== 'object') {\n siblingData[field.name] = {}\n }\n\n if (typeof siblingDoc[field.name] !== 'object') {\n siblingDoc[field.name] = {}\n }\n\n if (typeof siblingDocWithLocales![field.name] !== 'object') {\n siblingDocWithLocales![field.name] = {}\n }\n if (typeof siblingData[field.name] !== 'object') {\n siblingData[field.name] = {}\n }\n\n if (typeof siblingDoc[field.name] !== 'object') {\n siblingDoc[field.name] = {}\n }\n\n if (typeof siblingDocWithLocales![field.name] !== 'object') {\n siblingDocWithLocales![field.name] = {}\n }\n\n groupSiblingData = siblingData[field.name] as JsonObject\n groupSiblingDoc = siblingDoc[field.name] as JsonObject\n groupSiblingDocWithLocales = siblingDocWithLocales![field.name] as JsonObject\n }\n\n const fallbackLabel = field?.label || (isNamedGroup ? field.name : field?.type)\n\n await traverseFields({\n id,\n blockData,\n blockFields,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n errors,\n fieldLabelPath:\n field?.label === false\n ? fieldLabelPath\n : buildFieldLabel(fieldLabelPath, getTranslatedLabel(fallbackLabel, req.i18n)),\n fields: field.fields,\n global,\n isValidationOperation,\n mergeLocaleActions,\n operation,\n overrideAccess,\n parentIndexPath: isNamedGroup ? '' : indexPath,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: isNamedGroup ? path : parentPath,\n parentSchemaPath: schemaPath,\n req,\n siblingData: groupSiblingData,\n siblingDoc: groupSiblingDoc,\n siblingDocWithLocales: groupSiblingDocWithLocales!,\n skipHooks,\n skipValidation: skipValidationFromHere,\n submittedTopLevelFieldNames,\n })\n\n break\n }\n\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 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n\n if (typeof field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n const editor: RichTextAdapter = field?.editor\n\n if (!skipHooks && editor?.hooks?.beforeChange?.length) {\n for (const hook of editor.hooks.beforeChange) {\n const hookedValue = await hook({\n collection,\n context,\n data,\n docWithLocales,\n errors,\n field,\n fieldLabelPath:\n field?.label === false\n ? fieldLabelPath\n : buildFieldLabel(\n fieldLabelPath,\n getTranslatedLabel(field?.label || field?.name, req.i18n),\n ),\n global,\n indexPath: indexPathSegments,\n mergeLocaleActions,\n operation,\n originalDoc: doc,\n overrideAccess,\n parentIsLocalized,\n path: pathSegments,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingDoc[field.name],\n req,\n schemaPath: schemaPathSegments,\n siblingData,\n siblingDocWithLocales,\n skipValidation: skipValidationFromHere,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }\n }\n\n break\n }\n\n case 'tab': {\n let tabSiblingData = siblingData\n let tabSiblingDoc = siblingDoc\n let tabSiblingDocWithLocales = siblingDocWithLocales\n\n const isNamedTab = tabHasName(field)\n\n if (isNamedTab) {\n if (typeof siblingData[field.name] !== 'object') {\n siblingData[field.name] = {}\n }\n\n if (typeof siblingDoc[field.name] !== 'object') {\n siblingDoc[field.name] = {}\n }\n\n if (typeof siblingDocWithLocales![field.name] !== 'object') {\n siblingDocWithLocales![field.name] = {}\n }\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 blockData,\n blockFields,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n errors,\n fieldLabelPath:\n field?.label === false\n ? fieldLabelPath\n : buildFieldLabel(\n fieldLabelPath,\n getTranslatedLabel(field?.label || field.name, req.i18n),\n ),\n fields: field.fields,\n global,\n isValidationOperation,\n mergeLocaleActions,\n operation,\n overrideAccess,\n parentIndexPath: isNamedTab ? '' : indexPath,\n parentIsLocalized: parentIsLocalized || field.localized,\n parentPath: isNamedTab ? path : parentPath,\n parentSchemaPath: schemaPath,\n req,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n siblingDocWithLocales: tabSiblingDocWithLocales!,\n skipHooks,\n skipValidation: skipValidationFromHere,\n submittedTopLevelFieldNames,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n id,\n blockData,\n blockFields,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n errors,\n fieldLabelPath:\n field?.label === false\n ? fieldLabelPath\n : buildFieldLabel(fieldLabelPath, getTranslatedLabel(field?.label || '', req.i18n)),\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n isValidationOperation,\n mergeLocaleActions,\n operation,\n overrideAccess,\n parentIndexPath: indexPath,\n parentIsLocalized,\n parentPath: path,\n parentSchemaPath: schemaPath,\n req,\n siblingData,\n siblingDoc,\n siblingDocWithLocales: siblingDocWithLocales!,\n skipHooks,\n skipValidation: skipValidationFromHere,\n submittedTopLevelFieldNames,\n })\n\n break\n }\n\n default: {\n break\n }\n }\n}\n\nfunction hasInvalidFieldValueShape({\n field,\n value,\n}: {\n field: Field | TabAsField\n value: unknown\n}): boolean {\n if (value === null || typeof value === 'undefined' || !fieldAffectsData(field)) {\n return false\n }\n\n if (field.type === 'array' || field.type === 'blocks') {\n // Form state may use a numeric row count, while submitted values use arrays.\n return !(Array.isArray(value) || typeof value === 'number')\n }\n\n if (field.type === 'number') {\n // Only hasMany number fields may receive arrays.\n return typeof value === 'object' && !(field.hasMany && Array.isArray(value))\n }\n\n if ((field.type === 'relationship' || field.type === 'upload') && field.hasMany) {\n // HasMany relationships/uploads may receive arrays or one valid polymorphic value.\n if (typeof value !== 'object' || Array.isArray(value)) {\n return false\n }\n\n const relationshipValue = value as Record<PropertyKey, unknown>\n const valuePrototype = Object.getPrototypeOf(value)\n const isSinglePolymorphicRelationshipValue =\n Array.isArray(field.relationTo) &&\n (valuePrototype === null || valuePrototype === Object.prototype) &&\n Object.hasOwn(relationshipValue, 'relationTo') &&\n Object.hasOwn(relationshipValue, 'value') &&\n Reflect.ownKeys(relationshipValue).length === 2 &&\n typeof relationshipValue.relationTo === 'string' &&\n field.relationTo.includes(relationshipValue.relationTo) &&\n (typeof relationshipValue.value === 'string' || typeof relationshipValue.value === 'number')\n\n return !isSinglePolymorphicRelationshipValue\n }\n\n return false\n}\n"],"names":["MissingEditorProp","validateBlocksFilterOptions","deepMergeWithSourceArrays","getTranslatedLabel","isolateObjectProperty","fieldAffectsData","fieldShouldBeLocalized","tabHasName","getFieldPaths","flattenValidationData","getExistingRowDoc","traverseFields","buildFieldLabel","parentLabel","label","capitalizedLabel","charAt","toUpperCase","slice","promise","id","blockData","blockFields","collection","context","data","doc","docWithLocales","errors","field","fieldIndex","fieldLabelPath","global","isValidationOperation","mergeLocaleActions","operation","overrideAccess","parentIndexPath","parentIsLocalized","parentPath","parentSchemaPath","req","siblingData","siblingDoc","siblingDocWithLocales","siblingFields","skipHooks","skipValidation","submittedTopLevelFieldNames","indexPath","path","schemaPath","index","localization","payload","config","defaultLocale","operationLocale","locale","pathSegments","split","schemaPathSegments","indexPathSegments","filter","Boolean","map","Number","passesCondition","admin","condition","user","isOutsideSubmittedFieldScope","undefined","has","skipValidationFromHere","shouldSkipValidationForLocalizedFallback","includes","type","name","hooks","beforeChange","hook","hookedValue","originalDoc","previousSiblingDoc","previousValue","value","hasInvalidFieldValueShape","push","i18n","message","t","validate","valueToValidate","isLocaleKeyedValue","Array","isArray","localizedValuesToValidate","localeCodes","length","jsonError","JSON","parse","e","validateFn","validationResult","failedLocale","validationData","validationSiblingData","validationReq","localeContext","fields","collectionSlug","slug","event","preferences","filterOptionsError","filterOptions","invalidBlockSlugs","rowIndex","block","blockType","blockConfigOrSlug","blocks","find","blockFromField","blockConfig","blockLabelPath","labels","singular","fieldLabel","localeData","submittedValue","isAllLocales","existingValue","fieldValue","Object","keys","rows","promises","forEach","row","localized","Promise","all","rowSiblingDoc","rowSiblingDocWithLocales","blockTypeToMatch","curBlock","groupSiblingData","groupSiblingDoc","groupSiblingDocWithLocales","isNamedGroup","fallbackLabel","coordinates","parseFloat","editor","Error","tabSiblingData","tabSiblingDoc","tabSiblingDocWithLocales","isNamedTab","tabs","tab","hasMany","relationshipValue","valuePrototype","getPrototypeOf","isSinglePolymorphicRelationshipValue","relationTo","prototype","hasOwn","Reflect","ownKeys"],"mappings":"AAOA,SAASA,iBAAiB,QAAQ,2BAA0B;AAC5D,SAA8BC,2BAA2B,QAAQ,oBAAmB;AACpF,SAASC,yBAAyB,QAAQ,kCAAiC;AAC3E,SAASC,kBAAkB,QAAQ,2CAA0C;AAC7E,SAASC,qBAAqB,QAAQ,8CAA6C;AACnF,SAASC,gBAAgB,EAAEC,sBAAsB,EAAEC,UAAU,QAAQ,wBAAuB;AAC5F,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,qBAAqB,QAAQ,6BAA4B;AAClE,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,cAAc,QAAQ,sBAAqB;AAEpD,SAASC,gBAAgBC,WAAmB,EAAEC,KAAyB;IACrE,IAAI,CAACA,OAAO;QACV,OAAOD;IACT;IACA,MAAME,mBAAmBD,MAAME,MAAM,CAAC,GAAGC,WAAW,KAAKH,MAAMI,KAAK,CAAC;IACrE,OAAOL,eAAeE,mBAClB,GAAGF,YAAY,GAAG,EAAEE,kBAAkB,GACtCA,oBAAoBF;AAC1B;AA0CA,oEAAoE;AACpE,kBAAkB;AAClB,wBAAwB;AACxB,kBAAkB;AAClB,+BAA+B;AAC/B,yCAAyC;AACzC,sBAAsB;AAEtB,OAAO,MAAMM,UAAU,OAAO,EAC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KAAK,KAAK,YAAY,OAAO+E,kBAAkB/E,KAAK,KAAK,QAAO;QAE5F,OAAO,CAACkF;IACV;IAEA,OAAO;AACT"}
|
|
@@ -9,6 +9,7 @@ type Args = {
|
|
|
9
9
|
* Data of the nearest parent block. If no parent block exists, this will be the `undefined`
|
|
10
10
|
*/
|
|
11
11
|
blockData?: JsonObject;
|
|
12
|
+
blockFields?: Field[];
|
|
12
13
|
collection: null | SanitizedCollectionConfig;
|
|
13
14
|
context: RequestContext;
|
|
14
15
|
data: JsonObject;
|
|
@@ -63,6 +64,6 @@ type Args = {
|
|
|
63
64
|
* - Transform data for storage
|
|
64
65
|
* - Unflatten locales. The input `data` is the normal document for one locale. The output result will become the document with locales.
|
|
65
66
|
*/
|
|
66
|
-
export declare const traverseFields: ({ id, blockData, collection, context, data, doc, docWithLocales, errors, fieldLabelPath, fields, global, isValidationOperation, mergeLocaleActions, operation, overrideAccess, parentIndexPath, parentIsLocalized, parentPath, parentSchemaPath, req, siblingData, siblingDoc, siblingDocWithLocales, skipHooks, skipValidation, submittedTopLevelFieldNames, }: Args) => Promise<void>;
|
|
67
|
+
export declare const traverseFields: ({ id, blockData, blockFields, collection, context, data, doc, docWithLocales, errors, fieldLabelPath, fields, global, isValidationOperation, mergeLocaleActions, operation, overrideAccess, parentIndexPath, parentIsLocalized, parentPath, parentSchemaPath, req, siblingData, siblingDoc, siblingDocWithLocales, skipHooks, skipValidation, submittedTopLevelFieldNames, }: Args) => Promise<void>;
|
|
67
68
|
export {};
|
|
68
69
|
//# sourceMappingURL=traverseFields.d.ts.map
|
|
@@ -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,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,KAAK,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SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,2BAA2B,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAClD,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,
|
|
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,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACzF,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAI9D,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,SAAS,CAAC,EAAE,UAAU,CAAA;IACtB,WAAW,CAAC,EAAE,KAAK,EAAE,CAAA;IACrB,UAAU,EAAE,IAAI,GAAG,yBAAyB,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,UAAU,CAAA;IAChB;;OAEG;IACH,GAAG,EAAE,UAAU,CAAA;IACf;;OAEG;IACH,cAAc,EAAE,UAAU,CAAA;IAC1B,MAAM,EAAE,oBAAoB,EAAE,CAAA;IAC9B;;;;OAIG;IACH,cAAc,EAAE,MAAM,CAAA;IACtB,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,MAAM,EAAE,IAAI,GAAG,qBAAqB,CAAA;IACpC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,kBAAkB,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,EAAE,CAAA;IAClD,SAAS,EAAE,cAAc,CAAA;IACzB,cAAc,EAAE,OAAO,CAAA;IACvB,eAAe,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,UAAU,EAAE,MAAM,CAAA;IAClB,gBAAgB,EAAE,MAAM,CAAA;IACxB,GAAG,EAAE,cAAc,CAAA;IACnB,WAAW,EAAE,UAAU,CAAA;IACvB;;OAEG;IACH,UAAU,EAAE,UAAU,CAAA;IACtB;;OAEG;IACH,qBAAqB,EAAE,UAAU,CAAA;IACjC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,2BAA2B,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CAClD,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,iXA4BxB,IAAI,KAAG,OAAO,CAAC,IAAI,CAwCrB,CAAA"}
|
|
@@ -6,12 +6,13 @@ import { promise } from './promise.js';
|
|
|
6
6
|
* - Validate data
|
|
7
7
|
* - Transform data for storage
|
|
8
8
|
* - Unflatten locales. The input `data` is the normal document for one locale. The output result will become the document with locales.
|
|
9
|
-
*/ export const traverseFields = async ({ id, blockData, collection, context, data, doc, docWithLocales, errors, fieldLabelPath, fields, global, isValidationOperation, mergeLocaleActions, operation, overrideAccess, parentIndexPath, parentIsLocalized, parentPath, parentSchemaPath, req, siblingData, siblingDoc, siblingDocWithLocales, skipHooks, skipValidation, submittedTopLevelFieldNames })=>{
|
|
9
|
+
*/ export const traverseFields = async ({ id, blockData, blockFields, collection, context, data, doc, docWithLocales, errors, fieldLabelPath, fields, global, isValidationOperation, mergeLocaleActions, operation, overrideAccess, parentIndexPath, parentIsLocalized, parentPath, parentSchemaPath, req, siblingData, siblingDoc, siblingDocWithLocales, skipHooks, skipValidation, submittedTopLevelFieldNames })=>{
|
|
10
10
|
const promises = [];
|
|
11
11
|
fields.forEach((field, fieldIndex)=>{
|
|
12
12
|
promises.push(promise({
|
|
13
13
|
id,
|
|
14
14
|
blockData,
|
|
15
|
+
blockFields,
|
|
15
16
|
collection,
|
|
16
17
|
context,
|
|
17
18
|
data,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/fields/hooks/beforeChange/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { ValidationFieldError } from '../../../errors/index.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { RequestContext } from '../../../index.js'\nimport type { FieldOperation, JsonObject, PayloadRequest } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args = {\n /**\n * Data of the nearest parent block. If no parent block exists, this will be the `undefined`\n */\n blockData?: JsonObject\n collection: null | SanitizedCollectionConfig\n context: RequestContext\n data: JsonObject\n /**\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 errors: ValidationFieldError[]\n /**\n * Built up labels of parent fields\n *\n * @example \"Group Field > Tab Field > Text Field\"\n */\n fieldLabelPath: string\n fields: (Field | TabAsField)[]\n global: null | SanitizedGlobalConfig\n id?: number | string\n isValidationOperation?: boolean\n mergeLocaleActions: (() => Promise<void> | void)[]\n operation: FieldOperation\n overrideAccess: boolean\n parentIndexPath: string\n /**\n * @todo make required in v4.0\n */\n parentIsLocalized?: boolean\n parentPath: string\n parentSchemaPath: string\n req: PayloadRequest\n siblingData: JsonObject\n /**\n * The original siblingData (not modified by any hooks)\n */\n siblingDoc: JsonObject\n /**\n * The original siblingData with locales (not modified by any hooks)\n */\n siblingDocWithLocales: JsonObject\n skipHooks?: boolean\n skipValidation?: boolean\n submittedTopLevelFieldNames?: ReadonlySet<string>\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 blockData,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n errors,\n fieldLabelPath,\n fields,\n global,\n isValidationOperation,\n mergeLocaleActions,\n operation,\n overrideAccess,\n parentIndexPath,\n parentIsLocalized,\n parentPath,\n parentSchemaPath,\n req,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n skipHooks,\n skipValidation,\n submittedTopLevelFieldNames,\n}: Args): Promise<void> => {\n const promises: Promise<void>[] = []\n\n fields.forEach((field, fieldIndex) => {\n promises.push(\n promise({\n id,\n blockData,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n errors,\n field,\n fieldIndex,\n fieldLabelPath,\n global,\n isValidationOperation: isValidationOperation!,\n mergeLocaleActions,\n operation,\n overrideAccess,\n parentIndexPath,\n parentIsLocalized: parentIsLocalized!,\n parentPath,\n parentSchemaPath,\n req,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n siblingFields: fields,\n skipHooks: skipHooks!,\n skipValidation: skipValidation!,\n submittedTopLevelFieldNames,\n }),\n )\n })\n\n await Promise.all(promises)\n}\n"],"names":["promise","traverseFields","id","blockData","collection","context","data","doc","docWithLocales","errors","fieldLabelPath","fields","global","isValidationOperation","mergeLocaleActions","operation","overrideAccess","parentIndexPath","parentIsLocalized","parentPath","parentSchemaPath","req","siblingData","siblingDoc","siblingDocWithLocales","skipHooks","skipValidation","submittedTopLevelFieldNames","promises","forEach","field","fieldIndex","push","siblingFields","Promise","all"],"mappings":"AAOA,SAASA,OAAO,QAAQ,eAAc;
|
|
1
|
+
{"version":3,"sources":["../../../../src/fields/hooks/beforeChange/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { ValidationFieldError } from '../../../errors/index.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { RequestContext } from '../../../index.js'\nimport type { FieldOperation, JsonObject, PayloadRequest } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args = {\n /**\n * Data of the nearest parent block. If no parent block exists, this will be the `undefined`\n */\n blockData?: JsonObject\n blockFields?: Field[]\n collection: null | SanitizedCollectionConfig\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 errors: ValidationFieldError[]\n /**\n * Built up labels of parent fields\n *\n * @example \"Group Field > Tab Field > Text Field\"\n */\n fieldLabelPath: string\n fields: (Field | TabAsField)[]\n global: null | SanitizedGlobalConfig\n id?: number | string\n isValidationOperation?: boolean\n mergeLocaleActions: (() => Promise<void> | void)[]\n operation: FieldOperation\n overrideAccess: boolean\n parentIndexPath: string\n /**\n * @todo make required in v4.0\n */\n parentIsLocalized?: boolean\n parentPath: string\n parentSchemaPath: string\n req: PayloadRequest\n siblingData: JsonObject\n /**\n * The original siblingData (not modified by any hooks)\n */\n siblingDoc: JsonObject\n /**\n * The original siblingData with locales (not modified by any hooks)\n */\n siblingDocWithLocales: JsonObject\n skipHooks?: boolean\n skipValidation?: boolean\n submittedTopLevelFieldNames?: ReadonlySet<string>\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 blockData,\n blockFields,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n errors,\n fieldLabelPath,\n fields,\n global,\n isValidationOperation,\n mergeLocaleActions,\n operation,\n overrideAccess,\n parentIndexPath,\n parentIsLocalized,\n parentPath,\n parentSchemaPath,\n req,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n skipHooks,\n skipValidation,\n submittedTopLevelFieldNames,\n}: Args): Promise<void> => {\n const promises: Promise<void>[] = []\n\n fields.forEach((field, fieldIndex) => {\n promises.push(\n promise({\n id,\n blockData,\n blockFields,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n errors,\n field,\n fieldIndex,\n fieldLabelPath,\n global,\n isValidationOperation: isValidationOperation!,\n mergeLocaleActions,\n operation,\n overrideAccess,\n parentIndexPath,\n parentIsLocalized: parentIsLocalized!,\n parentPath,\n parentSchemaPath,\n req,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n siblingFields: fields,\n skipHooks: skipHooks!,\n skipValidation: skipValidation!,\n submittedTopLevelFieldNames,\n }),\n )\n })\n\n await Promise.all(promises)\n}\n"],"names":["promise","traverseFields","id","blockData","blockFields","collection","context","data","doc","docWithLocales","errors","fieldLabelPath","fields","global","isValidationOperation","mergeLocaleActions","operation","overrideAccess","parentIndexPath","parentIsLocalized","parentPath","parentSchemaPath","req","siblingData","siblingDoc","siblingDocWithLocales","skipHooks","skipValidation","submittedTopLevelFieldNames","promises","forEach","field","fieldIndex","push","siblingFields","Promise","all"],"mappings":"AAOA,SAASA,OAAO,QAAQ,eAAc;AAuDtC;;;;;;;CAOC,GACD,OAAO,MAAMC,iBAAiB,OAAO,EACnCC,EAAE,EACFC,SAAS,EACTC,WAAW,EACXC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,cAAc,EACdC,MAAM,EACNC,cAAc,EACdC,MAAM,EACNC,MAAM,EACNC,qBAAqB,EACrBC,kBAAkB,EAClBC,SAAS,EACTC,cAAc,EACdC,eAAe,EACfC,iBAAiB,EACjBC,UAAU,EACVC,gBAAgB,EAChBC,GAAG,EACHC,WAAW,EACXC,UAAU,EACVC,qBAAqB,EACrBC,SAAS,EACTC,cAAc,EACdC,2BAA2B,EACtB;IACL,MAAMC,WAA4B,EAAE;IAEpCjB,OAAOkB,OAAO,CAAC,CAACC,OAAOC;QACrBH,SAASI,IAAI,CACXjC,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAqB;YACAC;YACArB;YACAE;YACAC,uBAAuBA;YACvBC;YACAC;YACAC;YACAC;YACAC,mBAAmBA;YACnBC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAS,eAAetB;YACfc,WAAWA;YACXC,gBAAgBA;YAChBC;QACF;IAEJ;IAEA,MAAMO,QAAQC,GAAG,CAACP;AACpB,EAAC"}
|
|
@@ -153,7 +153,8 @@ export type GlobalAdminOptions = {
|
|
|
153
153
|
* Specify a navigational group for globals in the admin sidebar.
|
|
154
154
|
* - Provide a string to place the entity in a custom group.
|
|
155
155
|
* - Provide a record to define localized group names.
|
|
156
|
-
* - Set to `false` to exclude the
|
|
156
|
+
* - Set to `false` to exclude the global from the sidebar, command palette, and dashboard collection cards.
|
|
157
|
+
* This does not disable routes or change access control.
|
|
157
158
|
*/
|
|
158
159
|
group?: false | Record<string, string> | string;
|
|
159
160
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/globals/config/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAChE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAE1C,OAAO,KAAK,EACV,MAAM,EACN,QAAQ,EACR,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,qBAAqB,EACrB,WAAW,EACZ,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAA;AAClG,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AACzE,OAAO,KAAK,EACV,cAAc,EACd,i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AI,CAAC,YAAY,EAAE,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC,CAAC;IAC5D,UAAU,EAAE,IAAI,CAAA;IAChB,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,cAAc,GAAG,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAA;IACrF,UAAU,EAAE,mBAAmB,CAAA;IAC/B,SAAS,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAA;IAC7B;;;OAGG;IACH,eAAe,EAAE,cAAc,EAAE,CAAA;IACjC,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAA;IAC5B,IAAI,EAAE,UAAU,CAAA;IAChB,QAAQ,CAAC,EAAE,uBAAuB,CAAA;CACnC;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,MAAM,EAAE,qBAAqB,EAAE,CAAA;IAC/B,OAAO,CAAC,EACJ;QACE,CAAC,IAAI,EAAE,MAAM,GAAG;YACd,iBAAiB,EAAE,cAAc,CAAC,GAAG,CAAC,CAAA;YACtC,IAAI,EAAE,iBAAiB,CAAA;YACvB,WAAW,CAAC,EAAE,iBAAiB,CAAA;SAChC,CAAA;KACF,GACD,KAAK,CAAA;CACV,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/globals/config/types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { GraphQLNonNull, GraphQLObjectType } from 'graphql'\nimport type { IsAny } from 'ts-essentials'\n\nimport type {\n Access,\n Endpoint,\n EntityDescription,\n GeneratePreviewURL,\n LabelFunction,\n LivePreviewConfig,\n MetaConfig,\n SharedAdminComponents,\n StaticLabel,\n} from '../../config/types.js'\nimport type { DBIdentifierName } from '../../database/types.js'\nimport type { Authorship, SanitizedAuthorship } from '../../fields/baseFields/authorship/types.js'\nimport type { Field, FlattenedField } from '../../fields/config/types.js'\nimport type {\n GeneratedTypes,\n GlobalAdminCustom,\n GlobalCustom,\n GlobalSlug,\n RequestContext,\n TypedGlobal,\n TypedGlobalSelect,\n} from '../../index.js'\nimport type {\n FieldOperation,\n PayloadRequest,\n SelectIncludeType,\n Where,\n WithSelectFn,\n} from '../../types/index.js'\nimport type { IncomingGlobalVersions, SanitizedGlobalVersions } from '../../versions/types.js'\n\nexport type DataFromGlobalSlug<TSlug extends GlobalSlug> = TypedGlobal[TSlug]\n\nexport type SelectFromGlobalSlug<TSlug extends GlobalSlug> = TypedGlobalSelect[TSlug]\n\nexport type GlobalAccess<TData = any> = {\n read?: Access<TData>\n readVersions?: Access<TData>\n update?: Access<TData>\n /**\n * Controls on-demand validation for this global.\n * Falls back to `update` access when omitted.\n * The access function receives `req.operation === 'validate'`.\n * @see https://payloadcms.com/docs/validation/overview#access-control-and-hooks\n */\n validate?: Access<TData>\n}\n\n/**\n * Global slugs that do not have drafts enabled.\n * Detects globals without drafts by checking for the absence of the `_status` field.\n */\nexport type GlobalsWithoutDrafts = {\n [TSlug in GlobalSlug]: DataFromGlobalSlug<TSlug> extends { _status?: any } ? never : TSlug\n}[GlobalSlug]\n\n/**\n * Conditionally allows or forbids the `draft` property based on global configuration.\n * When `strictDraftTypes` is enabled, the `draft` property is forbidden on globals without drafts.\n */\nexport type DraftFlagFromGlobalSlug<TSlug extends GlobalSlug> = GeneratedTypes extends {\n strictDraftTypes: true\n}\n ? TSlug extends GlobalsWithoutDrafts\n ? {\n /**\n * The `draft` property is not allowed because this global does not have `versions.drafts` enabled.\n */\n draft?: never\n }\n : {\n /**\n * Whether the global should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n }\n : {\n /**\n * Whether the global should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n }\n\ntype GlobalChangeOperation = Extract<FieldOperation, 'update' | 'validate'>\n\nexport type BeforeValidateHook = (args: {\n context: RequestContext\n data?: any\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n /** Hook operation being performed. */\n operation: GlobalChangeOperation\n originalDoc?: any\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n req: PayloadRequest\n}) => any\n\nexport type BeforeChangeHook = (args: {\n context: RequestContext\n data: any\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n /** Hook operation being performed. */\n operation: GlobalChangeOperation\n originalDoc?: any\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n req: PayloadRequest\n}) => any\n\nexport type AfterChangeHook = (args: {\n context: RequestContext\n data: any\n doc: any\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n /** Hook operation being performed. */\n operation: 'update'\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n previousDoc: any\n req: PayloadRequest\n}) => any\n\nexport type BeforeReadHook = (args: {\n context: RequestContext\n doc: any\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n req: PayloadRequest\n}) => any\n\nexport type AfterReadHook = (args: {\n context: RequestContext\n doc: any\n findMany?: boolean\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n query?: Where\n req: PayloadRequest\n}) => any\n\nexport type HookOperationType = 'countVersions' | 'read' | 'restoreVersion' | 'update'\n\nexport type BeforeOperationHook = (args: {\n args?: any\n context: RequestContext\n /**\n * The Global which this hook is being run on\n * */\n global: SanitizedGlobalConfig\n /**\n * Hook operation being performed\n */\n operation: HookOperationType\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n req: PayloadRequest\n}) => any\n\nexport type GlobalAdminOptions = {\n /**\n * Custom admin components\n */\n components?: SharedAdminComponents\n /** Extension point to add your custom data. Available in server and client. */\n custom?: GlobalAdminCustom\n /**\n * Custom description for collection\n */\n description?: EntityDescription\n /**\n * Specify a navigational group for globals in the admin sidebar.\n * - Provide a string to place the entity in a custom group.\n * - Provide a record to define localized group names.\n * - Set to `false` to exclude the
|
|
1
|
+
{"version":3,"sources":["../../../src/globals/config/types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { GraphQLNonNull, GraphQLObjectType } from 'graphql'\nimport type { IsAny } from 'ts-essentials'\n\nimport type {\n Access,\n Endpoint,\n EntityDescription,\n GeneratePreviewURL,\n LabelFunction,\n LivePreviewConfig,\n MetaConfig,\n SharedAdminComponents,\n StaticLabel,\n} from '../../config/types.js'\nimport type { DBIdentifierName } from '../../database/types.js'\nimport type { Authorship, SanitizedAuthorship } from '../../fields/baseFields/authorship/types.js'\nimport type { Field, FlattenedField } from '../../fields/config/types.js'\nimport type {\n GeneratedTypes,\n GlobalAdminCustom,\n GlobalCustom,\n GlobalSlug,\n RequestContext,\n TypedGlobal,\n TypedGlobalSelect,\n} from '../../index.js'\nimport type {\n FieldOperation,\n PayloadRequest,\n SelectIncludeType,\n Where,\n WithSelectFn,\n} from '../../types/index.js'\nimport type { IncomingGlobalVersions, SanitizedGlobalVersions } from '../../versions/types.js'\n\nexport type DataFromGlobalSlug<TSlug extends GlobalSlug> = TypedGlobal[TSlug]\n\nexport type SelectFromGlobalSlug<TSlug extends GlobalSlug> = TypedGlobalSelect[TSlug]\n\nexport type GlobalAccess<TData = any> = {\n read?: Access<TData>\n readVersions?: Access<TData>\n update?: Access<TData>\n /**\n * Controls on-demand validation for this global.\n * Falls back to `update` access when omitted.\n * The access function receives `req.operation === 'validate'`.\n * @see https://payloadcms.com/docs/validation/overview#access-control-and-hooks\n */\n validate?: Access<TData>\n}\n\n/**\n * Global slugs that do not have drafts enabled.\n * Detects globals without drafts by checking for the absence of the `_status` field.\n */\nexport type GlobalsWithoutDrafts = {\n [TSlug in GlobalSlug]: DataFromGlobalSlug<TSlug> extends { _status?: any } ? never : TSlug\n}[GlobalSlug]\n\n/**\n * Conditionally allows or forbids the `draft` property based on global configuration.\n * When `strictDraftTypes` is enabled, the `draft` property is forbidden on globals without drafts.\n */\nexport type DraftFlagFromGlobalSlug<TSlug extends GlobalSlug> = GeneratedTypes extends {\n strictDraftTypes: true\n}\n ? TSlug extends GlobalsWithoutDrafts\n ? {\n /**\n * The `draft` property is not allowed because this global does not have `versions.drafts` enabled.\n */\n draft?: never\n }\n : {\n /**\n * Whether the global should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n }\n : {\n /**\n * Whether the global should be queried from the versions table/collection or not. [More](https://payloadcms.com/docs/versions/drafts#draft-api)\n */\n draft?: boolean\n }\n\ntype GlobalChangeOperation = Extract<FieldOperation, 'update' | 'validate'>\n\nexport type BeforeValidateHook = (args: {\n context: RequestContext\n data?: any\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n /** Hook operation being performed. */\n operation: GlobalChangeOperation\n originalDoc?: any\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n req: PayloadRequest\n}) => any\n\nexport type BeforeChangeHook = (args: {\n context: RequestContext\n data: any\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n /** Hook operation being performed. */\n operation: GlobalChangeOperation\n originalDoc?: any\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n req: PayloadRequest\n}) => any\n\nexport type AfterChangeHook = (args: {\n context: RequestContext\n data: any\n doc: any\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n /** Hook operation being performed. */\n operation: 'update'\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n previousDoc: any\n req: PayloadRequest\n}) => any\n\nexport type BeforeReadHook = (args: {\n context: RequestContext\n doc: any\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n req: PayloadRequest\n}) => any\n\nexport type AfterReadHook = (args: {\n context: RequestContext\n doc: any\n findMany?: boolean\n /** The global which this hook is being run on */\n global: SanitizedGlobalConfig\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n query?: Where\n req: PayloadRequest\n}) => any\n\nexport type HookOperationType = 'countVersions' | 'read' | 'restoreVersion' | 'update'\n\nexport type BeforeOperationHook = (args: {\n args?: any\n context: RequestContext\n /**\n * The Global which this hook is being run on\n * */\n global: SanitizedGlobalConfig\n /**\n * Hook operation being performed\n */\n operation: HookOperationType\n /**\n * Whether access control is being overridden for this operation\n */\n overrideAccess?: boolean\n req: PayloadRequest\n}) => any\n\nexport type GlobalAdminOptions = {\n /**\n * Custom admin components\n */\n components?: SharedAdminComponents\n /** Extension point to add your custom data. Available in server and client. */\n custom?: GlobalAdminCustom\n /**\n * Custom description for collection\n */\n description?: EntityDescription\n /**\n * Specify a navigational group for globals in the admin sidebar.\n * - Provide a string to place the entity in a custom group.\n * - Provide a record to define localized group names.\n * - Set to `false` to exclude the global from the sidebar, command palette, and dashboard collection cards.\n * This does not disable routes or change access control.\n */\n group?: false | Record<string, string> | string\n /**\n * Exclude the global from the admin nav and routes\n */\n hidden?: ((args: { user: PayloadRequest['user'] }) => boolean) | boolean\n /**\n * Live preview options\n */\n livePreview?: LivePreviewConfig\n meta?: MetaConfig\n /**\n * Function to generate custom preview URL\n */\n preview?: GeneratePreviewURL\n}\n\ntype GlobalHooks = {\n afterChange?: AfterChangeHook[]\n afterRead?: AfterReadHook[]\n beforeChange?: BeforeChangeHook[]\n beforeOperation?: BeforeOperationHook[]\n beforeRead?: BeforeReadHook[]\n beforeValidate?: BeforeValidateHook[]\n}\n\nexport type GlobalConfig<TSlug extends GlobalSlug = any> = {\n /**\n * Do not set this property manually. This is set to true during sanitization, to avoid\n * sanitizing the same global multiple times.\n */\n _sanitized?: boolean\n access?: GlobalAccess\n admin?: GlobalAdminOptions\n /**\n * Automatically track the user that created and last updated this global via\n * polymorphic `createdBy` / `updatedBy` relationship fields to your auth collections.\n *\n * Use `true` (default) to enable both, `false` to disable both, or an object to\n * toggle each field independently, e.g. `{ updatedBy: false }`.\n *\n * @default true\n */\n authorship?: Authorship | boolean\n /** Extension point to add your custom data. Server only. */\n custom?: GlobalCustom\n /**\n * Customize the SQL table name\n */\n dbName?: DBIdentifierName\n endpoints?: false | Omit<Endpoint, 'root'>[]\n fields: Field[]\n graphQL?:\n | {\n disableMutations?: true\n disableQueries?: true\n name?: string\n }\n | false\n hooks?: GlobalHooks\n label?: LabelFunction | StaticLabel\n /** Read-only Markdown instructions included in this global's MCP and CLI schema responses. */\n llmInstructions?: string\n /**\n * Enables / Disables the ability to lock documents while editing\n * @default true\n */\n lockDocuments?:\n | {\n duration: number\n }\n | false\n slug: string\n /**\n * Options used in typescript generation\n */\n typescript?: {\n /**\n * Typescript generation name given to the interface type\n */\n interface?: string\n }\n versions?: boolean | IncomingGlobalVersions\n} & Pick<\n WithSelectFn<\n IsAny<SelectFromGlobalSlug<TSlug>> extends true\n ? SelectIncludeType\n : SelectFromGlobalSlug<TSlug>\n >,\n 'select'\n>\n\nexport interface SanitizedGlobalConfig\n extends\n Omit<\n GlobalConfig,\n | '_sanitized'\n | 'access'\n | 'admin'\n | 'authorship'\n | 'custom'\n | 'endpoints'\n | 'hooks'\n | 'label'\n | 'slug'\n | 'versions'\n >,\n Required<Pick<GlobalConfig, 'admin' | 'custom' | 'label'>> {\n _sanitized: true\n access: Required<Pick<GlobalAccess, 'read' | 'readVersions' | 'update' | 'validate'>>\n authorship: SanitizedAuthorship\n endpoints: Endpoint[] | false\n /**\n * Fields in the database schema structure\n * Rows / collapsible / tabs w/o name `fields` merged to top, UIs are excluded\n */\n flattenedFields: FlattenedField[]\n hooks: Required<GlobalHooks>\n slug: GlobalSlug\n versions?: SanitizedGlobalVersions\n}\n\nexport type Globals = {\n config: SanitizedGlobalConfig[]\n graphQL?:\n | {\n [slug: string]: {\n mutationInputType: GraphQLNonNull<any>\n type: GraphQLObjectType\n versionType?: GraphQLObjectType\n }\n }\n | false\n}\n"],"names":[],"mappings":"AAAA,qDAAqD,GAiUrD,WAWC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addHierarchyToCollection.d.ts","sourceRoot":"","sources":["../../src/hierarchy/addHierarchyToCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;
|
|
1
|
+
{"version":3,"file":"addHierarchyToCollection.d.ts","sourceRoot":"","sources":["../../src/hierarchy/addHierarchyToCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAUtE,eAAO,MAAM,wBAAwB,iGAMlC;IACD,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,iBAAiB,EAAE,MAAM,CAAA;IACzB,kBAAkB,EAAE,MAAM,CAAA;CAC3B,SA6EA,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fieldAffectsData } from '../fields/config/types.js';
|
|
1
2
|
import { hierarchyCollectionAfterRead } from './hooks/collectionAfterRead.js';
|
|
2
3
|
import { hierarchyCollectionBeforeChange } from './hooks/collectionBeforeChange.js';
|
|
3
4
|
import { hierarchyCollectionBeforeDelete } from './hooks/collectionBeforeDelete.js';
|
|
@@ -8,28 +9,38 @@ export const addHierarchyToCollection = ({ collectionConfig, parentFieldName, sl
|
|
|
8
9
|
// Verify slug field exists if configured
|
|
9
10
|
const slugFieldInfo = slugFieldName ? findFieldByName(collectionConfig, slugFieldName) : undefined;
|
|
10
11
|
const validatedSlugFieldName = slugFieldInfo ? slugFieldName : undefined;
|
|
11
|
-
// Add virtual path fields (computed in afterRead)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
// Add virtual path fields (computed in afterRead). This can run again on the same
|
|
13
|
+
// `fields` array, so skip fields that already exist
|
|
14
|
+
const pathFields = [
|
|
15
|
+
{
|
|
16
|
+
name: slugPathFieldName,
|
|
17
|
+
type: 'text',
|
|
18
|
+
admin: {
|
|
19
|
+
hidden: true,
|
|
20
|
+
readOnly: true
|
|
21
|
+
},
|
|
22
|
+
index: true,
|
|
23
|
+
label: 'Slug Path',
|
|
24
|
+
virtual: true
|
|
18
25
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
{
|
|
27
|
+
name: titlePathFieldName,
|
|
28
|
+
type: 'text',
|
|
29
|
+
admin: {
|
|
30
|
+
hidden: true,
|
|
31
|
+
readOnly: true
|
|
32
|
+
},
|
|
33
|
+
index: true,
|
|
34
|
+
label: 'Title Path',
|
|
35
|
+
virtual: true
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
for (const pathField of pathFields){
|
|
39
|
+
const hasPathField = collectionConfig.fields.some((field)=>fieldAffectsData(field) && field.name === pathField.name);
|
|
40
|
+
if (!hasPathField) {
|
|
41
|
+
collectionConfig.fields.push(pathField);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
33
44
|
if (!collectionConfig.admin) {
|
|
34
45
|
collectionConfig.admin = {};
|
|
35
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hierarchy/addHierarchyToCollection.ts"],"sourcesContent":["import type { CollectionConfig } from '../collections/config/types.js'\n\nimport { hierarchyCollectionAfterRead } from './hooks/collectionAfterRead.js'\nimport { hierarchyCollectionBeforeChange } from './hooks/collectionBeforeChange.js'\nimport { hierarchyCollectionBeforeDelete } from './hooks/collectionBeforeDelete.js'\nimport { hierarchyCollectionBeforeOperation } from './hooks/collectionBeforeOperation.js'\nimport { findFieldByName, findUseAsTitleField } from './utils/findUseAsTitle.js'\n\nexport const addHierarchyToCollection = ({\n collectionConfig,\n parentFieldName,\n slugFieldName,\n slugPathFieldName,\n titlePathFieldName,\n}: {\n collectionConfig: CollectionConfig\n parentFieldName: string\n slugFieldName?: string\n slugPathFieldName: string\n titlePathFieldName: string\n}) => {\n const { titleFieldName } = findUseAsTitleField(collectionConfig)\n // Verify slug field exists if configured\n const slugFieldInfo = slugFieldName ? findFieldByName(collectionConfig, slugFieldName) : undefined\n const validatedSlugFieldName = slugFieldInfo ? slugFieldName : undefined\n\n // Add virtual path fields (computed in afterRead)\n
|
|
1
|
+
{"version":3,"sources":["../../src/hierarchy/addHierarchyToCollection.ts"],"sourcesContent":["import type { CollectionConfig } from '../collections/config/types.js'\nimport type { TextField } from '../fields/config/types.js'\n\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { hierarchyCollectionAfterRead } from './hooks/collectionAfterRead.js'\nimport { hierarchyCollectionBeforeChange } from './hooks/collectionBeforeChange.js'\nimport { hierarchyCollectionBeforeDelete } from './hooks/collectionBeforeDelete.js'\nimport { hierarchyCollectionBeforeOperation } from './hooks/collectionBeforeOperation.js'\nimport { findFieldByName, findUseAsTitleField } from './utils/findUseAsTitle.js'\n\nexport const addHierarchyToCollection = ({\n collectionConfig,\n parentFieldName,\n slugFieldName,\n slugPathFieldName,\n titlePathFieldName,\n}: {\n collectionConfig: CollectionConfig\n parentFieldName: string\n slugFieldName?: string\n slugPathFieldName: string\n titlePathFieldName: string\n}) => {\n const { titleFieldName } = findUseAsTitleField(collectionConfig)\n // Verify slug field exists if configured\n const slugFieldInfo = slugFieldName ? findFieldByName(collectionConfig, slugFieldName) : undefined\n const validatedSlugFieldName = slugFieldInfo ? slugFieldName : undefined\n\n // Add virtual path fields (computed in afterRead). This can run again on the same\n // `fields` array, so skip fields that already exist\n const pathFields: TextField[] = [\n {\n name: slugPathFieldName,\n type: 'text',\n admin: {\n hidden: true,\n readOnly: true,\n },\n index: true,\n label: 'Slug Path',\n virtual: true,\n },\n {\n name: titlePathFieldName,\n type: 'text',\n admin: {\n hidden: true,\n readOnly: true,\n },\n index: true,\n label: 'Title Path',\n virtual: true,\n },\n ]\n\n for (const pathField of pathFields) {\n const hasPathField = collectionConfig.fields.some(\n (field) => fieldAffectsData(field) && field.name === pathField.name,\n )\n\n if (!hasPathField) {\n collectionConfig.fields.push(pathField)\n }\n }\n\n if (!collectionConfig.admin) {\n collectionConfig.admin = {}\n }\n if (!collectionConfig.admin.listSearchableFields) {\n collectionConfig.admin.listSearchableFields = [titleFieldName]\n } else if (!collectionConfig.admin.listSearchableFields.includes(titleFieldName)) {\n collectionConfig.admin.listSearchableFields.push(titleFieldName)\n }\n\n collectionConfig.hooks = {\n ...(collectionConfig.hooks || {}),\n afterRead: [\n ...(collectionConfig.hooks?.afterRead || []),\n hierarchyCollectionAfterRead({ parentFieldName, slugPathFieldName, titlePathFieldName }),\n ],\n beforeChange: [\n ...(collectionConfig.hooks?.beforeChange || []),\n hierarchyCollectionBeforeChange({ parentFieldName }),\n ],\n beforeDelete: [\n ...(collectionConfig.hooks?.beforeDelete || []),\n hierarchyCollectionBeforeDelete({ parentFieldName }),\n ],\n beforeOperation: [\n ...(collectionConfig.hooks?.beforeOperation || []),\n hierarchyCollectionBeforeOperation({\n parentFieldName,\n slugFieldName: validatedSlugFieldName,\n slugPathFieldName,\n titleFieldName,\n titlePathFieldName,\n }),\n ],\n }\n}\n"],"names":["fieldAffectsData","hierarchyCollectionAfterRead","hierarchyCollectionBeforeChange","hierarchyCollectionBeforeDelete","hierarchyCollectionBeforeOperation","findFieldByName","findUseAsTitleField","addHierarchyToCollection","collectionConfig","parentFieldName","slugFieldName","slugPathFieldName","titlePathFieldName","titleFieldName","slugFieldInfo","undefined","validatedSlugFieldName","pathFields","name","type","admin","hidden","readOnly","index","label","virtual","pathField","hasPathField","fields","some","field","push","listSearchableFields","includes","hooks","afterRead","beforeChange","beforeDelete","beforeOperation"],"mappings":"AAGA,SAASA,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,4BAA4B,QAAQ,iCAAgC;AAC7E,SAAS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AAiB;QAChFL,iBAAiBY,KAAK,CAACY,oBAAoB,CAACD,IAAI,CAAClB;IACnD;IAEAL,iBAAiB0B,KAAK,GAAG;QACvB,GAAI1B,iBAAiB0B,KAAK,IAAI,CAAC,CAAC;QAChCC,WAAW;eACL3B,iBAAiB0B,KAAK,EAAEC,aAAa,EAAE;YAC3ClC,6BAA6B;gBAAEQ;gBAAiBE;gBAAmBC;YAAmB;SACvF;QACDwB,cAAc;eACR5B,iBAAiB0B,KAAK,EAAEE,gBAAgB,EAAE;YAC9ClC,gCAAgC;gBAAEO;YAAgB;SACnD;QACD4B,cAAc;eACR7B,iBAAiB0B,KAAK,EAAEG,gBAAgB,EAAE;YAC9ClC,gCAAgC;gBAAEM;YAAgB;SACnD;QACD6B,iBAAiB;eACX9B,iBAAiB0B,KAAK,EAAEI,mBAAmB,EAAE;YACjDlC,mCAAmC;gBACjCK;gBACAC,eAAeM;gBACfL;gBACAE;gBACAD;YACF;SACD;IACH;AACF,EAAC"}
|
|
@@ -233,7 +233,13 @@ const validateCollectionSpecificHierarchy = async ({ hierarchySlug, options, typ
|
|
|
233
233
|
options: collectionOptions
|
|
234
234
|
};
|
|
235
235
|
hierarchyCollection.fields = hierarchyCollection.fields || [];
|
|
236
|
-
|
|
236
|
+
// This can run again on the same `fields` array, so replace the field if it already exists
|
|
237
|
+
const existingTypeFieldIndex = hierarchyCollection.fields.findIndex((field)=>fieldAffectsData(field) && field.name === typeFieldName);
|
|
238
|
+
if (existingTypeFieldIndex === -1) {
|
|
239
|
+
hierarchyCollection.fields.push(typeField);
|
|
240
|
+
} else {
|
|
241
|
+
hierarchyCollection.fields[existingTypeFieldIndex] = typeField;
|
|
242
|
+
}
|
|
237
243
|
// Recompute flattenedFields since we added a field after initial sanitization
|
|
238
244
|
// This is required for the field to be queryable
|
|
239
245
|
if ('flattenedFields' in hierarchyCollection) {
|