payload 4.0.0-internal.5b1e7cd → 4.0.0-internal.5f0cd13

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 (641) hide show
  1. package/dist/admin/RichText.d.ts +3 -16
  2. package/dist/admin/RichText.d.ts.map +1 -1
  3. package/dist/admin/RichText.js.map +1 -1
  4. package/dist/admin/adapters/cookies.d.ts +21 -0
  5. package/dist/admin/adapters/cookies.d.ts.map +1 -0
  6. package/dist/admin/adapters/cookies.js +3 -0
  7. package/dist/admin/adapters/cookies.js.map +1 -0
  8. package/dist/admin/adapters/index.d.ts +4 -0
  9. package/dist/admin/adapters/index.d.ts.map +1 -0
  10. package/dist/admin/adapters/index.js +3 -0
  11. package/dist/admin/adapters/index.js.map +1 -0
  12. package/dist/admin/adapters/router.d.ts +56 -0
  13. package/dist/admin/adapters/router.d.ts.map +1 -0
  14. package/dist/admin/adapters/router.js +3 -0
  15. package/dist/admin/adapters/router.js.map +1 -0
  16. package/dist/admin/adapters/server.d.ts +23 -0
  17. package/dist/admin/adapters/server.d.ts.map +1 -0
  18. package/dist/admin/adapters/server.js +6 -0
  19. package/dist/admin/adapters/server.js.map +1 -0
  20. package/dist/admin/elements/Nav.d.ts +13 -0
  21. package/dist/admin/elements/Nav.d.ts.map +1 -1
  22. package/dist/admin/elements/Nav.js.map +1 -1
  23. package/dist/admin/elements/Table.d.ts +1 -0
  24. package/dist/admin/elements/Table.d.ts.map +1 -1
  25. package/dist/admin/elements/Table.js.map +1 -1
  26. package/dist/admin/functions/index.d.ts +1 -38
  27. package/dist/admin/functions/index.d.ts.map +1 -1
  28. package/dist/admin/functions/index.js.map +1 -1
  29. package/dist/admin/types.d.ts +5 -4
  30. package/dist/admin/types.d.ts.map +1 -1
  31. package/dist/admin/types.js.map +1 -1
  32. package/dist/admin/views/hierarchyList.d.ts +10 -0
  33. package/dist/admin/views/hierarchyList.d.ts.map +1 -0
  34. package/dist/admin/views/hierarchyList.js +3 -0
  35. package/dist/admin/views/hierarchyList.js.map +1 -0
  36. package/dist/admin/views/index.d.ts +1 -3
  37. package/dist/admin/views/index.d.ts.map +1 -1
  38. package/dist/admin/views/index.js.map +1 -1
  39. package/dist/admin/views/list.d.ts +47 -2
  40. package/dist/admin/views/list.d.ts.map +1 -1
  41. package/dist/admin/views/list.js.map +1 -1
  42. package/dist/auth/cookies.d.ts.map +1 -1
  43. package/dist/auth/defaultAccess.d.ts.map +1 -1
  44. package/dist/auth/ensureUsernameOrEmail.d.ts.map +1 -1
  45. package/dist/auth/executeAccess.d.ts.map +1 -1
  46. package/dist/auth/executeAuthStrategies.d.ts.map +1 -1
  47. package/dist/auth/extractAccessFromPermission.d.ts.map +1 -1
  48. package/dist/auth/extractJWT.d.ts.map +1 -1
  49. package/dist/auth/getAuthFields.d.ts.map +1 -1
  50. package/dist/auth/getFieldsToSign.d.ts.map +1 -1
  51. package/dist/auth/getLoginOptions.d.ts.map +1 -1
  52. package/dist/auth/isUserLocked.d.ts.map +1 -1
  53. package/dist/auth/jwt.d.ts.map +1 -1
  54. package/dist/auth/operations/access.d.ts.map +1 -1
  55. package/dist/auth/operations/auth.d.ts.map +1 -1
  56. package/dist/auth/operations/forgotPassword.d.ts.map +1 -1
  57. package/dist/auth/operations/init.d.ts.map +1 -1
  58. package/dist/auth/operations/local/auth.d.ts.map +1 -1
  59. package/dist/auth/operations/login.d.ts.map +1 -1
  60. package/dist/auth/operations/logout.d.ts.map +1 -1
  61. package/dist/auth/operations/me.d.ts.map +1 -1
  62. package/dist/auth/operations/refresh.d.ts.map +1 -1
  63. package/dist/auth/operations/registerFirstUser.d.ts.map +1 -1
  64. package/dist/auth/operations/resetPassword.d.ts.map +1 -1
  65. package/dist/auth/operations/unlock.d.ts.map +1 -1
  66. package/dist/auth/operations/verifyEmail.d.ts.map +1 -1
  67. package/dist/auth/sessions.d.ts.map +1 -1
  68. package/dist/auth/strategies/apiKey.d.ts.map +1 -1
  69. package/dist/auth/strategies/apiKey.js +6 -17
  70. package/dist/auth/strategies/apiKey.js.map +1 -1
  71. package/dist/auth/strategies/local/authenticate.d.ts.map +1 -1
  72. package/dist/auth/strategies/local/generatePasswordSaltHash.d.ts.map +1 -1
  73. package/dist/auth/strategies/local/incrementLoginAttempts.d.ts.map +1 -1
  74. package/dist/auth/strategies/local/register.d.ts.map +1 -1
  75. package/dist/auth/strategies/local/resetLoginAttempts.d.ts.map +1 -1
  76. package/dist/bin/generateImportMap/iterateCollections.d.ts.map +1 -1
  77. package/dist/bin/generateImportMap/iterateCollections.js +1 -0
  78. package/dist/bin/generateImportMap/iterateCollections.js.map +1 -1
  79. package/dist/bin/generateImportMap/iterateConfig.d.ts.map +1 -1
  80. package/dist/bin/generateImportMap/iterateConfig.js +7 -0
  81. package/dist/bin/generateImportMap/iterateConfig.js.map +1 -1
  82. package/dist/bin/generateImportMap/iterateFields.d.ts.map +1 -1
  83. package/dist/bin/generateImportMap/iterateFields.js +4 -1
  84. package/dist/bin/generateImportMap/iterateFields.js.map +1 -1
  85. package/dist/bin/generateImportMap/iterateGlobals.d.ts.map +1 -1
  86. package/dist/bin/generateImportMap/iterateGlobals.js +20 -8
  87. package/dist/bin/generateImportMap/iterateGlobals.js.map +1 -1
  88. package/dist/bin/generateImportMap/utilities/getFromImportMap.d.ts.map +1 -1
  89. package/dist/bin/generateTypes.d.ts.map +1 -1
  90. package/dist/bin/generateTypes.js +7 -1
  91. package/dist/bin/generateTypes.js.map +1 -1
  92. package/dist/bin/index.d.ts.map +1 -1
  93. package/dist/bin/index.js +1 -3
  94. package/dist/bin/index.js.map +1 -1
  95. package/dist/bin/migrate.d.ts.map +1 -1
  96. package/dist/collections/config/client.d.ts +4 -2
  97. package/dist/collections/config/client.d.ts.map +1 -1
  98. package/dist/collections/config/client.js +13 -1
  99. package/dist/collections/config/client.js.map +1 -1
  100. package/dist/collections/config/defaults.d.ts.map +1 -1
  101. package/dist/collections/config/defaults.js +1 -1
  102. package/dist/collections/config/defaults.js.map +1 -1
  103. package/dist/collections/config/sanitize.d.ts +10 -1
  104. package/dist/collections/config/sanitize.d.ts.map +1 -1
  105. package/dist/collections/config/sanitize.js +51 -10
  106. package/dist/collections/config/sanitize.js.map +1 -1
  107. package/dist/collections/config/sanitizeCompoundIndexes.d.ts.map +1 -1
  108. package/dist/collections/config/types.d.ts +76 -91
  109. package/dist/collections/config/types.d.ts.map +1 -1
  110. package/dist/collections/config/types.js.map +1 -1
  111. package/dist/collections/config/useAsTitle.d.ts.map +1 -1
  112. package/dist/collections/dataloader.d.ts.map +1 -1
  113. package/dist/collections/operations/count.d.ts.map +1 -1
  114. package/dist/collections/operations/countVersions.d.ts.map +1 -1
  115. package/dist/collections/operations/create.d.ts.map +1 -1
  116. package/dist/collections/operations/create.js +24 -19
  117. package/dist/collections/operations/create.js.map +1 -1
  118. package/dist/collections/operations/delete.d.ts.map +1 -1
  119. package/dist/collections/operations/delete.js +7 -2
  120. package/dist/collections/operations/delete.js.map +1 -1
  121. package/dist/collections/operations/deleteByID.d.ts.map +1 -1
  122. package/dist/collections/operations/deleteByID.js +7 -2
  123. package/dist/collections/operations/deleteByID.js.map +1 -1
  124. package/dist/collections/operations/duplicate.d.ts.map +1 -1
  125. package/dist/collections/operations/find.d.ts.map +1 -1
  126. package/dist/collections/operations/find.js +7 -2
  127. package/dist/collections/operations/find.js.map +1 -1
  128. package/dist/collections/operations/findByID.d.ts.map +1 -1
  129. package/dist/collections/operations/findByID.js +10 -5
  130. package/dist/collections/operations/findByID.js.map +1 -1
  131. package/dist/collections/operations/findDistinct.d.ts.map +1 -1
  132. package/dist/collections/operations/findVersionByID.d.ts.map +1 -1
  133. package/dist/collections/operations/findVersionByID.js +6 -4
  134. package/dist/collections/operations/findVersionByID.js.map +1 -1
  135. package/dist/collections/operations/findVersions.d.ts.map +1 -1
  136. package/dist/collections/operations/findVersions.js +6 -4
  137. package/dist/collections/operations/findVersions.js.map +1 -1
  138. package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
  139. package/dist/collections/operations/restoreVersion.js +7 -2
  140. package/dist/collections/operations/restoreVersion.js.map +1 -1
  141. package/dist/collections/operations/update.d.ts.map +1 -1
  142. package/dist/collections/operations/update.js +7 -2
  143. package/dist/collections/operations/update.js.map +1 -1
  144. package/dist/collections/operations/updateByID.d.ts.map +1 -1
  145. package/dist/collections/operations/updateByID.js +7 -2
  146. package/dist/collections/operations/updateByID.js.map +1 -1
  147. package/dist/collections/operations/utilities/buildAfterOperation.d.ts.map +1 -1
  148. package/dist/collections/operations/utilities/sanitizeSortQuery.d.ts.map +1 -1
  149. package/dist/collections/operations/utilities/update.d.ts.map +1 -1
  150. package/dist/collections/operations/utilities/update.js +5 -4
  151. package/dist/collections/operations/utilities/update.js.map +1 -1
  152. package/dist/config/build.d.ts.map +1 -1
  153. package/dist/config/build.js +8 -0
  154. package/dist/config/build.js.map +1 -1
  155. package/dist/config/client.d.ts +1 -1
  156. package/dist/config/client.d.ts.map +1 -1
  157. package/dist/config/client.js +2 -11
  158. package/dist/config/client.js.map +1 -1
  159. package/dist/config/defaults.d.ts.map +1 -1
  160. package/dist/config/defaults.js +0 -15
  161. package/dist/config/defaults.js.map +1 -1
  162. package/dist/config/orderable/index.d.ts.map +1 -1
  163. package/dist/config/orderable/index.js +0 -4
  164. package/dist/config/orderable/index.js.map +1 -1
  165. package/dist/config/sanitize.d.ts.map +1 -1
  166. package/dist/config/sanitize.js +6 -53
  167. package/dist/config/sanitize.js.map +1 -1
  168. package/dist/config/types.d.ts +188 -32
  169. package/dist/config/types.d.ts.map +1 -1
  170. package/dist/config/types.js.map +1 -1
  171. package/dist/database/combineQueries.d.ts.map +1 -1
  172. package/dist/database/migrations/findMigrationDir.d.ts.map +1 -1
  173. package/dist/database/migrations/getPredefinedMigration.d.ts.map +1 -1
  174. package/dist/database/migrations/readMigrationFiles.d.ts.map +1 -1
  175. package/dist/database/migrations/templates/localizeStatus.d.ts.map +1 -1
  176. package/dist/database/migrations/writeMigrationIndex.d.ts.map +1 -1
  177. package/dist/database/sanitizeJoinQuery.d.ts.map +1 -1
  178. package/dist/database/sanitizeWhereQuery.d.ts.map +1 -1
  179. package/dist/duplicateDocument/index.d.ts.map +1 -1
  180. package/dist/email/getStringifiedToAddress.d.ts.map +1 -1
  181. package/dist/exports/shared.d.ts +6 -3
  182. package/dist/exports/shared.d.ts.map +1 -1
  183. package/dist/exports/shared.js +4 -2
  184. package/dist/exports/shared.js.map +1 -1
  185. package/dist/fields/baseFields/slug/countVersions.d.ts.map +1 -1
  186. package/dist/fields/baseFields/slug/generateSlug.d.ts.map +1 -1
  187. package/dist/fields/baseFields/slug/index.d.ts.map +1 -1
  188. package/dist/fields/baseFields/slug/index.js +7 -5
  189. package/dist/fields/baseFields/slug/index.js.map +1 -1
  190. package/dist/fields/config/client.d.ts +1 -1
  191. package/dist/fields/config/client.d.ts.map +1 -1
  192. package/dist/fields/config/client.js +4 -3
  193. package/dist/fields/config/client.js.map +1 -1
  194. package/dist/fields/config/sanitize.d.ts.map +1 -1
  195. package/dist/fields/config/sanitize.js +13 -20
  196. package/dist/fields/config/sanitize.js.map +1 -1
  197. package/dist/fields/config/sanitizeJoinField.d.ts.map +1 -1
  198. package/dist/fields/config/sanitizeJoinField.js +3 -0
  199. package/dist/fields/config/sanitizeJoinField.js.map +1 -1
  200. package/dist/fields/config/types.d.ts +44 -118
  201. package/dist/fields/config/types.d.ts.map +1 -1
  202. package/dist/fields/config/types.js +12 -2
  203. package/dist/fields/config/types.js.map +1 -1
  204. package/dist/fields/getDefaultValue.d.ts.map +1 -1
  205. package/dist/fields/hooks/afterChange/index.d.ts.map +1 -1
  206. package/dist/fields/hooks/afterChange/promise.d.ts.map +1 -1
  207. package/dist/fields/hooks/afterChange/traverseFields.d.ts.map +1 -1
  208. package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
  209. package/dist/fields/hooks/afterRead/relationshipPopulationPromise.d.ts.map +1 -1
  210. package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
  211. package/dist/fields/hooks/afterRead/virtualFieldPopulationPromise.d.ts.map +1 -1
  212. package/dist/fields/hooks/beforeChange/cloneDataFromOriginalDoc.d.ts.map +1 -1
  213. package/dist/fields/hooks/beforeChange/getExistingRowDoc.d.ts.map +1 -1
  214. package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
  215. package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
  216. package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
  217. package/dist/fields/hooks/beforeDuplicate/index.d.ts.map +1 -1
  218. package/dist/fields/hooks/beforeDuplicate/promise.d.ts.map +1 -1
  219. package/dist/fields/hooks/beforeDuplicate/traverseFields.d.ts.map +1 -1
  220. package/dist/fields/hooks/beforeValidate/index.d.ts.map +1 -1
  221. package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
  222. package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
  223. package/dist/fields/isFieldDisabled.d.ts +12 -0
  224. package/dist/fields/isFieldDisabled.d.ts.map +1 -0
  225. package/dist/fields/isFieldDisabled.js +15 -0
  226. package/dist/fields/isFieldDisabled.js.map +1 -0
  227. package/dist/fields/isFieldDisabled.spec.js +134 -0
  228. package/dist/fields/isFieldDisabled.spec.js.map +1 -0
  229. package/dist/fields/mergeBaseFields.d.ts.map +1 -1
  230. package/dist/fields/setDefaultBeforeDuplicate.d.ts.map +1 -1
  231. package/dist/fields/validations.js +1 -1
  232. package/dist/fields/validations.js.map +1 -1
  233. package/dist/globals/config/client.d.ts +1 -1
  234. package/dist/globals/config/client.d.ts.map +1 -1
  235. package/dist/globals/config/client.js +2 -1
  236. package/dist/globals/config/client.js.map +1 -1
  237. package/dist/globals/config/sanitize.d.ts +6 -1
  238. package/dist/globals/config/sanitize.d.ts.map +1 -1
  239. package/dist/globals/config/sanitize.js +6 -2
  240. package/dist/globals/config/sanitize.js.map +1 -1
  241. package/dist/globals/config/types.d.ts +4 -57
  242. package/dist/globals/config/types.d.ts.map +1 -1
  243. package/dist/globals/config/types.js.map +1 -1
  244. package/dist/globals/operations/countGlobalVersions.d.ts.map +1 -1
  245. package/dist/globals/operations/docAccess.d.ts.map +1 -1
  246. package/dist/globals/operations/findOne.d.ts.map +1 -1
  247. package/dist/globals/operations/findOne.js +7 -2
  248. package/dist/globals/operations/findOne.js.map +1 -1
  249. package/dist/globals/operations/findVersionByID.d.ts.map +1 -1
  250. package/dist/globals/operations/findVersionByID.js +6 -4
  251. package/dist/globals/operations/findVersionByID.js.map +1 -1
  252. package/dist/globals/operations/findVersions.d.ts.map +1 -1
  253. package/dist/globals/operations/findVersions.js +6 -4
  254. package/dist/globals/operations/findVersions.js.map +1 -1
  255. package/dist/globals/operations/restoreVersion.d.ts.map +1 -1
  256. package/dist/globals/operations/update.d.ts.map +1 -1
  257. package/dist/globals/operations/update.js +7 -2
  258. package/dist/globals/operations/update.js.map +1 -1
  259. package/dist/hierarchy/addHierarchyToCollection.d.ts +9 -0
  260. package/dist/hierarchy/addHierarchyToCollection.d.ts.map +1 -0
  261. package/dist/hierarchy/addHierarchyToCollection.js +76 -0
  262. package/dist/hierarchy/addHierarchyToCollection.js.map +1 -0
  263. package/dist/hierarchy/buildParentField.d.ts +11 -0
  264. package/dist/hierarchy/buildParentField.d.ts.map +1 -0
  265. package/dist/hierarchy/buildParentField.js +42 -0
  266. package/dist/hierarchy/buildParentField.js.map +1 -0
  267. package/dist/hierarchy/constants.d.ts +15 -0
  268. package/dist/hierarchy/constants.d.ts.map +1 -0
  269. package/dist/hierarchy/constants.js +11 -0
  270. package/dist/hierarchy/constants.js.map +1 -0
  271. package/dist/hierarchy/createFolderField.d.ts +39 -0
  272. package/dist/hierarchy/createFolderField.d.ts.map +1 -0
  273. package/dist/hierarchy/createFolderField.js +54 -0
  274. package/dist/hierarchy/createFolderField.js.map +1 -0
  275. package/dist/hierarchy/createTagField.d.ts +44 -0
  276. package/dist/hierarchy/createTagField.d.ts.map +1 -0
  277. package/dist/hierarchy/createTagField.js +48 -0
  278. package/dist/hierarchy/createTagField.js.map +1 -0
  279. package/dist/hierarchy/getInitialTreeData.d.ts +27 -0
  280. package/dist/hierarchy/getInitialTreeData.d.ts.map +1 -0
  281. package/dist/hierarchy/getInitialTreeData.js +125 -0
  282. package/dist/hierarchy/getInitialTreeData.js.map +1 -0
  283. package/dist/hierarchy/hooks/collectionAfterDelete.d.ts +14 -0
  284. package/dist/hierarchy/hooks/collectionAfterDelete.d.ts.map +1 -0
  285. package/dist/hierarchy/hooks/collectionAfterDelete.js +21 -0
  286. package/dist/hierarchy/hooks/collectionAfterDelete.js.map +1 -0
  287. package/dist/hierarchy/hooks/collectionAfterRead.d.ts +27 -0
  288. package/dist/hierarchy/hooks/collectionAfterRead.d.ts.map +1 -0
  289. package/dist/hierarchy/hooks/collectionAfterRead.js +72 -0
  290. package/dist/hierarchy/hooks/collectionAfterRead.js.map +1 -0
  291. package/dist/hierarchy/hooks/collectionBeforeChange.d.ts +19 -0
  292. package/dist/hierarchy/hooks/collectionBeforeChange.d.ts.map +1 -0
  293. package/dist/hierarchy/hooks/collectionBeforeChange.js +90 -0
  294. package/dist/hierarchy/hooks/collectionBeforeChange.js.map +1 -0
  295. package/dist/hierarchy/hooks/collectionBeforeDelete.d.ts +15 -0
  296. package/dist/hierarchy/hooks/collectionBeforeDelete.d.ts.map +1 -0
  297. package/dist/hierarchy/hooks/collectionBeforeDelete.js +20 -0
  298. package/dist/hierarchy/hooks/collectionBeforeDelete.js.map +1 -0
  299. package/dist/hierarchy/hooks/collectionBeforeOperation.d.ts +33 -0
  300. package/dist/hierarchy/hooks/collectionBeforeOperation.d.ts.map +1 -0
  301. package/dist/hierarchy/hooks/collectionBeforeOperation.js +66 -0
  302. package/dist/hierarchy/hooks/collectionBeforeOperation.js.map +1 -0
  303. package/dist/hierarchy/hooks/ensureSafeCollectionsChange.d.ts +8 -0
  304. package/dist/hierarchy/hooks/ensureSafeCollectionsChange.d.ts.map +1 -0
  305. package/dist/hierarchy/hooks/ensureSafeCollectionsChange.js +108 -0
  306. package/dist/hierarchy/hooks/ensureSafeCollectionsChange.js.map +1 -0
  307. package/dist/hierarchy/injectHierarchyButton.d.ts +14 -0
  308. package/dist/hierarchy/injectHierarchyButton.d.ts.map +1 -0
  309. package/dist/hierarchy/injectHierarchyButton.js +37 -0
  310. package/dist/hierarchy/injectHierarchyButton.js.map +1 -0
  311. package/dist/hierarchy/presets.d.ts +13 -0
  312. package/dist/hierarchy/presets.d.ts.map +1 -0
  313. package/dist/hierarchy/presets.js +52 -0
  314. package/dist/hierarchy/presets.js.map +1 -0
  315. package/dist/hierarchy/resolveHierarchyCollections.d.ts +23 -0
  316. package/dist/hierarchy/resolveHierarchyCollections.d.ts.map +1 -0
  317. package/dist/hierarchy/resolveHierarchyCollections.js +321 -0
  318. package/dist/hierarchy/resolveHierarchyCollections.js.map +1 -0
  319. package/dist/hierarchy/sanitizeHierarchyCollection.d.ts +14 -0
  320. package/dist/hierarchy/sanitizeHierarchyCollection.d.ts.map +1 -0
  321. package/dist/hierarchy/sanitizeHierarchyCollection.js +119 -0
  322. package/dist/hierarchy/sanitizeHierarchyCollection.js.map +1 -0
  323. package/dist/hierarchy/types.d.ts +162 -0
  324. package/dist/hierarchy/types.d.ts.map +1 -0
  325. package/dist/hierarchy/types.js +6 -0
  326. package/dist/hierarchy/types.js.map +1 -0
  327. package/dist/hierarchy/utils/buildLocalizedHierarchyPaths.d.ts +77 -0
  328. package/dist/hierarchy/utils/buildLocalizedHierarchyPaths.d.ts.map +1 -0
  329. package/dist/hierarchy/utils/buildLocalizedHierarchyPaths.js +77 -0
  330. package/dist/hierarchy/utils/buildLocalizedHierarchyPaths.js.map +1 -0
  331. package/dist/hierarchy/utils/computePaths.d.ts +31 -0
  332. package/dist/hierarchy/utils/computePaths.d.ts.map +1 -0
  333. package/dist/hierarchy/utils/computePaths.js +445 -0
  334. package/dist/hierarchy/utils/computePaths.js.map +1 -0
  335. package/dist/hierarchy/utils/findUseAsTitle.d.ts +14 -0
  336. package/dist/hierarchy/utils/findUseAsTitle.d.ts.map +1 -0
  337. package/dist/hierarchy/utils/findUseAsTitle.js +89 -0
  338. package/dist/hierarchy/utils/findUseAsTitle.js.map +1 -0
  339. package/dist/hierarchy/utils/getAncestors.d.ts +34 -0
  340. package/dist/hierarchy/utils/getAncestors.d.ts.map +1 -0
  341. package/dist/hierarchy/utils/getAncestors.js +94 -0
  342. package/dist/hierarchy/utils/getAncestors.js.map +1 -0
  343. package/dist/hierarchy/utils/getLocalizedValue.d.ts +30 -0
  344. package/dist/hierarchy/utils/getLocalizedValue.d.ts.map +1 -0
  345. package/dist/hierarchy/utils/getLocalizedValue.js +46 -0
  346. package/dist/hierarchy/utils/getLocalizedValue.js.map +1 -0
  347. package/dist/hierarchy/utils/getLocalizedValue.spec.js +250 -0
  348. package/dist/hierarchy/utils/getLocalizedValue.spec.js.map +1 -0
  349. package/dist/index.bundled.d.ts +1017 -672
  350. package/dist/index.d.ts +32 -10
  351. package/dist/index.d.ts.map +1 -1
  352. package/dist/index.js +13 -8
  353. package/dist/index.js.map +1 -1
  354. package/dist/kv/adapters/DatabaseKVAdapter.d.ts.map +1 -1
  355. package/dist/locked-documents/config.d.ts.map +1 -1
  356. package/dist/preferences/config.d.ts.map +1 -1
  357. package/dist/preferences/deleteUserPreferences.d.ts.map +1 -1
  358. package/dist/preferences/keys.d.ts +8 -4
  359. package/dist/preferences/keys.d.ts.map +1 -1
  360. package/dist/preferences/keys.js +7 -4
  361. package/dist/preferences/keys.js.map +1 -1
  362. package/dist/preferences/types.d.ts +1 -1
  363. package/dist/preferences/types.d.ts.map +1 -1
  364. package/dist/preferences/types.js.map +1 -1
  365. package/dist/query-presets/access.d.ts.map +1 -1
  366. package/dist/query-presets/config.d.ts.map +1 -1
  367. package/dist/query-presets/config.js +11 -7
  368. package/dist/query-presets/config.js.map +1 -1
  369. package/dist/query-presets/constraints.d.ts.map +1 -1
  370. package/dist/query-presets/constraints.js +1 -1
  371. package/dist/query-presets/constraints.js.map +1 -1
  372. package/dist/queues/config/generateJobsJSONSchemas.d.ts +1 -1
  373. package/dist/queues/config/generateJobsJSONSchemas.d.ts.map +1 -1
  374. package/dist/queues/config/generateJobsJSONSchemas.js +31 -10
  375. package/dist/queues/config/generateJobsJSONSchemas.js.map +1 -1
  376. package/dist/queues/config/types/index.d.ts +0 -21
  377. package/dist/queues/config/types/index.d.ts.map +1 -1
  378. package/dist/queues/config/types/index.js.map +1 -1
  379. package/dist/queues/config/types/taskTypes.d.ts +0 -20
  380. package/dist/queues/config/types/taskTypes.d.ts.map +1 -1
  381. package/dist/queues/config/types/taskTypes.js.map +1 -1
  382. package/dist/queues/endpoints/run.d.ts.map +1 -1
  383. package/dist/queues/errors/handleWorkflowError.d.ts.map +1 -1
  384. package/dist/queues/errors/handleWorkflowError.js +9 -1
  385. package/dist/queues/errors/handleWorkflowError.js.map +1 -1
  386. package/dist/queues/localAPI.d.ts.map +1 -1
  387. package/dist/queues/localAPI.js +26 -67
  388. package/dist/queues/localAPI.js.map +1 -1
  389. package/dist/queues/operations/handleSchedules/getQueuesWithSchedules.d.ts.map +1 -1
  390. package/dist/queues/operations/handleSchedules/index.d.ts.map +1 -1
  391. package/dist/queues/operations/handleSchedules/index.js +1 -4
  392. package/dist/queues/operations/handleSchedules/index.js.map +1 -1
  393. package/dist/queues/operations/runJobs/index.d.ts.map +1 -1
  394. package/dist/queues/operations/runJobs/index.js +40 -37
  395. package/dist/queues/operations/runJobs/index.js.map +1 -1
  396. package/dist/queues/operations/runJobs/runJSONJob/index.d.ts.map +1 -1
  397. package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.d.ts.map +1 -1
  398. package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js +3 -22
  399. package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.js.map +1 -1
  400. package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.d.ts.map +1 -1
  401. package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.js +0 -2
  402. package/dist/queues/operations/runJobs/runJob/getUpdateJobFunction.js.map +1 -1
  403. package/dist/queues/operations/runJobs/runJob/index.d.ts.map +1 -1
  404. package/dist/queues/utilities/getJobTaskStatus.d.ts.map +1 -1
  405. package/dist/queues/utilities/updateJob.d.ts +1 -3
  406. package/dist/queues/utilities/updateJob.d.ts.map +1 -1
  407. package/dist/queues/utilities/updateJob.js +2 -18
  408. package/dist/queues/utilities/updateJob.js.map +1 -1
  409. package/dist/translations/getLocalI18n.d.ts.map +1 -1
  410. package/dist/types/index.d.ts +54 -5
  411. package/dist/types/index.d.ts.map +1 -1
  412. package/dist/types/index.js.map +1 -1
  413. package/dist/uploads/checkFileAccess.d.ts.map +1 -1
  414. package/dist/uploads/checkFileRestrictions.d.ts.map +1 -1
  415. package/dist/uploads/docWithFilenameExists.d.ts.map +1 -1
  416. package/dist/uploads/endpoints/getFileFromURL.d.ts.map +1 -1
  417. package/dist/uploads/endpoints/getFileFromURL.js +9 -5
  418. package/dist/uploads/endpoints/getFileFromURL.js.map +1 -1
  419. package/dist/uploads/fetchAPI-multipart/isEligibleRequest.d.ts.map +1 -1
  420. package/dist/uploads/fetchAPI-multipart/processNested.d.ts.map +1 -1
  421. package/dist/uploads/fetchAPI-multipart/utilities.d.ts.map +1 -1
  422. package/dist/uploads/fileExists.d.ts.map +1 -1
  423. package/dist/uploads/generateFileData.d.ts.map +1 -1
  424. package/dist/uploads/getBaseFields.d.ts.map +1 -1
  425. package/dist/uploads/getBaseFields.js +24 -70
  426. package/dist/uploads/getBaseFields.js.map +1 -1
  427. package/dist/uploads/getExternalFile.d.ts.map +1 -1
  428. package/dist/uploads/getFileByPath.d.ts.map +1 -1
  429. package/dist/uploads/getFileTypeFallback.d.ts.map +1 -1
  430. package/dist/uploads/getSafeFilename.d.ts +9 -4
  431. package/dist/uploads/getSafeFilename.d.ts.map +1 -1
  432. package/dist/uploads/getSafeFilename.js +5 -5
  433. package/dist/uploads/getSafeFilename.js.map +1 -1
  434. package/dist/uploads/image-resizing/createImageSize.d.ts.map +1 -1
  435. package/dist/uploads/image-resizing/generateImageSizeFilename.d.ts.map +1 -1
  436. package/dist/uploads/image-resizing/getImageResizeAction.d.ts.map +1 -1
  437. package/dist/uploads/image-resizing/parseFilename.d.ts.map +1 -1
  438. package/dist/uploads/image-resizing/sanitizeResizeConfig.d.ts.map +1 -1
  439. package/dist/uploads/mimeTypeValidator.d.ts.map +1 -1
  440. package/dist/uploads/safeFetch.d.ts +1 -1
  441. package/dist/uploads/safeFetch.d.ts.map +1 -1
  442. package/dist/uploads/saveBufferToFile.d.ts.map +1 -1
  443. package/dist/uploads/tempFile.d.ts.map +1 -1
  444. package/dist/uploads/types.d.ts +12 -29
  445. package/dist/uploads/types.d.ts.map +1 -1
  446. package/dist/uploads/types.js.map +1 -1
  447. package/dist/uploads/uploadFiles.d.ts.map +1 -1
  448. package/dist/utilities/addLocalesToRequest.d.ts.map +1 -1
  449. package/dist/utilities/addSelectGenericsToGeneretedTypes.d.ts.map +1 -1
  450. package/dist/utilities/appendDateTimezoneSelectFields.d.ts +13 -0
  451. package/dist/utilities/appendDateTimezoneSelectFields.d.ts.map +1 -0
  452. package/dist/utilities/appendDateTimezoneSelectFields.js +47 -0
  453. package/dist/utilities/appendDateTimezoneSelectFields.js.map +1 -0
  454. package/dist/utilities/appendNonTrashedFilter.d.ts.map +1 -1
  455. package/dist/utilities/appendUploadSelectFields.d.ts.map +1 -1
  456. package/dist/utilities/appendUploadSelectFields.js +3 -0
  457. package/dist/utilities/appendUploadSelectFields.js.map +1 -1
  458. package/dist/utilities/canAccessAdmin.d.ts.map +1 -1
  459. package/dist/utilities/checkDocumentLockStatus.d.ts.map +1 -1
  460. package/dist/utilities/configToJSONSchema.d.ts +34 -16
  461. package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
  462. package/dist/utilities/configToJSONSchema.js +127 -52
  463. package/dist/utilities/configToJSONSchema.js.map +1 -1
  464. package/dist/utilities/configToJSONSchema.spec.js +94 -65
  465. package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
  466. package/dist/utilities/createPayloadRequest.d.ts.map +1 -1
  467. package/dist/utilities/deepCopyObject.d.ts.map +1 -1
  468. package/dist/utilities/dependencies/resolveFrom.d.ts.map +1 -1
  469. package/dist/utilities/escapeRegExp.d.ts.map +1 -1
  470. package/dist/utilities/extractID.d.ts.map +1 -1
  471. package/dist/utilities/extractID.js +1 -1
  472. package/dist/utilities/extractID.js.map +1 -1
  473. package/dist/utilities/flattenAllFields.d.ts.map +1 -1
  474. package/dist/utilities/formatAdminURL.d.ts +13 -2
  475. package/dist/utilities/formatAdminURL.d.ts.map +1 -1
  476. package/dist/utilities/formatAdminURL.js +3 -15
  477. package/dist/utilities/formatAdminURL.js.map +1 -1
  478. package/dist/utilities/formatAdminURL.spec.js +1 -90
  479. package/dist/utilities/formatAdminURL.spec.js.map +1 -1
  480. package/dist/utilities/formatErrors.d.ts.map +1 -1
  481. package/dist/utilities/formatLabels.d.ts.map +1 -1
  482. package/dist/utilities/getBestFitFromSizes.d.ts.map +1 -1
  483. package/dist/utilities/getBlockSelect.d.ts.map +1 -1
  484. package/dist/utilities/getDataByPath.d.ts.map +1 -1
  485. package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts.map +1 -1
  486. package/dist/utilities/getFieldByPath.d.ts.map +1 -1
  487. package/dist/utilities/getFieldPermissions.d.ts.map +1 -1
  488. package/dist/utilities/getObjectDotNotation.d.ts.map +1 -1
  489. package/dist/utilities/getRequestEntity.d.ts.map +1 -1
  490. package/dist/utilities/getRequestLanguage.d.ts.map +1 -1
  491. package/dist/utilities/getRequestOrigin.d.ts.map +1 -1
  492. package/dist/utilities/getSafeRedirect.d.ts.map +1 -1
  493. package/dist/utilities/getSelectMode.d.ts.map +1 -1
  494. package/dist/utilities/getSiblingData.d.ts.map +1 -1
  495. package/dist/utilities/getTranslatedLabel.d.ts.map +1 -1
  496. package/dist/utilities/getVersionsConfig.d.ts.map +1 -1
  497. package/dist/utilities/handleEndpoints.d.ts.map +1 -1
  498. package/dist/utilities/handleEndpoints.js +2 -6
  499. package/dist/utilities/handleEndpoints.js.map +1 -1
  500. package/dist/utilities/headersWithCors.d.ts.map +1 -1
  501. package/dist/utilities/isEntityHidden.d.ts.map +1 -1
  502. package/dist/utilities/isURLAllowed.d.ts.map +1 -1
  503. package/dist/utilities/isValidID.d.ts.map +1 -1
  504. package/dist/utilities/logError.d.ts.map +1 -1
  505. package/dist/utilities/logger.d.ts.map +1 -1
  506. package/dist/utilities/mergeHeaders.d.ts.map +1 -1
  507. package/dist/utilities/mergeListSearchAndWhere.d.ts.map +1 -1
  508. package/dist/utilities/optionsAreEqual.d.ts.map +1 -1
  509. package/dist/utilities/parseBooleanString.d.ts.map +1 -1
  510. package/dist/utilities/parseCookies.d.ts.map +1 -1
  511. package/dist/utilities/parseParams/index.d.ts.map +1 -1
  512. package/dist/utilities/profiling.d.ts.map +1 -1
  513. package/dist/utilities/reduceFieldsToValues.d.ts.map +1 -1
  514. package/dist/utilities/resolveSelect.d.ts +16 -0
  515. package/dist/utilities/resolveSelect.d.ts.map +1 -0
  516. package/dist/utilities/resolveSelect.js +19 -0
  517. package/dist/utilities/resolveSelect.js.map +1 -0
  518. package/dist/utilities/routeError.d.ts.map +1 -1
  519. package/dist/utilities/sanitizeFallbackLocale.d.ts.map +1 -1
  520. package/dist/utilities/sanitizeInternalFields.d.ts.map +1 -1
  521. package/dist/utilities/sanitizeJoinParams.d.ts.map +1 -1
  522. package/dist/utilities/sanitizePopulateParam.d.ts.map +1 -1
  523. package/dist/utilities/sanitizeSelect.d.ts +1 -2
  524. package/dist/utilities/sanitizeSelect.d.ts.map +1 -1
  525. package/dist/utilities/sanitizeSelect.js +19 -25
  526. package/dist/utilities/sanitizeSelect.js.map +1 -1
  527. package/dist/utilities/sanitizeSelectParam.d.ts.map +1 -1
  528. package/dist/utilities/sanitizeSortParams.d.ts.map +1 -1
  529. package/dist/utilities/setsAreEqual.d.ts.map +1 -1
  530. package/dist/utilities/slugify.d.ts.map +1 -1
  531. package/dist/utilities/stripUnselectedFields.d.ts.map +1 -1
  532. package/dist/utilities/telemetry/events/adminInit.d.ts.map +1 -1
  533. package/dist/utilities/telemetry/events/serverInit.d.ts.map +1 -1
  534. package/dist/utilities/telemetry/index.d.ts.map +1 -1
  535. package/dist/utilities/telemetry/oneWayHash.d.ts.map +1 -1
  536. package/dist/utilities/timestamp.d.ts.map +1 -1
  537. package/dist/utilities/toKebabCase.d.ts.map +1 -1
  538. package/dist/utilities/transformColumnPreferences.d.ts.map +1 -1
  539. package/dist/utilities/transformWhereQuery.d.ts.map +1 -1
  540. package/dist/utilities/traverseFields.d.ts.map +1 -1
  541. package/dist/utilities/traverseForLocalizedFields.d.ts.map +1 -1
  542. package/dist/utilities/unflatten.d.ts.map +1 -1
  543. package/dist/utilities/validateMimeType.d.ts.map +1 -1
  544. package/dist/utilities/validateTimezones.d.ts.map +1 -1
  545. package/dist/utilities/validateWhereQuery.d.ts.map +1 -1
  546. package/dist/utilities/wordBoundariesRegex.d.ts.map +1 -1
  547. package/dist/utilities/wrapInternalEndpoints.d.ts.map +1 -1
  548. package/dist/versions/baseFields.d.ts.map +1 -1
  549. package/dist/versions/baseFields.js +3 -2
  550. package/dist/versions/baseFields.js.map +1 -1
  551. package/dist/versions/buildCollectionFields.d.ts.map +1 -1
  552. package/dist/versions/buildCollectionFields.js +0 -1
  553. package/dist/versions/buildCollectionFields.js.map +1 -1
  554. package/dist/versions/buildGlobalFields.d.ts.map +1 -1
  555. package/dist/versions/buildGlobalFields.js +0 -1
  556. package/dist/versions/buildGlobalFields.js.map +1 -1
  557. package/dist/versions/buildVersionCompoundIndexes.d.ts.map +1 -1
  558. package/dist/versions/deleteCollectionVersions.d.ts.map +1 -1
  559. package/dist/versions/deleteScheduledPublishJobs.d.ts.map +1 -1
  560. package/dist/versions/drafts/appendVersionToQueryKey.d.ts.map +1 -1
  561. package/dist/versions/drafts/getQueryDraftsSelect.d.ts.map +1 -1
  562. package/dist/versions/drafts/getQueryDraftsSort.d.ts.map +1 -1
  563. package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts.map +1 -1
  564. package/dist/versions/enforceMaxVersions.d.ts.map +1 -1
  565. package/dist/versions/getLatestCollectionVersion.d.ts.map +1 -1
  566. package/dist/versions/getLatestGlobalVersion.d.ts.map +1 -1
  567. package/dist/versions/migrations/localizeStatus/shared.d.ts.map +1 -1
  568. package/dist/versions/payloadPackageList.d.ts.map +1 -1
  569. package/dist/versions/payloadPackageList.js +0 -1
  570. package/dist/versions/payloadPackageList.js.map +1 -1
  571. package/dist/versions/saveSnapshot.d.ts.map +1 -1
  572. package/dist/versions/schedule/job.d.ts.map +1 -1
  573. package/package.json +20 -20
  574. package/dist/admin/views/folderList.d.ts +0 -56
  575. package/dist/admin/views/folderList.d.ts.map +0 -1
  576. package/dist/admin/views/folderList.js +0 -3
  577. package/dist/admin/views/folderList.js.map +0 -1
  578. package/dist/folders/addFolderCollection.d.ts +0 -10
  579. package/dist/folders/addFolderCollection.d.ts.map +0 -1
  580. package/dist/folders/addFolderCollection.js +0 -26
  581. package/dist/folders/addFolderCollection.js.map +0 -1
  582. package/dist/folders/addFolderFieldToCollection.d.ts +0 -8
  583. package/dist/folders/addFolderFieldToCollection.d.ts.map +0 -1
  584. package/dist/folders/addFolderFieldToCollection.js +0 -20
  585. package/dist/folders/addFolderFieldToCollection.js.map +0 -1
  586. package/dist/folders/buildFolderField.d.ts +0 -8
  587. package/dist/folders/buildFolderField.d.ts.map +0 -1
  588. package/dist/folders/buildFolderField.js +0 -87
  589. package/dist/folders/buildFolderField.js.map +0 -1
  590. package/dist/folders/constants.d.ts +0 -3
  591. package/dist/folders/constants.d.ts.map +0 -1
  592. package/dist/folders/constants.js +0 -4
  593. package/dist/folders/constants.js.map +0 -1
  594. package/dist/folders/createFolderCollection.d.ts +0 -11
  595. package/dist/folders/createFolderCollection.d.ts.map +0 -1
  596. package/dist/folders/createFolderCollection.js +0 -115
  597. package/dist/folders/createFolderCollection.js.map +0 -1
  598. package/dist/folders/hooks/deleteSubfoldersAfterDelete.d.ts +0 -8
  599. package/dist/folders/hooks/deleteSubfoldersAfterDelete.d.ts.map +0 -1
  600. package/dist/folders/hooks/deleteSubfoldersAfterDelete.js +0 -15
  601. package/dist/folders/hooks/deleteSubfoldersAfterDelete.js.map +0 -1
  602. package/dist/folders/hooks/dissasociateAfterDelete.d.ts +0 -8
  603. package/dist/folders/hooks/dissasociateAfterDelete.d.ts.map +0 -1
  604. package/dist/folders/hooks/dissasociateAfterDelete.js +0 -20
  605. package/dist/folders/hooks/dissasociateAfterDelete.js.map +0 -1
  606. package/dist/folders/hooks/ensureSafeCollectionsChange.d.ts +0 -5
  607. package/dist/folders/hooks/ensureSafeCollectionsChange.d.ts.map +0 -1
  608. package/dist/folders/hooks/ensureSafeCollectionsChange.js +0 -107
  609. package/dist/folders/hooks/ensureSafeCollectionsChange.js.map +0 -1
  610. package/dist/folders/hooks/reparentChildFolder.d.ts +0 -24
  611. package/dist/folders/hooks/reparentChildFolder.d.ts.map +0 -1
  612. package/dist/folders/hooks/reparentChildFolder.js +0 -72
  613. package/dist/folders/hooks/reparentChildFolder.js.map +0 -1
  614. package/dist/folders/types.d.ts +0 -118
  615. package/dist/folders/types.d.ts.map +0 -1
  616. package/dist/folders/types.js +0 -3
  617. package/dist/folders/types.js.map +0 -1
  618. package/dist/folders/utils/buildFolderWhereConstraints.d.ts +0 -13
  619. package/dist/folders/utils/buildFolderWhereConstraints.d.ts.map +0 -1
  620. package/dist/folders/utils/buildFolderWhereConstraints.js +0 -45
  621. package/dist/folders/utils/buildFolderWhereConstraints.js.map +0 -1
  622. package/dist/folders/utils/formatFolderOrDocumentItem.d.ts +0 -12
  623. package/dist/folders/utils/formatFolderOrDocumentItem.d.ts.map +0 -1
  624. package/dist/folders/utils/formatFolderOrDocumentItem.js +0 -30
  625. package/dist/folders/utils/formatFolderOrDocumentItem.js.map +0 -1
  626. package/dist/folders/utils/getFolderBreadcrumbs.d.ts +0 -14
  627. package/dist/folders/utils/getFolderBreadcrumbs.d.ts.map +0 -1
  628. package/dist/folders/utils/getFolderBreadcrumbs.js +0 -45
  629. package/dist/folders/utils/getFolderBreadcrumbs.js.map +0 -1
  630. package/dist/folders/utils/getFolderData.d.ts +0 -33
  631. package/dist/folders/utils/getFolderData.d.ts.map +0 -1
  632. package/dist/folders/utils/getFolderData.js +0 -88
  633. package/dist/folders/utils/getFolderData.js.map +0 -1
  634. package/dist/folders/utils/getFoldersAndDocumentsFromJoin.d.ts +0 -24
  635. package/dist/folders/utils/getFoldersAndDocumentsFromJoin.d.ts.map +0 -1
  636. package/dist/folders/utils/getFoldersAndDocumentsFromJoin.js +0 -66
  637. package/dist/folders/utils/getFoldersAndDocumentsFromJoin.js.map +0 -1
  638. package/dist/folders/utils/getOrphanedDocs.d.ts +0 -15
  639. package/dist/folders/utils/getOrphanedDocs.d.ts.map +0 -1
  640. package/dist/folders/utils/getOrphanedDocs.js +0 -40
  641. package/dist/folders/utils/getOrphanedDocs.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/config/orderable/index.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { BeforeChangeHook, CollectionConfig } from '../../collections/config/types.js'\nimport type { Config } from '../../config/types.js'\nimport type { Field, TextField } from '../../fields/config/types.js'\nimport type { Endpoint, PayloadHandler, SanitizedConfig } from '../types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { APIError } from '../../errors/index.js'\nimport { sanitizeField } from '../../fields/config/sanitize.js'\nimport { combineWhereConstraints } from '../../utilities/combineWhereConstraints.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { generateKeyBetween, generateNKeysBetween } from './fractional-indexing.js'\nimport { getJoinScopeContext } from './utils/getJoinScopeContext.js'\nimport { getJoinScopeWhereFromDocData } from './utils/getJoinScopeWhereFromDocData.js'\nimport { resolvePendingTargetKey } from './utils/resolvePendingTargetKey.js'\n\nexport const addOrderableFieldsAndHook = async (\n collection: CollectionConfig,\n config: Config,\n orderableFieldNames: string[],\n joinFieldPathsByCollection?: Map<string, Map<string, string>>,\n) => {\n // 1. Add fields\n for (const orderableFieldName of orderableFieldNames) {\n const orderField: TextField = {\n name: orderableFieldName,\n type: 'text',\n admin: {\n disableBulkEdit: true,\n disabled: true,\n disableGroupBy: true,\n disableListColumn: true,\n disableListFilter: true,\n hidden: true,\n readOnly: true,\n },\n hooks: {\n beforeDuplicate: [\n ({ siblingData }) => {\n delete siblingData[orderableFieldName]\n },\n ],\n },\n index: true,\n }\n\n // Sanitize the field using the standard sanitization logic\n await sanitizeField({\n collectionConfig: collection,\n config,\n existingFieldNames: new Set(),\n field: orderField,\n index: 0,\n isTopLevelField: true,\n joinPath: '',\n parentIndexPath: '',\n parentIsLocalized: false,\n parentSchemaPath: '',\n requireFieldLevelRichTextEditor: false,\n validRelationships: null,\n })\n\n collection.fields.unshift(orderField)\n }\n\n // 2. Add hook\n if (!collection.hooks) {\n collection.hooks = {}\n }\n if (!collection.hooks.beforeChange) {\n collection.hooks.beforeChange = []\n }\n\n const orderBeforeChangeHook: BeforeChangeHook = async ({ data, originalDoc, req }) => {\n for (const orderableFieldName of orderableFieldNames) {\n if (!data[orderableFieldName] && !originalDoc?.[orderableFieldName]) {\n const joinScopeWhere = getJoinScopeWhereFromDocData({\n collectionSlug: collection.slug,\n data,\n joinFieldPathsByCollection,\n orderableFieldName,\n originalDoc,\n })\n\n const lastDoc = await req.payload.find({\n collection: collection.slug,\n depth: 0,\n limit: 1,\n pagination: false,\n req,\n select: { [orderableFieldName]: true },\n sort: `-${orderableFieldName}`,\n where: combineWhereConstraints([\n {\n [orderableFieldName]: {\n exists: true,\n },\n },\n joinScopeWhere ?? undefined,\n ]),\n })\n\n const lastOrderValue = lastDoc.docs[0]?.[orderableFieldName] || null\n data[orderableFieldName] = generateKeyBetween(lastOrderValue, null)\n }\n }\n\n return data\n }\n\n collection.hooks.beforeChange.push(orderBeforeChangeHook)\n}\n\n/**\n * The body of the reorder endpoint.\n * @internal\n */\nexport type OrderableEndpointBody = {\n collectionSlug: string\n docsToMove: string[]\n newKeyWillBe: 'greater' | 'less'\n orderableFieldName: string\n target: {\n id: string\n key: string\n }\n}\n\nexport const addOrderableEndpoint = (\n config: SanitizedConfig,\n joinFieldPathsByCollection: Map<string, Map<string, string>>,\n) => {\n // 3. Add endpoint\n const reorderHandler: PayloadHandler = async (req) => {\n const body = (await req.json?.()) as OrderableEndpointBody\n\n const { collectionSlug, docsToMove, newKeyWillBe, orderableFieldName, target } = body\n\n if (!Array.isArray(docsToMove) || docsToMove.length === 0) {\n return new Response(JSON.stringify({ error: 'docsToMove must be a non-empty array' }), {\n headers: { 'Content-Type': 'application/json' },\n status: 400,\n })\n }\n if (newKeyWillBe !== 'greater' && newKeyWillBe !== 'less') {\n return new Response(JSON.stringify({ error: 'newKeyWillBe must be \"greater\" or \"less\"' }), {\n headers: { 'Content-Type': 'application/json' },\n status: 400,\n })\n }\n const collection = config.collections.find((c) => c.slug === collectionSlug)\n if (!collection) {\n return new Response(JSON.stringify({ error: `Collection ${collectionSlug} not found` }), {\n headers: { 'Content-Type': 'application/json' },\n status: 400,\n })\n }\n if (typeof orderableFieldName !== 'string') {\n return new Response(JSON.stringify({ error: 'orderableFieldName must be a string' }), {\n headers: { 'Content-Type': 'application/json' },\n status: 400,\n })\n }\n\n const { joinScopeWhere, targetDoc } = await getJoinScopeContext({\n collectionSlug: collection.slug,\n joinFieldPathsByCollection,\n orderableFieldName,\n req,\n target,\n })\n\n // Prevent reordering if user doesn't have editing permissions\n if (collection.access?.update) {\n await executeAccess(\n {\n // Currently only one doc can be moved at a time. We should review this if we want to allow\n // multiple docs to be moved at once in the future.\n id: docsToMove[0],\n data: {},\n req,\n },\n collection.access.update,\n )\n }\n /**\n * If there is no target.key, we can assume the user enabled `orderable`\n * on a collection with existing documents, and that this is the first\n * time they tried to reorder them. Therefore, we perform a one-time\n * migration by setting the key value for all documents. We do this\n * instead of enforcing `required` and `unique` at the database schema\n * level, so that users don't have to run a migration when they enable\n * `orderable` on a collection with existing documents.\n */\n if (!target.key) {\n const { docs } = await req.payload.find({\n collection: collection.slug,\n depth: 0,\n limit: 0,\n req,\n select: { [orderableFieldName]: true },\n where: combineWhereConstraints([\n {\n [orderableFieldName]: {\n exists: false,\n },\n },\n joinScopeWhere ?? undefined,\n ]),\n })\n await initTransaction(req)\n // We cannot update all documents in a single operation with `payload.update`,\n // because they would all end up with the same order key (`a0`).\n try {\n for (const doc of docs) {\n await req.payload.update({\n id: doc.id,\n collection: collection.slug,\n data: {\n // no data needed since the order hooks will handle this\n },\n depth: 0,\n req,\n })\n await commitTransaction(req)\n }\n } catch (e) {\n await killTransaction(req)\n if (e instanceof Error) {\n throw new APIError(e.message, httpStatus.INTERNAL_SERVER_ERROR)\n }\n }\n\n return new Response(JSON.stringify({ message: 'initial migration', success: true }), {\n headers: { 'Content-Type': 'application/json' },\n status: 200,\n })\n }\n\n if (\n typeof target !== 'object' ||\n typeof target.id === 'undefined' ||\n typeof target.key !== 'string'\n ) {\n return new Response(JSON.stringify({ error: 'target must be an object with id' }), {\n headers: { 'Content-Type': 'application/json' },\n status: 400,\n })\n }\n\n const targetId = target.id\n const targetKey = await resolvePendingTargetKey({\n collectionSlug: collection.slug,\n orderableFieldName,\n req,\n targetDoc,\n targetID: targetId,\n targetKey: target.key,\n })\n\n // The reason the endpoint does not receive this docId as an argument is that there\n // are situations where the user may not see or know what the next or previous one is. For\n // example, access control restrictions, if docBefore is the last one on the page, etc.\n const adjacentDoc = await req.payload.find({\n collection: collection.slug,\n depth: 0,\n limit: 1,\n pagination: false,\n select: { [orderableFieldName]: true },\n sort: newKeyWillBe === 'greater' ? orderableFieldName : `-${orderableFieldName}`,\n where: combineWhereConstraints([\n {\n [orderableFieldName]: {\n [newKeyWillBe === 'greater' ? 'greater_than' : 'less_than']: targetKey,\n },\n },\n joinScopeWhere ?? undefined,\n ]),\n })\n const adjacentDocKey = adjacentDoc.docs?.[0]?.[orderableFieldName] || null\n\n // Currently N (= docsToMove.length) is always 1. Maybe in the future we will\n // allow dragging and reordering multiple documents at once via the UI.\n const orderValues =\n newKeyWillBe === 'greater'\n ? generateNKeysBetween(targetKey, adjacentDocKey, docsToMove.length)\n : generateNKeysBetween(adjacentDocKey, targetKey, docsToMove.length)\n\n // Update each document with its new order value\n for (const [index, id] of docsToMove.entries()) {\n await req.payload.update({\n id,\n collection: collection.slug,\n data: {\n [orderableFieldName]: orderValues[index],\n },\n depth: 0,\n req,\n })\n }\n\n return new Response(JSON.stringify({ orderValues, success: true }), {\n headers: { 'Content-Type': 'application/json' },\n status: 200,\n })\n }\n\n const reorderEndpoint: Endpoint = {\n handler: reorderHandler,\n method: 'post',\n path: '/reorder',\n }\n\n if (!config.endpoints) {\n config.endpoints = []\n }\n\n config.endpoints.push(reorderEndpoint)\n}\n"],"names":["status","httpStatus","executeAccess","APIError","sanitizeField","combineWhereConstraints","commitTransaction","initTransaction","killTransaction","generateKeyBetween","generateNKeysBetween","getJoinScopeContext","getJoinScopeWhereFromDocData","resolvePendingTargetKey","addOrderableFieldsAndHook","collection","config","orderableFieldNames","joinFieldPathsByCollection","orderableFieldName","orderField","name","type","admin","disableBulkEdit","disabled","disableGroupBy","disableListColumn","disableListFilter","hidden","readOnly","hooks","beforeDuplicate","siblingData","index","collectionConfig","existingFieldNames","Set","field","isTopLevelField","joinPath","parentIndexPath","parentIsLocalized","parentSchemaPath","requireFieldLevelRichTextEditor","validRelationships","fields","unshift","beforeChange","orderBeforeChangeHook","data","originalDoc","req","joinScopeWhere","collectionSlug","slug","lastDoc","payload","find","depth","limit","pagination","select","sort","where","exists","undefined","lastOrderValue","docs","push","addOrderableEndpoint","reorderHandler","body","json","docsToMove","newKeyWillBe","target","Array","isArray","length","Response","JSON","stringify","error","headers","collections","c","targetDoc","access","update","id","key","doc","e","Error","message","INTERNAL_SERVER_ERROR","success","targetId","targetKey","targetID","adjacentDoc","adjacentDocKey","orderValues","entries","reorderEndpoint","handler","method","path","endpoints"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAOlD,SAASC,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,aAAa,QAAQ,kCAAiC;AAC/D,SAASC,uBAAuB,QAAQ,6CAA4C;AACpF,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,kBAAkB,EAAEC,oBAAoB,QAAQ,2BAA0B;AACnF,SAASC,mBAAmB,QAAQ,iCAAgC;AACpE,SAASC,4BAA4B,QAAQ,0CAAyC;AACtF,SAASC,uBAAuB,QAAQ,qCAAoC;AAE5E,OAAO,MAAMC,4BAA4B,OACvCC,YACAC,QACAC,qBACAC;IAEA,gBAAgB;IAChB,KAAK,MAAMC,sBAAsBF,oBAAqB;QACpD,MAAMG,aAAwB;YAC5BC,MAAMF;YACNG,MAAM;YACNC,OAAO;gBACLC,iBAAiB;gBACjBC,UAAU;gBACVC,gBAAgB;gBAChBC,mBAAmB;gBACnBC,mBAAmB;gBACnBC,QAAQ;gBACRC,UAAU;YACZ;YACAC,OAAO;gBACLC,iBAAiB;oBACf,CAAC,EAAEC,WAAW,EAAE;wBACd,OAAOA,WAAW,CAACd,mBAAmB;oBACxC;iBACD;YACH;YACAe,OAAO;QACT;QAEA,2DAA2D;QAC3D,MAAM9B,cAAc;YAClB+B,kBAAkBpB;YAClBC;YACAoB,oBAAoB,IAAIC;YACxBC,OAAOlB;YACPc,OAAO;YACPK,iBAAiB;YACjBC,UAAU;YACVC,iBAAiB;YACjBC,mBAAmB;YACnBC,kBAAkB;YAClBC,iCAAiC;YACjCC,oBAAoB;QACtB;QAEA9B,WAAW+B,MAAM,CAACC,OAAO,CAAC3B;IAC5B;IAEA,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AASC,KAAKC,SAAS,CAAC;YAAEqB;YAAaN,SAAS;QAAK,IAAI;YAClEb,SAAS;gBAAE,gBAAgB;YAAmB;YAC9CpF,QAAQ;QACV;IACF;IAEA,MAAMyG,kBAA4B;QAChCC,SAASnC;QACToC,QAAQ;QACRC,MAAM;IACR;IAEA,IAAI,CAAC5F,OAAO6F,SAAS,EAAE;QACrB7F,OAAO6F,SAAS,GAAG,EAAE;IACvB;IAEA7F,OAAO6F,SAAS,CAACxC,IAAI,CAACoC;AACxB,EAAC"}
1
+ {"version":3,"sources":["../../../src/config/orderable/index.ts"],"sourcesContent":["import { status as httpStatus } from 'http-status'\n\nimport type { BeforeChangeHook, CollectionConfig } from '../../collections/config/types.js'\nimport type { Config } from '../../config/types.js'\nimport type { Field, TextField } from '../../fields/config/types.js'\nimport type { Endpoint, PayloadHandler, SanitizedConfig } from '../types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { APIError } from '../../errors/index.js'\nimport { sanitizeField } from '../../fields/config/sanitize.js'\nimport { combineWhereConstraints } from '../../utilities/combineWhereConstraints.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { generateKeyBetween, generateNKeysBetween } from './fractional-indexing.js'\nimport { getJoinScopeContext } from './utils/getJoinScopeContext.js'\nimport { getJoinScopeWhereFromDocData } from './utils/getJoinScopeWhereFromDocData.js'\nimport { resolvePendingTargetKey } from './utils/resolvePendingTargetKey.js'\n\nexport const addOrderableFieldsAndHook = async (\n collection: CollectionConfig,\n config: Config,\n orderableFieldNames: string[],\n joinFieldPathsByCollection?: Map<string, Map<string, string>>,\n) => {\n // 1. Add fields\n for (const orderableFieldName of orderableFieldNames) {\n const orderField: TextField = {\n name: orderableFieldName,\n type: 'text',\n admin: {\n disabled: true,\n hidden: true,\n readOnly: true,\n },\n hooks: {\n beforeDuplicate: [\n ({ siblingData }) => {\n delete siblingData[orderableFieldName]\n },\n ],\n },\n index: true,\n }\n\n // Sanitize the field using the standard sanitization logic\n await sanitizeField({\n collectionConfig: collection,\n config,\n existingFieldNames: new Set(),\n field: orderField,\n index: 0,\n isTopLevelField: true,\n joinPath: '',\n parentIndexPath: '',\n parentIsLocalized: false,\n parentSchemaPath: '',\n requireFieldLevelRichTextEditor: false,\n validRelationships: null,\n })\n\n collection.fields.unshift(orderField)\n }\n\n // 2. Add hook\n if (!collection.hooks) {\n collection.hooks = {}\n }\n if (!collection.hooks.beforeChange) {\n collection.hooks.beforeChange = []\n }\n\n const orderBeforeChangeHook: BeforeChangeHook = async ({ data, originalDoc, req }) => {\n for (const orderableFieldName of orderableFieldNames) {\n if (!data[orderableFieldName] && !originalDoc?.[orderableFieldName]) {\n const joinScopeWhere = getJoinScopeWhereFromDocData({\n collectionSlug: collection.slug,\n data,\n joinFieldPathsByCollection,\n orderableFieldName,\n originalDoc,\n })\n\n const lastDoc = await req.payload.find({\n collection: collection.slug,\n depth: 0,\n limit: 1,\n pagination: false,\n req,\n select: { [orderableFieldName]: true },\n sort: `-${orderableFieldName}`,\n where: combineWhereConstraints([\n {\n [orderableFieldName]: {\n exists: true,\n },\n },\n joinScopeWhere ?? undefined,\n ]),\n })\n\n const lastOrderValue = lastDoc.docs[0]?.[orderableFieldName] || null\n data[orderableFieldName] = generateKeyBetween(lastOrderValue, null)\n }\n }\n\n return data\n }\n\n collection.hooks.beforeChange.push(orderBeforeChangeHook)\n}\n\n/**\n * The body of the reorder endpoint.\n * @internal\n */\nexport type OrderableEndpointBody = {\n collectionSlug: string\n docsToMove: string[]\n newKeyWillBe: 'greater' | 'less'\n orderableFieldName: string\n target: {\n id: string\n key: string\n }\n}\n\nexport const addOrderableEndpoint = (\n config: SanitizedConfig,\n joinFieldPathsByCollection: Map<string, Map<string, string>>,\n) => {\n // 3. Add endpoint\n const reorderHandler: PayloadHandler = async (req) => {\n const body = (await req.json?.()) as OrderableEndpointBody\n\n const { collectionSlug, docsToMove, newKeyWillBe, orderableFieldName, target } = body\n\n if (!Array.isArray(docsToMove) || docsToMove.length === 0) {\n return new Response(JSON.stringify({ error: 'docsToMove must be a non-empty array' }), {\n headers: { 'Content-Type': 'application/json' },\n status: 400,\n })\n }\n if (newKeyWillBe !== 'greater' && newKeyWillBe !== 'less') {\n return new Response(JSON.stringify({ error: 'newKeyWillBe must be \"greater\" or \"less\"' }), {\n headers: { 'Content-Type': 'application/json' },\n status: 400,\n })\n }\n const collection = config.collections.find((c) => c.slug === collectionSlug)\n if (!collection) {\n return new Response(JSON.stringify({ error: `Collection ${collectionSlug} not found` }), {\n headers: { 'Content-Type': 'application/json' },\n status: 400,\n })\n }\n if (typeof orderableFieldName !== 'string') {\n return new Response(JSON.stringify({ error: 'orderableFieldName must be a string' }), {\n headers: { 'Content-Type': 'application/json' },\n status: 400,\n })\n }\n\n const { joinScopeWhere, targetDoc } = await getJoinScopeContext({\n collectionSlug: collection.slug,\n joinFieldPathsByCollection,\n orderableFieldName,\n req,\n target,\n })\n\n // Prevent reordering if user doesn't have editing permissions\n if (collection.access?.update) {\n await executeAccess(\n {\n // Currently only one doc can be moved at a time. We should review this if we want to allow\n // multiple docs to be moved at once in the future.\n id: docsToMove[0],\n data: {},\n req,\n },\n collection.access.update,\n )\n }\n /**\n * If there is no target.key, we can assume the user enabled `orderable`\n * on a collection with existing documents, and that this is the first\n * time they tried to reorder them. Therefore, we perform a one-time\n * migration by setting the key value for all documents. We do this\n * instead of enforcing `required` and `unique` at the database schema\n * level, so that users don't have to run a migration when they enable\n * `orderable` on a collection with existing documents.\n */\n if (!target.key) {\n const { docs } = await req.payload.find({\n collection: collection.slug,\n depth: 0,\n limit: 0,\n req,\n select: { [orderableFieldName]: true },\n where: combineWhereConstraints([\n {\n [orderableFieldName]: {\n exists: false,\n },\n },\n joinScopeWhere ?? undefined,\n ]),\n })\n await initTransaction(req)\n // We cannot update all documents in a single operation with `payload.update`,\n // because they would all end up with the same order key (`a0`).\n try {\n for (const doc of docs) {\n await req.payload.update({\n id: doc.id,\n collection: collection.slug,\n data: {\n // no data needed since the order hooks will handle this\n },\n depth: 0,\n req,\n })\n await commitTransaction(req)\n }\n } catch (e) {\n await killTransaction(req)\n if (e instanceof Error) {\n throw new APIError(e.message, httpStatus.INTERNAL_SERVER_ERROR)\n }\n }\n\n return new Response(JSON.stringify({ message: 'initial migration', success: true }), {\n headers: { 'Content-Type': 'application/json' },\n status: 200,\n })\n }\n\n if (\n typeof target !== 'object' ||\n typeof target.id === 'undefined' ||\n typeof target.key !== 'string'\n ) {\n return new Response(JSON.stringify({ error: 'target must be an object with id' }), {\n headers: { 'Content-Type': 'application/json' },\n status: 400,\n })\n }\n\n const targetId = target.id\n const targetKey = await resolvePendingTargetKey({\n collectionSlug: collection.slug,\n orderableFieldName,\n req,\n targetDoc,\n targetID: targetId,\n targetKey: target.key,\n })\n\n // The reason the endpoint does not receive this docId as an argument is that there\n // are situations where the user may not see or know what the next or previous one is. For\n // example, access control restrictions, if docBefore is the last one on the page, etc.\n const adjacentDoc = await req.payload.find({\n collection: collection.slug,\n depth: 0,\n limit: 1,\n pagination: false,\n select: { [orderableFieldName]: true },\n sort: newKeyWillBe === 'greater' ? orderableFieldName : `-${orderableFieldName}`,\n where: combineWhereConstraints([\n {\n [orderableFieldName]: {\n [newKeyWillBe === 'greater' ? 'greater_than' : 'less_than']: targetKey,\n },\n },\n joinScopeWhere ?? undefined,\n ]),\n })\n const adjacentDocKey = adjacentDoc.docs?.[0]?.[orderableFieldName] || null\n\n // Currently N (= docsToMove.length) is always 1. Maybe in the future we will\n // allow dragging and reordering multiple documents at once via the UI.\n const orderValues =\n newKeyWillBe === 'greater'\n ? generateNKeysBetween(targetKey, adjacentDocKey, docsToMove.length)\n : generateNKeysBetween(adjacentDocKey, targetKey, docsToMove.length)\n\n // Update each document with its new order value\n for (const [index, id] of docsToMove.entries()) {\n await req.payload.update({\n id,\n collection: collection.slug,\n data: {\n [orderableFieldName]: orderValues[index],\n },\n depth: 0,\n req,\n })\n }\n\n return new Response(JSON.stringify({ orderValues, success: true }), {\n headers: { 'Content-Type': 'application/json' },\n status: 200,\n })\n }\n\n const reorderEndpoint: Endpoint = {\n handler: reorderHandler,\n method: 'post',\n path: '/reorder',\n }\n\n if (!config.endpoints) {\n config.endpoints = []\n }\n\n config.endpoints.push(reorderEndpoint)\n}\n"],"names":["status","httpStatus","executeAccess","APIError","sanitizeField","combineWhereConstraints","commitTransaction","initTransaction","killTransaction","generateKeyBetween","generateNKeysBetween","getJoinScopeContext","getJoinScopeWhereFromDocData","resolvePendingTargetKey","addOrderableFieldsAndHook","collection","config","orderableFieldNames","joinFieldPathsByCollection","orderableFieldName","orderField","name","type","admin","disabled","hidden","readOnly","hooks","beforeDuplicate","siblingData","index","collectionConfig","existingFieldNames","Set","field","isTopLevelField","joinPath","parentIndexPath","parentIsLocalized","parentSchemaPath","requireFieldLevelRichTextEditor","validRelationships","fields","unshift","beforeChange","orderBeforeChangeHook","data","originalDoc","req","joinScopeWhere","collectionSlug","slug","lastDoc","payload","find","depth","limit","pagination","select","sort","where","exists","undefined","lastOrderValue","docs","push","addOrderableEndpoint","reorderHandler","body","json","docsToMove","newKeyWillBe","target","Array","isArray","length","Response","JSON","stringify","error","headers","collections","c","targetDoc","access","update","id","key","doc","e","Error","message","INTERNAL_SERVER_ERROR","success","targetId","targetKey","targetID","adjacentDoc","adjacentDocKey","orderValues","entries","reorderEndpoint","handler","method","path","endpoints"],"mappings":"AAAA,SAASA,UAAUC,UAAU,QAAQ,cAAa;AAOlD,SAASC,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,QAAQ,QAAQ,wBAAuB;AAChD,SAASC,aAAa,QAAQ,kCAAiC;AAC/D,SAASC,uBAAuB,QAAQ,6CAA4C;AACpF,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,kBAAkB,EAAEC,oBAAoB,QAA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MAAM,cAAc,mBAA0B,MAAM,KAAG,OAAO,CAAC,eAAe,CAibpF,CAAA"}
1
+ {"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/config/sanitize.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACV,MAAM,EAGN,eAAe,EAIhB,MAAM,YAAY,CAAA;AA+FnB,eAAO,MAAM,cAAc,GAAU,gBAAgB,MAAM,KAAG,OAAO,CAAC,eAAe,CAgYpF,CAAA"}
@@ -1,14 +1,12 @@
1
1
  import { en } from '@payloadcms/translations/languages/en';
2
- import { deepMergeSimple } from '@payloadcms/translations/utilities';
3
2
  import { defaultUserCollection } from '../auth/defaultUser.js';
4
3
  import { authRootEndpoints } from '../auth/endpoints/index.js';
5
4
  import { sanitizeCollection } from '../collections/config/sanitize.js';
6
5
  import { migrationsCollection } from '../database/migrations/migrationsCollection.js';
7
6
  import { DuplicateCollection, InvalidConfiguration } from '../errors/index.js';
8
7
  import { defaultTimezones } from '../fields/baseFields/timezone/defaultTimezones.js';
9
- import { addFolderCollection } from '../folders/addFolderCollection.js';
10
- import { addFolderFieldToCollection } from '../folders/addFolderFieldToCollection.js';
11
8
  import { sanitizeGlobal } from '../globals/config/sanitize.js';
9
+ import { resolveHierarchyCollections } from '../hierarchy/resolveHierarchyCollections.js';
12
10
  import { baseBlockFields, formatLabels, sanitizeFields } from '../index.js';
13
11
  import { getLockedDocumentsCollection, lockedDocumentsCollectionSlug } from '../locked-documents/config.js';
14
12
  import { getPreferencesCollection, preferencesCollectionSlug } from '../preferences/config.js';
@@ -25,9 +23,6 @@ const sanitizeAdminConfig = (configToSanitize)=>{
25
23
  const sanitizedConfig = {
26
24
  ...configToSanitize
27
25
  };
28
- if (configToSanitize?.compatibility?.allowLocalizedWithinLocalized) {
29
- process.env.NEXT_PUBLIC_PAYLOAD_COMPATIBILITY_allowLocalizedWithinLocalized = 'true';
30
- }
31
26
  // default logging level will be 'error' if not provided
32
27
  sanitizedConfig.loggingLevels = {
33
28
  Forbidden: 'info',
@@ -41,7 +36,7 @@ const sanitizeAdminConfig = (configToSanitize)=>{
41
36
  widgets: []
42
37
  }).widgets.push({
43
38
  slug: 'collections',
44
- Component: '@payloadcms/next/rsc#CollectionCards',
39
+ Component: '@payloadcms/ui/rsc#CollectionCards',
45
40
  minWidth: 'full'
46
41
  });
47
42
  sanitizedConfig.admin.dashboard.defaultLayout ??= [
@@ -144,9 +139,6 @@ export const sanitizeConfig = async (incomingConfig)=>{
144
139
  lockedDocumentsCollectionSlug,
145
140
  preferencesCollectionSlug
146
141
  ];
147
- if (config.folders !== false) {
148
- validRelationships.push(config.folders.slug);
149
- }
150
142
  const dashboardWidgets = config.admin?.dashboard?.widgets ?? [];
151
143
  for (const widget of dashboardWidgets){
152
144
  if (widget.fields?.length) {
@@ -187,7 +179,6 @@ export const sanitizeConfig = async (incomingConfig)=>{
187
179
  config.blocks.push(flattenedSanitizedBlock);
188
180
  }
189
181
  }
190
- const folderEnabledCollections = [];
191
182
  // Track orderable join fields during sanitization
192
183
  const orderableJoins = [];
193
184
  for(let i = 0; i < config.collections.length; i++){
@@ -205,18 +196,7 @@ export const sanitizeConfig = async (incomingConfig)=>{
205
196
  validRelationships.push(queryPresetsCollectionSlug);
206
197
  }
207
198
  }
208
- if (config.folders !== false && config.collections[i].folders) {
209
- addFolderFieldToCollection({
210
- collection: config.collections[i],
211
- collectionSpecific: config.folders.collectionSpecific,
212
- folderFieldName: config.folders.fieldName,
213
- folderSlug: config.folders.slug
214
- });
215
- }
216
199
  config.collections[i] = await sanitizeCollection(config, config.collections[i], richTextSanitizationPromises, validRelationships, orderableJoins);
217
- if (config.folders !== false && config.collections[i].folders) {
218
- folderEnabledCollections.push(config.collections[i]);
219
- }
220
200
  }
221
201
  // Process orderable features after all collections are sanitized
222
202
  const fieldsToAdd = new Map();
@@ -266,6 +246,8 @@ export const sanitizeConfig = async (incomingConfig)=>{
266
246
  config.globals[i] = await sanitizeGlobal(config, config.globals[i], richTextSanitizationPromises, validRelationships);
267
247
  }
268
248
  }
249
+ // Resolve hierarchy relationships across collections (also adds sidebar tabs)
250
+ resolveHierarchyCollections(config);
269
251
  if (schedulePublishCollections.length || schedulePublishGlobals.length) {
270
252
  ;
271
253
  ((config.jobs ??= {}).tasks ??= []).push(getSchedulePublishTask({
@@ -290,31 +272,10 @@ export const sanitizeConfig = async (incomingConfig)=>{
290
272
  defaultJobsCollection = config.jobs.jobsCollectionOverrides({
291
273
  defaultJobsCollection
292
274
  });
293
- const hooks = defaultJobsCollection?.hooks;
294
- // @todo - delete this check in 4.0
295
- if (hooks && config?.jobs?.runHooks !== true) {
296
- for (const [hookKey, hook] of Object.entries(hooks)){
297
- const defaultAmount = hookKey === 'afterRead' || hookKey === 'beforeChange' ? 1 : 0;
298
- if (hook.length > defaultAmount) {
299
- // eslint-disable-next-line no-console
300
- console.warn(`The jobsCollectionOverrides function is returning a collection with an additional ${hookKey} hook defined. These hooks will not run unless the jobs.runHooks option is set to true. Setting this option to true will negatively impact performance.`);
301
- break;
302
- }
303
- }
304
- }
305
275
  }
306
276
  const sanitizedJobsCollection = await sanitizeCollection(config, defaultJobsCollection, richTextSanitizationPromises, validRelationships);
307
277
  (config.collections ??= []).push(sanitizedJobsCollection);
308
278
  }
309
- if (config.folders !== false && folderEnabledCollections.length) {
310
- await addFolderCollection({
311
- collectionSpecific: config.folders.collectionSpecific,
312
- config: config,
313
- folderEnabledCollections,
314
- richTextSanitizationPromises,
315
- validRelationships
316
- });
317
- }
318
279
  const lockedDocumentsCollection = getLockedDocumentsCollection(config);
319
280
  if (lockedDocumentsCollection) {
320
281
  configWithDefaults.collections.push(await sanitizeCollection(config, lockedDocumentsCollection, richTextSanitizationPromises, validRelationships));
@@ -340,13 +301,8 @@ export const sanitizeConfig = async (incomingConfig)=>{
340
301
  if (config.serverURL !== '') {
341
302
  config.csrf.push(config.serverURL);
342
303
  }
343
- const uploadAdapters = new Set();
344
- // interact with all collections
345
- for (const collection of config.collections){
346
- // deduped upload adapters
347
- if (collection.upload?.adapter) {
348
- uploadAdapters.add(collection.upload.adapter);
349
- }
304
+ if (!config.storage) {
305
+ config.storage = [];
350
306
  }
351
307
  if (!config.upload) {
352
308
  config.upload = {
@@ -366,9 +322,6 @@ export const sanitizeConfig = async (incomingConfig)=>{
366
322
  isRoot: true,
367
323
  parentIsLocalized: false
368
324
  });
369
- if (config.editor.i18n && Object.keys(config.editor.i18n).length >= 0) {
370
- config.i18n.translations = deepMergeSimple(config.i18n.translations, config.editor.i18n);
371
- }
372
325
  }
373
326
  const promises = [];
374
327
  for (const sanitizeFunction of richTextSanitizationPromises){
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/config/sanitize.ts"],"sourcesContent":["import type { AcceptedLanguages } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\nimport { deepMergeSimple } from '@payloadcms/translations/utilities'\n\nimport type { OrderableJoinInfo } from '../fields/config/sanitizeJoinField.js'\nimport type { CollectionSlug, GlobalSlug, SanitizedCollectionConfig } from '../index.js'\nimport type { SanitizedJobsConfig } from '../queues/config/types/index.js'\nimport type {\n Config,\n LocalizationConfigWithLabels,\n LocalizationConfigWithNoLabels,\n SanitizedConfig,\n Timezone,\n Widget,\n WidgetInstance,\n} from './types.js'\n\nimport { defaultUserCollection } from '../auth/defaultUser.js'\nimport { authRootEndpoints } from '../auth/endpoints/index.js'\nimport { sanitizeCollection } from '../collections/config/sanitize.js'\nimport { migrationsCollection } from '../database/migrations/migrationsCollection.js'\nimport { DuplicateCollection, InvalidConfiguration } from '../errors/index.js'\nimport { defaultTimezones } from '../fields/baseFields/timezone/defaultTimezones.js'\nimport { addFolderCollection } from '../folders/addFolderCollection.js'\nimport { addFolderFieldToCollection } from '../folders/addFolderFieldToCollection.js'\nimport { sanitizeGlobal } from '../globals/config/sanitize.js'\nimport { baseBlockFields, formatLabels, sanitizeFields } from '../index.js'\nimport {\n getLockedDocumentsCollection,\n lockedDocumentsCollectionSlug,\n} from '../locked-documents/config.js'\nimport { getPreferencesCollection, preferencesCollectionSlug } from '../preferences/config.js'\nimport { getQueryPresetsConfig, queryPresetsCollectionSlug } from '../query-presets/config.js'\nimport { getDefaultJobsCollection, jobsCollectionSlug } from '../queues/config/collection.js'\nimport { getJobStatsGlobal } from '../queues/config/global.js'\nimport { flattenAllFields, flattenBlock } from '../utilities/flattenAllFields.js'\nimport { hasScheduledPublishEnabled } from '../utilities/getVersionsConfig.js'\nimport { validateTimezones } from '../utilities/validateTimezones.js'\nimport { getSchedulePublishTask } from '../versions/schedule/job.js'\nimport { addDefaultsToConfig } from './defaults.js'\nimport { addOrderableEndpoint, addOrderableFieldsAndHook } from './orderable/index.js'\n\nconst sanitizeAdminConfig = (configToSanitize: Config): Partial<SanitizedConfig> => {\n const sanitizedConfig = { ...configToSanitize }\n\n if (configToSanitize?.compatibility?.allowLocalizedWithinLocalized) {\n process.env.NEXT_PUBLIC_PAYLOAD_COMPATIBILITY_allowLocalizedWithinLocalized = 'true'\n }\n\n // default logging level will be 'error' if not provided\n sanitizedConfig.loggingLevels = {\n Forbidden: 'info',\n Locked: 'info',\n MissingFile: 'info',\n NotFound: 'info',\n ValidationError: 'info',\n ...(sanitizedConfig.loggingLevels || {}),\n }\n ;(sanitizedConfig.admin!.dashboard ??= { widgets: [] }).widgets.push({\n slug: 'collections',\n Component: '@payloadcms/next/rsc#CollectionCards',\n minWidth: 'full',\n })\n sanitizedConfig.admin!.dashboard.defaultLayout ??= [\n {\n widgetSlug: 'collections',\n width: 'full',\n } satisfies WidgetInstance,\n ]\n\n // add default user collection if none provided\n if (!sanitizedConfig?.admin?.user) {\n const firstCollectionWithAuth = sanitizedConfig.collections!.find(({ auth }) => Boolean(auth))\n\n if (firstCollectionWithAuth) {\n sanitizedConfig.admin!.user = firstCollectionWithAuth.slug\n } else {\n sanitizedConfig.admin!.user = defaultUserCollection.slug\n sanitizedConfig.collections!.push(defaultUserCollection)\n }\n }\n\n const userCollection = sanitizedConfig.collections!.find(\n ({ slug }) => slug === sanitizedConfig.admin!.user,\n )\n\n if (!userCollection || !userCollection.auth) {\n throw new InvalidConfiguration(\n `${sanitizedConfig.admin!.user} is not a valid admin user collection`,\n )\n }\n\n if (sanitizedConfig?.admin?.timezones) {\n if (typeof configToSanitize?.admin?.timezones?.supportedTimezones === 'function') {\n sanitizedConfig.admin.timezones.supportedTimezones =\n configToSanitize.admin.timezones.supportedTimezones({ defaultTimezones })\n }\n\n if (!sanitizedConfig?.admin?.timezones?.supportedTimezones) {\n sanitizedConfig.admin.timezones.supportedTimezones = defaultTimezones\n }\n } else {\n sanitizedConfig.admin!.timezones = {\n supportedTimezones: defaultTimezones,\n }\n }\n\n validateTimezones({\n source: 'admin.timezones.supportedTimezones',\n timezones: sanitizedConfig.admin!.timezones.supportedTimezones as Timezone[],\n })\n\n return sanitizedConfig as unknown as Partial<SanitizedConfig>\n}\n\nexport const sanitizeConfig = async (incomingConfig: Config): Promise<SanitizedConfig> => {\n const configWithDefaults = addDefaultsToConfig(incomingConfig)\n\n const config: Partial<SanitizedConfig> = sanitizeAdminConfig(configWithDefaults)\n\n if (!config.endpoints) {\n config.endpoints = []\n }\n\n for (const endpoint of authRootEndpoints) {\n config.endpoints.push(endpoint)\n }\n\n if (config.localization && config.localization.locales?.length > 0) {\n // clone localization config so to not break everything\n const firstLocale = config.localization.locales[0]\n if (typeof firstLocale === 'string') {\n config.localization.localeCodes = [\n ...(config.localization as unknown as LocalizationConfigWithNoLabels).locales,\n ]\n\n // is string[], so convert to Locale[]\n config.localization.locales = (\n config.localization as unknown as LocalizationConfigWithNoLabels\n ).locales.map((locale) => ({\n code: locale,\n label: locale,\n rtl: false,\n toString: () => locale,\n }))\n } else {\n // is Locale[], so convert to string[] for localeCodes\n config.localization.localeCodes = config.localization.locales.map((locale) => locale.code)\n\n config.localization.locales = (\n config.localization as LocalizationConfigWithLabels\n ).locales.map((locale) => ({\n ...locale,\n toString: () => locale.code,\n }))\n }\n\n // Default fallback to true if not provided\n config.localization.fallback = config.localization?.fallback ?? true\n }\n\n const i18nConfig: SanitizedConfig['i18n'] = {\n fallbackLanguage: 'en',\n supportedLanguages: {\n en,\n },\n translations: {},\n }\n\n if (incomingConfig?.i18n) {\n i18nConfig.supportedLanguages =\n incomingConfig.i18n?.supportedLanguages || i18nConfig.supportedLanguages\n\n const supportedLangKeys = <AcceptedLanguages[]>Object.keys(i18nConfig.supportedLanguages)\n const fallbackLang = incomingConfig.i18n?.fallbackLanguage || i18nConfig.fallbackLanguage\n\n i18nConfig.fallbackLanguage = supportedLangKeys.includes(fallbackLang)\n ? fallbackLang\n : supportedLangKeys[0]!\n i18nConfig.translations =\n (incomingConfig.i18n?.translations as SanitizedConfig['i18n']['translations']) ||\n i18nConfig.translations\n }\n\n config.i18n = i18nConfig\n\n const richTextSanitizationPromises: Array<(config: SanitizedConfig) => Promise<void>> = []\n\n const schedulePublishCollections: CollectionSlug[] = []\n\n const queryPresetsCollections: CollectionSlug[] = []\n\n const schedulePublishGlobals: GlobalSlug[] = []\n\n const collectionSlugs = new Set<CollectionSlug>()\n\n const validRelationships = [\n ...(config.collections?.map((c) => c.slug) ?? []),\n jobsCollectionSlug,\n lockedDocumentsCollectionSlug,\n preferencesCollectionSlug,\n ]\n\n if (config.folders !== false) {\n validRelationships.push(config.folders!.slug)\n }\n\n const dashboardWidgets = config.admin?.dashboard?.widgets ?? ([] as Widget[])\n\n for (const widget of dashboardWidgets) {\n if (widget.fields?.length) {\n widget.fields = await sanitizeFields({\n config: config as unknown as Config,\n existingFieldNames: new Set(),\n fields: widget.fields,\n parentIsLocalized: false,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n }\n\n /**\n * Blocks sanitization needs to happen before collections, as collection/global join field sanitization needs config.blocks\n * to be populated with the sanitized blocks\n */\n config.blocks = []\n\n if (incomingConfig.blocks?.length) {\n for (const block of incomingConfig.blocks) {\n const sanitizedBlock = block\n\n if (sanitizedBlock._sanitized === true) {\n continue\n }\n sanitizedBlock._sanitized = true\n\n sanitizedBlock.fields = sanitizedBlock.fields.concat(baseBlockFields)\n\n sanitizedBlock.labels = !sanitizedBlock.labels\n ? formatLabels(sanitizedBlock.slug)\n : sanitizedBlock.labels\n\n sanitizedBlock.fields = await sanitizeFields({\n config: config as unknown as Config,\n existingFieldNames: new Set(),\n fields: sanitizedBlock.fields,\n parentIsLocalized: false,\n richTextSanitizationPromises,\n validRelationships,\n })\n\n const flattenedSanitizedBlock = flattenBlock({ block })\n\n config.blocks.push(flattenedSanitizedBlock)\n }\n }\n\n const folderEnabledCollections: SanitizedCollectionConfig[] = []\n\n // Track orderable join fields during sanitization\n const orderableJoins: OrderableJoinInfo[] = []\n\n for (let i = 0; i < config.collections!.length; i++) {\n if (collectionSlugs.has(config.collections![i]!.slug)) {\n throw new DuplicateCollection('slug', config.collections![i]!.slug)\n }\n\n collectionSlugs.add(config.collections![i]!.slug)\n\n const draftsConfig = config.collections![i]?.versions?.drafts\n\n if (typeof draftsConfig === 'object' && draftsConfig.schedulePublish) {\n schedulePublishCollections.push(config.collections![i]!.slug)\n }\n\n if (config.collections![i]!.enableQueryPresets) {\n queryPresetsCollections.push(config.collections![i]!.slug)\n\n if (!validRelationships.includes(queryPresetsCollectionSlug)) {\n validRelationships.push(queryPresetsCollectionSlug)\n }\n }\n\n if (config.folders !== false && config.collections![i]!.folders) {\n addFolderFieldToCollection({\n collection: config.collections![i]!,\n collectionSpecific: config.folders!.collectionSpecific,\n folderFieldName: config.folders!.fieldName,\n folderSlug: config.folders!.slug,\n })\n }\n\n config.collections![i] = await sanitizeCollection(\n config as unknown as Config,\n config.collections![i]!,\n richTextSanitizationPromises,\n validRelationships,\n orderableJoins,\n )\n\n if (config.folders !== false && config.collections![i]!.folders) {\n folderEnabledCollections.push(config.collections![i]!)\n }\n }\n\n // Process orderable features after all collections are sanitized\n const fieldsToAdd = new Map<SanitizedCollectionConfig, string[]>()\n const joinFieldPathsByCollection = new Map<string, Map<string, string>>()\n\n // Handle collection.orderable\n for (const collection of config.collections!) {\n if (collection.orderable) {\n const currentFields = fieldsToAdd.get(collection) || []\n fieldsToAdd.set(collection, [...currentFields, '_order'])\n collection.defaultSort = collection.defaultSort ?? '_order'\n }\n }\n\n // Handle orderable join fields (tracked during sanitization)\n for (const joinInfo of orderableJoins) {\n const targetCollection = config.collections!.find(\n (c) => c.slug === joinInfo.targetCollectionSlug,\n )\n if (targetCollection) {\n const currentFields = fieldsToAdd.get(targetCollection) || []\n fieldsToAdd.set(targetCollection, [...currentFields, joinInfo.orderFieldName])\n\n const currentJoinFieldPaths =\n joinFieldPathsByCollection.get(targetCollection.slug) || new Map<string, string>()\n currentJoinFieldPaths.set(joinInfo.orderFieldName, joinInfo.joinFieldOn)\n joinFieldPathsByCollection.set(targetCollection.slug, currentJoinFieldPaths)\n }\n }\n\n // Add fields, hooks, and update flattenedFields\n for (const [collection, orderableFields] of fieldsToAdd) {\n await addOrderableFieldsAndHook(\n collection,\n config as unknown as Config,\n orderableFields,\n joinFieldPathsByCollection,\n )\n // Regenerate flattenedFields since we added new fields\n collection.flattenedFields = flattenAllFields({ fields: collection.fields })\n }\n\n // Add endpoint if any orderable features exist\n if (fieldsToAdd.size > 0) {\n addOrderableEndpoint(config as SanitizedConfig, joinFieldPathsByCollection)\n }\n\n if (config.globals!.length > 0) {\n for (let i = 0; i < config.globals!.length; i++) {\n if (hasScheduledPublishEnabled(config.globals![i]!)) {\n schedulePublishGlobals.push(config.globals![i]!.slug)\n }\n\n config.globals![i] = await sanitizeGlobal(\n config as unknown as Config,\n config.globals![i]!,\n richTextSanitizationPromises,\n validRelationships,\n )\n }\n }\n\n if (schedulePublishCollections.length || schedulePublishGlobals.length) {\n ;((config.jobs ??= {} as SanitizedJobsConfig).tasks ??= []).push(\n getSchedulePublishTask({\n adminUserSlug: config.admin!.user,\n collections: schedulePublishCollections,\n globals: schedulePublishGlobals,\n }),\n )\n }\n\n ;(config.jobs ??= {} as SanitizedJobsConfig).enabled = Boolean(\n (Array.isArray(configWithDefaults.jobs?.tasks) && configWithDefaults.jobs?.tasks?.length) ||\n (Array.isArray(configWithDefaults.jobs?.workflows) &&\n configWithDefaults.jobs?.workflows?.length),\n )\n\n // Need to add default jobs collection before locked documents collections\n if (config.jobs.enabled) {\n // Check for schedule property in both tasks and workflows\n const hasScheduleProperty =\n (config?.jobs?.tasks?.length && config.jobs.tasks.some((task) => task.schedule)) ||\n (config?.jobs?.workflows?.length &&\n config.jobs.workflows.some((workflow) => workflow.schedule))\n\n if (hasScheduleProperty) {\n config.jobs.scheduling = true\n // Add payload-jobs-stats global for tracking when a job of a specific slug was last run\n ;(config.globals ??= []).push(\n await sanitizeGlobal(\n config as unknown as Config,\n getJobStatsGlobal(config as unknown as Config),\n richTextSanitizationPromises,\n validRelationships,\n ),\n )\n\n config.jobs.stats = true\n }\n\n let defaultJobsCollection = getDefaultJobsCollection(config.jobs)\n\n if (typeof config.jobs.jobsCollectionOverrides === 'function') {\n defaultJobsCollection = config.jobs.jobsCollectionOverrides({\n defaultJobsCollection,\n })\n\n const hooks = defaultJobsCollection?.hooks\n // @todo - delete this check in 4.0\n if (hooks && config?.jobs?.runHooks !== true) {\n for (const [hookKey, hook] of Object.entries(hooks)) {\n const defaultAmount = hookKey === 'afterRead' || hookKey === 'beforeChange' ? 1 : 0\n if (hook.length > defaultAmount) {\n // eslint-disable-next-line no-console\n console.warn(\n `The jobsCollectionOverrides function is returning a collection with an additional ${hookKey} hook defined. These hooks will not run unless the jobs.runHooks option is set to true. Setting this option to true will negatively impact performance.`,\n )\n break\n }\n }\n }\n }\n const sanitizedJobsCollection = await sanitizeCollection(\n config as unknown as Config,\n defaultJobsCollection,\n richTextSanitizationPromises,\n validRelationships,\n )\n\n ;(config.collections ??= []).push(sanitizedJobsCollection)\n }\n\n if (config.folders !== false && folderEnabledCollections.length) {\n await addFolderCollection({\n collectionSpecific: config.folders!.collectionSpecific,\n config: config as unknown as Config,\n folderEnabledCollections,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n\n const lockedDocumentsCollection = getLockedDocumentsCollection(config as unknown as Config)\n\n if (lockedDocumentsCollection) {\n configWithDefaults.collections!.push(\n await sanitizeCollection(\n config as unknown as Config,\n lockedDocumentsCollection,\n richTextSanitizationPromises,\n validRelationships,\n ),\n )\n }\n\n configWithDefaults.collections!.push(\n await sanitizeCollection(\n config as unknown as Config,\n getPreferencesCollection(config as unknown as Config),\n richTextSanitizationPromises,\n validRelationships,\n ),\n )\n\n const migrations = await sanitizeCollection(\n config as unknown as Config,\n migrationsCollection,\n richTextSanitizationPromises,\n validRelationships,\n )\n\n // @ts-expect-error indexSortableFields is only valid for @payloadcms/db-mongodb\n if (config?.db?.indexSortableFields) {\n migrations.indexes = [\n {\n fields: ['batch', 'name'],\n unique: false,\n },\n ]\n }\n configWithDefaults.collections!.push(migrations)\n\n if (queryPresetsCollections.length > 0) {\n configWithDefaults.collections!.push(\n await sanitizeCollection(\n config as unknown as Config,\n getQueryPresetsConfig(config as unknown as Config),\n richTextSanitizationPromises,\n validRelationships,\n ),\n )\n }\n\n if (config.serverURL !== '') {\n config.csrf!.push(config.serverURL!)\n }\n\n const uploadAdapters = new Set<string>()\n // interact with all collections\n for (const collection of config.collections!) {\n // deduped upload adapters\n if (collection.upload?.adapter) {\n uploadAdapters.add(collection.upload.adapter)\n }\n }\n\n if (!config.upload) {\n config.upload = { adapters: [] }\n }\n\n config.upload.adapters = Array.from(\n new Set(config.collections!.map((c) => c.upload?.adapter).filter(Boolean) as string[]),\n )\n\n // Pass through the email config as is so adapters don't break\n if (incomingConfig.email) {\n config.email = incomingConfig.email\n }\n\n /*\n Execute richText sanitization\n */\n if (typeof incomingConfig.editor === 'function') {\n config.editor = await incomingConfig.editor({\n config: config as SanitizedConfig,\n isRoot: true,\n parentIsLocalized: false,\n })\n if (config.editor.i18n && Object.keys(config.editor.i18n).length >= 0) {\n config.i18n.translations = deepMergeSimple(config.i18n.translations, config.editor.i18n)\n }\n }\n\n const promises: Promise<void>[] = []\n\n for (const sanitizeFunction of richTextSanitizationPromises) {\n promises.push(sanitizeFunction(config as SanitizedConfig))\n }\n\n await Promise.all(promises)\n\n return config as SanitizedConfig\n}\n"],"names":["en","deepMergeSimple","defaultUserCollection","authRootEndpoints","sanitizeCollection","migrationsCollection","DuplicateCollection","InvalidConfiguration","defaultTimezones","addFolderCollection","addFolderFieldToCollection","sanitizeGlobal","baseBlockFields","formatLabels","sanitizeFields","getLockedDocumentsCollection","lockedDocumentsCollectionSlug","getPreferencesCollection","preferencesCollectionSlug","getQueryPresetsConfig","queryPresetsCollectionSlug","getDefaultJobsCollection","jobsCollectionSlug","getJobStatsGlobal","flattenAllFields","flattenBlock","hasScheduledPublishEnabled","validateTimezones","getSchedulePublishTask","addDefaultsToConfig","addOrderableEndpoint","addOrderableFieldsAndHook","sanitizeAdminConfig","configToSanitize","sanitizedConfig","compatibility","allowLocalizedWithinLocalized","process","env","NEXT_PUBLIC_PAYLOAD_COMPATIBILITY_allowLocalizedWithinLocalized","loggingLevels","Forbidden","Locked","MissingFile","NotFound","ValidationError","admin","dashboard","widgets","push","slug","Component","minWidth","defaultLayout","widgetSlug","width","user","firstCollectionWithAuth","collections","find","auth","Boolean","userCollection","timezones","supportedTimezones","source","sanitizeConfig","incomingConfig","configWithDefaults","config","endpoints","endpoint","localization","locales","length","firstLocale","localeCodes","map","locale","code","label","rtl","toString","fallback","i18nConfig","fallbackLanguage","supportedLanguages","translations","i18n","supportedLangKeys","Object","keys","fallbackLang","includes","richTextSanitizationPromises","schedulePublishCollections","queryPresetsCollections","schedulePublishGlobals","collectionSlugs","Set","validRelationships","c","folders","dashboardWidgets","widget","fields","existingFieldNames","parentIsLocalized","blocks","block","sanitizedBlock","_sanitized","concat","labels","flattenedSanitizedBlock","folderEnabledCollections","orderableJoins","i","has","add","draftsConfig","versions","drafts","schedulePublish","enableQueryPresets","collection","collectionSpecific","folderFieldName","fieldName","folderSlug","fieldsToAdd","Map","joinFieldPathsByCollection","orderable","currentFields","get","set","defaultSort","joinInfo","targetCollection","targetCollectionSlug","orderFieldName","currentJoinFieldPaths","joinFieldOn","orderableFields","flattenedFields","size","globals","jobs","tasks","adminUserSlug","enabled","Array","isArray","workflows","hasScheduleProperty","some","task","schedule","workflow","scheduling","stats","defaultJobsCollection","jobsCollectionOverrides","hooks","runHooks","hookKey","hook","entries","defaultAmount","console","warn","sanitizedJobsCollection","lockedDocumentsCollection","migrations","db","indexSortableFields","indexes","unique","serverURL","csrf","uploadAdapters","upload","adapter","adapters","from","filter","email","editor","isRoot","promises","sanitizeFunction","Promise","all"],"mappings":"AAEA,SAASA,EAAE,QAAQ,wCAAuC;AAC1D,SAASC,eAAe,QAAQ,qCAAoC;AAepE,SAASC,qBAAqB,QAAQ,yBAAwB;AAC9D,SAASC,iBAAiB,QAAQ,6BAA4B;AAC9D,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,oBAAoB,QAAQ,iDAAgD;AACrF,SAASC,mBAAmB,EAAEC,oBAAoB,QAAQ,qBAAoB;AAC9E,SAASC,gBAAgB,QAAQ,oDAAmD;AACpF,SAASC,mBAAmB,QAAQ,oCAAmC;AACvE,SAASC,0BAA0B,QAAQ,2CAA0C;AACrF,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,eAAe,EAAEC,YAAY,EAAEC,cAAc,QAAQ,cAAa;AAC3E,SACEC,4BAA4B,EAC5BC,6BAA6B,QACxB,gCAA+B;AACtC,SAASC,wBAAwB,EAAEC,yBAAyB,QAAQ,2BAA0B;AAC9F,SAASC,qBAAqB,EAAEC,0BAA0B,QAAQ,6BAA4B;AAC9F,SAASC,wBAAwB,EAAEC,kBAAkB,QAAQ,iCAAgC;AAC7F,SAASC,iBAAiB,QAAQ,6BAA4B;AAC9D,SAASC,gBAAgB,EAAEC,YAAY,QAAQ,mCAAkC;AACjF,SAASC,0BAA0B,QAAQ,oCAAmC;AAC9E,SAASC,iBAAiB,QAAQ,oCAAmC;AACrE,SAASC,sBAAsB,QAAQ,8BAA6B;AACpE,SAASC,mBAAmB,QAAQ,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,GAAG,CAAC,CAACwB,IAAMA,EAAEiF,MAAM,EAAEC,SAASG,MAAM,CAAC7H;IAGnE,8DAA8D;IAC9D,IAAIM,eAAewH,KAAK,EAAE;QACxBtH,OAAOsH,KAAK,GAAGxH,eAAewH,KAAK;IACrC;IAEA;;GAEC,GACD,IAAI,OAAOxH,eAAeyH,MAAM,KAAK,YAAY;QAC/CvH,OAAOuH,MAAM,GAAG,MAAMzH,eAAeyH,MAAM,CAAC;YAC1CvH,QAAQA;YACRwH,QAAQ;YACRlF,mBAAmB;QACrB;QACA,IAAItC,OAAOuH,MAAM,CAACpG,IAAI,IAAIE,OAAOC,IAAI,CAACtB,OAAOuH,MAAM,CAACpG,IAAI,EAAEd,MAAM,IAAI,GAAG;YACrEL,OAAOmB,IAAI,CAACD,YAAY,GAAGtF,gBAAgBoE,OAAOmB,IAAI,CAACD,YAAY,EAAElB,OAAOuH,MAAM,CAACpG,IAAI;QACzF;IACF;IAEA,MAAMsG,WAA4B,EAAE;IAEpC,KAAK,MAAMC,oBAAoBjG,6BAA8B;QAC3DgG,SAAS7I,IAAI,CAAC8I,iBAAiB1H;IACjC;IAEA,MAAM2H,QAAQC,GAAG,CAACH;IAElB,OAAOzH;AACT,EAAC"}
1
+ {"version":3,"sources":["../../src/config/sanitize.ts"],"sourcesContent":["import type { AcceptedLanguages } from '@payloadcms/translations'\n\nimport { en } from '@payloadcms/translations/languages/en'\n\nimport type { OrderableJoinInfo } from '../fields/config/sanitizeJoinField.js'\nimport type { CollectionSlug, GlobalSlug, SanitizedCollectionConfig } from '../index.js'\nimport type { SanitizedJobsConfig } from '../queues/config/types/index.js'\nimport type {\n Config,\n LocalizationConfigWithLabels,\n LocalizationConfigWithNoLabels,\n SanitizedConfig,\n Timezone,\n Widget,\n WidgetInstance,\n} from './types.js'\n\nimport { defaultUserCollection } from '../auth/defaultUser.js'\nimport { authRootEndpoints } from '../auth/endpoints/index.js'\nimport { sanitizeCollection } from '../collections/config/sanitize.js'\nimport { migrationsCollection } from '../database/migrations/migrationsCollection.js'\nimport { DuplicateCollection, InvalidConfiguration } from '../errors/index.js'\nimport { defaultTimezones } from '../fields/baseFields/timezone/defaultTimezones.js'\nimport { sanitizeGlobal } from '../globals/config/sanitize.js'\nimport { resolveHierarchyCollections } from '../hierarchy/resolveHierarchyCollections.js'\nimport { baseBlockFields, formatLabels, sanitizeFields } from '../index.js'\nimport {\n getLockedDocumentsCollection,\n lockedDocumentsCollectionSlug,\n} from '../locked-documents/config.js'\nimport { getPreferencesCollection, preferencesCollectionSlug } from '../preferences/config.js'\nimport { getQueryPresetsConfig, queryPresetsCollectionSlug } from '../query-presets/config.js'\nimport { getDefaultJobsCollection, jobsCollectionSlug } from '../queues/config/collection.js'\nimport { getJobStatsGlobal } from '../queues/config/global.js'\nimport { flattenAllFields, flattenBlock } from '../utilities/flattenAllFields.js'\nimport { hasScheduledPublishEnabled } from '../utilities/getVersionsConfig.js'\nimport { validateTimezones } from '../utilities/validateTimezones.js'\nimport { getSchedulePublishTask } from '../versions/schedule/job.js'\nimport { addDefaultsToConfig } from './defaults.js'\nimport { addOrderableEndpoint, addOrderableFieldsAndHook } from './orderable/index.js'\n\nconst sanitizeAdminConfig = (configToSanitize: Config): Partial<SanitizedConfig> => {\n const sanitizedConfig = { ...configToSanitize }\n\n // default logging level will be 'error' if not provided\n sanitizedConfig.loggingLevels = {\n Forbidden: 'info',\n Locked: 'info',\n MissingFile: 'info',\n NotFound: 'info',\n ValidationError: 'info',\n ...(sanitizedConfig.loggingLevels || {}),\n }\n ;(sanitizedConfig.admin!.dashboard ??= { widgets: [] }).widgets.push({\n slug: 'collections',\n Component: '@payloadcms/ui/rsc#CollectionCards',\n minWidth: 'full',\n })\n sanitizedConfig.admin!.dashboard.defaultLayout ??= [\n {\n widgetSlug: 'collections',\n width: 'full',\n } satisfies WidgetInstance,\n ]\n\n // add default user collection if none provided\n if (!sanitizedConfig?.admin?.user) {\n const firstCollectionWithAuth = sanitizedConfig.collections!.find(({ auth }) => Boolean(auth))\n\n if (firstCollectionWithAuth) {\n sanitizedConfig.admin!.user = firstCollectionWithAuth.slug\n } else {\n sanitizedConfig.admin!.user = defaultUserCollection.slug\n sanitizedConfig.collections!.push(defaultUserCollection)\n }\n }\n\n const userCollection = sanitizedConfig.collections!.find(\n ({ slug }) => slug === sanitizedConfig.admin!.user,\n )\n\n if (!userCollection || !userCollection.auth) {\n throw new InvalidConfiguration(\n `${sanitizedConfig.admin!.user} is not a valid admin user collection`,\n )\n }\n\n if (sanitizedConfig?.admin?.timezones) {\n if (typeof configToSanitize?.admin?.timezones?.supportedTimezones === 'function') {\n sanitizedConfig.admin.timezones.supportedTimezones =\n configToSanitize.admin.timezones.supportedTimezones({ defaultTimezones })\n }\n\n if (!sanitizedConfig?.admin?.timezones?.supportedTimezones) {\n sanitizedConfig.admin.timezones.supportedTimezones = defaultTimezones\n }\n } else {\n sanitizedConfig.admin!.timezones = {\n supportedTimezones: defaultTimezones,\n }\n }\n\n validateTimezones({\n source: 'admin.timezones.supportedTimezones',\n timezones: sanitizedConfig.admin!.timezones.supportedTimezones as Timezone[],\n })\n\n return sanitizedConfig as unknown as Partial<SanitizedConfig>\n}\n\nexport const sanitizeConfig = async (incomingConfig: Config): Promise<SanitizedConfig> => {\n const configWithDefaults = addDefaultsToConfig(incomingConfig)\n\n const config: Partial<SanitizedConfig> = sanitizeAdminConfig(configWithDefaults)\n\n if (!config.endpoints) {\n config.endpoints = []\n }\n\n for (const endpoint of authRootEndpoints) {\n config.endpoints.push(endpoint)\n }\n\n if (config.localization && config.localization.locales?.length > 0) {\n // clone localization config so to not break everything\n const firstLocale = config.localization.locales[0]\n if (typeof firstLocale === 'string') {\n config.localization.localeCodes = [\n ...(config.localization as unknown as LocalizationConfigWithNoLabels).locales,\n ]\n\n // is string[], so convert to Locale[]\n config.localization.locales = (\n config.localization as unknown as LocalizationConfigWithNoLabels\n ).locales.map((locale) => ({\n code: locale,\n label: locale,\n rtl: false,\n toString: () => locale,\n }))\n } else {\n // is Locale[], so convert to string[] for localeCodes\n config.localization.localeCodes = config.localization.locales.map((locale) => locale.code)\n\n config.localization.locales = (\n config.localization as LocalizationConfigWithLabels\n ).locales.map((locale) => ({\n ...locale,\n toString: () => locale.code,\n }))\n }\n\n // Default fallback to true if not provided\n config.localization.fallback = config.localization?.fallback ?? true\n }\n\n const i18nConfig: SanitizedConfig['i18n'] = {\n fallbackLanguage: 'en',\n supportedLanguages: {\n en,\n },\n translations: {},\n }\n\n if (incomingConfig?.i18n) {\n i18nConfig.supportedLanguages =\n incomingConfig.i18n?.supportedLanguages || i18nConfig.supportedLanguages\n\n const supportedLangKeys = <AcceptedLanguages[]>Object.keys(i18nConfig.supportedLanguages)\n const fallbackLang = incomingConfig.i18n?.fallbackLanguage || i18nConfig.fallbackLanguage\n\n i18nConfig.fallbackLanguage = supportedLangKeys.includes(fallbackLang)\n ? fallbackLang\n : supportedLangKeys[0]!\n i18nConfig.translations =\n (incomingConfig.i18n?.translations as SanitizedConfig['i18n']['translations']) ||\n i18nConfig.translations\n }\n\n config.i18n = i18nConfig\n\n const richTextSanitizationPromises: Array<(config: SanitizedConfig) => Promise<void>> = []\n\n const schedulePublishCollections: CollectionSlug[] = []\n\n const queryPresetsCollections: CollectionSlug[] = []\n\n const schedulePublishGlobals: GlobalSlug[] = []\n\n const collectionSlugs = new Set<CollectionSlug>()\n\n const validRelationships = [\n ...(config.collections?.map((c) => c.slug) ?? []),\n jobsCollectionSlug,\n lockedDocumentsCollectionSlug,\n preferencesCollectionSlug,\n ]\n\n const dashboardWidgets = config.admin?.dashboard?.widgets ?? ([] as Widget[])\n\n for (const widget of dashboardWidgets) {\n if (widget.fields?.length) {\n widget.fields = await sanitizeFields({\n config: config as unknown as Config,\n existingFieldNames: new Set(),\n fields: widget.fields,\n parentIsLocalized: false,\n richTextSanitizationPromises,\n validRelationships,\n })\n }\n }\n\n /**\n * Blocks sanitization needs to happen before collections, as collection/global join field sanitization needs config.blocks\n * to be populated with the sanitized blocks\n */\n config.blocks = []\n\n if (incomingConfig.blocks?.length) {\n for (const block of incomingConfig.blocks) {\n const sanitizedBlock = block\n\n if (sanitizedBlock._sanitized === true) {\n continue\n }\n sanitizedBlock._sanitized = true\n\n sanitizedBlock.fields = sanitizedBlock.fields.concat(baseBlockFields)\n\n sanitizedBlock.labels = !sanitizedBlock.labels\n ? formatLabels(sanitizedBlock.slug)\n : sanitizedBlock.labels\n\n sanitizedBlock.fields = await sanitizeFields({\n config: config as unknown as Config,\n existingFieldNames: new Set(),\n fields: sanitizedBlock.fields,\n parentIsLocalized: false,\n richTextSanitizationPromises,\n validRelationships,\n })\n\n const flattenedSanitizedBlock = flattenBlock({ block })\n\n config.blocks.push(flattenedSanitizedBlock)\n }\n }\n\n // Track orderable join fields during sanitization\n const orderableJoins: OrderableJoinInfo[] = []\n\n for (let i = 0; i < config.collections!.length; i++) {\n if (collectionSlugs.has(config.collections![i]!.slug)) {\n throw new DuplicateCollection('slug', config.collections![i]!.slug)\n }\n\n collectionSlugs.add(config.collections![i]!.slug)\n\n const draftsConfig = config.collections![i]?.versions?.drafts\n\n if (typeof draftsConfig === 'object' && draftsConfig.schedulePublish) {\n schedulePublishCollections.push(config.collections![i]!.slug)\n }\n\n if (config.collections![i]!.enableQueryPresets) {\n queryPresetsCollections.push(config.collections![i]!.slug)\n\n if (!validRelationships.includes(queryPresetsCollectionSlug)) {\n validRelationships.push(queryPresetsCollectionSlug)\n }\n }\n\n config.collections![i] = await sanitizeCollection(\n config as unknown as Config,\n config.collections![i]!,\n richTextSanitizationPromises,\n validRelationships,\n orderableJoins,\n )\n }\n\n // Process orderable features after all collections are sanitized\n const fieldsToAdd = new Map<SanitizedCollectionConfig, string[]>()\n const joinFieldPathsByCollection = new Map<string, Map<string, string>>()\n\n // Handle collection.orderable\n for (const collection of config.collections!) {\n if (collection.orderable) {\n const currentFields = fieldsToAdd.get(collection) || []\n fieldsToAdd.set(collection, [...currentFields, '_order'])\n collection.defaultSort = collection.defaultSort ?? '_order'\n }\n }\n\n // Handle orderable join fields (tracked during sanitization)\n for (const joinInfo of orderableJoins) {\n const targetCollection = config.collections!.find(\n (c) => c.slug === joinInfo.targetCollectionSlug,\n )\n if (targetCollection) {\n const currentFields = fieldsToAdd.get(targetCollection) || []\n fieldsToAdd.set(targetCollection, [...currentFields, joinInfo.orderFieldName])\n\n const currentJoinFieldPaths =\n joinFieldPathsByCollection.get(targetCollection.slug) || new Map<string, string>()\n currentJoinFieldPaths.set(joinInfo.orderFieldName, joinInfo.joinFieldOn)\n joinFieldPathsByCollection.set(targetCollection.slug, currentJoinFieldPaths)\n }\n }\n\n // Add fields, hooks, and update flattenedFields\n for (const [collection, orderableFields] of fieldsToAdd) {\n await addOrderableFieldsAndHook(\n collection,\n config as unknown as Config,\n orderableFields,\n joinFieldPathsByCollection,\n )\n // Regenerate flattenedFields since we added new fields\n collection.flattenedFields = flattenAllFields({ fields: collection.fields })\n }\n\n // Add endpoint if any orderable features exist\n if (fieldsToAdd.size > 0) {\n addOrderableEndpoint(config as SanitizedConfig, joinFieldPathsByCollection)\n }\n\n if (config.globals!.length > 0) {\n for (let i = 0; i < config.globals!.length; i++) {\n if (hasScheduledPublishEnabled(config.globals![i]!)) {\n schedulePublishGlobals.push(config.globals![i]!.slug)\n }\n\n config.globals![i] = await sanitizeGlobal(\n config as unknown as Config,\n config.globals![i]!,\n richTextSanitizationPromises,\n validRelationships,\n )\n }\n }\n\n // Resolve hierarchy relationships across collections (also adds sidebar tabs)\n resolveHierarchyCollections(config as unknown as Config)\n\n if (schedulePublishCollections.length || schedulePublishGlobals.length) {\n ;((config.jobs ??= {} as SanitizedJobsConfig).tasks ??= []).push(\n getSchedulePublishTask({\n adminUserSlug: config.admin!.user,\n collections: schedulePublishCollections,\n globals: schedulePublishGlobals,\n }),\n )\n }\n\n ;(config.jobs ??= {} as SanitizedJobsConfig).enabled = Boolean(\n (Array.isArray(configWithDefaults.jobs?.tasks) && configWithDefaults.jobs?.tasks?.length) ||\n (Array.isArray(configWithDefaults.jobs?.workflows) &&\n configWithDefaults.jobs?.workflows?.length),\n )\n\n // Need to add default jobs collection before locked documents collections\n if (config.jobs.enabled) {\n // Check for schedule property in both tasks and workflows\n const hasScheduleProperty =\n (config?.jobs?.tasks?.length && config.jobs.tasks.some((task) => task.schedule)) ||\n (config?.jobs?.workflows?.length &&\n config.jobs.workflows.some((workflow) => workflow.schedule))\n\n if (hasScheduleProperty) {\n config.jobs.scheduling = true\n // Add payload-jobs-stats global for tracking when a job of a specific slug was last run\n ;(config.globals ??= []).push(\n await sanitizeGlobal(\n config as unknown as Config,\n getJobStatsGlobal(config as unknown as Config),\n richTextSanitizationPromises,\n validRelationships,\n ),\n )\n\n config.jobs.stats = true\n }\n\n let defaultJobsCollection = getDefaultJobsCollection(config.jobs)\n\n if (typeof config.jobs.jobsCollectionOverrides === 'function') {\n defaultJobsCollection = config.jobs.jobsCollectionOverrides({\n defaultJobsCollection,\n })\n }\n const sanitizedJobsCollection = await sanitizeCollection(\n config as unknown as Config,\n defaultJobsCollection,\n richTextSanitizationPromises,\n validRelationships,\n )\n\n ;(config.collections ??= []).push(sanitizedJobsCollection)\n }\n\n const lockedDocumentsCollection = getLockedDocumentsCollection(config as unknown as Config)\n\n if (lockedDocumentsCollection) {\n configWithDefaults.collections!.push(\n await sanitizeCollection(\n config as unknown as Config,\n lockedDocumentsCollection,\n richTextSanitizationPromises,\n validRelationships,\n ),\n )\n }\n\n configWithDefaults.collections!.push(\n await sanitizeCollection(\n config as unknown as Config,\n getPreferencesCollection(config as unknown as Config),\n richTextSanitizationPromises,\n validRelationships,\n ),\n )\n\n const migrations = await sanitizeCollection(\n config as unknown as Config,\n migrationsCollection,\n richTextSanitizationPromises,\n validRelationships,\n )\n\n // @ts-expect-error indexSortableFields is only valid for @payloadcms/db-mongodb\n if (config?.db?.indexSortableFields) {\n migrations.indexes = [\n {\n fields: ['batch', 'name'],\n unique: false,\n },\n ]\n }\n configWithDefaults.collections!.push(migrations)\n\n if (queryPresetsCollections.length > 0) {\n configWithDefaults.collections!.push(\n await sanitizeCollection(\n config as unknown as Config,\n getQueryPresetsConfig(config as unknown as Config),\n richTextSanitizationPromises,\n validRelationships,\n ),\n )\n }\n\n if (config.serverURL !== '') {\n config.csrf!.push(config.serverURL!)\n }\n\n if (!config.storage) {\n config.storage = []\n }\n\n if (!config.upload) {\n config.upload = { adapters: [] }\n }\n\n config.upload.adapters = Array.from(\n new Set(config.collections!.map((c) => c.upload?.adapter).filter(Boolean) as string[]),\n )\n\n // Pass through the email config as is so adapters don't break\n if (incomingConfig.email) {\n config.email = incomingConfig.email\n }\n\n /*\n Execute richText sanitization\n */\n if (typeof incomingConfig.editor === 'function') {\n config.editor = await incomingConfig.editor({\n config: config as SanitizedConfig,\n isRoot: true,\n parentIsLocalized: false,\n })\n }\n\n const promises: Promise<void>[] = []\n\n for (const sanitizeFunction of richTextSanitizationPromises) {\n promises.push(sanitizeFunction(config as SanitizedConfig))\n }\n\n await Promise.all(promises)\n\n return config as SanitizedConfig\n}\n"],"names":["en","defaultUserCollection","authRootEndpoints","sanitizeCollection","migrationsCollection","DuplicateCollection","InvalidConfiguration","defaultTimezones","sanitizeGlobal","resolveHierarchyCollections","baseBlockFields","formatLabels","sanitizeFields","getLockedDocumentsCollection","lockedDocumentsCollectionSlug","getPreferencesCollection","preferencesCollectionSlug","getQueryPresetsConfig","queryPresetsCollectionSlug","getDefaultJobsCollection","jobsCollectionSlug","getJobStatsGlobal","flattenAllFields","flattenBlock","hasScheduledPublishEnabled","validateTimezones","getSchedulePublishTask","addDefaultsToConfig","addOrderableEndpoint","addOrderableFieldsAndHook","sanitizeAdminConfig","configToSanitize","sanitizedConfig","loggingLevels","Forbidden","Locked","MissingFile","NotFound","ValidationError","admin","dashboard","widgets","push","slug","Component","minWidth","defaultLayout","widgetSlug","width","user","firstCollectionWithAuth","collections","find","auth","Boolean","userCollection","timezones","supportedTimezones","source","sanitizeConfig","incomingConfig","configWithDefaults","config","endpoints","endpoint","localization","locales","length","firstLocale","localeCodes","map","locale","code","label","rtl","toString","fallback","i18nConfig","fallbackLanguage","supportedLanguages","translations","i18n","supportedLangKeys","Object","keys","fallbackLang","includes","richTextSanitizationPromises","schedulePublishCollections","queryPresetsCollections","schedulePublishGlobals","collectionSlugs","Set","validRelationships","c","dashboardWidgets","widget","fields","existingFieldNames","parentIsLocalized","blocks","block","sanitizedBlock","_sanitized","concat","labels","flattenedSanitizedBlock","orderableJoins","i","has","add","draftsConfig","versions","drafts","schedulePublish","enableQueryPresets","fieldsToAdd","Map","joinFieldPathsByCollection","collection","orderable","currentFields","get","set","defaultSort","joinInfo","targetCollection","targetCollectionSlug","orderFieldName","currentJoinFieldPaths","joinFieldOn","orderableFields","flattenedFields","size","globals","jobs","tasks","adminUserSlug","enabled","Array","isArray","workflows","hasScheduleProperty","some","task","schedule","workflow","scheduling","stats","defaultJobsCollection","jobsCollectionOverrides","sanitizedJobsCollection","lockedDocumentsCollection","migrations","db","indexSortableFields","indexes","unique","serverURL","csrf","storage","upload","adapters","from","adapter","filter","email","editor","isRoot","promises","sanitizeFunction","Promise","all"],"mappings":"AAEA,SAASA,EAAE,QAAQ,wCAAuC;AAe1D,SAASC,qBAAqB,QAAQ,yBAAwB;AAC9D,SAASC,iBAAiB,QAAQ,6BAA4B;AAC9D,SAASC,kBAAkB,QAAQ,oCAAmC;AACtE,SAASC,oBAAoB,QAAQ,iDAAgD;AACrF,SAASC,mBAAmB,EAAEC,oBAAoB,QAAQ,qBAAoB;AAC9E,SAASC,gBAAgB,QAAQ,oDAAmD;AACpF,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,2BAA2B,QAAQ,8CAA6C;AACzF,SAASC,eAAe,EAAEC,YAAY,EAAEC,cAAc,QAAQ,cAAa;AAC3E,SACEC,4BAA4B,EAC5BC,6BAA6B,QACxB,gCAA+B;AACtC,SAASC,wBAAwB,EAAEC,yBAAyB,QAAQ,2BAA0B;AAC9F,SAASC,qBAAqB,EAAEC,0BAA0B,QA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