payload 3.0.0-beta.72 → 3.0.0-beta.74

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 (128) hide show
  1. package/dist/admin/RichText.d.ts +2 -1
  2. package/dist/admin/RichText.d.ts.map +1 -1
  3. package/dist/admin/RichText.js.map +1 -1
  4. package/dist/admin/elements/Cell.d.ts +1 -0
  5. package/dist/admin/elements/Cell.d.ts.map +1 -1
  6. package/dist/admin/elements/Cell.js.map +1 -1
  7. package/dist/admin/fields/Array.d.ts +3 -1
  8. package/dist/admin/fields/Array.d.ts.map +1 -1
  9. package/dist/admin/fields/Array.js.map +1 -1
  10. package/dist/admin/fields/Blocks.d.ts +3 -1
  11. package/dist/admin/fields/Blocks.d.ts.map +1 -1
  12. package/dist/admin/fields/Blocks.js.map +1 -1
  13. package/dist/admin/fields/Checkbox.d.ts +3 -1
  14. package/dist/admin/fields/Checkbox.d.ts.map +1 -1
  15. package/dist/admin/fields/Checkbox.js.map +1 -1
  16. package/dist/admin/fields/Code.d.ts +3 -1
  17. package/dist/admin/fields/Code.d.ts.map +1 -1
  18. package/dist/admin/fields/Code.js.map +1 -1
  19. package/dist/admin/fields/Date.d.ts +3 -1
  20. package/dist/admin/fields/Date.d.ts.map +1 -1
  21. package/dist/admin/fields/Date.js.map +1 -1
  22. package/dist/admin/fields/Email.d.ts +3 -1
  23. package/dist/admin/fields/Email.d.ts.map +1 -1
  24. package/dist/admin/fields/Email.js.map +1 -1
  25. package/dist/admin/fields/JSON.d.ts +3 -1
  26. package/dist/admin/fields/JSON.d.ts.map +1 -1
  27. package/dist/admin/fields/JSON.js.map +1 -1
  28. package/dist/admin/fields/Number.d.ts +3 -1
  29. package/dist/admin/fields/Number.d.ts.map +1 -1
  30. package/dist/admin/fields/Number.js.map +1 -1
  31. package/dist/admin/fields/Point.d.ts +3 -1
  32. package/dist/admin/fields/Point.d.ts.map +1 -1
  33. package/dist/admin/fields/Point.js.map +1 -1
  34. package/dist/admin/fields/Radio.d.ts +3 -1
  35. package/dist/admin/fields/Radio.d.ts.map +1 -1
  36. package/dist/admin/fields/Radio.js.map +1 -1
  37. package/dist/admin/fields/Relationship.d.ts +3 -1
  38. package/dist/admin/fields/Relationship.d.ts.map +1 -1
  39. package/dist/admin/fields/Relationship.js.map +1 -1
  40. package/dist/admin/fields/RichText.d.ts +3 -1
  41. package/dist/admin/fields/RichText.d.ts.map +1 -1
  42. package/dist/admin/fields/RichText.js.map +1 -1
  43. package/dist/admin/fields/Select.d.ts +3 -1
  44. package/dist/admin/fields/Select.d.ts.map +1 -1
  45. package/dist/admin/fields/Select.js.map +1 -1
  46. package/dist/admin/fields/Text.d.ts +3 -1
  47. package/dist/admin/fields/Text.d.ts.map +1 -1
  48. package/dist/admin/fields/Text.js.map +1 -1
  49. package/dist/admin/fields/Textarea.d.ts +3 -1
  50. package/dist/admin/fields/Textarea.d.ts.map +1 -1
  51. package/dist/admin/fields/Textarea.js.map +1 -1
  52. package/dist/admin/fields/Upload.d.ts +3 -2
  53. package/dist/admin/fields/Upload.d.ts.map +1 -1
  54. package/dist/admin/fields/Upload.js.map +1 -1
  55. package/dist/admin/forms/FieldDescription.d.ts +1 -2
  56. package/dist/admin/forms/FieldDescription.d.ts.map +1 -1
  57. package/dist/admin/forms/FieldDescription.js.map +1 -1
  58. package/dist/admin/forms/Form.d.ts +2 -2
  59. package/dist/admin/forms/Form.d.ts.map +1 -1
  60. package/dist/admin/forms/Form.js.map +1 -1
  61. package/dist/admin/forms/Label.d.ts +5 -3
  62. package/dist/admin/forms/Label.d.ts.map +1 -1
  63. package/dist/admin/forms/Label.js.map +1 -1
  64. package/dist/auth/baseFields/email.d.ts +2 -4
  65. package/dist/auth/baseFields/email.d.ts.map +1 -1
  66. package/dist/auth/baseFields/email.js +21 -21
  67. package/dist/auth/baseFields/email.js.map +1 -1
  68. package/dist/auth/baseFields/username.d.ts +2 -2
  69. package/dist/auth/baseFields/username.d.ts.map +1 -1
  70. package/dist/auth/baseFields/username.js +1 -1
  71. package/dist/auth/baseFields/username.js.map +1 -1
  72. package/dist/auth/ensureUsernameOrEmail.d.ts +17 -0
  73. package/dist/auth/ensureUsernameOrEmail.d.ts.map +1 -0
  74. package/dist/auth/ensureUsernameOrEmail.js +43 -0
  75. package/dist/auth/ensureUsernameOrEmail.js.map +1 -0
  76. package/dist/auth/getAuthFields.d.ts.map +1 -1
  77. package/dist/auth/getAuthFields.js +18 -10
  78. package/dist/auth/getAuthFields.js.map +1 -1
  79. package/dist/auth/operations/registerFirstUser.d.ts.map +1 -1
  80. package/dist/auth/operations/registerFirstUser.js +8 -0
  81. package/dist/auth/operations/registerFirstUser.js.map +1 -1
  82. package/dist/auth/types.d.ts +6 -1
  83. package/dist/auth/types.d.ts.map +1 -1
  84. package/dist/auth/types.js.map +1 -1
  85. package/dist/collections/config/defaults.d.ts.map +1 -1
  86. package/dist/collections/config/defaults.js +2 -1
  87. package/dist/collections/config/defaults.js.map +1 -1
  88. package/dist/collections/config/sanitize.d.ts.map +1 -1
  89. package/dist/collections/config/sanitize.js +17 -4
  90. package/dist/collections/config/sanitize.js.map +1 -1
  91. package/dist/collections/operations/create.d.ts.map +1 -1
  92. package/dist/collections/operations/create.js +8 -0
  93. package/dist/collections/operations/create.js.map +1 -1
  94. package/dist/collections/operations/update.d.ts.map +1 -1
  95. package/dist/collections/operations/update.js +11 -0
  96. package/dist/collections/operations/update.js.map +1 -1
  97. package/dist/collections/operations/updateByID.d.ts.map +1 -1
  98. package/dist/collections/operations/updateByID.js +11 -0
  99. package/dist/collections/operations/updateByID.js.map +1 -1
  100. package/dist/errors/ValidationError.d.ts +6 -8
  101. package/dist/errors/ValidationError.d.ts.map +1 -1
  102. package/dist/errors/ValidationError.js.map +1 -1
  103. package/dist/errors/index.d.ts +1 -0
  104. package/dist/errors/index.d.ts.map +1 -1
  105. package/dist/errors/index.js.map +1 -1
  106. package/dist/fields/config/client.d.ts +16 -15
  107. package/dist/fields/config/client.d.ts.map +1 -1
  108. package/dist/fields/config/types.d.ts +3 -1
  109. package/dist/fields/config/types.d.ts.map +1 -1
  110. package/dist/fields/config/types.js.map +1 -1
  111. package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
  112. package/dist/fields/hooks/beforeChange/promise.js +1 -0
  113. package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
  114. package/dist/fields/validations.d.ts +65 -74
  115. package/dist/fields/validations.d.ts.map +1 -1
  116. package/dist/fields/validations.js +20 -4
  117. package/dist/fields/validations.js.map +1 -1
  118. package/dist/index.d.ts +3 -2
  119. package/dist/index.d.ts.map +1 -1
  120. package/dist/index.js +1 -1
  121. package/dist/index.js.map +1 -1
  122. package/dist/uploads/types.d.ts +6 -0
  123. package/dist/uploads/types.d.ts.map +1 -1
  124. package/dist/uploads/types.js.map +1 -1
  125. package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
  126. package/dist/utilities/configToJSONSchema.js +88 -57
  127. package/dist/utilities/configToJSONSchema.js.map +1 -1
  128. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/config/types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { EditorProps } from '@monaco-editor/react'\nimport type { CSSProperties } from 'react'\n\n//eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport monacoeditor from 'monaco-editor' // IMPORTANT - DO NOT REMOVE: This is required for pnpm's default isolated mode to work - even though the import is not used. This is due to a typescript bug: https://github.com/microsoft/TypeScript/issues/47663#issuecomment-1519138189. (tsbugisolatedmode)\nimport type { JSONSchema4 } from 'json-schema'\nimport type React from 'react'\n\nimport type { RichTextAdapter, RichTextAdapterProvider } from '../../admin/RichText.js'\nimport type { ErrorComponent } from '../../admin/forms/Error.js'\nimport type {\n ConditionalDateProps,\n Description,\n DescriptionComponent,\n LabelComponent,\n RowLabelComponent,\n} from '../../admin/types.js'\nimport type { SanitizedCollectionConfig, TypeWithID } from '../../collections/config/types.js'\nimport type { CustomComponent, LabelFunction, LabelStatic } from '../../config/types.js'\nimport type { DBIdentifierName } from '../../database/types.js'\nimport type { SanitizedGlobalConfig } from '../../globals/config/types.js'\nimport type { CollectionSlug } from '../../index.js'\nimport type { DocumentPreferences } from '../../preferences/types.js'\nimport type { Operation, PayloadRequest, RequestContext, Where } from '../../types/index.js'\nimport type { ClientFieldConfig } from './client.js'\n\nexport type FieldHookArgs<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = {\n /** The collection which the field belongs to. If the field belongs to a global, this will be null. */\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n /** The data passed to update the document within create and update operations, and the full document itself in the afterRead hook. */\n data?: Partial<TData>\n /** The field which the hook is running against. */\n field: FieldAffectingData\n /** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */\n findMany?: boolean\n /** The global which the field belongs to. If the field belongs to a collection, this will be null. */\n global: SanitizedGlobalConfig | null\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation?: 'create' | 'delete' | 'read' | 'update'\n /** The full original document in `update` operations. In the `afterChange` hook, this is the resulting document of the operation. */\n originalDoc?: TData\n overrideAccess?: boolean\n /**\n * The path of the field, e.g. [\"group\", \"myArray\", 1, \"textField\"]. The path is the schemaPath but with indexes and would be used in the context of field data, not field schemas.\n */\n path: (number | string)[]\n /** The document before changes were applied, only in `afterChange` hooks. */\n previousDoc?: TData\n /** The sibling data of the document before changes being applied, only in `beforeChange`, `beforeValidate`, `beforeDuplicate` and `afterChange` field hooks. */\n previousSiblingDoc?: TData\n /** The previous value of the field, before changes, only in `beforeChange`, `afterChange`, `beforeDuplicate` and `beforeValidate` field hooks. */\n previousValue?: TValue\n /** The Express request object. It is mocked for Local API operations. */\n req: PayloadRequest\n /**\n * The schemaPath of the field, e.g. [\"group\", \"myArray\", \"textField\"]. The schemaPath is the path but without indexes and would be used in the context of field schemas, not field data.\n */\n schemaPath: string[]\n /** The sibling data passed to a field that the hook is running against. */\n siblingData: Partial<TSiblingData>\n /**\n * The original siblingData with locales (not modified by any hooks). Only available in `beforeChange` and `beforeDuplicate` field hooks.\n */\n siblingDocWithLocales?: Record<string, unknown>\n /** The value of the field. */\n value?: TValue\n}\n\nexport type FieldHook<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = (\n args: FieldHookArgs<TData, TValue, TSiblingData>,\n) => Promise<TValue> | TValue\n\nexport type FieldAccess<TData extends TypeWithID = any, TSiblingData = any> = (args: {\n /**\n * The incoming data used to `create` or `update` the document with. `data` is undefined during the `read` operation.\n */\n data?: Partial<TData>\n /**\n * The original data of the document before the `update` is applied. `doc` is undefined during the `create` operation.\n */\n doc?: TData\n /**\n * The `id` of the current document being read or updated. `id` is undefined during the `create` operation.\n */\n id?: number | string\n /** The `payload` object to interface with the payload API */\n req: PayloadRequest\n /**\n * Immediately adjacent data to this field. For example, if this is a `group` field, then `siblingData` will be the other fields within the group.\n */\n siblingData?: Partial<TSiblingData>\n}) => Promise<boolean> | boolean\n\nexport type Condition<TData extends TypeWithID = any, TSiblingData = any> = (\n data: Partial<TData>,\n siblingData: Partial<TSiblingData>,\n { user }: { user: PayloadRequest['user'] },\n) => boolean\n\nexport type FilterOptionsProps<TData = any> = {\n /**\n * An object containing the full collection or global document currently being edited.\n */\n data: TData\n /**\n * The `id` of the current document being edited. `id` is undefined during the `create` operation.\n */\n id: number | string\n /**\n * The collection `slug` to filter against, limited to this field's `relationTo` property.\n */\n relationTo: CollectionSlug\n /**\n * An object containing document data that is scoped to only fields within the same parent of this field.\n */\n siblingData: unknown\n /**\n * An object containing the currently authenticated user.\n */\n user: Partial<PayloadRequest['user']>\n}\n\nexport type FilterOptionsFunc<TData = any> = (\n options: FilterOptionsProps<TData>,\n) => Promise<Where | boolean> | Where | boolean\n\nexport type FilterOptions<TData = any> =\n | ((options: FilterOptionsProps<TData>) => Promise<Where | boolean> | Where | boolean)\n | Where\n | null\n\ntype Admin = {\n className?: string\n components?: {\n Cell?: CustomComponent\n Description?: DescriptionComponent\n Field?: CustomComponent\n /**\n * The Filter component has to be a client component\n */\n Filter?: React.ComponentType<any>\n }\n /**\n * You can programmatically show / hide fields based on what other fields are doing.\n * This is also run on the server, to determine if the field should be validated.\n */\n condition?: Condition\n /** Extension point to add your custom data. Available in server and client. */\n custom?: Record<string, any>\n description?: Description\n disableBulkEdit?: boolean\n /**\n * Shows / hides fields from appearing in the list view column selector.\n * @type boolean\n */\n disableListColumn?: boolean\n /**\n * Shows / hides fields from appearing in the list view filter options.\n * @type boolean\n */\n disableListFilter?: boolean\n disabled?: boolean\n hidden?: boolean\n position?: 'sidebar'\n readOnly?: boolean\n style?: CSSProperties\n width?: string\n}\n\nexport type Labels = {\n plural: LabelFunction | LabelStatic\n singular: LabelFunction | LabelStatic\n}\n\nexport type BaseValidateOptions<TData, TSiblingData, TValue> = {\n data: Partial<TData>\n id?: number | string\n operation?: Operation\n preferences: DocumentPreferences\n previousValue?: TValue\n req: PayloadRequest\n siblingData: Partial<TSiblingData>\n}\n\nexport type ValidateOptions<\n TData,\n TSiblingData,\n TFieldConfig extends object,\n TValue,\n> = BaseValidateOptions<TData, TSiblingData, TValue> & TFieldConfig\n\nexport type Validate<\n TValue = any,\n TData = any,\n TSiblingData = any,\n TFieldConfig extends object = object,\n> = (\n value: TValue,\n options: ValidateOptions<TData, TSiblingData, TFieldConfig, TValue>,\n) => Promise<string | true> | string | true\n\nexport type ClientValidate = Omit<Validate, 'req'>\n\nexport type OptionObject = {\n label: LabelFunction | LabelStatic\n value: string\n}\n\nexport type Option = OptionObject | string\n\nexport interface FieldBase {\n access?: {\n create?: FieldAccess\n read?: FieldAccess\n update?: FieldAccess\n }\n admin?: Admin\n /** Extension point to add your custom data. Server only. */\n custom?: Record<string, any>\n defaultValue?: any\n hidden?: boolean\n hooks?: {\n afterChange?: FieldHook[]\n afterRead?: FieldHook[]\n beforeChange?: FieldHook[]\n /**\n * Runs before a document is duplicated to prevent errors in unique fields or return null to use defaultValue.\n */\n beforeDuplicate?: FieldHook[]\n beforeValidate?: FieldHook[]\n }\n index?: boolean\n label?: LabelFunction | LabelStatic | false\n localized?: boolean\n /**\n * The name of the field. Must be alphanumeric and cannot contain ' . '\n *\n * Must not be one of reserved field names: ['__v', 'salt', 'hash', 'file']\n * @link https://payloadcms.com/docs/fields/overview#field-names\n */\n name: string\n required?: boolean\n saveToJWT?: boolean | string\n /**\n * Allows you to modify the base JSON schema that is generated during generate:types for this field.\n * This JSON schema will be used to generate the TypeScript interface of this field.\n */\n typescriptSchema?: Array<(args: { jsonSchema: JSONSchema4 }) => JSONSchema4>\n unique?: boolean\n validate?: Validate\n}\n\nexport type NumberField = {\n admin?: {\n /** Set this property to a string that will be used for browser autocomplete. */\n autoComplete?: string\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n /** Set this property to define a placeholder string for the field. */\n placeholder?: Record<string, string> | string\n /** Set a value for the number field to increment / decrement using browser controls. */\n step?: number\n } & Admin\n /** Maximum value accepted. Used in the default `validate` function. */\n max?: number\n /** Minimum value accepted. Used in the default `validate` function. */\n min?: number\n type: 'number'\n validate?: Validate<number | number[], unknown, unknown, NumberField>\n} & (\n | {\n /** Makes this field an ordered array of numbers instead of just a single number. */\n hasMany: true\n /** Maximum number of numbers in the numbers array, if `hasMany` is set to true. */\n maxRows?: number\n /** Minimum number of numbers in the numbers array, if `hasMany` is set to true. */\n minRows?: number\n }\n | {\n /** Makes this field an ordered array of numbers instead of just a single number. */\n hasMany?: false | undefined\n /** Maximum number of numbers in the numbers array, if `hasMany` is set to true. */\n maxRows?: undefined\n /** Minimum number of numbers in the numbers array, if `hasMany` is set to true. */\n minRows?: undefined\n }\n) &\n FieldBase\n\nexport type TextField = {\n admin?: {\n autoComplete?: string\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n placeholder?: Record<string, string> | string\n rtl?: boolean\n } & Admin\n maxLength?: number\n minLength?: number\n type: 'text'\n validate?: Validate<string | string[], unknown, unknown, TextField>\n} & (\n | {\n /** Makes this field an ordered array of strings instead of just a single string. */\n hasMany: true\n /** Maximum number of strings in the strings array, if `hasMany` is set to true. */\n maxRows?: number\n /** Minimum number of strings in the strings array, if `hasMany` is set to true. */\n minRows?: number\n }\n | {\n /** Makes this field an ordered array of strings instead of just a single string. */\n hasMany?: false | undefined\n /** Maximum number of strings in the strings array, if `hasMany` is set to true. */\n maxRows?: undefined\n /** Minimum number of strings in the strings array, if `hasMany` is set to true. */\n minRows?: undefined\n }\n) &\n FieldBase\n\nexport type EmailField = {\n admin?: {\n autoComplete?: string\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n placeholder?: Record<string, string> | string\n } & Admin\n type: 'email'\n validate?: Validate<string, unknown, unknown, EmailField>\n} & FieldBase\n\nexport type TextareaField = {\n admin?: {\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n placeholder?: Record<string, string> | string\n rows?: number\n rtl?: boolean\n } & Admin\n maxLength?: number\n minLength?: number\n type: 'textarea'\n validate?: Validate<string, unknown, unknown, TextareaField>\n} & FieldBase\n\nexport type CheckboxField = {\n admin?: {\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n } & Admin\n type: 'checkbox'\n validate?: Validate<unknown, unknown, unknown, CheckboxField>\n} & FieldBase\n\nexport type DateField = {\n admin?: {\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n date?: ConditionalDateProps\n placeholder?: Record<string, string> | string\n } & Admin\n type: 'date'\n validate?: Validate<unknown, unknown, unknown, DateField>\n} & FieldBase\n\nexport type GroupField = {\n admin?: {\n hideGutter?: boolean\n } & Admin\n fields: Field[]\n /** Customize generated GraphQL and Typescript schema names.\n * By default, it is bound to the collection.\n *\n * This is useful if you would like to generate a top level type to share amongst collections/fields.\n * **Note**: Top level types can collide, ensure they are unique amongst collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n type: 'group'\n validate?: Validate<unknown, unknown, unknown, GroupField>\n} & Omit<FieldBase, 'required'>\n\nexport type RowAdmin = Omit<Admin, 'description'>\n\nexport type RowField = {\n admin?: RowAdmin\n fields: Field[]\n type: 'row'\n} & Omit<FieldBase, 'admin' | 'label' | 'name' | 'validate'>\n\nexport type CollapsibleField = {\n fields: Field[]\n type: 'collapsible'\n} & (\n | {\n admin: {\n components: {\n RowLabel: RowLabelComponent\n } & Admin['components']\n initCollapsed?: boolean\n } & Admin\n label?: Required<FieldBase['label']>\n }\n | {\n admin?: {\n initCollapsed?: boolean\n } & Admin\n label: Required<FieldBase['label']>\n }\n) &\n Omit<FieldBase, 'label' | 'name' | 'validate'>\n\nexport type TabsAdmin = Omit<Admin, 'description'>\n\ntype TabBase = {\n description?: Description\n fields: Field[]\n interfaceName?: string\n saveToJWT?: boolean | string\n} & Omit<FieldBase, 'required' | 'validate'>\n\nexport type NamedTab = {\n /** Customize generated GraphQL and Typescript schema names.\n * The slug is used by default.\n *\n * This is useful if you would like to generate a top level type to share amongst collections/fields.\n * **Note**: Top level types can collide, ensure they are unique amongst collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n} & TabBase\n\nexport type UnnamedTab = {\n interfaceName?: never\n /**\n * Can be either:\n * - A string, which will be used as the tab's label.\n * - An object, where the key is the language code and the value is the label.\n */\n label:\n | {\n [selectedLanguage: string]: string\n }\n | LabelFunction\n | string\n localized?: never\n} & Omit<TabBase, 'name'>\n\nexport type Tab = NamedTab | UnnamedTab\n\nexport type TabsField = {\n admin?: TabsAdmin\n tabs: Tab[]\n type: 'tabs'\n} & Omit<FieldBase, 'admin' | 'localized' | 'name' | 'saveToJWT'>\n\nexport type TabAsField = {\n name?: string\n type: 'tab'\n} & Tab\n\nexport type UIField = {\n admin: {\n components?: {\n Cell?: CustomComponent\n Field: CustomComponent\n /**\n * The Filter component has to be a client component\n */\n Filter?: React.ComponentType<any>\n }\n condition?: Condition\n /** Extension point to add your custom data. Available in server and client. */\n custom?: Record<string, any>\n disableBulkEdit?: boolean\n /**\n * Shows / hides fields from appearing in the list view column selector.\n * @type boolean\n */\n disableListColumn?: boolean\n position?: string\n width?: string\n }\n /** Extension point to add your custom data. Server only. */\n custom?: Record<string, any>\n label?: Record<string, string> | string\n name: string\n type: 'ui'\n}\n\nexport type UploadField = {\n admin?: {\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n }\n }\n filterOptions?: FilterOptions\n /**\n * Sets a maximum population depth for this field, regardless of the remaining depth when this field is reached.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n relationTo: CollectionSlug\n type: 'upload'\n validate?: Validate<unknown, unknown, unknown, UploadField>\n} & FieldBase\n\ntype CodeAdmin = {\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n }\n editorOptions?: EditorProps['options']\n language?: string\n} & Admin\n\nexport type CodeField = {\n admin?: CodeAdmin\n maxLength?: number\n minLength?: number\n type: 'code'\n validate?: Validate<string, unknown, unknown, CodeField>\n} & Omit<FieldBase, 'admin'>\n\ntype JSONAdmin = {\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n }\n editorOptions?: EditorProps['options']\n} & Admin\n\nexport type JSONField = {\n admin?: JSONAdmin\n jsonSchema?: {\n fileMatch: string[]\n schema: JSONSchema4\n uri: string\n }\n type: 'json'\n validate?: Validate<Record<string, unknown>, unknown, unknown, JSONField>\n} & Omit<FieldBase, 'admin'>\n\nexport type SelectField = {\n admin?: {\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n }\n isClearable?: boolean\n isSortable?: boolean\n } & Admin\n /**\n * Customize the SQL table name\n */\n dbName?: DBIdentifierName\n /**\n * Customize the DB enum name\n */\n enumName?: DBIdentifierName\n hasMany?: boolean\n options: Option[]\n type: 'select'\n validate?: Validate<string, unknown, unknown, SelectField>\n} & FieldBase\n\ntype SharedRelationshipProperties = {\n filterOptions?: FilterOptions\n hasMany?: boolean\n /**\n * Sets a maximum population depth for this field, regardless of the remaining depth when this field is reached.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n type: 'relationship'\n validate?: Validate<unknown, unknown, unknown, SharedRelationshipProperties>\n} & (\n | {\n hasMany: true\n /**\n * @deprecated Use 'maxRows' instead\n */\n max?: number\n maxRows?: number\n /**\n * @deprecated Use 'minRows' instead\n */\n min?: number\n minRows?: number\n }\n | {\n hasMany?: false | undefined\n /**\n * @deprecated Use 'maxRows' instead\n */\n max?: undefined\n maxRows?: undefined\n /**\n * @deprecated Use 'minRows' instead\n */\n min?: undefined\n minRows?: undefined\n }\n) &\n FieldBase\n\ntype RelationshipAdmin = {\n allowCreate?: boolean\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n }\n isSortable?: boolean\n} & Admin\n\nexport type PolymorphicRelationshipField = {\n admin?: {\n sortOptions?: { [collectionSlug: CollectionSlug]: string }\n } & RelationshipAdmin\n relationTo: CollectionSlug[]\n} & SharedRelationshipProperties\n\nexport type SingleRelationshipField = {\n admin?: {\n sortOptions?: string\n } & RelationshipAdmin\n relationTo: CollectionSlug\n} & SharedRelationshipProperties\nexport type RelationshipField = PolymorphicRelationshipField | SingleRelationshipField\n\nexport type ValueWithRelation = {\n relationTo: CollectionSlug\n value: number | string\n}\n\nexport function valueIsValueWithRelation(value: unknown): value is ValueWithRelation {\n return value !== null && typeof value === 'object' && 'relationTo' in value && 'value' in value\n}\n\nexport type RelationshipValue =\n | (number | string)[]\n | ValueWithRelation\n | ValueWithRelation[]\n | (number | string)\n\nexport type RichTextField<\n Value extends object = any,\n AdapterProps = any,\n ExtraProperties = object,\n> = {\n admin?: {\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n }\n } & Admin\n editor?:\n | RichTextAdapter<Value, AdapterProps, AdapterProps>\n | RichTextAdapterProvider<Value, AdapterProps, AdapterProps>\n /**\n * Sets a maximum population depth for this field, regardless of the remaining depth when this field is reached.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n type: 'richText'\n} & ExtraProperties &\n FieldBase\n\nexport type ArrayField = {\n admin?: {\n components?: {\n RowLabel?: RowLabelComponent\n } & Admin['components']\n initCollapsed?: boolean\n /**\n * Disable drag and drop sorting\n */\n isSortable?: boolean\n } & Admin\n /**\n * Customize the SQL table name\n */\n dbName?: DBIdentifierName\n fields: Field[]\n /** Customize generated GraphQL and Typescript schema names.\n * By default, it is bound to the collection.\n *\n * This is useful if you would like to generate a top level type to share amongst collections/fields.\n * **Note**: Top level types can collide, ensure they are unique amongst collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n labels?: Labels\n maxRows?: number\n minRows?: number\n type: 'array'\n validate?: Validate<unknown[], unknown, unknown, ArrayField>\n} & FieldBase\n\nexport type RadioField = {\n admin?: {\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n }\n layout?: 'horizontal' | 'vertical'\n } & Admin\n /**\n * Customize the SQL table name\n */\n dbName?: DBIdentifierName\n /**\n * Customize the DB enum name\n */\n enumName?: DBIdentifierName\n options: Option[]\n type: 'radio'\n validate?: Validate<string, unknown, unknown, RadioField>\n} & FieldBase\n\nexport type Block = {\n admin?: {\n components?: {\n Label?: React.FC<{\n blockKind: 'block' | 'lexicalBlock' | 'lexicalInlineBlock' | string\n /**\n * May contain the formData\n */\n formData: Record<string, any>\n }>\n }\n /** Extension point to add your custom data. Available in server and client. */\n custom?: Record<string, any>\n }\n /** Extension point to add your custom data. Server only. */\n custom?: Record<string, any>\n /**\n * Customize the SQL table name\n */\n dbName?: DBIdentifierName\n fields: Field[]\n /** @deprecated - please migrate to the interfaceName property instead. */\n graphQL?: {\n singularName?: string\n }\n imageAltText?: string\n imageURL?: string\n /** Customize generated GraphQL and Typescript schema names.\n * The slug is used by default.\n *\n * This is useful if you would like to generate a top level type to share amongst collections/fields.\n * **Note**: Top level types can collide, ensure they are unique amongst collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n labels?: Labels\n slug: string\n}\n\nexport type BlockField = {\n admin?: {\n initCollapsed?: boolean\n /**\n * Disable drag and drop sorting\n */\n isSortable?: boolean\n } & Admin\n blocks: Block[]\n defaultValue?: unknown\n labels?: Labels\n maxRows?: number\n minRows?: number\n type: 'blocks'\n validate?: Validate<string, unknown, unknown, BlockField>\n} & FieldBase\n\nexport type PointField = {\n type: 'point'\n validate?: Validate<unknown, unknown, unknown, PointField>\n} & FieldBase\n\nexport type Field =\n | ArrayField\n | BlockField\n | CheckboxField\n | CodeField\n | CollapsibleField\n | DateField\n | EmailField\n | GroupField\n | JSONField\n | NumberField\n | PointField\n | RadioField\n | RelationshipField\n | RichTextField\n | RowField\n | SelectField\n | TabsField\n | TextField\n | TextareaField\n | UIField\n | UploadField\n\nexport type FieldAffectingData =\n | ArrayField\n | BlockField\n | CheckboxField\n | CodeField\n | DateField\n | EmailField\n | GroupField\n | JSONField\n | NumberField\n | PointField\n | RadioField\n | RelationshipField\n | RichTextField\n | SelectField\n | TabAsField\n | TextField\n | TextareaField\n | UploadField\n\nexport type NonPresentationalField =\n | ArrayField\n | BlockField\n | CheckboxField\n | CodeField\n | CollapsibleField\n | DateField\n | EmailField\n | GroupField\n | JSONField\n | NumberField\n | PointField\n | RadioField\n | RelationshipField\n | RichTextField\n | RowField\n | SelectField\n | TabsField\n | TextField\n | TextareaField\n | UploadField\n\nexport type FieldWithPath = {\n path?: string\n} & Field\n\nexport type FieldWithSubFields = ArrayField | CollapsibleField | GroupField | RowField\n\nexport type FieldPresentationalOnly = UIField\n\nexport type FieldWithMany = RelationshipField | SelectField\n\nexport type FieldWithMaxDepth = RelationshipField | UploadField\n\nexport function fieldHasSubFields(field: ClientFieldConfig | Field): field is FieldWithSubFields {\n return (\n field.type === 'group' ||\n field.type === 'array' ||\n field.type === 'row' ||\n field.type === 'collapsible'\n )\n}\n\nexport function fieldIsArrayType(field: Field): field is ArrayField {\n return field.type === 'array'\n}\n\nexport function fieldIsBlockType(field: Field): field is BlockField {\n return field.type === 'blocks'\n}\n\nexport function fieldIsGroupType(field: Field): field is GroupField {\n return field.type === 'group'\n}\n\nexport function optionIsObject(option: Option): option is OptionObject {\n return typeof option === 'object'\n}\n\nexport function optionsAreObjects(options: Option[]): options is OptionObject[] {\n return Array.isArray(options) && typeof options?.[0] === 'object'\n}\n\nexport function optionIsValue(option: Option): option is string {\n return typeof option === 'string'\n}\n\nexport function fieldSupportsMany(field: Field): field is FieldWithMany {\n return field.type === 'select' || field.type === 'relationship'\n}\n\nexport function fieldHasMaxDepth(field: Field): field is FieldWithMaxDepth {\n return (\n (field.type === 'upload' || field.type === 'relationship') && typeof field.maxDepth === 'number'\n )\n}\n\nexport function fieldIsPresentationalOnly(\n field: ClientFieldConfig | Field | TabAsField,\n): field is UIField {\n return field.type === 'ui'\n}\n\nexport function fieldAffectsData(\n field: ClientFieldConfig | Field | TabAsField,\n): field is FieldAffectingData {\n return 'name' in field && !fieldIsPresentationalOnly(field)\n}\n\nexport function tabHasName(tab: Tab): tab is NamedTab {\n return 'name' in tab\n}\n\nexport function fieldIsLocalized(field: Field | Tab): boolean {\n return 'localized' in field && field.localized\n}\n\nexport type HookName =\n | 'afterChange'\n | 'afterRead'\n | 'beforeChange'\n | 'beforeRead'\n | 'beforeValidate'\n"],"names":["valueIsValueWithRelation","value","fieldHasSubFields","field","type","fieldIsArrayType","fieldIsBlockType","fieldIsGroupType","optionIsObject","option","optionsAreObjects","options","Array","isArray","optionIsValue","fieldSupportsMany","fieldHasMaxDepth","maxDepth","fieldIsPresentationalOnly","fieldAffectsData","tabHasName","tab","fieldIsLocalized","localized"],"mappings":"AAAA,qDAAqD,GAwpBrD,OAAO,SAASA,yBAA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MoB,SAAS;AAChD"}
