payload 3.0.0-alpha.47 → 3.0.0-alpha.49

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 (275) hide show
  1. package/config.d.ts +4 -1
  2. package/config.js +4 -1
  3. package/dist/admin/RichText.d.ts +3 -7
  4. package/dist/admin/RichText.d.ts.map +1 -1
  5. package/dist/admin/RichText.js.map +1 -1
  6. package/dist/admin/forms/Error.d.ts +1 -0
  7. package/dist/admin/forms/Error.d.ts.map +1 -1
  8. package/dist/admin/forms/Error.js.map +1 -1
  9. package/dist/admin/forms/Form.d.ts +5 -0
  10. package/dist/admin/forms/Form.d.ts.map +1 -1
  11. package/dist/admin/forms/Form.js.map +1 -1
  12. package/dist/admin/forms/Label.d.ts +2 -1
  13. package/dist/admin/forms/Label.d.ts.map +1 -1
  14. package/dist/admin/forms/Label.js.map +1 -1
  15. package/dist/admin/forms/RowLabel.d.ts +2 -9
  16. package/dist/admin/forms/RowLabel.d.ts.map +1 -1
  17. package/dist/admin/forms/RowLabel.js.map +1 -1
  18. package/dist/admin/types.d.ts +2 -2
  19. package/dist/admin/types.d.ts.map +1 -1
  20. package/dist/admin/types.js.map +1 -1
  21. package/dist/admin/views/types.d.ts +8 -3
  22. package/dist/admin/views/types.d.ts.map +1 -1
  23. package/dist/admin/views/types.js.map +1 -1
  24. package/dist/auth/baseFields/apiKey.js +1 -1
  25. package/dist/auth/baseFields/apiKey.js.map +1 -1
  26. package/dist/auth/cookies.d.ts +4 -0
  27. package/dist/auth/cookies.d.ts.map +1 -1
  28. package/dist/auth/cookies.js +1 -1
  29. package/dist/auth/cookies.js.map +1 -1
  30. package/dist/auth/operations/forgotPassword.js +1 -1
  31. package/dist/auth/operations/forgotPassword.js.map +1 -1
  32. package/dist/auth/operations/login.d.ts +1 -5
  33. package/dist/auth/operations/login.d.ts.map +1 -1
  34. package/dist/auth/operations/login.js +0 -3
  35. package/dist/auth/operations/login.js.map +1 -1
  36. package/dist/auth/operations/me.d.ts +4 -4
  37. package/dist/auth/operations/me.d.ts.map +1 -1
  38. package/dist/auth/operations/me.js.map +1 -1
  39. package/dist/auth/operations/registerFirstUser.d.ts +1 -9
  40. package/dist/auth/operations/registerFirstUser.d.ts.map +1 -1
  41. package/dist/auth/operations/resetPassword.js +1 -1
  42. package/dist/auth/operations/resetPassword.js.map +1 -1
  43. package/dist/auth/strategies/apiKey.d.ts.map +1 -1
  44. package/dist/auth/strategies/apiKey.js +2 -0
  45. package/dist/auth/strategies/apiKey.js.map +1 -1
  46. package/dist/auth/strategies/local/incrementLoginAttempts.d.ts.map +1 -1
  47. package/dist/auth/strategies/local/incrementLoginAttempts.js +2 -0
  48. package/dist/auth/strategies/local/incrementLoginAttempts.js.map +1 -1
  49. package/dist/auth/strategies/local/register.d.ts.map +1 -1
  50. package/dist/auth/strategies/local/register.js +3 -0
  51. package/dist/auth/strategies/local/register.js.map +1 -1
  52. package/dist/auth/strategies/local/resetLoginAttempts.d.ts.map +1 -1
  53. package/dist/auth/strategies/local/resetLoginAttempts.js +1 -0
  54. package/dist/auth/strategies/local/resetLoginAttempts.js.map +1 -1
  55. package/dist/auth/types.d.ts +6 -1
  56. package/dist/auth/types.d.ts.map +1 -1
  57. package/dist/auth/types.js.map +1 -1
  58. package/dist/collections/config/client.d.ts +311 -0
  59. package/dist/collections/config/client.d.ts.map +1 -0
  60. package/dist/collections/config/client.js +56 -0
  61. package/dist/collections/config/client.js.map +1 -0
  62. package/dist/collections/config/defaults.d.ts +5 -5
  63. package/dist/collections/config/sanitize.d.ts.map +1 -1
  64. package/dist/collections/config/sanitize.js +4 -0
  65. package/dist/collections/config/sanitize.js.map +1 -1
  66. package/dist/collections/config/schema.d.ts.map +1 -1
  67. package/dist/collections/config/schema.js +0 -3
  68. package/dist/collections/config/schema.js.map +1 -1
  69. package/dist/collections/config/types.d.ts +4 -36
  70. package/dist/collections/config/types.d.ts.map +1 -1
  71. package/dist/collections/config/types.js.map +1 -1
  72. package/dist/collections/operations/create.d.ts +1 -9
  73. package/dist/collections/operations/create.d.ts.map +1 -1
  74. package/dist/collections/operations/delete.d.ts +2 -10
  75. package/dist/collections/operations/delete.d.ts.map +1 -1
  76. package/dist/collections/operations/duplicate.d.ts +14 -0
  77. package/dist/collections/operations/duplicate.d.ts.map +1 -0
  78. package/dist/collections/operations/duplicate.js +275 -0
  79. package/dist/collections/operations/duplicate.js.map +1 -0
  80. package/dist/collections/operations/find.d.ts.map +1 -1
  81. package/dist/collections/operations/findByID.d.ts.map +1 -1
  82. package/dist/collections/operations/findVersionByID.d.ts.map +1 -1
  83. package/dist/collections/operations/findVersions.d.ts.map +1 -1
  84. package/dist/collections/operations/local/create.js +1 -1
  85. package/dist/collections/operations/local/create.js.map +1 -1
  86. package/dist/collections/operations/local/duplicate.d.ts +21 -0
  87. package/dist/collections/operations/local/duplicate.d.ts.map +1 -0
  88. package/dist/collections/operations/local/duplicate.js +22 -0
  89. package/dist/collections/operations/local/duplicate.js.map +1 -0
  90. package/dist/collections/operations/local/index.d.ts +7 -5
  91. package/dist/collections/operations/local/index.d.ts.map +1 -1
  92. package/dist/collections/operations/local/index.js +2 -0
  93. package/dist/collections/operations/local/index.js.map +1 -1
  94. package/dist/collections/operations/local/update.js +1 -1
  95. package/dist/collections/operations/local/update.js.map +1 -1
  96. package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
  97. package/dist/collections/operations/update.d.ts +1 -5
  98. package/dist/collections/operations/update.d.ts.map +1 -1
  99. package/dist/collections/operations/updateByID.d.ts +1 -9
  100. package/dist/collections/operations/updateByID.d.ts.map +1 -1
  101. package/dist/collections/operations/utils.d.ts +1 -1
  102. package/dist/collections/operations/utils.d.ts.map +1 -1
  103. package/dist/config/client.d.ts +14 -0
  104. package/dist/config/client.d.ts.map +1 -0
  105. package/dist/config/client.js +59 -0
  106. package/dist/config/client.js.map +1 -0
  107. package/dist/config/defaults.d.ts.map +1 -1
  108. package/dist/config/defaults.js +0 -2
  109. package/dist/config/defaults.js.map +1 -1
  110. package/dist/config/load.d.ts.map +1 -1
  111. package/dist/config/load.js +3 -4
  112. package/dist/config/load.js.map +1 -1
  113. package/dist/config/schema.d.ts.map +1 -1
  114. package/dist/config/schema.js +0 -2
  115. package/dist/config/schema.js.map +1 -1
  116. package/dist/config/types.d.ts +23 -20
  117. package/dist/config/types.d.ts.map +1 -1
  118. package/dist/config/types.js.map +1 -1
  119. package/dist/config/validate.d.ts +1 -2
  120. package/dist/config/validate.d.ts.map +1 -1
  121. package/dist/config/validate.js +3 -4
  122. package/dist/config/validate.js.map +1 -1
  123. package/dist/database/types.d.ts +2 -2
  124. package/dist/database/types.d.ts.map +1 -1
  125. package/dist/database/types.js.map +1 -1
  126. package/dist/exports/config.d.ts +4 -1
  127. package/dist/exports/config.d.ts.map +1 -1
  128. package/dist/exports/config.js +4 -1
  129. package/dist/exports/config.js.map +1 -1
  130. package/dist/exports/operations.d.ts +1 -0
  131. package/dist/exports/operations.d.ts.map +1 -1
  132. package/dist/exports/operations.js +1 -0
  133. package/dist/exports/operations.js.map +1 -1
  134. package/dist/exports/types.d.ts +9 -4
  135. package/dist/exports/types.d.ts.map +1 -1
  136. package/dist/exports/types.js.map +1 -1
  137. package/dist/exports/uploads.d.ts +2 -0
  138. package/dist/exports/uploads.d.ts.map +1 -0
  139. package/dist/exports/uploads.js +3 -0
  140. package/dist/exports/uploads.js.map +1 -0
  141. package/dist/exports/utilities.d.ts +4 -1
  142. package/dist/exports/utilities.d.ts.map +1 -1
  143. package/dist/exports/utilities.js +4 -1
  144. package/dist/exports/utilities.js.map +1 -1
  145. package/dist/fields/config/client.d.ts +1272 -0
  146. package/dist/{config/createClientConfig.d.ts.map → fields/config/client.d.ts.map} +1 -1
  147. package/dist/fields/config/client.js +54 -0
  148. package/dist/fields/config/client.js.map +1 -0
  149. package/dist/fields/config/sanitize.d.ts.map +1 -1
  150. package/dist/fields/config/sanitize.js +2 -0
  151. package/dist/fields/config/sanitize.js.map +1 -1
  152. package/dist/fields/config/schema.d.ts.map +1 -1
  153. package/dist/fields/config/schema.js +1 -2
  154. package/dist/fields/config/schema.js.map +1 -1
  155. package/dist/fields/config/types.d.ts +25 -6
  156. package/dist/fields/config/types.d.ts.map +1 -1
  157. package/dist/fields/config/types.js +1 -1
  158. package/dist/fields/config/types.js.map +1 -1
  159. package/dist/fields/hooks/afterChange/index.d.ts.map +1 -1
  160. package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
  161. package/dist/fields/hooks/beforeValidate/index.d.ts +2 -1
  162. package/dist/fields/hooks/beforeValidate/index.d.ts.map +1 -1
  163. package/dist/fields/hooks/beforeValidate/index.js +2 -1
  164. package/dist/fields/hooks/beforeValidate/index.js.map +1 -1
  165. package/dist/fields/hooks/beforeValidate/promise.d.ts +2 -1
  166. package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
  167. package/dist/fields/hooks/beforeValidate/promise.js +30 -1
  168. package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
  169. package/dist/fields/hooks/beforeValidate/traverseFields.d.ts +2 -1
  170. package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
  171. package/dist/fields/hooks/beforeValidate/traverseFields.js +2 -1
  172. package/dist/fields/hooks/beforeValidate/traverseFields.js.map +1 -1
  173. package/dist/fields/setDefaultBeforeDuplicate.d.ts +3 -0
  174. package/dist/fields/setDefaultBeforeDuplicate.d.ts.map +1 -0
  175. package/dist/fields/setDefaultBeforeDuplicate.js +23 -0
  176. package/dist/fields/setDefaultBeforeDuplicate.js.map +1 -0
  177. package/dist/fields/validations.d.ts +3 -3
  178. package/dist/globals/config/client.d.ts +14 -0
  179. package/dist/globals/config/client.d.ts.map +1 -0
  180. package/dist/globals/config/client.js +42 -0
  181. package/dist/globals/config/client.js.map +1 -0
  182. package/dist/globals/config/types.d.ts +2 -21
  183. package/dist/globals/config/types.d.ts.map +1 -1
  184. package/dist/globals/config/types.js.map +1 -1
  185. package/dist/globals/operations/findOne.d.ts.map +1 -1
  186. package/dist/globals/operations/findVersionByID.d.ts.map +1 -1
  187. package/dist/globals/operations/findVersions.d.ts.map +1 -1
  188. package/dist/globals/operations/restoreVersion.d.ts.map +1 -1
  189. package/dist/globals/operations/update.d.ts +1 -9
  190. package/dist/globals/operations/update.d.ts.map +1 -1
  191. package/dist/index.d.ts +16 -14
  192. package/dist/index.d.ts.map +1 -1
  193. package/dist/index.js +13 -9
  194. package/dist/index.js.map +1 -1
  195. package/dist/preferences/operations/findOne.d.ts.map +1 -1
  196. package/dist/preferences/operations/findOne.js +3 -7
  197. package/dist/preferences/operations/findOne.js.map +1 -1
  198. package/dist/preferences/types.d.ts +5 -4
  199. package/dist/preferences/types.d.ts.map +1 -1
  200. package/dist/preferences/types.js.map +1 -1
  201. package/dist/uploads/generateFileData.d.ts.map +1 -1
  202. package/dist/uploads/generateFileData.js +1 -1
  203. package/dist/uploads/generateFileData.js.map +1 -1
  204. package/dist/uploads/getFileByPath.d.ts +1 -2
  205. package/dist/uploads/getFileByPath.d.ts.map +1 -1
  206. package/dist/uploads/getFileByPath.js +1 -2
  207. package/dist/uploads/getFileByPath.js.map +1 -1
  208. package/dist/utilities/createLocalReq.d.ts +1 -1
  209. package/dist/utilities/createLocalReq.d.ts.map +1 -1
  210. package/dist/utilities/createLocalReq.js +20 -23
  211. package/dist/utilities/createLocalReq.js.map +1 -1
  212. package/dist/utilities/fieldSchemaToJSON.d.ts +2 -2
  213. package/dist/utilities/fieldSchemaToJSON.d.ts.map +1 -1
  214. package/dist/utilities/fieldSchemaToJSON.js +20 -10
  215. package/dist/utilities/fieldSchemaToJSON.js.map +1 -1
  216. package/dist/utilities/flattenTopLevelFields.d.ts +2 -1
  217. package/dist/utilities/flattenTopLevelFields.d.ts.map +1 -1
  218. package/dist/utilities/flattenTopLevelFields.js +1 -1
  219. package/dist/utilities/flattenTopLevelFields.js.map +1 -1
  220. package/dist/utilities/getEntityPolicies.js +3 -3
  221. package/dist/utilities/getEntityPolicies.js.map +1 -1
  222. package/dist/utilities/getObjectDotNotation.d.ts.map +1 -1
  223. package/dist/utilities/mergeListSearchAndWhere.d.ts +12 -0
  224. package/dist/utilities/mergeListSearchAndWhere.d.ts.map +1 -0
  225. package/dist/utilities/mergeListSearchAndWhere.js +57 -0
  226. package/dist/utilities/mergeListSearchAndWhere.js.map +1 -0
  227. package/dist/utilities/sanitizeInternalFields.d.ts.map +1 -1
  228. package/dist/utilities/telemetry/events/adminInit.d.ts +1 -1
  229. package/dist/utilities/telemetry/events/adminInit.d.ts.map +1 -1
  230. package/dist/utilities/telemetry/events/adminInit.js +1 -1
  231. package/dist/utilities/telemetry/events/adminInit.js.map +1 -1
  232. package/dist/utilities/telemetry/oneWayHash.d.ts +1 -0
  233. package/dist/utilities/telemetry/oneWayHash.d.ts.map +1 -1
  234. package/dist/utilities/wait.d.ts +1 -2
  235. package/dist/utilities/wait.d.ts.map +1 -1
  236. package/dist/utilities/wait.js +1 -2
  237. package/dist/utilities/wait.js.map +1 -1
  238. package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts.map +1 -1
  239. package/dist/versions/drafts/replaceWithDraftIfAvailable.js +1 -0
  240. package/dist/versions/drafts/replaceWithDraftIfAvailable.js.map +1 -1
  241. package/dist/versions/enforceMaxVersions.d.ts.map +1 -1
  242. package/dist/versions/enforceMaxVersions.js +1 -0
  243. package/dist/versions/enforceMaxVersions.js.map +1 -1
  244. package/dist/versions/getLatestCollectionVersion.d.ts.map +1 -1
  245. package/dist/versions/getLatestCollectionVersion.js +2 -0
  246. package/dist/versions/getLatestCollectionVersion.js.map +1 -1
  247. package/dist/versions/getLatestGlobalVersion.d.ts.map +1 -1
  248. package/dist/versions/getLatestGlobalVersion.js +1 -0
  249. package/dist/versions/getLatestGlobalVersion.js.map +1 -1
  250. package/dist/versions/saveVersion.d.ts.map +1 -1
  251. package/dist/versions/saveVersion.js +1 -0
  252. package/dist/versions/saveVersion.js.map +1 -1
  253. package/operations.d.ts +1 -0
  254. package/operations.js +1 -0
  255. package/package.json +3 -3
  256. package/types.d.ts +9 -4
  257. package/uploads.d.ts +2 -0
  258. package/uploads.js +3 -0
  259. package/utilities.d.ts +4 -1
  260. package/utilities.js +4 -1
  261. package/components.d.ts +0 -14
  262. package/components.js +0 -71
  263. package/dist/config/createClientConfig.d.ts +0 -1246
  264. package/dist/config/createClientConfig.js +0 -175
  265. package/dist/config/createClientConfig.js.map +0 -1
  266. package/dist/localization/middleware.d.ts +0 -5
  267. package/dist/localization/middleware.d.ts.map +0 -1
  268. package/dist/localization/middleware.js +0 -37
  269. package/dist/localization/middleware.js.map +0 -1
  270. package/dist/localization/sanitizeFallbackLocale.d.ts +0 -3
  271. package/dist/localization/sanitizeFallbackLocale.d.ts.map +0 -1
  272. package/dist/localization/sanitizeFallbackLocale.js +0 -9
  273. package/dist/localization/sanitizeFallbackLocale.js.map +0 -1
  274. package/graphql.d.ts +0 -3
  275. package/graphql.js +0 -27
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/fields/config/types.ts"],"sourcesContent":["/* eslint-disable no-use-before-define */\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 React from 'react'\n\nimport type {\n ConditionalDateProps,\n Description,\n ErrorProps,\n LabelProps,\n RichTextAdapter,\n RowLabel,\n} from '../../admin/types.js'\nimport type { User } from '../../auth/index.js'\nimport type { SanitizedCollectionConfig, TypeWithID } from '../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../globals/config/types.js'\nimport type { Operation, PayloadRequest, RequestContext, Where } from '../../types/index.js'\n\nexport type FieldHookArgs<T extends TypeWithID = any, P = any, S = 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<T>\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?: T\n /** The document before changes were applied, only in `afterChange` hooks. */\n previousDoc?: T\n /** The sibling data of the document before changes being applied, only in `beforeChange` and `afterChange` hook. */\n previousSiblingDoc?: T\n /** The previous value of the field, before changes, only in `beforeChange` and `afterChange` hooks. */\n previousValue?: P\n /** The Express request object. It is mocked for Local API operations. */\n req: PayloadRequest\n /** The sibling data passed to a field that the hook is running against. */\n siblingData: Partial<S>\n /** The value of the field. */\n value?: P\n}\n\nexport type FieldHook<T extends TypeWithID = any, P = any, S = any> = (\n args: FieldHookArgs<T, P, S>,\n) => P | Promise<P>\n\nexport type FieldAccess<T extends TypeWithID = any, P = any, U = 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<T>\n /**\n * The original data of the document before the `update` is applied. `doc` is undefined during the `create` operation.\n */\n doc?: T\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 `Express` request object containing the currently authenticated `user` */\n req: PayloadRequest<U>\n /** The `payload` object to interface with the payload API */\n siblingData?: Partial<P>\n}) => Promise<boolean> | boolean\n\nexport type Condition<T extends TypeWithID = any, P = any> = (\n data: Partial<T>,\n siblingData: Partial<P>,\n { user }: { user: User },\n) => boolean\n\nexport type FilterOptionsProps<T = any> = {\n data: T\n id: number | string\n relationTo: string\n siblingData: unknown\n user: Partial<User>\n}\n\nexport type FilterOptions<T = any> =\n | ((options: FilterOptionsProps<T>) => Promise<Where | boolean> | Where | boolean)\n | Where\n | null\n\ntype Admin = {\n className?: string\n components?: {\n Cell?: React.ComponentType<any>\n Field?: React.ComponentType<any>\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 description?: Description\n disableBulkEdit?: 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: Record<string, string> | string\n singular: Record<string, string> | string\n}\n\nexport type BaseValidateOptions<TData, TSiblingData> = {\n data: Partial<TData>\n id?: number | string\n operation?: Operation\n req: PayloadRequest\n siblingData: Partial<TSiblingData>\n}\n\nexport type ValidateOptions<TData, TSiblingData, TFieldConfig extends object> = BaseValidateOptions<\n TData,\n TSiblingData\n> &\n TFieldConfig\n\nexport type Validate<\n TValue = any,\n TData = any,\n TSiblingData = any,\n TFieldConfig extends object = {},\n> = (\n value: TValue,\n options: ValidateOptions<TData, TSiblingData, TFieldConfig>,\n) => Promise<string | true> | string | true\n\nexport type ClientValidate = Omit<Validate, 'req'>\n\nexport type OptionObject = {\n label: Record<string, string> | string\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. */\n custom?: Record<string, any>\n defaultValue?: any\n hidden?: boolean\n hooks?: {\n afterChange?: FieldHook[]\n afterRead?: FieldHook[]\n beforeChange?: FieldHook[]\n beforeValidate?: FieldHook[]\n }\n index?: boolean\n label?: Record<string, string> | false | string\n localized?: boolean\n name: string\n required?: boolean\n saveToJWT?: boolean | string\n unique?: boolean\n validate?: Validate\n}\n\nexport type NumberField = FieldBase & {\n admin?: Admin & {\n /** Set this property to a string that will be used for browser autocomplete. */\n autoComplete?: string\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n afterInput?: React.ComponentType<any>[]\n beforeInput?: React.ComponentType<any>[]\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 }\n /** Maximum value accepted. Used in the default `validation` function. */\n max?: number\n /** Minimum value accepted. Used in the default `validation` function. */\n min?: number\n type: 'number'\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\nexport type TextField = FieldBase & {\n admin?: Admin & {\n autoComplete?: string\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n afterInput?: React.ComponentType<any>[]\n beforeInput?: React.ComponentType<any>[]\n }\n placeholder?: Record<string, string> | string\n rtl?: boolean\n }\n maxLength?: number\n minLength?: number\n type: 'text'\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\nexport type EmailField = FieldBase & {\n admin?: Admin & {\n autoComplete?: string\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n afterInput?: React.ComponentType<any>[]\n beforeInput?: React.ComponentType<any>[]\n }\n placeholder?: Record<string, string> | string\n }\n type: 'email'\n}\n\nexport type TextareaField = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n afterInput?: React.ComponentType<any>[]\n beforeInput?: React.ComponentType<any>[]\n }\n placeholder?: Record<string, string> | string\n rows?: number\n rtl?: boolean\n }\n maxLength?: number\n minLength?: number\n type: 'textarea'\n}\n\nexport type CheckboxField = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n afterInput?: React.ComponentType<any>[]\n beforeInput?: React.ComponentType<any>[]\n }\n }\n type: 'checkbox'\n}\n\nexport type DateField = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n afterInput?: React.ComponentType<any>[]\n beforeInput?: React.ComponentType<any>[]\n }\n date?: ConditionalDateProps\n placeholder?: Record<string, string> | string\n }\n type: 'date'\n}\n\nexport type GroupField = Omit<FieldBase, 'required' | 'validation'> & {\n admin?: Admin & {\n hideGutter?: boolean\n }\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 among collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n type: 'group'\n}\n\nexport type RowAdmin = Omit<Admin, 'description'>\n\nexport type RowField = Omit<FieldBase, 'admin' | 'label' | 'name'> & {\n admin?: RowAdmin\n fields: Field[]\n type: 'row'\n}\n\nexport type CollapsibleField = Omit<FieldBase, 'label' | 'name'> & {\n admin?: Admin & {\n initCollapsed?: boolean\n }\n fields: Field[]\n label: RowLabel\n type: 'collapsible'\n}\n\nexport type TabsAdmin = Omit<Admin, 'description'>\n\ntype TabBase = Omit<FieldBase, 'required' | 'validation'> & {\n description?: Description\n fields: Field[]\n interfaceName?: string\n saveToJWT?: boolean | string\n}\n\nexport type NamedTab = TabBase & {\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 among collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n}\n\nexport type UnnamedTab = Omit<TabBase, 'name'> & {\n interfaceName?: never\n label: Record<string, string> | string\n localized?: never\n}\n\nexport type Tab = NamedTab | UnnamedTab\n\nexport type TabsField = Omit<FieldBase, 'admin' | 'localized' | 'name' | 'saveToJWT'> & {\n admin?: TabsAdmin\n tabs: Tab[]\n type: 'tabs'\n}\n\nexport type TabAsField = Tab & {\n name?: string\n type: 'tab'\n}\n\nexport type UIField = {\n admin: {\n components?: {\n Cell?: React.ComponentType<any>\n Field: React.ComponentType<any>\n Filter?: React.ComponentType<any>\n }\n condition?: Condition\n disableBulkEdit?: boolean\n position?: string\n width?: string\n }\n /** Extension point to add your custom data. */\n custom?: Record<string, any>\n label?: Record<string, string> | string\n name: string\n type: 'ui'\n}\n\nexport type UploadField = FieldBase & {\n admin?: {\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n }\n }\n filterOptions?: FilterOptions\n maxDepth?: number\n relationTo: string\n type: 'upload'\n}\n\ntype CodeAdmin = Admin & {\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n }\n editorOptions?: EditorProps['options']\n language?: string\n}\n\nexport type CodeField = Omit<FieldBase, 'admin'> & {\n admin?: CodeAdmin\n maxLength?: number\n minLength?: number\n type: 'code'\n}\n\ntype JSONAdmin = Admin & {\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n }\n editorOptions?: EditorProps['options']\n}\n\nexport type JSONField = Omit<FieldBase, 'admin'> & {\n admin?: JSONAdmin\n type: 'json'\n}\n\nexport type SelectField = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n }\n isClearable?: boolean\n isSortable?: boolean\n }\n hasMany?: boolean\n options: Option[]\n type: 'select'\n}\n\ntype SharedRelationshipProperties = FieldBase & {\n filterOptions?: FilterOptions\n hasMany?: boolean\n maxDepth?: number\n type: 'relationship'\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\ntype RelationshipAdmin = Admin & {\n allowCreate?: boolean\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n }\n isSortable?: boolean\n}\nexport type PolymorphicRelationshipField = SharedRelationshipProperties & {\n admin?: RelationshipAdmin & {\n sortOptions?: { [collectionSlug: string]: string }\n }\n relationTo: string[]\n}\nexport type SingleRelationshipField = SharedRelationshipProperties & {\n admin?: RelationshipAdmin & {\n sortOptions?: string\n }\n relationTo: string\n}\nexport type RelationshipField = PolymorphicRelationshipField | SingleRelationshipField\n\nexport type ValueWithRelation = {\n relationTo: string\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 = {},\n> = FieldBase & {\n admin?: Admin\n editor?: RichTextAdapter<Value, AdapterProps, AdapterProps>\n type: 'richText'\n} & ExtraProperties\n\nexport type ArrayField = FieldBase & {\n admin?: Admin & {\n components?: {\n RowLabel?: RowLabel\n } & Admin['components']\n initCollapsed?: boolean\n }\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 among collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n labels?: Labels\n maxRows?: number\n minRows?: number\n type: 'array'\n}\n\nexport type RadioField = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n }\n layout?: 'horizontal' | 'vertical'\n }\n options: Option[]\n type: 'radio'\n}\n\nexport type Block = {\n /** Extension point to add your custom data. */\n custom?: Record<string, any>\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 among collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n labels?: Labels\n slug: string\n}\n\nexport type BlockField = FieldBase & {\n admin?: Admin & {\n initCollapsed?: boolean\n }\n blocks: Block[]\n defaultValue?: unknown\n labels?: Labels\n maxRows?: number\n minRows?: number\n type: 'blocks'\n}\n\nexport type PointField = FieldBase & {\n type: 'point'\n}\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 ClientConfigField = Omit<Field, 'access' | 'defaultValue' | 'hooks' | 'validate'>\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 = Field & {\n path?: string\n}\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: 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(field: Field | TabAsField): field is UIField {\n return field.type === 'ui'\n}\n\nexport function fieldAffectsData(field: Field | TabAsField): 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,uCAAuC,GAogBvC,OAAO,SAASA,yBAAyBC,KAAc;IACrD,OAAOA,UAAU,QAAQ,OAAOA,UAAU,YAAY,gBAAgBA,SAAS,WAAWA;AAC5F;AAuKA,OAAO,SAASC,kBAAkBC,KAAY;IAC5C,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,SAAS,CAAC,EAAE,KAAK;AAC3D;AAEA,OAAO,SAASG,cAAcL,MAAc;IAC1C,OAAO,OAAOA,WAAW;AAC3B;AAEA,OAAO,SAASM,kBAAkBZ,KAAY;IAC5C,OAAOA,MAAMC,IAAI,KAAK,YAAYD,MAAMC,IAAI,KAAK;AACnD;AAEA,OAAO,SAASY,iBAAiBb,KAAY;IAC3C,OACE,AAACA,CAAAA,MAAMC,IAAI,KAAK,YAAYD,MAAMC,IAAI,KAAK,cAAa,KAAM,OAAOD,MAAMc,QAAQ,KAAK;AAE5F;AAEA,OAAO,SAASC,0BAA0Bf,KAAyB;IACjE,OAAOA,MAAMC,IAAI,KAAK;AACxB;AAEA,OAAO,SAASe,iBAAiBhB,KAAyB;IACxD,OAAO,UAAUA,SAAS,CAACe,0BAA0Bf;AACvD;AAEA,OAAO,SAASiB,WAAWC,GAAQ;IACjC,OAAO,UAAUA;AACnB;AAEA,OAAO,SAASC,iBAAiBnB,KAAkB;IACjD,OAAO,eAAeA,SAASA,MAAMoB,SAAS;AAChD"}
1
+ {"version":3,"sources":["../../../src/fields/config/types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/* eslint-disable no-use-before-define */\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 React from 'react'\n\nimport type {\n ConditionalDateProps,\n Description,\n ErrorProps,\n LabelProps,\n RichTextAdapter,\n RowLabel,\n} from '../../admin/types.js'\nimport type { User } from '../../auth/index.js'\nimport type { SanitizedCollectionConfig, TypeWithID } from '../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../globals/config/types.js'\nimport type { Operation, PayloadRequest, RequestContext, Where } from '../../types/index.js'\nimport type { ClientFieldConfig } from './client.js'\n\nexport type FieldHookArgs<T extends TypeWithID = any, P = any, S = 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<T>\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?: T\n /** The document before changes were applied, only in `afterChange` hooks. */\n previousDoc?: T\n /** The sibling data of the document before changes being applied, only in `beforeChange` and `afterChange` hook. */\n previousSiblingDoc?: T\n /** The previous value of the field, before changes, only in `beforeChange` and `afterChange` hooks. */\n previousValue?: P\n /** The Express request object. It is mocked for Local API operations. */\n req: PayloadRequest\n /** The sibling data passed to a field that the hook is running against. */\n siblingData: Partial<S>\n /** The value of the field. */\n value?: P\n}\n\nexport type FieldHook<T extends TypeWithID = any, P = any, S = any> = (\n args: FieldHookArgs<T, P, S>,\n) => P | Promise<P>\n\nexport type FieldAccess<T extends TypeWithID = any, P = any, U = 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<T>\n /**\n * The original data of the document before the `update` is applied. `doc` is undefined during the `create` operation.\n */\n doc?: T\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 `Express` request object containing the currently authenticated `user` */\n req: PayloadRequest<U>\n /** The `payload` object to interface with the payload API */\n siblingData?: Partial<P>\n}) => Promise<boolean> | boolean\n\nexport type Condition<T extends TypeWithID = any, P = any> = (\n data: Partial<T>,\n siblingData: Partial<P>,\n { user }: { user: User },\n) => boolean\n\nexport type FilterOptionsProps<T = any> = {\n /**\n * An object containing the full collection or global document currently being edited.\n */\n data: T\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: string\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<User>\n}\n\nexport type FilterOptions<T = any> =\n | ((options: FilterOptionsProps<T>) => Promise<Where | boolean> | Where | boolean)\n | Where\n | null\n\ntype Admin = {\n className?: string\n components?: {\n Cell?: React.ComponentType<any>\n Field?: React.ComponentType<any>\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 description?: Description\n disableBulkEdit?: 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: Record<string, string> | string\n singular: Record<string, string> | string\n}\n\nexport type BaseValidateOptions<TData, TSiblingData> = {\n data: Partial<TData>\n id?: number | string\n operation?: Operation\n req: PayloadRequest\n siblingData: Partial<TSiblingData>\n}\n\nexport type ValidateOptions<TData, TSiblingData, TFieldConfig extends object> = BaseValidateOptions<\n TData,\n TSiblingData\n> &\n 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>,\n) => Promise<string | true> | string | true\n\nexport type ClientValidate = Omit<Validate, 'req'>\n\nexport type OptionObject = {\n label: Record<string, string> | string\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. */\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?: Record<string, string> | false | string\n localized?: boolean\n name: string\n required?: boolean\n saveToJWT?: boolean | string\n unique?: boolean\n validate?: Validate\n}\n\nexport type NumberField = FieldBase & {\n admin?: Admin & {\n /** Set this property to a string that will be used for browser autocomplete. */\n autoComplete?: string\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n afterInput?: React.ComponentType<any>[]\n beforeInput?: React.ComponentType<any>[]\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 }\n /** Maximum value accepted. Used in the default `validation` function. */\n max?: number\n /** Minimum value accepted. Used in the default `validation` function. */\n min?: number\n type: 'number'\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\nexport type TextField = FieldBase & {\n admin?: Admin & {\n autoComplete?: string\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n afterInput?: React.ComponentType<any>[]\n beforeInput?: React.ComponentType<any>[]\n }\n placeholder?: Record<string, string> | string\n rtl?: boolean\n }\n maxLength?: number\n minLength?: number\n type: 'text'\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\nexport type EmailField = FieldBase & {\n admin?: Admin & {\n autoComplete?: string\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n afterInput?: React.ComponentType<any>[]\n beforeInput?: React.ComponentType<any>[]\n }\n placeholder?: Record<string, string> | string\n }\n type: 'email'\n}\n\nexport type TextareaField = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n afterInput?: React.ComponentType<any>[]\n beforeInput?: React.ComponentType<any>[]\n }\n placeholder?: Record<string, string> | string\n rows?: number\n rtl?: boolean\n }\n maxLength?: number\n minLength?: number\n type: 'textarea'\n}\n\nexport type CheckboxField = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n afterInput?: React.ComponentType<any>[]\n beforeInput?: React.ComponentType<any>[]\n }\n }\n type: 'checkbox'\n}\n\nexport type DateField = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n afterInput?: React.ComponentType<any>[]\n beforeInput?: React.ComponentType<any>[]\n }\n date?: ConditionalDateProps\n placeholder?: Record<string, string> | string\n }\n type: 'date'\n}\n\nexport type GroupField = Omit<FieldBase, 'required' | 'validation'> & {\n admin?: Admin & {\n hideGutter?: boolean\n }\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 among collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n type: 'group'\n}\n\nexport type RowAdmin = Omit<Admin, 'description'>\n\nexport type RowField = Omit<FieldBase, 'admin' | 'label' | 'name'> & {\n admin?: RowAdmin\n fields: Field[]\n type: 'row'\n}\n\nexport type CollapsibleField = Omit<FieldBase, 'label' | 'name'> & {\n admin?: Admin & {\n initCollapsed?: boolean\n }\n fields: Field[]\n label: RowLabel\n type: 'collapsible'\n}\n\nexport type TabsAdmin = Omit<Admin, 'description'>\n\ntype TabBase = Omit<FieldBase, 'required' | 'validation'> & {\n description?: Description\n fields: Field[]\n interfaceName?: string\n saveToJWT?: boolean | string\n}\n\nexport type NamedTab = TabBase & {\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 among collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n}\n\nexport type UnnamedTab = Omit<TabBase, 'name'> & {\n interfaceName?: never\n label: Record<string, string> | string\n localized?: never\n}\n\nexport type Tab = NamedTab | UnnamedTab\n\nexport type TabsField = Omit<FieldBase, 'admin' | 'localized' | 'name' | 'saveToJWT'> & {\n admin?: TabsAdmin\n tabs: Tab[]\n type: 'tabs'\n}\n\nexport type TabAsField = Tab & {\n name?: string\n type: 'tab'\n}\n\nexport type UIField = {\n admin: {\n components?: {\n Cell?: React.ComponentType<any>\n Field: React.ComponentType<any>\n Filter?: React.ComponentType<any>\n }\n condition?: Condition\n disableBulkEdit?: boolean\n position?: string\n width?: string\n }\n /** Extension point to add your custom data. */\n custom?: Record<string, any>\n label?: Record<string, string> | string\n name: string\n type: 'ui'\n}\n\nexport type UploadField = FieldBase & {\n admin?: {\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n }\n }\n filterOptions?: FilterOptions\n maxDepth?: number\n relationTo: string\n type: 'upload'\n}\n\ntype CodeAdmin = Admin & {\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n }\n editorOptions?: EditorProps['options']\n language?: string\n}\n\nexport type CodeField = Omit<FieldBase, 'admin'> & {\n admin?: CodeAdmin\n maxLength?: number\n minLength?: number\n type: 'code'\n}\n\ntype JSONAdmin = Admin & {\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n }\n editorOptions?: EditorProps['options']\n}\n\nexport type JSONField = Omit<FieldBase, 'admin'> & {\n admin?: JSONAdmin\n type: 'json'\n}\n\nexport type SelectField = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n }\n isClearable?: boolean\n isSortable?: boolean\n }\n hasMany?: boolean\n options: Option[]\n type: 'select'\n}\n\ntype SharedRelationshipProperties = FieldBase & {\n filterOptions?: FilterOptions\n hasMany?: boolean\n maxDepth?: number\n type: 'relationship'\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\ntype RelationshipAdmin = Admin & {\n allowCreate?: boolean\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n }\n isSortable?: boolean\n}\nexport type PolymorphicRelationshipField = SharedRelationshipProperties & {\n admin?: RelationshipAdmin & {\n sortOptions?: { [collectionSlug: string]: string }\n }\n relationTo: string[]\n}\nexport type SingleRelationshipField = SharedRelationshipProperties & {\n admin?: RelationshipAdmin & {\n sortOptions?: string\n }\n relationTo: string\n}\nexport type RelationshipField = PolymorphicRelationshipField | SingleRelationshipField\n\nexport type ValueWithRelation = {\n relationTo: string\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> = FieldBase & {\n admin?: Admin\n editor?: RichTextAdapter<Value, AdapterProps, AdapterProps>\n type: 'richText'\n} & ExtraProperties\n\nexport type ArrayField = FieldBase & {\n admin?: Admin & {\n components?: {\n RowLabel?: RowLabel\n } & Admin['components']\n initCollapsed?: boolean\n }\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 among collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n labels?: Labels\n maxRows?: number\n minRows?: number\n type: 'array'\n}\n\nexport type RadioField = FieldBase & {\n admin?: Admin & {\n components?: {\n Error?: React.ComponentType<ErrorProps>\n Label?: React.ComponentType<LabelProps>\n }\n layout?: 'horizontal' | 'vertical'\n }\n options: Option[]\n type: 'radio'\n}\n\nexport type Block = {\n /** Extension point to add your custom data. */\n custom?: Record<string, any>\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 among collections, arrays, groups, blocks, tabs.\n */\n interfaceName?: string\n labels?: Labels\n slug: string\n}\n\nexport type BlockField = FieldBase & {\n admin?: Admin & {\n initCollapsed?: boolean\n }\n blocks: Block[]\n defaultValue?: unknown\n labels?: Labels\n maxRows?: number\n minRows?: number\n type: 'blocks'\n}\n\nexport type PointField = FieldBase & {\n type: 'point'\n}\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 = Field & {\n path?: string\n}\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,GACrD,uCAAuC,GAwhBvC,OAAO,SAASA,yBAAyBC,KAAc;IACrD,OAAOA,UAAU,QAAQ,OAAOA,UAAU,YAAY,gBAAgBA,SAAS,WAAWA;AAC5F;AAqKA,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,SAAS,CAAC,EAAE,KAAK;AAC3D;AAEA,OAAO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A;IAC9B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IACxC,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,WAAW,mJA6BvB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/afterChange/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAK7E,KAAK,IAAI,CAAC,CAAC,IAAI;IACb,UAAU,EAAE,yBAAyB,GAAG,IAAI,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IACjC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IAChC,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAA;IACpC,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IACxC,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,WAAW,6HAUrB,KAAK,CAAC,CAAC,KAAG,QAAQ,CAAC,CAmBrB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeChange/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,cAA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IAAI,CAAA;IACpC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,SAAS,EAAE,SAAS,CAAA;IACpB,GAAG,EAAE,cAAc,CAAA;IACnB,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,YAAY,qJAWtB,KAAK,CAAC,CAAC,KAAG,QAAQ,CAAC,CAgCrB,CAAA"}
@@ -6,12 +6,13 @@ type Args<T> = {
6
6
  context: RequestContext;
7
7
  data: Record<string, unknown> | T;
8
8
  doc?: Record<string, unknown> | T;
9
+ duplicate?: boolean;
9
10
  global: SanitizedGlobalConfig | null;
10
11
  id?: number | string;
11
12
  operation: 'create' | 'update';
12
13
  overrideAccess: boolean;
13
14
  req: PayloadRequest;
14
15
  };
15
- export declare const beforeValidate: <T extends Record<string, unknown>>({ id, collection, context, data: incomingData, doc, global, operation, overrideAccess, req, }: Args<T>) => Promise<T>;
16
+ export declare const beforeValidate: <T extends Record<string, unknown>>({ id, collection, context, data: incomingData, doc, duplicate, global, operation, overrideAccess, req, }: Args<T>) => Promise<T>;
16
17
  export {};
17
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeValidate/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAK7E,KAAK,IAAI,CAAC,CAAC,IAAI;IACb,UAAU,EAAE,yBAAyB,GAAG,IAAI,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IACjC,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAA;IACpC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,cAAc,2JA6B1B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeValidate/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAK7E,KAAK,IAAI,CAAC,CAAC,IAAI;IACb,UAAU,EAAE,yBAAyB,GAAG,IAAI,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IACjC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IACjC,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAA;IACpC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;CACpB,CAAA;AAED,eAAO,MAAM,cAAc,gJAWxB,KAAK,CAAC,CAAC,KAAG,QAAQ,CAAC,CAoBrB,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { deepCopyObject } from '../../../utilities/deepCopyObject.js';
2
2
  import { traverseFields } from './traverseFields.js';
3
- export const beforeValidate = async ({ id, collection, context, data: incomingData, doc, global, operation, overrideAccess, req })=>{
3
+ export const beforeValidate = async ({ id, collection, context, data: incomingData, doc, duplicate = false, global, operation, overrideAccess, req })=>{
4
4
  const data = deepCopyObject(incomingData);
5
5
  await traverseFields({
6
6
  id,
@@ -8,6 +8,7 @@ export const beforeValidate = async ({ id, collection, context, data: incomingDa
8
8
  context,
9
9
  data,
10
10
  doc,
11
+ duplicate,
11
12
  fields: collection?.fields || global?.fields,
12
13
  global,
13
14
  operation,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/index.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequest, RequestContext } from '../../../types/index.js'\n\nimport { deepCopyObject } from '../../../utilities/deepCopyObject.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args<T> = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: Record<string, unknown> | T\n doc?: Record<string, unknown> | T\n global: SanitizedGlobalConfig | null\n id?: number | string\n operation: 'create' | 'update'\n overrideAccess: boolean\n req: PayloadRequest\n}\n\nexport const beforeValidate = async <T extends Record<string, unknown>>({\n id,\n collection,\n context,\n data: incomingData,\n doc,\n global,\n operation,\n overrideAccess,\n req,\n}: Args<T>): Promise<T> => {\n const data = deepCopyObject(incomingData)\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: collection?.fields || global?.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: data,\n siblingDoc: doc,\n })\n\n return data\n}\n"],"names":["deepCopyObject","traverseFields","beforeValidate","id","collection","context","data","incomingData","doc","global","operation","overrideAccess","req","fields","siblingData","siblingDoc"],"mappings":"AAIA,SAASA,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,sBAAqB;AAcpD,OAAO,MAAMC,iBAAiB,OAA0C,EACtEC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,MAAMC,YAAY,EAClBC,GAAG,EACHC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,GAAG,EACK;IACR,MAAMN,OAAON,eAAeO;IAE5B,MAAMN,eAAe;QACnBE;QACAC;QACAC;QACAC;QACAE;QACAK,QAAQT,YAAYS,UAAUJ,QAAQI;QACtCJ;QACAC;QACAC;QACAC;QACAE,aAAaR;QACbS,YAAYP;IACd;IAEA,OAAOF;AACT,EAAC"}
1
+ {"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/index.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequest, RequestContext } from '../../../types/index.js'\n\nimport { deepCopyObject } from '../../../utilities/deepCopyObject.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args<T> = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: Record<string, unknown> | T\n doc?: Record<string, unknown> | T\n duplicate?: boolean\n global: SanitizedGlobalConfig | null\n id?: number | string\n operation: 'create' | 'update'\n overrideAccess: boolean\n req: PayloadRequest\n}\n\nexport const beforeValidate = async <T extends Record<string, unknown>>({\n id,\n collection,\n context,\n data: incomingData,\n doc,\n duplicate = false,\n global,\n operation,\n overrideAccess,\n req,\n}: Args<T>): Promise<T> => {\n const data = deepCopyObject(incomingData)\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n duplicate,\n fields: collection?.fields || global?.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: data,\n siblingDoc: doc,\n })\n\n return data\n}\n"],"names":["deepCopyObject","traverseFields","beforeValidate","id","collection","context","data","incomingData","doc","duplicate","global","operation","overrideAccess","req","fields","siblingData","siblingDoc"],"mappings":"AAIA,SAASA,cAAc,QAAQ,uCAAsC;AACrE,SAASC,cAAc,QAAQ,sBAAqB;AAepD,OAAO,MAAMC,iBAAiB,OAA0C,EACtEC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,MAAMC,YAAY,EAClBC,GAAG,EACHC,YAAY,KAAK,EACjBC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,GAAG,EACK;IACR,MAAMP,OAAON,eAAeO;IAE5B,MAAMN,eAAe;QACnBE;QACAC;QACAC;QACAC;QACAE;QACAC;QACAK,QAAQV,YAAYU,UAAUJ,QAAQI;QACtCJ;QACAC;QACAC;QACAC;QACAE,aAAaT;QACbU,YAAYR;IACd;IAEA,OAAOF;AACT,EAAC"}
@@ -7,6 +7,7 @@ type Args<T> = {
7
7
  context: RequestContext;
8
8
  data: T;
9
9
  doc: T;
10
+ duplicate: boolean;
10
11
  field: Field | TabAsField;
11
12
  global: SanitizedGlobalConfig | null;
12
13
  id?: number | string;
@@ -16,6 +17,6 @@ type Args<T> = {
16
17
  siblingData: Record<string, unknown>;
17
18
  siblingDoc: Record<string, unknown>;
18
19
  };
19
- export declare const promise: <T>({ id, collection, context, data, doc, field, global, operation, overrideAccess, req, siblingData, siblingDoc, }: Args<T>) => Promise<void>;
20
+ export declare const promise: <T>({ id, collection, context, data, doc, duplicate, field, global, operation, overrideAccess, req, siblingData, siblingDoc, }: Args<T>) => Promise<void>;
20
21
  export {};
21
22
  //# sourceMappingURL=promise.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"promise.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeValidate/promise.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7E,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAQ9D,KAAK,IAAI,CAAC,CAAC,IAAI;IACb,UAAU,EAAE,yBAAyB,GAAG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,QAAQ,GAAG,QAAQ,CAAA;IAC9B,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;IACnB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC,CAAA;AASD,eAAO,MAAM,OAAO,kIAcjB,KAAK,CAAC,CAAC,KAAG,QAAQ,IAAI,CA+ZxB,CAAA"}
@@ -9,7 +9,7 @@ import { traverseFields } from './traverseFields.js';
9
9
  // - Execute field access control
10
10
  // - Merge original document data into incoming data
11
11
  // - Compute default values for undefined fields
12
- export const promise = async ({ id, collection, context, data, doc, field, global, operation, overrideAccess, req, siblingData, siblingDoc })=>{
12
+ export const promise = async ({ id, collection, context, data, doc, duplicate, field, global, operation, overrideAccess, req, siblingData, siblingDoc })=>{
13
13
  if (fieldAffectsData(field)) {
14
14
  if (field.name === 'id') {
15
15
  if (field.type === 'number' && typeof siblingData[field.name] === 'string') {
@@ -181,6 +181,29 @@ export const promise = async ({ id, collection, context, data, doc, field, globa
181
181
  });
182
182
  }
183
183
  }
184
+ // Execute beforeDuplicate hook
185
+ if (duplicate && field.hooks?.beforeDuplicate) {
186
+ if (field.hooks?.beforeDuplicate) {
187
+ await field.hooks.beforeDuplicate.reduce(async (priorHook, currentHook)=>{
188
+ await priorHook;
189
+ const hookedValue = await currentHook({
190
+ collection,
191
+ context,
192
+ data,
193
+ field,
194
+ global,
195
+ operation,
196
+ originalDoc: doc,
197
+ req,
198
+ siblingData,
199
+ value: siblingData[field.name]
200
+ });
201
+ if (hookedValue !== undefined) {
202
+ siblingData[field.name] = hookedValue;
203
+ }
204
+ }, Promise.resolve());
205
+ }
206
+ }
184
207
  }
185
208
  // Traverse subfields
186
209
  switch(field.type){
@@ -196,6 +219,7 @@ export const promise = async ({ id, collection, context, data, doc, field, globa
196
219
  context,
197
220
  data,
198
221
  doc,
222
+ duplicate,
199
223
  fields: field.fields,
200
224
  global,
201
225
  operation,
@@ -218,6 +242,7 @@ export const promise = async ({ id, collection, context, data, doc, field, globa
218
242
  context,
219
243
  data,
220
244
  doc,
245
+ duplicate,
221
246
  fields: field.fields,
222
247
  global,
223
248
  operation,
@@ -248,6 +273,7 @@ export const promise = async ({ id, collection, context, data, doc, field, globa
248
273
  context,
249
274
  data,
250
275
  doc,
276
+ duplicate,
251
277
  fields: block.fields,
252
278
  global,
253
279
  operation,
@@ -271,6 +297,7 @@ export const promise = async ({ id, collection, context, data, doc, field, globa
271
297
  context,
272
298
  data,
273
299
  doc,
300
+ duplicate,
274
301
  fields: field.fields,
275
302
  global,
276
303
  operation,
@@ -300,6 +327,7 @@ export const promise = async ({ id, collection, context, data, doc, field, globa
300
327
  context,
301
328
  data,
302
329
  doc,
330
+ duplicate,
303
331
  fields: field.fields,
304
332
  global,
305
333
  operation,
@@ -318,6 +346,7 @@ export const promise = async ({ id, collection, context, data, doc, field, globa
318
346
  context,
319
347
  data,
320
348
  doc,
349
+ duplicate,
321
350
  fields: field.tabs.map((tab)=>({
322
351
  ...tab,
323
352
  type: 'tab'
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/promise.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { fieldAffectsData, tabHasName, valueIsValueWithRelation } from '../../config/types.js'\nimport getValueWithDefault from '../../getDefaultValue.js'\nimport { cloneDataFromOriginalDoc } from '../beforeChange/cloneDataFromOriginalDoc.js'\nimport { getExistingRowDoc } from '../beforeChange/getExistingRowDoc.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args<T> = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: T\n doc: T\n field: Field | TabAsField\n global: SanitizedGlobalConfig | null\n id?: number | string\n operation: 'create' | 'update'\n overrideAccess: boolean\n req: PayloadRequest\n siblingData: Record<string, unknown>\n siblingDoc: Record<string, unknown>\n}\n\n// This function is responsible for the following actions, in order:\n// - Sanitize incoming data\n// - Execute field hooks\n// - Execute field access control\n// - Merge original document data into incoming data\n// - Compute default values for undefined fields\n\nexport const promise = async <T>({\n id,\n collection,\n context,\n data,\n doc,\n field,\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n}: Args<T>): Promise<void> => {\n if (fieldAffectsData(field)) {\n if (field.name === 'id') {\n if (field.type === 'number' && typeof siblingData[field.name] === 'string') {\n const value = siblingData[field.name] as string\n\n siblingData[field.name] = parseFloat(value)\n }\n\n if (\n field.type === 'text' &&\n typeof siblingData[field.name]?.toString === 'function' &&\n typeof siblingData[field.name] !== 'string'\n ) {\n siblingData[field.name] = siblingData[field.name].toString()\n }\n }\n\n // Sanitize incoming data\n switch (field.type) {\n case 'number': {\n if (typeof siblingData[field.name] === 'string') {\n const value = siblingData[field.name] as string\n const trimmed = value.trim()\n siblingData[field.name] = trimmed.length === 0 ? null : parseFloat(trimmed)\n }\n\n break\n }\n\n case 'point': {\n if (Array.isArray(siblingData[field.name])) {\n siblingData[field.name] = (siblingData[field.name] as string[]).map((coordinate, i) => {\n if (typeof coordinate === 'string') {\n const value = siblingData[field.name][i] as string\n const trimmed = value.trim()\n return trimmed.length === 0 ? null : parseFloat(trimmed)\n }\n return coordinate\n })\n }\n\n break\n }\n\n case 'checkbox': {\n if (siblingData[field.name] === 'true') siblingData[field.name] = true\n if (siblingData[field.name] === 'false') siblingData[field.name] = false\n if (siblingData[field.name] === '') siblingData[field.name] = false\n\n break\n }\n\n case 'richText': {\n if (typeof siblingData[field.name] === 'string') {\n try {\n const richTextJSON = JSON.parse(siblingData[field.name] as string)\n siblingData[field.name] = richTextJSON\n } catch {\n // Disregard this data as it is not valid.\n // Will be reported to user by field validation\n }\n }\n\n break\n }\n\n case 'relationship':\n case 'upload': {\n if (\n siblingData[field.name] === '' ||\n siblingData[field.name] === 'none' ||\n siblingData[field.name] === 'null' ||\n siblingData[field.name] === null\n ) {\n if (field.type === 'relationship' && field.hasMany === true) {\n siblingData[field.name] = []\n } else {\n siblingData[field.name] = null\n }\n }\n\n const value = siblingData[field.name]\n\n if (Array.isArray(field.relationTo)) {\n if (Array.isArray(value)) {\n value.forEach((relatedDoc: { relationTo: string; value: unknown }, i) => {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === relatedDoc.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name][i] = {\n ...relatedDoc,\n value: parseFloat(relatedDoc.value as string),\n }\n }\n })\n }\n if (\n field.type === 'relationship' &&\n field.hasMany !== true &&\n valueIsValueWithRelation(value)\n ) {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === value.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name] = { ...value, value: parseFloat(value.value as string) }\n }\n }\n } else {\n if (Array.isArray(value)) {\n value.forEach((relatedDoc: unknown, i) => {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === field.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name][i] = parseFloat(relatedDoc as string)\n }\n })\n }\n if (field.type === 'relationship' && field.hasMany !== true && value) {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === field.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name] = parseFloat(value as string)\n }\n }\n }\n break\n }\n\n case 'array':\n case 'blocks': {\n // Handle cases of arrays being intentionally set to 0\n if (siblingData[field.name] === '0' || siblingData[field.name] === 0) {\n siblingData[field.name] = []\n }\n\n break\n }\n\n default: {\n break\n }\n }\n\n // Execute hooks\n if (field.hooks?.beforeValidate) {\n await field.hooks.beforeValidate.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 req,\n siblingData,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n\n // Execute access control\n if (field.access && field.access[operation]) {\n const result = overrideAccess\n ? true\n : await field.access[operation]({ id, data, doc, req, siblingData })\n\n if (!result) {\n delete siblingData[field.name]\n }\n }\n\n if (typeof siblingData[field.name] === 'undefined') {\n // If no incoming data, but existing document data is found, merge it in\n if (typeof siblingDoc[field.name] !== 'undefined') {\n siblingData[field.name] = cloneDataFromOriginalDoc(siblingDoc[field.name])\n\n // Otherwise compute default value\n } else if (typeof field.defaultValue !== 'undefined') {\n siblingData[field.name] = await getValueWithDefault({\n defaultValue: field.defaultValue,\n locale: req.locale,\n user: req.user,\n value: siblingData[field.name],\n })\n }\n }\n }\n\n // Traverse subfields\n switch (field.type) {\n case 'group': {\n if (typeof siblingData[field.name] !== 'object') siblingData[field.name] = {}\n if (typeof siblingDoc[field.name] !== 'object') siblingDoc[field.name] = {}\n\n const groupData = siblingData[field.name] as Record<string, unknown>\n const groupDoc = siblingDoc[field.name] as Record<string, unknown>\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: groupData,\n siblingDoc: groupDoc,\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) => {\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: row,\n siblingDoc: getExistingRowDoc(row, siblingDoc[field.name]),\n }),\n )\n })\n await Promise.all(promises)\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) => {\n const rowSiblingDoc = getExistingRowDoc(row, siblingDoc[field.name])\n const blockTypeToMatch = row.blockType || rowSiblingDoc.blockType\n const block = field.blocks.find((blockType) => blockType.slug === blockTypeToMatch)\n\n if (block) {\n row.blockType = blockTypeToMatch\n\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: block.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: row,\n siblingDoc: rowSiblingDoc,\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 fields: field.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n })\n\n break\n }\n\n case 'tab': {\n let tabSiblingData\n let tabSiblingDoc\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\n tabSiblingData = siblingData[field.name] as Record<string, unknown>\n tabSiblingDoc = siblingDoc[field.name] as Record<string, unknown>\n } else {\n tabSiblingData = siblingData\n tabSiblingDoc = siblingDoc\n }\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n })\n\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["fieldAffectsData","tabHasName","valueIsValueWithRelation","getValueWithDefault","cloneDataFromOriginalDoc","getExistingRowDoc","traverseFields","promise","id","collection","context","data","doc","field","global","operation","overrideAccess","req","siblingData","siblingDoc","name","type","value","parseFloat","toString","trimmed","trim","length","Array","isArray","map","coordinate","i","richTextJSON","JSON","parse","hasMany","relationTo","forEach","relatedDoc","relatedCollection","payload","config","collections","find","slug","relationshipIDField","fields","collectionField","hooks","beforeValidate","reduce","priorHook","currentHook","hookedValue","originalDoc","undefined","Promise","resolve","access","result","defaultValue","locale","user","groupData","groupDoc","rows","promises","row","push","all","rowSiblingDoc","blockTypeToMatch","blockType","block","blocks","tabSiblingData","tabSiblingDoc","tabs","tab"],"mappings":"AAAA,oCAAoC,GAMpC,SAASA,gBAAgB,EAAEC,UAAU,EAAEC,wBAAwB,QAAQ,wBAAuB;AAC9F,OAAOC,yBAAyB,2BAA0B;AAC1D,SAASC,wBAAwB,QAAQ,8CAA6C;AACtF,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,cAAc,QAAQ,sBAAqB;AAiBpD,oEAAoE;AACpE,2BAA2B;AAC3B,wBAAwB;AACxB,iCAAiC;AACjC,oDAAoD;AACpD,gDAAgD;AAEhD,OAAO,MAAMC,UAAU,OAAU,EAC/BC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,KAAK,EACLC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,GAAG,EACHC,WAAW,EACXC,UAAU,EACF;IACR,IAAInB,iBAAiBa,QAAQ;QAC3B,IAAIA,MAAMO,IAAI,KAAK,MAAM;YACvB,IAAIP,MAAMQ,IAAI,KAAK,YAAY,OAAOH,WAAW,CAACL,MAAMO,IAAI,CAAC,KAAK,UAAU;gBAC1E,MAAME,QAAQJ,WAAW,CAACL,MAAMO,IAAI,CAAC;gBAErCF,WAAW,CAACL,MAAMO,IAAI,CAAC,GAAGG,WAAWD;Y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;oBACAC;oBACAC;oBACAC;oBACAmC,QAAQlC,MAAMkC,MAAM;oBACpBjC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;gBACF;gBAEA;YACF;QAEA,KAAK;YAAO;gBACV,IAAIyD;gBACJ,IAAIC;gBACJ,IAAI5E,WAAWY,QAAQ;oBACrB,IAAI,OAAOK,WAAW,CAACL,MAAMO,IAAI,CAAC,KAAK,UAAUF,WAAW,CAACL,MAAMO,IAAI,CAAC,GAAG,CAAC;oBAC5E,IAAI,OAAOD,UAAU,CAACN,MAAMO,IAAI,CAAC,KAAK,UAAUD,UAAU,CAACN,MAAMO,IAAI,CAAC,GAAG,CAAC;oBAE1EwD,iBAAiB1D,WAAW,CAACL,MAAMO,IAAI,CAAC;oBACxCyD,gBAAgB1D,UAAU,CAACN,MAAMO,IAAI,CAAC;gBACxC,OAAO;oBACLwD,iBAAiB1D;oBACjB2D,gBAAgB1D;gBAClB;gBAEA,MAAMb,eAAe;oBACnBE;oBACAC;oBACAC;oBACAC;oBACAC;oBACAmC,QAAQlC,MAAMkC,MAAM;oBACpBjC;oBACAC;oBACAC;oBACAC;oBACAC,aAAa0D;oBACbzD,YAAY0D;gBACd;gBAEA;YACF;QAEA,KAAK;YAAQ;gBACX,MAAMvE,eAAe;oBACnBE;oBACAC;oBACAC;oBACAC;oBACAC;oBACAmC,QAAQlC,MAAMiE,IAAI,CAAChD,GAAG,CAAC,CAACiD,MAAS,CAAA;4BAAE,GAAGA,GAAG;4BAAE1D,MAAM;wBAAM,CAAA;oBACvDP;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;gBACF;gBAEA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/promise.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { fieldAffectsData, tabHasName, valueIsValueWithRelation } from '../../config/types.js'\nimport getValueWithDefault from '../../getDefaultValue.js'\nimport { cloneDataFromOriginalDoc } from '../beforeChange/cloneDataFromOriginalDoc.js'\nimport { getExistingRowDoc } from '../beforeChange/getExistingRowDoc.js'\nimport { traverseFields } from './traverseFields.js'\n\ntype Args<T> = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: T\n doc: T\n duplicate: boolean\n field: Field | TabAsField\n global: SanitizedGlobalConfig | null\n id?: number | string\n operation: 'create' | 'update'\n overrideAccess: boolean\n req: PayloadRequest\n siblingData: Record<string, unknown>\n siblingDoc: Record<string, unknown>\n}\n\n// This function is responsible for the following actions, in order:\n// - Sanitize incoming data\n// - Execute field hooks\n// - Execute field access control\n// - Merge original document data into incoming data\n// - Compute default values for undefined fields\n\nexport const promise = async <T>({\n id,\n collection,\n context,\n data,\n doc,\n duplicate,\n field,\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n}: Args<T>): Promise<void> => {\n if (fieldAffectsData(field)) {\n if (field.name === 'id') {\n if (field.type === 'number' && typeof siblingData[field.name] === 'string') {\n const value = siblingData[field.name] as string\n\n siblingData[field.name] = parseFloat(value)\n }\n\n if (\n field.type === 'text' &&\n typeof siblingData[field.name]?.toString === 'function' &&\n typeof siblingData[field.name] !== 'string'\n ) {\n siblingData[field.name] = siblingData[field.name].toString()\n }\n }\n\n // Sanitize incoming data\n switch (field.type) {\n case 'number': {\n if (typeof siblingData[field.name] === 'string') {\n const value = siblingData[field.name] as string\n const trimmed = value.trim()\n siblingData[field.name] = trimmed.length === 0 ? null : parseFloat(trimmed)\n }\n\n break\n }\n\n case 'point': {\n if (Array.isArray(siblingData[field.name])) {\n siblingData[field.name] = (siblingData[field.name] as string[]).map((coordinate, i) => {\n if (typeof coordinate === 'string') {\n const value = siblingData[field.name][i] as string\n const trimmed = value.trim()\n return trimmed.length === 0 ? null : parseFloat(trimmed)\n }\n return coordinate\n })\n }\n\n break\n }\n\n case 'checkbox': {\n if (siblingData[field.name] === 'true') siblingData[field.name] = true\n if (siblingData[field.name] === 'false') siblingData[field.name] = false\n if (siblingData[field.name] === '') siblingData[field.name] = false\n\n break\n }\n\n case 'richText': {\n if (typeof siblingData[field.name] === 'string') {\n try {\n const richTextJSON = JSON.parse(siblingData[field.name] as string)\n siblingData[field.name] = richTextJSON\n } catch {\n // Disregard this data as it is not valid.\n // Will be reported to user by field validation\n }\n }\n\n break\n }\n\n case 'relationship':\n case 'upload': {\n if (\n siblingData[field.name] === '' ||\n siblingData[field.name] === 'none' ||\n siblingData[field.name] === 'null' ||\n siblingData[field.name] === null\n ) {\n if (field.type === 'relationship' && field.hasMany === true) {\n siblingData[field.name] = []\n } else {\n siblingData[field.name] = null\n }\n }\n\n const value = siblingData[field.name]\n\n if (Array.isArray(field.relationTo)) {\n if (Array.isArray(value)) {\n value.forEach((relatedDoc: { relationTo: string; value: unknown }, i) => {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === relatedDoc.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name][i] = {\n ...relatedDoc,\n value: parseFloat(relatedDoc.value as string),\n }\n }\n })\n }\n if (\n field.type === 'relationship' &&\n field.hasMany !== true &&\n valueIsValueWithRelation(value)\n ) {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === value.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name] = { ...value, value: parseFloat(value.value as string) }\n }\n }\n } else {\n if (Array.isArray(value)) {\n value.forEach((relatedDoc: unknown, i) => {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === field.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name][i] = parseFloat(relatedDoc as string)\n }\n })\n }\n if (field.type === 'relationship' && field.hasMany !== true && value) {\n const relatedCollection = req.payload.config.collections.find(\n (collection) => collection.slug === field.relationTo,\n )\n const relationshipIDField = relatedCollection.fields.find(\n (collectionField) =>\n fieldAffectsData(collectionField) && collectionField.name === 'id',\n )\n if (relationshipIDField?.type === 'number') {\n siblingData[field.name] = parseFloat(value as string)\n }\n }\n }\n break\n }\n\n case 'array':\n case 'blocks': {\n // Handle cases of arrays being intentionally set to 0\n if (siblingData[field.name] === '0' || siblingData[field.name] === 0) {\n siblingData[field.name] = []\n }\n\n break\n }\n\n default: {\n break\n }\n }\n\n // Execute hooks\n if (field.hooks?.beforeValidate) {\n await field.hooks.beforeValidate.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 req,\n siblingData,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n\n // Execute access control\n if (field.access && field.access[operation]) {\n const result = overrideAccess\n ? true\n : await field.access[operation]({ id, data, doc, req, siblingData })\n\n if (!result) {\n delete siblingData[field.name]\n }\n }\n\n if (typeof siblingData[field.name] === 'undefined') {\n // If no incoming data, but existing document data is found, merge it in\n if (typeof siblingDoc[field.name] !== 'undefined') {\n siblingData[field.name] = cloneDataFromOriginalDoc(siblingDoc[field.name])\n\n // Otherwise compute default value\n } else if (typeof field.defaultValue !== 'undefined') {\n siblingData[field.name] = await getValueWithDefault({\n defaultValue: field.defaultValue,\n locale: req.locale,\n user: req.user,\n value: siblingData[field.name],\n })\n }\n }\n\n // Execute beforeDuplicate hook\n if (duplicate && field.hooks?.beforeDuplicate) {\n if (field.hooks?.beforeDuplicate) {\n await field.hooks.beforeDuplicate.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 req,\n siblingData,\n value: siblingData[field.name],\n })\n\n if (hookedValue !== undefined) {\n siblingData[field.name] = hookedValue\n }\n }, Promise.resolve())\n }\n }\n }\n\n // Traverse subfields\n switch (field.type) {\n case 'group': {\n if (typeof siblingData[field.name] !== 'object') siblingData[field.name] = {}\n if (typeof siblingDoc[field.name] !== 'object') siblingDoc[field.name] = {}\n\n const groupData = siblingData[field.name] as Record<string, unknown>\n const groupDoc = siblingDoc[field.name] as Record<string, unknown>\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n duplicate,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: groupData,\n siblingDoc: groupDoc,\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) => {\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n duplicate,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: row,\n siblingDoc: getExistingRowDoc(row, siblingDoc[field.name]),\n }),\n )\n })\n await Promise.all(promises)\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) => {\n const rowSiblingDoc = getExistingRowDoc(row, siblingDoc[field.name])\n const blockTypeToMatch = row.blockType || rowSiblingDoc.blockType\n const block = field.blocks.find((blockType) => blockType.slug === blockTypeToMatch)\n\n if (block) {\n row.blockType = blockTypeToMatch\n\n promises.push(\n traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n duplicate,\n fields: block.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: row,\n siblingDoc: rowSiblingDoc,\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 duplicate,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n })\n\n break\n }\n\n case 'tab': {\n let tabSiblingData\n let tabSiblingDoc\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\n tabSiblingData = siblingData[field.name] as Record<string, unknown>\n tabSiblingDoc = siblingDoc[field.name] as Record<string, unknown>\n } else {\n tabSiblingData = siblingData\n tabSiblingDoc = siblingDoc\n }\n\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n duplicate,\n fields: field.fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData: tabSiblingData,\n siblingDoc: tabSiblingDoc,\n })\n\n break\n }\n\n case 'tabs': {\n await traverseFields({\n id,\n collection,\n context,\n data,\n doc,\n duplicate,\n fields: field.tabs.map((tab) => ({ ...tab, type: 'tab' })),\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n })\n\n break\n }\n\n default: {\n break\n }\n }\n}\n"],"names":["fieldAffectsData","tabHasName","valueIsValueWithRelation","getValueWithDefault","cloneDataFromOriginalDoc","getExistingRowDoc","traverseFields","promise","id","collection","context","data","doc","duplicate","field","global","operation","overrideAccess","req","siblingData","siblingDoc","name","type","value","parseFloat","toString","trimmed","trim","length","Array","isArray","map","coordinate","i","richTextJSON","JSON","parse","hasMany","relationTo","forEach","relatedDoc","relatedCollection","payload","config","collections","find","slug","relationshipIDField","fields","collectionField","hooks","beforeValidate","reduce","priorHook","currentHook","hookedValue","originalDoc","undefined","Promise","resolve","access","result","defaultValue","locale","user","beforeDuplicate","groupData","groupDoc","rows","promises","row","push","all","rowSiblingDoc","blockTypeToMatch","blockType","block","blocks","tabSiblingData","tabSiblingDoc","tabs","tab"],"mappings":"AAAA,oCAAoC,GAMpC,SAASA,gBAAgB,EAAEC,U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oBACnBE;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAmC,QAAQlC,MAAMkC,MAAM;oBACpBjC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;gBACF;gBAEA;YACF;QAEA,KAAK;YAAO;gBACV,IAAI0D;gBACJ,IAAIC;gBACJ,IAAI9E,WAAWa,QAAQ;oBACrB,IAAI,OAAOK,WAAW,CAACL,MAAMO,IAAI,CAAC,KAAK,UAAUF,WAAW,CAACL,MAAMO,IAAI,CAAC,GAAG,CAAC;oBAC5E,IAAI,OAAOD,UAAU,CAACN,MAAMO,IAAI,CAAC,KAAK,UAAUD,UAAU,CAACN,MAAMO,IAAI,CAAC,GAAG,CAAC;oBAE1EyD,iBAAiB3D,WAAW,CAACL,MAAMO,IAAI,CAAC;oBACxC0D,gBAAgB3D,UAAU,CAACN,MAAMO,IAAI,CAAC;gBACxC,OAAO;oBACLyD,iBAAiB3D;oBACjB4D,gBAAgB3D;gBAClB;gBAEA,MAAMd,eAAe;oBACnBE;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAmC,QAAQlC,MAAMkC,MAAM;oBACpBjC;oBACAC;oBACAC;oBACAC;oBACAC,aAAa2D;oBACb1D,YAAY2D;gBACd;gBAEA;YACF;QAEA,KAAK;YAAQ;gBACX,MAAMzE,eAAe;oBACnBE;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;oBACAmC,QAAQlC,MAAMkE,IAAI,CAACjD,GAAG,CAAC,CAACkD,MAAS,CAAA;4BAAE,GAAGA,GAAG;4BAAE3D,MAAM;wBAAM,CAAA;oBACvDP;oBACAC;oBACAC;oBACAC;oBACAC;oBACAC;gBACF;gBAEA;YACF;QAEA;YAAS;gBACP;YACF;IACF;AACF,EAAC"}
@@ -7,6 +7,7 @@ type Args<T> = {
7
7
  context: RequestContext;
8
8
  data: T;
9
9
  doc: T;
10
+ duplicate: boolean;
10
11
  fields: (Field | TabAsField)[];
11
12
  global: SanitizedGlobalConfig | null;
12
13
  id?: number | string;
@@ -16,6 +17,6 @@ type Args<T> = {
16
17
  siblingData: Record<string, unknown>;
17
18
  siblingDoc: Record<string, unknown>;
18
19
  };
19
- export declare const traverseFields: <T>({ id, collection, context, data, doc, fields, global, operation, overrideAccess, req, siblingData, siblingDoc, }: Args<T>) => Promise<void>;
20
+ export declare const traverseFields: <T>({ id, collection, context, data, doc, duplicate, fields, global, operation, overrideAccess, req, siblingData, siblingDoc, }: Args<T>) => Promise<void>;
20
21
  export {};
21
22
  //# sourceMappingURL=traverseFields.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeValidate/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7E,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAI9D,KAAK,IAAI,CAAC,CAAC,IAAI;IACb,UAAU,EAAE,yBAAyB,GAAG,IAAI,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,CAAC,CAAA;IACP,GAAG,EAAE,CAAC,CAAA;IACN,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAA;IACpC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;IACnB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,cAAc,oIAad,QAAQ,IAAI,CAqBxB,CAAA"}
1
+ {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../../../src/fields/hooks/beforeValidate/traverseFields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAA;AACrF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAC7E,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAI9D,KAAK,IAAI,CAAC,CAAC,IAAI;IACb,UAAU,EAAE,yBAAyB,GAAG,IAAI,CAAA;IAC5C,OAAO,EAAE,cAAc,CAAA;IACvB,IAAI,EAAE,CAAC,CAAA;IACP,GAAG,EAAE,CAAC,CAAA;IACN,SAAS,EAAE,OAAO,CAAA;IAClB,MAAM,EAAE,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAA;IAC9B,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAA;IACpC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACpB,SAAS,EAAE,QAAQ,GAAG,QAAQ,CAAA;IAC9B,cAAc,EAAE,OAAO,CAAA;IACvB,GAAG,EAAE,cAAc,CAAA;IACnB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,cAAc,mIAcxB,KAAK,CAAC,CAAC,KAAG,QAAQ,IAAI,CAsBxB,CAAA"}
@@ -1,5 +1,5 @@
1
1
  import { promise } from './promise.js';
2
- export const traverseFields = async ({ id, collection, context, data, doc, fields, global, operation, overrideAccess, req, siblingData, siblingDoc })=>{
2
+ export const traverseFields = async ({ id, collection, context, data, doc, duplicate, fields, global, operation, overrideAccess, req, siblingData, siblingDoc })=>{
3
3
  const promises = [];
4
4
  fields.forEach((field)=>{
5
5
  promises.push(promise({
@@ -8,6 +8,7 @@ export const traverseFields = async ({ id, collection, context, data, doc, field
8
8
  context,
9
9
  data,
10
10
  doc,
11
+ duplicate,
11
12
  field,
12
13
  global,
13
14
  operation,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args<T> = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: T\n doc: T\n fields: (Field | TabAsField)[]\n global: SanitizedGlobalConfig | null\n id?: number | string\n operation: 'create' | 'update'\n overrideAccess: boolean\n req: PayloadRequest\n siblingData: Record<string, unknown>\n siblingDoc: Record<string, unknown>\n}\n\nexport const traverseFields = async <T>({\n id,\n collection,\n context,\n data,\n doc,\n fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n}: Args<T>): Promise<void> => {\n const promises = []\n fields.forEach((field) => {\n promises.push(\n promise({\n id,\n collection,\n context,\n data,\n doc,\n field,\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n }),\n )\n })\n await Promise.all(promises)\n}\n"],"names":["promise","traverseFields","id","collection","context","data","doc","fields","global","operation","overrideAccess","req","siblingData","siblingDoc","promises","forEach","field","push","Promise","all"],"mappings":"AAKA,SAASA,OAAO,QAAQ,eAAc;AAiBtC,OAAO,MAAMC,iBAAiB,OAAU,EACtCC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,MAAM,EACNC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,GAAG,EACHC,WAAW,EACXC,UAAU,EACF;IACR,MAAMC,WAAW,EAAE;IACnBP,OAAOQ,OAAO,CAAC,CAACC;QACdF,SAASG,IAAI,CACXjB,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAC;YACAU;YACAR;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;IAEJ;IACA,MAAMK,QAAQC,GAAG,CAACL;AACpB,EAAC"}
1
+ {"version":3,"sources":["../../../../src/fields/hooks/beforeValidate/traverseFields.ts"],"sourcesContent":["import type { SanitizedCollectionConfig } from '../../../collections/config/types.js'\nimport type { SanitizedGlobalConfig } from '../../../globals/config/types.js'\nimport type { PayloadRequest, RequestContext } from '../../../types/index.js'\nimport type { Field, TabAsField } from '../../config/types.js'\n\nimport { promise } from './promise.js'\n\ntype Args<T> = {\n collection: SanitizedCollectionConfig | null\n context: RequestContext\n data: T\n doc: T\n duplicate: boolean\n fields: (Field | TabAsField)[]\n global: SanitizedGlobalConfig | null\n id?: number | string\n operation: 'create' | 'update'\n overrideAccess: boolean\n req: PayloadRequest\n siblingData: Record<string, unknown>\n siblingDoc: Record<string, unknown>\n}\n\nexport const traverseFields = async <T>({\n id,\n collection,\n context,\n data,\n doc,\n duplicate,\n fields,\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n}: Args<T>): Promise<void> => {\n const promises = []\n fields.forEach((field) => {\n promises.push(\n promise({\n id,\n collection,\n context,\n data,\n doc,\n duplicate,\n field,\n global,\n operation,\n overrideAccess,\n req,\n siblingData,\n siblingDoc,\n }),\n )\n })\n await Promise.all(promises)\n}\n"],"names":["promise","traverseFields","id","collection","context","data","doc","duplicate","fields","global","operation","overrideAccess","req","siblingData","siblingDoc","promises","forEach","field","push","Promise","all"],"mappings":"AAKA,SAASA,OAAO,QAAQ,eAAc;AAkBtC,OAAO,MAAMC,iBAAiB,OAAU,EACtCC,EAAE,EACFC,UAAU,EACVC,OAAO,EACPC,IAAI,EACJC,GAAG,EACHC,SAAS,EACTC,MAAM,EACNC,MAAM,EACNC,SAAS,EACTC,cAAc,EACdC,GAAG,EACHC,WAAW,EACXC,UAAU,EACF;IACR,MAAMC,WAAW,EAAE;IACnBP,OAAOQ,OAAO,CAAC,CAACC;QACdF,SAASG,IAAI,CACXlB,QAAQ;YACNE;YACAC;YACAC;YACAC;YACAC;YACAC;YACAU;YACAR;YACAC;YACAC;YACAC;YACAC;YACAC;QACF;IAEJ;IACA,MAAMK,QAAQC,GAAG,CAACL;AACpB,EAAC"}
@@ -0,0 +1,3 @@
1
+ import type { FieldAffectingData } from './config/types.js';
2
+ export declare const setDefaultBeforeDuplicate: (field: FieldAffectingData) => void;
3
+ //# sourceMappingURL=setDefaultBeforeDuplicate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setDefaultBeforeDuplicate.d.ts","sourceRoot":"","sources":["../../src/fields/setDefaultBeforeDuplicate.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAa,MAAM,mBAAmB,CAAA;AAStE,eAAO,MAAM,yBAAyB,UAAW,kBAAkB,SAYlE,CAAA"}
@@ -0,0 +1,23 @@
1
+ import { extractTranslations } from '../translations/extractTranslations.js';
2
+ const copyTranslations = extractTranslations([
3
+ 'general:copy'
4
+ ]);
5
+ const unique = ({ value })=>typeof value === 'string' ? `${value} - Copy` : undefined;
6
+ const localizedUnique = ({ req, value })=>value ? `${value} - ${copyTranslations?.[req.locale]?.['general:copy'] ?? 'Copy'}` : undefined;
7
+ const uniqueRequired = ({ value })=>`${value} - Copy`;
8
+ const localizedUniqueRequired = ({ req, value })=>`${value} - ${copyTranslations?.[req.locale]?.['general:copy'] ?? 'Copy'}`;
9
+ export const setDefaultBeforeDuplicate = (field)=>{
10
+ if (('required' in field && field.required || field.unique) && (!field.hooks?.beforeDuplicate || Array.isArray(field.hooks.beforeDuplicate) && field.hooks.beforeDuplicate.length === 0)) {
11
+ if ((field.type === 'text' || field.type === 'textarea') && field.required && field.unique) {
12
+ field.hooks.beforeDuplicate = [
13
+ field.localized ? localizedUniqueRequired : uniqueRequired
14
+ ];
15
+ } else if (field.unique) {
16
+ field.hooks.beforeDuplicate = [
17
+ field.localized ? localizedUnique : unique
18
+ ];
19
+ }
20
+ }
21
+ };
22
+
23
+ //# sourceMappingURL=setDefaultBeforeDuplicate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/fields/setDefaultBeforeDuplicate.ts"],"sourcesContent":["import { extractTranslations } from '../translations/extractTranslations.js'\n\nconst copyTranslations = extractTranslations(['general:copy'])\n\n// default beforeDuplicate hook for required and unique fields\nimport type { FieldAffectingData, FieldHook } from './config/types.js'\n\nconst unique: FieldHook = ({ value }) => (typeof value === 'string' ? `${value} - Copy` : undefined)\nconst localizedUnique: FieldHook = ({ req, value }) =>\n value ? `${value} - ${copyTranslations?.[req.locale]?.['general:copy'] ?? 'Copy'}` : undefined\nconst uniqueRequired: FieldHook = ({ value }) => `${value} - Copy`\nconst localizedUniqueRequired: FieldHook = ({ req, value }) =>\n `${value} - ${copyTranslations?.[req.locale]?.['general:copy'] ?? 'Copy'}`\n\nexport const setDefaultBeforeDuplicate = (field: FieldAffectingData) => {\n if (\n (('required' in field && field.required) || field.unique) &&\n (!field.hooks?.beforeDuplicate ||\n (Array.isArray(field.hooks.beforeDuplicate) && field.hooks.beforeDuplicate.length === 0))\n ) {\n if ((field.type === 'text' || field.type === 'textarea') && field.required && field.unique) {\n field.hooks.beforeDuplicate = [field.localized ? localizedUniqueRequired : uniqueRequired]\n } else if (field.unique) {\n field.hooks.beforeDuplicate = [field.localized ? localizedUnique : unique]\n }\n }\n}\n"],"names":["extractTranslations","copyTranslations","unique","value","undefined","localizedUnique","req","locale","uniqueRequired","localizedUniqueRequired","setDefaultBeforeDuplicate","field","required","hooks","beforeDuplicate","Array","isArray","length","type","localized"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,yCAAwC;AAE5E,MAAMC,mBAAmBD,oBAAoB;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any>;
35
35
  };
36
36
  condition?: import("./config/types.js").Condition<any, any>;
37
- description?: import("../exports/types.js").Description;
37
+ description?: import("packages/payload/src/admin/forms/FieldDescription.js").Description;
38
38
  disableBulkEdit?: boolean;
39
39
  disabled?: boolean;
40
40
  hidden?: boolean;
@@ -44,8 +44,8 @@ declare const _default: {
44
44
  width?: string;
45
45
  } & {
46
46
  components?: {
47
- Error?: import("react").ComponentType<import("../exports/types.js").ErrorProps>;
48
- Label?: import("react").ComponentType<import("../exports/types.js").LabelProps>;
47
+ Error?: import("react").ComponentType<import("packages/payload/src/admin/forms/Error.js").ErrorProps>;
48
+ Label?: import("react").ComponentType<import("packages/payload/src/admin/forms/Label.js").LabelProps>;
49
49
  };
50
50
  editorOptions?: import("monaco-editor").editor.IStandaloneEditorConstructionOptions;
51
51
  };
@@ -0,0 +1,14 @@
1
+ import type { LivePreviewConfig, SanitizedConfig, ServerOnlyLivePreviewProperties } from '../../config/types.js';
2
+ import type { ClientFieldConfig } from '../../fields/config/client.js';
3
+ import type { SanitizedGlobalConfig } from './types.js';
4
+ export type ServerOnlyGlobalProperties = keyof Pick<SanitizedGlobalConfig, 'access' | 'admin' | 'endpoints' | 'fields' | 'hooks'>;
5
+ export type ServerOnlyGlobalAdminProperties = keyof Pick<SanitizedGlobalConfig['admin'], 'components' | 'hidden' | 'preview'>;
6
+ export type ClientGlobalConfig = Omit<SanitizedGlobalConfig, 'admin' | 'fields' | ServerOnlyGlobalProperties> & {
7
+ admin: Omit<SanitizedGlobalConfig['admin'], ServerOnlyGlobalAdminProperties & 'fields' & 'livePreview'> & {
8
+ livePreview?: Omit<LivePreviewConfig, ServerOnlyLivePreviewProperties>;
9
+ };
10
+ fields: ClientFieldConfig[];
11
+ };
12
+ export declare const createClientGlobalConfig: (global: SanitizedConfig['globals'][0]) => ClientGlobalConfig;
13
+ export declare const createClientGlobalConfigs: (globals: SanitizedConfig['globals']) => ClientGlobalConfig[];
14
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/globals/config/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,+BAA+B,EAChC,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAA;AACtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAIvD,MAAM,MAAM,0BAA0B,GAAG,MAAM,IAAI,CACjD,qBAAqB,EACrB,QAAQ,GAAG,OAAO,GAAG,WAAW,GAAG,QAAQ,GAAG,OAAO,CACtD,CAAA;AACD,MAAM,MAAM,+BAA+B,GAAG,MAAM,IAAI,CACtD,qBAAqB,CAAC,OAAO,CAAC,EAC9B,YAAY,GAAG,QAAQ,GAAG,SAAS,CACpC,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,qBAAqB,EACrB,OAAO,GAAG,QAAQ,GAAG,0BAA0B,CAChD,GAAG;IACF,KAAK,EAAE,IAAI,CACT,qBAAqB,CAAC,OAAO,CAAC,EAC9B,+BAA+B,GAAG,QAAQ,GAAG,aAAa,CAC3D,GAAG;QACF,WAAW,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,+BAA+B,CAAC,CAAA;KACvE,CAAA;IACD,MAAM,EAAE,iBAAiB,EAAE,CAAA;CAC5B,CAAA;AAED,eAAO,MAAM,wBAAwB,WAC3B,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KACpC,kBAuCF,CAAA;AAED,eAAO,MAAM,yBAAyB,YAC3B,eAAe,CAAC,SAAS,CAAC,KAClC,kBAAkB,EAA+D,CAAA"}
@@ -0,0 +1,42 @@
1
+ import { createClientFieldConfigs } from '../../fields/config/client.js';
2
+ export const createClientGlobalConfig = (global)=>{
3
+ const sanitized = {
4
+ ...global
5
+ };
6
+ sanitized.fields = createClientFieldConfigs(sanitized.fields);
7
+ const serverOnlyProperties = [
8
+ 'hooks',
9
+ 'access',
10
+ 'endpoints'
11
+ ];
12
+ serverOnlyProperties.forEach((key)=>{
13
+ if (key in sanitized) {
14
+ delete sanitized[key];
15
+ }
16
+ });
17
+ if ('admin' in sanitized) {
18
+ sanitized.admin = {
19
+ ...sanitized.admin
20
+ };
21
+ const serverOnlyGlobalAdminProperties = [
22
+ 'components',
23
+ 'hidden',
24
+ 'preview'
25
+ ];
26
+ serverOnlyGlobalAdminProperties.forEach((key)=>{
27
+ if (key in sanitized.admin) {
28
+ delete sanitized.admin[key];
29
+ }
30
+ });
31
+ if ('livePreview' in sanitized.admin) {
32
+ sanitized.admin.livePreview = {
33
+ ...sanitized.admin.livePreview
34
+ };
35
+ delete sanitized.admin.livePreview.url;
36
+ }
37
+ }
38
+ return sanitized;
39
+ };
40
+ export const createClientGlobalConfigs = (globals)=>globals.map((global)=>createClientGlobalConfig(global));
41
+
42
+ //# sourceMappingURL=client.js.map