payload 3.83.0-internal.06ac84e → 3.83.0-internal.86b7bfb
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/bin/generateImportMap/index.d.ts.map +1 -1
- package/dist/bin/generateImportMap/index.js +1 -0
- package/dist/bin/generateImportMap/index.js.map +1 -1
- package/dist/bin/index.d.ts.map +1 -1
- package/dist/bin/index.js +3 -1
- package/dist/bin/index.js.map +1 -1
- package/dist/config/build.js +5 -4
- package/dist/config/build.js.map +1 -1
- package/dist/config/definePlugin.d.ts +41 -0
- package/dist/config/definePlugin.d.ts.map +1 -0
- package/dist/config/definePlugin.js +34 -0
- package/dist/config/definePlugin.js.map +1 -0
- package/dist/config/types.d.ts +23 -2
- package/dist/config/types.d.ts.map +1 -1
- package/dist/config/types.js.map +1 -1
- package/dist/errors/APIError.d.ts +2 -1
- package/dist/errors/APIError.d.ts.map +1 -1
- package/dist/errors/APIError.js +1 -3
- package/dist/errors/APIError.js.map +1 -1
- package/dist/errors/ValidationError.d.ts +2 -1
- package/dist/errors/ValidationError.d.ts.map +1 -1
- package/dist/errors/ValidationError.js +1 -3
- package/dist/errors/ValidationError.js.map +1 -1
- package/dist/fields/config/sanitize.d.ts.map +1 -1
- package/dist/fields/config/sanitize.js +3 -0
- package/dist/fields/config/sanitize.js.map +1 -1
- package/dist/fields/config/sanitize.spec.js +66 -0
- package/dist/fields/config/sanitize.spec.js.map +1 -1
- package/dist/fields/config/types.d.ts +3 -2
- package/dist/fields/config/types.d.ts.map +1 -1
- package/dist/fields/config/types.js.map +1 -1
- package/dist/index.bundled.d.ts +431 -101
- package/dist/index.d.ts +19 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/queues/config/collection.d.ts.map +1 -1
- package/dist/queues/config/collection.js +0 -1
- package/dist/queues/config/collection.js.map +1 -1
- package/dist/queues/endpoints/run.d.ts.map +1 -1
- package/dist/queues/endpoints/run.js +0 -3
- package/dist/queues/endpoints/run.js.map +1 -1
- package/dist/queues/errors/calculateBackoffWaitUntil.d.ts.map +1 -1
- package/dist/queues/errors/calculateBackoffWaitUntil.js +5 -13
- package/dist/queues/errors/calculateBackoffWaitUntil.js.map +1 -1
- package/dist/queues/operations/handleSchedules/countRunnableOrActiveJobsForQueue.d.ts.map +1 -1
- package/dist/queues/operations/handleSchedules/countRunnableOrActiveJobsForQueue.js +2 -1
- package/dist/queues/operations/handleSchedules/countRunnableOrActiveJobsForQueue.js.map +1 -1
- package/dist/queues/operations/handleSchedules/defaultAfterSchedule.js +1 -1
- package/dist/queues/operations/handleSchedules/defaultAfterSchedule.js.map +1 -1
- package/dist/queues/operations/handleSchedules/index.d.ts.map +1 -1
- package/dist/queues/operations/handleSchedules/index.js +4 -1
- package/dist/queues/operations/handleSchedules/index.js.map +1 -1
- package/dist/queues/operations/runJobs/index.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/index.js +11 -16
- package/dist/queues/operations/runJobs/index.js.map +1 -1
- package/dist/queues/operations/runJobs/runJSONJob/index.d.ts.map +1 -1
- package/dist/queues/operations/runJobs/runJSONJob/index.js +1 -0
- package/dist/queues/operations/runJobs/runJSONJob/index.js.map +1 -1
- package/dist/queues/utilities/updateJob.d.ts.map +1 -1
- package/dist/queues/utilities/updateJob.js +2 -1
- package/dist/queues/utilities/updateJob.js.map +1 -1
- package/dist/utilities/filterDataToSelectedLocales.d.ts.map +1 -1
- package/dist/utilities/filterDataToSelectedLocales.js +74 -31
- package/dist/utilities/filterDataToSelectedLocales.js.map +1 -1
- package/dist/utilities/filterDataToSelectedLocales.spec.js +337 -0
- package/dist/utilities/filterDataToSelectedLocales.spec.js.map +1 -1
- package/dist/utilities/formatErrors.d.ts +1 -1
- package/dist/utilities/formatErrors.d.ts.map +1 -1
- package/dist/utilities/formatErrors.js +4 -7
- package/dist/utilities/formatErrors.js.map +1 -1
- package/dist/utilities/formatErrors.spec.js +101 -0
- package/dist/utilities/formatErrors.spec.js.map +1 -0
- package/dist/utilities/parseParams/index.d.ts +1 -1
- package/dist/utilities/parseParams/index.d.ts.map +1 -1
- package/dist/utilities/parseParams/index.js +3 -0
- package/dist/utilities/parseParams/index.js.map +1 -1
- package/dist/utilities/parseParams/index.spec.js +24 -0
- package/dist/utilities/parseParams/index.spec.js.map +1 -1
- package/dist/utilities/profiling.d.ts +12 -0
- package/dist/utilities/profiling.d.ts.map +1 -0
- package/dist/utilities/profiling.js +56 -0
- package/dist/utilities/profiling.js.map +1 -0
- package/dist/utilities/profiling.spec.js +53 -0
- package/dist/utilities/profiling.spec.js.map +1 -0
- package/dist/versions/saveVersion.js +1 -1
- package/dist/versions/saveVersion.js.map +1 -1
- package/dist/versions/updateLatestVersion.d.ts.map +1 -1
- package/dist/versions/updateLatestVersion.js +55 -8
- package/dist/versions/updateLatestVersion.js.map +1 -1
- package/package.json +4 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/config/sanitize.ts"],"sourcesContent":["import { deepMergeSimple } from '@payloadcms/translations/utilities'\n\nimport type {\n CollectionConfig,\n SanitizedJoin,\n SanitizedJoins,\n} from '../../collections/config/types.js'\nimport type { Config, SanitizedConfig } from '../../config/types.js'\nimport type { GlobalConfig } from '../../globals/config/types.js'\nimport type { OrderableJoinInfo } from './sanitizeJoinField.js'\nimport type { Field } from './types.js'\n\nimport {\n DuplicateFieldName,\n InvalidConfiguration,\n InvalidFieldName,\n InvalidFieldRelationship,\n MissingEditorProp,\n MissingFieldType,\n} from '../../errors/index.js'\nimport { ReservedFieldName } from '../../errors/ReservedFieldName.js'\nimport { flattenAllFields } from '../../utilities/flattenAllFields.js'\nimport { formatLabels, toWords } from '../../utilities/formatLabels.js'\nimport { validateTimezones } from '../../utilities/validateTimezones.js'\nimport { baseBlockFields } from '../baseFields/baseBlockFields.js'\nimport { baseIDField } from '../baseFields/baseIDField.js'\nimport { baseTimezoneField } from '../baseFields/timezone/baseField.js'\nimport { defaultTimezones } from '../baseFields/timezone/defaultTimezones.js'\nimport { getFieldPaths } from '../getFieldPaths.js'\nimport { setDefaultBeforeDuplicate } from '../setDefaultBeforeDuplicate.js'\nimport { validations } from '../validations.js'\nimport {\n reservedAPIKeyFieldNames,\n reservedBaseAuthFieldNames,\n reservedBaseUploadFieldNames,\n reservedVerifyFieldNames,\n} from './reservedFieldNames.js'\nimport { sanitizeJoinField } from './sanitizeJoinField.js'\nimport { fieldAffectsData as _fieldAffectsData, fieldIsLocalized, tabHasName } from './types.js'\n\ntype SanitizeFieldsArgs = {\n collectionConfig?: CollectionConfig\n config: Config\n existingFieldNames?: Set<string>\n fields: Field[]\n globalConfig?: GlobalConfig\n /**\n * Used to prevent unnecessary sanitization of fields that are not top-level.\n */\n isTopLevelField?: boolean\n joinPath?: string\n /**\n * When not passed in, assume that join are not supported (globals, arrays, blocks)\n */\n joins?: SanitizedJoins\n /**\n * Tracker for orderable join fields - populated during sanitization\n */\n orderableJoins?: OrderableJoinInfo[]\n /**\n * A string of '-' separated indexes representing where\n * to find this field in a given field schema array.\n */\n parentIndexPath?: string\n parentIsLocalized: boolean\n /**\n * Path for parent fields relative to their position in the schema.\n */\n parentSchemaPath?: string\n polymorphicJoins?: SanitizedJoin[]\n /**\n * If true, a richText field will require an editor property to be set, as the sanitizeFields function will not add it from the payload config if not present.\n *\n * @default false\n */\n requireFieldLevelRichTextEditor?: boolean\n /**\n * If this property is set, RichText fields won't be sanitized immediately. Instead, they will be added to this array as promises\n * so that you can sanitize them together, after the config has been sanitized.\n */\n richTextSanitizationPromises?: Array<(config: SanitizedConfig) => Promise<void>>\n /**\n * If not null, will validate that upload and relationship fields do not relate to a collection that is not in this array.\n * This validation will be skipped if validRelationships is null.\n */\n validRelationships: null | string[]\n}\n\nexport type SanitizeFieldArgs = {\n collectionConfig?: CollectionConfig\n config: Config\n existingFieldNames: Set<string>\n field: Field\n globalConfig?: GlobalConfig\n /**\n * The index of this field in the parent fields array\n */\n index: number\n /**\n * Used to prevent unnecessary sanitization of fields that are not top-level.\n */\n isTopLevelField: boolean\n joinPath: string\n /**\n * When not passed in, assume that joins are not supported (globals, arrays, blocks)\n */\n joins?: SanitizedJoins\n /**\n * Tracker for orderable join fields - populated during sanitization\n */\n orderableJoins?: OrderableJoinInfo[]\n parentIndexPath: string\n parentIsLocalized: boolean\n parentSchemaPath: string\n polymorphicJoins?: SanitizedJoin[]\n requireFieldLevelRichTextEditor: boolean\n richTextSanitizationPromises?: Array<(config: SanitizedConfig) => Promise<void>>\n validRelationships: null | string[]\n}\n\ntype SanitizeFieldResult = {\n /**\n * Fields to insert after this field (e.g., timezone field)\n */\n fieldsToInsert?: Field[]\n}\n\n/**\n * Sanitize a single field. Handles all per-field logic including:\n * - Validation setup\n * - Hooks/access/admin defaults\n * - Type-specific handling\n * - Recursive sanitization of nested fields\n *\n * @returns Result containing any fields to insert after this one\n */\nexport const sanitizeField = async ({\n collectionConfig,\n config,\n existingFieldNames,\n field,\n globalConfig,\n index,\n isTopLevelField,\n joinPath,\n joins,\n orderableJoins,\n parentIndexPath,\n parentIsLocalized,\n parentSchemaPath,\n polymorphicJoins,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n}: SanitizeFieldArgs): Promise<SanitizeFieldResult> => {\n const result: SanitizeFieldResult = {}\n\n if ('_sanitized' in field && field._sanitized === true) {\n return result\n }\n\n if ('_sanitized' in field) {\n field._sanitized = true\n }\n\n if (!field.type) {\n throw new MissingFieldType(field)\n }\n\n const fieldAffectsData = _fieldAffectsData(field)\n\n const { indexPath, schemaPath } = getFieldPaths({\n field,\n index,\n parentIndexPath,\n parentSchemaPath,\n })\n\n // Reserved field name checks\n if (isTopLevelField && fieldAffectsData && field.name) {\n if (collectionConfig && collectionConfig.upload) {\n if (reservedBaseUploadFieldNames.includes(field.name)) {\n throw new ReservedFieldName(field, field.name)\n }\n }\n\n if (\n collectionConfig &&\n collectionConfig.auth &&\n typeof collectionConfig.auth === 'object' &&\n !collectionConfig.auth.disableLocalStrategy\n ) {\n if (reservedBaseAuthFieldNames.includes(field.name)) {\n throw new ReservedFieldName(field, field.name)\n }\n\n if (collectionConfig.auth.verify) {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n if (reservedAPIKeyFieldNames.includes(field.name)) {\n throw new ReservedFieldName(field, field.name)\n }\n\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n if (reservedVerifyFieldNames.includes(field.name)) {\n throw new ReservedFieldName(field, field.name)\n }\n }\n }\n }\n\n // Invalid field name check\n if (fieldAffectsData && field.name.includes('.')) {\n throw new InvalidFieldName(field, field.name)\n }\n\n // Auto-label\n if (\n 'name' in field &&\n field.name &&\n typeof field.label !== 'object' &&\n typeof field.label !== 'string' &&\n typeof field.label !== 'function' &&\n field.label !== false\n ) {\n field.label = toWords(field.name)\n }\n\n // Checkbox default\n if (\n field.type === 'checkbox' &&\n typeof field.defaultValue === 'undefined' &&\n field.required === true\n ) {\n field.defaultValue = false\n }\n\n // Join field sanitization\n if (field.type === 'join') {\n sanitizeJoinField({\n config,\n field,\n joinPath,\n joins,\n orderableJoins,\n parentIsLocalized,\n polymorphicJoins,\n })\n }\n\n // Relationship/upload validation\n if (field.type === 'relationship' || field.type === 'upload') {\n if (Array.isArray(field.relationTo) && field.relationTo.length === 0) {\n throw new Error(\n `Field \"${field.name}\" of type \"${field.type}\" has an empty relationTo array. At least one collection must be specified.`,\n )\n }\n\n if (validRelationships) {\n const relationships = Array.isArray(field.relationTo) ? field.relationTo : [field.relationTo]\n\n relationships.forEach((relationship: string) => {\n if (!validRelationships.includes(relationship)) {\n throw new InvalidFieldRelationship(field, relationship)\n }\n })\n }\n\n if (field.min && !field.minRows) {\n console.warn(\n `(payload): The \"min\" property is deprecated for the Relationship field \"${field.name}\" and will be removed in a future version. Please use \"minRows\" instead.`,\n )\n field.minRows = field.min\n }\n\n if (field.max && !field.maxRows) {\n console.warn(\n `(payload): The \"max\" property is deprecated for the Relationship field \"${field.name}\" and will be removed in a future version. Please use \"maxRows\" instead.`,\n )\n field.maxRows = field.max\n }\n }\n\n // Upload isSortable default\n if (field.type === 'upload') {\n if (!field.admin || !('isSortable' in field.admin)) {\n field.admin = {\n isSortable: true,\n ...field.admin,\n }\n }\n }\n\n // Array ID field\n if (field.type === 'array' && field.fields) {\n const hasCustomID = field.fields.some((f) => 'name' in f && f.name === 'id')\n if (!hasCustomID) {\n field.fields.push(baseIDField)\n }\n }\n\n // Blocks/array labels\n if ((field.type === 'blocks' || field.type === 'array') && field.label) {\n field.labels = field.labels || formatLabels(field.name)\n }\n\n if (fieldAffectsData) {\n if (existingFieldNames.has(field.name)) {\n throw new DuplicateFieldName(field.name)\n } else if (!['blockName', 'id'].includes(field.name)) {\n existingFieldNames.add(field.name)\n }\n\n if (typeof field.localized !== 'undefined') {\n let shouldDisableLocalized = !config.localization\n\n if (\n process.env.NEXT_PUBLIC_PAYLOAD_COMPATIBILITY_allowLocalizedWithinLocalized !== 'true' &&\n parentIsLocalized &&\n // @todo PAYLOAD_DO_NOT_SANITIZE_LOCALIZED_PROPERTY=true will be the default in 4.0\n process.env.PAYLOAD_DO_NOT_SANITIZE_LOCALIZED_PROPERTY !== 'true'\n ) {\n shouldDisableLocalized = true\n }\n\n if (shouldDisableLocalized) {\n delete field.localized\n }\n }\n\n if (typeof field.validate === 'undefined') {\n if ('virtual' in field && field.virtual) {\n field.validate = (): true => true\n } else {\n const defaultValidate = validations[field.type as keyof typeof validations]\n if (defaultValidate) {\n field.validate = (val: any, options: any) =>\n defaultValidate(val, { ...field, ...options })\n } else {\n field.validate = (): true => true\n }\n }\n }\n\n if (!field.hooks) {\n field.hooks = {}\n }\n\n if (!field.access) {\n field.access = {}\n }\n\n setDefaultBeforeDuplicate(field, parentIsLocalized)\n }\n\n if (!field.admin) {\n field.admin = {}\n }\n\n // Make sure that the richText field has an editor\n if (field.type === 'richText') {\n const sanitizeRichText = async (_config: SanitizedConfig) => {\n if (!field.editor) {\n if (_config.editor && !requireFieldLevelRichTextEditor) {\n // config.editor should be sanitized at this point\n field.editor = _config.editor\n } else {\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\n if (typeof field.editor === 'function') {\n field.editor = await field.editor({\n config: _config,\n isRoot: requireFieldLevelRichTextEditor,\n parentIsLocalized: (parentIsLocalized || field.localized)!,\n })\n }\n\n if (field.editor.i18n && Object.keys(field.editor.i18n).length >= 0) {\n config.i18n!.translations = deepMergeSimple(config.i18n!.translations!, field.editor.i18n)\n }\n }\n if (richTextSanitizationPromises) {\n richTextSanitizationPromises.push(sanitizeRichText)\n } else {\n await sanitizeRichText(config as unknown as SanitizedConfig)\n }\n }\n\n if (field.type === 'blocks' && field.blocks) {\n if (field.blockReferences && field.blocks?.length) {\n throw new Error('You cannot have both blockReferences and blocks in the same blocks field')\n }\n\n const blockSlugs: string[] = []\n\n for (const block of field.blockReferences ?? field.blocks) {\n const blockSlug = typeof block === 'string' ? block : block.slug\n\n if (blockSlugs.includes(blockSlug)) {\n throw new DuplicateFieldName(blockSlug)\n }\n\n blockSlugs.push(blockSlug)\n\n if (typeof block === 'string') {\n continue\n }\n\n if (block._sanitized === true) {\n continue\n }\n\n block._sanitized = true\n block.fields = block.fields.concat(baseBlockFields)\n block.labels = !block.labels ? formatLabels(block.slug) : block.labels\n\n block.fields = await sanitizeFields({\n collectionConfig,\n config,\n existingFieldNames: new Set(),\n fields: block.fields,\n isTopLevelField: false,\n parentIndexPath: '',\n parentIsLocalized: (parentIsLocalized || field.localized)!,\n parentSchemaPath: schemaPath + '.' + block.slug,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n }\n\n if ('fields' in field && field.fields) {\n field.fields = await sanitizeFields({\n collectionConfig,\n config,\n existingFieldNames: fieldAffectsData ? new Set() : existingFieldNames,\n fields: field.fields,\n isTopLevelField: isTopLevelField && !fieldAffectsData,\n joinPath: fieldAffectsData ? `${joinPath ? joinPath + '.' : ''}${field.name}` : joinPath,\n joins,\n orderableJoins,\n parentIndexPath: fieldAffectsData ? '' : indexPath,\n parentIsLocalized: parentIsLocalized || fieldIsLocalized(field),\n parentSchemaPath: schemaPath,\n polymorphicJoins,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n\n if (field.type === 'tabs') {\n for (let j = 0; j < field.tabs.length; j++) {\n const tab = field.tabs[j]!\n\n const isNamedTab = tabHasName(tab)\n\n if (isNamedTab && typeof tab.label === 'undefined') {\n tab.label = toWords(tab.name)\n }\n\n const { indexPath: tabIndexPath, schemaPath: tabSchemaPath } = getFieldPaths({\n field: tab,\n index: j,\n parentIndexPath: indexPath,\n parentSchemaPath: schemaPath,\n })\n\n if (\n 'admin' in tab &&\n tab.admin?.condition &&\n typeof tab.admin.condition === 'function' &&\n !tab.id\n ) {\n tab.id = tabSchemaPath\n }\n\n tab.fields = await sanitizeFields({\n collectionConfig,\n config,\n existingFieldNames: isNamedTab ? new Set() : existingFieldNames,\n fields: tab.fields,\n isTopLevelField: isTopLevelField && !isNamedTab,\n joinPath: isNamedTab ? `${joinPath ? joinPath + '.' : ''}${tab.name}` : joinPath,\n joins,\n orderableJoins,\n parentIndexPath: isNamedTab ? '' : tabIndexPath,\n parentIsLocalized: parentIsLocalized || (isNamedTab && tab.localized)!,\n parentSchemaPath: tabSchemaPath,\n polymorphicJoins,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n\n field.tabs[j] = tab\n }\n }\n\n if (field.type === 'ui' && typeof field.admin.disableBulkEdit === 'undefined') {\n field.admin.disableBulkEdit = true\n }\n\n // Timezone field insertion\n if (field.type === 'date' && field.timezone) {\n const name = field.name + '_tz'\n\n let defaultTimezone =\n field.timezone && typeof field.timezone === 'object'\n ? field.timezone.defaultTimezone\n : config.admin?.timezones?.defaultTimezone\n\n const required =\n field.required ||\n (field.timezone && typeof field.timezone === 'object' && field.timezone.required)\n\n const supportedTimezones =\n field.timezone && typeof field.timezone === 'object' && field.timezone.supportedTimezones\n ? field.timezone.supportedTimezones\n : config.admin?.timezones?.supportedTimezones\n\n const options =\n typeof supportedTimezones === 'function'\n ? supportedTimezones({ defaultTimezones })\n : supportedTimezones\n\n validateTimezones({\n source: `field \"${field.name}\" timezone.supportedTimezones`,\n timezones: options,\n })\n\n if (options && options.length === 1 && options[0]?.value) {\n defaultTimezone = options[0].value\n }\n\n // Generate label for timezone field\n const timezoneLabel = typeof field.label === 'string' ? `${field.label} Tz` : toWords(name)\n\n const baseField = baseTimezoneField({\n name,\n defaultValue: defaultTimezone,\n label: timezoneLabel,\n options,\n required,\n })\n\n // Apply override if provided\n const timezoneField =\n typeof field.timezone === 'object' && typeof field.timezone.override === 'function'\n ? field.timezone.override({ baseField })\n : baseField\n\n result.fieldsToInsert = [timezoneField]\n }\n\n // Virtual field handling\n if ('virtual' in field && typeof field.virtual === 'string') {\n const virtualField = field\n const configFields = (collectionConfig || globalConfig)?.fields\n if (configFields) {\n let flattenFields = flattenAllFields({ fields: configFields })\n const paths = field.virtual.split('.')\n let isHasMany = false\n\n for (const [idx, segment] of paths.entries()) {\n const foundField = flattenFields.find((e) => e.name === segment)\n if (!foundField) {\n break\n }\n\n if (\n foundField.type === 'group' ||\n foundField.type === 'tab' ||\n foundField.type === 'array'\n ) {\n flattenFields = foundField.flattenedFields\n } else if (\n (foundField.type === 'relationship' || foundField.type === 'upload') &&\n idx !== paths.length - 1 &&\n typeof foundField.relationTo === 'string'\n ) {\n if (\n foundField.hasMany &&\n (virtualField.type === 'text' ||\n virtualField.type === 'number' ||\n virtualField.type === 'select')\n ) {\n if (isHasMany) {\n throw new InvalidConfiguration(\n `Virtual field ${virtualField.name} in ${globalConfig ? `global ${globalConfig.slug}` : `collection ${collectionConfig?.slug}`} references 2 or more hasMany relationships on the path ${virtualField.virtual} which is not allowed.`,\n )\n }\n\n isHasMany = true\n virtualField.hasMany = true\n }\n const relatedCollection = config.collections?.find(\n (e) => e.slug === foundField.relationTo,\n )\n if (relatedCollection) {\n flattenFields = flattenAllFields({ fields: relatedCollection.fields })\n }\n }\n }\n }\n }\n\n return result\n}\n\nexport const sanitizeFields = async ({\n collectionConfig,\n config,\n existingFieldNames = new Set(),\n fields,\n globalConfig,\n isTopLevelField = true,\n joinPath = '',\n joins,\n orderableJoins,\n parentIndexPath = '',\n parentIsLocalized,\n parentSchemaPath = '',\n polymorphicJoins,\n requireFieldLevelRichTextEditor = false,\n richTextSanitizationPromises,\n validRelationships,\n}: SanitizeFieldsArgs): Promise<Field[]> => {\n if (!fields) {\n return []\n }\n\n for (let i = 0; i < fields.length; i++) {\n const field = fields[i]!\n\n const result = await sanitizeField({\n collectionConfig,\n config,\n existingFieldNames,\n field,\n globalConfig,\n index: i,\n isTopLevelField,\n joinPath,\n joins,\n orderableJoins,\n parentIndexPath,\n parentIsLocalized,\n parentSchemaPath,\n polymorphicJoins,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n\n fields[i] = field\n\n if (result.fieldsToInsert?.length) {\n fields.splice(i + 1, 0, ...result.fieldsToInsert)\n i += result.fieldsToInsert.length\n }\n }\n\n return fields\n}\n"],"names":["deepMergeSimple","DuplicateFieldName","InvalidConfiguration","InvalidFieldName","InvalidFieldRelationship","MissingEditorProp","MissingFieldType","ReservedFieldName","flattenAllFields","formatLabels","toWords","validateTimezones","baseBlockFields","baseIDField","baseTimezoneField","defaultTimezones","getFieldPaths","setDefaultBeforeDuplicate","validations","reservedAPIKeyFieldNames","reservedBaseAuthFieldNames","reservedBaseUploadFieldNames","reservedVerifyFieldNames","sanitizeJoinField","fieldAffectsData","_fieldAffectsData","fieldIsLocalized","tabHasName","sanitizeField","collectionConfig","config","existingFieldNames","field","globalConfig","index","isTopLevelField","joinPath","joins","orderableJoins","parentIndexPath","parentIsLocalized","parentSchemaPath","polymorphicJoins","requireFieldLevelRichTextEditor","richTextSanitizationPromises","validRelationships","result","_sanitized","type","indexPath","schemaPath","name","upload","includes","auth","disableLocalStrategy","verify","label","defaultValue","required","Array","isArray","relationTo","length","Error","relationships","forEach","relationship","min","minRows","console","warn","max","maxRows","admin","isSortable","fields","hasCustomID","some","f","push","labels","has","add","localized","shouldDisableLocalized","localization","process","env","NEXT_PUBLIC_PAYLOAD_COMPATIBILITY_allowLocalizedWithinLocalized","PAYLOAD_DO_NOT_SANITIZE_LOCALIZED_PROPERTY","validate","virtual","defaultValidate","val","options","hooks","access","sanitizeRichText","_config","editor","isRoot","i18n","Object","keys","translations","blocks","blockReferences","blockSlugs","block","blockSlug","slug","concat","sanitizeFields","Set","j","tabs","tab","isNamedTab","tabIndexPath","tabSchemaPath","condition","id","disableBulkEdit","timezone","defaultTimezone","timezones","supportedTimezones","source","value","timezoneLabel","baseField","timezoneField","override","fieldsToInsert","virtualField","configFields","flattenFields","paths","split","isHasMany","idx","segment","entries","foundField","find","e","flattenedFields","hasMany","relatedCollection","collections","i","splice"],"mappings":"AAAA,SAASA,eAAe,QAAQ,qCAAoC;AAYpE,SACEC,kBAAkB,EAClBC,oBAAoB,EACpBC,gBAAgB,EAChBC,wBAAwB,EACxBC,iBAAiB,EACjBC,gBAAgB,QACX,wBAAuB;AAC9B,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,gBAAgB,QAAQ,sCAAqC;AACtE,SAASC,YAAY,EAAEC,OAAO,QAAQ,kCAAiC;AACvE,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,mCAAkC;AAClE,SAASC,WAAW,QAAQ,+BAA8B;AAC1D,SAASC,iBAAiB,QAAQ,sCAAqC;AACvE,SAASC,gBAAgB,QAAQ,6CAA4C;AAC7E,SAASC,aAAa,QAAQ,sBAAqB;AACnD,SAASC,yBAAyB,QAAQ,kCAAiC;AAC3E,SAASC,WAAW,QAAQ,oBAAmB;AAC/C,SACEC,wBAAwB,EACxBC,0BAA0B,EAC1BC,4BAA4B,EAC5BC,wBAAwB,QACnB,0BAAy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,IAAI,GAAG,MAAMzG,OAAOwF,cAAc;YAChDiB,KAAKzG,OAAOwF,cAAc,CAACvE,MAAM;QACnC;IACF;IAEA,OAAOa;AACT,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/config/sanitize.ts"],"sourcesContent":["import { deepMergeSimple } from '@payloadcms/translations/utilities'\n\nimport type {\n CollectionConfig,\n SanitizedJoin,\n SanitizedJoins,\n} from '../../collections/config/types.js'\nimport type { Config, SanitizedConfig } from '../../config/types.js'\nimport type { GlobalConfig } from '../../globals/config/types.js'\nimport type { OrderableJoinInfo } from './sanitizeJoinField.js'\nimport type { Field } from './types.js'\n\nimport {\n DuplicateFieldName,\n InvalidConfiguration,\n InvalidFieldName,\n InvalidFieldRelationship,\n MissingEditorProp,\n MissingFieldType,\n} from '../../errors/index.js'\nimport { ReservedFieldName } from '../../errors/ReservedFieldName.js'\nimport { flattenAllFields } from '../../utilities/flattenAllFields.js'\nimport { formatLabels, toWords } from '../../utilities/formatLabels.js'\nimport { validateTimezones } from '../../utilities/validateTimezones.js'\nimport { baseBlockFields } from '../baseFields/baseBlockFields.js'\nimport { baseIDField } from '../baseFields/baseIDField.js'\nimport { baseTimezoneField } from '../baseFields/timezone/baseField.js'\nimport { defaultTimezones } from '../baseFields/timezone/defaultTimezones.js'\nimport { getFieldPaths } from '../getFieldPaths.js'\nimport { setDefaultBeforeDuplicate } from '../setDefaultBeforeDuplicate.js'\nimport { validations } from '../validations.js'\nimport {\n reservedAPIKeyFieldNames,\n reservedBaseAuthFieldNames,\n reservedBaseUploadFieldNames,\n reservedVerifyFieldNames,\n} from './reservedFieldNames.js'\nimport { sanitizeJoinField } from './sanitizeJoinField.js'\nimport { fieldAffectsData as _fieldAffectsData, fieldIsLocalized, tabHasName } from './types.js'\n\ntype SanitizeFieldsArgs = {\n collectionConfig?: CollectionConfig\n config: Config\n existingFieldNames?: Set<string>\n fields: Field[]\n globalConfig?: GlobalConfig\n /**\n * Used to prevent unnecessary sanitization of fields that are not top-level.\n */\n isTopLevelField?: boolean\n joinPath?: string\n /**\n * When not passed in, assume that join are not supported (globals, arrays, blocks)\n */\n joins?: SanitizedJoins\n /**\n * Tracker for orderable join fields - populated during sanitization\n */\n orderableJoins?: OrderableJoinInfo[]\n /**\n * A string of '-' separated indexes representing where\n * to find this field in a given field schema array.\n */\n parentIndexPath?: string\n parentIsLocalized: boolean\n /**\n * Path for parent fields relative to their position in the schema.\n */\n parentSchemaPath?: string\n polymorphicJoins?: SanitizedJoin[]\n /**\n * If true, a richText field will require an editor property to be set, as the sanitizeFields function will not add it from the payload config if not present.\n *\n * @default false\n */\n requireFieldLevelRichTextEditor?: boolean\n /**\n * If this property is set, RichText fields won't be sanitized immediately. Instead, they will be added to this array as promises\n * so that you can sanitize them together, after the config has been sanitized.\n */\n richTextSanitizationPromises?: Array<(config: SanitizedConfig) => Promise<void>>\n /**\n * If not null, will validate that upload and relationship fields do not relate to a collection that is not in this array.\n * This validation will be skipped if validRelationships is null.\n */\n validRelationships: null | string[]\n}\n\nexport type SanitizeFieldArgs = {\n collectionConfig?: CollectionConfig\n config: Config\n existingFieldNames: Set<string>\n field: Field\n globalConfig?: GlobalConfig\n /**\n * The index of this field in the parent fields array\n */\n index: number\n /**\n * Used to prevent unnecessary sanitization of fields that are not top-level.\n */\n isTopLevelField: boolean\n joinPath: string\n /**\n * When not passed in, assume that joins are not supported (globals, arrays, blocks)\n */\n joins?: SanitizedJoins\n /**\n * Tracker for orderable join fields - populated during sanitization\n */\n orderableJoins?: OrderableJoinInfo[]\n parentIndexPath: string\n parentIsLocalized: boolean\n parentSchemaPath: string\n polymorphicJoins?: SanitizedJoin[]\n requireFieldLevelRichTextEditor: boolean\n richTextSanitizationPromises?: Array<(config: SanitizedConfig) => Promise<void>>\n validRelationships: null | string[]\n}\n\ntype SanitizeFieldResult = {\n /**\n * Fields to insert after this field (e.g., timezone field)\n */\n fieldsToInsert?: Field[]\n}\n\n/**\n * Sanitize a single field. Handles all per-field logic including:\n * - Validation setup\n * - Hooks/access/admin defaults\n * - Type-specific handling\n * - Recursive sanitization of nested fields\n *\n * @returns Result containing any fields to insert after this one\n */\nexport const sanitizeField = async ({\n collectionConfig,\n config,\n existingFieldNames,\n field,\n globalConfig,\n index,\n isTopLevelField,\n joinPath,\n joins,\n orderableJoins,\n parentIndexPath,\n parentIsLocalized,\n parentSchemaPath,\n polymorphicJoins,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n}: SanitizeFieldArgs): Promise<SanitizeFieldResult> => {\n const result: SanitizeFieldResult = {}\n\n if ('_sanitized' in field && field._sanitized === true) {\n return result\n }\n\n if ('_sanitized' in field) {\n field._sanitized = true\n }\n\n if (!field.type) {\n throw new MissingFieldType(field)\n }\n\n const fieldAffectsData = _fieldAffectsData(field)\n\n const { indexPath, schemaPath } = getFieldPaths({\n field,\n index,\n parentIndexPath,\n parentSchemaPath,\n })\n\n // Reserved field name checks\n if (isTopLevelField && fieldAffectsData && field.name) {\n if (collectionConfig && collectionConfig.upload) {\n if (reservedBaseUploadFieldNames.includes(field.name)) {\n throw new ReservedFieldName(field, field.name)\n }\n }\n\n if (\n collectionConfig &&\n collectionConfig.auth &&\n typeof collectionConfig.auth === 'object' &&\n !collectionConfig.auth.disableLocalStrategy\n ) {\n if (reservedBaseAuthFieldNames.includes(field.name)) {\n throw new ReservedFieldName(field, field.name)\n }\n\n if (collectionConfig.auth.verify) {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n if (reservedAPIKeyFieldNames.includes(field.name)) {\n throw new ReservedFieldName(field, field.name)\n }\n\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n if (reservedVerifyFieldNames.includes(field.name)) {\n throw new ReservedFieldName(field, field.name)\n }\n }\n }\n }\n\n // Invalid field name check\n if (fieldAffectsData && field.name.includes('.')) {\n throw new InvalidFieldName(field, field.name)\n }\n\n // Auto-label\n if (\n 'name' in field &&\n field.name &&\n typeof field.label !== 'object' &&\n typeof field.label !== 'string' &&\n typeof field.label !== 'function' &&\n field.label !== false\n ) {\n field.label = toWords(field.name)\n }\n\n // Checkbox default\n if (\n field.type === 'checkbox' &&\n typeof field.defaultValue === 'undefined' &&\n field.required === true\n ) {\n field.defaultValue = false\n }\n\n // Join field sanitization\n if (field.type === 'join') {\n sanitizeJoinField({\n config,\n field,\n joinPath,\n joins,\n orderableJoins,\n parentIsLocalized,\n polymorphicJoins,\n })\n }\n\n // Relationship/upload validation\n if (field.type === 'relationship' || field.type === 'upload') {\n if (Array.isArray(field.relationTo) && field.relationTo.length === 0) {\n throw new Error(\n `Field \"${field.name}\" of type \"${field.type}\" has an empty relationTo array. At least one collection must be specified.`,\n )\n }\n\n if (validRelationships) {\n const relationships = Array.isArray(field.relationTo) ? field.relationTo : [field.relationTo]\n\n relationships.forEach((relationship: string) => {\n if (!validRelationships.includes(relationship)) {\n throw new InvalidFieldRelationship(field, relationship)\n }\n })\n }\n\n if (field.min && !field.minRows) {\n console.warn(\n `(payload): The \"min\" property is deprecated for the Relationship field \"${field.name}\" and will be removed in a future version. Please use \"minRows\" instead.`,\n )\n field.minRows = field.min\n }\n\n if (field.max && !field.maxRows) {\n console.warn(\n `(payload): The \"max\" property is deprecated for the Relationship field \"${field.name}\" and will be removed in a future version. Please use \"maxRows\" instead.`,\n )\n field.maxRows = field.max\n }\n }\n\n // Upload isSortable default\n if (field.type === 'upload') {\n if (!field.admin || !('isSortable' in field.admin)) {\n field.admin = {\n isSortable: true,\n ...field.admin,\n }\n }\n }\n\n // Array ID field\n if (field.type === 'array' && field.fields) {\n const hasCustomID = field.fields.some((f) => 'name' in f && f.name === 'id')\n if (!hasCustomID) {\n field.fields.push(baseIDField)\n }\n }\n\n // Blocks/array labels\n if ((field.type === 'blocks' || field.type === 'array') && field.label) {\n field.labels = field.labels || formatLabels(field.name)\n }\n\n if (fieldAffectsData) {\n if (existingFieldNames.has(field.name)) {\n throw new DuplicateFieldName(field.name)\n } else if (!['blockName', 'id'].includes(field.name)) {\n existingFieldNames.add(field.name)\n }\n\n if (typeof field.localized !== 'undefined') {\n let shouldDisableLocalized = !config.localization\n\n if (\n process.env.NEXT_PUBLIC_PAYLOAD_COMPATIBILITY_allowLocalizedWithinLocalized !== 'true' &&\n parentIsLocalized &&\n // @todo PAYLOAD_DO_NOT_SANITIZE_LOCALIZED_PROPERTY=true will be the default in 4.0\n process.env.PAYLOAD_DO_NOT_SANITIZE_LOCALIZED_PROPERTY !== 'true'\n ) {\n shouldDisableLocalized = true\n }\n\n if (shouldDisableLocalized) {\n delete field.localized\n }\n }\n\n if (typeof field.validate === 'undefined') {\n if ('virtual' in field && field.virtual) {\n field.validate = (): true => true\n } else {\n const defaultValidate = validations[field.type as keyof typeof validations]\n if (defaultValidate) {\n field.validate = (val: any, options: any) =>\n defaultValidate(val, { ...field, ...options })\n } else {\n field.validate = (): true => true\n }\n }\n }\n\n if (!field.hooks) {\n field.hooks = {}\n }\n\n if (!field.access) {\n field.access = {}\n }\n\n setDefaultBeforeDuplicate(field, parentIsLocalized)\n }\n\n if (!field.admin) {\n field.admin = {}\n }\n\n if ('virtual' in field && field.virtual && field.admin.readOnly !== false && fieldAffectsData) {\n field.admin.readOnly = true\n }\n\n // Make sure that the richText field has an editor\n if (field.type === 'richText') {\n const sanitizeRichText = async (_config: SanitizedConfig) => {\n if (!field.editor) {\n if (_config.editor && !requireFieldLevelRichTextEditor) {\n // config.editor should be sanitized at this point\n field.editor = _config.editor\n } else {\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\n if (typeof field.editor === 'function') {\n field.editor = await field.editor({\n config: _config,\n isRoot: requireFieldLevelRichTextEditor,\n parentIsLocalized: (parentIsLocalized || field.localized)!,\n })\n }\n\n if (field.editor.i18n && Object.keys(field.editor.i18n).length >= 0) {\n config.i18n!.translations = deepMergeSimple(config.i18n!.translations!, field.editor.i18n)\n }\n }\n if (richTextSanitizationPromises) {\n richTextSanitizationPromises.push(sanitizeRichText)\n } else {\n await sanitizeRichText(config as unknown as SanitizedConfig)\n }\n }\n\n if (field.type === 'blocks' && field.blocks) {\n if (field.blockReferences && field.blocks?.length) {\n throw new Error('You cannot have both blockReferences and blocks in the same blocks field')\n }\n\n const blockSlugs: string[] = []\n\n for (const block of field.blockReferences ?? field.blocks) {\n const blockSlug = typeof block === 'string' ? block : block.slug\n\n if (blockSlugs.includes(blockSlug)) {\n throw new DuplicateFieldName(blockSlug)\n }\n\n blockSlugs.push(blockSlug)\n\n if (typeof block === 'string') {\n continue\n }\n\n if (block._sanitized === true) {\n continue\n }\n\n block._sanitized = true\n block.fields = block.fields.concat(baseBlockFields)\n block.labels = !block.labels ? formatLabels(block.slug) : block.labels\n\n block.fields = await sanitizeFields({\n collectionConfig,\n config,\n existingFieldNames: new Set(),\n fields: block.fields,\n isTopLevelField: false,\n parentIndexPath: '',\n parentIsLocalized: (parentIsLocalized || field.localized)!,\n parentSchemaPath: schemaPath + '.' + block.slug,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n }\n\n if ('fields' in field && field.fields) {\n field.fields = await sanitizeFields({\n collectionConfig,\n config,\n existingFieldNames: fieldAffectsData ? new Set() : existingFieldNames,\n fields: field.fields,\n isTopLevelField: isTopLevelField && !fieldAffectsData,\n joinPath: fieldAffectsData ? `${joinPath ? joinPath + '.' : ''}${field.name}` : joinPath,\n joins,\n orderableJoins,\n parentIndexPath: fieldAffectsData ? '' : indexPath,\n parentIsLocalized: parentIsLocalized || fieldIsLocalized(field),\n parentSchemaPath: schemaPath,\n polymorphicJoins,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n\n if (field.type === 'tabs') {\n for (let j = 0; j < field.tabs.length; j++) {\n const tab = field.tabs[j]!\n\n const isNamedTab = tabHasName(tab)\n\n if (isNamedTab && typeof tab.label === 'undefined') {\n tab.label = toWords(tab.name)\n }\n\n const { indexPath: tabIndexPath, schemaPath: tabSchemaPath } = getFieldPaths({\n field: tab,\n index: j,\n parentIndexPath: indexPath,\n parentSchemaPath: schemaPath,\n })\n\n if (\n 'admin' in tab &&\n tab.admin?.condition &&\n typeof tab.admin.condition === 'function' &&\n !tab.id\n ) {\n tab.id = tabSchemaPath\n }\n\n tab.fields = await sanitizeFields({\n collectionConfig,\n config,\n existingFieldNames: isNamedTab ? new Set() : existingFieldNames,\n fields: tab.fields,\n isTopLevelField: isTopLevelField && !isNamedTab,\n joinPath: isNamedTab ? `${joinPath ? joinPath + '.' : ''}${tab.name}` : joinPath,\n joins,\n orderableJoins,\n parentIndexPath: isNamedTab ? '' : tabIndexPath,\n parentIsLocalized: parentIsLocalized || (isNamedTab && tab.localized)!,\n parentSchemaPath: tabSchemaPath,\n polymorphicJoins,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n\n field.tabs[j] = tab\n }\n }\n\n if (field.type === 'ui' && typeof field.admin.disableBulkEdit === 'undefined') {\n field.admin.disableBulkEdit = true\n }\n\n // Timezone field insertion\n if (field.type === 'date' && field.timezone) {\n const name = field.name + '_tz'\n\n let defaultTimezone =\n field.timezone && typeof field.timezone === 'object'\n ? field.timezone.defaultTimezone\n : config.admin?.timezones?.defaultTimezone\n\n const required =\n field.required ||\n (field.timezone && typeof field.timezone === 'object' && field.timezone.required)\n\n const supportedTimezones =\n field.timezone && typeof field.timezone === 'object' && field.timezone.supportedTimezones\n ? field.timezone.supportedTimezones\n : config.admin?.timezones?.supportedTimezones\n\n const options =\n typeof supportedTimezones === 'function'\n ? supportedTimezones({ defaultTimezones })\n : supportedTimezones\n\n validateTimezones({\n source: `field \"${field.name}\" timezone.supportedTimezones`,\n timezones: options,\n })\n\n if (options && options.length === 1 && options[0]?.value) {\n defaultTimezone = options[0].value\n }\n\n // Generate label for timezone field\n const timezoneLabel = typeof field.label === 'string' ? `${field.label} Tz` : toWords(name)\n\n const baseField = baseTimezoneField({\n name,\n defaultValue: defaultTimezone,\n label: timezoneLabel,\n options,\n required,\n })\n\n // Apply override if provided\n const timezoneField =\n typeof field.timezone === 'object' && typeof field.timezone.override === 'function'\n ? field.timezone.override({ baseField })\n : baseField\n\n result.fieldsToInsert = [timezoneField]\n }\n\n // Virtual field handling\n if ('virtual' in field && typeof field.virtual === 'string') {\n const virtualField = field\n const configFields = (collectionConfig || globalConfig)?.fields\n if (configFields) {\n let flattenFields = flattenAllFields({ fields: configFields })\n const paths = field.virtual.split('.')\n let isHasMany = false\n\n for (const [idx, segment] of paths.entries()) {\n const foundField = flattenFields.find((e) => e.name === segment)\n if (!foundField) {\n break\n }\n\n if (\n foundField.type === 'group' ||\n foundField.type === 'tab' ||\n foundField.type === 'array'\n ) {\n flattenFields = foundField.flattenedFields\n } else if (\n (foundField.type === 'relationship' || foundField.type === 'upload') &&\n idx !== paths.length - 1 &&\n typeof foundField.relationTo === 'string'\n ) {\n if (\n foundField.hasMany &&\n (virtualField.type === 'text' ||\n virtualField.type === 'number' ||\n virtualField.type === 'select')\n ) {\n if (isHasMany) {\n throw new InvalidConfiguration(\n `Virtual field ${virtualField.name} in ${globalConfig ? `global ${globalConfig.slug}` : `collection ${collectionConfig?.slug}`} references 2 or more hasMany relationships on the path ${virtualField.virtual} which is not allowed.`,\n )\n }\n\n isHasMany = true\n virtualField.hasMany = true\n }\n const relatedCollection = config.collections?.find(\n (e) => e.slug === foundField.relationTo,\n )\n if (relatedCollection) {\n flattenFields = flattenAllFields({ fields: relatedCollection.fields })\n }\n }\n }\n }\n }\n\n return result\n}\n\nexport const sanitizeFields = async ({\n collectionConfig,\n config,\n existingFieldNames = new Set(),\n fields,\n globalConfig,\n isTopLevelField = true,\n joinPath = '',\n joins,\n orderableJoins,\n parentIndexPath = '',\n parentIsLocalized,\n parentSchemaPath = '',\n polymorphicJoins,\n requireFieldLevelRichTextEditor = false,\n richTextSanitizationPromises,\n validRelationships,\n}: SanitizeFieldsArgs): Promise<Field[]> => {\n if (!fields) {\n return []\n }\n\n for (let i = 0; i < fields.length; i++) {\n const field = fields[i]!\n\n const result = await sanitizeField({\n collectionConfig,\n config,\n existingFieldNames,\n field,\n globalConfig,\n index: i,\n isTopLevelField,\n joinPath,\n joins,\n orderableJoins,\n parentIndexPath,\n parentIsLocalized,\n parentSchemaPath,\n polymorphicJoins,\n requireFieldLevelRichTextEditor,\n richTextSanitizationPromises,\n validRelationships,\n })\n\n fields[i] = field\n\n if (result.fieldsToInsert?.length) {\n fields.splice(i + 1, 0, ...result.fieldsToInsert)\n i += result.fieldsToInsert.length\n }\n }\n\n return fields\n}\n"],"names":["deepMergeSimple","DuplicateFieldName","InvalidConfiguration","InvalidFieldName","InvalidFieldRelationship","MissingEditorProp","MissingFieldType","ReservedFieldName","flattenAllFields","formatLabels","toWords","validateTimezones","baseBlockFields","baseIDField","baseTimezoneField","defaultTimezones","getFieldPaths","setDefaultBeforeDuplicate","validations","reservedAPIKeyFieldNames","reservedBaseAuthFieldNames","reservedBaseUploadFieldNames","reservedVerifyFieldNames","sanitizeJoinField","fieldAffectsData","_fieldAffectsData","fieldIsLocalized","tabHasName","sanitizeField","collectionConfig","config","existingFieldNames","field","globalConfig","index","isTopLevelField","joinPath","joins","orderableJoins","parentIndexPath","parentIsLocalized","parentSchemaPath","polymorphicJoins","requireFieldLevelRichTextEditor","richTextSanitizationPromises","validRelationships","result","_sanitized","type","indexPath","schemaPath","name","upload","includes","auth","disableLocalStrategy","verify","label","defaultValue","required","Array","isArray","relationTo","length","Error","relationships","forEach","relationship","min","minRows","console","warn","max","maxRows","admin","isSortable","fields","hasCustomID","some","f","push","labels","has","add","localized","shouldDisableLocalized","localization","process","env","NEXT_PUBLIC_PAYLOAD_COMPATIBILITY_allowLocalizedWithinLocalized","PAYLOAD_DO_NOT_SANITIZE_LOCALIZED_PROPERTY","validate","virtual","defaultValidate","val","options","hooks","access","readOnly","sanitizeRichText","_config","editor","isRoot","i18n","Object","keys","translations","blocks","blockReferences","blockSlugs","block","blockSlug","slug","concat","sanitizeFields","Set","j","tabs","tab","isNamedTab","tabIndexPath","tabSchemaPath","condition","id","disableBulkEdit","timezone","defaultTimezone","timezones","supportedTimezones","source","value","timezoneLabel","baseField","timezoneField","override","fieldsToInsert","virtualField","configFields","flattenFields","paths","split","isHasMany","idx","segment","entries","foundField","find","e","flattenedFields","hasMany","relatedCollection","collections","i","splice"],"mappings":"AAAA,SAASA,eAAe,QAAQ,qCAAoC;AAYpE,SACEC,kBAAkB,EAClBC,oBAAoB,EACpBC,gBAAgB,EAChBC,wBAAwB,EACxBC,iBAAiB,EACjBC,gBAAgB,QACX,wBAAuB;AAC9B,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,gBAAgB,QAAQ,sCAAqC;AACtE,SAASC,YAAY,EAAEC,OAAO,QAAQ,kCAAiC;AACvE,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,mCAAkC;AAClE,SAASC,WAAW,QAAQ,+BAA8B;AAC1D,SAASC,iBAAiB,QAAQ,sCAAqC;AACvE,SAASC,gBAAgB,QAAQ,6CAA4C;AAC7E,SAASC,aAAa,QAAQ,sBAAqB;AACnD,SAASC,yBAAyB,QAAQ,kCAAiC;AAC3E,SAASC,WAAW,QAAQ,oBAAmB;AAC/C,SACEC,wBAAwB,EACxBC,0BAA0B,EAC1BC,4BAA4B,EAC5BC,wBAAwB,QACnB,0BAAyB;AAChC,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,oBAAoBC,iBAAiB,EAAEC,gBAAgB,EAAEC,UAAU,QAAQ,aAAY;AAyFhG;;;;;;;;CAQC,GACD,OAAO,MAAMC,gBAAgB,OAAO,EAClCC,gBAAgB,EAChBC,MAAM,EACNC,kBAAkB,EAClBC,KAAK,EACLC,YAAY,EACZC,KAAK,EACLC,eAAe,EACfC,QAAQ,EACRC,KAAK,EACLC,cAAc,EACdC,eAAe,EACfC,iBAAiB,EACjBC,gBAAgB,EAChBC,gBAAgB,EAChBC,+BAA+B,EAC/BC,4BAA4B,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BACzB;oBACA,MAAMC,oBAAoBxH,OAAOyH,WAAW,EAAEL,KAC5C,CAACC,IAAMA,EAAEnC,IAAI,KAAKiC,WAAWnF,UAAU;oBAEzC,IAAIwF,mBAAmB;wBACrBZ,gBAAgBlI,iBAAiB;4BAAEoE,QAAQ0E,kBAAkB1E,MAAM;wBAAC;oBACtE;gBACF;YACF;QACF;IACF;IAEA,OAAO9B;AACT,EAAC;AAED,OAAO,MAAMoE,iBAAiB,OAAO,EACnCrF,gBAAgB,EAChBC,MAAM,EACNC,qBAAqB,IAAIoF,KAAK,EAC9BvC,MAAM,EACN3C,YAAY,EACZE,kBAAkB,IAAI,EACtBC,WAAW,EAAE,EACbC,KAAK,EACLC,cAAc,EACdC,kBAAkB,EAAE,EACpBC,iBAAiB,EACjBC,mBAAmB,EAAE,EACrBC,gBAAgB,EAChBC,kCAAkC,KAAK,EACvCC,4BAA4B,EAC5BC,kBAAkB,EACC;IACnB,IAAI,CAAC+B,QAAQ;QACX,OAAO,EAAE;IACX;IAEA,IAAK,IAAI4E,IAAI,GAAGA,IAAI5E,OAAOb,MAAM,EAAEyF,IAAK;QACtC,MAAMxH,QAAQ4C,MAAM,CAAC4E,EAAE;QAEvB,MAAM1G,SAAS,MAAMlB,cAAc;YACjCC;YACAC;YACAC;YACAC;YACAC;YACAC,OAAOsH;YACPrH;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;QAEA+B,MAAM,CAAC4E,EAAE,GAAGxH;QAEZ,IAAIc,OAAOyF,cAAc,EAAExE,QAAQ;YACjCa,OAAO6E,MAAM,CAACD,IAAI,GAAG,MAAM1G,OAAOyF,cAAc;YAChDiB,KAAK1G,OAAOyF,cAAc,CAACxE,MAAM;QACnC;IACF;IAEA,OAAOa;AACT,EAAC"}
|
|
@@ -673,6 +673,72 @@ describe('sanitizeFields', ()=>{
|
|
|
673
673
|
});
|
|
674
674
|
expect(result).not.toBe(true);
|
|
675
675
|
});
|
|
676
|
+
it('should default readOnly to true for virtual: true fields', async ()=>{
|
|
677
|
+
const fields = [
|
|
678
|
+
{
|
|
679
|
+
name: 'virtualText',
|
|
680
|
+
type: 'text',
|
|
681
|
+
virtual: true
|
|
682
|
+
}
|
|
683
|
+
];
|
|
684
|
+
const sanitizedField = (await sanitizeFields({
|
|
685
|
+
config,
|
|
686
|
+
collectionConfig,
|
|
687
|
+
fields,
|
|
688
|
+
validRelationships: []
|
|
689
|
+
}))[0];
|
|
690
|
+
expect(sanitizedField.admin?.readOnly).toBe(true);
|
|
691
|
+
});
|
|
692
|
+
it('should default readOnly to true for virtual: "string" fields', async ()=>{
|
|
693
|
+
const fields = [
|
|
694
|
+
{
|
|
695
|
+
name: 'virtualRef',
|
|
696
|
+
type: 'text',
|
|
697
|
+
virtual: 'post.title'
|
|
698
|
+
}
|
|
699
|
+
];
|
|
700
|
+
const sanitizedField = (await sanitizeFields({
|
|
701
|
+
config,
|
|
702
|
+
collectionConfig,
|
|
703
|
+
fields,
|
|
704
|
+
validRelationships: []
|
|
705
|
+
}))[0];
|
|
706
|
+
expect(sanitizedField.admin?.readOnly).toBe(true);
|
|
707
|
+
});
|
|
708
|
+
it('should not override readOnly: false on virtual fields', async ()=>{
|
|
709
|
+
const fields = [
|
|
710
|
+
{
|
|
711
|
+
name: 'virtualText',
|
|
712
|
+
type: 'text',
|
|
713
|
+
virtual: true,
|
|
714
|
+
admin: {
|
|
715
|
+
readOnly: false
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
];
|
|
719
|
+
const sanitizedField = (await sanitizeFields({
|
|
720
|
+
config,
|
|
721
|
+
collectionConfig,
|
|
722
|
+
fields,
|
|
723
|
+
validRelationships: []
|
|
724
|
+
}))[0];
|
|
725
|
+
expect(sanitizedField.admin?.readOnly).toBe(false);
|
|
726
|
+
});
|
|
727
|
+
it('should not set readOnly on non-virtual fields', async ()=>{
|
|
728
|
+
const fields = [
|
|
729
|
+
{
|
|
730
|
+
name: 'normalText',
|
|
731
|
+
type: 'text'
|
|
732
|
+
}
|
|
733
|
+
];
|
|
734
|
+
const sanitizedField = (await sanitizeFields({
|
|
735
|
+
config,
|
|
736
|
+
collectionConfig,
|
|
737
|
+
fields,
|
|
738
|
+
validRelationships: []
|
|
739
|
+
}))[0];
|
|
740
|
+
expect(sanitizedField.admin?.readOnly).toBeUndefined();
|
|
741
|
+
});
|
|
676
742
|
});
|
|
677
743
|
});
|
|
678
744
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/fields/config/sanitize.spec.ts"],"sourcesContent":["import type { Config } from '../../config/types.js'\nimport type {\n ArrayField,\n Block,\n BlocksField,\n CheckboxField,\n Field,\n NumberField,\n TextField,\n} from './types.js'\n\nimport {\n DuplicateFieldName,\n InvalidFieldName,\n InvalidFieldRelationship,\n MissingFieldType,\n} from '../../errors/index.js'\nimport { sanitizeFields } from './sanitize.js'\nimport { CollectionConfig } from '../../index.js'\nimport { describe, it, expect } from 'vitest'\n\ndescribe('sanitizeFields', () => {\n const config = {} as Config\n const collectionConfig = {} as CollectionConfig\n\n it('should throw on missing type field', async () => {\n const fields: Field[] = [\n // @ts-expect-error\n {\n name: 'Some Collection',\n label: 'some-collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n }).rejects.toThrow(MissingFieldType)\n })\n\n it('should throw on invalid field name', async () => {\n const fields: Field[] = [\n {\n name: 'some.collection',\n type: 'text',\n label: 'some.collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n }).rejects.toThrow(InvalidFieldName)\n })\n\n it('should throw on duplicate field name', async () => {\n const fields: Field[] = [\n {\n name: 'someField',\n type: 'text',\n label: 'someField',\n },\n {\n name: 'someField',\n type: 'text',\n label: 'someField',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n }).rejects.toThrow(DuplicateFieldName)\n })\n\n it('should throw on duplicate block slug', async () => {\n const fields: Field[] = [\n {\n name: 'blocks',\n type: 'blocks',\n blocks: [\n {\n slug: 'block',\n fields: [\n {\n name: 'blockField',\n type: 'text',\n },\n ],\n },\n {\n slug: 'block',\n fields: [\n {\n name: 'blockField',\n type: 'text',\n },\n ],\n },\n ],\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n }).rejects.toThrow(DuplicateFieldName)\n })\n\n describe('auto-labeling', () => {\n it('should populate label if missing', async () => {\n const fields: Field[] = [\n {\n name: 'someField',\n type: 'text',\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.name).toStrictEqual('someField')\n expect(sanitizedField.label).toStrictEqual('Some Field')\n expect(sanitizedField.type).toStrictEqual('text')\n })\n\n it('should allow auto-label override', async () => {\n const fields: Field[] = [\n {\n name: 'someField',\n type: 'text',\n label: 'Do not label',\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.name).toStrictEqual('someField')\n expect(sanitizedField.label).toStrictEqual('Do not label')\n expect(sanitizedField.type).toStrictEqual('text')\n })\n\n describe('opt-out', () => {\n it('should allow label opt-out', async () => {\n const fields: Field[] = [\n {\n name: 'someField',\n type: 'text',\n label: false,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.name).toStrictEqual('someField')\n expect(sanitizedField.label).toStrictEqual(false)\n expect(sanitizedField.type).toStrictEqual('text')\n })\n\n it('should allow label opt-out for arrays', async () => {\n const arrayField: ArrayField = {\n name: 'items',\n type: 'array',\n fields: [\n {\n name: 'itemName',\n type: 'text',\n },\n ],\n label: false,\n }\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields: [arrayField],\n validRelationships: [],\n })\n )[0] as ArrayField\n\n expect(sanitizedField.name).toStrictEqual('items')\n expect(sanitizedField.label).toStrictEqual(false)\n expect(sanitizedField.type).toStrictEqual('array')\n expect(sanitizedField.labels).toBeUndefined()\n })\n\n it('should allow label opt-out for blocks', async () => {\n const fields: Field[] = [\n {\n name: 'noLabelBlock',\n type: 'blocks',\n blocks: [\n {\n slug: 'number',\n fields: [\n {\n name: 'testNumber',\n type: 'number',\n },\n ],\n },\n ],\n label: false,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as BlocksField\n\n expect(sanitizedField.name).toStrictEqual('noLabelBlock')\n expect(sanitizedField.label).toStrictEqual(false)\n expect(sanitizedField.type).toStrictEqual('blocks')\n expect(sanitizedField.labels).toBeUndefined()\n })\n })\n\n it('should label arrays with plural and singular', async () => {\n const fields: Field[] = [\n {\n name: 'items',\n type: 'array',\n fields: [\n {\n name: 'itemName',\n type: 'text',\n },\n ],\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as ArrayField\n\n expect(sanitizedField.name).toStrictEqual('items')\n expect(sanitizedField.label).toStrictEqual('Items')\n expect(sanitizedField.type).toStrictEqual('array')\n expect(sanitizedField.labels).toMatchObject({ plural: 'Items', singular: 'Item' })\n })\n\n it('should label blocks with plural and singular', async () => {\n const fields: Field[] = [\n {\n name: 'specialBlock',\n type: 'blocks',\n blocks: [\n {\n slug: 'number',\n fields: [{ name: 'testNumber', type: 'number' }],\n },\n ],\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as BlocksField\n\n expect(sanitizedField.name).toStrictEqual('specialBlock')\n expect(sanitizedField.label).toStrictEqual('Special Block')\n expect(sanitizedField.type).toStrictEqual('blocks')\n expect(sanitizedField.labels).toMatchObject({\n plural: 'Special Blocks',\n singular: 'Special Block',\n })\n\n expect((sanitizedField.blocks[0].fields[0] as NumberField).label).toStrictEqual('Test Number')\n })\n })\n\n describe('relationships', () => {\n it('should not throw on valid relationship', async () => {\n const validRelationships = ['some-collection']\n const fields: Field[] = [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: 'some-collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).not.toThrow()\n })\n\n it('should not throw on valid relationship - multiple', async () => {\n const validRelationships = ['some-collection', 'another-collection']\n const fields: Field[] = [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: ['some-collection', 'another-collection'],\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).not.toThrow()\n })\n\n it('should not throw on valid relationship inside blocks', async () => {\n const validRelationships = ['some-collection']\n const relationshipBlock: Block = {\n slug: 'relationshipBlock',\n fields: [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: 'some-collection',\n },\n ],\n }\n\n const fields: Field[] = [\n {\n name: 'layout',\n type: 'blocks',\n blocks: [relationshipBlock],\n label: 'Layout Blocks',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).not.toThrow()\n })\n\n it('should throw on invalid relationship', async () => {\n const validRelationships = ['some-collection']\n const fields: Field[] = [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: 'not-valid',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).rejects.toThrow(InvalidFieldRelationship)\n })\n\n it('should throw on invalid relationship - multiple', async () => {\n const validRelationships = ['some-collection', 'another-collection']\n const fields: Field[] = [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: ['some-collection', 'not-valid'],\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).rejects.toThrow(InvalidFieldRelationship)\n })\n\n it('should throw on invalid relationship inside blocks', async () => {\n const validRelationships = ['some-collection']\n const relationshipBlock: Block = {\n slug: 'relationshipBlock',\n fields: [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: 'not-valid',\n },\n ],\n }\n\n const fields: Field[] = [\n {\n name: 'layout',\n type: 'blocks',\n blocks: [relationshipBlock],\n label: 'Layout Blocks',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).rejects.toThrow(InvalidFieldRelationship)\n })\n\n it('should throw on empty relationTo array', async () => {\n const validRelationships = ['some-collection']\n const fields: Field[] = [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: [],\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).rejects.toThrow('has an empty relationTo array')\n })\n\n it('should throw on empty relationTo array for upload field', async () => {\n const validRelationships = ['some-collection']\n const fields: Field[] = [\n {\n name: 'My Upload',\n type: 'upload',\n label: 'my-upload',\n relationTo: [],\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).rejects.toThrow('has an empty relationTo array')\n })\n\n it('should throw on empty relationTo array inside blocks', async () => {\n const validRelationships = ['some-collection']\n const relationshipBlock: Block = {\n slug: 'relationshipBlock',\n fields: [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: [],\n },\n ],\n }\n\n const fields: Field[] = [\n {\n name: 'layout',\n type: 'blocks',\n blocks: [relationshipBlock],\n label: 'Layout Blocks',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).rejects.toThrow('has an empty relationTo array')\n })\n\n it('should defaultValue of checkbox to false if required and undefined', async () => {\n const fields: Field[] = [\n {\n name: 'My Checkbox',\n type: 'checkbox',\n required: true,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as CheckboxField\n\n expect(sanitizedField.defaultValue).toStrictEqual(false)\n })\n\n it('should return empty field array if no fields', async () => {\n const sanitizedFields = await sanitizeFields({\n config,\n collectionConfig,\n fields: [],\n validRelationships: [],\n })\n\n expect(sanitizedFields).toStrictEqual([])\n })\n })\n describe('blocks', () => {\n it('should maintain admin.blockName true after sanitization', async () => {\n const fields: Field[] = [\n {\n name: 'noLabelBlock',\n type: 'blocks',\n blocks: [\n {\n slug: 'number',\n admin: {\n disableBlockName: true,\n },\n fields: [\n {\n name: 'testNumber',\n type: 'number',\n },\n ],\n },\n ],\n label: false,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as BlocksField\n\n const sanitizedBlock = sanitizedField.blocks[0]\n\n expect(sanitizedBlock.admin?.disableBlockName).toStrictEqual(true)\n })\n it('should default admin.disableBlockName to true after sanitization', async () => {\n const fields: Field[] = [\n {\n name: 'noLabelBlock',\n type: 'blocks',\n blocks: [\n {\n slug: 'number',\n fields: [\n {\n name: 'testNumber',\n type: 'number',\n },\n ],\n },\n ],\n label: false,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as BlocksField\n\n const sanitizedBlock = sanitizedField.blocks[0]\n\n expect(sanitizedBlock.admin?.disableBlockName).toStrictEqual(undefined)\n })\n })\n\n describe('virtual fields', () => {\n it('should assign a noop validate for virtual: true fields', async () => {\n const fields: Field[] = [\n {\n name: 'virtualText',\n type: 'text',\n virtual: true,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.validate).toBeDefined()\n expect(sanitizedField.validate!('', {} as any)).toBe(true)\n expect(sanitizedField.validate!(undefined as any, {} as any)).toBe(true)\n })\n\n it('should assign a noop validate for virtual: \"string\" fields', async () => {\n const fields: Field[] = [\n {\n name: 'virtualRef',\n type: 'text',\n virtual: 'post.title',\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.validate).toBeDefined()\n expect(sanitizedField.validate!(undefined as any, {} as any)).toBe(true)\n })\n\n it('should not override an explicit validate on a virtual field', async () => {\n const customValidate = () => true as const\n const fields: Field[] = [\n {\n name: 'virtualText',\n type: 'text',\n virtual: true,\n validate: customValidate,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.validate).toBe(customValidate)\n })\n\n it('should assign default type-based validate for non-virtual fields', async () => {\n const fields: Field[] = [\n {\n name: 'normalText',\n type: 'text',\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.validate).toBeDefined()\n // Non-virtual text field should use the text validator which checks required/minLength/etc.\n // Passing undefined with required should fail\n const result = sanitizedField.validate!(undefined as any, { required: true, req: { payload: { config: {} }, t: ((v: string) => v) as any } } as any)\n expect(result).not.toBe(true)\n })\n })\n})\n"],"names":["DuplicateFieldName","InvalidFieldName","InvalidFieldRelationship","MissingFieldType","sanitizeFields","describe","it","expect","config","collectionConfig","fields","name","label","validRelationships","rejects","toThrow","type","blocks","slug","sanitizedField","toStrictEqual","arrayField","labels","toBeUndefined","toMatchObject","plural","singular","relationTo","not","relationshipBlock","required","defaultValue","sanitizedFields","admin","disableBlockName","sanitizedBlock","undefined","virtual","validate","toBeDefined","toBe","customValidate","result","req","payload","t","v"],"mappings":"AAWA,SACEA,kBAAkB,EAClBC,gBAAgB,EAChBC,wBAAwB,EACxBC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EF,WAAkB,CAAC,IAAWI,IAAI,CAAC;QACrE;QAEAlC,GAAG,+DAA+D;YAChE,MAAMmC,iBAAiB,IAAM;YAC7B,MAAM/B,SAAkB;gBACtB;oBACEC,MAAM;oBACNK,MAAM;oBACNqB,SAAS;oBACTC,UAAUG;gBACZ;aACD;YAED,MAAMtB,iBAAiB,AACrB,CAAA,MAAMf,eAAe;gBACnBI;gBACAC;gBACAC;gBACAG,oBAAoB,EAAE;YACxB,EAAC,CACF,CAAC,EAAE;YAEJN,OAAOY,eAAemB,QAAQ,EAAEE,IAAI,CAACC;QACvC;QAEAnC,GAAG,oEAAoE;YACrE,MAAMI,SAAkB;gBACtB;oBACEC,MAAM;oBACNK,MAAM;gBACR;aACD;YAED,MAAMG,iBAAiB,AACrB,CAAA,MAAMf,eAAe;gBACnBI;gBACAC;gBACAC;gBACAG,oBAAoB,EAAE;YACxB,EAAC,CACF,CAAC,EAAE;YAEJN,OAAOY,eAAemB,QAAQ,EAAEC,WAAW;YAC3C,4FAA4F;YAC5F,8CAA8C;YAC9C,MAAMG,SAASvB,eAAemB,QAAQ,CAAEF,WAAkB;gBAAEN,UAAU;gBAAMa,KAAK;oBAAEC,SAAS;wBAAEpC,QAAQ,CAAC;oBAAE;oBAAGqC,GAAI,CAACC,IAAcA;gBAAU;YAAE;YAC3IvC,OAAOmC,QAAQd,GAAG,CAACY,IAAI,CAAC;QAC1B;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../src/fields/config/sanitize.spec.ts"],"sourcesContent":["import type { Config } from '../../config/types.js'\nimport type {\n ArrayField,\n Block,\n BlocksField,\n CheckboxField,\n Field,\n NumberField,\n TextField,\n} from './types.js'\n\nimport {\n DuplicateFieldName,\n InvalidFieldName,\n InvalidFieldRelationship,\n MissingFieldType,\n} from '../../errors/index.js'\nimport { sanitizeFields } from './sanitize.js'\nimport { CollectionConfig } from '../../index.js'\nimport { describe, it, expect } from 'vitest'\n\ndescribe('sanitizeFields', () => {\n const config = {} as Config\n const collectionConfig = {} as CollectionConfig\n\n it('should throw on missing type field', async () => {\n const fields: Field[] = [\n // @ts-expect-error\n {\n name: 'Some Collection',\n label: 'some-collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n }).rejects.toThrow(MissingFieldType)\n })\n\n it('should throw on invalid field name', async () => {\n const fields: Field[] = [\n {\n name: 'some.collection',\n type: 'text',\n label: 'some.collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n }).rejects.toThrow(InvalidFieldName)\n })\n\n it('should throw on duplicate field name', async () => {\n const fields: Field[] = [\n {\n name: 'someField',\n type: 'text',\n label: 'someField',\n },\n {\n name: 'someField',\n type: 'text',\n label: 'someField',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n }).rejects.toThrow(DuplicateFieldName)\n })\n\n it('should throw on duplicate block slug', async () => {\n const fields: Field[] = [\n {\n name: 'blocks',\n type: 'blocks',\n blocks: [\n {\n slug: 'block',\n fields: [\n {\n name: 'blockField',\n type: 'text',\n },\n ],\n },\n {\n slug: 'block',\n fields: [\n {\n name: 'blockField',\n type: 'text',\n },\n ],\n },\n ],\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n }).rejects.toThrow(DuplicateFieldName)\n })\n\n describe('auto-labeling', () => {\n it('should populate label if missing', async () => {\n const fields: Field[] = [\n {\n name: 'someField',\n type: 'text',\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.name).toStrictEqual('someField')\n expect(sanitizedField.label).toStrictEqual('Some Field')\n expect(sanitizedField.type).toStrictEqual('text')\n })\n\n it('should allow auto-label override', async () => {\n const fields: Field[] = [\n {\n name: 'someField',\n type: 'text',\n label: 'Do not label',\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.name).toStrictEqual('someField')\n expect(sanitizedField.label).toStrictEqual('Do not label')\n expect(sanitizedField.type).toStrictEqual('text')\n })\n\n describe('opt-out', () => {\n it('should allow label opt-out', async () => {\n const fields: Field[] = [\n {\n name: 'someField',\n type: 'text',\n label: false,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.name).toStrictEqual('someField')\n expect(sanitizedField.label).toStrictEqual(false)\n expect(sanitizedField.type).toStrictEqual('text')\n })\n\n it('should allow label opt-out for arrays', async () => {\n const arrayField: ArrayField = {\n name: 'items',\n type: 'array',\n fields: [\n {\n name: 'itemName',\n type: 'text',\n },\n ],\n label: false,\n }\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields: [arrayField],\n validRelationships: [],\n })\n )[0] as ArrayField\n\n expect(sanitizedField.name).toStrictEqual('items')\n expect(sanitizedField.label).toStrictEqual(false)\n expect(sanitizedField.type).toStrictEqual('array')\n expect(sanitizedField.labels).toBeUndefined()\n })\n\n it('should allow label opt-out for blocks', async () => {\n const fields: Field[] = [\n {\n name: 'noLabelBlock',\n type: 'blocks',\n blocks: [\n {\n slug: 'number',\n fields: [\n {\n name: 'testNumber',\n type: 'number',\n },\n ],\n },\n ],\n label: false,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as BlocksField\n\n expect(sanitizedField.name).toStrictEqual('noLabelBlock')\n expect(sanitizedField.label).toStrictEqual(false)\n expect(sanitizedField.type).toStrictEqual('blocks')\n expect(sanitizedField.labels).toBeUndefined()\n })\n })\n\n it('should label arrays with plural and singular', async () => {\n const fields: Field[] = [\n {\n name: 'items',\n type: 'array',\n fields: [\n {\n name: 'itemName',\n type: 'text',\n },\n ],\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as ArrayField\n\n expect(sanitizedField.name).toStrictEqual('items')\n expect(sanitizedField.label).toStrictEqual('Items')\n expect(sanitizedField.type).toStrictEqual('array')\n expect(sanitizedField.labels).toMatchObject({ plural: 'Items', singular: 'Item' })\n })\n\n it('should label blocks with plural and singular', async () => {\n const fields: Field[] = [\n {\n name: 'specialBlock',\n type: 'blocks',\n blocks: [\n {\n slug: 'number',\n fields: [{ name: 'testNumber', type: 'number' }],\n },\n ],\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as BlocksField\n\n expect(sanitizedField.name).toStrictEqual('specialBlock')\n expect(sanitizedField.label).toStrictEqual('Special Block')\n expect(sanitizedField.type).toStrictEqual('blocks')\n expect(sanitizedField.labels).toMatchObject({\n plural: 'Special Blocks',\n singular: 'Special Block',\n })\n\n expect((sanitizedField.blocks[0].fields[0] as NumberField).label).toStrictEqual('Test Number')\n })\n })\n\n describe('relationships', () => {\n it('should not throw on valid relationship', async () => {\n const validRelationships = ['some-collection']\n const fields: Field[] = [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: 'some-collection',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).not.toThrow()\n })\n\n it('should not throw on valid relationship - multiple', async () => {\n const validRelationships = ['some-collection', 'another-collection']\n const fields: Field[] = [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: ['some-collection', 'another-collection'],\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).not.toThrow()\n })\n\n it('should not throw on valid relationship inside blocks', async () => {\n const validRelationships = ['some-collection']\n const relationshipBlock: Block = {\n slug: 'relationshipBlock',\n fields: [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: 'some-collection',\n },\n ],\n }\n\n const fields: Field[] = [\n {\n name: 'layout',\n type: 'blocks',\n blocks: [relationshipBlock],\n label: 'Layout Blocks',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).not.toThrow()\n })\n\n it('should throw on invalid relationship', async () => {\n const validRelationships = ['some-collection']\n const fields: Field[] = [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: 'not-valid',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).rejects.toThrow(InvalidFieldRelationship)\n })\n\n it('should throw on invalid relationship - multiple', async () => {\n const validRelationships = ['some-collection', 'another-collection']\n const fields: Field[] = [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: ['some-collection', 'not-valid'],\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).rejects.toThrow(InvalidFieldRelationship)\n })\n\n it('should throw on invalid relationship inside blocks', async () => {\n const validRelationships = ['some-collection']\n const relationshipBlock: Block = {\n slug: 'relationshipBlock',\n fields: [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: 'not-valid',\n },\n ],\n }\n\n const fields: Field[] = [\n {\n name: 'layout',\n type: 'blocks',\n blocks: [relationshipBlock],\n label: 'Layout Blocks',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).rejects.toThrow(InvalidFieldRelationship)\n })\n\n it('should throw on empty relationTo array', async () => {\n const validRelationships = ['some-collection']\n const fields: Field[] = [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: [],\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).rejects.toThrow('has an empty relationTo array')\n })\n\n it('should throw on empty relationTo array for upload field', async () => {\n const validRelationships = ['some-collection']\n const fields: Field[] = [\n {\n name: 'My Upload',\n type: 'upload',\n label: 'my-upload',\n relationTo: [],\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).rejects.toThrow('has an empty relationTo array')\n })\n\n it('should throw on empty relationTo array inside blocks', async () => {\n const validRelationships = ['some-collection']\n const relationshipBlock: Block = {\n slug: 'relationshipBlock',\n fields: [\n {\n name: 'My Relationship',\n type: 'relationship',\n label: 'my-relationship',\n relationTo: [],\n },\n ],\n }\n\n const fields: Field[] = [\n {\n name: 'layout',\n type: 'blocks',\n blocks: [relationshipBlock],\n label: 'Layout Blocks',\n },\n ]\n\n await expect(async () => {\n await sanitizeFields({ config, collectionConfig, fields, validRelationships })\n }).rejects.toThrow('has an empty relationTo array')\n })\n\n it('should defaultValue of checkbox to false if required and undefined', async () => {\n const fields: Field[] = [\n {\n name: 'My Checkbox',\n type: 'checkbox',\n required: true,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as CheckboxField\n\n expect(sanitizedField.defaultValue).toStrictEqual(false)\n })\n\n it('should return empty field array if no fields', async () => {\n const sanitizedFields = await sanitizeFields({\n config,\n collectionConfig,\n fields: [],\n validRelationships: [],\n })\n\n expect(sanitizedFields).toStrictEqual([])\n })\n })\n describe('blocks', () => {\n it('should maintain admin.blockName true after sanitization', async () => {\n const fields: Field[] = [\n {\n name: 'noLabelBlock',\n type: 'blocks',\n blocks: [\n {\n slug: 'number',\n admin: {\n disableBlockName: true,\n },\n fields: [\n {\n name: 'testNumber',\n type: 'number',\n },\n ],\n },\n ],\n label: false,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as BlocksField\n\n const sanitizedBlock = sanitizedField.blocks[0]\n\n expect(sanitizedBlock.admin?.disableBlockName).toStrictEqual(true)\n })\n it('should default admin.disableBlockName to true after sanitization', async () => {\n const fields: Field[] = [\n {\n name: 'noLabelBlock',\n type: 'blocks',\n blocks: [\n {\n slug: 'number',\n fields: [\n {\n name: 'testNumber',\n type: 'number',\n },\n ],\n },\n ],\n label: false,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as BlocksField\n\n const sanitizedBlock = sanitizedField.blocks[0]\n\n expect(sanitizedBlock.admin?.disableBlockName).toStrictEqual(undefined)\n })\n })\n\n describe('virtual fields', () => {\n it('should assign a noop validate for virtual: true fields', async () => {\n const fields: Field[] = [\n {\n name: 'virtualText',\n type: 'text',\n virtual: true,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.validate).toBeDefined()\n expect(sanitizedField.validate!('', {} as any)).toBe(true)\n expect(sanitizedField.validate!(undefined as any, {} as any)).toBe(true)\n })\n\n it('should assign a noop validate for virtual: \"string\" fields', async () => {\n const fields: Field[] = [\n {\n name: 'virtualRef',\n type: 'text',\n virtual: 'post.title',\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.validate).toBeDefined()\n expect(sanitizedField.validate!(undefined as any, {} as any)).toBe(true)\n })\n\n it('should not override an explicit validate on a virtual field', async () => {\n const customValidate = () => true as const\n const fields: Field[] = [\n {\n name: 'virtualText',\n type: 'text',\n virtual: true,\n validate: customValidate,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.validate).toBe(customValidate)\n })\n\n it('should assign default type-based validate for non-virtual fields', async () => {\n const fields: Field[] = [\n {\n name: 'normalText',\n type: 'text',\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.validate).toBeDefined()\n // Non-virtual text field should use the text validator which checks required/minLength/etc.\n // Passing undefined with required should fail\n const result = sanitizedField.validate!(\n undefined as any,\n { required: true, req: { payload: { config: {} }, t: ((v: string) => v) as any } } as any,\n )\n expect(result).not.toBe(true)\n })\n\n it('should default readOnly to true for virtual: true fields', async () => {\n const fields: Field[] = [\n {\n name: 'virtualText',\n type: 'text',\n virtual: true,\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.admin?.readOnly).toBe(true)\n })\n\n it('should default readOnly to true for virtual: \"string\" fields', async () => {\n const fields: Field[] = [\n {\n name: 'virtualRef',\n type: 'text',\n virtual: 'post.title',\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.admin?.readOnly).toBe(true)\n })\n\n it('should not override readOnly: false on virtual fields', async () => {\n const fields: Field[] = [\n {\n name: 'virtualText',\n type: 'text',\n virtual: true,\n admin: { readOnly: false },\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.admin?.readOnly).toBe(false)\n })\n\n it('should not set readOnly on non-virtual fields', async () => {\n const fields: Field[] = [\n {\n name: 'normalText',\n type: 'text',\n },\n ]\n\n const sanitizedField = (\n await sanitizeFields({\n config,\n collectionConfig,\n fields,\n validRelationships: [],\n })\n )[0] as TextField\n\n expect(sanitizedField.admin?.readOnly).toBeUndefined()\n })\n })\n})\n"],"names":["DuplicateFieldName","InvalidFieldName","InvalidFieldRelationship","MissingFieldType","sanitizeFields","describe","it","expect","config","collectionConfig","fields","name","label","validRelationships","rejects","toThrow","type","blocks","slug","sanitizedField","toStrictEqual","arrayField","labels","toBeUndefined","toMatchObject","plural","singular","relationTo","not","relationshipBlock","required","defaultValue","sanitizedFields","admin","disableBlockName","sanitizedBlock","undefined","virtual","validate","toBeDefined","toBe","customValidate","result","req","payload","t","v","readOnly"],"mappings":"AAWA,SACEA,kBAAkB,EAClBC,gBAAgB,EAChBC,wBAAwB,EACxBC,gBAAgB,QACX,wBAAuB;AAC9B,SAASC,cAAc,QAAQ,gBAAe;AAE9C,SAASC,QAAQ,EAAEC,EAAE,EAAEC,MAAM,QAAQ,SAAQ;AAE7CF,SAAS,kBAAkB;IACzB,MAAMG,SAAS,CAAC;IAChB,MAAMC,mBAAmB,CAAC;IAE1BH,GAAG,sCAAsC;QACvC,MAAMI,SAAkB;YACtB,mBAAmB;YACnB;gBACEC,MAAM;gBACNC,OAAO;YACT;SACD;QAED,MAAML,OAAO;YACX,MAAMH,eAAe;gBACnBI;gBACAC;gBACAC;gBACAG,oBAAoB,EAAE;YACxB;QACF,GAAGC,OAAO,CAACC,OAAO,CAACZ;IACrB;IAEAG,GAAG,sCAAsC;QACvC,MAAMI,SAAkB;YACtB;gBACEC,MAAM;gBACNK,MAAM;gBACNJ,OAAO;YACT;SACD;QAED,MAAML,OAAO;YACX,MAAMH,eAAe;gBACnBI;gBACAC;gBACAC;gBACAG,oBAAoB,EAAE;YACxB;QACF,GAAGC,OAAO,CAACC,OAAO,CAACd;IACrB;IAEAK,GAAG,wCAAwC;QACzC,MAAMI,SAAkB;YACtB;gBACEC,MAAM;gBACNK,MAAM;gBACNJ,OAAO;YACT;YACA;gBACED,MAAM;gBACNK,MAAM;gBACNJ,OAAO;YACT;SACD;QAED,MAAML,OAAO;YACX,MAAMH,eAAe;gBACnBI;gBACAC;gBACAC;gBACAG,oBAAoB,EAAE;YACxB;QACF,GAAGC,OAAO,CAACC,OAAO,CAACf;IACrB;IAEAM,GAAG,wCAAwC;QACzC,MAAMI,SAAkB;YACtB;gBACEC,MAAM;gBACNK,MAAM;gBACNC,QAAQ;oBAC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gBACnBI;gBACAC;gBACAC;gBACAG,oBAAoB,EAAE;YACxB,EAAC,CACF,CAAC,EAAE;YAEJN,OAAOY,eAAec,KAAK,EAAEc,UAAUP,IAAI,CAAC;QAC9C;QAEAlC,GAAG,gEAAgE;YACjE,MAAMI,SAAkB;gBACtB;oBACEC,MAAM;oBACNK,MAAM;oBACNqB,SAAS;gBACX;aACD;YAED,MAAMlB,iBAAiB,AACrB,CAAA,MAAMf,eAAe;gBACnBI;gBACAC;gBACAC;gBACAG,oBAAoB,EAAE;YACxB,EAAC,CACF,CAAC,EAAE;YAEJN,OAAOY,eAAec,KAAK,EAAEc,UAAUP,IAAI,CAAC;QAC9C;QAEAlC,GAAG,yDAAyD;YAC1D,MAAMI,SAAkB;gBACtB;oBACEC,MAAM;oBACNK,MAAM;oBACNqB,SAAS;oBACTJ,OAAO;wBAAEc,UAAU;oBAAM;gBAC3B;aACD;YAED,MAAM5B,iBAAiB,AACrB,CAAA,MAAMf,eAAe;gBACnBI;gBACAC;gBACAC;gBACAG,oBAAoB,EAAE;YACxB,EAAC,CACF,CAAC,EAAE;YAEJN,OAAOY,eAAec,KAAK,EAAEc,UAAUP,IAAI,CAAC;QAC9C;QAEAlC,GAAG,iDAAiD;YAClD,MAAMI,SAAkB;gBACtB;oBACEC,MAAM;oBACNK,MAAM;gBACR;aACD;YAED,MAAMG,iBAAiB,AACrB,CAAA,MAAMf,eAAe;gBACnBI;gBACAC;gBACAC;gBACAG,oBAAoB,EAAE;YACxB,EAAC,CACF,CAAC,EAAE;YAEJN,OAAOY,eAAec,KAAK,EAAEc,UAAUxB,aAAa;QACtD;IACF;AACF"}
|
|
@@ -168,6 +168,7 @@ export type BlocksFilterOptionsProps<TData = any> = {
|
|
|
168
168
|
id: number | string;
|
|
169
169
|
} & Pick<FilterOptionsProps<TData>, 'data' | 'req' | 'siblingData' | 'user'>;
|
|
170
170
|
export type BlocksFilterOptions<TData = any> = ((options: BlocksFilterOptionsProps<TData>) => BlockSlugOrString | Promise<BlockSlugOrString | true> | true) | BlockSlugOrString;
|
|
171
|
+
export type FieldPosition = 'main' | 'sidebar';
|
|
171
172
|
export type FieldAdmin = {
|
|
172
173
|
className?: string;
|
|
173
174
|
components?: {
|
|
@@ -210,7 +211,7 @@ export type FieldAdmin = {
|
|
|
210
211
|
*/
|
|
211
212
|
disableListFilter?: boolean;
|
|
212
213
|
hidden?: boolean;
|
|
213
|
-
position?:
|
|
214
|
+
position?: FieldPosition;
|
|
214
215
|
readOnly?: boolean;
|
|
215
216
|
style?: CSSProperties;
|
|
216
217
|
width?: CSSProperties['width'];
|
|
@@ -238,7 +239,7 @@ export type AdminClient = {
|
|
|
238
239
|
*/
|
|
239
240
|
disableListFilter?: boolean;
|
|
240
241
|
hidden?: boolean;
|
|
241
|
-
position?:
|
|
242
|
+
position?: FieldPosition;
|
|
242
243
|
readOnly?: boolean;
|
|
243
244
|
style?: {
|
|
244
245
|
'--field-width'?: CSSProperties['width'];
|