payload 4.0.0-internal.c2b57ce → 4.0.0-internal.cd69eef

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 (822) hide show
  1. package/LICENSE.md +1 -1
  2. package/bin.js +11 -0
  3. package/dist/__testing__/predefinedMigration.d.ts +4 -3
  4. package/dist/__testing__/predefinedMigration.d.ts.map +1 -1
  5. package/dist/admin/RichText.d.ts +3 -11
  6. package/dist/admin/RichText.d.ts.map +1 -1
  7. package/dist/admin/RichText.js.map +1 -1
  8. package/dist/admin/adapters/devReload.d.ts +9 -0
  9. package/dist/admin/adapters/devReload.d.ts.map +1 -0
  10. package/dist/admin/adapters/devReload.js +6 -0
  11. package/dist/admin/adapters/devReload.js.map +1 -0
  12. package/dist/admin/adapters/index.d.ts +3 -0
  13. package/dist/admin/adapters/index.d.ts.map +1 -1
  14. package/dist/admin/adapters/index.js.map +1 -1
  15. package/dist/admin/adapters/render.d.ts +16 -0
  16. package/dist/admin/adapters/render.d.ts.map +1 -0
  17. package/dist/admin/adapters/render.js +7 -0
  18. package/dist/admin/adapters/render.js.map +1 -0
  19. package/dist/admin/adapters/router.d.ts +8 -0
  20. package/dist/admin/adapters/router.d.ts.map +1 -1
  21. package/dist/admin/adapters/router.js.map +1 -1
  22. package/dist/admin/adapters/views.d.ts +36 -0
  23. package/dist/admin/adapters/views.d.ts.map +1 -0
  24. package/dist/admin/adapters/views.js +7 -0
  25. package/dist/admin/adapters/views.js.map +1 -0
  26. package/dist/admin/fields/Row.d.ts +2 -2
  27. package/dist/admin/fields/Row.d.ts.map +1 -1
  28. package/dist/admin/fields/Row.js.map +1 -1
  29. package/dist/admin/forms/Description.d.ts +2 -2
  30. package/dist/admin/forms/Description.d.ts.map +1 -1
  31. package/dist/admin/forms/Description.js.map +1 -1
  32. package/dist/admin/forms/Field.d.ts +10 -5
  33. package/dist/admin/forms/Field.d.ts.map +1 -1
  34. package/dist/admin/forms/Field.js.map +1 -1
  35. package/dist/admin/functions/index.d.ts +10 -1
  36. package/dist/admin/functions/index.d.ts.map +1 -1
  37. package/dist/admin/functions/index.js.map +1 -1
  38. package/dist/admin/types.d.ts +3 -2
  39. package/dist/admin/types.d.ts.map +1 -1
  40. package/dist/admin/types.js.map +1 -1
  41. package/dist/admin/views/dashboard.d.ts +7 -0
  42. package/dist/admin/views/dashboard.d.ts.map +1 -1
  43. package/dist/admin/views/dashboard.js.map +1 -1
  44. package/dist/admin/views/document.d.ts +5 -3
  45. package/dist/admin/views/document.d.ts.map +1 -1
  46. package/dist/admin/views/document.js.map +1 -1
  47. package/dist/admin/views/list.d.ts +10 -1
  48. package/dist/admin/views/list.d.ts.map +1 -1
  49. package/dist/admin/views/list.js.map +1 -1
  50. package/dist/auth/baseFields/apiKey.d.ts +10 -2
  51. package/dist/auth/baseFields/apiKey.d.ts.map +1 -1
  52. package/dist/auth/baseFields/apiKey.js +35 -24
  53. package/dist/auth/baseFields/apiKey.js.map +1 -1
  54. package/dist/auth/cookies.d.ts +2 -2
  55. package/dist/auth/cookies.d.ts.map +1 -1
  56. package/dist/auth/defaultAccess.d.ts +1 -1
  57. package/dist/auth/defaultAccess.d.ts.map +1 -1
  58. package/dist/auth/defaultAccess.js +1 -1
  59. package/dist/auth/defaultAccess.js.map +1 -1
  60. package/dist/auth/defaultUser.d.ts.map +1 -1
  61. package/dist/auth/defaultUser.js +2 -1
  62. package/dist/auth/defaultUser.js.map +1 -1
  63. package/dist/auth/ensureUsernameOrEmail.d.ts.map +1 -1
  64. package/dist/auth/executeAccess.d.ts.map +1 -1
  65. package/dist/auth/executeAuthStrategies.d.ts.map +1 -1
  66. package/dist/auth/extractAccessFromPermission.d.ts.map +1 -1
  67. package/dist/auth/extractJWT.d.ts +1 -1
  68. package/dist/auth/extractJWT.d.ts.map +1 -1
  69. package/dist/auth/getAuthFields.d.ts.map +1 -1
  70. package/dist/auth/getAuthFields.js +2 -2
  71. package/dist/auth/getAuthFields.js.map +1 -1
  72. package/dist/auth/getFieldsToSign.d.ts +1 -1
  73. package/dist/auth/getFieldsToSign.d.ts.map +1 -1
  74. package/dist/auth/getLoginOptions.d.ts +1 -1
  75. package/dist/auth/getLoginOptions.d.ts.map +1 -1
  76. package/dist/auth/isUserLocked.d.ts.map +1 -1
  77. package/dist/auth/jwt.d.ts.map +1 -1
  78. package/dist/auth/operations/access.d.ts.map +1 -1
  79. package/dist/auth/operations/auth.d.ts +2 -2
  80. package/dist/auth/operations/auth.d.ts.map +1 -1
  81. package/dist/auth/operations/auth.js.map +1 -1
  82. package/dist/auth/operations/forgotPassword.d.ts.map +1 -1
  83. package/dist/auth/operations/init.d.ts.map +1 -1
  84. package/dist/auth/operations/local/auth.d.ts.map +1 -1
  85. package/dist/auth/operations/login.d.ts +2 -1
  86. package/dist/auth/operations/login.d.ts.map +1 -1
  87. package/dist/auth/operations/login.js.map +1 -1
  88. package/dist/auth/operations/logout.d.ts.map +1 -1
  89. package/dist/auth/operations/me.d.ts +2 -2
  90. package/dist/auth/operations/me.d.ts.map +1 -1
  91. package/dist/auth/operations/me.js.map +1 -1
  92. package/dist/auth/operations/refresh.d.ts.map +1 -1
  93. package/dist/auth/operations/refresh.js +9 -3
  94. package/dist/auth/operations/refresh.js.map +1 -1
  95. package/dist/auth/operations/registerFirstUser.d.ts.map +1 -1
  96. package/dist/auth/operations/resetPassword.d.ts.map +1 -1
  97. package/dist/auth/operations/resetPassword.js.map +1 -1
  98. package/dist/auth/operations/unlock.d.ts.map +1 -1
  99. package/dist/auth/operations/verifyEmail.d.ts.map +1 -1
  100. package/dist/auth/sendVerificationEmail.d.ts +2 -2
  101. package/dist/auth/sendVerificationEmail.d.ts.map +1 -1
  102. package/dist/auth/sendVerificationEmail.js +1 -1
  103. package/dist/auth/sendVerificationEmail.js.map +1 -1
  104. package/dist/auth/sessions.d.ts +4 -5
  105. package/dist/auth/sessions.d.ts.map +1 -1
  106. package/dist/auth/sessions.js +5 -3
  107. package/dist/auth/sessions.js.map +1 -1
  108. package/dist/auth/strategies/apiKey.d.ts.map +1 -1
  109. package/dist/auth/strategies/apiKey.js.map +1 -1
  110. package/dist/auth/strategies/local/authenticate.d.ts.map +1 -1
  111. package/dist/auth/strategies/local/generatePasswordSaltHash.d.ts.map +1 -1
  112. package/dist/auth/strategies/local/incrementLoginAttempts.d.ts +2 -2
  113. package/dist/auth/strategies/local/incrementLoginAttempts.d.ts.map +1 -1
  114. package/dist/auth/strategies/local/incrementLoginAttempts.js +1 -1
  115. package/dist/auth/strategies/local/incrementLoginAttempts.js.map +1 -1
  116. package/dist/auth/strategies/local/register.d.ts.map +1 -1
  117. package/dist/auth/strategies/local/resetLoginAttempts.d.ts.map +1 -1
  118. package/dist/auth/types.d.ts +25 -21
  119. package/dist/auth/types.d.ts.map +1 -1
  120. package/dist/auth/types.js.map +1 -1
  121. package/dist/bin/build.d.ts +49 -0
  122. package/dist/bin/build.d.ts.map +1 -0
  123. package/dist/bin/build.js +226 -0
  124. package/dist/bin/build.js.map +1 -0
  125. package/dist/bin/build.spec.js +594 -0
  126. package/dist/bin/build.spec.js.map +1 -0
  127. package/dist/bin/frameworkConventions.d.ts +8 -0
  128. package/dist/bin/frameworkConventions.d.ts.map +1 -0
  129. package/dist/bin/frameworkConventions.js +8 -0
  130. package/dist/bin/frameworkConventions.js.map +1 -0
  131. package/dist/bin/generateImportMap/index.d.ts.map +1 -1
  132. package/dist/bin/generateImportMap/index.js +8 -5
  133. package/dist/bin/generateImportMap/index.js.map +1 -1
  134. package/dist/bin/generateImportMap/iterateCollections.d.ts.map +1 -1
  135. package/dist/bin/generateImportMap/iterateCollections.js +11 -0
  136. package/dist/bin/generateImportMap/iterateCollections.js.map +1 -1
  137. package/dist/bin/generateImportMap/iterateConfig.d.ts.map +1 -1
  138. package/dist/bin/generateImportMap/iterateConfig.js +12 -0
  139. package/dist/bin/generateImportMap/iterateConfig.js.map +1 -1
  140. package/dist/bin/generateImportMap/iterateFields.d.ts.map +1 -1
  141. package/dist/bin/generateImportMap/iterateFields.js +4 -1
  142. package/dist/bin/generateImportMap/iterateFields.js.map +1 -1
  143. package/dist/bin/generateImportMap/utilities/getFromImportMap.d.ts.map +1 -1
  144. package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.d.ts +5 -1
  145. package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.d.ts.map +1 -1
  146. package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.js +33 -18
  147. package/dist/bin/generateImportMap/utilities/resolveImportMapFilePath.js.map +1 -1
  148. package/dist/bin/generateTypes.d.ts +3 -2
  149. package/dist/bin/generateTypes.d.ts.map +1 -1
  150. package/dist/bin/generateTypes.js +11 -1
  151. package/dist/bin/generateTypes.js.map +1 -1
  152. package/dist/bin/index.d.ts.map +1 -1
  153. package/dist/bin/index.js +9 -0
  154. package/dist/bin/index.js.map +1 -1
  155. package/dist/bin/loadEnv.d.ts +3 -1
  156. package/dist/bin/loadEnv.d.ts.map +1 -1
  157. package/dist/bin/loadEnv.js +40 -10
  158. package/dist/bin/loadEnv.js.map +1 -1
  159. package/dist/bin/migrate.d.ts.map +1 -1
  160. package/dist/collections/config/client.d.ts +11 -4
  161. package/dist/collections/config/client.d.ts.map +1 -1
  162. package/dist/collections/config/client.js +8 -0
  163. package/dist/collections/config/client.js.map +1 -1
  164. package/dist/collections/config/defaults.d.ts +0 -4
  165. package/dist/collections/config/defaults.d.ts.map +1 -1
  166. package/dist/collections/config/defaults.js +2 -17
  167. package/dist/collections/config/defaults.js.map +1 -1
  168. package/dist/collections/config/defaults.spec.js +47 -0
  169. package/dist/collections/config/defaults.spec.js.map +1 -0
  170. package/dist/collections/config/sanitize.d.ts.map +1 -1
  171. package/dist/collections/config/sanitize.js +1 -11
  172. package/dist/collections/config/sanitize.js.map +1 -1
  173. package/dist/collections/config/sanitizeCompoundIndexes.d.ts.map +1 -1
  174. package/dist/collections/config/types.d.ts +13 -9
  175. package/dist/collections/config/types.d.ts.map +1 -1
  176. package/dist/collections/config/types.js.map +1 -1
  177. package/dist/collections/config/useAsTitle.d.ts.map +1 -1
  178. package/dist/collections/dataloader.d.ts +1 -1
  179. package/dist/collections/dataloader.d.ts.map +1 -1
  180. package/dist/collections/endpoints/create.d.ts.map +1 -1
  181. package/dist/collections/endpoints/create.js +0 -2
  182. package/dist/collections/endpoints/create.js.map +1 -1
  183. package/dist/collections/endpoints/updateByID.d.ts.map +1 -1
  184. package/dist/collections/endpoints/updateByID.js +1 -2
  185. package/dist/collections/endpoints/updateByID.js.map +1 -1
  186. package/dist/collections/operations/count.d.ts.map +1 -1
  187. package/dist/collections/operations/count.js +1 -0
  188. package/dist/collections/operations/count.js.map +1 -1
  189. package/dist/collections/operations/countVersions.d.ts.map +1 -1
  190. package/dist/collections/operations/create.d.ts +0 -1
  191. package/dist/collections/operations/create.d.ts.map +1 -1
  192. package/dist/collections/operations/create.js +15 -6
  193. package/dist/collections/operations/create.js.map +1 -1
  194. package/dist/collections/operations/delete.d.ts.map +1 -1
  195. package/dist/collections/operations/delete.js +3 -0
  196. package/dist/collections/operations/delete.js.map +1 -1
  197. package/dist/collections/operations/deleteByID.d.ts.map +1 -1
  198. package/dist/collections/operations/duplicate.d.ts.map +1 -1
  199. package/dist/collections/operations/find.d.ts.map +1 -1
  200. package/dist/collections/operations/findByID.d.ts.map +1 -1
  201. package/dist/collections/operations/findDistinct.d.ts.map +1 -1
  202. package/dist/collections/operations/findDistinct.js +1 -0
  203. package/dist/collections/operations/findDistinct.js.map +1 -1
  204. package/dist/collections/operations/findVersionByID.d.ts.map +1 -1
  205. package/dist/collections/operations/findVersions.d.ts.map +1 -1
  206. package/dist/collections/operations/local/count.d.ts +3 -3
  207. package/dist/collections/operations/local/count.d.ts.map +1 -1
  208. package/dist/collections/operations/local/count.js.map +1 -1
  209. package/dist/collections/operations/local/countVersions.d.ts +3 -3
  210. package/dist/collections/operations/local/countVersions.d.ts.map +1 -1
  211. package/dist/collections/operations/local/countVersions.js.map +1 -1
  212. package/dist/collections/operations/local/create.d.ts +3 -3
  213. package/dist/collections/operations/local/create.d.ts.map +1 -1
  214. package/dist/collections/operations/local/create.js.map +1 -1
  215. package/dist/collections/operations/local/delete.d.ts +3 -3
  216. package/dist/collections/operations/local/delete.d.ts.map +1 -1
  217. package/dist/collections/operations/local/delete.js.map +1 -1
  218. package/dist/collections/operations/local/duplicate.d.ts +3 -3
  219. package/dist/collections/operations/local/duplicate.d.ts.map +1 -1
  220. package/dist/collections/operations/local/duplicate.js.map +1 -1
  221. package/dist/collections/operations/local/find.d.ts +3 -3
  222. package/dist/collections/operations/local/find.d.ts.map +1 -1
  223. package/dist/collections/operations/local/find.js.map +1 -1
  224. package/dist/collections/operations/local/findByID.d.ts +3 -3
  225. package/dist/collections/operations/local/findByID.d.ts.map +1 -1
  226. package/dist/collections/operations/local/findByID.js.map +1 -1
  227. package/dist/collections/operations/local/findDistinct.d.ts +2 -2
  228. package/dist/collections/operations/local/findDistinct.d.ts.map +1 -1
  229. package/dist/collections/operations/local/findDistinct.js.map +1 -1
  230. package/dist/collections/operations/local/findVersionByID.d.ts +3 -3
  231. package/dist/collections/operations/local/findVersionByID.d.ts.map +1 -1
  232. package/dist/collections/operations/local/findVersionByID.js.map +1 -1
  233. package/dist/collections/operations/local/findVersions.d.ts +3 -3
  234. package/dist/collections/operations/local/findVersions.d.ts.map +1 -1
  235. package/dist/collections/operations/local/findVersions.js.map +1 -1
  236. package/dist/collections/operations/local/restoreVersion.d.ts +3 -3
  237. package/dist/collections/operations/local/restoreVersion.d.ts.map +1 -1
  238. package/dist/collections/operations/local/restoreVersion.js.map +1 -1
  239. package/dist/collections/operations/local/update.d.ts +7 -11
  240. package/dist/collections/operations/local/update.d.ts.map +1 -1
  241. package/dist/collections/operations/local/update.js +1 -2
  242. package/dist/collections/operations/local/update.js.map +1 -1
  243. package/dist/collections/operations/restoreVersion.d.ts.map +1 -1
  244. package/dist/collections/operations/update.d.ts +0 -1
  245. package/dist/collections/operations/update.d.ts.map +1 -1
  246. package/dist/collections/operations/update.js +8 -4
  247. package/dist/collections/operations/update.js.map +1 -1
  248. package/dist/collections/operations/updateByID.d.ts +0 -1
  249. package/dist/collections/operations/updateByID.d.ts.map +1 -1
  250. package/dist/collections/operations/updateByID.js +1 -5
  251. package/dist/collections/operations/updateByID.js.map +1 -1
  252. package/dist/collections/operations/utilities/buildAfterOperation.d.ts +1 -1
  253. package/dist/collections/operations/utilities/buildAfterOperation.d.ts.map +1 -1
  254. package/dist/collections/operations/utilities/copyDataWithFreshRowIDs.d.ts +9 -0
  255. package/dist/collections/operations/utilities/copyDataWithFreshRowIDs.d.ts.map +1 -0
  256. package/dist/collections/operations/utilities/copyDataWithFreshRowIDs.js +170 -0
  257. package/dist/collections/operations/utilities/copyDataWithFreshRowIDs.js.map +1 -0
  258. package/dist/collections/operations/utilities/sanitizeSortQuery.d.ts.map +1 -1
  259. package/dist/collections/operations/utilities/types.d.ts +20 -29
  260. package/dist/collections/operations/utilities/types.d.ts.map +1 -1
  261. package/dist/collections/operations/utilities/types.js.map +1 -1
  262. package/dist/collections/operations/utilities/update.d.ts +1 -2
  263. package/dist/collections/operations/utilities/update.d.ts.map +1 -1
  264. package/dist/collections/operations/utilities/update.js +64 -65
  265. package/dist/collections/operations/utilities/update.js.map +1 -1
  266. package/dist/config/client.d.ts +2 -2
  267. package/dist/config/client.d.ts.map +1 -1
  268. package/dist/config/client.js.map +1 -1
  269. package/dist/config/defaults.d.ts +0 -4
  270. package/dist/config/defaults.d.ts.map +1 -1
  271. package/dist/config/defaults.js +0 -78
  272. package/dist/config/defaults.js.map +1 -1
  273. package/dist/config/definePlugin.d.ts +10 -10
  274. package/dist/config/definePlugin.d.ts.map +1 -1
  275. package/dist/config/definePlugin.js +7 -11
  276. package/dist/config/definePlugin.js.map +1 -1
  277. package/dist/config/orderable/fractional-indexing.d.ts +23 -23
  278. package/dist/config/orderable/fractional-indexing.d.ts.map +1 -1
  279. package/dist/config/orderable/index.d.ts.map +1 -1
  280. package/dist/config/orderable/index.js +23 -0
  281. package/dist/config/orderable/index.js.map +1 -1
  282. package/dist/config/sanitize.d.ts.map +1 -1
  283. package/dist/config/sanitize.js +141 -13
  284. package/dist/config/sanitize.js.map +1 -1
  285. package/dist/config/types.d.ts +67 -20
  286. package/dist/config/types.d.ts.map +1 -1
  287. package/dist/config/types.js +2 -0
  288. package/dist/config/types.js.map +1 -1
  289. package/dist/database/combineQueries.d.ts.map +1 -1
  290. package/dist/database/getLocalizedPaths.d.ts.map +1 -1
  291. package/dist/database/getLocalizedPaths.js +1 -1
  292. package/dist/database/getLocalizedPaths.js.map +1 -1
  293. package/dist/database/migrations/findMigrationDir.d.ts.map +1 -1
  294. package/dist/database/migrations/getPredefinedMigration.d.ts.map +1 -1
  295. package/dist/database/migrations/migrationsCollection.d.ts.map +1 -1
  296. package/dist/database/migrations/migrationsCollection.js +2 -1
  297. package/dist/database/migrations/migrationsCollection.js.map +1 -1
  298. package/dist/database/migrations/readMigrationFiles.d.ts.map +1 -1
  299. package/dist/database/migrations/writeMigrationIndex.d.ts.map +1 -1
  300. package/dist/database/sanitizeJoinQuery.d.ts.map +1 -1
  301. package/dist/database/sanitizeWhereQuery.d.ts.map +1 -1
  302. package/dist/database/types.d.ts +1 -5
  303. package/dist/database/types.d.ts.map +1 -1
  304. package/dist/database/types.js.map +1 -1
  305. package/dist/duplicateDocument/index.d.ts.map +1 -1
  306. package/dist/email/getStringifiedToAddress.d.ts.map +1 -1
  307. package/dist/errors/APIError.d.ts.map +1 -1
  308. package/dist/errors/AuthenticationError.d.ts.map +1 -1
  309. package/dist/errors/DuplicateCollection.d.ts.map +1 -1
  310. package/dist/errors/DuplicateFieldName.d.ts.map +1 -1
  311. package/dist/errors/DuplicateGlobal.d.ts.map +1 -1
  312. package/dist/errors/ErrorDeletingFile.d.ts.map +1 -1
  313. package/dist/errors/FileRetrievalError.d.ts.map +1 -1
  314. package/dist/errors/FileUploadError.d.ts.map +1 -1
  315. package/dist/errors/Forbidden.d.ts.map +1 -1
  316. package/dist/errors/InvalidConfiguration.d.ts.map +1 -1
  317. package/dist/errors/InvalidFieldJoin.d.ts.map +1 -1
  318. package/dist/errors/InvalidFieldName.d.ts.map +1 -1
  319. package/dist/errors/InvalidFieldRelationship.d.ts.map +1 -1
  320. package/dist/errors/InvalidSchema.d.ts.map +1 -1
  321. package/dist/errors/Locked.d.ts.map +1 -1
  322. package/dist/errors/LockedAuth.d.ts.map +1 -1
  323. package/dist/errors/MissingCollectionLabel.d.ts.map +1 -1
  324. package/dist/errors/MissingEditorProp.d.ts.map +1 -1
  325. package/dist/errors/MissingFieldInputOptions.d.ts.map +1 -1
  326. package/dist/errors/MissingFieldType.d.ts.map +1 -1
  327. package/dist/errors/MissingFile.d.ts.map +1 -1
  328. package/dist/errors/NotFound.d.ts.map +1 -1
  329. package/dist/errors/QueryError.d.ts.map +1 -1
  330. package/dist/errors/ReservedFieldName.d.ts.map +1 -1
  331. package/dist/errors/TimestampsRequired.d.ts.map +1 -1
  332. package/dist/errors/UnauthorizedError.d.ts.map +1 -1
  333. package/dist/errors/UnverifiedEmail.d.ts.map +1 -1
  334. package/dist/errors/ValidationError.d.ts +1 -0
  335. package/dist/errors/ValidationError.d.ts.map +1 -1
  336. package/dist/errors/ValidationError.js.map +1 -1
  337. package/dist/exports/internal.d.ts +2 -0
  338. package/dist/exports/internal.d.ts.map +1 -1
  339. package/dist/exports/internal.js +2 -0
  340. package/dist/exports/internal.js.map +1 -1
  341. package/dist/exports/migrations.d.ts +5 -13
  342. package/dist/exports/migrations.d.ts.map +1 -1
  343. package/dist/exports/migrations.js +5 -13
  344. package/dist/exports/migrations.js.map +1 -1
  345. package/dist/exports/shared.d.ts +23 -2
  346. package/dist/exports/shared.d.ts.map +1 -1
  347. package/dist/exports/shared.js +22 -1
  348. package/dist/exports/shared.js.map +1 -1
  349. package/dist/fields/baseFields/slug/countVersions.d.ts.map +1 -1
  350. package/dist/fields/baseFields/slug/countVersions.js +6 -8
  351. package/dist/fields/baseFields/slug/countVersions.js.map +1 -1
  352. package/dist/fields/baseFields/slug/generateSlug.d.ts +14 -7
  353. package/dist/fields/baseFields/slug/generateSlug.d.ts.map +1 -1
  354. package/dist/fields/baseFields/slug/generateSlug.js +53 -73
  355. package/dist/fields/baseFields/slug/generateSlug.js.map +1 -1
  356. package/dist/fields/baseFields/slug/types.d.ts +14 -0
  357. package/dist/fields/baseFields/slug/types.d.ts.map +1 -0
  358. package/dist/fields/baseFields/slug/types.js +6 -0
  359. package/dist/fields/baseFields/slug/types.js.map +1 -0
  360. package/dist/fields/config/client.d.ts +6 -6
  361. package/dist/fields/config/client.d.ts.map +1 -1
  362. package/dist/fields/config/client.js +14 -14
  363. package/dist/fields/config/client.js.map +1 -1
  364. package/dist/fields/config/sanitize.d.ts.map +1 -1
  365. package/dist/fields/config/sanitize.js +40 -4
  366. package/dist/fields/config/sanitize.js.map +1 -1
  367. package/dist/fields/config/sanitizeJoinField.d.ts.map +1 -1
  368. package/dist/fields/config/types.d.ts +80 -76
  369. package/dist/fields/config/types.d.ts.map +1 -1
  370. package/dist/fields/config/types.js.map +1 -1
  371. package/dist/fields/getDefaultValue.d.ts.map +1 -1
  372. package/dist/fields/hooks/afterChange/index.d.ts.map +1 -1
  373. package/dist/fields/hooks/afterChange/promise.d.ts.map +1 -1
  374. package/dist/fields/hooks/afterChange/promise.js +1 -1
  375. package/dist/fields/hooks/afterChange/promise.js.map +1 -1
  376. package/dist/fields/hooks/afterChange/traverseFields.d.ts.map +1 -1
  377. package/dist/fields/hooks/afterRead/promise.d.ts.map +1 -1
  378. package/dist/fields/hooks/afterRead/promise.js +13 -3
  379. package/dist/fields/hooks/afterRead/promise.js.map +1 -1
  380. package/dist/fields/hooks/afterRead/relationshipPopulationPromise.d.ts.map +1 -1
  381. package/dist/fields/hooks/afterRead/traverseFields.d.ts.map +1 -1
  382. package/dist/fields/hooks/afterRead/virtualFieldPopulationPromise.d.ts.map +1 -1
  383. package/dist/fields/hooks/beforeChange/cloneDataFromOriginalDoc.d.ts.map +1 -1
  384. package/dist/fields/hooks/beforeChange/getExistingRowDoc.d.ts.map +1 -1
  385. package/dist/fields/hooks/beforeChange/index.d.ts.map +1 -1
  386. package/dist/fields/hooks/beforeChange/promise.d.ts.map +1 -1
  387. package/dist/fields/hooks/beforeChange/promise.js +3 -3
  388. package/dist/fields/hooks/beforeChange/promise.js.map +1 -1
  389. package/dist/fields/hooks/beforeChange/traverseFields.d.ts.map +1 -1
  390. package/dist/fields/hooks/beforeDuplicate/index.d.ts.map +1 -1
  391. package/dist/fields/hooks/beforeDuplicate/promise.d.ts.map +1 -1
  392. package/dist/fields/hooks/beforeDuplicate/promise.js +2 -2
  393. package/dist/fields/hooks/beforeDuplicate/promise.js.map +1 -1
  394. package/dist/fields/hooks/beforeDuplicate/traverseFields.d.ts.map +1 -1
  395. package/dist/fields/hooks/beforeValidate/index.d.ts.map +1 -1
  396. package/dist/fields/hooks/beforeValidate/promise.d.ts.map +1 -1
  397. package/dist/fields/hooks/beforeValidate/promise.js +11 -2
  398. package/dist/fields/hooks/beforeValidate/promise.js.map +1 -1
  399. package/dist/fields/hooks/beforeValidate/traverseFields.d.ts.map +1 -1
  400. package/dist/fields/isFieldDisabled.d.ts.map +1 -1
  401. package/dist/fields/mergeBaseFields.d.ts.map +1 -1
  402. package/dist/fields/setDefaultBeforeDuplicate.d.ts.map +1 -1
  403. package/dist/fields/setDefaultBeforeDuplicate.js +1 -0
  404. package/dist/fields/setDefaultBeforeDuplicate.js.map +1 -1
  405. package/dist/fields/sortableFieldTypes.d.ts.map +1 -1
  406. package/dist/fields/sortableFieldTypes.js +1 -0
  407. package/dist/fields/sortableFieldTypes.js.map +1 -1
  408. package/dist/fields/validations.d.ts +4 -1
  409. package/dist/fields/validations.d.ts.map +1 -1
  410. package/dist/fields/validations.js +12 -4
  411. package/dist/fields/validations.js.map +1 -1
  412. package/dist/globals/config/client.d.ts +4 -4
  413. package/dist/globals/config/client.d.ts.map +1 -1
  414. package/dist/globals/config/sanitize.d.ts.map +1 -1
  415. package/dist/globals/config/sanitize.js +2 -6
  416. package/dist/globals/config/sanitize.js.map +1 -1
  417. package/dist/globals/config/sanitize.spec.js +43 -0
  418. package/dist/globals/config/sanitize.spec.js.map +1 -0
  419. package/dist/globals/endpoints/update.d.ts.map +1 -1
  420. package/dist/globals/endpoints/update.js +0 -2
  421. package/dist/globals/endpoints/update.js.map +1 -1
  422. package/dist/globals/operations/countGlobalVersions.d.ts.map +1 -1
  423. package/dist/globals/operations/docAccess.d.ts.map +1 -1
  424. package/dist/globals/operations/findOne.d.ts.map +1 -1
  425. package/dist/globals/operations/findVersionByID.d.ts.map +1 -1
  426. package/dist/globals/operations/findVersions.d.ts.map +1 -1
  427. package/dist/globals/operations/local/countVersions.d.ts +3 -3
  428. package/dist/globals/operations/local/countVersions.d.ts.map +1 -1
  429. package/dist/globals/operations/local/countVersions.js.map +1 -1
  430. package/dist/globals/operations/local/findOne.d.ts +3 -3
  431. package/dist/globals/operations/local/findOne.d.ts.map +1 -1
  432. package/dist/globals/operations/local/findOne.js.map +1 -1
  433. package/dist/globals/operations/local/findVersionByID.d.ts +3 -3
  434. package/dist/globals/operations/local/findVersionByID.d.ts.map +1 -1
  435. package/dist/globals/operations/local/findVersionByID.js.map +1 -1
  436. package/dist/globals/operations/local/findVersions.d.ts +3 -3
  437. package/dist/globals/operations/local/findVersions.d.ts.map +1 -1
  438. package/dist/globals/operations/local/findVersions.js.map +1 -1
  439. package/dist/globals/operations/local/restoreVersion.d.ts +3 -3
  440. package/dist/globals/operations/local/restoreVersion.d.ts.map +1 -1
  441. package/dist/globals/operations/local/restoreVersion.js.map +1 -1
  442. package/dist/globals/operations/local/update.d.ts +7 -9
  443. package/dist/globals/operations/local/update.d.ts.map +1 -1
  444. package/dist/globals/operations/local/update.js +1 -2
  445. package/dist/globals/operations/local/update.js.map +1 -1
  446. package/dist/globals/operations/restoreVersion.d.ts.map +1 -1
  447. package/dist/globals/operations/update.d.ts +0 -1
  448. package/dist/globals/operations/update.d.ts.map +1 -1
  449. package/dist/globals/operations/update.js +52 -58
  450. package/dist/globals/operations/update.js.map +1 -1
  451. package/dist/hierarchy/addHierarchyToCollection.d.ts.map +1 -1
  452. package/dist/hierarchy/buildParentField.d.ts.map +1 -1
  453. package/dist/hierarchy/constants.d.ts.map +1 -1
  454. package/dist/hierarchy/getInitialTreeData.d.ts.map +1 -1
  455. package/dist/hierarchy/hooks/collectionAfterDelete.d.ts.map +1 -1
  456. package/dist/hierarchy/hooks/collectionAfterRead.d.ts.map +1 -1
  457. package/dist/hierarchy/hooks/collectionBeforeChange.d.ts.map +1 -1
  458. package/dist/hierarchy/hooks/collectionBeforeDelete.d.ts.map +1 -1
  459. package/dist/hierarchy/hooks/collectionBeforeOperation.d.ts.map +1 -1
  460. package/dist/hierarchy/hooks/ensureSafeCollectionsChange.d.ts.map +1 -1
  461. package/dist/hierarchy/injectHierarchyButton.d.ts.map +1 -1
  462. package/dist/hierarchy/resolveHierarchyCollections.d.ts.map +1 -1
  463. package/dist/hierarchy/resolveHierarchyCollections.js +1 -1
  464. package/dist/hierarchy/resolveHierarchyCollections.js.map +1 -1
  465. package/dist/hierarchy/sanitizeHierarchyCollection.d.ts.map +1 -1
  466. package/dist/hierarchy/sanitizeHierarchyCollection.js +3 -1
  467. package/dist/hierarchy/sanitizeHierarchyCollection.js.map +1 -1
  468. package/dist/hierarchy/types.d.ts +8 -1
  469. package/dist/hierarchy/types.d.ts.map +1 -1
  470. package/dist/hierarchy/types.js.map +1 -1
  471. package/dist/index.bundled.d.ts +4466 -4152
  472. package/dist/index.d.ts +79 -34
  473. package/dist/index.d.ts.map +1 -1
  474. package/dist/index.js +54 -37
  475. package/dist/index.js.map +1 -1
  476. package/dist/kv/adapters/DatabaseKVAdapter.d.ts.map +1 -1
  477. package/dist/kv/adapters/DatabaseKVAdapter.js +1 -0
  478. package/dist/kv/adapters/DatabaseKVAdapter.js.map +1 -1
  479. package/dist/kv/adapters/InMemoryKVAdapter.d.ts.map +1 -1
  480. package/dist/locked-documents/config.d.ts.map +1 -1
  481. package/dist/locked-documents/config.js +2 -1
  482. package/dist/locked-documents/config.js.map +1 -1
  483. package/dist/preferences/config.d.ts.map +1 -1
  484. package/dist/preferences/config.js +2 -1
  485. package/dist/preferences/config.js.map +1 -1
  486. package/dist/preferences/deleteUserPreferences.d.ts.map +1 -1
  487. package/dist/preferences/keys.d.ts +8 -4
  488. package/dist/preferences/keys.d.ts.map +1 -1
  489. package/dist/preferences/keys.js +4 -1
  490. package/dist/preferences/keys.js.map +1 -1
  491. package/dist/preferences/types.d.ts +15 -0
  492. package/dist/preferences/types.d.ts.map +1 -1
  493. package/dist/preferences/types.js +3 -1
  494. package/dist/preferences/types.js.map +1 -1
  495. package/dist/query-presets/access.d.ts.map +1 -1
  496. package/dist/query-presets/config.d.ts.map +1 -1
  497. package/dist/query-presets/config.js +77 -37
  498. package/dist/query-presets/config.js.map +1 -1
  499. package/dist/query-presets/constraints.d.ts.map +1 -1
  500. package/dist/query-presets/constraints.js +3 -2
  501. package/dist/query-presets/constraints.js.map +1 -1
  502. package/dist/query-presets/types.d.ts +1 -1
  503. package/dist/query-presets/types.d.ts.map +1 -1
  504. package/dist/queues/config/collection.d.ts.map +1 -1
  505. package/dist/queues/config/collection.js +2 -1
  506. package/dist/queues/config/collection.js.map +1 -1
  507. package/dist/queues/config/generateJobsJSONSchemas.d.ts +1 -1
  508. package/dist/queues/config/generateJobsJSONSchemas.d.ts.map +1 -1
  509. package/dist/queues/config/generateJobsJSONSchemas.js +33 -12
  510. package/dist/queues/config/generateJobsJSONSchemas.js.map +1 -1
  511. package/dist/queues/config/global.d.ts.map +1 -1
  512. package/dist/queues/config/global.js +2 -1
  513. package/dist/queues/config/global.js.map +1 -1
  514. package/dist/queues/endpoints/run.d.ts.map +1 -1
  515. package/dist/queues/errors/index.d.ts.map +1 -1
  516. package/dist/queues/localAPI.d.ts +8 -8
  517. package/dist/queues/localAPI.d.ts.map +1 -1
  518. package/dist/queues/operations/handleSchedules/getQueuesWithSchedules.d.ts.map +1 -1
  519. package/dist/queues/operations/runJobs/index.d.ts.map +1 -1
  520. package/dist/queues/operations/runJobs/runJSONJob/index.d.ts.map +1 -1
  521. package/dist/queues/operations/runJobs/runJob/getRunTaskFunction.d.ts.map +1 -1
  522. package/dist/queues/operations/runJobs/runJob/importHandlerPath.d.ts +1 -1
  523. package/dist/queues/operations/runJobs/runJob/importHandlerPath.d.ts.map +1 -1
  524. package/dist/queues/operations/runJobs/runJob/index.d.ts.map +1 -1
  525. package/dist/queues/utilities/getCurrentDate.d.ts.map +1 -1
  526. package/dist/queues/utilities/getJobTaskStatus.d.ts.map +1 -1
  527. package/dist/translations/getLocalI18n.d.ts.map +1 -1
  528. package/dist/types/constants.d.ts +2 -2
  529. package/dist/types/constants.d.ts.map +1 -1
  530. package/dist/types/index.d.ts +9 -7
  531. package/dist/types/index.d.ts.map +1 -1
  532. package/dist/types/index.js.map +1 -1
  533. package/dist/uploads/checkFileAccess.d.ts.map +1 -1
  534. package/dist/uploads/checkFileRestrictions.d.ts.map +1 -1
  535. package/dist/uploads/cropImage.d.ts.map +1 -1
  536. package/dist/uploads/docWithFilenameExists.d.ts.map +1 -1
  537. package/dist/uploads/endpoints/uploadInstructions.d.ts +3 -0
  538. package/dist/uploads/endpoints/uploadInstructions.d.ts.map +1 -0
  539. package/dist/uploads/endpoints/uploadInstructions.js +38 -0
  540. package/dist/uploads/endpoints/uploadInstructions.js.map +1 -0
  541. package/dist/uploads/fetchAPI-multipart/isEligibleRequest.d.ts.map +1 -1
  542. package/dist/uploads/fetchAPI-multipart/processMultipart.d.ts.map +1 -1
  543. package/dist/uploads/fetchAPI-multipart/processMultipart.js +4 -0
  544. package/dist/uploads/fetchAPI-multipart/processMultipart.js.map +1 -1
  545. package/dist/uploads/fetchAPI-multipart/processNested.d.ts.map +1 -1
  546. package/dist/uploads/fetchAPI-multipart/utilities.d.ts.map +1 -1
  547. package/dist/uploads/fileExists.d.ts.map +1 -1
  548. package/dist/uploads/generateFileData.d.ts +2 -1
  549. package/dist/uploads/generateFileData.d.ts.map +1 -1
  550. package/dist/uploads/generateFileData.js +5 -2
  551. package/dist/uploads/generateFileData.js.map +1 -1
  552. package/dist/uploads/getBaseFields.d.ts.map +1 -1
  553. package/dist/uploads/getExternalFile.d.ts.map +1 -1
  554. package/dist/uploads/getFileByPath.d.ts +1 -1
  555. package/dist/uploads/getFileByPath.d.ts.map +1 -1
  556. package/dist/uploads/getFileTypeFallback.d.ts.map +1 -1
  557. package/dist/uploads/getSafeFilename.d.ts.map +1 -1
  558. package/dist/uploads/image-resizing/createImageSize.d.ts.map +1 -1
  559. package/dist/uploads/image-resizing/generateImageSizeFilename.d.ts.map +1 -1
  560. package/dist/uploads/image-resizing/getImageResizeAction.d.ts +1 -1
  561. package/dist/uploads/image-resizing/getImageResizeAction.d.ts.map +1 -1
  562. package/dist/uploads/image-resizing/parseFilename.d.ts.map +1 -1
  563. package/dist/uploads/image-resizing/sanitizeResizeConfig.d.ts.map +1 -1
  564. package/dist/uploads/matchMimeType.d.ts +8 -0
  565. package/dist/uploads/matchMimeType.d.ts.map +1 -0
  566. package/dist/uploads/matchMimeType.js +19 -0
  567. package/dist/uploads/matchMimeType.js.map +1 -0
  568. package/dist/uploads/matchMimeType.spec.js +66 -0
  569. package/dist/uploads/matchMimeType.spec.js.map +1 -0
  570. package/dist/uploads/mimeTypeValidator.d.ts.map +1 -1
  571. package/dist/uploads/safeFetch.d.ts.map +1 -1
  572. package/dist/uploads/safeFetch.js +11 -5
  573. package/dist/uploads/safeFetch.js.map +1 -1
  574. package/dist/uploads/saveBufferToFile.d.ts.map +1 -1
  575. package/dist/uploads/tempFile.d.ts.map +1 -1
  576. package/dist/uploads/types.d.ts +68 -1
  577. package/dist/uploads/types.d.ts.map +1 -1
  578. package/dist/uploads/types.js.map +1 -1
  579. package/dist/uploads/uploadFiles.d.ts.map +1 -1
  580. package/dist/utilities/addDataAndFileToRequest.d.ts.map +1 -1
  581. package/dist/utilities/addDataAndFileToRequest.js +11 -4
  582. package/dist/utilities/addDataAndFileToRequest.js.map +1 -1
  583. package/dist/utilities/addLocalesToRequest.d.ts.map +1 -1
  584. package/dist/utilities/addSelectGenericsToGeneretedTypes.d.ts.map +1 -1
  585. package/dist/utilities/appendDateTimezoneSelectFields.d.ts.map +1 -1
  586. package/dist/utilities/appendDateTimezoneSelectFields.js +2 -2
  587. package/dist/utilities/appendDateTimezoneSelectFields.js.map +1 -1
  588. package/dist/utilities/appendNonTrashedFilter.d.ts.map +1 -1
  589. package/dist/utilities/appendUploadSelectFields.d.ts.map +1 -1
  590. package/dist/utilities/canAccessAdmin.d.ts.map +1 -1
  591. package/dist/utilities/checkDocumentLockStatus.d.ts.map +1 -1
  592. package/dist/utilities/configToJSONSchema.d.ts +68 -16
  593. package/dist/utilities/configToJSONSchema.d.ts.map +1 -1
  594. package/dist/utilities/configToJSONSchema.js +312 -117
  595. package/dist/utilities/configToJSONSchema.js.map +1 -1
  596. package/dist/utilities/configToJSONSchema.spec.js +656 -85
  597. package/dist/utilities/configToJSONSchema.spec.js.map +1 -1
  598. package/dist/utilities/createLocalReq.d.ts +2 -2
  599. package/dist/utilities/createLocalReq.d.ts.map +1 -1
  600. package/dist/utilities/createLocalReq.js.map +1 -1
  601. package/dist/utilities/createPayloadRequest.d.ts.map +1 -1
  602. package/dist/utilities/createPayloadRequest.js +1 -0
  603. package/dist/utilities/createPayloadRequest.js.map +1 -1
  604. package/dist/utilities/deepCopyObject.d.ts.map +1 -1
  605. package/dist/utilities/deepCopyObject.js +8 -0
  606. package/dist/utilities/deepCopyObject.js.map +1 -1
  607. package/dist/utilities/dependencies/dependencyChecker.js +1 -1
  608. package/dist/utilities/dependencies/dependencyChecker.js.map +1 -1
  609. package/dist/utilities/dependencies/getDependencies.d.ts.map +1 -1
  610. package/dist/utilities/dependencies/getDependencies.js +5 -5
  611. package/dist/utilities/dependencies/getDependencies.js.map +1 -1
  612. package/dist/utilities/dependencies/resolveFrom.d.ts.map +1 -1
  613. package/dist/utilities/dynamicImport.js +1 -1
  614. package/dist/utilities/dynamicImport.js.map +1 -1
  615. package/dist/utilities/escapeRegExp.d.ts.map +1 -1
  616. package/dist/utilities/extractID.d.ts.map +1 -1
  617. package/dist/utilities/filterDataToSelectedLocales.d.ts.map +1 -1
  618. package/dist/utilities/filterDataToSelectedLocales.js +5 -12
  619. package/dist/utilities/filterDataToSelectedLocales.js.map +1 -1
  620. package/dist/utilities/filterDataToSelectedLocales.spec.js +1 -2
  621. package/dist/utilities/filterDataToSelectedLocales.spec.js.map +1 -1
  622. package/dist/utilities/flattenAllFields.d.ts.map +1 -1
  623. package/dist/utilities/flattenAllFields.js +7 -22
  624. package/dist/utilities/flattenAllFields.js.map +1 -1
  625. package/dist/utilities/formatAdminURL.d.ts.map +1 -1
  626. package/dist/utilities/formatErrors.d.ts.map +1 -1
  627. package/dist/utilities/formatErrors.js +3 -1
  628. package/dist/utilities/formatErrors.js.map +1 -1
  629. package/dist/utilities/formatLabels.d.ts.map +1 -1
  630. package/dist/utilities/getBestFitFromSizes.d.ts.map +1 -1
  631. package/dist/utilities/getBlockSelect.d.ts.map +1 -1
  632. package/dist/utilities/getDataByPath.d.ts.map +1 -1
  633. package/dist/utilities/getEntityPermissions/getEntityPermissions.d.ts.map +1 -1
  634. package/dist/utilities/getEntityPermissions/getEntityPermissions.js +2 -0
  635. package/dist/utilities/getEntityPermissions/getEntityPermissions.js.map +1 -1
  636. package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts +7 -1
  637. package/dist/utilities/getEntityPermissions/populateFieldPermissions.d.ts.map +1 -1
  638. package/dist/utilities/getEntityPermissions/populateFieldPermissions.js +24 -7
  639. package/dist/utilities/getEntityPermissions/populateFieldPermissions.js.map +1 -1
  640. package/dist/utilities/getFieldByPath.d.ts.map +1 -1
  641. package/dist/utilities/getFieldByPath.js +1 -1
  642. package/dist/utilities/getFieldByPath.js.map +1 -1
  643. package/dist/utilities/getFieldPermissions.d.ts.map +1 -1
  644. package/dist/utilities/getObjectDotNotation.d.ts.map +1 -1
  645. package/dist/utilities/getRequestEntity.d.ts.map +1 -1
  646. package/dist/utilities/getRequestLanguage.d.ts +2 -2
  647. package/dist/utilities/getRequestLanguage.d.ts.map +1 -1
  648. package/dist/utilities/getRequestLanguage.js.map +1 -1
  649. package/dist/utilities/getRequestOrigin.d.ts +2 -2
  650. package/dist/utilities/getRequestOrigin.d.ts.map +1 -1
  651. package/dist/utilities/getSafeRedirect.d.ts.map +1 -1
  652. package/dist/utilities/getSelectMode.d.ts.map +1 -1
  653. package/dist/utilities/getSiblingData.d.ts.map +1 -1
  654. package/dist/utilities/getTranslatedLabel.d.ts.map +1 -1
  655. package/dist/utilities/getVersionsConfig.d.ts +1 -1
  656. package/dist/utilities/getVersionsConfig.d.ts.map +1 -1
  657. package/dist/utilities/getVersionsConfig.js.map +1 -1
  658. package/dist/utilities/handleEndpoints.d.ts.map +1 -1
  659. package/dist/utilities/handleEndpoints.js +7 -3
  660. package/dist/utilities/handleEndpoints.js.map +1 -1
  661. package/dist/utilities/headersWithCors.d.ts.map +1 -1
  662. package/dist/utilities/isEntityHidden.d.ts +2 -2
  663. package/dist/utilities/isEntityHidden.d.ts.map +1 -1
  664. package/dist/utilities/isURLAllowed.d.ts.map +1 -1
  665. package/dist/utilities/isURLAllowed.js +9 -3
  666. package/dist/utilities/isURLAllowed.js.map +1 -1
  667. package/dist/utilities/isURLAllowed.spec.js +78 -0
  668. package/dist/utilities/isURLAllowed.spec.js.map +1 -0
  669. package/dist/utilities/isValidID.d.ts +1 -1
  670. package/dist/utilities/isValidID.d.ts.map +1 -1
  671. package/dist/utilities/logError.d.ts.map +1 -1
  672. package/dist/utilities/logger.d.ts +1 -1
  673. package/dist/utilities/logger.d.ts.map +1 -1
  674. package/dist/utilities/mergeHeaders.d.ts.map +1 -1
  675. package/dist/utilities/mergeListSearchAndWhere.d.ts.map +1 -1
  676. package/dist/utilities/mergeLocalizedData.d.ts +14 -4
  677. package/dist/utilities/mergeLocalizedData.d.ts.map +1 -1
  678. package/dist/utilities/mergeLocalizedData.js +54 -46
  679. package/dist/utilities/mergeLocalizedData.js.map +1 -1
  680. package/dist/utilities/mergeLocalizedData.spec.js +23 -23
  681. package/dist/utilities/mergeLocalizedData.spec.js.map +1 -1
  682. package/dist/utilities/miniChalk.d.ts.map +1 -1
  683. package/dist/utilities/optionsAreEqual.d.ts.map +1 -1
  684. package/dist/utilities/parseBooleanString.d.ts.map +1 -1
  685. package/dist/utilities/parseCookies.d.ts +1 -1
  686. package/dist/utilities/parseCookies.d.ts.map +1 -1
  687. package/dist/utilities/parseParams/index.d.ts +2 -5
  688. package/dist/utilities/parseParams/index.d.ts.map +1 -1
  689. package/dist/utilities/parseParams/index.js.map +1 -1
  690. package/dist/utilities/parseParams/index.spec.js +0 -9
  691. package/dist/utilities/parseParams/index.spec.js.map +1 -1
  692. package/dist/utilities/profiling.d.ts.map +1 -1
  693. package/dist/utilities/reduceFieldsToValues.d.ts.map +1 -1
  694. package/dist/utilities/resolveSelect.d.ts.map +1 -1
  695. package/dist/utilities/routeError.d.ts.map +1 -1
  696. package/dist/utilities/sanitizeFallbackLocale.d.ts.map +1 -1
  697. package/dist/utilities/sanitizeInternalFields.d.ts.map +1 -1
  698. package/dist/utilities/sanitizeJoinParams.d.ts.map +1 -1
  699. package/dist/utilities/sanitizePopulateParam.d.ts.map +1 -1
  700. package/dist/utilities/sanitizeSelect.d.ts.map +1 -1
  701. package/dist/utilities/sanitizeSelectParam.d.ts.map +1 -1
  702. package/dist/utilities/sanitizeSortParams.d.ts.map +1 -1
  703. package/dist/utilities/setsAreEqual.d.ts.map +1 -1
  704. package/dist/utilities/slugify.d.ts.map +1 -1
  705. package/dist/utilities/stripUnselectedFields.d.ts.map +1 -1
  706. package/dist/utilities/telemetry/conf/index.d.ts.map +1 -1
  707. package/dist/utilities/telemetry/events/adminInit.d.ts.map +1 -1
  708. package/dist/utilities/telemetry/events/adminInit.js +2 -3
  709. package/dist/utilities/telemetry/events/adminInit.js.map +1 -1
  710. package/dist/utilities/telemetry/events/serverInit.d.ts.map +1 -1
  711. package/dist/utilities/telemetry/events/serverInit.js +2 -3
  712. package/dist/utilities/telemetry/events/serverInit.js.map +1 -1
  713. package/dist/utilities/telemetry/index.d.ts +15 -4
  714. package/dist/utilities/telemetry/index.d.ts.map +1 -1
  715. package/dist/utilities/telemetry/index.js +6 -1
  716. package/dist/utilities/telemetry/index.js.map +1 -1
  717. package/dist/utilities/telemetry/index.spec.js +43 -0
  718. package/dist/utilities/telemetry/index.spec.js.map +1 -0
  719. package/dist/utilities/telemetry/oneWayHash.d.ts.map +1 -1
  720. package/dist/utilities/timestamp.d.ts.map +1 -1
  721. package/dist/utilities/toKebabCase.d.ts.map +1 -1
  722. package/dist/utilities/transformColumnPreferences.d.ts.map +1 -1
  723. package/dist/utilities/transformColumnPreferences.js +4 -2
  724. package/dist/utilities/transformColumnPreferences.js.map +1 -1
  725. package/dist/utilities/transformWhereQuery.d.ts.map +1 -1
  726. package/dist/utilities/traverseFields.d.ts.map +1 -1
  727. package/dist/utilities/traverseFields.js +2 -4
  728. package/dist/utilities/traverseFields.js.map +1 -1
  729. package/dist/utilities/traverseForLocalizedFields.d.ts.map +1 -1
  730. package/dist/utilities/traverseForLocalizedFields.js +3 -0
  731. package/dist/utilities/traverseForLocalizedFields.js.map +1 -1
  732. package/dist/utilities/unflatten.d.ts.map +1 -1
  733. package/dist/utilities/validateMimeType.d.ts.map +1 -1
  734. package/dist/utilities/validateTimezones.d.ts.map +1 -1
  735. package/dist/utilities/validateWhereQuery.d.ts.map +1 -1
  736. package/dist/utilities/wordBoundariesRegex.d.ts.map +1 -1
  737. package/dist/utilities/wrapInternalEndpoints.d.ts.map +1 -1
  738. package/dist/versions/baseFields.d.ts +1 -2
  739. package/dist/versions/baseFields.d.ts.map +1 -1
  740. package/dist/versions/baseFields.js +0 -13
  741. package/dist/versions/baseFields.js.map +1 -1
  742. package/dist/versions/buildCollectionFields.d.ts.map +1 -1
  743. package/dist/versions/buildCollectionFields.js +0 -2
  744. package/dist/versions/buildCollectionFields.js.map +1 -1
  745. package/dist/versions/buildGlobalFields.d.ts.map +1 -1
  746. package/dist/versions/buildGlobalFields.js +0 -2
  747. package/dist/versions/buildGlobalFields.js.map +1 -1
  748. package/dist/versions/buildSingleLocalePublishData.d.ts +32 -0
  749. package/dist/versions/buildSingleLocalePublishData.d.ts.map +1 -0
  750. package/dist/versions/buildSingleLocalePublishData.js +37 -0
  751. package/dist/versions/buildSingleLocalePublishData.js.map +1 -0
  752. package/dist/versions/buildVersionCompoundIndexes.d.ts.map +1 -1
  753. package/dist/versions/defaults.d.ts.map +1 -1
  754. package/dist/versions/deleteCollectionVersions.d.ts.map +1 -1
  755. package/dist/versions/deleteScheduledPublishJobs.d.ts.map +1 -1
  756. package/dist/versions/drafts/appendVersionToQueryKey.d.ts.map +1 -1
  757. package/dist/versions/drafts/getQueryDraftsSelect.d.ts.map +1 -1
  758. package/dist/versions/drafts/getQueryDraftsSort.d.ts.map +1 -1
  759. package/dist/versions/drafts/replaceWithDraftIfAvailable.d.ts.map +1 -1
  760. package/dist/versions/enforceMaxVersions.d.ts.map +1 -1
  761. package/dist/versions/getLatestCollectionVersion.d.ts.map +1 -1
  762. package/dist/versions/getLatestGlobalVersion.d.ts.map +1 -1
  763. package/dist/versions/migrations/localizeStatus/shared.d.ts.map +1 -1
  764. package/dist/versions/saveVersion.d.ts +0 -2
  765. package/dist/versions/saveVersion.d.ts.map +1 -1
  766. package/dist/versions/saveVersion.js +12 -17
  767. package/dist/versions/saveVersion.js.map +1 -1
  768. package/dist/versions/schedule/job.d.ts.map +1 -1
  769. package/dist/versions/schedule/job.js +6 -10
  770. package/dist/versions/schedule/job.js.map +1 -1
  771. package/dist/versions/types.d.ts +2 -15
  772. package/dist/versions/types.d.ts.map +1 -1
  773. package/dist/versions/types.js.map +1 -1
  774. package/package.json +9 -6
  775. package/dist/database/migrations/templates/localizeStatus.d.ts +0 -10
  776. package/dist/database/migrations/templates/localizeStatus.d.ts.map +0 -1
  777. package/dist/database/migrations/templates/localizeStatus.js +0 -54
  778. package/dist/database/migrations/templates/localizeStatus.js.map +0 -1
  779. package/dist/fields/baseFields/slug/index.d.ts +0 -89
  780. package/dist/fields/baseFields/slug/index.d.ts.map +0 -1
  781. package/dist/fields/baseFields/slug/index.js +0 -81
  782. package/dist/fields/baseFields/slug/index.js.map +0 -1
  783. package/dist/versions/migrations/localizeStatus/index.d.ts +0 -12
  784. package/dist/versions/migrations/localizeStatus/index.d.ts.map +0 -1
  785. package/dist/versions/migrations/localizeStatus/index.js +0 -33
  786. package/dist/versions/migrations/localizeStatus/index.js.map +0 -1
  787. package/dist/versions/migrations/localizeStatus/mongo/down.d.ts +0 -9
  788. package/dist/versions/migrations/localizeStatus/mongo/down.d.ts.map +0 -1
  789. package/dist/versions/migrations/localizeStatus/mongo/down.js +0 -112
  790. package/dist/versions/migrations/localizeStatus/mongo/down.js.map +0 -1
  791. package/dist/versions/migrations/localizeStatus/mongo/index.d.ts +0 -8
  792. package/dist/versions/migrations/localizeStatus/mongo/index.d.ts.map +0 -1
  793. package/dist/versions/migrations/localizeStatus/mongo/index.js +0 -8
  794. package/dist/versions/migrations/localizeStatus/mongo/index.js.map +0 -1
  795. package/dist/versions/migrations/localizeStatus/mongo/up.d.ts +0 -9
  796. package/dist/versions/migrations/localizeStatus/mongo/up.d.ts.map +0 -1
  797. package/dist/versions/migrations/localizeStatus/mongo/up.js +0 -220
  798. package/dist/versions/migrations/localizeStatus/mongo/up.js.map +0 -1
  799. package/dist/versions/migrations/localizeStatus/sql/down.d.ts +0 -11
  800. package/dist/versions/migrations/localizeStatus/sql/down.d.ts.map +0 -1
  801. package/dist/versions/migrations/localizeStatus/sql/down.js +0 -213
  802. package/dist/versions/migrations/localizeStatus/sql/down.js.map +0 -1
  803. package/dist/versions/migrations/localizeStatus/sql/index.d.ts +0 -8
  804. package/dist/versions/migrations/localizeStatus/sql/index.d.ts.map +0 -1
  805. package/dist/versions/migrations/localizeStatus/sql/index.js +0 -8
  806. package/dist/versions/migrations/localizeStatus/sql/index.js.map +0 -1
  807. package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.d.ts +0 -13
  808. package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.d.ts.map +0 -1
  809. package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.js +0 -51
  810. package/dist/versions/migrations/localizeStatus/sql/migrateMainCollection.js.map +0 -1
  811. package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.d.ts +0 -13
  812. package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.d.ts.map +0 -1
  813. package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.js +0 -54
  814. package/dist/versions/migrations/localizeStatus/sql/migrateMainGlobal.js.map +0 -1
  815. package/dist/versions/migrations/localizeStatus/sql/up.d.ts +0 -11
  816. package/dist/versions/migrations/localizeStatus/sql/up.d.ts.map +0 -1
  817. package/dist/versions/migrations/localizeStatus/sql/up.js +0 -277
  818. package/dist/versions/migrations/localizeStatus/sql/up.js.map +0 -1
  819. package/dist/versions/saveSnapshot.d.ts +0 -18
  820. package/dist/versions/saveSnapshot.d.ts.map +0 -1
  821. package/dist/versions/saveSnapshot.js +0 -38
  822. package/dist/versions/saveSnapshot.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/globals/operations/update.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type { FindOptions } from '../../collections/operations/local/find.js'\nimport type { GlobalSlug, JsonObject } from '../../index.js'\nimport type {\n Operation,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformGlobalWithSelect,\n Where,\n} from '../../types/index.js'\nimport type {\n DataFromGlobalSlug,\n SanitizedGlobalConfig,\n SelectFromGlobalSlug,\n} from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { afterChange } from '../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { beforeChange } from '../../fields/hooks/beforeChange/index.js'\nimport { beforeValidate } from '../../fields/hooks/beforeValidate/index.js'\nimport { deepCopyObjectSimple } from '../../index.js'\nimport { checkDocumentLockStatus } from '../../utilities/checkDocumentLockStatus.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { getSelectMode } from '../../utilities/getSelectMode.js'\nimport {\n hasDraftsEnabled,\n hasDraftValidationEnabled,\n hasLocalizeStatusEnabled,\n} from '../../utilities/getVersionsConfig.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { mergeLocalizedData } from '../../utilities/mergeLocalizedData.js'\nimport { resolveSelect } from '../../utilities/resolveSelect.js'\nimport { sanitizeSelect } from '../../utilities/sanitizeSelect.js'\nimport { getLatestGlobalVersion } from '../../versions/getLatestGlobalVersion.js'\nimport { saveVersion } from '../../versions/saveVersion.js'\ntype Args<TSlug extends GlobalSlug> = {\n autosave?: boolean\n data: DeepPartial<Omit<DataFromGlobalSlug<TSlug>, 'id'>>\n depth?: number\n disableTransaction?: boolean\n draft?: boolean\n globalConfig: SanitizedGlobalConfig\n overrideAccess?: boolean\n overrideLock?: boolean\n populate?: PopulateType\n publishAllLocales?: boolean\n publishSpecificLocale?: string\n req: PayloadRequest\n showHiddenFields?: boolean\n slug: string\n unpublishAllLocales?: boolean\n} & Pick<FindOptions<string, SelectType>, 'select'>\n\nexport const updateOperation = async <\n TSlug extends GlobalSlug,\n TSelect extends SelectFromGlobalSlug<TSlug>,\n>(\n args: Args<TSlug>,\n): Promise<TransformGlobalWithSelect<TSlug, TSelect>> => {\n if (args.publishSpecificLocale) {\n args.req.locale = args.publishSpecificLocale\n }\n\n const {\n slug,\n autosave,\n depth,\n disableTransaction,\n draft: draftArg,\n globalConfig,\n overrideAccess,\n overrideLock,\n populate,\n publishAllLocales: publishAllLocalesArg,\n publishSpecificLocale,\n req: { fallbackLocale, locale, payload, payload: { config } = {} },\n req,\n select: incomingSelect,\n showHiddenFields,\n unpublishAllLocales: unpublishAllLocalesArg,\n } = args\n\n try {\n const shouldCommit = !disableTransaction && (await initTransaction(req))\n\n // /////////////////////////////////////\n // beforeOperation - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.beforeOperation?.length) {\n for (const hook of globalConfig.hooks.beforeOperation) {\n args =\n (await hook({\n args,\n context: args.req.context,\n global: globalConfig,\n operation: 'update',\n overrideAccess,\n req: args.req,\n })) || args\n }\n }\n\n let { data } = args\n\n const publishAllLocales =\n !draftArg && (publishAllLocalesArg ?? (hasLocalizeStatusEnabled(globalConfig) ? false : true))\n const unpublishAllLocales =\n typeof unpublishAllLocalesArg === 'string'\n ? unpublishAllLocalesArg === 'true'\n : !!unpublishAllLocalesArg\n const isSavingDraft =\n Boolean(draftArg && hasDraftsEnabled(globalConfig)) &&\n data._status !== 'published' &&\n !publishAllLocales\n\n if (isSavingDraft) {\n data._status = 'draft'\n }\n\n // /////////////////////////////////////\n // 1. Retrieve and execute access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess(\n {\n data,\n req,\n },\n globalConfig.access.update,\n )\n : true\n\n // /////////////////////////////////////\n // Retrieve document\n // /////////////////////////////////////\n\n const query: Where = overrideAccess ? undefined! : (accessResults as Where)\n\n // /////////////////////////////////////\n // 2. Retrieve document\n // /////////////////////////////////////\n const globalVersionResult = await getLatestGlobalVersion({\n slug,\n config: globalConfig,\n locale: locale!,\n payload,\n req,\n where: query,\n })\n const { global, globalExists } = globalVersionResult || {}\n\n let globalJSON: JsonObject = {}\n\n if (globalVersionResult && globalVersionResult.global) {\n globalJSON = deepCopyObjectSimple(global)\n\n if (globalJSON._id) {\n delete globalJSON._id\n }\n }\n\n const originalDoc = await afterRead({\n collection: null,\n context: req.context,\n depth: 0,\n doc: deepCopyObjectSimple(globalJSON),\n draft: draftArg!,\n fallbackLocale: fallbackLocale!,\n global: globalConfig,\n locale: locale!,\n overrideAccess: true,\n req,\n showHiddenFields: showHiddenFields!,\n })\n\n // ///////////////////////////////////////////\n // Handle potentially locked global documents\n // ///////////////////////////////////////////\n\n await checkDocumentLockStatus({\n globalSlug: slug,\n lockErrorMessage: `Global with slug \"${slug}\" is currently locked by another user and cannot be updated.`,\n overrideLock,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Fields\n // /////////////////////////////////////\n\n data = await beforeValidate({\n collection: null,\n context: req.context,\n data,\n doc: originalDoc,\n global: globalConfig,\n operation: 'update',\n overrideAccess: overrideAccess!,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.beforeValidate?.length) {\n for (const hook of globalConfig.hooks.beforeValidate) {\n data =\n (await hook({\n context: req.context,\n data,\n global: globalConfig,\n originalDoc,\n overrideAccess,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.beforeChange?.length) {\n for (const hook of globalConfig.hooks.beforeChange) {\n data =\n (await hook({\n context: req.context,\n data,\n global: globalConfig,\n originalDoc,\n overrideAccess,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Fields\n // /////////////////////////////////////\n\n const beforeChangeArgs = {\n collection: null,\n context: req.context,\n data,\n doc: originalDoc,\n docWithLocales: globalJSON,\n global: globalConfig,\n operation: 'update' as Operation,\n req,\n skipValidation:\n (isSavingDraft && !hasDraftValidationEnabled(globalConfig)) ||\n // Skip validation for unpublish operations — they only change _status, not document data\n unpublishAllLocales,\n }\n\n let result: JsonObject = await beforeChange(beforeChangeArgs)\n let snapshotToSave: JsonObject | undefined\n\n // /////////////////////////////////////\n // Handle Localized Data Merging\n // /////////////////////////////////////\n\n if (config && config.localization && globalConfig.versions) {\n let currentGlobal: JsonObject | null = null\n let snapshotData: JsonObject | undefined\n\n if (globalConfig.versions.drafts && globalConfig.versions.drafts.localizeStatus) {\n if (publishAllLocales || unpublishAllLocales) {\n let accessibleLocaleCodes = config.localization.localeCodes\n\n if (config.localization.filterAvailableLocales) {\n const filteredLocales = await config.localization.filterAvailableLocales({\n locales: config.localization.locales,\n req,\n })\n accessibleLocaleCodes = filteredLocales.map((locale) =>\n typeof locale === 'string' ? locale : locale.code,\n )\n }\n\n if (typeof result._status !== 'object' || result._status === null) {\n result._status = {}\n }\n\n for (const localeCode of accessibleLocaleCodes) {\n result._status[localeCode] = unpublishAllLocales ? 'draft' : 'published'\n }\n } else if (!isSavingDraft) {\n // publishing a single locale\n currentGlobal = await payload.db.findGlobal({\n slug: globalConfig.slug,\n req,\n where: query,\n })\n snapshotData = result\n }\n } else if (publishSpecificLocale) {\n // previous way of publishing a single locale\n currentGlobal = (\n await getLatestGlobalVersion({\n slug,\n config: globalConfig,\n payload,\n published: true,\n req,\n where: query,\n })\n ).global\n snapshotData = {\n ...result,\n _status: 'draft',\n }\n }\n\n if (snapshotData) {\n snapshotToSave = deepCopyObjectSimple(snapshotData)\n\n result = mergeLocalizedData({\n configBlockReferences: config.blocks,\n dataWithLocales: result || {},\n docWithLocales: currentGlobal || {},\n fields: globalConfig.fields,\n selectedLocales: [locale!],\n })\n }\n }\n // /////////////////////////////////////\n // Update\n // /////////////////////////////////////\n\n const select = sanitizeSelect({\n fields: globalConfig.flattenedFields,\n select: resolveSelect({\n config: globalConfig.select,\n operation: 'update',\n req,\n select: incomingSelect,\n }),\n })\n\n if (!isSavingDraft) {\n const now = new Date().toISOString()\n // Ensure global has createdAt\n if (!result.createdAt) {\n result.createdAt = now\n }\n\n // Ensure updatedAt date is always updated\n result.updatedAt = now\n\n if (globalExists) {\n result = await payload.db.updateGlobal({\n slug,\n data: result,\n req,\n select,\n })\n } else {\n result = await payload.db.createGlobal({\n slug,\n data: result,\n req,\n })\n }\n }\n\n // /////////////////////////////////////\n // Create version\n // /////////////////////////////////////\n if (globalConfig.versions) {\n const { globalType } = result\n result = await saveVersion({\n autosave,\n docWithLocales: result,\n draft: isSavingDraft,\n global: globalConfig,\n operation: 'update',\n payload,\n publishSpecificLocale,\n req,\n select,\n snapshot: snapshotToSave,\n unpublish: unpublishAllLocales,\n })\n\n result = {\n ...result,\n globalType,\n }\n }\n\n // /////////////////////////////////////\n // Execute globalType field if not selected\n // /////////////////////////////////////\n if (select && result.globalType) {\n const selectMode = getSelectMode(select)\n if (\n (selectMode === 'include' && !select['globalType']) ||\n (selectMode === 'exclude' && select['globalType'] === false)\n ) {\n delete result['globalType']\n }\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: null,\n context: req.context,\n depth: depth!,\n doc: result,\n draft: draftArg!,\n fallbackLocale: null,\n global: globalConfig,\n locale: locale!,\n overrideAccess: overrideAccess!,\n populate,\n req,\n select,\n showHiddenFields: showHiddenFields!,\n })\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.afterRead?.length) {\n for (const hook of globalConfig.hooks.afterRead) {\n result =\n (await hook({\n context: req.context,\n doc: result,\n global: globalConfig,\n overrideAccess,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: null,\n context: req.context,\n data,\n doc: result,\n global: globalConfig,\n operation: 'update',\n previousDoc: originalDoc,\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.afterChange?.length) {\n for (const hook of globalConfig.hooks.afterChange) {\n result =\n (await hook({\n context: req.context,\n data,\n doc: result,\n global: globalConfig,\n overrideAccess,\n previousDoc: originalDoc,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n if (shouldCommit) {\n await commitTransaction(req)\n }\n\n return result as TransformGlobalWithSelect<TSlug, TSelect>\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","afterChange","afterRead","beforeChange","beforeValidate","deepCopyObjectSimple","checkDocumentLockStatus","commitTransaction","getSelectMode","hasDraftsEnabled","hasDraftValidationEnabled","hasLocalizeStatusEnabled","initTransaction","killTransaction","mergeLocalizedData","resolveSelect","sanitizeSelect","getLatestGlobalVersion","saveVersion","updateOperation","args","publishSpecificLocale","req","locale","slug","autosave","depth","disableTransaction","draft","draftArg","globalConfig","overrideAccess","overrideLock","populate","publishAllLocales","publishAllLocalesArg","fallbackLocale","payload","config","select","incomingSelect","showHiddenFields","unpublishAllLocales","unpublishAllLocalesArg","shouldCommit","hooks","beforeOperation","length","hook","context","global","operation","data","isSavingDraft","Boolean","_status","accessResults","access","update","query","undefined","globalVersionResult","where","globalExists","globalJSON","_id","originalDoc","collection","doc","globalSlug","lockErrorMessage","beforeChangeArgs","docWithLocales","skipValidation","result","snapshotToSave","localization","versions","currentGlobal","snapshotData","drafts","localizeStatus","accessibleLocaleCodes","localeCodes","filterAvailableLocales","filteredLocales","locales","map","code","localeCode","db","findGlobal","published","configBlockReferences","blocks","dataWithLocales","fields","selectedLocales","flattenedFields","now","Date","toISOString","createdAt","updatedAt","updateGlobal","createGlobal","globalType","snapshot","unpublish","selectMode","previousDoc","error"],"mappings":"AAkBA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,WAAW,QAAQ,0CAAyC;AACrE,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,YAAY,QAAQ,2CAA0C;AACvE,SAASC,cAAc,QAAQ,6CAA4C;AAC3E,SAASC,oBAAoB,QAAQ,iBAAgB;AACrD,SAASC,uBAAuB,QAAQ,6CAA4C;AACpF,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SACEC,gBAAgB,EAChBC,yBAAyB,EACzBC,wBAAwB,QACnB,uCAAsC;AAC7C,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,kBAAkB,QAAQ,wCAAuC;AAC1E,SAASC,aAAa,QAAQ,m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;QAExC,IAAI9B,cAAc;YAChB,MAAMrC,kBAAkBe;QAC1B;QAEA,OAAOoD;IACT,EAAE,OAAOqC,OAAgB;QACvB,MAAMlG,gBAAgBS;QACtB,MAAMyF;IACR;AACF,EAAC"}
