payload 3.94.0 → 3.94.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/auth/defaultAccess.d.ts +4 -0
  2. package/dist/auth/defaultAccess.d.ts.map +1 -1
  3. package/dist/auth/defaultAccess.js +4 -1
  4. package/dist/auth/defaultAccess.js.map +1 -1
  5. package/dist/auth/defaultAdminPanelUserAccess.consumers.spec.js +47 -0
  6. package/dist/auth/defaultAdminPanelUserAccess.consumers.spec.js.map +1 -0
  7. package/dist/collections/operations/count.d.ts.map +1 -1
  8. package/dist/collections/operations/count.js +3 -1
  9. package/dist/collections/operations/count.js.map +1 -1
  10. package/dist/collections/operations/countVersions.d.ts.map +1 -1
  11. package/dist/collections/operations/countVersions.js +3 -1
  12. package/dist/collections/operations/countVersions.js.map +1 -1
  13. package/dist/collections/operations/delete.d.ts.map +1 -1
  14. package/dist/collections/operations/delete.js +9 -7
  15. package/dist/collections/operations/delete.js.map +1 -1
  16. package/dist/collections/operations/find.d.ts.map +1 -1
  17. package/dist/collections/operations/find.js +9 -15
  18. package/dist/collections/operations/find.js.map +1 -1
  19. package/dist/collections/operations/findDistinct.d.ts.map +1 -1
  20. package/dist/collections/operations/findDistinct.js +3 -1
  21. package/dist/collections/operations/findDistinct.js.map +1 -1
  22. package/dist/collections/operations/findVersions.d.ts.map +1 -1
  23. package/dist/collections/operations/findVersions.js +10 -8
  24. package/dist/collections/operations/findVersions.js.map +1 -1
  25. package/dist/collections/operations/update.d.ts.map +1 -1
  26. package/dist/collections/operations/update.js +9 -15
  27. package/dist/collections/operations/update.js.map +1 -1
  28. package/dist/config/defaults.js +7 -7
  29. package/dist/config/defaults.js.map +1 -1
  30. package/dist/database/cloneWhere.d.ts +10 -0
  31. package/dist/database/cloneWhere.d.ts.map +1 -0
  32. package/dist/database/cloneWhere.js +31 -0
  33. package/dist/database/cloneWhere.js.map +1 -0
  34. package/dist/database/queryValidation/validateSearchParams.d.ts.map +1 -1
  35. package/dist/database/queryValidation/validateSearchParams.js +37 -1
  36. package/dist/database/queryValidation/validateSearchParams.js.map +1 -1
  37. package/dist/database/queryValidation/validateSortQuery.d.ts.map +1 -1
  38. package/dist/database/queryValidation/validateSortQuery.js +4 -2
  39. package/dist/database/queryValidation/validateSortQuery.js.map +1 -1
  40. package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
  41. package/dist/fields/hooks/beforeChange/index.js +6 -0
  42. package/dist/fields/hooks/beforeChange/index.js.map +1 -1
  43. package/dist/folders/createFolderCollection.js +6 -6
  44. package/dist/folders/createFolderCollection.js.map +1 -1
  45. package/dist/globals/operations/countGlobalVersions.d.ts.map +1 -1
  46. package/dist/globals/operations/countGlobalVersions.js +3 -1
  47. package/dist/globals/operations/countGlobalVersions.js.map +1 -1
  48. package/dist/globals/operations/findVersions.d.ts.map +1 -1
  49. package/dist/globals/operations/findVersions.js +3 -1
  50. package/dist/globals/operations/findVersions.js.map +1 -1
  51. package/dist/index.bundled.d.ts +58 -7
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/locked-documents/config.js +5 -5
  54. package/dist/locked-documents/config.js.map +1 -1
  55. package/dist/query-presets/access.js +5 -5
  56. package/dist/query-presets/access.js.map +1 -1
  57. package/dist/queues/config/global.d.ts.map +1 -1
  58. package/dist/queues/config/global.js +5 -0
  59. package/dist/queues/config/global.js.map +1 -1
  60. package/dist/queues/config/types/index.d.ts +3 -3
  61. package/dist/queues/config/types/index.js.map +1 -1
  62. package/dist/queues/localAPI.d.ts +6 -12
  63. package/dist/queues/localAPI.d.ts.map +1 -1
  64. package/dist/queues/localAPI.js +3 -3
  65. package/dist/queues/localAPI.js.map +1 -1
  66. package/dist/queues/operations/runJobs/index.js +1 -1
  67. package/dist/queues/operations/runJobs/index.js.map +1 -1
  68. package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
  69. package/dist/utilities/configToJSONSchema.js +6 -0
  70. package/dist/utilities/configToJSONSchema.js.map +1 -1
  71. package/dist/utilities/configToJSONSchema.spec.js +17 -0
  72. package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
  73. package/dist/utilities/deepMerge.d.ts +55 -3
  74. package/dist/utilities/deepMerge.d.ts.map +1 -1
  75. package/dist/utilities/deepMerge.js +97 -2
  76. package/dist/utilities/deepMerge.js.map +1 -1
  77. package/dist/utilities/deepMerge.spec.js +332 -0
  78. package/dist/utilities/deepMerge.spec.js.map +1 -0
  79. package/dist/utilities/sanitizeUpdateData.d.ts +5 -0
  80. package/dist/utilities/sanitizeUpdateData.d.ts.map +1 -0
  81. package/dist/utilities/sanitizeUpdateData.js +10 -0
  82. package/dist/utilities/sanitizeUpdateData.js.map +1 -0
  83. package/package.json +2 -3
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/configToJSONSchema.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { JSONSchema4, JSONSchema4TypeName } from 'json-schema'\n\nimport type { Auth } from '../auth/types.js'\nimport type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { FieldAffectingData, FlattenedField, Option } from '../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\n\nimport { MissingEditorProp } from '../errors/MissingEditorProp.js'\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { generateJobsJSONSchemas } from '../queues/config/generateJobsJSONSchemas.js'\nimport { flattenAllFields } from './flattenAllFields.js'\nimport { formatNames } from './formatLabels.js'\nimport { getCollectionIDFieldTypes } from './getCollectionIDFieldTypes.js'\nimport { optionsAreEqual } from './optionsAreEqual.js'\n\nconst fieldIsRequired = (field: FlattenedField): boolean => {\n const isConditional = Boolean(field?.admin && field?.admin?.condition)\n if (isConditional) {\n return false\n }\n\n const isMarkedRequired = 'required' in field && field.required === true\n if (fieldAffectsData(field) && isMarkedRequired) {\n return true\n }\n\n // if any subfields are required, this field is required\n if ('fields' in field && field.type !== 'array') {\n return field.flattenedFields.some((subField) => fieldIsRequired(subField))\n }\n\n return false\n}\n\nfunction buildOptionEnums(options: Option[]): string[] {\n return options.map((option) => {\n if (typeof option === 'object' && 'value' in option) {\n return option.value\n }\n\n return option\n })\n}\n\nfunction generateEntitySchemas(\n entities: (SanitizedCollectionConfig | SanitizedGlobalConfig)[],\n): JSONSchema4 {\n const properties = [...entities].reduce(\n (acc, { slug }) => {\n acc[slug] = {\n $ref: `#/definitions/${slug}`,\n }\n\n return acc\n },\n {} as Record<string, JSONSchema4>,\n )\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\nfunction generateEntitySelectSchemas(\n entities: (SanitizedCollectionConfig | SanitizedGlobalConfig)[],\n): JSONSchema4 {\n const properties = [...entities].reduce(\n (acc, { slug }) => {\n acc[slug] = {\n $ref: `#/definitions/${slug}_select`,\n }\n\n return acc\n },\n {} as Record<string, JSONSchema4>,\n )\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\nfunction generateCollectionJoinsSchemas(collections: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties = [...collections].reduce<Record<string, JSONSchema4>>(\n (acc, { slug, joins, polymorphicJoins }) => {\n const schema = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n required: [] as string[],\n } satisfies JSONSchema4\n\n for (const collectionSlug in joins) {\n for (const join of joins[collectionSlug]!) {\n ;(schema.properties as any)[join.joinPath] = {\n type: 'string',\n enum: [collectionSlug],\n }\n schema.required.push(join.joinPath)\n }\n }\n\n for (const join of polymorphicJoins) {\n ;(schema.properties as any)[join.joinPath] = {\n type: 'string',\n enum: join.field.collection,\n }\n schema.required.push(join.joinPath)\n }\n\n if (Object.keys(schema.properties).length > 0) {\n acc[slug] = schema\n }\n\n return acc\n },\n {},\n )\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\nconst widgetWidths = ['x-small', 'small', 'medium', 'large', 'x-large', 'full'] as const\n\nfunction getAllowedWidgetWidths({\n maxWidth,\n minWidth,\n}: {\n maxWidth?: (typeof widgetWidths)[number]\n minWidth?: (typeof widgetWidths)[number]\n}): string[] {\n const minIndex = minWidth ? widgetWidths.indexOf(minWidth) : 0\n const maxIndex = maxWidth ? widgetWidths.indexOf(maxWidth) : widgetWidths.length - 1\n\n if (minIndex === -1 || maxIndex === -1 || minIndex > maxIndex) {\n return [...widgetWidths]\n }\n\n return widgetWidths.slice(minIndex, maxIndex + 1)\n}\n\nfunction generateWidgetSchemas({\n collectionIDFieldTypes,\n config,\n i18n,\n interfaceNameDefinitions,\n opts = {},\n}: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config: SanitizedConfig\n i18n?: I18n\n interfaceNameDefinitions: Map<string, JSONSchema4>\n opts?: ConfigToJSONSchemaOptions\n}): {\n definitions: Record<string, JSONSchema4>\n schema: JSONSchema4\n} {\n const widgets = config.admin?.dashboard?.widgets ?? []\n const definitions: Record<string, JSONSchema4> = {}\n const properties: Record<string, JSONSchema4> = {}\n\n for (const widget of widgets) {\n const definition = `${widget.slug}_widget`\n const widthEnum = getAllowedWidgetWidths({\n maxWidth: widget.maxWidth,\n minWidth: widget.minWidth,\n })\n let dataSchema: JSONSchema4\n\n if (widget.fields?.length) {\n const widgetFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n flattenAllFields({ fields: widget.fields }),\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n )\n\n dataSchema = {\n type: 'object',\n additionalProperties: false,\n ...widgetFieldSchemas,\n }\n } else {\n dataSchema = {\n type: 'object',\n additionalProperties: true,\n }\n }\n\n definitions[definition] = {\n type: 'object',\n additionalProperties: false,\n properties: {\n data: dataSchema,\n width: {\n type: 'string',\n enum: widthEnum,\n },\n },\n required: ['width'],\n }\n\n properties[widget.slug] = {\n $ref: `#/definitions/${definition}`,\n }\n }\n\n return {\n definitions,\n schema: {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n },\n }\n}\n\nfunction generateLocaleEntitySchemas(localization: SanitizedConfig['localization']): JSONSchema4 {\n if (localization && 'locales' in localization && localization?.locales) {\n const localesFromConfig = localization?.locales\n\n const locales = [...localesFromConfig].map((locale) => {\n return locale.code\n }, [])\n\n return {\n type: 'string',\n enum: locales,\n }\n }\n\n return {\n type: 'null',\n }\n}\n\nfunction generateFallbackLocaleEntitySchemas(\n localization: SanitizedConfig['localization'],\n): JSONSchema4 {\n if (localization && 'localeCodes' in localization && localization?.localeCodes) {\n const localeCodes = [...localization.localeCodes].map((localeCode) => {\n return localeCode\n }, [])\n\n return {\n oneOf: [\n { type: 'string', enum: ['false', 'none', 'null'] },\n { type: 'boolean', enum: [false] },\n { type: 'null' },\n { type: 'string', enum: localeCodes },\n { type: 'array', items: { type: 'string', enum: localeCodes } },\n ],\n }\n }\n\n return {\n type: 'null',\n }\n}\n\nfunction generateAuthEntitySchemas(entities: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties: JSONSchema4[] = [...entities]\n .filter(({ auth }) => Boolean(auth))\n .map(({ slug }) => {\n return { $ref: `#/definitions/${slug}` }\n }, {})\n\n return {\n oneOf: properties,\n }\n}\n\n/**\n * Generates the JSON Schema for database configuration\n *\n * @example { db: idType: string }\n */\nfunction generateDbEntitySchema(config: SanitizedConfig): JSONSchema4 {\n const defaultIDType: JSONSchema4 =\n config.db?.defaultIDType === 'number' ? { type: 'number' } : { type: 'string' }\n\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n defaultIDType,\n },\n required: ['defaultIDType'],\n }\n}\n\n/**\n * Returns a JSON Schema Type with 'null' added if the field is not required.\n */\nexport function withNullableJSONSchemaType(\n fieldType: JSONSchema4TypeName,\n isRequired: boolean,\n): JSONSchema4TypeName | JSONSchema4TypeName[] {\n const fieldTypes = [fieldType]\n if (isRequired) {\n return fieldType\n }\n fieldTypes.push('null')\n return fieldTypes\n}\n\nfunction entityOrFieldToJsDocs({\n entity,\n i18n,\n}: {\n entity: FlattenedField | SanitizedCollectionConfig | SanitizedGlobalConfig\n i18n?: I18n\n}): string | undefined {\n let description: string | undefined = undefined\n if (entity?.admin?.description) {\n if (typeof entity?.admin?.description === 'string') {\n description = entity?.admin?.description\n } else if (typeof entity?.admin?.description === 'object') {\n if (entity?.admin?.description?.en) {\n description = entity?.admin?.description?.en\n } else if (entity?.admin?.description?.[i18n!.language]) {\n description = entity?.admin?.description?.[i18n!.language]\n }\n } else if (typeof entity?.admin?.description === 'function' && i18n) {\n // do not evaluate description functions for generating JSDocs. The output of\n // those can differ depending on where and when they are called, creating\n // inconsistencies in the generated JSDocs.\n }\n }\n return description\n}\n\ntype ConfigToJSONSchemaOptions = {\n forceInlineBlocks?: boolean\n}\n\nexport function fieldsToJSONSchema(\n /**\n * Used for relationship fields, to determine whether to use a string or number type for the ID.\n * While there is a default ID field type set by the db adapter, they can differ on a collection-level\n * if they have custom ID fields.\n */\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' },\n fields: FlattenedField[],\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n config?: SanitizedConfig,\n i18n?: I18n,\n opts: ConfigToJSONSchemaOptions = {},\n): {\n properties: {\n [k: string]: JSONSchema4\n }\n required: string[]\n} {\n const requiredFieldNames = new Set<string>()\n\n return {\n properties: Object.fromEntries(\n fields.reduce((fieldSchemas, field, index) => {\n const isRequired = fieldAffectsData(field) && fieldIsRequired(field)\n\n const fieldDescription = entityOrFieldToJsDocs({ entity: field, i18n })\n const baseFieldSchema: JSONSchema4 = {}\n if (fieldDescription) {\n baseFieldSchema.description = fieldDescription\n }\n\n let fieldSchema: JSONSchema4\n\n switch (field.type) {\n case 'array': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n ),\n },\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n break\n }\n case 'blocks': {\n // Check for a case where no blocks are provided.\n // We need to generate an empty array for this case, note that JSON schema 4 doesn't support empty arrays\n // so the best we can get is `unknown[]`\n const hasBlocks = Boolean(\n field.blockReferences ? field.blockReferences.length : field.blocks.length,\n )\n\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: hasBlocks\n ? {\n oneOf: (field.blockReferences ?? field.blocks).map((block) => {\n if (typeof block === 'string') {\n const resolvedBlock = config?.blocks?.find((b) => b.slug === block)\n\n if (!resolvedBlock) {\n return {}\n }\n\n if (!opts.forceInlineBlocks) {\n return {\n $ref: `#/definitions/${resolvedBlock.interfaceName ?? resolvedBlock.slug}`,\n }\n }\n\n block = resolvedBlock\n }\n const blockFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n block.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n )\n\n const blockSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {\n ...blockFieldSchemas.properties,\n blockType: {\n const: block.slug,\n },\n },\n required: ['blockType', ...blockFieldSchemas.required],\n }\n\n if (!opts.forceInlineBlocks && block.interfaceName) {\n interfaceNameDefinitions.set(block.interfaceName, blockSchema)\n\n return {\n $ref: `#/definitions/${block.interfaceName}`,\n }\n }\n\n return blockSchema\n }),\n }\n : {},\n }\n break\n }\n case 'checkbox': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('boolean', isRequired),\n }\n break\n }\n case 'code':\n case 'date':\n case 'email':\n case 'textarea': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n }\n break\n }\n\n case 'group': {\n if (fieldAffectsData(field)) {\n fieldSchema = {\n ...baseFieldSchema,\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n ),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = { $ref: `#/definitions/${field.interfaceName}` }\n }\n }\n break\n }\n\n case 'join': {\n let items: JSONSchema4\n\n if (Array.isArray(field.collection)) {\n items = {\n oneOf: field.collection.map((collection) => ({\n type: 'object',\n additionalProperties: false,\n properties: {\n relationTo: {\n const: collection,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[collection],\n },\n {\n $ref: `#/definitions/${collection}`,\n },\n ],\n },\n },\n required: ['collectionSlug', 'value'],\n })),\n }\n } else {\n items = {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.collection],\n },\n {\n $ref: `#/definitions/${field.collection}`,\n },\n ],\n }\n }\n\n fieldSchema = {\n ...baseFieldSchema,\n type: 'object',\n additionalProperties: false,\n properties: {\n docs: {\n type: 'array',\n items,\n },\n hasNextPage: { type: 'boolean' },\n totalDocs: { type: 'number' },\n },\n }\n break\n }\n\n case 'json': {\n fieldSchema = field.jsonSchema?.schema || {\n ...baseFieldSchema,\n type: ['object', 'array', 'string', 'number', 'boolean', 'null'],\n }\n break\n }\n\n case 'number': {\n if (field.hasMany === true) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'number' },\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('number', isRequired),\n }\n }\n break\n }\n\n case 'point': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: [\n {\n type: 'number',\n },\n {\n type: 'number',\n },\n ],\n maxItems: 2,\n minItems: 2,\n }\n break\n }\n\n case 'radio': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n enum: buildOptionEnums(field.options),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n\n break\n }\n case 'relationship':\n case 'upload': {\n if (Array.isArray(field.relationTo)) {\n if (field.hasMany) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: field.relationTo.map((relation) => {\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n relationTo: {\n const: relation,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[relation],\n },\n {\n $ref: `#/definitions/${relation}`,\n },\n ],\n },\n },\n required: ['value', 'relationTo'],\n }\n }),\n },\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n oneOf: field.relationTo.map((relation) => {\n return {\n type: withNullableJSONSchemaType('object', isRequired),\n additionalProperties: false,\n properties: {\n relationTo: {\n const: relation,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[relation],\n },\n {\n $ref: `#/definitions/${relation}`,\n },\n ],\n },\n },\n required: ['value', 'relationTo'],\n }\n }),\n }\n }\n } else if (field.hasMany) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.relationTo],\n },\n {\n $ref: `#/definitions/${field.relationTo}`,\n },\n ],\n },\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n oneOf: [\n {\n type: withNullableJSONSchemaType(\n collectionIDFieldTypes[field.relationTo]!,\n isRequired,\n ),\n },\n { $ref: `#/definitions/${field.relationTo}` },\n ],\n }\n }\n\n break\n }\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n if (typeof field.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n if (field.editor.outputSchema) {\n fieldSchema = {\n ...baseFieldSchema,\n ...field.editor.outputSchema({\n collectionIDFieldTypes,\n config,\n field,\n i18n,\n interfaceNameDefinitions,\n isRequired,\n }),\n }\n } else {\n // Maintain backwards compatibility with existing rich text editors\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n },\n }\n }\n\n break\n }\n\n case 'select': {\n const optionEnums = buildOptionEnums(field.options)\n // We get the previous field to check for a date in the case of a timezone select\n // This works because timezone selects are always inserted right after a date with 'timezone: true'\n const previousField = fields?.[index - 1]\n const isTimezoneField =\n previousField?.type === 'date' && previousField.timezone && field.name.includes('_tz')\n\n // Check if the timezone field's options match the global config's supported timezones\n const hasMatchingGlobalTimezones =\n isTimezoneField &&\n config &&\n optionsAreEqual(field.options, config.admin?.timezones?.supportedTimezones)\n\n // Timezone selects should reference the supportedTimezones definition\n // only if the field's options match the global config\n if (isTimezoneField && hasMatchingGlobalTimezones) {\n fieldSchema = {\n $ref: `#/definitions/supportedTimezones`,\n }\n } else {\n if (field.hasMany) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'string',\n },\n }\n if (optionEnums?.length) {\n ;(fieldSchema.items as JSONSchema4).enum = optionEnums\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n }\n if (optionEnums?.length) {\n fieldSchema.enum = optionEnums\n }\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n break\n }\n\n break\n }\n case 'tab': {\n fieldSchema = {\n ...baseFieldSchema,\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n ),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = { $ref: `#/definitions/${field.interfaceName}` }\n }\n break\n }\n\n case 'text':\n if (field.hasMany === true) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'string' },\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n }\n }\n break\n\n default: {\n break\n }\n }\n\n if ('typescriptSchema' in field && field?.typescriptSchema?.length) {\n for (const schema of field.typescriptSchema) {\n fieldSchema = schema({ jsonSchema: fieldSchema! })\n }\n }\n\n if (fieldSchema! && fieldAffectsData(field)) {\n if (isRequired && fieldSchema.required !== false) {\n requiredFieldNames.add(field.name)\n }\n fieldSchemas.set(field.name, fieldSchema)\n }\n\n return fieldSchemas\n }, new Map<string, JSONSchema4>()),\n ),\n required: Array.from(requiredFieldNames),\n }\n}\n\n// This function is part of the public API and is exported through payload/utilities\nexport function entityToJSONSchema(\n config: SanitizedConfig,\n entity: SanitizedCollectionConfig | SanitizedGlobalConfig,\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n defaultIDType: 'number' | 'text',\n collectionIDFieldTypes?: { [key: string]: 'number' | 'string' },\n i18n?: I18n,\n opts: ConfigToJSONSchemaOptions = {},\n): JSONSchema4 {\n if (!collectionIDFieldTypes) {\n collectionIDFieldTypes = getCollectionIDFieldTypes({ config, defaultIDType })\n }\n\n const title = entity.typescript?.interface\n ? entity.typescript.interface\n : formatNames(entity.slug).singular\n\n let mutableFields = [...entity.flattenedFields]\n\n const idField: FieldAffectingData = { name: 'id', type: defaultIDType as 'text', required: true }\n const customIdField = mutableFields.find((field) => field.name === 'id') as FieldAffectingData\n\n if (customIdField && customIdField.type !== 'group' && customIdField.type !== 'tab') {\n mutableFields = mutableFields.map((field) => {\n if (field === customIdField) {\n return { ...field, required: true }\n }\n\n return field\n })\n } else {\n mutableFields.unshift(idField)\n }\n\n // mark timestamp fields required\n if ('timestamps' in entity && entity.timestamps !== false) {\n mutableFields = mutableFields.map((field) => {\n if (field.name === 'createdAt' || field.name === 'updatedAt') {\n return {\n ...field,\n required: true,\n }\n }\n return field\n })\n }\n\n if (\n 'auth' in entity &&\n entity.auth &&\n (!entity.auth?.disableLocalStrategy ||\n (typeof entity.auth?.disableLocalStrategy === 'object' &&\n entity.auth.disableLocalStrategy.enableFields))\n ) {\n mutableFields.push({\n name: 'password',\n type: 'text',\n })\n }\n\n const isAuthCollection = 'auth' in entity && entity.auth\n\n const fieldsSchema = fieldsToJSONSchema(\n collectionIDFieldTypes,\n mutableFields,\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n )\n\n // Add collection property to auth collections\n if (isAuthCollection) {\n fieldsSchema.properties = {\n ...fieldsSchema.properties,\n collection: { type: 'string', enum: [entity.slug] },\n }\n fieldsSchema.required = [...(fieldsSchema.required || []), 'collection']\n }\n\n const jsonSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n title,\n ...fieldsSchema,\n }\n\n const entityDescription = entityOrFieldToJsDocs({ entity, i18n })\n\n if (entityDescription) {\n jsonSchema.description = entityDescription\n }\n\n return jsonSchema\n}\n\nexport function fieldsToSelectJSONSchema({\n config,\n fields,\n interfaceNameDefinitions,\n}: {\n config: SanitizedConfig\n fields: FlattenedField[]\n interfaceNameDefinitions: Map<string, JSONSchema4>\n}): JSONSchema4 {\n const schema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n }\n\n for (const field of fields) {\n switch (field.type) {\n case 'array':\n case 'group':\n case 'tab': {\n let fieldSchema: JSONSchema4 = fieldsToSelectJSONSchema({\n config,\n fields: field.flattenedFields,\n interfaceNameDefinitions,\n })\n\n if (field.interfaceName) {\n const definition = `${field.interfaceName}_select`\n interfaceNameDefinitions.set(definition, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${definition}`,\n }\n }\n\n schema.properties![field.name] = {\n oneOf: [\n {\n type: 'boolean',\n },\n fieldSchema,\n ],\n }\n\n break\n }\n\n case 'blocks': {\n const blocksSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n }\n\n for (const block of field.blockReferences ?? field.blocks) {\n if (typeof block === 'string') {\n continue // TODO\n }\n\n let blockSchema = fieldsToSelectJSONSchema({\n config,\n fields: block.flattenedFields,\n interfaceNameDefinitions,\n })\n\n if (block.interfaceName) {\n const definition = `${block.interfaceName}_select`\n interfaceNameDefinitions.set(definition, blockSchema)\n blockSchema = {\n $ref: `#/definitions/${definition}`,\n }\n }\n\n blocksSchema.properties![block.slug] = {\n oneOf: [\n {\n type: 'boolean',\n },\n blockSchema,\n ],\n }\n }\n\n schema.properties![field.name] = {\n oneOf: [\n {\n type: 'boolean',\n },\n blocksSchema,\n ],\n }\n\n break\n }\n\n default:\n schema.properties![field.name] = {\n type: 'boolean',\n }\n break\n }\n }\n\n return schema\n}\n\nconst fieldType: JSONSchema4 = {\n type: 'string',\n required: false,\n}\nconst generateAuthFieldTypes = ({\n type,\n loginWithUsername,\n}: {\n loginWithUsername: Auth['loginWithUsername']\n type: 'forgotOrUnlock' | 'login' | 'register'\n}): JSONSchema4 => {\n if (loginWithUsername) {\n switch (type) {\n case 'forgotOrUnlock': {\n if (loginWithUsername.allowEmailLogin) {\n // allow email or username for unlock/forgot-password\n return {\n additionalProperties: false,\n oneOf: [\n {\n additionalProperties: false,\n properties: { email: fieldType },\n required: ['email'],\n },\n {\n additionalProperties: false,\n properties: { username: fieldType },\n required: ['username'],\n },\n ],\n }\n } else {\n // allow only username for unlock/forgot-password\n return {\n additionalProperties: false,\n properties: { username: fieldType },\n required: ['username'],\n }\n }\n }\n\n case 'login': {\n if (loginWithUsername.allowEmailLogin) {\n // allow username or email and require password for login\n return {\n additionalProperties: false,\n oneOf: [\n {\n additionalProperties: false,\n properties: { email: fieldType, password: fieldType },\n required: ['email', 'password'],\n },\n {\n additionalProperties: false,\n properties: { password: fieldType, username: fieldType },\n required: ['username', 'password'],\n },\n ],\n }\n } else {\n // allow only username and password for login\n return {\n additionalProperties: false,\n properties: {\n password: fieldType,\n username: fieldType,\n },\n required: ['username', 'password'],\n }\n }\n }\n\n case 'register': {\n const requiredFields: ('email' | 'password' | 'username')[] = ['password']\n const properties: {\n email?: JSONSchema4['properties']\n password?: JSONSchema4['properties']\n username?: JSONSchema4['properties']\n } = {\n password: fieldType,\n username: fieldType,\n }\n\n if (loginWithUsername.requireEmail) {\n requiredFields.push('email')\n }\n if (loginWithUsername.requireUsername) {\n requiredFields.push('username')\n }\n if (loginWithUsername.requireEmail || loginWithUsername.allowEmailLogin) {\n properties.email = fieldType\n }\n\n return {\n additionalProperties: false,\n properties,\n required: requiredFields,\n }\n }\n }\n }\n\n // default email (and password for login/register)\n return {\n additionalProperties: false,\n properties: { email: fieldType, password: fieldType },\n required: ['email', 'password'],\n }\n}\n\nexport function authCollectionToOperationsJSONSchema(\n config: SanitizedCollectionConfig,\n): JSONSchema4 {\n const loginWithUsername = config.auth?.loginWithUsername\n const loginUserFields: JSONSchema4 = generateAuthFieldTypes({ type: 'login', loginWithUsername })\n const forgotOrUnlockUserFields: JSONSchema4 = generateAuthFieldTypes({\n type: 'forgotOrUnlock',\n loginWithUsername,\n })\n const registerUserFields: JSONSchema4 = generateAuthFieldTypes({\n type: 'register',\n loginWithUsername,\n })\n\n const properties: JSONSchema4['properties'] = {\n forgotPassword: forgotOrUnlockUserFields,\n login: loginUserFields,\n registerFirstUser: registerUserFields,\n unlock: forgotOrUnlockUserFields,\n }\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n title: `${formatNames(config.slug).singular}AuthOperations`,\n }\n}\n\n// Generates the JSON Schema for supported timezones\nexport function timezonesToJSONSchema(\n supportedTimezones: SanitizedConfig['admin']['timezones']['supportedTimezones'],\n): JSONSchema4 {\n return {\n description: 'Supported timezones in IANA format.',\n enum: supportedTimezones.map((timezone) =>\n typeof timezone === 'string' ? timezone : timezone.value,\n ),\n }\n}\n\nfunction generateAuthOperationSchemas(collections: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties = collections.reduce(\n (acc, collection) => {\n if (collection.auth) {\n acc[collection.slug] = {\n $ref: `#/definitions/auth/${collection.slug}`,\n }\n }\n return acc\n },\n {} as Record<string, JSONSchema4>,\n )\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\n/**\n * This is used for generating the TypeScript types (payload-types.ts) with the payload generate:types command.\n */\nexport function configToJSONSchema(\n config: SanitizedConfig,\n defaultIDType?: 'number' | 'text',\n i18n?: I18n,\n opts: ConfigToJSONSchemaOptions = {},\n): JSONSchema4 {\n // a mutable Map to store custom top-level `interfaceName` types. Fields with an `interfaceName` property will be moved to the top-level definitions here\n const interfaceNameDefinitions: Map<string, JSONSchema4> = new Map()\n\n // Used for relationship fields, to determine whether to use a string or number type for the ID.\n const collectionIDFieldTypes = getCollectionIDFieldTypes({\n config,\n defaultIDType: defaultIDType!,\n })\n\n // Collections and Globals have to be moved to the top-level definitions as well. Reason: The top-level type will be the `Config` type - we don't want all collection and global\n // types to be inlined inside the `Config` type\n\n const entities: {\n entity: SanitizedCollectionConfig | SanitizedGlobalConfig\n type: 'collection' | 'global'\n }[] = [\n ...config.globals.map((global) => ({ type: 'global' as const, entity: global })),\n ...config.collections.map((collection) => ({\n type: 'collection' as const,\n entity: collection,\n })),\n ]\n\n const entityDefinitions: { [k: string]: JSONSchema4 } = entities.reduce(\n (acc, { type, entity }) => {\n acc[entity.slug] = entityToJSONSchema(\n config,\n entity,\n interfaceNameDefinitions,\n defaultIDType!,\n collectionIDFieldTypes,\n i18n,\n opts,\n )\n const select = fieldsToSelectJSONSchema({\n config,\n fields: entity.flattenedFields,\n interfaceNameDefinitions,\n })\n\n if (type === 'global') {\n select.properties!.globalType = {\n type: 'boolean',\n }\n }\n\n acc[`${entity.slug}_select`] = {\n type: 'object',\n additionalProperties: false,\n ...select,\n }\n\n return acc\n },\n {} as Record<string, JSONSchema4>,\n )\n\n const timezoneDefinitions = timezonesToJSONSchema(config.admin.timezones.supportedTimezones)\n const widgetSchemas = generateWidgetSchemas({\n collectionIDFieldTypes,\n config,\n i18n,\n interfaceNameDefinitions,\n opts,\n })\n\n const authOperationDefinitions = [...config.collections]\n .filter(({ auth }) => Boolean(auth))\n .reduce(\n (acc, authCollection) => {\n acc.auth[authCollection.slug] = authCollectionToOperationsJSONSchema(authCollection)\n return acc\n },\n { auth: {} as Record<string, JSONSchema4> },\n )\n\n const jobsSchemas = config.jobs\n ? generateJobsJSONSchemas(\n config,\n config.jobs,\n interfaceNameDefinitions,\n collectionIDFieldTypes,\n i18n,\n )\n : {}\n\n const blocksDefinition: JSONSchema4 | undefined = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n required: [],\n }\n if (config?.blocks?.length) {\n for (const block of config.blocks) {\n const blockFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n block.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n )\n\n const blockSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {\n ...blockFieldSchemas.properties,\n blockType: {\n const: block.slug,\n },\n },\n required: ['blockType', ...blockFieldSchemas.required],\n }\n\n const interfaceName = block.interfaceName ?? block.slug\n interfaceNameDefinitions.set(interfaceName, blockSchema)\n\n blocksDefinition.properties![block.slug] = {\n $ref: `#/definitions/${interfaceName}`,\n }\n ;(blocksDefinition.required as string[]).push(block.slug)\n }\n }\n\n let jsonSchema: JSONSchema4 = {\n additionalProperties: false,\n definitions: {\n supportedTimezones: timezoneDefinitions,\n ...entityDefinitions,\n ...widgetSchemas.definitions,\n ...Object.fromEntries(interfaceNameDefinitions),\n ...authOperationDefinitions,\n },\n // These properties here will be very simple, as all the complexity is in the definitions. These are just the properties for the top-level `Config` type\n type: 'object',\n properties: {\n auth: generateAuthOperationSchemas(config.collections),\n blocks: blocksDefinition,\n collections: generateEntitySchemas(config.collections || []),\n collectionsJoins: generateCollectionJoinsSchemas(config.collections || []),\n collectionsSelect: generateEntitySelectSchemas(config.collections || []),\n db: generateDbEntitySchema(config),\n fallbackLocale: generateFallbackLocaleEntitySchemas(config.localization),\n globals: generateEntitySchemas(config.globals || []),\n globalsSelect: generateEntitySelectSchemas(config.globals || []),\n locale: generateLocaleEntitySchemas(config.localization),\n widgets: widgetSchemas.schema,\n ...(config.typescript?.strictDraftTypes\n ? {\n strictDraftTypes: {\n type: 'boolean',\n const: true,\n },\n }\n : {}),\n user: generateAuthEntitySchemas(config.collections),\n },\n required: [\n 'user',\n 'locale',\n 'fallbackLocale',\n 'collections',\n 'collectionsSelect',\n 'collectionsJoins',\n 'globalsSelect',\n ...(config.typescript?.strictDraftTypes ? ['strictDraftTypes'] : []),\n 'globals',\n 'auth',\n 'db',\n 'jobs',\n 'blocks',\n 'widgets',\n ],\n title: 'Config',\n }\n\n if (jobsSchemas.definitions?.size) {\n for (const [key, value] of jobsSchemas.definitions) {\n jsonSchema.definitions![key] = value\n }\n }\n if (jobsSchemas.properties) {\n jsonSchema.properties!.jobs = {\n type: 'object',\n additionalProperties: false,\n properties: jobsSchemas.properties,\n required: ['tasks', 'workflows'],\n }\n }\n\n if (config?.typescript?.schema?.length) {\n for (const schema of config.typescript.schema) {\n jsonSchema = schema({ collectionIDFieldTypes, config, i18n: i18n!, jsonSchema })\n }\n }\n\n return jsonSchema\n}\n"],"names":["MissingEditorProp","fieldAffectsData","generateJobsJSONSchemas","flattenAllFields","formatNames","getCollectionIDFieldTypes","optionsAreEqual","fieldIsRequired","field","isConditional","Boolean","admin","condition","isMarkedRequired","required","type","flattenedFields","some","subField","buildOptionEnums","options","map","option","value","generateEntitySchemas","entities","properties","reduce","acc","slug","$ref","additionalProperties","Object","keys","generateEntitySelectSchemas","generateCollectionJoinsSchemas","collections","joins","polymorphicJoins","schema","collectionSlug","join","joinPath","enum","push","collection","length","widgetWidths","getAllowedWidgetWidths","maxWidth","minWidth","minIndex","indexOf","maxIndex","slice","generateWidgetSchemas","collectionIDFieldTypes","config","i18n","interfaceNameDefinitions","opts","widgets","dashboard","definitions","widget","definition","widthEnum","dataSchema","fields","widgetFieldSchemas","fieldsToJSONSchema","data","width","generateLocaleEntitySchemas","localization","locales","localesFromConfig","locale","code","generateFallbackLocaleEntitySchemas","localeCodes","localeCode","oneOf","items","generateAuthEntitySchemas","filter","auth","generateDbEntitySchema","defaultIDType","db","withNullableJSONSchemaType","fieldType","isRequired","fieldTypes","entityOrFieldToJsDocs","entity","description","undefined","en","language","requiredFieldNames","Set","fromEntries","fieldSchemas","index","fieldDescription","baseFieldSchema","fieldSchema","interfaceName","set","hasBlocks","blockReferences","blocks","block","resolvedBlock","find","b","forceInlineBlocks","blockFieldSchemas","blockSchema","blockType","const","Array","isArray","relationTo","docs","hasNextPage","totalDocs","jsonSchema","hasMany","maxItems","minItems","relation","editor","Error","outputSchema","optionEnums","previousField","isTimezoneField","timezone","name","includes","hasMatchingGlobalTimezones","timezones","supportedTimezones","typescriptSchema","add","Map","from","entityToJSONSchema","title","typescript","interface","singular","mutableFields","idField","customIdField","unshift","timestamps","disableLocalStrategy","enableFields","isAuthCollection","fieldsSchema","entityDescription","fieldsToSelectJSONSchema","blocksSchema","generateAuthFieldTypes","loginWithUsername","allowEmailLogin","email","username","password","requiredFields","requireEmail","requireUsername","authCollectionToOperationsJSONSchema","loginUserFields","forgotOrUnlockUserFields","registerUserFields","forgotPassword","login","registerFirstUser","unlock","timezonesToJSONSchema","generateAuthOperationSchemas","configToJSONSchema","globals","global","entityDefinitions","select","globalType","timezoneDefinitions","widgetSchemas","authOperationDefinitions","authCollection","jobsSchemas","jobs","blocksDefinition","collectionsJoins","collectionsSelect","fallbackLocale","globalsSelect","strictDraftTypes","user","size","key"],"mappings":"AASA,SAASA,iBAAiB,QAAQ,iCAAgC;AAClE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,uBAAuB,QAAQ,8CAA6C;AACrF,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,WAAW,QAAQ,oBAAmB;AAC/C,SAASC,yBAAyB,QAAQ,iCAAgC;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QACpD;QACAtB,UAAU;YACR;YACA;YACA;YACA;YACA;YACA;YACA;eACI2C,OAAO8F,UAAU,EAAEmD,mBAAmB;gBAAC;aAAmB,GAAG,EAAE;YACnE;YACA;YACA;YACA;YACA;YACA;SACD;QACDpD,OAAO;IACT;IAEA,IAAI6C,YAAYpI,WAAW,EAAE6I,MAAM;QACjC,KAAK,MAAM,CAACC,KAAKtL,MAAM,IAAI4K,YAAYpI,WAAW,CAAE;YAClDiE,WAAWjE,WAAW,AAAC,CAAC8I,IAAI,GAAGtL;QACjC;IACF;IACA,IAAI4K,YAAYzK,UAAU,EAAE;QAC1BsG,WAAWtG,UAAU,CAAE0K,IAAI,GAAG;YAC5BrL,MAAM;YACNgB,sBAAsB;YACtBL,YAAYyK,YAAYzK,UAAU;YAClCZ,UAAU;gBAAC;gBAAS;aAAY;QAClC;IACF;IAEA,IAAI2C,QAAQ8F,YAAYhH,QAAQO,QAAQ;QACtC,KAAK,MAAMP,UAAUkB,OAAO8F,UAAU,CAAChH,MAAM,CAAE;YAC7CyF,aAAazF,OAAO;gBAAEiB;gBAAwBC;gBAAQC,MAAMA;gBAAOsE;YAAW;QAChF;IACF;IAEA,OAAOA;AACT"}
1
+ {"version":3,"sources":["../../src/utilities/configToJSONSchema.ts"],"sourcesContent":["import type { I18n } from '@payloadcms/translations'\nimport type { JSONSchema4, JSONSchema4TypeName } from 'json-schema'\n\nimport type { Auth } from '../auth/types.js'\nimport type { SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { SanitizedConfig } from '../config/types.js'\nimport type { FieldAffectingData, FlattenedField, Option } from '../fields/config/types.js'\nimport type { SanitizedGlobalConfig } from '../globals/config/types.js'\n\nimport { MissingEditorProp } from '../errors/MissingEditorProp.js'\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { generateJobsJSONSchemas } from '../queues/config/generateJobsJSONSchemas.js'\nimport { flattenAllFields } from './flattenAllFields.js'\nimport { formatNames } from './formatLabels.js'\nimport { getCollectionIDFieldTypes } from './getCollectionIDFieldTypes.js'\nimport { optionsAreEqual } from './optionsAreEqual.js'\n\nconst fieldIsRequired = (field: FlattenedField): boolean => {\n const isConditional = Boolean(field?.admin && field?.admin?.condition)\n if (isConditional) {\n return false\n }\n\n const isMarkedRequired = 'required' in field && field.required === true\n if (fieldAffectsData(field) && isMarkedRequired) {\n return true\n }\n\n // if any subfields are required, this field is required\n if ('fields' in field && field.type !== 'array') {\n return field.flattenedFields.some((subField) => fieldIsRequired(subField))\n }\n\n return false\n}\n\nfunction buildOptionEnums(options: Option[]): string[] {\n return options.map((option) => {\n if (typeof option === 'object' && 'value' in option) {\n return option.value\n }\n\n return option\n })\n}\n\nfunction generateEntitySchemas(\n entities: (SanitizedCollectionConfig | SanitizedGlobalConfig)[],\n): JSONSchema4 {\n const properties = [...entities].reduce(\n (acc, { slug }) => {\n acc[slug] = {\n $ref: `#/definitions/${slug}`,\n }\n\n return acc\n },\n {} as Record<string, JSONSchema4>,\n )\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\nfunction generateEntitySelectSchemas(\n entities: (SanitizedCollectionConfig | SanitizedGlobalConfig)[],\n): JSONSchema4 {\n const properties = [...entities].reduce(\n (acc, { slug }) => {\n acc[slug] = {\n $ref: `#/definitions/${slug}_select`,\n }\n\n return acc\n },\n {} as Record<string, JSONSchema4>,\n )\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\nfunction generateCollectionJoinsSchemas(collections: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties = [...collections].reduce<Record<string, JSONSchema4>>(\n (acc, { slug, joins, polymorphicJoins }) => {\n const schema = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n required: [] as string[],\n } satisfies JSONSchema4\n\n for (const collectionSlug in joins) {\n for (const join of joins[collectionSlug]!) {\n ;(schema.properties as any)[join.joinPath] = {\n type: 'string',\n enum: [collectionSlug],\n }\n schema.required.push(join.joinPath)\n }\n }\n\n for (const join of polymorphicJoins) {\n ;(schema.properties as any)[join.joinPath] = {\n type: 'string',\n enum: join.field.collection,\n }\n schema.required.push(join.joinPath)\n }\n\n if (Object.keys(schema.properties).length > 0) {\n acc[slug] = schema\n }\n\n return acc\n },\n {},\n )\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\nconst widgetWidths = ['x-small', 'small', 'medium', 'large', 'x-large', 'full'] as const\n\nfunction getAllowedWidgetWidths({\n maxWidth,\n minWidth,\n}: {\n maxWidth?: (typeof widgetWidths)[number]\n minWidth?: (typeof widgetWidths)[number]\n}): string[] {\n const minIndex = minWidth ? widgetWidths.indexOf(minWidth) : 0\n const maxIndex = maxWidth ? widgetWidths.indexOf(maxWidth) : widgetWidths.length - 1\n\n if (minIndex === -1 || maxIndex === -1 || minIndex > maxIndex) {\n return [...widgetWidths]\n }\n\n return widgetWidths.slice(minIndex, maxIndex + 1)\n}\n\nfunction generateWidgetSchemas({\n collectionIDFieldTypes,\n config,\n i18n,\n interfaceNameDefinitions,\n opts = {},\n}: {\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' }\n config: SanitizedConfig\n i18n?: I18n\n interfaceNameDefinitions: Map<string, JSONSchema4>\n opts?: ConfigToJSONSchemaOptions\n}): {\n definitions: Record<string, JSONSchema4>\n schema: JSONSchema4\n} {\n const widgets = config.admin?.dashboard?.widgets ?? []\n const definitions: Record<string, JSONSchema4> = {}\n const properties: Record<string, JSONSchema4> = {}\n\n for (const widget of widgets) {\n const definition = `${widget.slug}_widget`\n const widthEnum = getAllowedWidgetWidths({\n maxWidth: widget.maxWidth,\n minWidth: widget.minWidth,\n })\n let dataSchema: JSONSchema4\n\n if (widget.fields?.length) {\n const widgetFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n flattenAllFields({ fields: widget.fields }),\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n )\n\n dataSchema = {\n type: 'object',\n additionalProperties: false,\n ...widgetFieldSchemas,\n }\n } else {\n dataSchema = {\n type: 'object',\n additionalProperties: true,\n }\n }\n\n definitions[definition] = {\n type: 'object',\n additionalProperties: false,\n properties: {\n data: dataSchema,\n width: {\n type: 'string',\n enum: widthEnum,\n },\n },\n required: ['width'],\n }\n\n properties[widget.slug] = {\n $ref: `#/definitions/${definition}`,\n }\n }\n\n return {\n definitions,\n schema: {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n },\n }\n}\n\nfunction generateLocaleEntitySchemas(localization: SanitizedConfig['localization']): JSONSchema4 {\n if (localization && 'locales' in localization && localization?.locales) {\n const localesFromConfig = localization?.locales\n\n const locales = [...localesFromConfig].map((locale) => {\n return locale.code\n }, [])\n\n return {\n type: 'string',\n enum: locales,\n }\n }\n\n return {\n type: 'null',\n }\n}\n\nfunction generateFallbackLocaleEntitySchemas(\n localization: SanitizedConfig['localization'],\n): JSONSchema4 {\n if (localization && 'localeCodes' in localization && localization?.localeCodes) {\n const localeCodes = [...localization.localeCodes].map((localeCode) => {\n return localeCode\n }, [])\n\n return {\n oneOf: [\n { type: 'string', enum: ['false', 'none', 'null'] },\n { type: 'boolean', enum: [false] },\n { type: 'null' },\n { type: 'string', enum: localeCodes },\n { type: 'array', items: { type: 'string', enum: localeCodes } },\n ],\n }\n }\n\n return {\n type: 'null',\n }\n}\n\nfunction generateAuthEntitySchemas(entities: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties: JSONSchema4[] = [...entities]\n .filter(({ auth }) => Boolean(auth))\n .map(({ slug }) => {\n return { $ref: `#/definitions/${slug}` }\n }, {})\n\n return {\n oneOf: properties,\n }\n}\n\n/**\n * Generates the JSON Schema for database configuration\n *\n * @example { db: idType: string }\n */\nfunction generateDbEntitySchema(config: SanitizedConfig): JSONSchema4 {\n const defaultIDType: JSONSchema4 =\n config.db?.defaultIDType === 'number' ? { type: 'number' } : { type: 'string' }\n\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n defaultIDType,\n },\n required: ['defaultIDType'],\n }\n}\n\n/**\n * Returns a JSON Schema Type with 'null' added if the field is not required.\n */\nexport function withNullableJSONSchemaType(\n fieldType: JSONSchema4TypeName,\n isRequired: boolean,\n): JSONSchema4TypeName | JSONSchema4TypeName[] {\n const fieldTypes = [fieldType]\n if (isRequired) {\n return fieldType\n }\n fieldTypes.push('null')\n return fieldTypes\n}\n\nfunction entityOrFieldToJsDocs({\n entity,\n i18n,\n}: {\n entity: FlattenedField | SanitizedCollectionConfig | SanitizedGlobalConfig\n i18n?: I18n\n}): string | undefined {\n let description: string | undefined = undefined\n if (entity?.admin?.description) {\n if (typeof entity?.admin?.description === 'string') {\n description = entity?.admin?.description\n } else if (typeof entity?.admin?.description === 'object') {\n if (entity?.admin?.description?.en) {\n description = entity?.admin?.description?.en\n } else if (entity?.admin?.description?.[i18n!.language]) {\n description = entity?.admin?.description?.[i18n!.language]\n }\n } else if (typeof entity?.admin?.description === 'function' && i18n) {\n // do not evaluate description functions for generating JSDocs. The output of\n // those can differ depending on where and when they are called, creating\n // inconsistencies in the generated JSDocs.\n }\n }\n return description\n}\n\ntype ConfigToJSONSchemaOptions = {\n forceInlineBlocks?: boolean\n}\n\nexport function fieldsToJSONSchema(\n /**\n * Used for relationship fields, to determine whether to use a string or number type for the ID.\n * While there is a default ID field type set by the db adapter, they can differ on a collection-level\n * if they have custom ID fields.\n */\n collectionIDFieldTypes: { [key: string]: 'number' | 'string' },\n fields: FlattenedField[],\n /**\n * Allows you to define new top-level interfaces that can be re-used in the output schema.\n */\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n config?: SanitizedConfig,\n i18n?: I18n,\n opts: ConfigToJSONSchemaOptions = {},\n): {\n properties: {\n [k: string]: JSONSchema4\n }\n required: string[]\n} {\n const requiredFieldNames = new Set<string>()\n\n return {\n properties: Object.fromEntries(\n fields.reduce((fieldSchemas, field, index) => {\n const isRequired = fieldAffectsData(field) && fieldIsRequired(field)\n\n const fieldDescription = entityOrFieldToJsDocs({ entity: field, i18n })\n const baseFieldSchema: JSONSchema4 = {}\n if (fieldDescription) {\n baseFieldSchema.description = fieldDescription\n }\n\n let fieldSchema: JSONSchema4\n\n switch (field.type) {\n case 'array': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n ),\n },\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n break\n }\n case 'blocks': {\n // Check for a case where no blocks are provided.\n // We need to generate an empty array for this case, note that JSON schema 4 doesn't support empty arrays\n // so the best we can get is `unknown[]`\n const hasBlocks = Boolean(\n field.blockReferences ? field.blockReferences.length : field.blocks.length,\n )\n\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: hasBlocks\n ? {\n oneOf: (field.blockReferences ?? field.blocks).map((block) => {\n if (typeof block === 'string') {\n const resolvedBlock = config?.blocks?.find((b) => b.slug === block)\n\n if (!resolvedBlock) {\n return {}\n }\n\n if (!opts.forceInlineBlocks) {\n return {\n $ref: `#/definitions/${resolvedBlock.interfaceName ?? resolvedBlock.slug}`,\n }\n }\n\n block = resolvedBlock\n }\n const blockFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n block.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n )\n\n const blockSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {\n ...blockFieldSchemas.properties,\n blockType: {\n const: block.slug,\n },\n },\n required: ['blockType', ...blockFieldSchemas.required],\n }\n\n if (!opts.forceInlineBlocks && block.interfaceName) {\n interfaceNameDefinitions.set(block.interfaceName, blockSchema)\n\n return {\n $ref: `#/definitions/${block.interfaceName}`,\n }\n }\n\n return blockSchema\n }),\n }\n : {},\n }\n break\n }\n case 'checkbox': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('boolean', isRequired),\n }\n break\n }\n case 'code':\n case 'date':\n case 'email':\n case 'textarea': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n }\n break\n }\n\n case 'group': {\n if (fieldAffectsData(field)) {\n fieldSchema = {\n ...baseFieldSchema,\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n ),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = { $ref: `#/definitions/${field.interfaceName}` }\n }\n }\n break\n }\n\n case 'join': {\n let items: JSONSchema4\n\n if (Array.isArray(field.collection)) {\n items = {\n oneOf: field.collection.map((collection) => ({\n type: 'object',\n additionalProperties: false,\n properties: {\n relationTo: {\n const: collection,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[collection],\n },\n {\n $ref: `#/definitions/${collection}`,\n },\n ],\n },\n },\n required: ['collectionSlug', 'value'],\n })),\n }\n } else {\n items = {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.collection],\n },\n {\n $ref: `#/definitions/${field.collection}`,\n },\n ],\n }\n }\n\n fieldSchema = {\n ...baseFieldSchema,\n type: 'object',\n additionalProperties: false,\n properties: {\n docs: {\n type: 'array',\n items,\n },\n hasNextPage: { type: 'boolean' },\n totalDocs: { type: 'number' },\n },\n }\n break\n }\n\n case 'json': {\n fieldSchema = field.jsonSchema?.schema || {\n ...baseFieldSchema,\n type: ['object', 'array', 'string', 'number', 'boolean', 'null'],\n }\n break\n }\n\n case 'number': {\n if (field.hasMany === true) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'number' },\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('number', isRequired),\n }\n }\n break\n }\n\n case 'point': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: [\n {\n type: 'number',\n },\n {\n type: 'number',\n },\n ],\n maxItems: 2,\n minItems: 2,\n }\n break\n }\n\n case 'radio': {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n enum: buildOptionEnums(field.options),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n\n break\n }\n case 'relationship':\n case 'upload': {\n if (Array.isArray(field.relationTo)) {\n if (field.hasMany) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: field.relationTo.map((relation) => {\n return {\n type: 'object',\n additionalProperties: false,\n properties: {\n relationTo: {\n const: relation,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[relation],\n },\n {\n $ref: `#/definitions/${relation}`,\n },\n ],\n },\n },\n required: ['value', 'relationTo'],\n }\n }),\n },\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n oneOf: field.relationTo.map((relation) => {\n return {\n type: withNullableJSONSchemaType('object', isRequired),\n additionalProperties: false,\n properties: {\n relationTo: {\n const: relation,\n },\n value: {\n oneOf: [\n {\n type: collectionIDFieldTypes[relation],\n },\n {\n $ref: `#/definitions/${relation}`,\n },\n ],\n },\n },\n required: ['value', 'relationTo'],\n }\n }),\n }\n }\n } else if (field.hasMany) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n oneOf: [\n {\n type: collectionIDFieldTypes[field.relationTo],\n },\n {\n $ref: `#/definitions/${field.relationTo}`,\n },\n ],\n },\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n oneOf: [\n {\n type: withNullableJSONSchemaType(\n collectionIDFieldTypes[field.relationTo]!,\n isRequired,\n ),\n },\n { $ref: `#/definitions/${field.relationTo}` },\n ],\n }\n }\n\n break\n }\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n if (typeof field.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n if (field.editor.outputSchema) {\n fieldSchema = {\n ...baseFieldSchema,\n ...field.editor.outputSchema({\n collectionIDFieldTypes,\n config,\n field,\n i18n,\n interfaceNameDefinitions,\n isRequired,\n }),\n }\n } else {\n // Maintain backwards compatibility with existing rich text editors\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'object',\n },\n }\n }\n\n break\n }\n\n case 'select': {\n const optionEnums = buildOptionEnums(field.options)\n // We get the previous field to check for a date in the case of a timezone select\n // This works because timezone selects are always inserted right after a date with 'timezone: true'\n const previousField = fields?.[index - 1]\n const isTimezoneField =\n previousField?.type === 'date' && previousField.timezone && field.name.includes('_tz')\n\n // Check if the timezone field's options match the global config's supported timezones\n const hasMatchingGlobalTimezones =\n isTimezoneField &&\n config &&\n optionsAreEqual(field.options, config.admin?.timezones?.supportedTimezones)\n\n // Timezone selects should reference the supportedTimezones definition\n // only if the field's options match the global config\n if (isTimezoneField && hasMatchingGlobalTimezones) {\n fieldSchema = {\n $ref: `#/definitions/supportedTimezones`,\n }\n } else {\n if (field.hasMany) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: {\n type: 'string',\n },\n }\n if (optionEnums?.length) {\n ;(fieldSchema.items as JSONSchema4).enum = optionEnums\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n }\n if (optionEnums?.length) {\n fieldSchema.enum = optionEnums\n }\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${field.interfaceName}`,\n }\n }\n break\n }\n\n break\n }\n case 'tab': {\n fieldSchema = {\n ...baseFieldSchema,\n type: 'object',\n additionalProperties: false,\n ...fieldsToJSONSchema(\n collectionIDFieldTypes,\n field.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n ),\n }\n\n if (field.interfaceName) {\n interfaceNameDefinitions.set(field.interfaceName, fieldSchema)\n\n fieldSchema = { $ref: `#/definitions/${field.interfaceName}` }\n }\n break\n }\n\n case 'text':\n if (field.hasMany === true) {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('array', isRequired),\n items: { type: 'string' },\n }\n } else {\n fieldSchema = {\n ...baseFieldSchema,\n type: withNullableJSONSchemaType('string', isRequired),\n }\n }\n break\n\n default: {\n break\n }\n }\n\n if ('typescriptSchema' in field && field?.typescriptSchema?.length) {\n for (const schema of field.typescriptSchema) {\n fieldSchema = schema({ jsonSchema: fieldSchema! })\n }\n }\n\n if (fieldSchema! && fieldAffectsData(field)) {\n if (isRequired && fieldSchema.required !== false) {\n requiredFieldNames.add(field.name)\n }\n fieldSchemas.set(field.name, fieldSchema)\n }\n\n return fieldSchemas\n }, new Map<string, JSONSchema4>()),\n ),\n required: Array.from(requiredFieldNames),\n }\n}\n\n// This function is part of the public API and is exported through payload/utilities\nexport function entityToJSONSchema(\n config: SanitizedConfig,\n entity: SanitizedCollectionConfig | SanitizedGlobalConfig,\n interfaceNameDefinitions: Map<string, JSONSchema4>,\n defaultIDType: 'number' | 'text',\n collectionIDFieldTypes?: { [key: string]: 'number' | 'string' },\n i18n?: I18n,\n opts: ConfigToJSONSchemaOptions = {},\n): JSONSchema4 {\n if (!collectionIDFieldTypes) {\n collectionIDFieldTypes = getCollectionIDFieldTypes({ config, defaultIDType })\n }\n\n const title = entity.typescript?.interface\n ? entity.typescript.interface\n : formatNames(entity.slug).singular\n\n let mutableFields = [...entity.flattenedFields]\n\n const idField: FieldAffectingData = { name: 'id', type: defaultIDType as 'text', required: true }\n const customIdField = mutableFields.find((field) => field.name === 'id') as FieldAffectingData\n\n if (customIdField && customIdField.type !== 'group' && customIdField.type !== 'tab') {\n mutableFields = mutableFields.map((field) => {\n if (field === customIdField) {\n return { ...field, required: true }\n }\n\n return field\n })\n } else {\n mutableFields.unshift(idField)\n }\n\n // mark timestamp fields required\n if ('timestamps' in entity && entity.timestamps !== false) {\n mutableFields = mutableFields.map((field) => {\n if (field.name === 'createdAt' || field.name === 'updatedAt') {\n return {\n ...field,\n required: true,\n }\n }\n return field\n })\n }\n\n if (\n 'auth' in entity &&\n entity.auth &&\n (!entity.auth?.disableLocalStrategy ||\n (typeof entity.auth?.disableLocalStrategy === 'object' &&\n entity.auth.disableLocalStrategy.enableFields))\n ) {\n mutableFields.push({\n name: 'password',\n type: 'text',\n })\n }\n\n const isAuthCollection = 'auth' in entity && entity.auth\n\n const fieldsSchema = fieldsToJSONSchema(\n collectionIDFieldTypes,\n mutableFields,\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n )\n\n // Add collection property to auth collections\n if (isAuthCollection) {\n fieldsSchema.properties = {\n ...fieldsSchema.properties,\n collection: { type: 'string', enum: [entity.slug] },\n }\n fieldsSchema.required = [...(fieldsSchema.required || []), 'collection']\n }\n\n const jsonSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n title,\n ...fieldsSchema,\n }\n\n const entityDescription = entityOrFieldToJsDocs({ entity, i18n })\n\n if (entityDescription) {\n jsonSchema.description = entityDescription\n }\n\n return jsonSchema\n}\n\nexport function fieldsToSelectJSONSchema({\n config,\n fields,\n interfaceNameDefinitions,\n}: {\n config: SanitizedConfig\n fields: FlattenedField[]\n interfaceNameDefinitions: Map<string, JSONSchema4>\n}): JSONSchema4 {\n const schema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n }\n\n for (const field of fields) {\n switch (field.type) {\n case 'array':\n case 'group':\n case 'tab': {\n let fieldSchema: JSONSchema4 = fieldsToSelectJSONSchema({\n config,\n fields: field.flattenedFields,\n interfaceNameDefinitions,\n })\n\n if (field.interfaceName) {\n const definition = `${field.interfaceName}_select`\n interfaceNameDefinitions.set(definition, fieldSchema)\n\n fieldSchema = {\n $ref: `#/definitions/${definition}`,\n }\n }\n\n schema.properties![field.name] = {\n oneOf: [\n {\n type: 'boolean',\n },\n fieldSchema,\n ],\n }\n\n break\n }\n\n case 'blocks': {\n const blocksSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n }\n\n for (const block of field.blockReferences ?? field.blocks) {\n if (typeof block === 'string') {\n continue // TODO\n }\n\n let blockSchema = fieldsToSelectJSONSchema({\n config,\n fields: block.flattenedFields,\n interfaceNameDefinitions,\n })\n\n if (block.interfaceName) {\n const definition = `${block.interfaceName}_select`\n interfaceNameDefinitions.set(definition, blockSchema)\n blockSchema = {\n $ref: `#/definitions/${definition}`,\n }\n }\n\n blocksSchema.properties![block.slug] = {\n oneOf: [\n {\n type: 'boolean',\n },\n blockSchema,\n ],\n }\n }\n\n schema.properties![field.name] = {\n oneOf: [\n {\n type: 'boolean',\n },\n blocksSchema,\n ],\n }\n\n break\n }\n\n default:\n schema.properties![field.name] = {\n type: 'boolean',\n }\n break\n }\n }\n\n return schema\n}\n\nconst fieldType: JSONSchema4 = {\n type: 'string',\n required: false,\n}\nconst generateAuthFieldTypes = ({\n type,\n loginWithUsername,\n}: {\n loginWithUsername: Auth['loginWithUsername']\n type: 'forgotOrUnlock' | 'login' | 'register'\n}): JSONSchema4 => {\n if (loginWithUsername) {\n switch (type) {\n case 'forgotOrUnlock': {\n if (loginWithUsername.allowEmailLogin) {\n // allow email or username for unlock/forgot-password\n return {\n additionalProperties: false,\n oneOf: [\n {\n additionalProperties: false,\n properties: { email: fieldType },\n required: ['email'],\n },\n {\n additionalProperties: false,\n properties: { username: fieldType },\n required: ['username'],\n },\n ],\n }\n } else {\n // allow only username for unlock/forgot-password\n return {\n additionalProperties: false,\n properties: { username: fieldType },\n required: ['username'],\n }\n }\n }\n\n case 'login': {\n if (loginWithUsername.allowEmailLogin) {\n // allow username or email and require password for login\n return {\n additionalProperties: false,\n oneOf: [\n {\n additionalProperties: false,\n properties: { email: fieldType, password: fieldType },\n required: ['email', 'password'],\n },\n {\n additionalProperties: false,\n properties: { password: fieldType, username: fieldType },\n required: ['username', 'password'],\n },\n ],\n }\n } else {\n // allow only username and password for login\n return {\n additionalProperties: false,\n properties: {\n password: fieldType,\n username: fieldType,\n },\n required: ['username', 'password'],\n }\n }\n }\n\n case 'register': {\n const requiredFields: ('email' | 'password' | 'username')[] = ['password']\n const properties: {\n email?: JSONSchema4['properties']\n password?: JSONSchema4['properties']\n username?: JSONSchema4['properties']\n } = {\n password: fieldType,\n username: fieldType,\n }\n\n if (loginWithUsername.requireEmail) {\n requiredFields.push('email')\n }\n if (loginWithUsername.requireUsername) {\n requiredFields.push('username')\n }\n if (loginWithUsername.requireEmail || loginWithUsername.allowEmailLogin) {\n properties.email = fieldType\n }\n\n return {\n additionalProperties: false,\n properties,\n required: requiredFields,\n }\n }\n }\n }\n\n // default email (and password for login/register)\n return {\n additionalProperties: false,\n properties: { email: fieldType, password: fieldType },\n required: ['email', 'password'],\n }\n}\n\nexport function authCollectionToOperationsJSONSchema(\n config: SanitizedCollectionConfig,\n): JSONSchema4 {\n const loginWithUsername = config.auth?.loginWithUsername\n const loginUserFields: JSONSchema4 = generateAuthFieldTypes({ type: 'login', loginWithUsername })\n const forgotOrUnlockUserFields: JSONSchema4 = generateAuthFieldTypes({\n type: 'forgotOrUnlock',\n loginWithUsername,\n })\n const registerUserFields: JSONSchema4 = generateAuthFieldTypes({\n type: 'register',\n loginWithUsername,\n })\n\n const properties: JSONSchema4['properties'] = {\n forgotPassword: forgotOrUnlockUserFields,\n login: loginUserFields,\n registerFirstUser: registerUserFields,\n unlock: forgotOrUnlockUserFields,\n }\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n title: `${formatNames(config.slug).singular}AuthOperations`,\n }\n}\n\n// Generates the JSON Schema for supported timezones\nexport function timezonesToJSONSchema(\n supportedTimezones: SanitizedConfig['admin']['timezones']['supportedTimezones'],\n): JSONSchema4 {\n if (supportedTimezones.length === 0) {\n return {\n description: 'Supported timezones in IANA format.',\n tsType: 'never',\n }\n }\n\n return {\n description: 'Supported timezones in IANA format.',\n enum: supportedTimezones.map((timezone) =>\n typeof timezone === 'string' ? timezone : timezone.value,\n ),\n }\n}\n\nfunction generateAuthOperationSchemas(collections: SanitizedCollectionConfig[]): JSONSchema4 {\n const properties = collections.reduce(\n (acc, collection) => {\n if (collection.auth) {\n acc[collection.slug] = {\n $ref: `#/definitions/auth/${collection.slug}`,\n }\n }\n return acc\n },\n {} as Record<string, JSONSchema4>,\n )\n\n return {\n type: 'object',\n additionalProperties: false,\n properties,\n required: Object.keys(properties),\n }\n}\n\n/**\n * This is used for generating the TypeScript types (payload-types.ts) with the payload generate:types command.\n */\nexport function configToJSONSchema(\n config: SanitizedConfig,\n defaultIDType?: 'number' | 'text',\n i18n?: I18n,\n opts: ConfigToJSONSchemaOptions = {},\n): JSONSchema4 {\n // a mutable Map to store custom top-level `interfaceName` types. Fields with an `interfaceName` property will be moved to the top-level definitions here\n const interfaceNameDefinitions: Map<string, JSONSchema4> = new Map()\n\n // Used for relationship fields, to determine whether to use a string or number type for the ID.\n const collectionIDFieldTypes = getCollectionIDFieldTypes({\n config,\n defaultIDType: defaultIDType!,\n })\n\n // Collections and Globals have to be moved to the top-level definitions as well. Reason: The top-level type will be the `Config` type - we don't want all collection and global\n // types to be inlined inside the `Config` type\n\n const entities: {\n entity: SanitizedCollectionConfig | SanitizedGlobalConfig\n type: 'collection' | 'global'\n }[] = [\n ...config.globals.map((global) => ({ type: 'global' as const, entity: global })),\n ...config.collections.map((collection) => ({\n type: 'collection' as const,\n entity: collection,\n })),\n ]\n\n const entityDefinitions: { [k: string]: JSONSchema4 } = entities.reduce(\n (acc, { type, entity }) => {\n acc[entity.slug] = entityToJSONSchema(\n config,\n entity,\n interfaceNameDefinitions,\n defaultIDType!,\n collectionIDFieldTypes,\n i18n,\n opts,\n )\n const select = fieldsToSelectJSONSchema({\n config,\n fields: entity.flattenedFields,\n interfaceNameDefinitions,\n })\n\n if (type === 'global') {\n select.properties!.globalType = {\n type: 'boolean',\n }\n }\n\n acc[`${entity.slug}_select`] = {\n type: 'object',\n additionalProperties: false,\n ...select,\n }\n\n return acc\n },\n {} as Record<string, JSONSchema4>,\n )\n\n const timezoneDefinitions = timezonesToJSONSchema(config.admin.timezones.supportedTimezones)\n const widgetSchemas = generateWidgetSchemas({\n collectionIDFieldTypes,\n config,\n i18n,\n interfaceNameDefinitions,\n opts,\n })\n\n const authOperationDefinitions = [...config.collections]\n .filter(({ auth }) => Boolean(auth))\n .reduce(\n (acc, authCollection) => {\n acc.auth[authCollection.slug] = authCollectionToOperationsJSONSchema(authCollection)\n return acc\n },\n { auth: {} as Record<string, JSONSchema4> },\n )\n\n const jobsSchemas = config.jobs\n ? generateJobsJSONSchemas(\n config,\n config.jobs,\n interfaceNameDefinitions,\n collectionIDFieldTypes,\n i18n,\n )\n : {}\n\n const blocksDefinition: JSONSchema4 | undefined = {\n type: 'object',\n additionalProperties: false,\n properties: {},\n required: [],\n }\n if (config?.blocks?.length) {\n for (const block of config.blocks) {\n const blockFieldSchemas = fieldsToJSONSchema(\n collectionIDFieldTypes,\n block.flattenedFields,\n interfaceNameDefinitions,\n config,\n i18n,\n opts,\n )\n\n const blockSchema: JSONSchema4 = {\n type: 'object',\n additionalProperties: false,\n properties: {\n ...blockFieldSchemas.properties,\n blockType: {\n const: block.slug,\n },\n },\n required: ['blockType', ...blockFieldSchemas.required],\n }\n\n const interfaceName = block.interfaceName ?? block.slug\n interfaceNameDefinitions.set(interfaceName, blockSchema)\n\n blocksDefinition.properties![block.slug] = {\n $ref: `#/definitions/${interfaceName}`,\n }\n ;(blocksDefinition.required as string[]).push(block.slug)\n }\n }\n\n let jsonSchema: JSONSchema4 = {\n additionalProperties: false,\n definitions: {\n supportedTimezones: timezoneDefinitions,\n ...entityDefinitions,\n ...widgetSchemas.definitions,\n ...Object.fromEntries(interfaceNameDefinitions),\n ...authOperationDefinitions,\n },\n // These properties here will be very simple, as all the complexity is in the definitions. These are just the properties for the top-level `Config` type\n type: 'object',\n properties: {\n auth: generateAuthOperationSchemas(config.collections),\n blocks: blocksDefinition,\n collections: generateEntitySchemas(config.collections || []),\n collectionsJoins: generateCollectionJoinsSchemas(config.collections || []),\n collectionsSelect: generateEntitySelectSchemas(config.collections || []),\n db: generateDbEntitySchema(config),\n fallbackLocale: generateFallbackLocaleEntitySchemas(config.localization),\n globals: generateEntitySchemas(config.globals || []),\n globalsSelect: generateEntitySelectSchemas(config.globals || []),\n locale: generateLocaleEntitySchemas(config.localization),\n widgets: widgetSchemas.schema,\n ...(config.typescript?.strictDraftTypes\n ? {\n strictDraftTypes: {\n type: 'boolean',\n const: true,\n },\n }\n : {}),\n user: generateAuthEntitySchemas(config.collections),\n },\n required: [\n 'user',\n 'locale',\n 'fallbackLocale',\n 'collections',\n 'collectionsSelect',\n 'collectionsJoins',\n 'globalsSelect',\n ...(config.typescript?.strictDraftTypes ? ['strictDraftTypes'] : []),\n 'globals',\n 'auth',\n 'db',\n 'jobs',\n 'blocks',\n 'widgets',\n ],\n title: 'Config',\n }\n\n if (jobsSchemas.definitions?.size) {\n for (const [key, value] of jobsSchemas.definitions) {\n jsonSchema.definitions![key] = value\n }\n }\n if (jobsSchemas.properties) {\n jsonSchema.properties!.jobs = {\n type: 'object',\n additionalProperties: false,\n properties: jobsSchemas.properties,\n required: ['tasks', 'workflows'],\n }\n }\n\n if (config?.typescript?.schema?.length) {\n for (const schema of config.typescript.schema) {\n jsonSchema = schema({ collectionIDFieldTypes, config, i18n: i18n!, jsonSchema })\n }\n }\n\n return jsonSchema\n}\n"],"names":["MissingEditorProp","fieldAffectsData","generateJobsJSONSchemas","flattenAllFields","formatNames","getCollectionIDFieldTypes","optionsAreEqual","fieldIsRequired","field","isConditional","Boolean","admin","condition","isMarkedRequired","required","type","flattenedFields","some","subField","buildOptionEnums","options","map","option","value","generateEntitySchemas","entities","properties","reduce","acc","slug","$ref","additionalProperties","Object","keys","generateEntitySelectSchemas","generateCollectionJoinsSchemas","collections","joins","polymorphicJoins","schema","collectionSlug","join","joinPath","enum","push","collection","length","widgetWidths","getAllowedWidgetWidths","maxWidth","minWidth","minIndex","indexOf","maxIndex","slice","generateWidgetSchemas","collectionIDFieldTypes","config","i18n","interfaceNameDefinitions","opts","widgets","dashboard","definitions","widget","definition","widthEnum","dataSchema","fields","widgetFieldSchemas","fieldsToJSONSchema","data","width","generateLocaleEntitySchemas","localization","locales","localesFromConfig","locale","code","generateFallbackLocaleEntitySchemas","localeCodes","localeCode","oneOf","items","generateAuthEntitySchemas","filter","auth","generateDbEntitySchema","defaultIDType","db","withNullableJSONSchemaType","fieldType","isRequired","fieldTypes","entityOrFieldToJsDocs","entity","description","undefined","en","language","requiredFieldNames","Set","fromEntries","fieldSchemas","index","fieldDescription","baseFieldSchema","fieldSchema","interfaceName","set","hasBlocks","blockReferences","blocks","block","resolvedBlock","find","b","forceInlineBlocks","blockFieldSchemas","blockSchema","blockType","const","Array","isArray","relationTo","docs","hasNextPage","totalDocs","jsonSchema","hasMany","maxItems","minItems","relation","editor","Error","outputSchema","optionEnums","previousField","isTimezoneField","timezone","name","includes","hasMatchingGlobalTimezones","timezones","supportedTimezones","typescriptSchema","add","Map","from","entityToJSONSchema","title","typescript","interface","singular","mutableFields","idField","customIdField","unshift","timestamps","disableLocalStrategy","enableFields","isAuthCollection","fieldsSchema","entityDescription","fieldsToSelectJSONSchema","blocksSchema","generateAuthFieldTypes","loginWithUsername","allowEmailLogin","email","username","password","requiredFields","requireEmail","requireUsername","authCollectionToOperationsJSONSchema","loginUserFields","forgotOrUnlockUserFields","registerUserFields","forgotPassword","login","registerFirstUser","unlock","timezonesToJSONSchema","tsType","generateAuthOperationSchemas","configToJSONSchema","globals","global","entityDefinitions","select","globalType","timezoneDefinitions","widgetSchemas","authOperationDefinitions","authCollection","jobsSchemas","jobs","blocksDefinition","collectionsJoins","collectionsSelect","fallbackLocale","globalsSelect","strictDraftTypes","user","size","key"],"mappings":"AASA,SAASA,iBAAiB,QAAQ,iCAAgC;AAClE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,uBAAuB,QAAQ,8CAA6C;AACrF,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SAASC,WAAW,QAAQ,oBAAmB;AAC/C,SAASC,yBAAyB,QAAQ,iCAAgC;AAC1E,SAASC,eAAe,QAAQ,uBAAsB;AAEtD,MAAMC,kBAAkB,CAACC;IACvB,MAAMC,gBAAgBC,QAAQF,OAAOG,SAASH,OAAOG,OAAOC;IAC5D,IAAIH,eAAe;QACjB,OAAO;IACT;IAEA,MAAMI,mBAAmB,cAAcL,SAASA,MAAMM,QAAQ,KAAK;IACnE,IAAIb,iBAAiBO,UAAUK,kBAAkB;QAC/C,OAAO;IACT;IAEA,wDAAwD;IACxD,IAAI,YAAYL,SAASA,MAAMO,IAAI,KAAK,SAAS;QAC/C,OAAOP,MAAMQ,eAAe,CAACC,IAAI,CAAC,CAACC,WAAaX,gBAAgBW;IAClE;IAEA,OAAO;AACT;AAEA,SAASC,iBAAiBC,OAAiB;IACzC,OAAOA,QAAQC,GAAG,CAAC,CAACC;QAClB,IAAI,OAAOA,WAAW,YAAY,WAAWA,QAAQ;YACnD,OAAOA,OAAOC,KAAK;QACrB;QAEA,OAAOD;IACT;AACF;AAEA,SAASE,sBACPC,QAA+D;IAE/D,MAAMC,aAAa;WAAID;KAAS,CAACE,MAAM,CACrC,CAACC,KAAK,EAAEC,IAAI,EAAE;QACZD,GAAG,CAACC,KAAK,GAAG;YACVC,MAAM,CAAC,cAAc,EAAED,MAAM;QAC/B;QAEA,OAAOD;IACT,GACA,CAAC;IAGH,OAAO;QACLb,MAAM;QACNgB,sBAAsB;QACtBL;QACAZ,UAAUkB,OAAOC,IAAI,CAAC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
  import { describe, it, expect } from 'vitest';
2
3
  import { sanitizeConfig } from '../config/sanitize.js';
3
4
  import { configToJSONSchema } from './configToJSONSchema.js';
4
5
  describe('configToJSONSchema', ()=>{
6
+ it('should generate never for empty supported timezones', async ()=>{
7
+ const config = await sanitizeConfig({
8
+ admin: {
9
+ timezones: {
10
+ defaultTimezone: 'Europe/London',
11
+ supportedTimezones: []
12
+ }
13
+ },
14
+ collections: []
15
+ });
16
+ const schema = configToJSONSchema(config, 'text');
17
+ const types = await compile(schema, 'Config', {
18
+ unreachableDefinitions: true
19
+ });
20
+ expect(types).toContain('export type SupportedTimezones = never;');
21
+ });
5
22
  it('should handle optional arrays with required fields', async ()=>{
6
23
  // @ts-expect-error
7
24
  const config = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utilities/configToJSONSchema.spec.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\nimport { describe, it, expect } from 'vitest'\n\nimport type { Config } from '../config/types.js'\n\nimport { sanitizeConfig } from '../config/sanitize.js'\nimport { configToJSONSchema } from './configToJSONSchema.js'\nimport type { Block, BlocksField, RichTextField } from '../fields/config/types.js'\n\ndescribe('configToJSONSchema', () => {\n it('should handle optional arrays with required fields', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'someRequiredField',\n type: 'array',\n fields: [\n {\n name: 'someRequiredField',\n type: 'text',\n required: true,\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n someRequiredField: {\n type: ['array', 'null'],\n items: {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n someRequiredField: {\n type: 'string',\n },\n },\n required: ['someRequiredField'],\n },\n },\n },\n required: ['id'],\n title: 'Test',\n })\n })\n\n it('should handle block fields with no blocks', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'blockField',\n type: 'blocks',\n blocks: [],\n },\n {\n name: 'blockFieldRequired',\n type: 'blocks',\n blocks: [],\n required: true,\n },\n {\n name: 'blockFieldWithFields',\n type: 'blocks',\n blocks: [\n {\n slug: 'test',\n fields: [\n {\n name: 'field',\n type: 'text',\n },\n ],\n },\n ],\n },\n {\n name: 'blockFieldWithFieldsRequired',\n type: 'blocks',\n blocks: [\n {\n slug: 'test',\n fields: [\n {\n name: 'field',\n type: 'text',\n required: true,\n },\n ],\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n blockField: {\n type: ['array', 'null'],\n items: {},\n },\n blockFieldRequired: {\n type: 'array',\n items: {},\n },\n blockFieldWithFields: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n blockName: {\n type: ['string', 'null'],\n },\n blockType: {\n const: 'test',\n },\n field: {\n type: ['string', 'null'],\n },\n },\n required: ['blockType'],\n },\n ],\n },\n },\n blockFieldWithFieldsRequired: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n blockName: {\n type: ['string', 'null'],\n },\n blockType: {\n const: 'test',\n },\n field: {\n type: 'string',\n },\n },\n required: ['blockType', 'field'],\n },\n ],\n },\n },\n },\n required: ['id', 'blockFieldRequired'],\n title: 'Test',\n })\n })\n\n it('should handle tabs and named tabs with required fields', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n {\n name: 'fieldInUnnamedTab',\n type: 'text',\n },\n ],\n label: 'unnamedTab',\n },\n {\n name: 'namedTab',\n fields: [\n {\n name: 'fieldInNamedTab',\n type: 'text',\n },\n ],\n label: 'namedTab',\n },\n {\n name: 'namedTabWithRequired',\n fields: [\n {\n name: 'fieldInNamedTab',\n type: 'text',\n required: true,\n },\n ],\n label: 'namedTabWithRequired',\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n fieldInUnnamedTab: {\n type: ['string', 'null'],\n },\n namedTab: {\n type: 'object',\n additionalProperties: false,\n properties: {\n fieldInNamedTab: {\n type: ['string', 'null'],\n },\n },\n required: [],\n },\n namedTabWithRequired: {\n type: 'object',\n additionalProperties: false,\n properties: {\n fieldInNamedTab: {\n type: 'string',\n },\n },\n required: ['fieldInNamedTab'],\n },\n },\n required: ['id', 'namedTabWithRequired'],\n title: 'Test',\n })\n })\n\n it('should handle custom typescript schema and JSON field schema', async () => {\n const customSchema: JSONSchema4 = {\n type: 'object',\n properties: {\n id: {\n type: 'number',\n },\n required: ['id'],\n },\n }\n\n const config: Partial<Config> = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'withCustom',\n type: 'text',\n typescriptSchema: [() => customSchema],\n },\n {\n name: 'jsonWithSchema',\n type: 'json',\n jsonSchema: {\n fileMatch: ['a://b/foo.json'],\n schema: customSchema,\n uri: 'a://b/foo.json',\n },\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config as Config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n jsonWithSchema: customSchema,\n withCustom: customSchema,\n },\n required: ['id'],\n title: 'Test',\n })\n })\n\n it('should handle same block object being referenced in both collection and config.blocks', async () => {\n const sharedBlock: Block = {\n slug: 'sharedBlock',\n interfaceName: 'SharedBlock',\n fields: [\n {\n name: 'richText',\n type: 'richText',\n editor: () => {\n // stub rich text editor\n return {\n CellComponent: '',\n FieldComponent: '',\n validate: () => true,\n }\n },\n },\n ],\n }\n\n // @ts-expect-error\n const config: Config = {\n blocks: [sharedBlock],\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'someBlockField',\n type: 'blocks',\n blocks: [sharedBlock],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n // Ensure both rich text editor are sanitized\n const sanitizedConfig = await sanitizeConfig(config)\n expect(typeof (sanitizedConfig?.blocks?.[0]?.fields?.[0] as RichTextField)?.editor).toBe(\n 'object',\n )\n expect(\n typeof (\n (sanitizedConfig.collections[0].fields[0] as BlocksField)?.blocks?.[0]\n ?.fields?.[0] as RichTextField\n )?.editor,\n ).toBe('object')\n\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n const expectedBlockSchema = {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: { type: ['string', 'null'] },\n blockName: { type: ['string', 'null'] },\n blockType: { const: 'sharedBlock' },\n richText: { type: ['array', 'null'], items: { type: 'object' } },\n },\n required: ['blockType'],\n }\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n title: 'Test',\n properties: {\n id: {\n type: 'string',\n },\n someBlockField: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n $ref: '#/definitions/SharedBlock',\n },\n ],\n },\n },\n },\n required: ['id'],\n })\n\n // The definition should still be registered for TypeScript type generation\n expect(schema?.definitions?.SharedBlock).toStrictEqual(expectedBlockSchema)\n })\n\n it('should allow overriding required to false', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'title',\n type: 'text',\n required: true,\n defaultValue: 'test',\n typescriptSchema: [\n () => ({\n type: 'string',\n required: false,\n }),\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n // @ts-expect-error\n expect(schema.definitions.test.properties.title.required).toStrictEqual(false)\n })\n\n it('should propagate forceInlineBlocks to nested fields (array, group, tab)', async () => {\n const namedBlock: Block = {\n slug: 'myBlock',\n interfaceName: 'MyBlock',\n fields: [{ name: 'text', type: 'text' }],\n }\n\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'arr',\n type: 'array',\n fields: [{ name: 'blocks', type: 'blocks', blocks: [namedBlock] }],\n },\n {\n name: 'grp',\n type: 'group',\n fields: [{ name: 'blocks', type: 'blocks', blocks: [namedBlock] }],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n\n // Without forceInlineBlocks: blocks field uses $ref\n const schemaDefault = configToJSONSchema(sanitizedConfig, 'text')\n const arrItemsDefault = schemaDefault.definitions!.test.properties!.arr.items as JSONSchema4\n const arrBlocksDefault = (arrItemsDefault.properties!.blocks.items as JSONSchema4).oneOf![0]\n expect(arrBlocksDefault).toStrictEqual({ $ref: '#/definitions/MyBlock' })\n\n // With forceInlineBlocks: blocks field is inlined, no $ref\n const schemaInline = configToJSONSchema(sanitizedConfig, 'text', undefined, {\n forceInlineBlocks: true,\n })\n const arrItemsInline = schemaInline.definitions!.test.properties!.arr.items as JSONSchema4\n const arrBlocksInline = (arrItemsInline.properties!.blocks.items as JSONSchema4).oneOf![0]\n expect(arrBlocksInline).not.toHaveProperty('$ref')\n expect(arrBlocksInline.properties?.blockType).toStrictEqual({ const: 'myBlock' })\n\n const grpBlocksInline = (\n schemaInline.definitions!.test.properties!.grp.properties!.blocks.items as JSONSchema4\n ).oneOf![0]\n expect(grpBlocksInline).not.toHaveProperty('$ref')\n expect(grpBlocksInline.properties?.blockType).toStrictEqual({ const: 'myBlock' })\n })\n})\n"],"names":["describe","it","expect","sanitizeConfig","configToJSONSchema","config","collections","slug","fields","name","type","required","timestamps","sanitizedConfig","schema","definitions","test","toStrictEqual","additionalProperties","properties","id","someRequiredField","items","title","blocks","blockField","blockFieldRequired","blockFieldWithFields","oneOf","blockName","blockType","const","field","blockFieldWithFieldsRequired","tabs","label","fieldInUnnamedTab","namedTab","fieldInNamedTab","namedTabWithRequired","customSchema","typescriptSchema","jsonSchema","fileMatch","uri","jsonWithSchema","withCustom","sharedBlock","interfaceName","editor","CellComponent","FieldComponent","validate","toBe","expectedBlockSchema","richText","someBlockField","$ref","SharedBlock","defaultValue","namedBlock","schemaDefault","arrItemsDefault","arr","arrBlocksDefault","schemaInline","undefined","forceInlineBlocks","arrItemsInline","arrBlocksInline","not","toHaveProperty","grpBlocksInline","grp"],"mappings":"AACA,SAASA,QAAQ,EAAEC,EAAE,EAAEC,MAAM,QAAQ,SAAQ;AAI7C,SAASC,cAAc,QAAQ,wBAAuB;AACtD,SAASC,kBAAkB,QAAQ,0BAAyB;AAG5DJ,SAAS,sBAAsB;IAC7BC,GAAG,sDAAsD;QACvD,mBAAmB;QACnB,MAAMI,SAAiB;YACrBC,aAAa;gBACX;oBACEC,MAAM;oBACNC,QAAQ;wBACN;4BACEC,MAAM;4BACNC,MAAM;4BACNF,QAAQ;gCACN;oCACEC,MAAM;oCACNC,MAAM;oCACNC,UAAU;gCACZ;6BACD;wBACH;qBACD;oBACDC,YAAY;gBACd;aACD;QACH;QAEA,MAAMC,kBAAkB,MAAMV,eAAeE;QAC7C,MAAMS,SAASV,mBAAmBS,iBAAiB;QAEnDX,OAAOY,QAAQC,aAAaC,MAAMC,aAAa,CAAC;YAC9CP,MAAM;YACNQ,sBAAsB;YACtBC,YAAY;gBACVC,IAAI;oBACFV,MAAM;gBACR;gBACAW,mBAAmB;oBACjBX,MAAM;wBAAC;wBAAS;qBAAO;oBACvBY,OAAO;wBACLZ,MAAM;wB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AAWb,aAAa,CAAC;YAAEc,OAAO;QAAU;IACjF;AACF"}
1
+ {"version":3,"sources":["../../src/utilities/configToJSONSchema.spec.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\nimport { compile } from 'json-schema-to-typescript'\nimport { describe, it, expect } from 'vitest'\n\nimport type { Config } from '../config/types.js'\n\nimport { sanitizeConfig } from '../config/sanitize.js'\nimport { configToJSONSchema } from './configToJSONSchema.js'\nimport type { Block, BlocksField, RichTextField } from '../fields/config/types.js'\n\ndescribe('configToJSONSchema', () => {\n it('should generate never for empty supported timezones', async () => {\n const config = await sanitizeConfig({\n admin: {\n timezones: {\n defaultTimezone: 'Europe/London',\n supportedTimezones: [],\n },\n },\n collections: [],\n } as Config)\n const schema = configToJSONSchema(config, 'text')\n const types = await compile(schema, 'Config', { unreachableDefinitions: true })\n\n expect(types).toContain('export type SupportedTimezones = never;')\n })\n\n it('should handle optional arrays with required fields', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'someRequiredField',\n type: 'array',\n fields: [\n {\n name: 'someRequiredField',\n type: 'text',\n required: true,\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n someRequiredField: {\n type: ['array', 'null'],\n items: {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n someRequiredField: {\n type: 'string',\n },\n },\n required: ['someRequiredField'],\n },\n },\n },\n required: ['id'],\n title: 'Test',\n })\n })\n\n it('should handle block fields with no blocks', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'blockField',\n type: 'blocks',\n blocks: [],\n },\n {\n name: 'blockFieldRequired',\n type: 'blocks',\n blocks: [],\n required: true,\n },\n {\n name: 'blockFieldWithFields',\n type: 'blocks',\n blocks: [\n {\n slug: 'test',\n fields: [\n {\n name: 'field',\n type: 'text',\n },\n ],\n },\n ],\n },\n {\n name: 'blockFieldWithFieldsRequired',\n type: 'blocks',\n blocks: [\n {\n slug: 'test',\n fields: [\n {\n name: 'field',\n type: 'text',\n required: true,\n },\n ],\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n blockField: {\n type: ['array', 'null'],\n items: {},\n },\n blockFieldRequired: {\n type: 'array',\n items: {},\n },\n blockFieldWithFields: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n blockName: {\n type: ['string', 'null'],\n },\n blockType: {\n const: 'test',\n },\n field: {\n type: ['string', 'null'],\n },\n },\n required: ['blockType'],\n },\n ],\n },\n },\n blockFieldWithFieldsRequired: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: ['string', 'null'],\n },\n blockName: {\n type: ['string', 'null'],\n },\n blockType: {\n const: 'test',\n },\n field: {\n type: 'string',\n },\n },\n required: ['blockType', 'field'],\n },\n ],\n },\n },\n },\n required: ['id', 'blockFieldRequired'],\n title: 'Test',\n })\n })\n\n it('should handle tabs and named tabs with required fields', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n type: 'tabs',\n tabs: [\n {\n fields: [\n {\n name: 'fieldInUnnamedTab',\n type: 'text',\n },\n ],\n label: 'unnamedTab',\n },\n {\n name: 'namedTab',\n fields: [\n {\n name: 'fieldInNamedTab',\n type: 'text',\n },\n ],\n label: 'namedTab',\n },\n {\n name: 'namedTabWithRequired',\n fields: [\n {\n name: 'fieldInNamedTab',\n type: 'text',\n required: true,\n },\n ],\n label: 'namedTabWithRequired',\n },\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n fieldInUnnamedTab: {\n type: ['string', 'null'],\n },\n namedTab: {\n type: 'object',\n additionalProperties: false,\n properties: {\n fieldInNamedTab: {\n type: ['string', 'null'],\n },\n },\n required: [],\n },\n namedTabWithRequired: {\n type: 'object',\n additionalProperties: false,\n properties: {\n fieldInNamedTab: {\n type: 'string',\n },\n },\n required: ['fieldInNamedTab'],\n },\n },\n required: ['id', 'namedTabWithRequired'],\n title: 'Test',\n })\n })\n\n it('should handle custom typescript schema and JSON field schema', async () => {\n const customSchema: JSONSchema4 = {\n type: 'object',\n properties: {\n id: {\n type: 'number',\n },\n required: ['id'],\n },\n }\n\n const config: Partial<Config> = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'withCustom',\n type: 'text',\n typescriptSchema: [() => customSchema],\n },\n {\n name: 'jsonWithSchema',\n type: 'json',\n jsonSchema: {\n fileMatch: ['a://b/foo.json'],\n schema: customSchema,\n uri: 'a://b/foo.json',\n },\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config as Config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n properties: {\n id: {\n type: 'string',\n },\n jsonWithSchema: customSchema,\n withCustom: customSchema,\n },\n required: ['id'],\n title: 'Test',\n })\n })\n\n it('should handle same block object being referenced in both collection and config.blocks', async () => {\n const sharedBlock: Block = {\n slug: 'sharedBlock',\n interfaceName: 'SharedBlock',\n fields: [\n {\n name: 'richText',\n type: 'richText',\n editor: () => {\n // stub rich text editor\n return {\n CellComponent: '',\n FieldComponent: '',\n validate: () => true,\n }\n },\n },\n ],\n }\n\n // @ts-expect-error\n const config: Config = {\n blocks: [sharedBlock],\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'someBlockField',\n type: 'blocks',\n blocks: [sharedBlock],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n // Ensure both rich text editor are sanitized\n const sanitizedConfig = await sanitizeConfig(config)\n expect(typeof (sanitizedConfig?.blocks?.[0]?.fields?.[0] as RichTextField)?.editor).toBe(\n 'object',\n )\n expect(\n typeof (\n (sanitizedConfig.collections[0].fields[0] as BlocksField)?.blocks?.[0]\n ?.fields?.[0] as RichTextField\n )?.editor,\n ).toBe('object')\n\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n const expectedBlockSchema = {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: { type: ['string', 'null'] },\n blockName: { type: ['string', 'null'] },\n blockType: { const: 'sharedBlock' },\n richText: { type: ['array', 'null'], items: { type: 'object' } },\n },\n required: ['blockType'],\n }\n\n expect(schema?.definitions?.test).toStrictEqual({\n type: 'object',\n additionalProperties: false,\n title: 'Test',\n properties: {\n id: {\n type: 'string',\n },\n someBlockField: {\n type: ['array', 'null'],\n items: {\n oneOf: [\n {\n $ref: '#/definitions/SharedBlock',\n },\n ],\n },\n },\n },\n required: ['id'],\n })\n\n // The definition should still be registered for TypeScript type generation\n expect(schema?.definitions?.SharedBlock).toStrictEqual(expectedBlockSchema)\n })\n\n it('should allow overriding required to false', async () => {\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'title',\n type: 'text',\n required: true,\n defaultValue: 'test',\n typescriptSchema: [\n () => ({\n type: 'string',\n required: false,\n }),\n ],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n const schema = configToJSONSchema(sanitizedConfig, 'text')\n\n // @ts-expect-error\n expect(schema.definitions.test.properties.title.required).toStrictEqual(false)\n })\n\n it('should propagate forceInlineBlocks to nested fields (array, group, tab)', async () => {\n const namedBlock: Block = {\n slug: 'myBlock',\n interfaceName: 'MyBlock',\n fields: [{ name: 'text', type: 'text' }],\n }\n\n // @ts-expect-error\n const config: Config = {\n collections: [\n {\n slug: 'test',\n fields: [\n {\n name: 'arr',\n type: 'array',\n fields: [{ name: 'blocks', type: 'blocks', blocks: [namedBlock] }],\n },\n {\n name: 'grp',\n type: 'group',\n fields: [{ name: 'blocks', type: 'blocks', blocks: [namedBlock] }],\n },\n ],\n timestamps: false,\n },\n ],\n }\n\n const sanitizedConfig = await sanitizeConfig(config)\n\n // Without forceInlineBlocks: blocks field uses $ref\n const schemaDefault = configToJSONSchema(sanitizedConfig, 'text')\n const arrItemsDefault = schemaDefault.definitions!.test.properties!.arr.items as JSONSchema4\n const arrBlocksDefault = (arrItemsDefault.properties!.blocks.items as JSONSchema4).oneOf![0]\n expect(arrBlocksDefault).toStrictEqual({ $ref: '#/definitions/MyBlock' })\n\n // With forceInlineBlocks: blocks field is inlined, no $ref\n const schemaInline = configToJSONSchema(sanitizedConfig, 'text', undefined, {\n forceInlineBlocks: true,\n })\n const arrItemsInline = schemaInline.definitions!.test.properties!.arr.items as JSONSchema4\n const arrBlocksInline = (arrItemsInline.properties!.blocks.items as JSONSchema4).oneOf![0]\n expect(arrBlocksInline).not.toHaveProperty('$ref')\n expect(arrBlocksInline.properties?.blockType).toStrictEqual({ const: 'myBlock' })\n\n const grpBlocksInline = (\n schemaInline.definitions!.test.properties!.grp.properties!.blocks.items as JSONSchema4\n ).oneOf![0]\n expect(grpBlocksInline).not.toHaveProperty('$ref')\n expect(grpBlocksInline.properties?.blockType).toStrictEqual({ const: 'myBlock' })\n })\n})\n"],"names":["compile","describe","it","expect","sanitizeConfig","configToJSONSchema","config","admin","timezones","defaultTimezone","supportedTimezones","collections","schema","types","unreachableDefinitions","toContain","slug","fields","name","type","required","timestamps","sanitizedConfig","definitions","test","toStrictEqual","additionalProperties","properties","id","someRequiredField","items","title","blocks","blockField","blockFieldRequired","blockFieldWithFields","oneOf","blockName","blockType","const","field","blockFieldWithFieldsRequired","tabs","label","fieldInUnnamedTab","namedTab","fieldInNamedTab","namedTabWithRequired","customSchema","typescriptSchema","jsonSchema","fileMatch","uri","jsonWithSchema","withCustom","sharedBlock","interfaceName","editor","CellComponent","FieldComponent","validate","toBe","expectedBlockSchema","richText","someBlockField","$ref","SharedBlock","defaultValue","namedBlock","schemaDefault","arrItemsDefault","arr","arrBlocksDefault","schemaInline","undefined","forceInlineBlocks","arrItemsInline","arrBlocksInline","not","toHaveProperty","grpBlocksInline","grp"],"mappings":"AACA,SAASA,OAAO,QAAQ,4BAA2B;AACnD,SAASC,QAAQ,EAAEC,EAAE,EAAEC,MAAM,QAAQ,SAAQ;AAI7C,SAASC,cAAc,QAAQ,wBAAuB;AACtD,SAASC,kBAAkB,QAAQ,0BAAyB;AAG5DJ,SAAS,sBAAsB;IAC7BC,GAAG,uDAAuD;QACxD,MAAMI,SAAS,MAAMF,eAAe;YAClCG,OAAO;gBACLC,WAAW;oBACTC,iBAAiB;oBACjBC,oBAAoB,EAAE;gBACxB;YACF;YACAC,aAAa,EAAE;QACjB;QACA,MAAMC,SAASP,mBAAmBC,QAAQ;QAC1C,MAAMO,QAAQ,MAAMb,QAAQY,QAAQ,UAAU;YAAEE,wBAAwB;QAAK;QAE7EX,OAAOU,OAAOE,SAAS,CAAC;IAC1B;IAEAb,GAAG,sDAAsD;QACvD,mBAAmB;QACnB,MAAMI,SAAiB;YACrBK,aAAa;gBACX;oBACEK,MAAM;oBACNC,QAAQ;wBACN;4BACEC,MAAM;4BACNC,MAAM;4BACNF,QAAQ;gCACN;oCACEC,MAAM;oCACNC,MAAM;oCACNC,UAAU;gCACZ;6BACD;wBACH;qBACD;oBACDC,YAAY;gBACd;aACD;QACH;QAEA,MAAMC,kBAAkB,MAAMlB,eAAeE;QAC7C,MAAMM,SAASP,mBAAmBiB,i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AACtBP,aAAalD,WAAW,CAAEC,IAAI,CAACG,UAAU,CAAEsD,GAAG,CAACtD,UAAU,CAAEK,MAAM,CAACF,KAAK,CACvEM,KAAK,AAAC,CAAC,EAAE;QACXjC,OAAO6E,iBAAiBF,GAAG,CAACC,cAAc,CAAC;QAC3C5E,OAAO6E,gBAAgBrD,UAAU,EAAEW,WAAWb,aAAa,CAAC;YAAEc,OAAO;QAAU;IACjF;AACF"}
@@ -1,11 +1,62 @@
1
- import deepMerge from 'deepmerge';
2
- export { deepMerge };
1
+ export type DeepMergeArrayMergeOptions = {
2
+ cloneUnlessOtherwiseSpecified(value: object, options?: DeepMergeOptions): any;
3
+ isMergeableObject(value: object): boolean;
4
+ };
5
+ export type DeepMergeOptions = {
6
+ /**
7
+ * Merges two arrays. Defaults to concatenating `target` and `source`.
8
+ */
9
+ arrayMerge?: (target: any[], source: any[], options: ResolvedDeepMergeOptions) => any[];
10
+ /**
11
+ * When `false`, mergeable values are copied by reference instead of being deeply cloned.
12
+ * @default true
13
+ */
14
+ clone?: boolean;
15
+ /**
16
+ * Returns a custom merge function for a given key, or `undefined` to use the default merge.
17
+ */
18
+ customMerge?: (key: string, options?: DeepMergeOptions) => ((x: any, y: any) => any) | undefined;
19
+ /**
20
+ * Determines whether a value should be merged recursively or copied as-is.
21
+ */
22
+ isMergeableObject?(value: object): boolean;
23
+ };
24
+ type ResolvedDeepMergeOptions = {
25
+ arrayMerge: NonNullable<DeepMergeOptions['arrayMerge']>;
26
+ isMergeableObject: (value: unknown) => boolean;
27
+ } & DeepMergeArrayMergeOptions & DeepMergeOptions;
28
+ /**
29
+ * Fully-featured deepMerge. Returns a new object and does not mutate its arguments.
30
+ *
31
+ * Array handling: arrays are concatenated unless `arrayMerge` is provided.
32
+ *
33
+ * `__proto__` keys are never copied to the result, preventing prototype poisoning of the returned
34
+ * object when merging untrusted input (e.g. parsed JSON).
35
+ */
36
+ export declare function deepMerge<T>(x: Partial<T>, y: Partial<T>, options?: DeepMergeOptions): T;
37
+ export declare function deepMerge<T1, T2>(x: Partial<T1>, y: Partial<T2>, options?: DeepMergeOptions): T1 & T2;
38
+ export declare namespace deepMerge {
39
+ var all: typeof deepMergeAll;
40
+ }
41
+ /**
42
+ * Keeps the `deepMerge.Options` / `deepMerge.ArrayMergeOptions` type references from the former
43
+ * `deepmerge` dependency working.
44
+ */
45
+ export declare namespace deepMerge {
46
+ type ArrayMergeOptions = DeepMergeArrayMergeOptions;
47
+ type Options = DeepMergeOptions;
48
+ }
49
+ /**
50
+ * Deep-merges all objects in the array, from left to right.
51
+ */
52
+ declare function deepMergeAll<T = object>(objects: Partial<T>[], options?: DeepMergeOptions): T;
53
+ declare function deepMergeAll(objects: object[], options?: DeepMergeOptions): object;
3
54
  /**
4
55
  * Fully-featured deepMerge.
5
56
  *
6
57
  * Array handling: Arrays in the target object are combined with the source object's arrays.
7
58
  */
8
- export declare function deepMergeWithCombinedArrays<T extends object>(obj1: object, obj2: object, options?: deepMerge.Options): T;
59
+ export declare function deepMergeWithCombinedArrays<T extends object>(obj1: object, obj2: object, options?: DeepMergeOptions): T;
9
60
  /**
10
61
  * Fully-featured deepMerge.
11
62
  *
@@ -16,4 +67,5 @@ export declare function deepMergeWithSourceArrays<T extends object>(obj1: object
16
67
  * Fully-featured deepMerge. Does not clone React components by default.
17
68
  */
18
69
  export declare function deepMergeWithReactComponents<T extends object>(obj1: object, obj2: object): T;
70
+ export {};
19
71
  //# sourceMappingURL=deepMerge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deepMerge.d.ts","sourceRoot":"","sources":["../../src/utilities/deepMerge.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAA;AAIjC,OAAO,EAAE,SAAS,EAAE,CAAA;AACpB;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,CAAC,SAAS,MAAM,EAC1D,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,SAAS,CAAC,OAAY,GA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