1
+ {"version":3,"sources":["../../../src/fields/config/types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { EditorProps } from '@monaco-editor/react'\nimport type { CSSProperties } from 'react'\n\n//eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport monacoeditor from 'monaco-editor' // IMPORTANT - DO NOT REMOVE: This is required for pnpm's default isolated mode to work - even though the import is not used. This is due to a typescript bug: https://github.com/microsoft/TypeScript/issues/47663#issuecomment-1519138189. (tsbugisolatedmode)\nimport type { JSONSchema4 } from 'json-schema'\nimport type React from 'react'\nimport type { DeepPartial } from 'ts-essentials'\n\nimport type { RichTextAdapter, RichTextAdapterProvider } from '../../admin/RichText.js'\nimport type { ErrorComponent } from '../../admin/forms/Error.js'\nimport type {\n ConditionalDateProps,\n Description,\n DescriptionComponent,\n LabelComponent,\n RowLabelComponent,\n} from '../../admin/types.js'\nimport type { SanitizedCollectionConfig, TypeWithID } from '../../collections/config/types.js'\nimport type { CustomComponent, LabelFunction, LabelStatic } from '../../config/types.js'\nimport type { DBIdentifierName } from '../../database/types.js'\nimport type { SanitizedGlobalConfig } from '../../globals/config/types.js'\nimport type { CollectionSlug } from '../../index.js'\nimport type { DocumentPreferences } from '../../preferences/types.js'\nimport type { Operation, PayloadRequest, RequestContext, Where } from '../../types/index.js'\nimport type { ClientFieldConfig } from './client.js'\n\nexport type FieldHookArgs<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = {\n /** The collection which the field belongs to. If the field belongs to a global, this will be null. */\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n /** The data passed to update the document within create and update operations, and the full document itself in the afterRead hook. */\n data?: Partial<TData>\n /** The field which the hook is running against. */\n field: FieldAffectingData\n /** Boolean to denote if this hook is running against finding one, or finding many within the afterRead hook. */\n findMany?: boolean\n /** The global which the field belongs to. If the field belongs to a collection, this will be null. */\n global: SanitizedGlobalConfig | null\n /** A string relating to which operation the field type is currently executing within. Useful within beforeValidate, beforeChange, and afterChange hooks to differentiate between create and update operations. */\n operation?: 'create' | 'delete' | 'read' | 'update'\n /** The full original document in `update` operations. In the `afterChange` hook, this is the resulting document of the operation. */\n originalDoc?: TData\n overrideAccess?: boolean\n /**\n * The path of the field, e.g. [\"group\", \"myArray\", 1, \"textField\"]. The path is the schemaPath but with indexes and would be used in the context of field data, not field schemas.\n */\n path: (number | string)[]\n /** The document before changes were applied, only in `afterChange` hooks. */\n previousDoc?: TData\n /** The sibling data of the document before changes being applied, only in `beforeChange`, `beforeValidate`, `beforeDuplicate` and `afterChange` field hooks. */\n previousSiblingDoc?: TData\n /** The previous value of the field, before changes, only in `beforeChange`, `afterChange`, `beforeDuplicate` and `beforeValidate` field hooks. */\n previousValue?: TValue\n /** The Express request object. It is mocked for Local API operations. */\n req: PayloadRequest\n /**\n * The schemaPath of the field, e.g. [\"group\", \"myArray\", \"textField\"]. The schemaPath is the path but without indexes and would be used in the context of field schemas, not field data.\n */\n schemaPath: string[]\n /** The sibling data passed to a field that the hook is running against. */\n siblingData: Partial<TSiblingData>\n /**\n * The original siblingData with locales (not modified by any hooks). Only available in `beforeChange` and `beforeDuplicate` field hooks.\n */\n siblingDocWithLocales?: Record<string, unknown>\n /** The value of the field. */\n value?: TValue\n}\n\nexport type FieldHook<TData extends TypeWithID = any, TValue = any, TSiblingData = any> = (\n args: FieldHookArgs<TData, TValue, TSiblingData>,\n) => Promise<TValue> | TValue\n\nexport type FieldAccess<TData extends TypeWithID = any, TSiblingData = any> = (args: {\n /**\n * The incoming data used to `create` or `update` the document with. `data` is undefined during the `read` operation.\n */\n data?: Partial<TData>\n /**\n * The original data of the document before the `update` is applied. `doc` is undefined during the `create` operation.\n */\n doc?: TData\n /**\n * The `id` of the current document being read or updated. `id` is undefined during the `create` operation.\n */\n id?: number | string\n /** The `payload` object to interface with the payload API */\n req: PayloadRequest\n /**\n * Immediately adjacent data to this field. For example, if this is a `group` field, then `siblingData` will be the other fields within the group.\n */\n siblingData?: Partial<TSiblingData>\n}) => Promise<boolean> | boolean\n\nexport type Condition<TData extends TypeWithID = any, TSiblingData = any> = (\n data: Partial<TData>,\n siblingData: Partial<TSiblingData>,\n { user }: { user: PayloadRequest['user'] },\n) => boolean\n\nexport type FilterOptionsProps<TData = any> = {\n /**\n * An object containing the full collection or global document currently being edited.\n */\n data: TData\n /**\n * The `id` of the current document being edited. `id` is undefined during the `create` operation.\n */\n id: number | string\n /**\n * The collection `slug` to filter against, limited to this field's `relationTo` property.\n */\n relationTo: CollectionSlug\n /**\n * An object containing document data that is scoped to only fields within the same parent of this field.\n */\n siblingData: unknown\n /**\n * An object containing the currently authenticated user.\n */\n user: Partial<PayloadRequest['user']>\n}\n\nexport type FilterOptionsFunc<TData = any> = (\n options: FilterOptionsProps<TData>,\n) => Promise<Where | boolean> | Where | boolean\n\nexport type FilterOptions<TData = any> =\n | ((options: FilterOptionsProps<TData>) => Promise<Where | boolean> | Where | boolean)\n | Where\n | null\n\ntype Admin = {\n className?: string\n components?: {\n Cell?: CustomComponent\n Description?: DescriptionComponent\n Field?: CustomComponent\n /**\n * The Filter component has to be a client component\n */\n Filter?: React.ComponentType<any>\n }\n /**\n * You can programmatically show / hide fields based on what other fields are doing.\n * This is also run on the server, to determine if the field should be validated.\n */\n condition?: Condition\n /** Extension point to add your custom data. Available in server and client. */\n custom?: Record<string, any>\n description?: Description\n disableBulkEdit?: boolean\n /**\n * Shows / hides fields from appearing in the list view column selector.\n * @type boolean\n */\n disableListColumn?: boolean\n /**\n * Shows / hides fields from appearing in the list view filter options.\n * @type boolean\n */\n disableListFilter?: boolean\n disabled?: boolean\n hidden?: boolean\n position?: 'sidebar'\n readOnly?: boolean\n style?: CSSProperties\n width?: string\n}\n\nexport type Labels = {\n plural: LabelFunction | LabelStatic\n singular: LabelFunction | LabelStatic\n}\n\nexport type BaseValidateOptions<TData, TSiblingData, TValue> = {\n collectionSlug?: string\n data: Partial<TData>\n id?: number | string\n operation?: Operation\n preferences: DocumentPreferences\n previousValue?: TValue\n req: PayloadRequest\n required?: boolean\n siblingData: Partial<TSiblingData>\n}\n\nexport type ValidateOptions<\n TData,\n TSiblingData,\n TFieldConfig extends object,\n TValue,\n> = BaseValidateOptions<TData, TSiblingData, TValue> & TFieldConfig\n\nexport type Validate<\n TValue = any,\n TData = any,\n TSiblingData = any,\n TFieldConfig extends object = object,\n> = (\n value: TValue,\n options: ValidateOptions<TData, TSiblingData, TFieldConfig, TValue>,\n) => Promise<string | true> | string | true\n\nexport type OptionObject = {\n label: LabelFunction | LabelStatic\n value: string\n}\n\nexport type Option = OptionObject | string\n\nexport interface FieldBase {\n access?: {\n create?: FieldAccess\n read?: FieldAccess\n update?: FieldAccess\n }\n admin?: Admin\n /** Extension point to add your custom data. Server only. */\n custom?: Record<string, any>\n defaultValue?: any\n hidden?: boolean\n hooks?: {\n afterChange?: FieldHook[]\n afterRead?: FieldHook[]\n beforeChange?: FieldHook[]\n /**\n * Runs before a document is duplicated to prevent errors in unique fields or return null to use defaultValue.\n */\n beforeDuplicate?: FieldHook[]\n beforeValidate?: FieldHook[]\n }\n index?: boolean\n label?: LabelFunction | LabelStatic | false\n localized?: boolean\n /**\n * The name of the field. Must be alphanumeric and cannot contain ' . '\n *\n * Must not be one of reserved field names: ['__v', 'salt', 'hash', 'file']\n * @link https://payloadcms.com/docs/fields/overview#field-names\n */\n name: string\n required?: boolean\n saveToJWT?: boolean | string\n /**\n * Allows you to modify the base JSON schema that is generated during generate:types for this field.\n * This JSON schema will be used to generate the TypeScript interface of this field.\n */\n typescriptSchema?: Array<(args: { jsonSchema: JSONSchema4 }) => JSONSchema4>\n unique?: boolean\n validate?: Validate\n}\n\nexport type NumberField = {\n admin?: {\n /** Set this property to a string that will be used for browser autocomplete. */\n autoComplete?: string\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n /** Set this property to define a placeholder string for the field. */\n placeholder?: Record<string, string> | string\n /** Set a value for the number field to increment / decrement using browser controls. */\n step?: number\n } & Admin\n /** Maximum value accepted. Used in the default `validate` function. */\n max?: number\n /** Minimum value accepted. Used in the default `validate` function. */\n min?: number\n type: 'number'\n validate?: Validate<number | number[], unknown, unknown, NumberField>\n} & (\n | {\n /** Makes this field an ordered array of numbers instead of just a single number. */\n hasMany: true\n /** Maximum number of numbers in the numbers array, if `hasMany` is set to true. */\n maxRows?: number\n /** Minimum number of numbers in the numbers array, if `hasMany` is set to true. */\n minRows?: number\n }\n | {\n /** Makes this field an ordered array of numbers instead of just a single number. */\n hasMany?: false | undefined\n /** Maximum number of numbers in the numbers array, if `hasMany` is set to true. */\n maxRows?: undefined\n /** Minimum number of numbers in the numbers array, if `hasMany` is set to true. */\n minRows?: undefined\n }\n) &\n FieldBase\n\nexport type TextField = {\n admin?: {\n autoComplete?: string\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n placeholder?: Record<string, string> | string\n rtl?: boolean\n } & Admin\n maxLength?: number\n minLength?: number\n type: 'text'\n validate?: Validate<string | string[], unknown, unknown, TextField>\n} & (\n | {\n /** Makes this field an ordered array of strings instead of just a single string. */\n hasMany: true\n /** Maximum number of strings in the strings array, if `hasMany` is set to true. */\n maxRows?: number\n /** Minimum number of strings in the strings array, if `hasMany` is set to true. */\n minRows?: number\n }\n | {\n /** Makes this field an ordered array of strings instead of just a single string. */\n hasMany?: false | undefined\n /** Maximum number of strings in the strings array, if `hasMany` is set to true. */\n maxRows?: undefined\n /** Minimum number of strings in the strings array, if `hasMany` is set to true. */\n minRows?: undefined\n }\n) &\n FieldBase\n\nexport type EmailField = {\n admin?: {\n autoComplete?: string\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n placeholder?: Record<string, string> | string\n } & Admin\n type: 'email'\n validate?: Validate<string, unknown, unknown, EmailField>\n} & FieldBase\n\nexport type TextareaField = {\n admin?: {\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n placeholder?: Record<string, string> | string\n rows?: number\n rtl?: boolean\n } & Admin\n maxLength?: number\n minLength?: number\n type: 'textarea'\n validate?: Validate<string, unknown, unknown, TextareaField>\n} & FieldBase\n\nexport type CheckboxField = {\n admin?: {\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n } & Admin\n type: 'checkbox'\n validate?: Validate<unknown, unknown, unknown, CheckboxField>\n} & FieldBase\n\nexport type DateField = {\n admin?: {\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n afterInput?: CustomComponent[]\n beforeInput?: CustomComponent[]\n }\n date?: ConditionalDateProps\n placeholder?: Record<string, string> | string\n } & Admin\n type: 'date'\n validate?: Validate<unknown, unknown, unknown, DateField>\n} & FieldBase\n\nexport type GroupField = {\n admin?: {\n hideGutter?: boolean\n } & Admin\n fields: Field[]\n /** Customize generated GraphQL and Typescript schema names.\n * By default, it is bound to the collection.\n *\n * This is useful if you would like to generate a top level type to share amongst collections/fields.\n * **Note**: Top level types can collide, ensure they are unique amongst collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n type: 'group'\n validate?: Validate<unknown, unknown, unknown, GroupField>\n} & Omit<FieldBase, 'required'>\n\nexport type RowAdmin = Omit<Admin, 'description'>\n\nexport type RowField = {\n admin?: RowAdmin\n fields: Field[]\n type: 'row'\n} & Omit<FieldBase, 'admin' | 'label' | 'name' | 'validate'>\n\nexport type CollapsibleField = {\n fields: Field[]\n type: 'collapsible'\n} & (\n | {\n admin: {\n components: {\n RowLabel: RowLabelComponent\n } & Admin['components']\n initCollapsed?: boolean\n } & Admin\n label?: Required<FieldBase['label']>\n }\n | {\n admin?: {\n initCollapsed?: boolean\n } & Admin\n label: Required<FieldBase['label']>\n }\n) &\n Omit<FieldBase, 'label' | 'name' | 'validate'>\n\nexport type TabsAdmin = Omit<Admin, 'description'>\n\ntype TabBase = {\n description?: Description\n fields: Field[]\n interfaceName?: string\n saveToJWT?: boolean | string\n} & Omit<FieldBase, 'required' | 'validate'>\n\nexport type NamedTab = {\n /** Customize generated GraphQL and Typescript schema names.\n * The slug is used by default.\n *\n * This is useful if you would like to generate a top level type to share amongst collections/fields.\n * **Note**: Top level types can collide, ensure they are unique amongst collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n} & TabBase\n\nexport type UnnamedTab = {\n interfaceName?: never\n /**\n * Can be either:\n * - A string, which will be used as the tab's label.\n * - An object, where the key is the language code and the value is the label.\n */\n label:\n | {\n [selectedLanguage: string]: string\n }\n | LabelFunction\n | string\n localized?: never\n} & Omit<TabBase, 'name'>\n\nexport type Tab = NamedTab | UnnamedTab\n\nexport type TabsField = {\n admin?: TabsAdmin\n tabs: Tab[]\n type: 'tabs'\n} & Omit<FieldBase, 'admin' | 'localized' | 'name' | 'saveToJWT'>\n\nexport type TabAsField = {\n name?: string\n type: 'tab'\n} & Tab\n\nexport type UIField = {\n admin: {\n components?: {\n Cell?: CustomComponent\n Field: CustomComponent\n /**\n * The Filter component has to be a client component\n */\n Filter?: React.ComponentType<any>\n }\n condition?: Condition\n /** Extension point to add your custom data. Available in server and client. */\n custom?: Record<string, any>\n disableBulkEdit?: boolean\n /**\n * Shows / hides fields from appearing in the list view column selector.\n * @type boolean\n */\n disableListColumn?: boolean\n position?: string\n width?: string\n }\n /** Extension point to add your custom data. Server only. */\n custom?: Record<string, any>\n label?: Record<string, string> | string\n name: string\n type: 'ui'\n}\n\nexport type UploadField = {\n admin?: {\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n }\n }\n displayPreview?: boolean\n filterOptions?: FilterOptions\n /**\n * Sets a maximum population depth for this field, regardless of the remaining depth when this field is reached.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n relationTo: CollectionSlug\n type: 'upload'\n validate?: Validate<unknown, unknown, unknown, UploadField>\n} & FieldBase\n\ntype CodeAdmin = {\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n }\n editorOptions?: EditorProps['options']\n language?: string\n} & Admin\n\nexport type CodeField = {\n admin?: CodeAdmin\n maxLength?: number\n minLength?: number\n type: 'code'\n validate?: Validate<string, unknown, unknown, CodeField>\n} & Omit<FieldBase, 'admin'>\n\ntype JSONAdmin = {\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n }\n editorOptions?: EditorProps['options']\n} & Admin\n\nexport type JSONField = {\n admin?: JSONAdmin\n jsonSchema?: {\n fileMatch: string[]\n schema: JSONSchema4\n uri: string\n }\n type: 'json'\n validate?: Validate<Record<string, unknown>, unknown, unknown, JSONField>\n} & Omit<FieldBase, 'admin'>\n\nexport type SelectField = {\n admin?: {\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n }\n isClearable?: boolean\n isSortable?: boolean\n } & Admin\n /**\n * Customize the SQL table name\n */\n dbName?: DBIdentifierName\n /**\n * Customize the DB enum name\n */\n enumName?: DBIdentifierName\n hasMany?: boolean\n options: Option[]\n type: 'select'\n validate?: Validate<string, unknown, unknown, SelectField>\n} & FieldBase\n\ntype SharedRelationshipProperties = {\n filterOptions?: FilterOptions\n hasMany?: boolean\n /**\n * Sets a maximum population depth for this field, regardless of the remaining depth when this field is reached.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n type: 'relationship'\n validate?: Validate<unknown, unknown, unknown, SharedRelationshipProperties>\n} & (\n | {\n hasMany: true\n /**\n * @deprecated Use 'maxRows' instead\n */\n max?: number\n maxRows?: number\n /**\n * @deprecated Use 'minRows' instead\n */\n min?: number\n minRows?: number\n }\n | {\n hasMany?: false | undefined\n /**\n * @deprecated Use 'maxRows' instead\n */\n max?: undefined\n maxRows?: undefined\n /**\n * @deprecated Use 'minRows' instead\n */\n min?: undefined\n minRows?: undefined\n }\n) &\n FieldBase\n\ntype RelationshipAdmin = {\n allowCreate?: boolean\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n }\n isSortable?: boolean\n} & Admin\n\nexport type PolymorphicRelationshipField = {\n admin?: {\n sortOptions?: { [collectionSlug: CollectionSlug]: string }\n } & RelationshipAdmin\n relationTo: CollectionSlug[]\n} & SharedRelationshipProperties\n\nexport type SingleRelationshipField = {\n admin?: {\n sortOptions?: string\n } & RelationshipAdmin\n relationTo: CollectionSlug\n} & SharedRelationshipProperties\nexport type RelationshipField = PolymorphicRelationshipField | SingleRelationshipField\n\nexport type ValueWithRelation = {\n relationTo: CollectionSlug\n value: number | string\n}\n\nexport function valueIsValueWithRelation(value: unknown): value is ValueWithRelation {\n return value !== null && typeof value === 'object' && 'relationTo' in value && 'value' in value\n}\n\nexport type RelationshipValue =\n | (number | string)[]\n | ValueWithRelation\n | ValueWithRelation[]\n | (number | string)\n\nexport type RichTextField<\n Value extends object = any,\n AdapterProps = any,\n ExtraProperties = object,\n> = {\n admin?: {\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n }\n } & Admin\n editor?:\n | RichTextAdapter<Value, AdapterProps, AdapterProps>\n | RichTextAdapterProvider<Value, AdapterProps, AdapterProps>\n /**\n * Sets a maximum population depth for this field, regardless of the remaining depth when this field is reached.\n *\n * {@link https://payloadcms.com/docs/getting-started/concepts#field-level-max-depth}\n */\n maxDepth?: number\n type: 'richText'\n} & ExtraProperties &\n FieldBase\n\nexport type ArrayField = {\n admin?: {\n components?: {\n RowLabel?: RowLabelComponent\n } & Admin['components']\n initCollapsed?: boolean\n /**\n * Disable drag and drop sorting\n */\n isSortable?: boolean\n } & Admin\n /**\n * Customize the SQL table name\n */\n dbName?: DBIdentifierName\n fields: Field[]\n /** Customize generated GraphQL and Typescript schema names.\n * By default, it is bound to the collection.\n *\n * This is useful if you would like to generate a top level type to share amongst collections/fields.\n * **Note**: Top level types can collide, ensure they are unique amongst collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n labels?: Labels\n maxRows?: number\n minRows?: number\n type: 'array'\n validate?: Validate<unknown[], unknown, unknown, ArrayField>\n} & FieldBase\n\nexport type RadioField = {\n admin?: {\n components?: {\n Error?: ErrorComponent\n Label?: LabelComponent\n }\n layout?: 'horizontal' | 'vertical'\n } & Admin\n /**\n * Customize the SQL table name\n */\n dbName?: DBIdentifierName\n /**\n * Customize the DB enum name\n */\n enumName?: DBIdentifierName\n options: Option[]\n type: 'radio'\n validate?: Validate<string, unknown, unknown, RadioField>\n} & FieldBase\n\nexport type Block = {\n admin?: {\n components?: {\n Label?: React.FC<{\n blockKind: 'block' | 'lexicalBlock' | 'lexicalInlineBlock' | string\n /**\n * May contain the formData\n */\n formData: Record<string, any>\n }>\n }\n /** Extension point to add your custom data. Available in server and client. */\n custom?: Record<string, any>\n }\n /** Extension point to add your custom data. Server only. */\n custom?: Record<string, any>\n /**\n * Customize the SQL table name\n */\n dbName?: DBIdentifierName\n fields: Field[]\n /** @deprecated - please migrate to the interfaceName property instead. */\n graphQL?: {\n singularName?: string\n }\n imageAltText?: string\n imageURL?: string\n /** Customize generated GraphQL and Typescript schema names.\n * The slug is used by default.\n *\n * This is useful if you would like to generate a top level type to share amongst collections/fields.\n * **Note**: Top level types can collide, ensure they are unique amongst collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n labels?: Labels\n slug: string\n}\n\nexport type BlockField = {\n admin?: {\n initCollapsed?: boolean\n /**\n * Disable drag and drop sorting\n */\n isSortable?: boolean\n } & Admin\n blocks: Block[]\n defaultValue?: unknown\n labels?: Labels\n maxRows?: number\n minRows?: number\n type: 'blocks'\n validate?: Validate<string, unknown, unknown, BlockField>\n} & FieldBase\n\nexport type PointField = {\n type: 'point'\n validate?: Validate<unknown, unknown, unknown, PointField>\n} & FieldBase\n\nexport type Field =\n | ArrayField\n | BlockField\n | CheckboxField\n | CodeField\n | CollapsibleField\n | DateField\n | EmailField\n | GroupField\n | JSONField\n | NumberField\n | PointField\n | RadioField\n | RelationshipField\n | RichTextField\n | RowField\n | SelectField\n | TabsField\n | TextField\n | TextareaField\n | UIField\n | UploadField\n\nexport type FieldAffectingData =\n | ArrayField\n | BlockField\n | CheckboxField\n | CodeField\n | DateField\n | EmailField\n | GroupField\n | JSONField\n | NumberField\n | PointField\n | RadioField\n | RelationshipField\n | RichTextField\n | SelectField\n | TabAsField\n | TextField\n | TextareaField\n | UploadField\n\nexport type NonPresentationalField =\n | ArrayField\n | BlockField\n | CheckboxField\n | CodeField\n | CollapsibleField\n | DateField\n | EmailField\n | GroupField\n | JSONField\n | NumberField\n | PointField\n | RadioField\n | RelationshipField\n | RichTextField\n | RowField\n | SelectField\n | TabsField\n | TextField\n | TextareaField\n | UploadField\n\nexport type FieldWithPath = {\n path?: string\n} & Field\n\nexport type FieldWithSubFields = ArrayField | CollapsibleField | GroupField | RowField\n\nexport type FieldPresentationalOnly = UIField\n\nexport type FieldWithMany = RelationshipField | SelectField\n\nexport type FieldWithMaxDepth = RelationshipField | UploadField\n\nexport function fieldHasSubFields(field: ClientFieldConfig | Field): field is FieldWithSubFields {\n return (\n field.type === 'group' ||\n field.type === 'array' ||\n field.type === 'row' ||\n field.type === 'collapsible'\n )\n}\n\nexport function fieldIsArrayType(field: Field): field is ArrayField {\n return field.type === 'array'\n}\n\nexport function fieldIsBlockType(field: Field): field is BlockField {\n return field.type === 'blocks'\n}\n\nexport function fieldIsGroupType(field: Field): field is GroupField {\n return field.type === 'group'\n}\n\nexport function optionIsObject(option: Option): option is OptionObject {\n return typeof option === 'object'\n}\n\nexport function optionsAreObjects(options: Option[]): options is OptionObject[] {\n return Array.isArray(options) && typeof options?.[0] === 'object'\n}\n\nexport function optionIsValue(option: Option): option is string {\n return typeof option === 'string'\n}\n\nexport function fieldSupportsMany(field: Field): field is FieldWithMany {\n return field.type === 'select' || field.type === 'relationship'\n}\n\nexport function fieldHasMaxDepth(field: Field): field is FieldWithMaxDepth {\n return (\n (field.type === 'upload' || field.type === 'relationship') && typeof field.maxDepth === 'number'\n )\n}\n\nexport function fieldIsPresentationalOnly(\n field: ClientFieldConfig | Field | TabAsField,\n): field is UIField {\n return field.type === 'ui'\n}\n\nexport function fieldAffectsData(\n field: ClientFieldConfig | Field | TabAsField,\n): field is FieldAffectingData {\n return 'name' in field && !fieldIsPresentationalOnly(field)\n}\n\nexport function tabHasName(tab: Tab): tab is NamedTab {\n return 'name' in tab\n}\n\nexport function fieldIsLocalized(field: Field | Tab): boolean {\n return 'localized' in field && field.localized\n}\n\nexport type HookName =\n | 'afterChange'\n | 'afterRead'\n | 'beforeChange'\n | 'beforeRead'\n | 'beforeValidate'\n"],"names":["valueIsValueWithRelation","value","fieldHasSubFields","field","type","fieldIsArrayType","fieldIsBlockType","fieldIsGroupType","optionIsObject","option","optionsAreObjects","options","Array","isArray","optionIsValue","fieldSupportsMany","fieldHasMaxDepth","maxDepth","fieldIsPresentationalOnly","fieldAffectsData","tabHasName","tab","fieldIsLocalized","localized"],"mappings":"AAAA,qDAAqD,GA0pBrD,OAAO,SAASA,yBAAyBC,KAAc;IACrD,OAAOA,UAAU,QAAQ,OAAOA,UAAU,YAAY,gBAAgBA,SAAS,WAAWA;AAC5F;AA4NA,OAAO,SAASC,kBAAkBC,KAAgC;IAChE,OACEA,MAAMC,IAAI,KAAK,WACfD,MAAMC,IAAI,KAAK,WACfD,MAAMC,IAAI,KAAK,SACfD,MAAMC,IAAI,KAAK;AAEnB;AAEA,OAAO,SAASC,iBAAiBF,KAAY;IAC3C,OAAOA,MAAMC,IAAI,KAAK;AACxB;AAEA,OAAO,SAASE,iBAAiBH,KAAY;IAC3C,OAAOA,MAAMC,IAAI,KAAK;AACxB;AAEA,OAAO,SAASG,iBAAiBJ,KAAY;IAC3C,OAAOA,MAAMC,IAAI,KAAK;AACxB;AAEA,OAAO,SAASI,eAAeC,MAAc;IAC3C,OAAO,OAAOA,WAAW;AAC3B;AAEA,OAAO,SAASC,kBAAkBC,OAAiB;IACjD,OAAOC,MAAMC,OAAO,CAACF,YAAY,OAAOA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ChB,GAAG,EAAE,UAAU,CAAA;IACf,cAAc,EAAE,UAAU,CAAA;IAC1B,SAAS,EAAE,OAAO,CAAA;IAClB,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IAC5C,KAAK,EAAE,KAAK,GAAG,UAAU,CAAA;IACzB,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAA;IACpC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,kBAAkB,EAAE,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAA;IAC3C,SAAS,EAAE,SAAS,CAAA;IACpB;;OAEG;IACH,UAAU,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IAC/B;;OAEG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAA;IAC1B,GAAG,EAAE,cAAc,CAAA;IACnB,WAAW,EAAE,UAAU,CAAA;IACvB,UAAU,EAAE,UAAU,CAAA;IACtB,qBAAqB,CAAC,EAAE,UAAU,CAAA;IAClC,cAAc,EAAE,OAAO,CAAA;CACxB,CAAA;AAUD,eAAO,MAAM,OAAO,gOAoBjB,IAAI,KAAG,OAAO,CAAC,IAAI,CA2arB,CAAA"}
@@ -75,6 +75,7 @@ export const promise = async ({ id, collection, context, data, doc, docWithLocal
75
75
  const validationResult = await field.validate(valueToValidate, {
76
76
  ...field,
77
77
  id,
78
+ collectionSlug: collection?.slug,
78
79
  data: deepMergeWithSourceArrays(doc, data),
79
80
  jsonError,
80
81
  operation,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/fields/hooks/beforeChange/promise.ts"],"sourcesContent":["import type { RichTextAdapter } from '../../../admin/RichText.js'\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { JsonObject, Operation, PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, FieldHookArgs, TabAsField, ValidateOptions } from '../../config/types.js'\n\nimport { MissingEditorProp } from '../../../errors/index.js'\nimport { deepMergeWithSourceArrays } from '../../../utilities/deepMerge.js'\nimport { fieldAffectsData, tabHasName } from '../../config/types.js'\nimport { getFieldPaths } from '../../getFieldPaths.js'\nimport { beforeDuplicate } from './beforeDuplicate.js'\nimport { getExistingRowDoc } from './getExistingRowDoc.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: JsonObject\n doc: JsonObject\n docWithLocales: JsonObject\n duplicate: boolean\n errors: { field: string; message: string }[]\n field: Field | TabAsField\n global: SanitizedGlobalConfig | null\n id?: number | string\n mergeLocaleActions: (() => Promise<void>)[]\n operation: Operation\n /**\n * The parent's path.\n */\n parentPath: (number | string)[]\n /**\n * The parent's schemaPath (path without indexes).\n */\n parentSchemaPath: string[]\n req: PayloadRequest\n siblingData: JsonObject\n siblingDoc: JsonObject\n siblingDocWithLocales?: JsonObject\n skipValidation: boolean\n}\n\n// This function is responsible for the following actions, in order:\n// - Run condition\n// - Execute field hooks\n// - Validate data\n// - Transform data for storage\n// - beforeDuplicate hooks (if duplicate)\n// - Unflatten locales\n\nexport const promise = async ({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n field,\n global,\n mergeLocaleActions,\n operation,\n parentPath,\n parentSchemaPath,\n req,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n skipValidation,\n}: Args): Promise<void> => {\n const passesCondition = field.admin?.condition\n ? Boolean(field.admin.condition(data, siblingData, { user: req.user }))\n : true\n let skipValidationFromHere = skipValidation || !passesCondition\n const { localization } = req.payload.config\n const defaultLocale = localization ? localization?.defaultLocale : 'en'\n const operationLocale = req.locale || defaultLocale\n\n const { path: fieldPath, schemaPath: fieldSchemaPath } = getFieldPaths({\n field,\n parentPath,\n parentSchemaPath,\n })\n\n if (fieldAffectsData(field)) {\n // skip validation if the field is localized and the incoming data is null\n if (field.localized && operationLocale !== defaultLocale) {\n if (['array', 'blocks'].includes(field.type) && siblingData[field.name] === null) {\n skipValidationFromHere = true\n }\n }\n\n // Execute hooks\n if (field.hooks?.beforeChange) {\n await field.hooks.beforeChange.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n field,\n global,\n operation,\n originalDoc: doc,\n path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingDoc[field.name],\n req,\n schemaPath: parentSchemaPath,\n siblingData,\n siblingDocWithLocales,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n\n // Validate\n if (!skipValidationFromHere && 'validate' in field && field.validate) {\n const valueToValidate = siblingData[field.name]\n let jsonError: object\n\n if (field.type === 'json' && typeof siblingData[field.name] === 'string') {\n try {\n JSON.parse(siblingData[field.name] as string)\n } catch (e) {\n jsonError = e\n }\n }\n\n const validationResult = await field.validate(valueToValidate, {\n ...field,\n id,\n data: deepMergeWithSourceArrays(doc, data),\n jsonError,\n operation,\n preferences: { fields: {} },\n previousValue: siblingDoc[field.name],\n req,\n siblingData: deepMergeWithSourceArrays(siblingDoc, siblingData),\n } as ValidateOptions<any, any, { jsonError: object }, any>)\n\n if (typeof validationResult === 'string') {\n errors.push({\n field: fieldPath.join('.'),\n message: validationResult,\n })\n }\n }\n\n const beforeDuplicateArgs: FieldHookArgs = {\n collection,\n context,\n data,\n field,\n global: undefined,\n path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingDoc[field.name],\n req,\n schemaPath: parentSchemaPath,\n siblingData,\n siblingDocWithLocales,\n value: siblingData[field.name],\n }\n\n // Push merge locale action if applicable\n if (localization && field.localized) {\n mergeLocaleActions.push(async () => {\n const localeData = await localization.localeCodes.reduce(\n async (localizedValuesPromise: Promise<JsonObject>, locale) => {\n const localizedValues = await localizedValuesPromise\n let fieldValue =\n locale === req.locale\n ? siblingData[field.name]\n : siblingDocWithLocales?.[field.name]?.[locale]\n\n if (duplicate && field.hooks?.beforeDuplicate?.length) {\n beforeDuplicateArgs.value = fieldValue\n fieldValue = await beforeDuplicate(beforeDuplicateArgs)\n }\n\n // const result = await localizedValues\n // update locale value if it's not undefined\n if (typeof fieldValue !== 'undefined') {\n return {\n ...localizedValues,\n [locale]: fieldValue,\n }\n }\n\n return localizedValuesPromise\n },\n Promise.resolve({}),\n )\n\n // If there are locales with data, set the data\n if (Object.keys(localeData).length > 0) {\n siblingData[field.name] = localeData\n }\n })\n } else if (duplicate && field.hooks?.beforeDuplicate?.length) {\n mergeLocaleActions.push(async () => {\n siblingData[field.name] = await beforeDuplicate(beforeDuplicateArgs)\n })\n }\n }\n\n switch (field.type) {\n case 'point': {\n // Transform point data for storage\n if (\n Array.isArray(siblingData[field.name]) &&\n siblingData[field.name][0] !== null &&\n siblingData[field.name][1] !== null\n ) {\n siblingData[field.name] = {\n type: 'Point',\n coordinates: [\n parseFloat(siblingData[field.name][0]),\n parseFloat(siblingData[field.name][1]),\n ],\n }\n }\n\n break\n }\n\n case 'group': {\n if (typeof siblingData[field.name] !== 'object') siblingData[field.name] = {}\n if (typeof siblingDoc[field.name] !== 'object') siblingDoc[field.name] = {}\n if (typeof siblingDocWithLocales[field.name] !== 'object')\n siblingDocWithLocales[field.name] = {}\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: field.fields,\n global,\n mergeLocaleActions,\n operation,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: siblingData[field.name] as JsonObject,\n siblingDoc: siblingDoc[field.name] as JsonObject,\n siblingDocWithLocales: siblingDocWithLocales[field.name] as JsonObject,\n skipValidation: skipValidationFromHere,\n })\n\n break\n }\n\n case 'array': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row, i) => {\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: field.fields,\n global,\n mergeLocaleActions,\n operation,\n path: [...fieldPath, i],\n req,\n schemaPath: fieldSchemaPath,\n siblingData: row as JsonObject,\n siblingDoc: getExistingRowDoc(row as JsonObject, siblingDoc[field.name]),\n siblingDocWithLocales: getExistingRowDoc(\n row as JsonObject,\n siblingDocWithLocales[field.name],\n ),\n skipValidation: skipValidationFromHere,\n }),\n )\n })\n\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'blocks': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row, i) => {\n const rowSiblingDoc = getExistingRowDoc(row as JsonObject, siblingDoc[field.name])\n const rowSiblingDocWithLocales = getExistingRowDoc(\n row as JsonObject,\n siblingDocWithLocales[field.name],\n )\n\n const blockTypeToMatch = (row as JsonObject).blockType || rowSiblingDoc.blockType\n const block = field.blocks.find((blockType) => blockType.slug === blockTypeToMatch)\n\n if (block) {\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: block.fields,\n global,\n mergeLocaleActions,\n operation,\n path: [...fieldPath, i],\n req,\n schemaPath: fieldSchemaPath,\n siblingData: row as JsonObject,\n siblingDoc: rowSiblingDoc,\n siblingDocWithLocales: rowSiblingDocWithLocales,\n skipValidation: skipValidationFromHere,\n }),\n )\n }\n })\n\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'row':\n case 'collapsible': {\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: field.fields,\n global,\n mergeLocaleActions,\n operation,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n skipValidation: skipValidationFromHere,\n })\n\n break\n }\n\n case 'tab': {\n let tabSiblingData = siblingData\n let tabSiblingDoc = siblingDoc\n let tabSiblingDocWithLocales = siblingDocWithLocales\n\n if (tabHasName(field)) {\n if (typeof siblingData[field.name] !== 'object') siblingData[field.name] = {}\n if (typeof siblingDoc[field.name] !== 'object') siblingDoc[field.name] = {}\n if (typeof siblingDocWithLocales[field.name] !== 'object')\n siblingDocWithLocales[field.name] = {}\n\n tabSiblingData = siblingData[field.name] as JsonObject\n tabSiblingDoc = siblingDoc[field.name] as JsonObject\n tabSiblingDocWithLocales = siblingDocWithLocales[field.name] as JsonObject\n }\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: field.fields,\n global,\n mergeLocaleActions,\n operation,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n siblingDocWithLocales: tabSiblingDocWithLocales,\n skipValidation: skipValidationFromHere,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n mergeLocaleActions,\n operation,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n skipValidation: skipValidationFromHere,\n })\n\n break\n }\n\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n if (typeof field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n const editor: RichTextAdapter = field?.editor\n\n if (editor?.hooks?.beforeChange?.length) {\n await editor.hooks.beforeChange.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n docWithLocales,\n duplicate,\n errors,\n field,\n global,\n mergeLocaleActions,\n operation,\n originalDoc: doc,\n path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingDoc[field.name],\n req,\n schemaPath: parentSchemaPath,\n siblingData,\n siblingDocWithLocales,\n skipValidation,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","deepMergeWithSourceArrays","fieldAffectsData","tabHasName","getFieldPaths","beforeDuplicate","getExistingRowDoc","traverseFields","promise","id","collection","context","data","doc","docWithLocales","duplicate","errors","field","global","mergeLocaleActions","operation","parentPath","parentSchemaPath","req","siblingData","siblingDoc","siblingDocWithLocales","skipValidation","passesCondition","admin","condition","Boolean","user","skipValidationFromHere","localization","payload","config","defaultLocale","operationLocale","locale","path","fieldPath","schemaPath","fieldSchemaPath","localized","includes","type","name","hooks","beforeChange","reduce","priorHook","currentHook","hookedValue","originalDoc","previousSiblingDoc","previousValue","value","undefined","Promise","resolve","validate","valueToValidate","jsonError","JSON","parse","e","validationResult","preferences","fields","push","join","message","beforeDuplicateArgs","localeData","localeCodes","localizedValuesPromise","localizedValues","fieldValue","length","Object","keys","Array","isArray","coordinates","parseFloat","rows","promises","forEach","row","i","all","rowSiblingDoc","rowSiblingDocWithLocales","blockTypeToMatch","blockType","block","blocks","find","slug","tabSiblingData","tabSiblingDoc","tabSiblingDocWithLocales","tabs","map","tab","editor","Error"],"mappings":"AAMA,SAASA,iBAAiB,QAAQ,2BAA0B;AAC5D,SAASC,yBAAyB,QAAQ,kCAAiC;AAC3E,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,wBAAuB;AACpE,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,cAAc,QAAQ,sBAAqB;AA8BpD,oEAAoE;AACpE,kBAAkB;AAClB,wBAAwB;AACxB,kBAAkB;AAClB,+BAA+B;AAC/B,yCAAyC;AACzC,sBAAsB;AAEtB,OAAO,MAAMC,UAAU,OAAO,EAC5BC,EAAE,EACFC,UAAU,EACVC,OAAO,EAC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;gBACX,MAAM1B,eAAe;oBACnBE;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAqD,QAAQpD,MAAMsF,IAAI,CAACC,GAAG,CAAC,CAACC,MAAS,CAAA;4BAAE,GAAGA,GAAG;4BAAE3D,MAAM;wBAAM,CAAA;oBACvD5B;oBACAC;oBACAC;oBACAoB,MAAMC;oBACNlB;oBACAmB,YAAYC;oBACZnB;oBACAC;oBACAC;oBACAC,gBAAgBM;gBAClB;gBAEA;YACF;QAEA,KAAK;YAAY;gBACf,IAAI,CAAChB,OAAOyF,QAAQ;oBAClB,MAAM,IAAI1G,kBAAkBiB,OAAO,8HAA8H;;gBACnK;gBACA,IAAI,OAAOA,OAAOyF,WAAW,YAAY;oBACvC,MAAM,IAAIC,MAAM;gBAClB;gBAEA,MAAMD,SAA0BzF,OAAOyF;gBAEvC,IAAIA,QAAQ1D,OAAOC,cAAc8B,QAAQ;oBACvC,MAAM2B,OAAO1D,KAAK,CAACC,YAAY,CAACC,MAAM,CAAC,OAAOC,WAAWC;wBACvD,MAAMD;wBAEN,MAAME,cAAc,MAAMD,YAAY;4BACpC1C;4BACAC;4BACAC;4BACAE;4BACAC;4BACAC;4BACAC;4BACAC;4BACAC;4BACAC;4BACAkC,aAAazC;4BACb2B,MAAMC;4BACNc,oBAAoB9B;4BACpB+B,eAAe/B,UAAU,CAACR,MAAM8B,IAAI,CAAC;4BACrCxB;4BACAmB,YAAYpB;4BACZE;4BACAE;4BACAC;4BACA8B,OAAOjC,WAAW,CAACP,MAAM8B,IAAI,CAAC;wBAChC;wBAEA,IAAIM,gBAAgBK,WAAW;4BAC7BlC,WAAW,CAACP,MAAM8B,IAAI,CAAC,GAAGM;wBAC5B;oBACF,GAAGM,QAAQC,OAAO;gBACpB;gBAEA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/fields/hooks/beforeChange/promise.ts"],"sourcesContent":["import type { RichTextAdapter } from '../../../admin/RichText.js'\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { JsonObject, Operation, PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, FieldHookArgs, TabAsField, ValidateOptions } from '../../config/types.js'\n\nimport { MissingEditorProp } from '../../../errors/index.js'\nimport { deepMergeWithSourceArrays } from '../../../utilities/deepMerge.js'\nimport { fieldAffectsData, tabHasName } from '../../config/types.js'\nimport { getFieldPaths } from '../../getFieldPaths.js'\nimport { beforeDuplicate } from './beforeDuplicate.js'\nimport { getExistingRowDoc } from './getExistingRowDoc.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: JsonObject\n doc: JsonObject\n docWithLocales: JsonObject\n duplicate: boolean\n errors: { field: string; message: string }[]\n field: Field | TabAsField\n global: SanitizedGlobalConfig | null\n id?: number | string\n mergeLocaleActions: (() => Promise<void>)[]\n operation: Operation\n /**\n * The parent's path.\n */\n parentPath: (number | string)[]\n /**\n * The parent's schemaPath (path without indexes).\n */\n parentSchemaPath: string[]\n req: PayloadRequest\n siblingData: JsonObject\n siblingDoc: JsonObject\n siblingDocWithLocales?: JsonObject\n skipValidation: boolean\n}\n\n// This function is responsible for the following actions, in order:\n// - Run condition\n// - Execute field hooks\n// - Validate data\n// - Transform data for storage\n// - beforeDuplicate hooks (if duplicate)\n// - Unflatten locales\n\nexport const promise = async ({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n field,\n global,\n mergeLocaleActions,\n operation,\n parentPath,\n parentSchemaPath,\n req,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n skipValidation,\n}: Args): Promise<void> => {\n const passesCondition = field.admin?.condition\n ? Boolean(field.admin.condition(data, siblingData, { user: req.user }))\n : true\n let skipValidationFromHere = skipValidation || !passesCondition\n const { localization } = req.payload.config\n const defaultLocale = localization ? localization?.defaultLocale : 'en'\n const operationLocale = req.locale || defaultLocale\n\n const { path: fieldPath, schemaPath: fieldSchemaPath } = getFieldPaths({\n field,\n parentPath,\n parentSchemaPath,\n })\n\n if (fieldAffectsData(field)) {\n // skip validation if the field is localized and the incoming data is null\n if (field.localized && operationLocale !== defaultLocale) {\n if (['array', 'blocks'].includes(field.type) && siblingData[field.name] === null) {\n skipValidationFromHere = true\n }\n }\n\n // Execute hooks\n if (field.hooks?.beforeChange) {\n await field.hooks.beforeChange.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n field,\n global,\n operation,\n originalDoc: doc,\n path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingDoc[field.name],\n req,\n schemaPath: parentSchemaPath,\n siblingData,\n siblingDocWithLocales,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n\n // Validate\n if (!skipValidationFromHere && 'validate' in field && field.validate) {\n const valueToValidate = siblingData[field.name]\n let jsonError: object\n\n if (field.type === 'json' && typeof siblingData[field.name] === 'string') {\n try {\n JSON.parse(siblingData[field.name] as string)\n } catch (e) {\n jsonError = e\n }\n }\n\n const validationResult = await field.validate(valueToValidate, {\n ...field,\n id,\n collectionSlug: collection?.slug,\n data: deepMergeWithSourceArrays(doc, data),\n jsonError,\n operation,\n preferences: { fields: {} },\n previousValue: siblingDoc[field.name],\n req,\n siblingData: deepMergeWithSourceArrays(siblingDoc, siblingData),\n } as ValidateOptions<any, any, { jsonError: object }, any>)\n\n if (typeof validationResult === 'string') {\n errors.push({\n field: fieldPath.join('.'),\n message: validationResult,\n })\n }\n }\n\n const beforeDuplicateArgs: FieldHookArgs = {\n collection,\n context,\n data,\n field,\n global: undefined,\n path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingDoc[field.name],\n req,\n schemaPath: parentSchemaPath,\n siblingData,\n siblingDocWithLocales,\n value: siblingData[field.name],\n }\n\n // Push merge locale action if applicable\n if (localization && field.localized) {\n mergeLocaleActions.push(async () => {\n const localeData = await localization.localeCodes.reduce(\n async (localizedValuesPromise: Promise<JsonObject>, locale) => {\n const localizedValues = await localizedValuesPromise\n let fieldValue =\n locale === req.locale\n ? siblingData[field.name]\n : siblingDocWithLocales?.[field.name]?.[locale]\n\n if (duplicate && field.hooks?.beforeDuplicate?.length) {\n beforeDuplicateArgs.value = fieldValue\n fieldValue = await beforeDuplicate(beforeDuplicateArgs)\n }\n\n // const result = await localizedValues\n // update locale value if it's not undefined\n if (typeof fieldValue !== 'undefined') {\n return {\n ...localizedValues,\n [locale]: fieldValue,\n }\n }\n\n return localizedValuesPromise\n },\n Promise.resolve({}),\n )\n\n // If there are locales with data, set the data\n if (Object.keys(localeData).length > 0) {\n siblingData[field.name] = localeData\n }\n })\n } else if (duplicate && field.hooks?.beforeDuplicate?.length) {\n mergeLocaleActions.push(async () => {\n siblingData[field.name] = await beforeDuplicate(beforeDuplicateArgs)\n })\n }\n }\n\n switch (field.type) {\n case 'point': {\n // Transform point data for storage\n if (\n Array.isArray(siblingData[field.name]) &&\n siblingData[field.name][0] !== null &&\n siblingData[field.name][1] !== null\n ) {\n siblingData[field.name] = {\n type: 'Point',\n coordinates: [\n parseFloat(siblingData[field.name][0]),\n parseFloat(siblingData[field.name][1]),\n ],\n }\n }\n\n break\n }\n\n case 'group': {\n if (typeof siblingData[field.name] !== 'object') siblingData[field.name] = {}\n if (typeof siblingDoc[field.name] !== 'object') siblingDoc[field.name] = {}\n if (typeof siblingDocWithLocales[field.name] !== 'object')\n siblingDocWithLocales[field.name] = {}\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: field.fields,\n global,\n mergeLocaleActions,\n operation,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: siblingData[field.name] as JsonObject,\n siblingDoc: siblingDoc[field.name] as JsonObject,\n siblingDocWithLocales: siblingDocWithLocales[field.name] as JsonObject,\n skipValidation: skipValidationFromHere,\n })\n\n break\n }\n\n case 'array': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row, i) => {\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: field.fields,\n global,\n mergeLocaleActions,\n operation,\n path: [...fieldPath, i],\n req,\n schemaPath: fieldSchemaPath,\n siblingData: row as JsonObject,\n siblingDoc: getExistingRowDoc(row as JsonObject, siblingDoc[field.name]),\n siblingDocWithLocales: getExistingRowDoc(\n row as JsonObject,\n siblingDocWithLocales[field.name],\n ),\n skipValidation: skipValidationFromHere,\n }),\n )\n })\n\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'blocks': {\n const rows = siblingData[field.name]\n\n if (Array.isArray(rows)) {\n const promises = []\n rows.forEach((row, i) => {\n const rowSiblingDoc = getExistingRowDoc(row as JsonObject, siblingDoc[field.name])\n const rowSiblingDocWithLocales = getExistingRowDoc(\n row as JsonObject,\n siblingDocWithLocales[field.name],\n )\n\n const blockTypeToMatch = (row as JsonObject).blockType || rowSiblingDoc.blockType\n const block = field.blocks.find((blockType) => blockType.slug === blockTypeToMatch)\n\n if (block) {\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: block.fields,\n global,\n mergeLocaleActions,\n operation,\n path: [...fieldPath, i],\n req,\n schemaPath: fieldSchemaPath,\n siblingData: row as JsonObject,\n siblingDoc: rowSiblingDoc,\n siblingDocWithLocales: rowSiblingDocWithLocales,\n skipValidation: skipValidationFromHere,\n }),\n )\n }\n })\n\n await Promise.all(promises)\n }\n\n break\n }\n\n case 'row':\n case 'collapsible': {\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: field.fields,\n global,\n mergeLocaleActions,\n operation,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n skipValidation: skipValidationFromHere,\n })\n\n break\n }\n\n case 'tab': {\n let tabSiblingData = siblingData\n let tabSiblingDoc = siblingDoc\n let tabSiblingDocWithLocales = siblingDocWithLocales\n\n if (tabHasName(field)) {\n if (typeof siblingData[field.name] !== 'object') siblingData[field.name] = {}\n if (typeof siblingDoc[field.name] !== 'object') siblingDoc[field.name] = {}\n if (typeof siblingDocWithLocales[field.name] !== 'object')\n siblingDocWithLocales[field.name] = {}\n\n tabSiblingData = siblingData[field.name] as JsonObject\n tabSiblingDoc = siblingDoc[field.name] as JsonObject\n tabSiblingDocWithLocales = siblingDocWithLocales[field.name] as JsonObject\n }\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: field.fields,\n global,\n mergeLocaleActions,\n operation,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n siblingDocWithLocales: tabSiblingDocWithLocales,\n skipValidation: skipValidationFromHere,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n docWithLocales,\n duplicate,\n errors,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n mergeLocaleActions,\n operation,\n path: fieldPath,\n req,\n schemaPath: fieldSchemaPath,\n siblingData,\n siblingDoc,\n siblingDocWithLocales,\n skipValidation: skipValidationFromHere,\n })\n\n break\n }\n\n case 'richText': {\n if (!field?.editor) {\n throw new MissingEditorProp(field) // while we allow disabling editor functionality, you should not have any richText fields defined if you do not have an editor\n }\n if (typeof field?.editor === 'function') {\n throw new Error('Attempted to access unsanitized rich text editor.')\n }\n\n const editor: RichTextAdapter = field?.editor\n\n if (editor?.hooks?.beforeChange?.length) {\n await editor.hooks.beforeChange.reduce(async (priorHook, currentHook) => {\n await priorHook\n\n const hookedValue = await currentHook({\n collection,\n context,\n data,\n docWithLocales,\n duplicate,\n errors,\n field,\n global,\n mergeLocaleActions,\n operation,\n originalDoc: doc,\n path: fieldPath,\n previousSiblingDoc: siblingDoc,\n previousValue: siblingDoc[field.name],\n req,\n schemaPath: parentSchemaPath,\n siblingData,\n siblingDocWithLocales,\n skipValidation,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["MissingEditorProp","deepMergeWithSourceArrays","fieldAffectsData","tabHasName","getFieldPaths","beforeDuplicate","getExistingRowDoc","traverseFields","promise","id","collection","context","data","doc","docWithLocales","duplicate","errors","field","global","mergeLocaleActions","operation","parentPath","parentSchemaPath","req","siblingData","siblingDoc","siblingDocWithLocales","skipValidation","passesCondition","admin","condition","Boolean","user","skipValidationFromHere","localization","payload","config","defaultLocale","operationLocale","locale","path","fieldPath","schemaPath","fieldSchemaPath","localized","includes","type","name","hooks","beforeChange","reduce","priorHook","currentHook","hookedValue","originalDoc","previousSiblingDoc","previousValue","value","undefined","Promise","resolve","validate","valueToValidate","jsonError","JSON","parse","e","validationResult","collectionSlug","slug","preferences","fields","push","join","message","beforeDuplicateArgs","localeData","localeCodes","localizedValuesPromise","localizedValues","fieldValue","length","Object","keys","Array","isArray","coordinates","parseFloat","rows","promises","forEach","row","i","all","rowSiblingDoc","rowSiblingDocWithLocales","blockTypeToMatch","blockType","block","blocks","find","tabSiblingData","tabSiblingDoc","tabSiblingDocWithLocales","tabs","map","tab","editor","Error"],"mappings":"AAMA,SAASA,iBAAiB,QAAQ,2BAA0B;AAC5D,SAASC,yBAAyB,QAAQ,kCAAiC;AAC3E,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,wBAAuB;AACpE,SAASC,aAAa,QAAQ,yBAAwB;AACtD,SAASC,eAAe,QAAQ,uBAAsB;AACtD,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,cAAc,QAAQ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WAAW;4BAC7BlC,WAAW,CAACP,MAAM8B,IAAI,CAAC,GAAGM;wBAC5B;oBACF,GAAGM,QAAQC,OAAO;gBACpB;gBAEA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
@@ -1,81 +1,72 @@
1
1
  import type { ArrayField, BlockField, CheckboxField, CodeField, DateField, EmailField, JSONField, NumberField, PointField, RadioField, RelationshipField, RelationshipValue, RichTextField, SelectField, TextField, TextareaField, UploadField, Validate } from './config/types.js';
2
- export declare const text: Validate<string | string[], unknown, unknown, TextField>;
3
- export declare const password: Validate<string, unknown, unknown, TextField>;
4
- export declare const confirmPassword: Validate<string, unknown, unknown, TextField>;
5
- export declare const email: Validate<string, unknown, unknown, EmailField>;
6
- export declare const username: Validate<string, unknown, unknown, TextField>;
7
- export declare const textarea: Validate<string, unknown, unknown, TextareaField>;
8
- export declare const code: Validate<string, unknown, unknown, CodeField>;
9
- export declare const json: Validate<string, unknown, unknown, {
2
+ export type TextFieldValidation = Validate<string, unknown, unknown, TextField>;
3
+ export declare const text: TextFieldValidation;
4
+ export type PasswordFieldValidation = Validate<string, unknown, unknown, TextField>;
5
+ export declare const password: PasswordFieldValidation;
6
+ export type ConfirmPasswordFieldValidation = Validate<string, unknown, {
7
+ password: string;
8
+ }, TextField>;
9
+ export declare const confirmPassword: ConfirmPasswordFieldValidation;
10
+ export type EmailFieldValidation = Validate<string, unknown, {
11
+ username?: string;
12
+ }, EmailField>;
13
+ export declare const email: EmailFieldValidation;
14
+ export type UsernameFieldValidation = Validate<string, unknown, {
15
+ email?: string;
16
+ }, TextField>;
17
+ export declare const username: UsernameFieldValidation;
18
+ export type TextareaFieldValidation = Validate<string, unknown, unknown, TextareaField>;
19
+ export declare const textarea: TextareaFieldValidation;
20
+ export type CodeFieldValidation = Validate<string, unknown, unknown, CodeField>;
21
+ export declare const code: CodeFieldValidation;
22
+ export type JSONFieldValidation = Validate<string, unknown, unknown, {
10
23
  jsonError?: string;
11
24
  } & JSONField>;
12
- export declare const checkbox: Validate<boolean, unknown, unknown, CheckboxField>;
13
- export declare const date: Validate<Date, unknown, unknown, DateField>;
14
- export declare const richText: Validate<object, unknown, unknown, RichTextField>;
15
- export declare const number: Validate<number | number[], unknown, unknown, NumberField>;
16
- export declare const array: Validate<unknown[], unknown, unknown, ArrayField>;
17
- export declare const blocks: Validate<unknown, unknown, unknown, BlockField>;
18
- export declare const upload: Validate<unknown, unknown, unknown, UploadField>;
19
- export declare const relationship: Validate<RelationshipValue, unknown, unknown, RelationshipField>;
20
- export declare const select: Validate<unknown, unknown, unknown, SelectField>;
21
- export declare const radio: Validate<unknown, unknown, unknown, RadioField>;
22
- export declare const point: Validate<[number | string, number | string], unknown, unknown, PointField>;
25
+ export declare const json: JSONFieldValidation;
26
+ export type CheckboxFieldValidation = Validate<boolean, unknown, unknown, CheckboxField>;
27
+ export declare const checkbox: CheckboxFieldValidation;
28
+ export type DateFieldValidation = Validate<Date, unknown, unknown, DateField>;
29
+ export declare const date: DateFieldValidation;
30
+ export type RichTextFieldValidation = Validate<object, unknown, unknown, RichTextField>;
31
+ export declare const richText: RichTextFieldValidation;
32
+ export type NumberFieldValidation = Validate<number | number[], unknown, unknown, NumberField>;
33
+ export declare const number: NumberFieldValidation;
34
+ export type ArrayFieldValidation = Validate<unknown[], unknown, unknown, ArrayField>;
35
+ export declare const array: ArrayFieldValidation;
36
+ export type BlockFieldValidation = Validate<unknown, unknown, unknown, BlockField>;
37
+ export declare const blocks: BlockFieldValidation;
38
+ export type UploadFieldValidation = Validate<unknown, unknown, unknown, UploadField>;
39
+ export declare const upload: UploadFieldValidation;
40
+ export type RelationshipFieldValidation = Validate<RelationshipValue, unknown, unknown, RelationshipField>;
41
+ export declare const relationship: RelationshipFieldValidation;
42
+ export type SelectFieldValidation = Validate<string | string[], unknown, unknown, SelectField>;
43
+ export declare const select: SelectFieldValidation;
44
+ export type RadioFieldValidation = Validate<unknown, unknown, unknown, RadioField>;
45
+ export declare const radio: RadioFieldValidation;
46
+ export type PointFieldValidation = Validate<[
47
+ number | string,
48
+ number | string
49
+ ], unknown, unknown, PointField>;
50
+ export declare const point: PointFieldValidation;
23
51
  declare const _default: {
24
- array: Validate<unknown[], unknown, unknown, ArrayField>;
25
- blocks: Validate<unknown, unknown, unknown, BlockField>;
26
- checkbox: Validate<boolean, unknown, unknown, CheckboxField>;
27
- code: Validate<string, unknown, unknown, CodeField>;
28
- confirmPassword: Validate<string, unknown, unknown, TextField>;
29
- date: Validate<Date, unknown, unknown, DateField>;
30
- email: Validate<string, unknown, unknown, EmailField>;
31
- json: Validate<string, unknown, unknown, {
32
- jsonError?: string;
33
- } & {
34
- admin?: {
35
- components?: {
36
- Error?: import("../index.js").ErrorComponent;
37
- Label?: import("../index.js").LabelComponent;
38
- };
39
- editorOptions?: import("@monaco-editor/react").EditorProps["options"];
40
- } & {
41
- className?: string;
42
- components?: {
43
- Cell?: import("../index.js").CustomComponent;
44
- Description?: import("../index.js").DescriptionComponent;
45
- Field?: import("../index.js").CustomComponent;
46
- Filter?: import("react").ComponentType<any>;
47
- };
48
- condition?: import("./config/types.js").Condition;
49
- custom?: Record<string, any>;
50
- description?: import("../index.js").Description;
51
- disableBulkEdit?: boolean;
52
- disableListColumn?: boolean;
53
- disableListFilter?: boolean;
54
- disabled?: boolean;
55
- hidden?: boolean;
56
- position?: "sidebar";
57
- readOnly?: boolean;
58
- style?: import("react").CSSProperties;
59
- width?: string;
60
- };
61
- jsonSchema?: {
62
- fileMatch: string[];
63
- schema: import("json-schema").JSONSchema4;
64
- uri: string;
65
- };
66
- type: "json";
67
- validate?: Validate<Record<string, unknown>, unknown, unknown, JSONField>;
68
- } & Omit<import("./config/types.js").FieldBase, "admin">>;
69
- number: Validate<number | number[], unknown, unknown, NumberField>;
70
- password: Validate<string, unknown, unknown, TextField>;
71
- point: Validate<[string | number, string | number], unknown, unknown, PointField>;
72
- radio: Validate<unknown, unknown, unknown, RadioField>;
73
- relationship: Validate<RelationshipValue, unknown, unknown, RelationshipField>;
74
- richText: Validate<object, unknown, unknown, RichTextField>;
75
- select: Validate<unknown, unknown, unknown, SelectField>;
76
- text: Validate<string | string[], unknown, unknown, TextField>;
77
- textarea: Validate<string, unknown, unknown, TextareaField>;
78
- upload: Validate<unknown, unknown, unknown, UploadField>;
52
+ array: ArrayFieldValidation;
53
+ blocks: BlockFieldValidation;
54
+ checkbox: CheckboxFieldValidation;
55
+ code: CodeFieldValidation;
56
+ confirmPassword: ConfirmPasswordFieldValidation;
57
+ date: DateFieldValidation;
58
+ email: EmailFieldValidation;
59
+ json: JSONFieldValidation;
60
+ number: NumberFieldValidation;
61
+ password: PasswordFieldValidation;
62
+ point: PointFieldValidation;
63
+ radio: RadioFieldValidation;
64
+ relationship: RelationshipFieldValidation;
65
+ richText: RichTextFieldValidation;
66
+ select: SelectFieldValidation;
67
+ text: TextFieldValidation;
68
+ textarea: TextareaFieldValidation;
69
+ upload: UploadFieldValidation;
79
70
  };
80
71
  export default _default;
81
72
  //# sourceMappingURL=validations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validations.d.ts","sourceRoot":"","sources":["../../src/fields/validations.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EACV,aAAa,EACb,SAAS,EACT,SAAS,EACT,UAAU,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,UAAU,EACV,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,WAAW,EACX,SAAS,EACT,aAAa,EACb,WAAW,EACX,QAAQ,EACT,MAAM,mBAAmB,CAAA;AAK1B,eAAO,MAAM,IAAI,EAAE,QAAQ,CAAC,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CAkDzE,CAAA;AAED,eAAO,MAAM,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,CA8BlE,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,MAAM,EA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C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,CAAC,CAAA;AAClF,eAAO,MAAM,KAAK,EAAE,oBASnB,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG,QAAQ,CACzC;IAAC,MAAM,GAAG,MAAM;IAAE,MAAM,GAAG,MAAM;CAAC,EAClC,OAAO,EACP,OAAO,EACP,UAAU,CACX,CAAA;AACD,eAAO,MAAM,KAAK,EAAE,oBAkBnB,CAAA;;;;;;;;;;;;;;;;;;;;;AAED,wBAmBC"}
@@ -65,23 +65,39 @@ export const password = (value, { maxLength: fieldMaxLength, minLength = 3, req:
65
65
  }
66
66
  return true;
67
67
  };
68
- export const confirmPassword = (value, { req: { data, t }, required })=>{
68
+ export const confirmPassword = (value, { req: { t }, required, siblingData })=>{
69
69
  if (required && !value) {
70
70
  return t('validation:required');
71
71
  }
72
- if (value && typeof data.formState === 'object' && 'password' in data.formState && typeof data.formState.password === 'object' && 'value' in data.formState.password && value !== data.formState.password.value) {
72
+ if (value && value !== siblingData.password) {
73
73
  return t('fields:passwordsDoNotMatch');
74
74
  }
75
75
  return true;
76
76
  };
77
- export const email = (value, { req: { t }, required })=>{
77
+ export const email = (value, { collectionSlug, req: { payload: { config }, t }, required, siblingData })=>{
78
+ if (collectionSlug) {
79
+ const collection = config.collections.find(({ slug })=>slug === collectionSlug);
80
+ if (collection.auth.loginWithUsername && !collection.auth.loginWithUsername?.requireUsername && !collection.auth.loginWithUsername?.requireEmail) {
81
+ if (!value && !siblingData?.username) {
82
+ return t('validation:required');
83
+ }
84
+ }
85
+ }
78
86
  if (value && !/\S[^\s@]*@\S+\.\S+/.test(value) || !value && required) {
79
87
  return t('validation:emailAddress');
80
88
  }
81
89
  return true;
82
90
  };
83
- export const username = (value, { req: { payload: { config }, t }, required })=>{
91
+ export const username = (value, { collectionSlug, req: { payload: { config }, t }, required, siblingData })=>{
84
92
  let maxLength;
93
+ if (collectionSlug) {
94
+ const collection = config.collections.find(({ slug })=>slug === collectionSlug);
95
+ if (collection.auth.loginWithUsername && !collection.auth.loginWithUsername?.requireUsername && !collection.auth.loginWithUsername?.requireEmail) {
96
+ if (!value && !siblingData?.email) {
97
+ return t('validation:required');
98
+ }
99
+ }
100
+ }
85
101
  if (typeof config?.defaultMaxTextLength === 'number') maxLength = config.defaultMaxTextLength;
86
102
  if (value && maxLength && value.length > maxLength) {
87
103
  return t('validation:shorterThanMax', {