1
+ {"version":3,"sources":["../../../src/globals/operations/update.ts"],"sourcesContent":["import type { DeepPartial } from 'ts-essentials'\n\nimport type { FindOptions } from '../../collections/operations/local/find.js'\nimport type { GlobalSlug, JsonObject } from '../../index.js'\nimport type {\n Operation,\n PayloadRequest,\n PopulateType,\n SelectType,\n TransformGlobalWithSelect,\n Where,\n} from '../../types/index.js'\nimport type {\n DataFromGlobalSlug,\n SanitizedGlobalConfig,\n SelectFromGlobalSlug,\n} from '../config/types.js'\n\nimport { executeAccess } from '../../auth/executeAccess.js'\nimport { afterChange } from '../../fields/hooks/afterChange/index.js'\nimport { afterRead } from '../../fields/hooks/afterRead/index.js'\nimport { beforeChange } from '../../fields/hooks/beforeChange/index.js'\nimport { beforeValidate } from '../../fields/hooks/beforeValidate/index.js'\nimport { deepCopyObjectSimple } from '../../index.js'\nimport { checkDocumentLockStatus } from '../../utilities/checkDocumentLockStatus.js'\nimport { commitTransaction } from '../../utilities/commitTransaction.js'\nimport { getSelectMode } from '../../utilities/getSelectMode.js'\nimport {\n hasDraftsEnabled,\n hasDraftValidationEnabled,\n hasLocalizeStatusEnabled,\n} from '../../utilities/getVersionsConfig.js'\nimport { initTransaction } from '../../utilities/initTransaction.js'\nimport { killTransaction } from '../../utilities/killTransaction.js'\nimport { resolveSelect } from '../../utilities/resolveSelect.js'\nimport { sanitizeSelect } from '../../utilities/sanitizeSelect.js'\nimport { buildLocalizedPublishData } from '../../versions/buildSingleLocalePublishData.js'\nimport { getLatestGlobalVersion } from '../../versions/getLatestGlobalVersion.js'\nimport { saveVersion } from '../../versions/saveVersion.js'\ntype Args<TSlug extends GlobalSlug> = {\n autosave?: boolean\n data: DeepPartial<Omit<DataFromGlobalSlug<TSlug>, 'id'>>\n depth?: number\n disableTransaction?: boolean\n draft?: boolean\n globalConfig: SanitizedGlobalConfig\n overrideAccess?: boolean\n overrideLock?: boolean\n populate?: PopulateType\n publishAllLocales?: boolean\n req: PayloadRequest\n showHiddenFields?: boolean\n slug: string\n unpublishAllLocales?: boolean\n} & Pick<FindOptions<string, SelectType>, 'select'>\n\nexport const updateOperation = async <\n TSlug extends GlobalSlug,\n TSelect extends SelectFromGlobalSlug<TSlug>,\n>(\n args: Args<TSlug>,\n): Promise<TransformGlobalWithSelect<TSlug, TSelect>> => {\n const {\n slug,\n autosave,\n depth,\n disableTransaction,\n draft: draftArg,\n globalConfig,\n overrideAccess,\n overrideLock,\n populate,\n publishAllLocales: publishAllLocalesArg,\n req: { fallbackLocale, locale, payload, payload: { config } = {} },\n req,\n select: incomingSelect,\n showHiddenFields,\n unpublishAllLocales: unpublishAllLocalesArg,\n } = args\n\n try {\n const shouldCommit = !disableTransaction && (await initTransaction(req))\n\n // /////////////////////////////////////\n // beforeOperation - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.beforeOperation?.length) {\n for (const hook of globalConfig.hooks.beforeOperation) {\n args =\n (await hook({\n args,\n context: args.req.context,\n global: globalConfig,\n operation: 'update',\n overrideAccess,\n req: args.req,\n })) || args\n }\n }\n\n let { data } = args\n\n const publishAllLocales =\n !draftArg &&\n (publishAllLocalesArg ??\n (hasLocalizeStatusEnabled(globalConfig) && locale !== 'all' ? false : true))\n const unpublishAllLocales =\n typeof unpublishAllLocalesArg === 'string'\n ? unpublishAllLocalesArg === 'true'\n : !!unpublishAllLocalesArg\n const isSavingDraft =\n Boolean(draftArg && hasDraftsEnabled(globalConfig)) &&\n data._status !== 'published' &&\n !publishAllLocales\n\n if (isSavingDraft) {\n data._status = 'draft'\n }\n\n // /////////////////////////////////////\n // 1. Retrieve and execute access\n // /////////////////////////////////////\n\n const accessResults = !overrideAccess\n ? await executeAccess(\n {\n data,\n req,\n },\n globalConfig.access.update,\n )\n : true\n\n // /////////////////////////////////////\n // Retrieve document\n // /////////////////////////////////////\n\n const query: Where = overrideAccess ? undefined! : (accessResults as Where)\n\n // /////////////////////////////////////\n // 2. Retrieve document\n // /////////////////////////////////////\n const globalVersionResult = await getLatestGlobalVersion({\n slug,\n config: globalConfig,\n locale: publishAllLocales || unpublishAllLocales ? 'all' : locale!,\n payload,\n req,\n where: query,\n })\n const { global, globalExists } = globalVersionResult || {}\n\n let globalJSON: JsonObject = {}\n\n if (globalVersionResult && globalVersionResult.global) {\n globalJSON = deepCopyObjectSimple(global)\n\n if (globalJSON._id) {\n delete globalJSON._id\n }\n }\n\n const originalDoc = await afterRead({\n collection: null,\n context: req.context,\n depth: 0,\n doc: deepCopyObjectSimple(globalJSON),\n draft: draftArg!,\n fallbackLocale: fallbackLocale!,\n global: globalConfig,\n locale: locale!,\n overrideAccess: true,\n req,\n showHiddenFields: showHiddenFields!,\n })\n\n // ///////////////////////////////////////////\n // Handle potentially locked global documents\n // ///////////////////////////////////////////\n\n await checkDocumentLockStatus({\n globalSlug: slug,\n lockErrorMessage: `Global with slug \"${slug}\" is currently locked by another user and cannot be updated.`,\n overrideLock,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Fields\n // /////////////////////////////////////\n\n data = await beforeValidate({\n collection: null,\n context: req.context,\n data,\n doc: originalDoc,\n global: globalConfig,\n operation: 'update',\n overrideAccess: overrideAccess!,\n req,\n })\n\n // /////////////////////////////////////\n // beforeValidate - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.beforeValidate?.length) {\n for (const hook of globalConfig.hooks.beforeValidate) {\n data =\n (await hook({\n context: req.context,\n data,\n global: globalConfig,\n originalDoc,\n overrideAccess,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.beforeChange?.length) {\n for (const hook of globalConfig.hooks.beforeChange) {\n data =\n (await hook({\n context: req.context,\n data,\n global: globalConfig,\n originalDoc,\n overrideAccess,\n req,\n })) || data\n }\n }\n\n // /////////////////////////////////////\n // beforeChange - Fields\n // /////////////////////////////////////\n\n const beforeChangeArgs = {\n collection: null,\n context: req.context,\n data,\n doc: originalDoc,\n docWithLocales: globalJSON,\n global: globalConfig,\n operation: 'update' as Operation,\n req,\n skipValidation:\n (isSavingDraft && !hasDraftValidationEnabled(globalConfig)) ||\n // Skip validation for unpublish operations — they only change _status, not document data\n unpublishAllLocales,\n }\n\n let result: JsonObject = await beforeChange(beforeChangeArgs)\n\n if (\n config?.localization &&\n hasLocalizeStatusEnabled(globalConfig) &&\n typeof result._status === 'string'\n ) {\n const statusStr = result._status\n result._status = {}\n for (const localeCode of config.localization.localeCodes) {\n ;(result._status as Record<string, unknown>)[localeCode] = statusStr\n }\n }\n\n // /////////////////////////////////////\n // Handle Localized Data Merging\n // /////////////////////////////////////\n\n let localizedPublishData: JsonObject | null = null\n\n if (config && config.localization && globalConfig.versions) {\n if (hasLocalizeStatusEnabled(globalConfig)) {\n if (publishAllLocales || unpublishAllLocales) {\n let accessibleLocaleCodes = config.localization.localeCodes\n\n if (config.localization.filterAvailableLocales) {\n const filteredLocales = await config.localization.filterAvailableLocales({\n locales: config.localization.locales,\n req,\n })\n accessibleLocaleCodes = filteredLocales.map((locale) =>\n typeof locale === 'string' ? locale : locale.code,\n )\n }\n\n if (typeof result._status !== 'object' || result._status === null) {\n result._status = {}\n }\n\n for (const localeCode of accessibleLocaleCodes) {\n result._status[localeCode] = unpublishAllLocales ? 'draft' : 'published'\n }\n } else if (\n !isSavingDraft &&\n result._status &&\n typeof result._status === 'object' &&\n !Array.isArray(result._status) &&\n (result._status as Record<string, unknown>)[locale!] === 'published'\n ) {\n const currentGlobal = await payload.db.findGlobal({\n slug: globalConfig.slug,\n locale: 'all',\n req,\n where: query,\n })\n\n localizedPublishData = buildLocalizedPublishData({\n config,\n currentDoc: currentGlobal as JsonObject,\n fields: globalConfig.fields,\n locale: locale!,\n result,\n })\n }\n }\n }\n\n const dataToUpdate: JsonObject = { ...(localizedPublishData ?? result) }\n\n // /////////////////////////////////////\n // Update\n // /////////////////////////////////////\n\n const select = sanitizeSelect({\n fields: globalConfig.flattenedFields,\n select: resolveSelect({\n config: globalConfig.select,\n operation: 'update',\n req,\n select: incomingSelect,\n }),\n })\n\n let resultWithLocales: JsonObject = result\n\n if (!isSavingDraft) {\n const now = new Date().toISOString()\n // Ensure global has createdAt\n if (!dataToUpdate.createdAt) {\n dataToUpdate.createdAt = now\n }\n\n // Ensure updatedAt date is always updated\n dataToUpdate.updatedAt = now\n\n if (globalExists) {\n resultWithLocales = await payload.db.updateGlobal({\n slug,\n data: dataToUpdate,\n req,\n select,\n })\n } else {\n resultWithLocales = await payload.db.createGlobal({\n slug,\n data: dataToUpdate,\n req,\n })\n }\n\n resultWithLocales.updatedAt = now\n\n if (localizedPublishData) {\n // Keep full locale payload for version writes during single-locale publish.\n resultWithLocales = {\n ...result,\n createdAt: resultWithLocales.createdAt ?? result.createdAt ?? now,\n updatedAt: now,\n }\n }\n }\n\n // /////////////////////////////////////\n // Create version\n // /////////////////////////////////////\n if (globalConfig.versions) {\n const { globalType } = resultWithLocales\n resultWithLocales = await saveVersion({\n autosave,\n docWithLocales: resultWithLocales,\n draft: isSavingDraft,\n global: globalConfig,\n operation: 'update',\n payload,\n req,\n select,\n unpublish: unpublishAllLocales,\n })\n\n resultWithLocales = {\n ...resultWithLocales,\n globalType,\n }\n }\n\n // /////////////////////////////////////\n // Execute globalType field if not selected\n // /////////////////////////////////////\n if (select && resultWithLocales.globalType) {\n const selectMode = getSelectMode(select)\n if (\n (selectMode === 'include' && !select['globalType']) ||\n (selectMode === 'exclude' && select['globalType'] === false)\n ) {\n delete resultWithLocales['globalType']\n }\n }\n\n // /////////////////////////////////////\n // afterRead - Fields\n // /////////////////////////////////////\n\n result = await afterRead({\n collection: null,\n context: req.context,\n depth: depth!,\n doc: resultWithLocales,\n draft: draftArg!,\n fallbackLocale: null,\n global: globalConfig,\n locale: locale!,\n overrideAccess: overrideAccess!,\n populate,\n req,\n select,\n showHiddenFields: showHiddenFields!,\n })\n\n // /////////////////////////////////////\n // afterRead - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.afterRead?.length) {\n for (const hook of globalConfig.hooks.afterRead) {\n result =\n (await hook({\n context: req.context,\n doc: result,\n global: globalConfig,\n overrideAccess,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // afterChange - Fields\n // /////////////////////////////////////\n\n result = await afterChange({\n collection: null,\n context: req.context,\n data,\n doc: result,\n global: globalConfig,\n operation: 'update',\n previousDoc: originalDoc,\n req,\n })\n\n // /////////////////////////////////////\n // afterChange - Global\n // /////////////////////////////////////\n\n if (globalConfig.hooks?.afterChange?.length) {\n for (const hook of globalConfig.hooks.afterChange) {\n result =\n (await hook({\n context: req.context,\n data,\n doc: result,\n global: globalConfig,\n overrideAccess,\n previousDoc: originalDoc,\n req,\n })) || result\n }\n }\n\n // /////////////////////////////////////\n // Return results\n // /////////////////////////////////////\n\n if (shouldCommit) {\n await commitTransaction(req)\n }\n\n return result as TransformGlobalWithSelect<TSlug, TSelect>\n } catch (error: unknown) {\n await killTransaction(req)\n throw error\n }\n}\n"],"names":["executeAccess","afterChange","afterRead","beforeChange","beforeValidate","deepCopyObjectSimple","checkDocumentLockStatus","commitTransaction","getSelectMode","hasDraftsEnabled","hasDraftValidationEnabled","hasLocalizeStatusEnabled","initTransaction","killTransaction","resolveSelect","sanitizeSelect","buildLocalizedPublishData","getLatestGlobalVersion","saveVersion","updateOperation","args","slug","autosave","depth","disableTransaction","draft","draftArg","globalConfig","overrideAccess","overrideLock","populate","publishAllLocales","publishAllLocalesArg","req","fallbackLocale","locale","payload","config","select","incomingSelect","showHiddenFields","unpublishAllLocales","unpublishAllLocalesArg","shouldCommit","hooks","beforeOperation","length","hook","context","global","operation","data","isSavingDraft","Boolean","_status","accessResults","access","update","query","undefined","globalVersionResult","where","globalExists","globalJSON","_id","originalDoc","collection","doc","globalSlug","lockErrorMessage","beforeChangeArgs","docWithLocales","skipValidation","result","localization","statusStr","localeCode","localeCodes","localizedPublishData","versions","accessibleLocaleCodes","filterAvailableLocales","filteredLocales","locales","map","code","Array","isArray","currentGlobal","db","findGlobal","currentDoc","fields","dataToUpdate","flattenedFields","resultWithLocales","now","Date","toISOString","createdAt","updatedAt","updateGlobal","createGlobal","globalType","unpublish","selectMode","previousDoc","error"],"mappings":"AAkBA,SAASA,aAAa,QAAQ,8BAA6B;AAC3D,SAASC,WAAW,QAAQ,0CAAyC;AACrE,SAASC,SAAS,QAAQ,wCAAuC;AACjE,SAASC,YAAY,QAAQ,2CAA0C;AACvE,SAASC,cAAc,QAAQ,6CAA4C;AAC3E,SAASC,oBAAoB,QAAQ,iBAAgB;AACrD,SAASC,uBAAuB,QAAQ,6CAA4C;AACpF,SAASC,iBAAiB,QAAQ,uCAAsC;AACxE,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SACEC,gBAAgB,EAChBC,yBAAyB,EACzBC,wBAAwB,QACnB,uCAAsC;AAC7C,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,eAAe,QAAQ,qCAAoC;AACpE,SAASC,aAAa,QAAQ,mCAAkC;AAChE,SAASC,cAAc,QAAQ,oCAAmC;AAClE,SAASC,yBAAyB,QAAQ,iDAAgD;AAC1F,SAASC,sBAAsB,QAAQ,2CAA0C;AACjF,SAASC,WAAW,QAAQ,gCAA+B;AAkB3D,OAAO,MAAMC,kBAAkB,OAI7BC;IAEA,MAAM,EACJC,IAAI,EACJC,QAAQ,EACRC,KAAK,EACLC,kBAAkB,EAClBC,OAAOC,QAAQ,EACfC,YAAY,EACZC,cAAc,EACdC,YAAY,EACZC,QAAQ,EACRC,mBAAmBC,oBAAoB,EACvCC,KAAK,EAAEC,cAAc,EAAEC,MAAM,EAAEC,OAAO,EAAEA,SAAS,EAAEC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,EAClEJ,GAAG,EACHK,QAAQC,cAAc,EACtBC,gBAAgB,EAChBC,qBAAqBC,sBA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;YAChBE;YACAG;YACAK;YACAE,kBAAkBA;QACpB;QAEA,wCAAwC;QACxC,qBAAqB;QACrB,wCAAwC;QAExC,IAAIb,aAAaiB,KAAK,EAAE1C,WAAW4C,QAAQ;YACzC,KAAK,MAAMC,QAAQpB,aAAaiB,KAAK,CAAC1C,SAAS,CAAE;gBAC/CuE,SACE,AAAC,MAAM1B,KAAK;oBACVC,SAASf,IAAIe,OAAO;oBACpBmB,KAAKM;oBACLxB,QAAQtB;oBACRC;oBACAK;gBACF,MAAOwC;YACX;QACF;QAEA,wCAAwC;QACxC,uBAAuB;QACvB,wCAAwC;QAExCA,SAAS,MAAMxE,YAAY;YACzBiE,YAAY;YACZlB,SAASf,IAAIe,OAAO;YACpBG;YACAgB,KAAKM;YACLxB,QAAQtB;YACRuB,WAAW;YACXwD,aAAazC;YACbhC;QACF;QAEA,wCAAwC;QACxC,uBAAuB;QACvB,wCAAwC;QAExC,IAAIN,aAAaiB,KAAK,EAAE3C,aAAa6C,QAAQ;YAC3C,KAAK,MAAMC,QAAQpB,aAAaiB,KAAK,CAAC3C,WAAW,CAAE;gBACjDwE,SACE,AAAC,MAAM1B,KAAK;oBACVC,SAASf,IAAIe,OAAO;oBACpBG;oBACAgB,KAAKM;oBACLxB,QAAQtB;oBACRC;oBACA8E,aAAazC;oBACbhC;gBACF,MAAOwC;YACX;QACF;QAEA,wCAAwC;QACxC,iBAAiB;QACjB,wCAAwC;QAExC,IAAI9B,cAAc;YAChB,MAAMpC,kBAAkB0B;QAC1B;QAEA,OAAOwC;IACT,EAAE,OAAOkC,OAAgB;QACvB,MAAM9F,gBAAgBoB;QACtB,MAAM0E;IACR;AACF,EAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"addHierarchyToCollection.d.ts","sourceRoot":"","sources":["../../src/hierarchy/addHierarchyToCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAQtE,eAAO,MAAM,wBAAwB,GAAI,8FAMtC;IACD,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,iBAAiB,EAAE,MAAM,CAAA;IACzB,kBAAkB,EAAE,MAAM,CAAA;CAC3B,SAkEA,CAAA"}
1
+ {"version":3,"file":"addHierarchyToCollection.d.ts","sourceRoot":"","sources":["../../src/hierarchy/addHierarchyToCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAQtE,eAAO,MAAM,wBAAwB,iGAMlC;IACD,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,iBAAiB,EAAE,MAAM,CAAA;IACzB,kBAAkB,EAAE,MAAM,CAAA;CAC3B,SAkEA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"buildParentField.d.ts","sourceRoot":"","sources":["../../src/hierarchy/buildParentField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AAExE,eAAO,MAAM,gBAAgB,GAAI,qEAK9B;IACD,cAAc,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAA;IAC5C,eAAe,EAAE,MAAM,CAAA;CACxB,KAAG,uBA0CH,CAAA"}
1
+ {"version":3,"file":"buildParentField.d.ts","sourceRoot":"","sources":["../../src/hierarchy/buildParentField.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AAExE,eAAO,MAAM,gBAAgB,wEAK1B;IACD,cAAc,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,CAAA;IAC5C,eAAe,EAAE,MAAM,CAAA;CACxB,KAAG,uBA0CH,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/hierarchy/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,yBAAyB,gBAAgB,CAAA;AACtD,eAAO,MAAM,0BAA0B,iBAAiB,CAAA;AACxD,eAAO,MAAM,wBAAwB,OAAO,CAAA;AAE5C,+CAA+C;AAC/C,eAAO,MAAM,4BAA4B,MAAM,CAAA;AAE/C,0DAA0D;AAC1D,eAAO,MAAM,4BAA4B,KAAK,CAAA;AAE9C,6DAA6D;AAC7D,eAAO,MAAM,sBAAsB,OAAO,CAAA;AAE1C,8FAA8F;AAC9F,eAAO,MAAM,qBAAqB,GAAI,eAAe,MAAM,KAAG,MAA+B,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/hierarchy/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,eAAO,MAAM,yBAAyB,gBAAgB,CAAA;AACtD,eAAO,MAAM,0BAA0B,iBAAiB,CAAA;AACxD,eAAO,MAAM,wBAAwB,OAAO,CAAA;AAE5C,+CAA+C;AAC/C,eAAO,MAAM,4BAA4B,MAAM,CAAA;AAE/C,0DAA0D;AAC1D,eAAO,MAAM,4BAA4B,KAAK,CAAA;AAE9C,6DAA6D;AAC7D,eAAO,MAAM,sBAAsB,OAAO,CAAA;AAE1C,8FAA8F;AAC9F,eAAO,MAAM,qBAAqB,kBAAmB,MAAM,KAAG,MAA+B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getInitialTreeData.d.ts","sourceRoot":"","sources":["../../src/hierarchy/getInitialTreeData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EA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Ac,EAAE,MAAM,CAAA;IACtB,eAAe,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IACrC,+FAA+F;IAC/F,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,cAAc,CAAC,SAAS,CAAC,CAAA;IAClC,uGAAuG;IACvG,cAAc,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAA;IACvC,oFAAoF;IACpF,oBAAoB,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAA;IAC7C,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,EAAE,UAAU,EAAE,CAAA;IAElB,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC7F,CAAA;AAED,eAAO,MAAM,kBAAkB,sIAU5B,sBAAsB,KAAG,OAAO,CAAC,eAAe,CA0IlD,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"collectionAfterDelete.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/collectionAfterDelete.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAA;AAE/D,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC3C,CAAA;AAED,eAAO,MAAM,8BAA8B,GACxC,wBAAwB,IAAI,KAAG,yBAgB/B,CAAA"}
1
+ {"version":3,"file":"collectionAfterDelete.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/collectionAfterDelete.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAA;AAE/D,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC3C,CAAA;AAED,eAAO,MAAM,8BAA8B,2BAChB,IAAI,KAAG,yBAgB/B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"collectionAfterRead.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/collectionAfterRead.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAkB,MAAM,gBAAgB,CAAA;AAgC7E,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,4BAA4B,GACtC,4DAA4D,IAAI,KAAG,uBAuDnE,CAAA"}
1
+ {"version":3,"file":"collectionAfterRead.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/collectionAfterRead.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAkB,MAAM,gBAAgB,CAAA;AAgC7E,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,4BAA4B,+DACsB,IAAI,KAAG,uBAuDnE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"collectionBeforeChange.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/collectionBeforeChange.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,0BAA0B,EAI3B,MAAM,gBAAgB,CAAA;AAEvB,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,+BAA+B,GACzC,qBAAqB,IAAI,KAAG,0BAgC5B,CAAA"}
1
+ {"version":3,"file":"collectionBeforeChange.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/collectionBeforeChange.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,0BAA0B,EAI3B,MAAM,gBAAgB,CAAA;AAEvB,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,+BAA+B,wBACpB,IAAI,KAAG,0BAgC5B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"collectionBeforeDelete.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/collectionBeforeDelete.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAA;AAEhE,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,+BAA+B,GACzC,qBAAqB,IAAI,KAAG,0BAe5B,CAAA"}
1
+ {"version":3,"file":"collectionBeforeDelete.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/collectionBeforeDelete.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAA;AAEhE,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,eAAO,MAAM,+BAA+B,wBACpB,IAAI,KAAG,0BAe5B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"collectionBeforeOperation.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/collectionBeforeOperation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAA;CAC3B,CAAA;AA0BD,eAAO,MAAM,kCAAkC,GAAI,KAAK,SAAS,cAAc,EAAE,4FAM9E,IAAI,KAAG,mBAAmB,CAAC,KAAK,CA0DlC,CAAA"}
1
+ {"version":3,"file":"collectionBeforeOperation.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/collectionBeforeOperation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,KAAK,IAAI,GAAG;IACV;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,iBAAiB,EAAE,MAAM,CAAA;IACzB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAA;CAC3B,CAAA;AA0BD,eAAO,MAAM,kCAAkC,GAAI,KAAK,SAAS,cAAc,8FAM5E,IAAI,KAAG,mBAAmB,CAAC,KAAK,CA0DlC,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"ensureSafeCollectionsChange.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/ensureSafeCollectionsChange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,4BAA4B,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIjG,eAAO,MAAM,2BAA2B,GACrC,mEAKE;IACD,eAAe,EAAE,MAAM,CAAA;IACvB,WAAW,EAAE,cAAc,CAAA;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,KAAG,4BAmIH,CAAA"}
1
+ {"version":3,"file":"ensureSafeCollectionsChange.d.ts","sourceRoot":"","sources":["../../../src/hierarchy/hooks/ensureSafeCollectionsChange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,4BAA4B,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAIjG,eAAO,MAAM,2BAA2B,sEAMnC;IACD,eAAe,EAAE,MAAM,CAAA;IACvB,WAAW,EAAE,cAAc,CAAA;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB,KAAG,4BAmIH,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"injectHierarchyButton.d.ts","sourceRoot":"","sources":["../../src/hierarchy/injectHierarchyButton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAEtE;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,sEAKnC;IACD,UAAU,EAAE,gBAAgB,CAAA;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,uBAAuB,EAAE,MAAM,CAAA;IAC/B,eAAe,EAAE,MAAM,CAAA;CACxB,KAAG,IAiCH,CAAA"}
1
+ {"version":3,"file":"injectHierarchyButton.d.ts","sourceRoot":"","sources":["../../src/hierarchy/injectHierarchyButton.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AAEtE;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,yEAK/B;IACD,UAAU,EAAE,gBAAgB,CAAA;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,uBAAuB,EAAE,MAAM,CAAA;IAC/B,eAAe,EAAE,MAAM,CAAA;CACxB,KAAG,IAiCH,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"resolveHierarchyCollections.d.ts","sourceRoot":"","sources":["../../src/hierarchy/resolveHierarchyCollections.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAuBhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,2BAA2B,GAAI,QAAQ,MAAM,KAAG,IAiJ5D,CAAA"}
1
+ {"version":3,"file":"resolveHierarchyCollections.d.ts","sourceRoot":"","sources":["../../src/hierarchy/resolveHierarchyCollections.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAuBhD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,2BAA2B,WAAY,MAAM,KAAG,IAiJ5D,CAAA"}
@@ -211,7 +211,7 @@ import { injectHierarchyButton } from './injectHierarchyButton.js';
211
211
  admin: {
212
212
  components: {
213
213
  Field: {
214
- path: '@payloadcms/next/rsc#HierarchyTypeFieldServer',
214
+ path: '@payloadcms/ui/rsc#HierarchyTypeFieldServer',
215
215
  serverProps: {
216
216
  collectionOptions,
217
217
  parentFieldName
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hierarchy/resolveHierarchyCollections.ts"],"sourcesContent":["import type { CollectionConfig, SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { Config } from '../config/types.js'\nimport type {\n JoinField,\n Option,\n RelationshipField,\n SelectField,\n Validate,\n} from '../fields/config/types.js'\nimport type { Document } from '../types/index.js'\nimport type {\n HierarchyJoinFieldConfig,\n SanitizedHierarchyConfig,\n SanitizedHierarchyRelatedCollection,\n} from './types.js'\n\nimport { sanitizeJoinField } from '../fields/config/sanitizeJoinField.js'\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { extractID } from '../utilities/extractID.js'\nimport { flattenAllFields } from '../utilities/flattenAllFields.js'\nimport { getHierarchyFieldName } from './constants.js'\nimport { hierarchyCollectionAfterDelete } from './hooks/collectionAfterDelete.js'\nimport { injectHierarchyButton } from './injectHierarchyButton.js'\n\n/**\n * Resolves hierarchy relationships across collections.\n *\n * This function runs after individual collection sanitization to establish\n * cross-collection hierarchy relationships. It discovers which collections\n * reference each hierarchy and configures the necessary fields, components,\n * and hooks.\n *\n * @remarks\n * Must be called after all collections are sanitized.\n *\n * **What it does:**\n * - Discovers related collections by scanning for hierarchy relationship fields\n * - Injects `HierarchyButton` component when `custom.hierarchy.injectHeaderButton` is set\n * - Adds `collectionSpecific` validation to ensure hierarchy items accept the document type\n * - Injects the `hierarchyType` select field when `collectionSpecific` is enabled\n * - Injects join field when `joinField` is configured\n * - Adds `afterDelete` hook to clear hierarchy references when items are deleted\n * - Populates `relatedCollections` in the sanitized hierarchy config\n */\nexport const resolveHierarchyCollections = (config: Config): void => {\n const hierarchyCollections =\n config.collections?.filter((col) => col.hierarchy && typeof col.hierarchy === 'object') || []\n\n for (const hierarchyCollection of hierarchyCollections) {\n const hierarchy = hierarchyCollection.hierarchy\n\n // TypeScript guard - hierarchy is guaranteed to be an object by the filter above\n if (!hierarchy || typeof hierarchy !== 'object') {\n continue\n }\n\n const hierarchyConfig = hierarchy as SanitizedHierarchyConfig\n const defaultFieldName = getHierarchyFieldName(hierarchyCollection.slug)\n const parentFieldName = hierarchyConfig.parentFieldName ?? defaultFieldName\n const isParentFieldNameOverridden = parentFieldName !== defaultFieldName\n const collectionSpecific = hierarchyConfig.collectionSpecific\n const typeFieldName = collectionSpecific ? collectionSpecific.fieldName : undefined\n const allowHasMany = hierarchyConfig.allowHasMany ?? true\n\n // Build relatedCollections by scanning all collections for hierarchy fields\n const sanitizedRelatedCollections: Record<string, SanitizedHierarchyRelatedCollection> = {}\n\n const selfParentField = hierarchyCollection.fields.find(\n (field) =>\n fieldAffectsData(field) &&\n field.name === parentFieldName &&\n field.type === 'relationship' &&\n (field as RelationshipField).relationTo === hierarchyCollection.slug,\n ) as RelationshipField | undefined\n\n // Check if the hierarchy collection's own parent field should be replaced with a header button\n if (selfParentField?.custom?.hierarchy?.injectHeaderButton === true) {\n injectHierarchyButton({\n collection: hierarchyCollection,\n fieldName: parentFieldName,\n hierarchyCollectionSlug: hierarchyCollection.slug,\n parentFieldName: hierarchyConfig.parentFieldName,\n })\n }\n\n for (const collection of config.collections || []) {\n // Skip the hierarchy collection itself (handled above)\n if (collection.slug === hierarchyCollection.slug) {\n continue\n }\n\n // Find hierarchy field by the default name (what createFolderField uses)\n const hierarchyField = collection.fields.find(\n (field) =>\n fieldAffectsData(field) &&\n field.name === defaultFieldName &&\n field.type === 'relationship' &&\n (field as RelationshipField).relationTo === hierarchyCollection.slug,\n ) as RelationshipField | undefined\n\n // If parentFieldName is overridden, rename the field to match\n if (hierarchyField && isParentFieldNameOverridden) {\n hierarchyField.name = parentFieldName\n }\n\n if (!hierarchyField) {\n continue\n }\n\n const fieldHasMany = hierarchyField.hasMany ?? allowHasMany\n\n // If collectionSpecific, inject validation to check hierarchy allows this collection type\n if (collectionSpecific) {\n injectCollectionSpecificValidation({\n hierarchyField,\n hierarchySlug: hierarchyCollection.slug,\n typeFieldName: typeFieldName!,\n })\n }\n\n // Store discovered collection with hasMany info\n sanitizedRelatedCollections[collection.slug] = {\n fieldName: parentFieldName,\n hasMany: fieldHasMany,\n }\n\n // Inject HierarchyButton if field requests it\n if (hierarchyField.custom?.hierarchy?.injectHeaderButton === true) {\n injectHierarchyButton({\n collection,\n fieldName: parentFieldName,\n hierarchyCollectionSlug: hierarchyCollection.slug,\n parentFieldName: hierarchyConfig.parentFieldName,\n })\n }\n }\n\n // If collectionSpecific, add type field to hierarchy collection\n if (hierarchyConfig.collectionSpecific) {\n injectTypeField({\n config,\n hierarchyCollection: hierarchyCollection as SanitizedCollectionConfig,\n parentFieldName: hierarchyConfig.parentFieldName,\n sanitizedRelatedCollections,\n typeFieldName: hierarchyConfig.collectionSpecific.fieldName,\n })\n }\n\n // If joinField is configured, add the join field to query children\n if (hierarchyConfig.joinField) {\n injectJoinField({\n config,\n hierarchyCollection: hierarchyCollection as SanitizedCollectionConfig,\n joinFieldConfig: hierarchyConfig.joinField,\n parentFieldName,\n relatedSlugs: Object.keys(sanitizedRelatedCollections),\n })\n }\n\n // Update hierarchy config with sanitized relatedCollections\n if (hierarchyConfig) {\n hierarchyConfig.relatedCollections = sanitizedRelatedCollections\n }\n\n // Add afterDelete hook to clear folder references from related documents\n if (Object.keys(sanitizedRelatedCollections).length > 0) {\n injectAfterDeleteHook({\n hierarchyCollection: hierarchyCollection as SanitizedCollectionConfig,\n sanitizedRelatedCollections,\n })\n }\n\n // Add sidebar tab for this hierarchy collection (unless explicitly disabled)\n if (hierarchyConfig.admin.injectSidebarTab !== false) {\n injectSidebarTab({\n config,\n hierarchyCollection,\n hierarchyConfig,\n })\n\n // Hide from nav when sidebar tab is injected (unless user explicitly set group)\n if (hierarchyCollection.admin?.group === undefined) {\n hierarchyCollection.admin = {\n ...hierarchyCollection.admin,\n group: false,\n }\n }\n }\n }\n}\n\n/**\n * Injects validation for collectionSpecific hierarchy fields.\n * Ensures the selected hierarchy item allows documents of this collection type.\n */\nfunction injectCollectionSpecificValidation({\n hierarchyField,\n hierarchySlug,\n typeFieldName,\n}: {\n hierarchyField: RelationshipField\n hierarchySlug: string\n typeFieldName: string\n}): void {\n const existingValidate = hierarchyField.validate\n\n const validate: Validate<unknown> = async (value, options) => {\n // Run existing validation first if present\n if (existingValidate) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const existingResult = await existingValidate(value as any, options as any)\n if (existingResult !== true) {\n return existingResult\n }\n }\n\n // No hierarchy selected, no validation needed\n if (!value) {\n return true\n }\n\n const { collectionSlug, overrideAccess, previousValue, req } = options\n const newID = extractID<Document>(value)\n\n // Value didn't change, no validation needed\n if (previousValue && extractID<Document>(previousValue) === newID) {\n return true\n }\n\n // Fetch the hierarchy item to check its type field\n let parentItem: Document | null = null\n if (typeof newID === 'string' || typeof newID === 'number') {\n try {\n parentItem = await req.payload.findByID({\n id: newID,\n collection: hierarchySlug,\n depth: 0,\n overrideAccess: overrideAccess ?? false,\n req,\n select: { [typeFieldName]: true },\n })\n } catch {\n return `Hierarchy item with ID ${newID} not found`\n }\n }\n\n if (!parentItem) {\n return `Hierarchy item with ID ${newID} not found`\n }\n\n const allowedTypes: string[] = (parentItem[typeFieldName] as string[]) || []\n\n // If hierarchy has no types, it accepts all collections\n if (allowedTypes.length === 0) {\n return true\n }\n\n // Check if this collection is allowed\n if (collectionSlug && allowedTypes.includes(collectionSlug)) {\n return true\n }\n\n return `Hierarchy item \"${newID}\" does not allow documents of type \"${collectionSlug}\"`\n }\n\n hierarchyField.validate = validate\n}\n\n/**\n * Injects the hierarchyType select field into a hierarchy collection.\n */\nfunction injectTypeField({\n config,\n hierarchyCollection,\n parentFieldName,\n sanitizedRelatedCollections,\n typeFieldName,\n}: {\n config: Config\n hierarchyCollection: CollectionConfig | SanitizedCollectionConfig\n parentFieldName: string\n sanitizedRelatedCollections: Record<string, SanitizedHierarchyRelatedCollection>\n typeFieldName: string\n}): void {\n const collectionOptions: Option[] = Object.keys(sanitizedRelatedCollections).map((slug) => {\n const relatedCollection = config.collections?.find((c) => c.slug === slug)\n return {\n label: relatedCollection?.labels?.plural || slug,\n value: slug,\n }\n })\n\n const typeField: SelectField = {\n name: typeFieldName,\n type: 'select',\n admin: {\n components: {\n Field: {\n path: '@payloadcms/next/rsc#HierarchyTypeFieldServer',\n serverProps: {\n collectionOptions,\n parentFieldName,\n },\n },\n },\n position: 'sidebar',\n },\n hasMany: true,\n options: collectionOptions,\n }\n\n hierarchyCollection.fields = hierarchyCollection.fields || []\n hierarchyCollection.fields.push(typeField)\n\n // Recompute flattenedFields since we added a field after initial sanitization\n // This is required for the field to be queryable\n if ('flattenedFields' in hierarchyCollection) {\n hierarchyCollection.flattenedFields = flattenAllFields({\n fields: hierarchyCollection.fields,\n })\n }\n}\n\n/**\n * Injects a join field to query all children of a hierarchy item.\n */\nfunction injectJoinField({\n config,\n hierarchyCollection,\n joinFieldConfig,\n parentFieldName,\n relatedSlugs,\n}: {\n config: Config\n hierarchyCollection: SanitizedCollectionConfig\n joinFieldConfig: HierarchyJoinFieldConfig\n parentFieldName: string\n relatedSlugs: string[]\n}): void {\n const { name, admin: userAdmin, ...userConfig } = joinFieldConfig\n\n const hasJoinField = hierarchyCollection.fields?.some(\n (field) => 'name' in field && field.name === name,\n )\n\n if (hasJoinField) {\n return\n }\n\n const joinField: JoinField = {\n // User config (spread first so auto-generated values take precedence for required fields)\n ...userConfig,\n // Auto-generated values (these cannot be overridden)\n name,\n type: 'join',\n collection: [hierarchyCollection.slug, ...relatedSlugs],\n hasMany: true,\n on: parentFieldName,\n // Merge admin config\n admin: {\n ...userAdmin,\n },\n }\n\n hierarchyCollection.fields = hierarchyCollection.fields || []\n hierarchyCollection.fields.push(joinField)\n\n // Sanitize the join field to register it properly\n sanitizeJoinField({\n config,\n field: joinField,\n joins: hierarchyCollection.joins,\n parentIsLocalized: false,\n polymorphicJoins: hierarchyCollection.polymorphicJoins,\n })\n\n // Recompute flattenedFields since we added a field after initial sanitization\n hierarchyCollection.flattenedFields = flattenAllFields({\n fields: hierarchyCollection.fields,\n })\n}\n\n/**\n * Injects afterDelete hook to clear hierarchy references from related documents.\n */\nfunction injectAfterDeleteHook({\n hierarchyCollection,\n sanitizedRelatedCollections,\n}: {\n hierarchyCollection: CollectionConfig | SanitizedCollectionConfig\n sanitizedRelatedCollections: Record<string, SanitizedHierarchyRelatedCollection>\n}): void {\n // Build map of collection slugs to their field names\n const relatedCollectionFieldMap: Record<string, string> = {}\n for (const [slug, relatedConfig] of Object.entries(sanitizedRelatedCollections)) {\n relatedCollectionFieldMap[slug] = relatedConfig.fieldName\n }\n\n hierarchyCollection.hooks = hierarchyCollection.hooks || {}\n hierarchyCollection.hooks.afterDelete = [\n ...(hierarchyCollection.hooks.afterDelete || []),\n hierarchyCollectionAfterDelete({ relatedCollections: relatedCollectionFieldMap }),\n ]\n}\n\n/**\n * Injects a sidebar tab for a hierarchy collection.\n */\nfunction injectSidebarTab({\n config,\n hierarchyCollection,\n hierarchyConfig,\n}: {\n config: Config\n hierarchyCollection: CollectionConfig\n hierarchyConfig: SanitizedHierarchyConfig\n}): void {\n const tabSlug = `hierarchy-${hierarchyCollection.slug}`\n const Icon = hierarchyConfig.admin.components.Icon\n\n // Initialize admin config structure\n config.admin = config.admin || {}\n config.admin.components = config.admin.components || {}\n config.admin.components.sidebar = config.admin.components.sidebar || {}\n config.admin.components.sidebar.tabs = config.admin.components.sidebar.tabs || []\n\n // Check if tab already exists\n const hasTab = config.admin.components.sidebar.tabs.some((tab) => tab.slug === tabSlug)\n\n if (!hasTab) {\n config.admin.components.sidebar.tabs.push({\n slug: tabSlug,\n components: {\n Content: {\n clientProps: {\n hierarchyCollectionSlug: hierarchyCollection.slug,\n },\n path: '@payloadcms/ui/rsc#HierarchySidebarTabServer',\n },\n Icon,\n },\n label: hierarchyCollection.labels?.plural || hierarchyCollection.slug,\n })\n }\n}\n"],"names":["sanitizeJoinField","fieldAffectsData","extractID","flattenAllFields","getHierarchyFieldName","hierarchyCollectionAfterDelete","injectHierarchyButton","resolveHierarchyCollections","config","hierarchyCollections","collections","filter","col","hierarchy","hierarchyCollection","hierarchyConfig","defaultFieldName","slug","parentFieldName","isParentFieldNameOverridden","collectionSpecific","typeFieldName","fieldName","undefined","allowHasMany","sanitizedRelatedCollections","selfParentField","fields","find","field","name","type","relationTo","custom","injectHeaderButton","collection","hierarchyCollectionSlug","hierarchyField","fieldHasMany","hasMany","injectCollectionSpecificValidation","hierarchySlug","injectTypeField","joinField","injectJoinField","joinFieldConfig","relatedSlugs","Object","keys","relatedCollections","length","injectAfterDeleteHook","admin","injectSidebarTab","group","existingValidate","validate","value","options","existingResult","collectionSlug","overrideAccess","previousValue","req","newID","parentItem","payload","findByID","id","depth","select","allowedTypes","includes","collectionOptions","map","relatedCollection","c","label","labels","plural","typeField","components","Field","path","serverProps","position","push","flattenedFields","userAdmin","userConfig","hasJoinField","some","on","joins","parentIsLocalized","polymorphicJoins","relatedCollectionFieldMap","relatedConfig","entries","hooks","afterDelete","tabSlug","Icon","sidebar","tabs","hasTab","tab","Content","clientProps"],"mappings":"AAgBA,SAASA,iBAAiB,QAAQ,wCAAuC;AACzE,SAASC,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,SAAS,QAAQ,4BAA2B;AACrD,SAASC,gBAAgB,QAAQ,mCAAkC;AACnE,SAASC,qBAAqB,QAAQ,iBAAgB;AACtD,SAASC,8BAA8B,QAAQ,mCAAkC;AACjF,SAASC,qBAAqB,QAAQ,6BAA4B;AAElE;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,MAAMC,8BAA8B,CAACC;IAC1C,MAAMC,uBACJD,OAAOE,WAAW,EAAEC,OAAO,CAACC,MAAQA,IAAIC,SAAS,IAAI,OAAOD,IAAIC,SAAS,KAAK,aAAa,EAAE;IAE/F,KAAK,MAAMC,uBAAuBL,qBAAsB;QACtD,MAAMI,YAAYC,oBAAoBD,SAAS;QAE/C,iFAAiF;QACjF,IAAI,CAACA,aAAa,OAAOA,cAAc,UAAU;YAC/C;QACF;QAEA,MAAME,kBAAkBF;QACxB,MAAMG,mBAAmBZ,sBAAsBU,oBAAoBG,IAAI;QACvE,MAAMC,kBAAkBH,gBAAgBG,eAAe,IAAIF;QAC3D,MAAMG,8BAA8BD,oBAAoBF;QACxD,MAAMI,qBAAqBL,gBAAgBK,kBAAkB;QAC7D,MAAMC,gBAAgBD,qBAAqBA,mBAAmBE,SAAS,GAAGC;QAC1E,MAAMC,eAAeT,gBAAgBS,YAAY,IAAI;QAErD,4EAA4E;QAC5E,MAAMC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ACsB,OAAO,GAAG/F,OAAO4C,KAAK,CAAC6B,UAAU,CAACsB,OAAO,IAAI,CAAC;IACtE/F,OAAO4C,KAAK,CAAC6B,UAAU,CAACsB,OAAO,CAACC,IAAI,GAAGhG,OAAO4C,KAAK,CAAC6B,UAAU,CAACsB,OAAO,CAACC,IAAI,IAAI,EAAE;IAEjF,8BAA8B;IAC9B,MAAMC,SAASjG,OAAO4C,KAAK,CAAC6B,UAAU,CAACsB,OAAO,CAACC,IAAI,CAACb,IAAI,CAAC,CAACe,MAAQA,IAAIzF,IAAI,KAAKoF;IAE/E,IAAI,CAACI,QAAQ;QACXjG,OAAO4C,KAAK,CAAC6B,UAAU,CAACsB,OAAO,CAACC,IAAI,CAAClB,IAAI,CAAC;YACxCrE,MAAMoF;YACNpB,YAAY;gBACV0B,SAAS;oBACPC,aAAa;wBACXxE,yBAAyBtB,oBAAoBG,IAAI;oBACnD;oBACAkE,MAAM;gBACR;gBACAmB;YACF;YACAzB,OAAO/D,oBAAoBgE,MAAM,EAAEC,UAAUjE,oBAAoBG,IAAI;QACvE;IACF;AACF"}
1
+ {"version":3,"sources":["../../src/hierarchy/resolveHierarchyCollections.ts"],"sourcesContent":["import type { CollectionConfig, SanitizedCollectionConfig } from '../collections/config/types.js'\nimport type { Config } from '../config/types.js'\nimport type {\n JoinField,\n Option,\n RelationshipField,\n SelectField,\n Validate,\n} from '../fields/config/types.js'\nimport type { Document } from '../types/index.js'\nimport type {\n HierarchyJoinFieldConfig,\n SanitizedHierarchyConfig,\n SanitizedHierarchyRelatedCollection,\n} from './types.js'\n\nimport { sanitizeJoinField } from '../fields/config/sanitizeJoinField.js'\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { extractID } from '../utilities/extractID.js'\nimport { flattenAllFields } from '../utilities/flattenAllFields.js'\nimport { getHierarchyFieldName } from './constants.js'\nimport { hierarchyCollectionAfterDelete } from './hooks/collectionAfterDelete.js'\nimport { injectHierarchyButton } from './injectHierarchyButton.js'\n\n/**\n * Resolves hierarchy relationships across collections.\n *\n * This function runs after individual collection sanitization to establish\n * cross-collection hierarchy relationships. It discovers which collections\n * reference each hierarchy and configures the necessary fields, components,\n * and hooks.\n *\n * @remarks\n * Must be called after all collections are sanitized.\n *\n * **What it does:**\n * - Discovers related collections by scanning for hierarchy relationship fields\n * - Injects `HierarchyButton` component when `custom.hierarchy.injectHeaderButton` is set\n * - Adds `collectionSpecific` validation to ensure hierarchy items accept the document type\n * - Injects the `hierarchyType` select field when `collectionSpecific` is enabled\n * - Injects join field when `joinField` is configured\n * - Adds `afterDelete` hook to clear hierarchy references when items are deleted\n * - Populates `relatedCollections` in the sanitized hierarchy config\n */\nexport const resolveHierarchyCollections = (config: Config): void => {\n const hierarchyCollections =\n config.collections?.filter((col) => col.hierarchy && typeof col.hierarchy === 'object') || []\n\n for (const hierarchyCollection of hierarchyCollections) {\n const hierarchy = hierarchyCollection.hierarchy\n\n // TypeScript guard - hierarchy is guaranteed to be an object by the filter above\n if (!hierarchy || typeof hierarchy !== 'object') {\n continue\n }\n\n const hierarchyConfig = hierarchy as SanitizedHierarchyConfig\n const defaultFieldName = getHierarchyFieldName(hierarchyCollection.slug)\n const parentFieldName = hierarchyConfig.parentFieldName ?? defaultFieldName\n const isParentFieldNameOverridden = parentFieldName !== defaultFieldName\n const collectionSpecific = hierarchyConfig.collectionSpecific\n const typeFieldName = collectionSpecific ? collectionSpecific.fieldName : undefined\n const allowHasMany = hierarchyConfig.allowHasMany ?? true\n\n // Build relatedCollections by scanning all collections for hierarchy fields\n const sanitizedRelatedCollections: Record<string, SanitizedHierarchyRelatedCollection> = {}\n\n const selfParentField = hierarchyCollection.fields.find(\n (field) =>\n fieldAffectsData(field) &&\n field.name === parentFieldName &&\n field.type === 'relationship' &&\n (field as RelationshipField).relationTo === hierarchyCollection.slug,\n ) as RelationshipField | undefined\n\n // Check if the hierarchy collection's own parent field should be replaced with a header button\n if (selfParentField?.custom?.hierarchy?.injectHeaderButton === true) {\n injectHierarchyButton({\n collection: hierarchyCollection,\n fieldName: parentFieldName,\n hierarchyCollectionSlug: hierarchyCollection.slug,\n parentFieldName: hierarchyConfig.parentFieldName,\n })\n }\n\n for (const collection of config.collections || []) {\n // Skip the hierarchy collection itself (handled above)\n if (collection.slug === hierarchyCollection.slug) {\n continue\n }\n\n // Find hierarchy field by the default name (what createFolderField uses)\n const hierarchyField = collection.fields.find(\n (field) =>\n fieldAffectsData(field) &&\n field.name === defaultFieldName &&\n field.type === 'relationship' &&\n (field as RelationshipField).relationTo === hierarchyCollection.slug,\n ) as RelationshipField | undefined\n\n // If parentFieldName is overridden, rename the field to match\n if (hierarchyField && isParentFieldNameOverridden) {\n hierarchyField.name = parentFieldName\n }\n\n if (!hierarchyField) {\n continue\n }\n\n const fieldHasMany = hierarchyField.hasMany ?? allowHasMany\n\n // If collectionSpecific, inject validation to check hierarchy allows this collection type\n if (collectionSpecific) {\n injectCollectionSpecificValidation({\n hierarchyField,\n hierarchySlug: hierarchyCollection.slug,\n typeFieldName: typeFieldName!,\n })\n }\n\n // Store discovered collection with hasMany info\n sanitizedRelatedCollections[collection.slug] = {\n fieldName: parentFieldName,\n hasMany: fieldHasMany,\n }\n\n // Inject HierarchyButton if field requests it\n if (hierarchyField.custom?.hierarchy?.injectHeaderButton === true) {\n injectHierarchyButton({\n collection,\n fieldName: parentFieldName,\n hierarchyCollectionSlug: hierarchyCollection.slug,\n parentFieldName: hierarchyConfig.parentFieldName,\n })\n }\n }\n\n // If collectionSpecific, add type field to hierarchy collection\n if (hierarchyConfig.collectionSpecific) {\n injectTypeField({\n config,\n hierarchyCollection: hierarchyCollection as SanitizedCollectionConfig,\n parentFieldName: hierarchyConfig.parentFieldName,\n sanitizedRelatedCollections,\n typeFieldName: hierarchyConfig.collectionSpecific.fieldName,\n })\n }\n\n // If joinField is configured, add the join field to query children\n if (hierarchyConfig.joinField) {\n injectJoinField({\n config,\n hierarchyCollection: hierarchyCollection as SanitizedCollectionConfig,\n joinFieldConfig: hierarchyConfig.joinField,\n parentFieldName,\n relatedSlugs: Object.keys(sanitizedRelatedCollections),\n })\n }\n\n // Update hierarchy config with sanitized relatedCollections\n if (hierarchyConfig) {\n hierarchyConfig.relatedCollections = sanitizedRelatedCollections\n }\n\n // Add afterDelete hook to clear folder references from related documents\n if (Object.keys(sanitizedRelatedCollections).length > 0) {\n injectAfterDeleteHook({\n hierarchyCollection: hierarchyCollection as SanitizedCollectionConfig,\n sanitizedRelatedCollections,\n })\n }\n\n // Add sidebar tab for this hierarchy collection (unless explicitly disabled)\n if (hierarchyConfig.admin.injectSidebarTab !== false) {\n injectSidebarTab({\n config,\n hierarchyCollection,\n hierarchyConfig,\n })\n\n // Hide from nav when sidebar tab is injected (unless user explicitly set group)\n if (hierarchyCollection.admin?.group === undefined) {\n hierarchyCollection.admin = {\n ...hierarchyCollection.admin,\n group: false,\n }\n }\n }\n }\n}\n\n/**\n * Injects validation for collectionSpecific hierarchy fields.\n * Ensures the selected hierarchy item allows documents of this collection type.\n */\nfunction injectCollectionSpecificValidation({\n hierarchyField,\n hierarchySlug,\n typeFieldName,\n}: {\n hierarchyField: RelationshipField\n hierarchySlug: string\n typeFieldName: string\n}): void {\n const existingValidate = hierarchyField.validate\n\n const validate: Validate<unknown> = async (value, options) => {\n // Run existing validation first if present\n if (existingValidate) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const existingResult = await existingValidate(value as any, options as any)\n if (existingResult !== true) {\n return existingResult\n }\n }\n\n // No hierarchy selected, no validation needed\n if (!value) {\n return true\n }\n\n const { collectionSlug, overrideAccess, previousValue, req } = options\n const newID = extractID<Document>(value)\n\n // Value didn't change, no validation needed\n if (previousValue && extractID<Document>(previousValue) === newID) {\n return true\n }\n\n // Fetch the hierarchy item to check its type field\n let parentItem: Document | null = null\n if (typeof newID === 'string' || typeof newID === 'number') {\n try {\n parentItem = await req.payload.findByID({\n id: newID,\n collection: hierarchySlug,\n depth: 0,\n overrideAccess: overrideAccess ?? false,\n req,\n select: { [typeFieldName]: true },\n })\n } catch {\n return `Hierarchy item with ID ${newID} not found`\n }\n }\n\n if (!parentItem) {\n return `Hierarchy item with ID ${newID} not found`\n }\n\n const allowedTypes: string[] = (parentItem[typeFieldName] as string[]) || []\n\n // If hierarchy has no types, it accepts all collections\n if (allowedTypes.length === 0) {\n return true\n }\n\n // Check if this collection is allowed\n if (collectionSlug && allowedTypes.includes(collectionSlug)) {\n return true\n }\n\n return `Hierarchy item \"${newID}\" does not allow documents of type \"${collectionSlug}\"`\n }\n\n hierarchyField.validate = validate\n}\n\n/**\n * Injects the hierarchyType select field into a hierarchy collection.\n */\nfunction injectTypeField({\n config,\n hierarchyCollection,\n parentFieldName,\n sanitizedRelatedCollections,\n typeFieldName,\n}: {\n config: Config\n hierarchyCollection: CollectionConfig | SanitizedCollectionConfig\n parentFieldName: string\n sanitizedRelatedCollections: Record<string, SanitizedHierarchyRelatedCollection>\n typeFieldName: string\n}): void {\n const collectionOptions: Option[] = Object.keys(sanitizedRelatedCollections).map((slug) => {\n const relatedCollection = config.collections?.find((c) => c.slug === slug)\n return {\n label: relatedCollection?.labels?.plural || slug,\n value: slug,\n }\n })\n\n const typeField: SelectField = {\n name: typeFieldName,\n type: 'select',\n admin: {\n components: {\n Field: {\n path: '@payloadcms/ui/rsc#HierarchyTypeFieldServer',\n serverProps: {\n collectionOptions,\n parentFieldName,\n },\n },\n },\n position: 'sidebar',\n },\n hasMany: true,\n options: collectionOptions,\n }\n\n hierarchyCollection.fields = hierarchyCollection.fields || []\n hierarchyCollection.fields.push(typeField)\n\n // Recompute flattenedFields since we added a field after initial sanitization\n // This is required for the field to be queryable\n if ('flattenedFields' in hierarchyCollection) {\n hierarchyCollection.flattenedFields = flattenAllFields({\n fields: hierarchyCollection.fields,\n })\n }\n}\n\n/**\n * Injects a join field to query all children of a hierarchy item.\n */\nfunction injectJoinField({\n config,\n hierarchyCollection,\n joinFieldConfig,\n parentFieldName,\n relatedSlugs,\n}: {\n config: Config\n hierarchyCollection: SanitizedCollectionConfig\n joinFieldConfig: HierarchyJoinFieldConfig\n parentFieldName: string\n relatedSlugs: string[]\n}): void {\n const { name, admin: userAdmin, ...userConfig } = joinFieldConfig\n\n const hasJoinField = hierarchyCollection.fields?.some(\n (field) => 'name' in field && field.name === name,\n )\n\n if (hasJoinField) {\n return\n }\n\n const joinField: JoinField = {\n // User config (spread first so auto-generated values take precedence for required fields)\n ...userConfig,\n // Auto-generated values (these cannot be overridden)\n name,\n type: 'join',\n collection: [hierarchyCollection.slug, ...relatedSlugs],\n hasMany: true,\n on: parentFieldName,\n // Merge admin config\n admin: {\n ...userAdmin,\n },\n }\n\n hierarchyCollection.fields = hierarchyCollection.fields || []\n hierarchyCollection.fields.push(joinField)\n\n // Sanitize the join field to register it properly\n sanitizeJoinField({\n config,\n field: joinField,\n joins: hierarchyCollection.joins,\n parentIsLocalized: false,\n polymorphicJoins: hierarchyCollection.polymorphicJoins,\n })\n\n // Recompute flattenedFields since we added a field after initial sanitization\n hierarchyCollection.flattenedFields = flattenAllFields({\n fields: hierarchyCollection.fields,\n })\n}\n\n/**\n * Injects afterDelete hook to clear hierarchy references from related documents.\n */\nfunction injectAfterDeleteHook({\n hierarchyCollection,\n sanitizedRelatedCollections,\n}: {\n hierarchyCollection: CollectionConfig | SanitizedCollectionConfig\n sanitizedRelatedCollections: Record<string, SanitizedHierarchyRelatedCollection>\n}): void {\n // Build map of collection slugs to their field names\n const relatedCollectionFieldMap: Record<string, string> = {}\n for (const [slug, relatedConfig] of Object.entries(sanitizedRelatedCollections)) {\n relatedCollectionFieldMap[slug] = relatedConfig.fieldName\n }\n\n hierarchyCollection.hooks = hierarchyCollection.hooks || {}\n hierarchyCollection.hooks.afterDelete = [\n ...(hierarchyCollection.hooks.afterDelete || []),\n hierarchyCollectionAfterDelete({ relatedCollections: relatedCollectionFieldMap }),\n ]\n}\n\n/**\n * Injects a sidebar tab for a hierarchy collection.\n */\nfunction injectSidebarTab({\n config,\n hierarchyCollection,\n hierarchyConfig,\n}: {\n config: Config\n hierarchyCollection: CollectionConfig\n hierarchyConfig: SanitizedHierarchyConfig\n}): void {\n const tabSlug = `hierarchy-${hierarchyCollection.slug}`\n const Icon = hierarchyConfig.admin.components.Icon\n\n // Initialize admin config structure\n config.admin = config.admin || {}\n config.admin.components = config.admin.components || {}\n config.admin.components.sidebar = config.admin.components.sidebar || {}\n config.admin.components.sidebar.tabs = config.admin.components.sidebar.tabs || []\n\n // Check if tab already exists\n const hasTab = config.admin.components.sidebar.tabs.some((tab) => tab.slug === tabSlug)\n\n if (!hasTab) {\n config.admin.components.sidebar.tabs.push({\n slug: tabSlug,\n components: {\n Content: {\n clientProps: {\n hierarchyCollectionSlug: hierarchyCollection.slug,\n },\n path: '@payloadcms/ui/rsc#HierarchySidebarTabServer',\n },\n Icon,\n },\n label: hierarchyCollection.labels?.plural || hierarchyCollection.slug,\n })\n }\n}\n"],"names":["sanitizeJoinField","fieldAffectsData","extractID","flattenAllFields","getHierarchyFieldName","hierarchyCollectionAfterDelete","injectHierarchyButton","resolveHierarchyCollections","config","hierarchyCollections","collections","filter","col","hierarchy","hierarchyCollection","hierarchyConfig","defaultFieldName","slug","parentFieldName","isParentFieldNameOverridden","collectionSpecific","typeFieldName","fieldName","undefined","allowHasMany","sanitizedRelatedCollections","selfParentField","fields","find","field","name","type","relationTo","custom","injectHeaderButton","collection","hierarchyCollectionSlug","hierarchyField","fieldHasMany","hasMany","injectCollectionSpecificValidation","hierarchySlug","injectTypeField","joinField","injectJoinField","joinFieldConfig","relatedSlugs","Object","keys","relatedCollections","length","injectAfterDeleteHook","admin","injectSidebarTab","group","existingValidate","validate","value","options","existingResult","collectionSlug","overrideAccess","previousValue","req","newID","parentItem","payload","findByID","id","depth","select","allowedTypes","includes","collectionOptions","map","relatedCollection","c","label","labels","plural","typeField","components","Field","path","serverProps","position","push","flattenedFields","userAdmin","userConfig","hasJoinField","some","on","joins","parentIsLocalized","polymorphicJoins","relatedCollectionFieldMap","relatedConfig","entries","hooks","afterDelete","tab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sB,OAAO,CAACC,IAAI,CAACb,IAAI,CAAC,CAACe,MAAQA,IAAIzF,IAAI,KAAKoF;IAE/E,IAAI,CAACI,QAAQ;QACXjG,OAAO4C,KAAK,CAAC6B,UAAU,CAACsB,OAAO,CAACC,IAAI,CAAClB,IAAI,CAAC;YACxCrE,MAAMoF;YACNpB,YAAY;gBACV0B,SAAS;oBACPC,aAAa;wBACXxE,yBAAyBtB,oBAAoBG,IAAI;oBACnD;oBACAkE,MAAM;gBACR;gBACAmB;YACF;YACAzB,OAAO/D,oBAAoBgE,MAAM,EAAEC,UAAUjE,oBAAoBG,IAAI;QACvE;IACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"sanitizeHierarchyCollection.d.ts","sourceRoot":"","sources":["../../src/hierarchy/sanitizeHierarchyCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAgBhD;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,GACtC,kBAAkB,gBAAgB,EAClC,SAAS,MAAM,KACd,IAkIF,CAAA"}
1
+ {"version":3,"file":"sanitizeHierarchyCollection.d.ts","sourceRoot":"","sources":["../../src/hierarchy/sanitizeHierarchyCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAgBhD;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,qBACpB,gBAAgB,WACzB,MAAM,KACd,IAoIF,CAAA"}
@@ -64,6 +64,7 @@ import { ensureSafeCollectionsChange } from './hooks/ensureSafeCollectionsChange
64
64
  const slugify = collectionConfig.hierarchy.slugify ?? ((text)=>defaultSlugify(text) ?? '');
65
65
  const treeLimit = collectionConfig.hierarchy.admin?.treeLimit ?? DEFAULT_HIERARCHY_TREE_LIMIT;
66
66
  const iconComponent = collectionConfig.hierarchy.admin?.components?.Icon;
67
+ const smallIconComponent = collectionConfig.hierarchy.admin?.components?.SmallIcon;
67
68
  const slugField = collectionConfig.hierarchy.slugField;
68
69
  // Apply hierarchy to collection (adds fields and hooks)
69
70
  addHierarchyToCollection({
@@ -96,7 +97,8 @@ import { ensureSafeCollectionsChange } from './hooks/ensureSafeCollectionsChange
96
97
  collectionConfig.hierarchy = {
97
98
  admin: {
98
99
  components: {
99
- Icon: iconComponent || '@payloadcms/ui#TagIcon'
100
+ Icon: iconComponent || '@payloadcms/ui#TagIcon',
101
+ SmallIcon: smallIconComponent || iconComponent || '@payloadcms/ui#TagIcon'
100
102
  },
101
103
  injectSidebarTab,
102
104
  treeLimit,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hierarchy/sanitizeHierarchyCollection.ts"],"sourcesContent":["import type { CollectionConfig } from '../collections/config/types.js'\nimport type { Config } from '../config/types.js'\nimport type { SanitizedHierarchyConfig } from './types.js'\n\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { slugify as defaultSlugify } from '../utilities/slugify.js'\nimport { addHierarchyToCollection } from './addHierarchyToCollection.js'\nimport { buildParentField } from './buildParentField.js'\nimport {\n DEFAULT_ALLOW_HAS_MANY,\n DEFAULT_HIERARCHY_TREE_LIMIT,\n getHierarchyFieldName,\n HIERARCHY_SLUG_PATH_FIELD,\n HIERARCHY_TITLE_PATH_FIELD,\n} from './constants.js'\nimport { ensureSafeCollectionsChange } from './hooks/ensureSafeCollectionsChange.js'\n\n/**\n * Sanitizes hierarchy configuration for a single collection.\n *\n * This is phase 1 of hierarchy setup, called during individual collection sanitization.\n * It normalizes the hierarchy config, creates the parent field if needed, adds hooks,\n * and sets up the sanitized config structure.\n *\n * Phase 2 (`resolveHierarchyCollections`) runs after all collections are sanitized\n * to establish cross-collection relationships.\n */\nexport const sanitizeHierarchyCollection = (\n collectionConfig: CollectionConfig,\n _config: Config,\n): void => {\n if (!collectionConfig.hierarchy) {\n collectionConfig.hierarchy = false\n return\n }\n\n // Normalize boolean to object and apply parentFieldName default\n const defaultParentFieldName = getHierarchyFieldName(collectionConfig.slug)\n\n if (collectionConfig.hierarchy === true) {\n collectionConfig.hierarchy = {\n parentFieldName: defaultParentFieldName,\n }\n }\n\n const parentFieldName = collectionConfig.hierarchy.parentFieldName ?? defaultParentFieldName\n\n // Check if parent field already exists\n const existingParentField = collectionConfig.fields.find(\n (field) => fieldAffectsData(field) && field.name === parentFieldName,\n )\n\n if (existingParentField) {\n // Validate existing parent field configuration\n if (existingParentField.type !== 'relationship') {\n throw new Error(\n `Hierarchy parent field \"${parentFieldName}\" in collection \"${collectionConfig.slug}\" must be a relationship field`,\n )\n }\n\n if (existingParentField.hasMany !== false) {\n throw new Error(\n `Hierarchy parent field \"${parentFieldName}\" in collection \"${collectionConfig.slug}\" must have hasMany set to false`,\n )\n }\n\n if (existingParentField.localized === true) {\n throw new Error(\n `Hierarchy parent field \"${parentFieldName}\" in collection \"${collectionConfig.slug}\" cannot be localized. The parent relationship must be consistent across all locales.`,\n )\n }\n } else {\n // Auto-create parent field if it doesn't exist\n // useHeaderButton defaults to true - parent selection via header button with miller columns\n const useHeaderButton = collectionConfig.hierarchy.admin?.useHeaderButton ?? true\n\n const parentField = buildParentField({\n collectionSlug: collectionConfig.slug,\n injectHeaderButton: useHeaderButton,\n parentFieldName,\n })\n\n collectionConfig.fields.unshift(parentField)\n }\n\n // Apply defaults for optional fields\n const slugPathFieldName =\n collectionConfig.hierarchy.slugPathFieldName || HIERARCHY_SLUG_PATH_FIELD\n const titlePathFieldName =\n collectionConfig.hierarchy.titlePathFieldName || HIERARCHY_TITLE_PATH_FIELD\n const allowHasMany = collectionConfig.hierarchy.allowHasMany ?? DEFAULT_ALLOW_HAS_MANY\n const rawCollectionSpecific = collectionConfig.hierarchy.collectionSpecific\n const collectionSpecific: { fieldName: string } | false =\n rawCollectionSpecific === true\n ? { fieldName: 'hierarchyType' }\n : rawCollectionSpecific\n ? { fieldName: rawCollectionSpecific.fieldName ?? 'hierarchyType' }\n : false\n const joinField = collectionConfig.hierarchy.joinField\n ? collectionConfig.hierarchy.joinField\n : undefined\n const slugify =\n collectionConfig.hierarchy.slugify ?? ((text: string) => defaultSlugify(text) ?? '')\n const treeLimit = collectionConfig.hierarchy.admin?.treeLimit ?? DEFAULT_HIERARCHY_TREE_LIMIT\n const iconComponent = collectionConfig.hierarchy.admin?.components?.Icon\n\n const slugField = collectionConfig.hierarchy.slugField\n\n // Apply hierarchy to collection (adds fields and hooks)\n addHierarchyToCollection({\n collectionConfig,\n parentFieldName: collectionConfig.hierarchy.parentFieldName,\n slugFieldName: slugField,\n slugPathFieldName,\n titlePathFieldName,\n })\n\n // If collectionSpecific, add beforeValidate hook to enforce scope inheritance\n // (hierarchyType field is added in resolveHierarchyCollections after discovery)\n if (collectionSpecific) {\n // Use parentFieldName for both - backward compatible configs use the same field name everywhere\n if (!collectionConfig.hooks) {\n collectionConfig.hooks = {}\n }\n if (!collectionConfig.hooks.beforeValidate) {\n collectionConfig.hooks.beforeValidate = []\n }\n collectionConfig.hooks.beforeValidate.push(\n ensureSafeCollectionsChange({\n folderFieldName: parentFieldName,\n foldersSlug: collectionConfig.slug,\n parentFieldName,\n typeFieldName: collectionSpecific.fieldName,\n }),\n )\n }\n\n // Set sanitized hierarchy config (cast needed as we're transitioning from HierarchyConfig to SanitizedHierarchyConfig)\n const useHeaderButton = collectionConfig.hierarchy.admin?.useHeaderButton ?? false\n const injectSidebarTab = collectionConfig.hierarchy.admin?.injectSidebarTab ?? true\n\n ;(collectionConfig as unknown as { hierarchy: SanitizedHierarchyConfig }).hierarchy = {\n admin: {\n components: {\n Icon: iconComponent || '@payloadcms/ui#TagIcon',\n },\n injectSidebarTab,\n treeLimit,\n useHeaderButton,\n },\n allowHasMany,\n collectionSpecific,\n joinField,\n parentFieldName,\n relatedCollections: {},\n slugField,\n slugify,\n slugPathFieldName,\n titlePathFieldName,\n }\n}\n"],"names":["fieldAffectsData","slugify","defaultSlugify","addHierarchyToCollection","buildParentField","DEFAULT_ALLOW_HAS_MANY","DEFAULT_HIERARCHY_TREE_LIMIT","getHierarchyFieldName","HIERARCHY_SLUG_PATH_FIELD","HIERARCHY_TITLE_PATH_FIELD","ensureSafeCollectionsChange","sanitizeHierarchyCollection","collectionConfig","_config","hierarchy","defaultParentFieldName","slug","parentFieldName","existingParentField","fields","find","field","name","type","Error","hasMany","localized","useHeaderButton","admin","parentField","collectionSlug","injectHeaderButton","unshift","slugPathFieldName","titlePathFieldName","allowHasMany","rawCollectionSpecific","collectionSpecific","fieldName","joinField","undefined","text","treeLimit","iconComponent","components","Icon","slugField","slugFieldName","hooks","beforeValidate","push","folderFieldName","foldersSlug","typeFieldName","injectSidebarTab","relatedCollections"],"mappings":"AAIA,SAASA,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,WAAWC,cAAc,QAAQ,0BAAyB;AACnE,SAASC,wBAAwB,QAAQ,gCAA+B;AACxE,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SACEC,sBAAsB,EACtBC,4BAA4B,EAC5BC,qBAAqB,EACrBC,yBAAyB,EACzBC,0BAA0B,QACrB,iBAAgB;AACvB,SAASC,2BAA2B,QAAQ,yCAAwC;AAEpF;;;;;;;;;CASC,GACD,OAAO,MAAMC,8BAA8B,CACzCC,kBACAC;IAEA,IAAI,CAACD,iBAAiBE,SAAS,EAAE;QAC/BF,iBAAiBE,SAAS,GAAG;QAC7B;IACF;IAEA,gEAAgE;IAChE,MAAMC,yBAAyBR,sBAAsBK,iBAAiBI,IAAI;IAE1E,IAAIJ,iBAAiBE,SAAS,KAAK,MAAM;QACvCF,iBAAiBE,SAAS,GAAG;YAC3BG,iBAAiBF;QACnB;IACF;IAEA,MAAME,kBAAkBL,iBAAiBE,SAAS,CAACG,eAAe,IAAIF;IAEtE,uCAAuC;IACvC,MAAMG,sBAAsBN,iBAAiBO,MAAM,CAACC,IAAI,CACtD,CAAC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":3,"sources":["../../src/hierarchy/sanitizeHierarchyCollection.ts"],"sourcesContent":["import type { CollectionConfig } from '../collections/config/types.js'\nimport type { Config } from '../config/types.js'\nimport type { SanitizedHierarchyConfig } from './types.js'\n\nimport { fieldAffectsData } from '../fields/config/types.js'\nimport { slugify as defaultSlugify } from '../utilities/slugify.js'\nimport { addHierarchyToCollection } from './addHierarchyToCollection.js'\nimport { buildParentField } from './buildParentField.js'\nimport {\n DEFAULT_ALLOW_HAS_MANY,\n DEFAULT_HIERARCHY_TREE_LIMIT,\n getHierarchyFieldName,\n HIERARCHY_SLUG_PATH_FIELD,\n HIERARCHY_TITLE_PATH_FIELD,\n} from './constants.js'\nimport { ensureSafeCollectionsChange } from './hooks/ensureSafeCollectionsChange.js'\n\n/**\n * Sanitizes hierarchy configuration for a single collection.\n *\n * This is phase 1 of hierarchy setup, called during individual collection sanitization.\n * It normalizes the hierarchy config, creates the parent field if needed, adds hooks,\n * and sets up the sanitized config structure.\n *\n * Phase 2 (`resolveHierarchyCollections`) runs after all collections are sanitized\n * to establish cross-collection relationships.\n */\nexport const sanitizeHierarchyCollection = (\n collectionConfig: CollectionConfig,\n _config: Config,\n): void => {\n if (!collectionConfig.hierarchy) {\n collectionConfig.hierarchy = false\n return\n }\n\n // Normalize boolean to object and apply parentFieldName default\n const defaultParentFieldName = getHierarchyFieldName(collectionConfig.slug)\n\n if (collectionConfig.hierarchy === true) {\n collectionConfig.hierarchy = {\n parentFieldName: defaultParentFieldName,\n }\n }\n\n const parentFieldName = collectionConfig.hierarchy.parentFieldName ?? defaultParentFieldName\n\n // Check if parent field already exists\n const existingParentField = collectionConfig.fields.find(\n (field) => fieldAffectsData(field) && field.name === parentFieldName,\n )\n\n if (existingParentField) {\n // Validate existing parent field configuration\n if (existingParentField.type !== 'relationship') {\n throw new Error(\n `Hierarchy parent field \"${parentFieldName}\" in collection \"${collectionConfig.slug}\" must be a relationship field`,\n )\n }\n\n if (existingParentField.hasMany !== false) {\n throw new Error(\n `Hierarchy parent field \"${parentFieldName}\" in collection \"${collectionConfig.slug}\" must have hasMany set to false`,\n )\n }\n\n if (existingParentField.localized === true) {\n throw new Error(\n `Hierarchy parent field \"${parentFieldName}\" in collection \"${collectionConfig.slug}\" cannot be localized. The parent relationship must be consistent across all locales.`,\n )\n }\n } else {\n // Auto-create parent field if it doesn't exist\n // useHeaderButton defaults to true - parent selection via header button with miller columns\n const useHeaderButton = collectionConfig.hierarchy.admin?.useHeaderButton ?? true\n\n const parentField = buildParentField({\n collectionSlug: collectionConfig.slug,\n injectHeaderButton: useHeaderButton,\n parentFieldName,\n })\n\n collectionConfig.fields.unshift(parentField)\n }\n\n // Apply defaults for optional fields\n const slugPathFieldName =\n collectionConfig.hierarchy.slugPathFieldName || HIERARCHY_SLUG_PATH_FIELD\n const titlePathFieldName =\n collectionConfig.hierarchy.titlePathFieldName || HIERARCHY_TITLE_PATH_FIELD\n const allowHasMany = collectionConfig.hierarchy.allowHasMany ?? DEFAULT_ALLOW_HAS_MANY\n const rawCollectionSpecific = collectionConfig.hierarchy.collectionSpecific\n const collectionSpecific: { fieldName: string } | false =\n rawCollectionSpecific === true\n ? { fieldName: 'hierarchyType' }\n : rawCollectionSpecific\n ? { fieldName: rawCollectionSpecific.fieldName ?? 'hierarchyType' }\n : false\n const joinField = collectionConfig.hierarchy.joinField\n ? collectionConfig.hierarchy.joinField\n : undefined\n const slugify =\n collectionConfig.hierarchy.slugify ?? ((text: string) => defaultSlugify(text) ?? '')\n const treeLimit = collectionConfig.hierarchy.admin?.treeLimit ?? DEFAULT_HIERARCHY_TREE_LIMIT\n const iconComponent = collectionConfig.hierarchy.admin?.components?.Icon\n const smallIconComponent = collectionConfig.hierarchy.admin?.components?.SmallIcon\n\n const slugField = collectionConfig.hierarchy.slugField\n\n // Apply hierarchy to collection (adds fields and hooks)\n addHierarchyToCollection({\n collectionConfig,\n parentFieldName: collectionConfig.hierarchy.parentFieldName,\n slugFieldName: slugField,\n slugPathFieldName,\n titlePathFieldName,\n })\n\n // If collectionSpecific, add beforeValidate hook to enforce scope inheritance\n // (hierarchyType field is added in resolveHierarchyCollections after discovery)\n if (collectionSpecific) {\n // Use parentFieldName for both - backward compatible configs use the same field name everywhere\n if (!collectionConfig.hooks) {\n collectionConfig.hooks = {}\n }\n if (!collectionConfig.hooks.beforeValidate) {\n collectionConfig.hooks.beforeValidate = []\n }\n collectionConfig.hooks.beforeValidate.push(\n ensureSafeCollectionsChange({\n folderFieldName: parentFieldName,\n foldersSlug: collectionConfig.slug,\n parentFieldName,\n typeFieldName: collectionSpecific.fieldName,\n }),\n )\n }\n\n // Set sanitized hierarchy config (cast needed as we're transitioning from HierarchyConfig to SanitizedHierarchyConfig)\n const useHeaderButton = collectionConfig.hierarchy.admin?.useHeaderButton ?? false\n const injectSidebarTab = collectionConfig.hierarchy.admin?.injectSidebarTab ?? true\n\n ;(collectionConfig as unknown as { hierarchy: SanitizedHierarchyConfig }).hierarchy = {\n admin: {\n components: {\n Icon: iconComponent || '@payloadcms/ui#TagIcon',\n SmallIcon: smallIconComponent || iconComponent || '@payloadcms/ui#TagIcon',\n },\n injectSidebarTab,\n treeLimit,\n useHeaderButton,\n },\n allowHasMany,\n collectionSpecific,\n joinField,\n parentFieldName,\n relatedCollections: {},\n slugField,\n slugify,\n slugPathFieldName,\n titlePathFieldName,\n }\n}\n"],"names":["fieldAffectsData","slugify","defaultSlugify","addHierarchyToCollection","buildParentField","DEFAULT_ALLOW_HAS_MANY","DEFAULT_HIERARCHY_TREE_LIMIT","getHierarchyFieldName","HIERARCHY_SLUG_PATH_FIELD","HIERARCHY_TITLE_PATH_FIELD","ensureSafeCollectionsChange","sanitizeHierarchyCollection","collectionConfig","_config","hierarchy","defaultParentFieldName","slug","parentFieldName","existingParentField","fields","find","field","name","type","Error","hasMany","localized","useHeaderButton","admin","parentField","collectionSlug","injectHeaderButton","unshift","slugPathFieldName","titlePathFieldName","allowHasMany","rawCollectionSpecific","collectionSpecific","fieldName","joinField","undefined","text","treeLimit","iconComponent","components","Icon","smallIconComponent","SmallIcon","slugField","slugFieldName","hooks","beforeValidate","push","folderFieldName","foldersSlug","typeFieldName","injectSidebarTab","relatedCollections"],"mappings":"AAIA,SAASA,gBAAgB,QAAQ,4BAA2B;AAC5D,SAASC,WAAWC,cAAc,QAAQ,0BAAyB;AACnE,SAASC,wBAAwB,QAAQ,gCAA+B;AACxE,SAASC,gBAAgB,QAAQ,wBAAuB;AACxD,SACEC,sBAAsB,EACtBC,4BAA4B,EAC5BC,qBAAqB,EACrBC,yBAAyB,EACzBC,0BAA0B,QACrB,iBAAgB;AACvB,SAASC,2BAA2B,QAAQ,yCAAwC;AAEpF;;;;;;;;;CASC,GACD,OAAO,MAAMC,8BAA8B,CACzCC,kBACAC;IAEA,IAAI,CAACD,iBAAiBE,SAAS,EAAE;QAC/BF,iBAAiBE,SAAS,GAAG;QAC7B;IACF;IAEA,gEAAgE;IAChE,MAAMC,yBAAyBR,sBAAsBK,iBAAiBI,IAAI;IAE1E,IAAIJ,iBAAiBE,SAAS,KAAK,MAAM;QACvCF,iBAAiBE,SAAS,GAAG;YAC3BG,iBAAiBF;QACnB;IACF;IAEA,MAAME,kBAAkBL,iBAAiBE,SAAS,CAACG,eAAe,IAAIF;IAEtE,uCAAuC;IACvC,MAAMG,sBAAsBN,iBAAiBO,MAAM,CAACC,IAAI,CACtD,CAACC,QAAUrB,iBAAiBqB,UAAUA,MAAMC,IAAI,KAAKL;IAGvD,IAAIC,qBAAqB;QACvB,+CAA+C;QAC/C,IAAIA,oBAAoBK,IAAI,KAAK,gBAAgB;YAC/C,MAAM,IAAIC,MACR,CAAC,wBAAwB,EAAEP,gBAAgB,iBAAiB,EAAEL,iBAAiBI,IAAI,CAAC,8BAA8B,CAAC;QAEvH;QAEA,IAAIE,oBAAoBO,OAAO,KAAK,OAAO;YACzC,MAAM,IAAID,MACR,CAAC,wBAAwB,EAAEP,gBAAgB,iBAAiB,EAAEL,iBAAiBI,IAAI,CAAC,gCAAgC,CAAC;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D,wDAAwD;IACxD7C,yBAAyB;QACvBS;QACAK,iBAAiBL,iBAAiBE,SAAS,CAACG,eAAe;QAC3DgC,eAAeD;QACff;QACAC;IACF;IAEA,8EAA8E;IAC9E,gFAAgF;IAChF,IAAIG,oBAAoB;QACtB,gGAAgG;QAChG,IAAI,CAACzB,iBAAiBsC,KAAK,EAAE;YAC3BtC,iBAAiBsC,KAAK,GAAG,CAAC;QAC5B;QACA,IAAI,CAACtC,iBAAiBsC,KAAK,CAACC,cAAc,EAAE;YAC1CvC,iBAAiBsC,KAAK,CAACC,cAAc,GAAG,EAAE;QAC5C;QACAvC,iBAAiBsC,KAAK,CAACC,cAAc,CAACC,IAAI,CACxC1C,4BAA4B;YAC1B2C,iBAAiBpC;YACjBqC,aAAa1C,iBAAiBI,IAAI;YAClCC;YACAsC,eAAelB,mBAAmBC,SAAS;QAC7C;IAEJ;IAEA,uHAAuH;IACvH,MAAMX,kBAAkBf,iBAAiBE,SAAS,CAACc,KAAK,EAAED,mBAAmB;IAC7E,MAAM6B,mBAAmB5C,iBAAiBE,SAAS,CAACc,KAAK,EAAE4B,oBAAoB;IAE7E5C,iBAAwEE,SAAS,GAAG;QACpFc,OAAO;YACLgB,YAAY;gBACVC,MAAMF,iBAAiB;gBACvBI,WAAWD,sBAAsBH,iBAAiB;YACpD;YACAa;YACAd;YACAf;QACF;QACAQ;QACAE;QACAE;QACAtB;QACAwC,oBAAoB,CAAC;QACrBT;QACA/C;QACAgC;QACAC;IACF;AACF,EAAC"}
@@ -23,9 +23,15 @@ export type HierarchyConfig = {
23
23
  */
24
24
  components?: {
25
25
  /**
26
- * Custom icon component for hierarchy items
26
+ * Custom icon component for hierarchy items.
27
+ * - 24x24 size icon.
27
28
  */
28
29
  Icon?: PayloadComponent;
30
+ /**
31
+ * Small icon component for compact hierarchy contexts:
32
+ * - 16x16 size icon.
33
+ */
34
+ SmallIcon?: PayloadComponent;
29
35
  };
30
36
  /**
31
37
  * Whether to inject a sidebar tab for this hierarchy collection
@@ -107,6 +113,7 @@ export type SanitizedHierarchyConfig = {
107
113
  admin: {
108
114
  components: {
109
115
  Icon: PayloadComponent;
116
+ SmallIcon: PayloadComponent;
110
117
  };
111
118
  injectSidebarTab: boolean;
112
119
  treeLimit: number;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/hierarchy/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAE1D;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,MAAM,CAAA;CACb,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,CAAC,CAAA;AAE/E;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,KAAK,CAAC,EAAE;QACN;;WAEG;QACH,UAAU,CAAC,EAAE;YACX;;eAEG;YACH,IAAI,CAAC,EAAE,gBAAgB,CAAA;SACxB,CAAA;QACD;;;WAGG;QACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;QAC1B;;;WAGG;QACH,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB;;;;WAIG;QACH,eAAe,CAAC,EAAE,OAAO,CAAA;KAC1B,CAAA;IACD;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;;OAIG;IACH,kBAAkB,CAAC,EACf;QACE;;;WAGG;QACH,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,GACD,OAAO,CAAA;IACX;;;;;OAKG;IACH,SAAS,CAAC,EAAE,wBAAwB,CAAA;IACpC;;;;OAIG;IACH,eAAe,EAAE,MAAM,CAAA;IACvB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;;OAKG;I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AA;CAC5B,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,KAAK,EAAE;QACL,UAAU,EAAE;YACV,IAAI,EAAE,gBAAgB,CAAA;YACtB,SAAS,EAAE,gBAAgB,CAAA;SAC5B,CAAA;QACD,gBAAgB,EAAE,OAAO,CAAA;QACzB,SAAS,EAAE,MAAM,CAAA;QACjB,eAAe,EAAE,OAAO,CAAA;KACzB,CAAA;IACD,YAAY,EAAE,OAAO,CAAA;IACrB,kBAAkB,EACd;QACE,SAAS,EAAE,MAAM,CAAA;KAClB,GACD,KAAK,CAAA;IACT;;OAEG;IACH,SAAS,CAAC,EAAE,wBAAwB,CAAA;IACpC,eAAe,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,mCAAmC,CAAC,CAAA;IACvE;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;IACjC,iBAAiB,EAAE,MAAM,CAAA;IACzB,kBAAkB,EAAE,MAAM,CAAA;CAC3B,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,mCAAmC,GAAG;IAChD,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,IAAI,CAAC,wBAAwB,EAAE,SAAS,CAAC,CAAA;AAE7E;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/hierarchy/types.ts"],"sourcesContent":["import type { PayloadComponent } from '../config/types.js'\nimport type { JoinField } from '../fields/config/types.js'\n\n/**\n * User-configurable options for the hierarchy join field.\n * Excludes properties that are auto-generated: type, collection, on, hasMany\n */\nexport type HierarchyJoinFieldConfig = {\n name: string\n} & Omit<Partial<JoinField>, 'collection' | 'hasMany' | 'name' | 'on' | 'type'>\n\n/**\n * Configuration options for hierarchy feature\n *\n * Hierarchies are always self-referential - documents can only nest under other documents\n * from the same collection.\n */\nexport type HierarchyConfig = {\n /**\n * UI configuration for hierarchy\n */\n admin?: {\n /**\n * Custom components for hierarchy UI\n */\n components?: {\n /**\n * Custom icon component for hierarchy items\n */\n Icon?: PayloadComponent\n }\n /**\n * Whether to inject a sidebar tab for this hierarchy collection\n * @default true\n */\n injectSidebarTab?: boolean\n /**\n * Maximum number of items to load in tree views\n * @default 100\n */\n treeLimit?: number\n /**\n * Whether to use a header button for parent selection instead of inline field.\n * When true, the parent field is hidden and a button is injected into the document header.\n * @default true\n */\n useHeaderButton?: boolean\n }\n /**\n * Whether related documents can have multiple values of this hierarchy\n * Set to false for folder-like behavior (single parent), true for tag-like behavior (multiple)\n * @default true\n */\n allowHasMany?: boolean\n /**\n * Whether this hierarchy is scoped to specific collections\n * When true or an object, hierarchy items can be restricted to certain collections\n * @default false\n */\n collectionSpecific?:\n | {\n /**\n * Name of the select field for specifying allowed collections\n * @default 'hierarchyType'\n */\n fieldName?: string\n }\n | boolean\n /**\n * Configure a join field to query all children (nested hierarchy items and related documents)\n * If not set, no join field is created.\n * You can pass additional JoinField options (admin, defaultLimit, defaultSort, etc.)\n * that will be merged with the auto-generated config.\n */\n joinField?: HierarchyJoinFieldConfig\n /**\n * Name of the field that references the parent document\n * Will automatically create this field if it does not exist\n * @default '_h_${collectionSlug}' (e.g., '_h_folders' for a collection with slug 'folders')\n */\n parentFieldName: string\n /**\n * Name of the field to use for slug path generation.\n * When set, uses this field's value directly instead of slugifying the title.\n * Useful when you have a dedicated slug field (e.g., 'slug') separate from the title.\n * @example 'slug' - uses the 'slug' field value as-is for path segments\n */\n slugField?: string\n /**\n * Custom function to slugify text for path generation\n * Used by computeSlugPath() utility for generating slug-based breadcrumb paths\n * Only used when slugField is not set.\n * Defaults to internal slugify implementation\n */\n slugify?: (text: string) => string\n /**\n * Name of the virtual field that will contain the slug-based breadcrumb path\n * @default HIERARCHY_SLUG_PATH_FIELD ('_h_slugPath')\n */\n slugPathFieldName?: string\n /**\n * Name of the virtual field that will contain the title-based breadcrumb path\n * @default HIERARCHY_TITLE_PATH_FIELD ('_h_titlePath')\n */\n titlePathFieldName?: string\n}\n\n/**\n * Sanitized hierarchy configuration with all defaults applied\n */\nexport type SanitizedHierarchyConfig = {\n admin: {\n components: {\n Icon: PayloadComponent\n }\n injectSidebarTab: boolean\n treeLimit: number\n useHeaderButton: boolean\n }\n allowHasMany: boolean\n collectionSpecific:\n | {\n fieldName: string\n }\n | false\n /**\n * Join field configuration, or undefined if not enabled\n */\n joinField?: HierarchyJoinFieldConfig\n parentFieldName: string\n /**\n * Auto-populated during validation - maps collection slug to field info\n */\n relatedCollections: Record<string, SanitizedHierarchyRelatedCollection>\n /**\n * Field name for slug values, or undefined to use slugified title\n */\n slugField?: string\n slugify: (text: string) => string\n slugPathFieldName: string\n titlePathFieldName: string\n}\n\n/**\n * Information about how a collection relates to this hierarchy\n */\nexport type SanitizedHierarchyRelatedCollection = {\n fieldName: string\n hasMany: boolean\n}\n\n/**\n * Client-safe hierarchy configuration (excludes functions that can't cross server-client boundary)\n */\nexport type ClientHierarchyConfig = Omit<SanitizedHierarchyConfig, 'slugify'>\n\n/**\n * Breadcrumb item for folder hierarchies\n * @deprecated Use hierarchy breadcrumbs instead\n */\nexport type FolderBreadcrumb = {\n id: number | string\n name: string\n}\n"],"names":[],"mappings":"AA4JA;;;CAGC,GACD,WAGC"}
1
+ {"version":3,"sources":["../../src/hierarchy/types.ts"],"sourcesContent":["import type { PayloadComponent } from '../config/types.js'\nimport type { JoinField } from '../fields/config/types.js'\n\n/**\n * User-configurable options for the hierarchy join field.\n * Excludes properties that are auto-generated: type, collection, on, hasMany\n */\nexport type HierarchyJoinFieldConfig = {\n name: string\n} & Omit<Partial<JoinField>, 'collection' | 'hasMany' | 'name' | 'on' | 'type'>\n\n/**\n * Configuration options for hierarchy feature\n *\n * Hierarchies are always self-referential - documents can only nest under other documents\n * from the same collection.\n */\nexport type HierarchyConfig = {\n /**\n * UI configuration for hierarchy\n */\n admin?: {\n /**\n * Custom components for hierarchy UI\n */\n components?: {\n /**\n * Custom icon component for hierarchy items.\n * - 24x24 size icon.\n */\n Icon?: PayloadComponent\n /**\n * Small icon component for compact hierarchy contexts:\n * - 16x16 size icon.\n */\n SmallIcon?: PayloadComponent\n }\n /**\n * Whether to inject a sidebar tab for this hierarchy collection\n * @default true\n */\n injectSidebarTab?: boolean\n /**\n * Maximum number of items to load in tree views\n * @default 100\n */\n treeLimit?: number\n /**\n * Whether to use a header button for parent selection instead of inline field.\n * When true, the parent field is hidden and a button is injected into the document header.\n * @default true\n */\n useHeaderButton?: boolean\n }\n /**\n * Whether related documents can have multiple values of this hierarchy\n * Set to false for folder-like behavior (single parent), true for tag-like behavior (multiple)\n * @default true\n */\n allowHasMany?: boolean\n /**\n * Whether this hierarchy is scoped to specific collections\n * When true or an object, hierarchy items can be restricted to certain collections\n * @default false\n */\n collectionSpecific?:\n | {\n /**\n * Name of the select field for specifying allowed collections\n * @default 'hierarchyType'\n */\n fieldName?: string\n }\n | boolean\n /**\n * Configure a join field to query all children (nested hierarchy items and related documents)\n * If not set, no join field is created.\n * You can pass additional JoinField options (admin, defaultLimit, defaultSort, etc.)\n * that will be merged with the auto-generated config.\n */\n joinField?: HierarchyJoinFieldConfig\n /**\n * Name of the field that references the parent document\n * Will automatically create this field if it does not exist\n * @default '_h_${collectionSlug}' (e.g., '_h_folders' for a collection with slug 'folders')\n */\n parentFieldName: string\n /**\n * Name of the field to use for slug path generation.\n * When set, uses this field's value directly instead of slugifying the title.\n * Useful when you have a dedicated slug field (e.g., 'slug') separate from the title.\n * @example 'slug' - uses the 'slug' field value as-is for path segments\n */\n slugField?: string\n /**\n * Custom function to slugify text for path generation\n * Used by computeSlugPath() utility for generating slug-based breadcrumb paths\n * Only used when slugField is not set.\n * Defaults to internal slugify implementation\n */\n slugify?: (text: string) => string\n /**\n * Name of the virtual field that will contain the slug-based breadcrumb path\n * @default HIERARCHY_SLUG_PATH_FIELD ('_h_slugPath')\n */\n slugPathFieldName?: string\n /**\n * Name of the virtual field that will contain the title-based breadcrumb path\n * @default HIERARCHY_TITLE_PATH_FIELD ('_h_titlePath')\n */\n titlePathFieldName?: string\n}\n\n/**\n * Sanitized hierarchy configuration with all defaults applied\n */\nexport type SanitizedHierarchyConfig = {\n admin: {\n components: {\n Icon: PayloadComponent\n SmallIcon: PayloadComponent\n }\n injectSidebarTab: boolean\n treeLimit: number\n useHeaderButton: boolean\n }\n allowHasMany: boolean\n collectionSpecific:\n | {\n fieldName: string\n }\n | false\n /**\n * Join field configuration, or undefined if not enabled\n */\n joinField?: HierarchyJoinFieldConfig\n parentFieldName: string\n /**\n * Auto-populated during validation - maps collection slug to field info\n */\n relatedCollections: Record<string, SanitizedHierarchyRelatedCollection>\n /**\n * Field name for slug values, or undefined to use slugified title\n */\n slugField?: string\n slugify: (text: string) => string\n slugPathFieldName: string\n titlePathFieldName: string\n}\n\n/**\n * Information about how a collection relates to this hierarchy\n */\nexport type SanitizedHierarchyRelatedCollection = {\n fieldName: string\n hasMany: boolean\n}\n\n/**\n * Client-safe hierarchy configuration (excludes functions that can't cross server-client boundary)\n */\nexport type ClientHierarchyConfig = Omit<SanitizedHierarchyConfig, 'slugify'>\n\n/**\n * Breadcrumb item for folder hierarchies\n * @deprecated Use hierarchy breadcrumbs instead\n */\nexport type FolderBreadcrumb = {\n id: number | string\n name: string\n}\n"],"names":[],"mappings":"AAmKA;;;CAGC,GACD,WAGC"}