rimecms 1.2.0 → 1.4.0

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 (748) hide show
  1. package/dist/adapter-sqlite/collection.server.js +2 -1
  2. package/dist/adapter-sqlite/columns.server.d.ts +42 -61
  3. package/dist/adapter-sqlite/columns.server.js +50 -111
  4. package/dist/adapter-sqlite/constant.d.ts +16 -0
  5. package/dist/adapter-sqlite/constant.js +16 -0
  6. package/dist/adapter-sqlite/db-move.server.d.ts +31 -0
  7. package/dist/adapter-sqlite/db-move.server.js +102 -0
  8. package/dist/adapter-sqlite/drizzle-config.server.d.ts +9 -0
  9. package/dist/adapter-sqlite/drizzle-config.server.js +39 -0
  10. package/dist/adapter-sqlite/generate-schema/column.server.d.ts +8 -6
  11. package/dist/adapter-sqlite/generate-schema/column.server.js +13 -49
  12. package/dist/adapter-sqlite/generate-schema/index.server.d.ts +1 -0
  13. package/dist/adapter-sqlite/generate-schema/index.server.js +6 -0
  14. package/dist/adapter-sqlite/generate-schema/relations/junction.server.d.ts +3 -3
  15. package/dist/adapter-sqlite/generate-schema/relations/junction.server.js +3 -3
  16. package/dist/adapter-sqlite/generate-schema/root.server.d.ts +4 -0
  17. package/dist/adapter-sqlite/generate-schema/root.server.js +26 -33
  18. package/dist/adapter-sqlite/generate-schema/templates.server.d.ts +0 -22
  19. package/dist/adapter-sqlite/generate-schema/templates.server.js +0 -33
  20. package/dist/adapter-sqlite/generate-schema/write.server.d.ts +6 -0
  21. package/dist/adapter-sqlite/generate-schema/write.server.js +13 -3
  22. package/dist/adapter-sqlite/hooks.server.d.ts +3 -0
  23. package/dist/adapter-sqlite/hooks.server.js +64 -0
  24. package/dist/adapter-sqlite/index.server.d.ts +9 -1
  25. package/dist/adapter-sqlite/index.server.js +23 -2
  26. package/dist/adapter-sqlite/locales.server.js +1 -4
  27. package/dist/adapter-sqlite/order-by.server.d.ts +6 -0
  28. package/dist/adapter-sqlite/order-by.server.js +6 -0
  29. package/dist/adapter-sqlite/read.server.d.ts +12 -1
  30. package/dist/adapter-sqlite/read.server.js +94 -38
  31. package/dist/adapter-sqlite/registry.server.d.ts +2 -2
  32. package/dist/adapter-sqlite/registry.server.js +2 -2
  33. package/dist/adapter-sqlite/relations.server.d.ts +5 -0
  34. package/dist/adapter-sqlite/relations.server.js +27 -7
  35. package/dist/adapter-sqlite/repeatable.server.d.ts +4 -1
  36. package/dist/adapter-sqlite/repeatable.server.js +4 -1
  37. package/dist/adapter-sqlite/select.server.d.ts +6 -0
  38. package/dist/adapter-sqlite/select.server.js +56 -113
  39. package/dist/adapter-sqlite/table.server.js +7 -0
  40. package/dist/adapter-sqlite/transform.server.js +8 -2
  41. package/dist/adapter-sqlite/where.server.d.ts +11 -0
  42. package/dist/adapter-sqlite/where.server.js +237 -236
  43. package/dist/adapter-sqlite/write.server.d.ts +5 -0
  44. package/dist/adapter-sqlite/write.server.js +9 -7
  45. package/dist/core/adapter.d.ts +63 -12
  46. package/dist/core/auth/access.d.ts +3 -5
  47. package/dist/core/auth/access.js +3 -5
  48. package/dist/core/auth/augment.js +3 -4
  49. package/dist/core/auth/augment.server.d.ts +4 -0
  50. package/dist/core/auth/augment.server.js +4 -0
  51. package/dist/core/auth/better-auth/config.server.d.ts +24 -16
  52. package/dist/core/auth/better-auth/config.server.js +6 -0
  53. package/dist/core/auth/better-auth/hooks.server.js +17 -5
  54. package/dist/core/auth/better-auth/instance.server.d.ts +38 -32
  55. package/dist/core/auth/better-auth/permissions.d.ts +8 -7
  56. package/dist/core/auth/better-auth/permissions.js +1 -0
  57. package/dist/core/auth/better-auth-tables.server.d.ts +9 -7
  58. package/dist/core/auth/better-auth-tables.server.js +9 -7
  59. package/dist/core/auth/constant.d.ts +3 -3
  60. package/dist/core/auth/constant.js +3 -3
  61. package/dist/core/auth/constant.server.d.ts +3 -3
  62. package/dist/core/auth/constant.server.js +3 -3
  63. package/dist/core/auth/handler/index.server.js +37 -15
  64. package/dist/core/auth/hooks/create-better-auth-user.server.d.ts +4 -2
  65. package/dist/core/auth/hooks/create-better-auth-user.server.js +132 -185
  66. package/dist/core/auth/hooks/forward-roles.server.d.ts +2 -1
  67. package/dist/core/auth/hooks/forward-roles.server.js +3 -3
  68. package/dist/core/auth/hooks/populate-api-key.server.d.ts +2 -2
  69. package/dist/core/auth/hooks/populate-api-key.server.js +11 -3
  70. package/dist/core/auth/hooks/prevent-user-mutations.server.d.ts +2 -2
  71. package/dist/core/auth/hooks/prevent-user-mutations.server.js +5 -4
  72. package/dist/core/auth/hooks/sign-in-new-user.server.d.ts +5 -6
  73. package/dist/core/auth/hooks/sign-in-new-user.server.js +5 -6
  74. package/dist/core/auth/staff/derive.d.ts +10 -0
  75. package/dist/core/auth/staff/derive.js +10 -0
  76. package/dist/core/auth/tables.d.ts +4 -0
  77. package/dist/core/auth/tables.js +4 -0
  78. package/dist/core/auth/types.d.ts +10 -5
  79. package/dist/core/auth/user.server.d.ts +8 -3
  80. package/dist/core/auth/user.server.js +8 -3
  81. package/dist/core/auth/validate-config.d.ts +1 -3
  82. package/dist/core/auth/validate-config.js +2 -4
  83. package/dist/core/boot.server.d.ts +38 -32
  84. package/dist/core/boot.server.js +7 -2
  85. package/dist/core/codegen.server.d.ts +2 -3
  86. package/dist/core/codegen.server.js +18 -16
  87. package/dist/core/config/build.d.ts +1 -1
  88. package/dist/core/config/build.server.d.ts +2 -1
  89. package/dist/core/config/build.server.js +1 -0
  90. package/dist/core/config/context.server.d.ts +3 -9
  91. package/dist/core/config/context.server.js +3 -9
  92. package/dist/core/config/index.server.d.ts +4 -2
  93. package/dist/core/config/index.server.js +4 -2
  94. package/dist/core/config/types.d.ts +17 -6
  95. package/dist/core/config/validate.server.d.ts +4 -0
  96. package/dist/core/config/validate.server.js +100 -90
  97. package/dist/core/constants.d.ts +13 -5
  98. package/dist/core/constants.js +13 -5
  99. package/dist/core/constants.server.d.ts +7 -0
  100. package/dist/core/constants.server.js +7 -0
  101. package/dist/core/dev/cache.server.d.ts +10 -7
  102. package/dist/core/dev/cache.server.js +10 -11
  103. package/dist/core/dev/cli/commands/build.d.ts +7 -2
  104. package/dist/core/dev/cli/commands/build.js +38 -12
  105. package/dist/core/dev/cli/commands/clear.server.d.ts +6 -0
  106. package/dist/core/dev/cli/commands/clear.server.js +20 -6
  107. package/dist/core/dev/cli/commands/generate-exports.server.js +25 -4
  108. package/dist/core/dev/cli/commands/generate.server.d.ts +5 -0
  109. package/dist/core/dev/cli/commands/generate.server.js +7 -8
  110. package/dist/core/dev/cli/commands/init.server.d.ts +10 -1
  111. package/dist/core/dev/cli/commands/init.server.js +45 -53
  112. package/dist/core/dev/cli/commands/uploads-move.server.js +3 -0
  113. package/dist/core/dev/cli/index.js +34 -16
  114. package/dist/core/dev/cli/templates/build.d.ts +4 -0
  115. package/dist/core/dev/cli/templates/build.js +4 -0
  116. package/dist/core/dev/cli/templates/init.d.ts +7 -10
  117. package/dist/core/dev/cli/templates/init.js +22 -47
  118. package/dist/core/dev/cli/util/adapter-hooks.server.d.ts +15 -0
  119. package/dist/core/dev/cli/util/adapter-hooks.server.js +17 -0
  120. package/dist/core/dev/cli/util/package-manager.server.d.ts +10 -1
  121. package/dist/core/dev/cli/util/package-manager.server.js +21 -19
  122. package/dist/core/dev/cli/util/package.server.d.ts +1 -0
  123. package/dist/core/dev/cli/util/package.server.js +2 -2
  124. package/dist/core/dev/cli/util/project-name.d.ts +2 -1
  125. package/dist/core/dev/cli/util/project-name.js +6 -4
  126. package/dist/core/dev/cli/util/prompt.server.d.ts +2 -1
  127. package/dist/core/dev/cli/util/prompt.server.js +2 -1
  128. package/dist/core/dev/codegen/routes/common.server.d.ts +12 -0
  129. package/dist/core/dev/codegen/routes/common.server.js +9 -17
  130. package/dist/core/dev/codegen/routes/custom-css.server.d.ts +3 -9
  131. package/dist/core/dev/codegen/routes/custom-css.server.js +8 -34
  132. package/dist/core/dev/codegen/routes/index.server.d.ts +4 -5
  133. package/dist/core/dev/codegen/routes/index.server.js +33 -17
  134. package/dist/core/dev/codegen/routes/util.server.d.ts +13 -23
  135. package/dist/core/dev/codegen/routes/util.server.js +15 -25
  136. package/dist/core/dev/codegen/runtime/index.server.d.ts +2 -3
  137. package/dist/core/dev/codegen/runtime/index.server.js +2 -3
  138. package/dist/core/dev/codegen/runtime/parse-exports.server.js +10 -3
  139. package/dist/core/dev/codegen/sanitize/index.server.d.ts +11 -1
  140. package/dist/core/dev/codegen/sanitize/index.server.js +81 -50
  141. package/dist/core/dev/codegen/types/index.server.d.ts +2 -4
  142. package/dist/core/dev/codegen/types/index.server.js +6 -10
  143. package/dist/core/dev/codegen/types/templates.server.d.ts +4 -2
  144. package/dist/core/dev/codegen/types/templates.server.js +13 -26
  145. package/dist/core/dev/config-memo.server.js +6 -7
  146. package/dist/core/dev/constants.server.d.ts +4 -2
  147. package/dist/core/dev/constants.server.js +7 -4
  148. package/dist/core/dev/deny-storage.server.d.ts +2 -2
  149. package/dist/core/dev/deny-storage.server.js +2 -2
  150. package/dist/core/dev/ensure.server.d.ts +5 -0
  151. package/dist/core/dev/ensure.server.js +9 -22
  152. package/dist/core/dev/env.server.d.ts +3 -1
  153. package/dist/core/dev/env.server.js +3 -1
  154. package/dist/core/dev/vite.server.d.ts +10 -0
  155. package/dist/core/dev/vite.server.js +21 -5
  156. package/dist/core/errors/handler.server.d.ts +9 -3
  157. package/dist/core/errors/handler.server.js +11 -6
  158. package/dist/core/errors/index.d.ts +21 -1
  159. package/dist/core/errors/index.js +23 -3
  160. package/dist/core/fields/builders/boolean-builder.d.ts +4 -0
  161. package/dist/core/fields/builders/boolean-builder.js +6 -1
  162. package/dist/core/fields/builders/field-builder.d.ts +16 -4
  163. package/dist/core/fields/builders/field-builder.js +11 -0
  164. package/dist/core/fields/builders/form-field-builder.d.ts +46 -2
  165. package/dist/core/fields/builders/form-field-builder.js +47 -2
  166. package/dist/core/fields/builders/index.d.ts +0 -2
  167. package/dist/core/fields/builders/index.js +0 -2
  168. package/dist/core/fields/builders/select-builder.d.ts +13 -2
  169. package/dist/core/fields/builders/select-builder.js +13 -1
  170. package/dist/core/fields/initial.d.ts +4 -1
  171. package/dist/core/fields/types.d.ts +5 -6
  172. package/dist/core/fields/util.d.ts +9 -14
  173. package/dist/core/fields/util.js +10 -15
  174. package/dist/core/fields/validate.d.ts +3 -0
  175. package/dist/core/fields/validate.js +3 -0
  176. package/dist/core/fields/walk.d.ts +4 -1
  177. package/dist/core/fields/walk.js +1 -2
  178. package/dist/core/handler.server.d.ts +5 -0
  179. package/dist/core/handler.server.js +15 -1
  180. package/dist/core/i18n/en/common.d.ts +28 -0
  181. package/dist/core/i18n/en/common.js +28 -0
  182. package/dist/core/i18n/en/errors.d.ts +6 -0
  183. package/dist/core/i18n/en/errors.js +6 -0
  184. package/dist/core/i18n/en/fields.d.ts +11 -0
  185. package/dist/core/i18n/en/fields.js +12 -1
  186. package/dist/core/i18n/fr/common.d.ts +28 -0
  187. package/dist/core/i18n/fr/common.js +29 -0
  188. package/dist/core/i18n/fr/errors.d.ts +6 -0
  189. package/dist/core/i18n/fr/errors.js +6 -0
  190. package/dist/core/i18n/fr/fields.d.ts +11 -0
  191. package/dist/core/i18n/fr/fields.js +12 -1
  192. package/dist/core/i18n/index.d.ts +1 -0
  193. package/dist/core/i18n/index.js +7 -0
  194. package/dist/core/i18n/register.server.js +1 -1
  195. package/dist/core/locale/types.d.ts +2 -6
  196. package/dist/core/logger.server.js +8 -2
  197. package/dist/core/panel/configure.js +2 -2
  198. package/dist/core/panel/types.d.ts +4 -2
  199. package/dist/core/pipeline/build-document.server.d.ts +2 -2
  200. package/dist/core/pipeline/build-document.server.js +2 -2
  201. package/dist/core/pipeline/build.server.js +2 -12
  202. package/dist/core/{prototype/shared/versions/hooks → pipeline}/fallback-data-from-original.d.ts +6 -6
  203. package/dist/core/{prototype/shared/versions/hooks → pipeline}/fallback-data-from-original.js +5 -5
  204. package/dist/core/pipeline/hooks/original-config-map.server.d.ts +3 -2
  205. package/dist/core/pipeline/hooks/original-config-map.server.js +3 -2
  206. package/dist/core/pipeline/hooks/process-document-fields.server.d.ts +2 -1
  207. package/dist/core/pipeline/hooks/process-document-fields.server.js +4 -9
  208. package/dist/core/pipeline/hooks/sort-document-props.server.js +4 -3
  209. package/dist/core/pipeline/hooks/validate-fields.server.d.ts +15 -1
  210. package/dist/core/pipeline/hooks/validate-fields.server.js +142 -47
  211. package/dist/core/pipeline/persist/blocks/extract.server.d.ts +5 -0
  212. package/dist/core/pipeline/persist/blocks/extract.server.js +5 -0
  213. package/dist/core/pipeline/persist/blocks/index.server.d.ts +3 -7
  214. package/dist/core/pipeline/persist/blocks/index.server.js +3 -8
  215. package/dist/core/pipeline/persist/relations/diff.server.js +1 -0
  216. package/dist/core/pipeline/persist/relations/extract.server.d.ts +1 -0
  217. package/dist/core/pipeline/persist/relations/extract.server.js +2 -0
  218. package/dist/core/pipeline/persist/relations/index.server.d.ts +6 -0
  219. package/dist/core/pipeline/persist/relations/index.server.js +31 -8
  220. package/dist/core/pipeline/persist/repeatable.server.d.ts +21 -12
  221. package/dist/core/pipeline/persist/repeatable.server.js +28 -4
  222. package/dist/core/pipeline/persist/tree/extract.server.d.ts +5 -0
  223. package/dist/core/pipeline/persist/tree/extract.server.js +6 -8
  224. package/dist/core/pipeline/persist/tree/index.server.d.ts +5 -0
  225. package/dist/core/pipeline/persist/tree/index.server.js +5 -0
  226. package/dist/core/pipeline/populate-relations.server.d.ts +1 -0
  227. package/dist/core/pipeline/populate-relations.server.js +1 -0
  228. package/dist/core/pipeline/run.server.d.ts +26 -17
  229. package/dist/core/pipeline/run.server.js +51 -9
  230. package/dist/core/pipeline/types.d.ts +30 -7
  231. package/dist/core/pipeline/without-denied-fields.d.ts +15 -0
  232. package/dist/core/pipeline/without-denied-fields.js +53 -2
  233. package/dist/core/plugins/api-init/index.server.d.ts +8 -0
  234. package/dist/core/plugins/api-init/index.server.js +8 -0
  235. package/dist/core/plugins/cache/HeaderButton.svelte +15 -6
  236. package/dist/core/plugins/cache/cache.server.d.ts +9 -0
  237. package/dist/core/plugins/cache/cache.server.js +9 -0
  238. package/dist/core/plugins/cache/handler.server.d.ts +5 -0
  239. package/dist/core/plugins/cache/handler.server.js +5 -0
  240. package/dist/core/plugins/cache/module.server.d.ts +4 -19
  241. package/dist/core/plugins/cache/module.server.js +5 -1
  242. package/dist/core/plugins/cache/types.d.ts +6 -0
  243. package/dist/core/plugins/index.d.ts +1 -0
  244. package/dist/core/plugins/index.js +1 -0
  245. package/dist/core/plugins/mailer/index.server.d.ts +5 -2
  246. package/dist/core/plugins/mailer/index.server.js +4 -0
  247. package/dist/core/plugins/plugins.server.d.ts +1 -0
  248. package/dist/core/plugins/plugins.server.js +1 -0
  249. package/dist/core/plugins/sse/client.js +4 -0
  250. package/dist/core/prototype/area/definition.server.d.ts +2 -3
  251. package/dist/core/prototype/area/definition.server.js +2 -3
  252. package/dist/core/prototype/area/operations/find.d.ts +5 -0
  253. package/dist/core/prototype/area/operations/find.js +5 -0
  254. package/dist/core/prototype/area/rest/endpoint.server.d.ts +3 -3
  255. package/dist/core/prototype/area/rest/endpoint.server.js +3 -3
  256. package/dist/core/prototype/area/rest/get.server.d.ts +2 -1
  257. package/dist/core/prototype/area/rest/get.server.js +2 -1
  258. package/dist/core/prototype/area/rest/update.server.d.ts +2 -1
  259. package/dist/core/prototype/area/rest/update.server.js +2 -1
  260. package/dist/core/prototype/collection/api.server.d.ts +15 -1
  261. package/dist/core/prototype/collection/api.server.js +16 -0
  262. package/dist/core/prototype/collection/augment-label.d.ts +9 -0
  263. package/dist/core/prototype/collection/augment-label.js +9 -0
  264. package/dist/core/prototype/collection/definition.d.ts +1 -1
  265. package/dist/core/prototype/collection/definition.js +1 -1
  266. package/dist/core/prototype/collection/hooks/merge-with-initial.server.d.ts +3 -3
  267. package/dist/core/prototype/collection/hooks/merge-with-initial.server.js +3 -3
  268. package/dist/core/prototype/collection/hooks.server.d.ts +2 -6
  269. package/dist/core/prototype/collection/hooks.server.js +8 -9
  270. package/dist/core/prototype/collection/nested/hooks/add-children.server.d.ts +3 -1
  271. package/dist/core/prototype/collection/nested/hooks/add-children.server.js +19 -11
  272. package/dist/core/prototype/collection/nested/hooks/index.server.d.ts +1 -0
  273. package/dist/core/prototype/collection/nested/hooks/index.server.js +1 -0
  274. package/dist/core/prototype/collection/nested/hooks/place-at-end.server.d.ts +10 -0
  275. package/dist/core/prototype/collection/nested/hooks/place-at-end.server.js +24 -0
  276. package/dist/core/prototype/collection/nested/move.server.d.ts +35 -0
  277. package/dist/core/prototype/collection/nested/move.server.js +74 -0
  278. package/dist/core/prototype/collection/operations/count.d.ts +19 -0
  279. package/dist/core/prototype/collection/operations/count.js +23 -0
  280. package/dist/core/prototype/collection/operations/create.d.ts +16 -0
  281. package/dist/core/prototype/collection/operations/create.js +46 -26
  282. package/dist/core/prototype/collection/operations/delete-by-id.d.ts +5 -0
  283. package/dist/core/prototype/collection/operations/delete-by-id.js +5 -0
  284. package/dist/core/prototype/collection/operations/delete.d.ts +8 -0
  285. package/dist/core/prototype/collection/operations/delete.js +8 -0
  286. package/dist/core/prototype/collection/operations/duplicate.d.ts +8 -0
  287. package/dist/core/prototype/collection/operations/duplicate.js +12 -0
  288. package/dist/core/prototype/collection/operations/find-by-id.d.ts +5 -0
  289. package/dist/core/prototype/collection/operations/find-by-id.js +5 -0
  290. package/dist/core/prototype/collection/operations/find.d.ts +6 -1
  291. package/dist/core/prototype/collection/operations/find.js +7 -2
  292. package/dist/core/prototype/collection/rest/count.server.d.ts +5 -0
  293. package/dist/core/prototype/collection/rest/count.server.js +12 -0
  294. package/dist/core/prototype/collection/rest/create.server.d.ts +2 -1
  295. package/dist/core/prototype/collection/rest/create.server.js +2 -1
  296. package/dist/core/prototype/collection/rest/delete-by-id.server.d.ts +1 -3
  297. package/dist/core/prototype/collection/rest/delete-by-id.server.js +1 -3
  298. package/dist/core/prototype/collection/rest/get-by-id.server.d.ts +2 -1
  299. package/dist/core/prototype/collection/rest/get-by-id.server.js +2 -1
  300. package/dist/core/prototype/collection/rest/get.server.d.ts +2 -1
  301. package/dist/core/prototype/collection/rest/get.server.js +2 -1
  302. package/dist/core/prototype/collection/rest/index.server.js +5 -0
  303. package/dist/core/prototype/collection/rest/lock.server.js +0 -5
  304. package/dist/core/prototype/collection/rest/move.server.d.ts +11 -0
  305. package/dist/core/prototype/collection/rest/move.server.js +34 -0
  306. package/dist/core/prototype/collection/rest/update-by-id.server.d.ts +3 -1
  307. package/dist/core/prototype/collection/rest/update-by-id.server.js +3 -1
  308. package/dist/core/prototype/collection/thumbnail/hooks/set-document-thumbnail.server.js +17 -9
  309. package/dist/core/prototype/collection/upload/boot/index.server.d.ts +3 -5
  310. package/dist/core/prototype/collection/upload/boot/index.server.js +3 -5
  311. package/dist/core/prototype/collection/upload/directories/configure.server.js +1 -2
  312. package/dist/core/prototype/collection/upload/directories/create.server.d.ts +15 -0
  313. package/dist/core/prototype/collection/upload/directories/create.server.js +19 -0
  314. package/dist/core/prototype/collection/upload/directories/derive.js +2 -2
  315. package/dist/core/prototype/collection/upload/directories/pipeline.server.js +5 -4
  316. package/dist/core/prototype/collection/upload/disk/save.server.d.ts +9 -5
  317. package/dist/core/prototype/collection/upload/disk/save.server.js +19 -6
  318. package/dist/core/prototype/collection/upload/ensure.server.d.ts +2 -7
  319. package/dist/core/prototype/collection/upload/ensure.server.js +2 -7
  320. package/dist/core/prototype/collection/upload/handler.server.d.ts +4 -0
  321. package/dist/core/prototype/collection/upload/handler.server.js +13 -4
  322. package/dist/core/prototype/collection/upload/hooks/convert-base64.server.d.ts +3 -10
  323. package/dist/core/prototype/collection/upload/hooks/convert-base64.server.js +5 -18
  324. package/dist/core/prototype/collection/upload/hooks/delete-folder-contents.server.d.ts +10 -0
  325. package/dist/core/prototype/collection/upload/hooks/delete-folder-contents.server.js +30 -0
  326. package/dist/core/prototype/collection/upload/hooks/extract-path.server.d.ts +1 -1
  327. package/dist/core/prototype/collection/upload/hooks/extract-path.server.js +1 -1
  328. package/dist/core/prototype/collection/upload/hooks/handle-path-creation.server.js +8 -20
  329. package/dist/core/prototype/collection/upload/hooks/index.server.d.ts +2 -5
  330. package/dist/core/prototype/collection/upload/hooks/index.server.js +2 -5
  331. package/dist/core/prototype/collection/upload/hooks/populate-sizes.server.d.ts +4 -2
  332. package/dist/core/prototype/collection/upload/hooks/populate-sizes.server.js +18 -19
  333. package/dist/core/prototype/collection/upload/hooks/process-file-upload.server.d.ts +3 -1
  334. package/dist/core/prototype/collection/upload/hooks/process-file-upload.server.js +16 -3
  335. package/dist/core/prototype/collection/upload/hooks/update-directory-children.server.js +3 -2
  336. package/dist/core/prototype/collection/upload/module.d.ts +4 -2
  337. package/dist/core/prototype/collection/upload/module.js +12 -17
  338. package/dist/core/prototype/collection/upload/module.server.d.ts +3 -4
  339. package/dist/core/prototype/collection/upload/module.server.js +3 -4
  340. package/dist/core/prototype/collection/upload/types.d.ts +21 -6
  341. package/dist/core/prototype/collection/upload/util/client.d.ts +2 -2
  342. package/dist/core/prototype/collection/upload/util/client.js +2 -2
  343. package/dist/core/prototype/collection/upload/util/config.d.ts +1 -0
  344. package/dist/core/prototype/collection/upload/util/converter.server.d.ts +5 -0
  345. package/dist/core/prototype/collection/upload/util/converter.server.js +16 -24
  346. package/dist/core/prototype/collection/upload/util/mime.d.ts +60 -0
  347. package/dist/core/prototype/collection/upload/util/mime.js +94 -4
  348. package/dist/core/prototype/collection/upload/util/path.d.ts +5 -1
  349. package/dist/core/prototype/collection/upload/util/path.js +9 -12
  350. package/dist/core/prototype/define.d.ts +14 -0
  351. package/dist/core/prototype/define.js +14 -0
  352. package/dist/core/prototype/shared/title/find-title.js +1 -0
  353. package/dist/core/prototype/shared/title/select.d.ts +2 -2
  354. package/dist/core/prototype/shared/title/select.js +2 -2
  355. package/dist/core/prototype/shared/url/hooks/set-live-url.server.js +2 -3
  356. package/dist/core/prototype/shared/versions/augment.js +8 -4
  357. package/dist/core/prototype/shared/versions/hooks/handle-new-version.server.js +6 -2
  358. package/dist/core/prototype/shared/versions/validate-config.server.js +1 -2
  359. package/dist/core/prototype/types.d.ts +0 -5
  360. package/dist/core/rime.server.d.ts +3 -2
  361. package/dist/core/rime.server.js +3 -2
  362. package/dist/core/routes/context.server.d.ts +11 -0
  363. package/dist/core/routes/context.server.js +11 -0
  364. package/dist/core/routes/handler.server.d.ts +4 -3
  365. package/dist/core/routes/handler.server.js +4 -3
  366. package/dist/core/routes/panel-navigation.d.ts +4 -5
  367. package/dist/core/routes/panel-navigation.js +4 -8
  368. package/dist/core/routes/util.d.ts +8 -2
  369. package/dist/core/routes/util.js +10 -4
  370. package/dist/fields/blocks/component/AddBlockButton.svelte +1 -0
  371. package/dist/fields/blocks/component/Blocks.svelte +15 -11
  372. package/dist/fields/blocks/component/focus/BlocksFocus.svelte +22 -10
  373. package/dist/fields/blocks/component/focus/LayersList.svelte +5 -0
  374. package/dist/fields/blocks/component/focus/Palette.svelte +0 -1
  375. package/dist/fields/blocks/component/focus/Renders.svelte +5 -4
  376. package/dist/fields/blocks/component/focus/Renders.svelte.d.ts +2 -1
  377. package/dist/fields/blocks/component/focus/focus.svelte.js +42 -13
  378. package/dist/fields/blocks/component/picker/BlockPicker.svelte +2 -2
  379. package/dist/fields/blocks/index.d.ts +16 -0
  380. package/dist/fields/blocks/index.js +15 -2
  381. package/dist/fields/checkbox/component/Checkbox.svelte +1 -0
  382. package/dist/fields/combobox/component/ComboBox.svelte +3 -2
  383. package/dist/fields/combobox/index.d.ts +1 -0
  384. package/dist/fields/combobox/index.js +1 -0
  385. package/dist/fields/component/index.d.ts +3 -0
  386. package/dist/fields/component/index.js +3 -0
  387. package/dist/fields/date/component/Date.svelte +8 -5
  388. package/dist/fields/date/index.d.ts +1 -0
  389. package/dist/fields/date/index.js +1 -0
  390. package/dist/fields/email/component/Email.svelte +8 -5
  391. package/dist/fields/email/index.d.ts +1 -0
  392. package/dist/fields/email/index.js +1 -0
  393. package/dist/fields/group/component/Group.svelte +8 -15
  394. package/dist/fields/group/index.d.ts +7 -1
  395. package/dist/fields/group/index.js +5 -4
  396. package/dist/fields/link/component/Link.svelte +19 -8
  397. package/dist/fields/link/component/RessourceInput.svelte +68 -47
  398. package/dist/fields/link/index.d.ts +12 -0
  399. package/dist/fields/link/index.js +14 -1
  400. package/dist/fields/number/component/Number.svelte +1 -0
  401. package/dist/fields/number/index.js +5 -3
  402. package/dist/fields/radio/component/Radio.svelte +12 -3
  403. package/dist/fields/radio/index.d.ts +1 -0
  404. package/dist/fields/radio/index.js +1 -0
  405. package/dist/fields/relation/component/Cell.svelte +4 -4
  406. package/dist/fields/relation/component/Relation.svelte +92 -131
  407. package/dist/fields/relation/component/Relation.svelte.d.ts +0 -1
  408. package/dist/fields/relation/component/RelationInline.svelte +22 -27
  409. package/dist/fields/relation/component/default/Default.svelte +50 -19
  410. package/dist/fields/relation/component/default/Default.svelte.d.ts +12 -1
  411. package/dist/fields/relation/component/types.d.ts +5 -3
  412. package/dist/fields/relation/component/upload/Browse.svelte +50 -41
  413. package/dist/fields/relation/component/upload/Browse.svelte.d.ts +6 -1
  414. package/dist/fields/relation/component/upload/Upload.svelte +8 -3
  415. package/dist/fields/relation/component/upload/Upload.svelte.d.ts +0 -1
  416. package/dist/fields/relation/index.d.ts +27 -10
  417. package/dist/fields/relation/index.js +16 -0
  418. package/dist/fields/relation/populate.js +1 -0
  419. package/dist/fields/relation/query.d.ts +22 -0
  420. package/dist/fields/relation/query.js +29 -0
  421. package/dist/fields/relation/relation.test-d.js +11 -0
  422. package/dist/fields/repeatable/RepeatableActions.svelte +4 -0
  423. package/dist/fields/repeatable/RepeatableActions.svelte.d.ts +4 -0
  424. package/dist/fields/repeatable.js +3 -21
  425. package/dist/fields/rich-text/client.d.ts +26 -0
  426. package/dist/fields/rich-text/client.js +26 -0
  427. package/dist/fields/rich-text/component/RichTextInline.svelte +2 -9
  428. package/dist/fields/rich-text/component/RichTextInline.svelte.d.ts +2 -9
  429. package/dist/fields/rich-text/component/bubble-menu/bubble-menu.svelte +2 -0
  430. package/dist/fields/rich-text/component/bubble-menu/icon-button/icon-button.css +0 -1
  431. package/dist/fields/rich-text/component/bubble-menu/icon-button/icon-button.svelte +1 -2
  432. package/dist/fields/rich-text/component/bubble-menu/node-selector/node-selector.css +0 -1
  433. package/dist/fields/rich-text/component/bubble-menu/node-selector/node-selector.svelte +9 -6
  434. package/dist/fields/rich-text/component/context.svelte.d.ts +1 -0
  435. package/dist/fields/rich-text/component/context.svelte.js +1 -0
  436. package/dist/fields/rich-text/component/drag-handle/drag-handle.css +0 -1
  437. package/dist/fields/rich-text/component/drag-handle/drag-handle.svelte +1 -0
  438. package/dist/fields/rich-text/component/styles/editor.css +0 -1
  439. package/dist/fields/rich-text/component/styles/field.css +10 -11
  440. package/dist/fields/rich-text/core/build-editor-config.d.ts +15 -6
  441. package/dist/fields/rich-text/core/build-editor-config.js +47 -66
  442. package/dist/fields/rich-text/core/extensions/current-node/current-node.css +1 -0
  443. package/dist/fields/rich-text/core/extensions/current-node/current-node.d.ts +2 -2
  444. package/dist/fields/rich-text/core/extensions/current-node/current-node.js +3 -4
  445. package/dist/fields/rich-text/core/extensions/drag-handle/drag-handle-plugin.d.ts +5 -0
  446. package/dist/fields/rich-text/core/extensions/drag-handle/drag-handle-plugin.js +40 -77
  447. package/dist/fields/rich-text/core/extensions/drag-handle/drag-handle.d.ts +1 -1
  448. package/dist/fields/rich-text/core/extensions/drag-handle/drag-handle.js +1 -1
  449. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/cloneElement.d.ts +4 -0
  450. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/cloneElement.js +5 -0
  451. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/dragHandler.d.ts +5 -0
  452. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/dragHandler.js +11 -13
  453. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/findNextElementFromCursor.d.ts +6 -8
  454. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/findNextElementFromCursor.js +9 -14
  455. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/getInnerCoords.d.ts +1 -0
  456. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/getInnerCoords.js +6 -5
  457. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/getOuterNode.d.ts +3 -1
  458. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/getOuterNode.js +8 -21
  459. package/dist/fields/rich-text/core/features/blockquote.js +5 -1
  460. package/dist/fields/rich-text/core/features/bold.js +0 -3
  461. package/dist/fields/rich-text/core/features/bullet-list.js +5 -1
  462. package/dist/fields/rich-text/core/features/fields/extension.d.ts +1 -0
  463. package/dist/fields/rich-text/core/features/fields/extension.js +1 -0
  464. package/dist/fields/rich-text/core/features/fields/fields-form.svelte +54 -0
  465. package/dist/fields/rich-text/core/features/fields/fields-form.svelte.d.ts +14 -0
  466. package/dist/fields/rich-text/core/features/fields/fields.svelte +30 -35
  467. package/dist/fields/rich-text/core/features/fields/index.d.ts +2 -0
  468. package/dist/fields/rich-text/core/features/fields/index.js +1 -0
  469. package/dist/fields/rich-text/core/features/heading.js +19 -68
  470. package/dist/fields/rich-text/core/features/hr/hr.css +1 -2
  471. package/dist/fields/rich-text/core/features/hr/hr.js +5 -1
  472. package/dist/fields/rich-text/core/features/index.d.ts +1 -0
  473. package/dist/fields/rich-text/core/features/index.js +1 -0
  474. package/dist/fields/rich-text/core/features/json-attribute.d.ts +1 -1
  475. package/dist/fields/rich-text/core/features/json-attribute.js +1 -1
  476. package/dist/fields/rich-text/core/features/link/component/link-selector.svelte +61 -58
  477. package/dist/fields/rich-text/core/features/link/component/link-selector.svelte.d.ts +3 -1
  478. package/dist/fields/rich-text/core/features/link/index.d.ts +5 -0
  479. package/dist/fields/rich-text/core/features/link/index.js +2 -14
  480. package/dist/fields/rich-text/core/features/ordered-list.js +5 -1
  481. package/dist/fields/rich-text/core/features/paragraph.js +5 -1
  482. package/dist/fields/rich-text/core/features/pick-dialog.svelte +16 -4
  483. package/dist/fields/rich-text/core/features/pick-dialog.svelte.d.ts +7 -3
  484. package/dist/fields/rich-text/core/features/resource/index.d.ts +1 -0
  485. package/dist/fields/rich-text/core/features/resource/index.js +1 -0
  486. package/dist/fields/rich-text/core/features/resource/resource-extension.d.ts +1 -0
  487. package/dist/fields/rich-text/core/features/resource/resource-extension.js +8 -6
  488. package/dist/fields/rich-text/core/features/resource/resource.svelte +38 -49
  489. package/dist/fields/rich-text/core/features/resource/types.d.ts +1 -0
  490. package/dist/fields/rich-text/core/features/upload/index.d.ts +1 -0
  491. package/dist/fields/rich-text/core/features/upload/index.js +2 -1
  492. package/dist/fields/rich-text/core/features/upload/upload-extension.d.ts +6 -0
  493. package/dist/fields/rich-text/core/features/upload/upload-extension.js +2 -2
  494. package/dist/fields/{relation/component → rich-text/core/features}/upload/upload.css +1 -2
  495. package/dist/fields/rich-text/core/features/upload/upload.svelte +47 -73
  496. package/dist/fields/rich-text/core/features/upload/upload.svelte.d.ts +1 -0
  497. package/dist/fields/rich-text/core/render-rich-text.svelte +30 -16
  498. package/dist/fields/rich-text/core/rich-text-editor-core.svelte +8 -3
  499. package/dist/fields/rich-text/core/rich-text-editor-core.svelte.d.ts +1 -0
  500. package/dist/fields/rich-text/core/svelte/constant.d.ts +1 -0
  501. package/dist/fields/rich-text/core/svelte/constant.js +1 -0
  502. package/dist/fields/rich-text/core/svelte/node-view-renderer.svelte.d.ts +10 -0
  503. package/dist/fields/rich-text/core/svelte/node-view-renderer.svelte.js +23 -6
  504. package/dist/fields/rich-text/core/svelte/node-view-wrapper.svelte +6 -2
  505. package/dist/fields/rich-text/core/svelte/node-view-wrapper.svelte.d.ts +1 -0
  506. package/dist/fields/rich-text/core/svelte/renderer.d.ts +1 -0
  507. package/dist/fields/rich-text/core/svelte/renderer.js +1 -0
  508. package/dist/fields/rich-text/core/types.d.ts +11 -0
  509. package/dist/fields/rich-text/index.d.ts +2 -0
  510. package/dist/fields/rich-text/index.js +12 -7
  511. package/dist/fields/rich-text/json.d.ts +6 -4
  512. package/dist/fields/rich-text/json.js +6 -4
  513. package/dist/fields/select/component/Select.svelte +37 -12
  514. package/dist/fields/select/index.d.ts +2 -1
  515. package/dist/fields/select/index.js +1 -0
  516. package/dist/fields/separator/index.d.ts +1 -0
  517. package/dist/fields/separator/index.js +1 -0
  518. package/dist/fields/slug/component/Slug.svelte +14 -13
  519. package/dist/fields/slug/index.d.ts +11 -0
  520. package/dist/fields/slug/index.js +11 -0
  521. package/dist/fields/tabs/component/Tabs.svelte +4 -7
  522. package/dist/fields/tabs/index.d.ts +10 -0
  523. package/dist/fields/tabs/index.js +10 -0
  524. package/dist/fields/text/component/TextInline.svelte +12 -10
  525. package/dist/fields/text/index.d.ts +7 -0
  526. package/dist/fields/text/index.js +9 -2
  527. package/dist/fields/textarea/index.d.ts +3 -0
  528. package/dist/fields/textarea/index.js +5 -2
  529. package/dist/fields/time/index.d.ts +1 -0
  530. package/dist/fields/time/index.js +4 -6
  531. package/dist/fields/toggle/component/Toggle.svelte +1 -0
  532. package/dist/fields/toggle/index.d.ts +1 -0
  533. package/dist/fields/toggle/index.js +1 -0
  534. package/dist/fields/tree/component/AddItemButton.svelte +3 -2
  535. package/dist/fields/tree/component/AddItemButton.svelte.d.ts +1 -1
  536. package/dist/fields/tree/component/Tree.svelte +16 -57
  537. package/dist/fields/tree/component/TreeBlock.svelte +26 -40
  538. package/dist/fields/tree/component/props.d.ts +3 -2
  539. package/dist/fields/tree/index.js +14 -2
  540. package/dist/fields/tree/util.js +0 -3
  541. package/dist/fields/types.d.ts +23 -1
  542. package/dist/index.d.ts +1 -0
  543. package/dist/index.js +1 -0
  544. package/dist/live/Consumer.svelte +6 -0
  545. package/dist/live/LiveEdit.svelte +23 -5
  546. package/dist/live/LiveEdit.svelte.d.ts +2 -1
  547. package/dist/live/Provider.svelte +5 -1
  548. package/dist/live/context.svelte.d.ts +3 -4
  549. package/dist/live/context.svelte.js +9 -6
  550. package/dist/panel/components/Root.svelte +7 -1
  551. package/dist/panel/components/fields/FieldsPreview.svelte +15 -1
  552. package/dist/panel/components/fields/Label.svelte +2 -0
  553. package/dist/panel/components/fields/RenderFields.svelte +12 -1
  554. package/dist/panel/components/fields/fieldset.svelte.d.ts +7 -1
  555. package/dist/panel/components/fields/fieldset.svelte.js +7 -1
  556. package/dist/panel/components/fields/setting.css +7 -0
  557. package/dist/panel/components/sections/auth/AuthForm.svelte +4 -1
  558. package/dist/panel/components/sections/collection/Avatar.svelte +1 -1
  559. package/dist/panel/components/sections/collection/bulk-upload/FileDrop.svelte +3 -0
  560. package/dist/panel/components/sections/collection/bulk-upload/PageDrop.svelte +11 -1
  561. package/dist/panel/components/sections/collection/folder/FolderEdit.svelte +10 -1
  562. package/dist/panel/components/sections/collection/folder/FolderWithActions.svelte +45 -34
  563. package/dist/panel/components/sections/collection/folder/Folders.svelte +1 -0
  564. package/dist/panel/components/sections/collection/grid/CollectionGrid.svelte +8 -3
  565. package/dist/panel/components/sections/collection/grid/CollectionGrid.svelte.d.ts +2 -1
  566. package/dist/panel/components/sections/collection/grid/create-directory-dialog/CreateDirectoryDialog.svelte +3 -1
  567. package/dist/panel/components/sections/collection/grid/grid-item/GridItem.svelte +4 -0
  568. package/dist/panel/components/sections/collection/header/ButtonCreate.svelte +1 -5
  569. package/dist/panel/components/sections/collection/header/SearchInput.svelte +2 -0
  570. package/dist/panel/components/sections/collection/header/SelectUI.svelte +25 -5
  571. package/dist/panel/components/sections/collection/list/CollectionList.svelte +4 -1
  572. package/dist/panel/components/sections/collection/list/row/Row.svelte +16 -16
  573. package/dist/panel/components/sections/collection/list/row/Row.svelte.d.ts +4 -4
  574. package/dist/panel/components/sections/collection/tree/CollectionTree.svelte +4 -80
  575. package/dist/panel/components/sections/collection/tree/CollectionTreeNode.svelte +18 -8
  576. package/dist/panel/components/sections/collection/tree/sortable.d.ts +11 -0
  577. package/dist/panel/components/sections/collection/tree/sortable.js +45 -0
  578. package/dist/panel/components/sections/collection/upload-thumb-cell/UploadThumbCell.svelte +5 -3
  579. package/dist/panel/components/sections/collection/upload-thumb-cell/UploadThumbCell.svelte.d.ts +0 -1
  580. package/dist/panel/components/sections/commands/CommandPalette.svelte +5 -0
  581. package/dist/panel/components/sections/document/AuthAPIKeyDialog.svelte +14 -4
  582. package/dist/panel/components/sections/document/AuthAPIKeyDialog.svelte.d.ts +2 -0
  583. package/dist/panel/components/sections/document/AuthFooter.svelte +37 -31
  584. package/dist/panel/components/sections/document/AuthFooter.svelte.d.ts +0 -2
  585. package/dist/panel/components/sections/document/ButtonSave.svelte +2 -6
  586. package/dist/panel/components/sections/document/ButtonSave.svelte.d.ts +1 -3
  587. package/dist/panel/components/sections/document/ButtonStatus.svelte +24 -11
  588. package/dist/panel/components/sections/document/ChangeSlugDialog.svelte +16 -0
  589. package/dist/panel/components/sections/document/CurrentlyEdited.svelte +5 -3
  590. package/dist/panel/components/sections/document/CurrentlyEdited.svelte.d.ts +1 -0
  591. package/dist/panel/components/sections/document/Document.svelte +29 -18
  592. package/dist/panel/components/sections/document/DocumentChildren.svelte +48 -41
  593. package/dist/panel/components/sections/document/Header.svelte +13 -11
  594. package/dist/panel/components/sections/document/Settings.svelte +127 -157
  595. package/dist/panel/components/sections/document/Versions.svelte +11 -2
  596. package/dist/panel/components/sections/document/upload-header/UploadHeader.svelte +32 -13
  597. package/dist/panel/components/sections/document/upload-header/UploadHeader.svelte.d.ts +2 -0
  598. package/dist/panel/components/sections/document/upload-header/drop-zone/DropZone.svelte +24 -10
  599. package/dist/panel/components/sections/document/upload-header/drop-zone/DropZone.svelte.d.ts +3 -0
  600. package/dist/panel/components/sections/live/LiveEditPanel.svelte +11 -5
  601. package/dist/panel/components/sections/live/LiveEditPanel.svelte.d.ts +10 -3
  602. package/dist/panel/components/sections/live/LiveFloatingUI.svelte +18 -2
  603. package/dist/panel/components/sections/live/LiveFloatingUI.svelte.d.ts +3 -0
  604. package/dist/panel/components/ui/button/button.svelte +0 -3
  605. package/dist/panel/components/ui/calendar/calendar.css +0 -1
  606. package/dist/panel/components/ui/calendar/calendar.svelte.d.ts +1 -1
  607. package/dist/panel/components/ui/card-resource/card-resource.svelte +17 -3
  608. package/dist/panel/components/ui/card-resource/card-resource.svelte.d.ts +2 -0
  609. package/dist/panel/components/ui/checkbox/checkbox.svelte.d.ts +1 -1
  610. package/dist/panel/components/ui/command/command-count.css +6 -0
  611. package/dist/panel/components/ui/command/command-count.svelte +15 -0
  612. package/dist/panel/components/ui/command/command-count.svelte.d.ts +9 -0
  613. package/dist/panel/components/ui/command/command-dialog.css +2 -0
  614. package/dist/panel/components/ui/command/command-input-select.svelte +5 -0
  615. package/dist/panel/components/ui/command/filter.d.ts +10 -0
  616. package/dist/panel/components/ui/command/filter.js +11 -0
  617. package/dist/panel/components/ui/command/index.d.ts +2 -1
  618. package/dist/panel/components/ui/command/index.js +2 -1
  619. package/dist/panel/components/ui/context-menu/context-menu.css +2 -2
  620. package/dist/panel/components/ui/dialog/dialog-content.css +4 -1
  621. package/dist/panel/components/ui/dialog/dialog-content.svelte +8 -1
  622. package/dist/panel/components/ui/dialog/dialog-overlay.css +2 -1
  623. package/dist/panel/components/ui/dropdown-menu/dropdown-menu-content.css +2 -2
  624. package/dist/panel/components/ui/input/input.svelte +3 -0
  625. package/dist/panel/components/ui/language-switcher/LanguageSwitcher.svelte +1 -1
  626. package/dist/panel/components/ui/layer/layer.svelte.d.ts +22 -0
  627. package/dist/panel/components/ui/layer/layer.svelte.js +37 -0
  628. package/dist/panel/components/ui/nav/Nav.svelte +4 -9
  629. package/dist/panel/components/ui/nav/NavGroup.svelte +6 -6
  630. package/dist/panel/components/ui/nav/NavItem.svelte +1 -0
  631. package/dist/panel/components/ui/nav/NavItem.svelte.d.ts +1 -0
  632. package/dist/panel/components/ui/nav/UserButton.svelte +4 -4
  633. package/dist/panel/components/ui/page-header/PageHeader.svelte +1 -5
  634. package/dist/panel/components/ui/page-header/PageHeader.svelte.d.ts +1 -0
  635. package/dist/panel/components/ui/popover/popover-content.css +2 -1
  636. package/dist/panel/components/ui/radio-row-group/radio-row-group.css +0 -1
  637. package/dist/panel/components/ui/scroll-area/scroll-area-scrollbar.svelte +3 -4
  638. package/dist/panel/components/ui/scroll-area/scroll-area-scrollbar.svelte.d.ts +1 -1
  639. package/dist/panel/components/ui/scroll-area/scroll-area.css +0 -6
  640. package/dist/panel/components/ui/scroll-area/scroll-area.svelte +4 -1
  641. package/dist/panel/components/ui/sheet/index.d.ts +1 -1
  642. package/dist/panel/components/ui/sheet/sheet-content.svelte +13 -2
  643. package/dist/panel/components/ui/sheet/sheet-content.svelte.d.ts +3 -0
  644. package/dist/panel/components/ui/sheet/sheet.css +11 -43
  645. package/dist/panel/components/ui/sonner/sonner.css +5 -0
  646. package/dist/panel/components/ui/switch/switch.svelte.d.ts +1 -1
  647. package/dist/panel/components/ui/tag/tag.svelte +8 -1
  648. package/dist/panel/components/ui/tooltip/tooltip-content.svelte +1 -1
  649. package/dist/panel/components/ui/tree/tree-rows.css +1 -8
  650. package/dist/panel/context/api-proxy.svelte.d.ts +2 -0
  651. package/dist/panel/context/api-proxy.svelte.js +30 -4
  652. package/dist/panel/context/blocks-ops.d.ts +6 -0
  653. package/dist/panel/context/blocks-ops.js +6 -0
  654. package/dist/panel/context/bulk-delete.d.ts +4 -3
  655. package/dist/panel/context/bulk-delete.js +13 -7
  656. package/dist/panel/context/collection.svelte.d.ts +10 -22
  657. package/dist/panel/context/collection.svelte.js +73 -115
  658. package/dist/panel/context/commands.svelte.js +5 -0
  659. package/dist/panel/context/config.svelte.js +2 -0
  660. package/dist/panel/context/createContext.svelte.d.ts +1 -0
  661. package/dist/panel/context/createContext.svelte.js +1 -0
  662. package/dist/panel/context/documentForm.svelte.d.ts +4 -2
  663. package/dist/panel/context/documentForm.svelte.js +87 -159
  664. package/dist/panel/context/errors.svelte.d.ts +8 -0
  665. package/dist/panel/context/errors.svelte.js +8 -0
  666. package/dist/panel/context/form.svelte.d.ts +8 -1
  667. package/dist/panel/context/form.svelte.js +37 -40
  668. package/dist/panel/context/livePanel.svelte.d.ts +3 -0
  669. package/dist/panel/context/locale.svelte.js +3 -0
  670. package/dist/panel/context/nav.svelte.js +9 -21
  671. package/dist/panel/context/tree-ops.d.ts +14 -0
  672. package/dist/panel/context/tree-ops.js +70 -0
  673. package/dist/panel/context/versions.svelte.d.ts +6 -0
  674. package/dist/panel/context/versions.svelte.js +18 -0
  675. package/dist/panel/index.d.ts +1 -10
  676. package/dist/panel/pages/area/Area.svelte +1 -1
  677. package/dist/panel/pages/area/actions.server.js +1 -0
  678. package/dist/panel/pages/area/load.server.d.ts +1 -0
  679. package/dist/panel/pages/area/load.server.js +1 -1
  680. package/dist/panel/pages/auth/forgot-password/ForgotPassword.svelte +23 -16
  681. package/dist/panel/pages/auth/forgot-password/load.server.d.ts +1 -0
  682. package/dist/panel/pages/auth/forgot-password/load.server.js +3 -5
  683. package/dist/panel/pages/auth/image.server.d.ts +6 -0
  684. package/dist/panel/pages/auth/image.server.js +19 -0
  685. package/dist/panel/pages/auth/reset-password/ResetPassword.svelte +22 -15
  686. package/dist/panel/pages/auth/reset-password/load.server.d.ts +3 -0
  687. package/dist/panel/pages/auth/reset-password/load.server.js +5 -5
  688. package/dist/panel/pages/auth/sign-in/actions.server.js +33 -25
  689. package/dist/panel/pages/auth/sign-in/load.server.d.ts +4 -0
  690. package/dist/panel/pages/auth/sign-in/load.server.js +6 -5
  691. package/dist/panel/pages/collection/Collection.svelte.d.ts +1 -1
  692. package/dist/panel/pages/collection/CollectionPage.svelte +31 -27
  693. package/dist/panel/pages/collection/CollectionPage.svelte.d.ts +1 -1
  694. package/dist/panel/pages/collection/load.server.d.ts +5 -2
  695. package/dist/panel/pages/collection/load.server.js +53 -54
  696. package/dist/panel/pages/collection-document/CollectionDocument.svelte +1 -1
  697. package/dist/panel/pages/collection-document/actions.server.js +3 -11
  698. package/dist/panel/pages/collection-document/load.server.d.ts +5 -0
  699. package/dist/panel/pages/collection-document/load.server.js +10 -3
  700. package/dist/panel/pages/dashboard/DashboardRow.svelte +13 -0
  701. package/dist/panel/pages/dashboard/load.server.d.ts +3 -0
  702. package/dist/panel/pages/dashboard/load.server.js +19 -8
  703. package/dist/panel/pages/live/Live.svelte +45 -45
  704. package/dist/panel/pages/live/load.server.d.ts +5 -0
  705. package/dist/panel/pages/live/load.server.js +5 -0
  706. package/dist/panel/pages/shared/DocumentPage.svelte +9 -5
  707. package/dist/panel/pages/shared/DocumentPage.svelte.d.ts +0 -1
  708. package/dist/panel/style/font.css +3 -3
  709. package/dist/panel/style/index.css +23 -8
  710. package/dist/panel/style/palette.css +1 -1
  711. package/dist/panel/style/size.css +1 -0
  712. package/dist/panel/style/z-index.css +18 -0
  713. package/dist/panel/types.d.ts +0 -1
  714. package/dist/panel/util/Sortable.d.ts +6 -1
  715. package/dist/panel/util/Sortable.js +6 -1
  716. package/dist/panel/util/auth.d.ts +18 -0
  717. package/dist/panel/util/auth.js +25 -0
  718. package/dist/panel/util/candidates.svelte.d.ts +118 -0
  719. package/dist/panel/util/candidates.svelte.js +176 -0
  720. package/dist/panel/util/count.d.ts +19 -0
  721. package/dist/panel/util/count.js +20 -0
  722. package/dist/panel/util/dataError.d.ts +1 -0
  723. package/dist/panel/util/dataError.js +1 -0
  724. package/dist/panel/util/storage.d.ts +13 -0
  725. package/dist/panel/util/storage.js +37 -0
  726. package/dist/panel/util/time.d.ts +7 -1
  727. package/dist/panel/util/time.js +19 -5
  728. package/dist/panel/util/upload-file.d.ts +0 -8
  729. package/dist/panel/util/upload-file.js +6 -12
  730. package/dist/server.js +3 -0
  731. package/dist/util/form-data.d.ts +3 -3
  732. package/dist/util/form-data.js +4 -2
  733. package/dist/util/function.d.ts +7 -6
  734. package/dist/util/function.js +7 -6
  735. package/dist/util/object.d.ts +10 -11
  736. package/dist/util/object.js +21 -55
  737. package/dist/util/random.d.ts +8 -12
  738. package/dist/util/random.js +34 -88
  739. package/dist/util/string.js +76 -114
  740. package/dist/util/types.d.ts +2 -0
  741. package/package.json +17 -15
  742. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/getComputedStyle.d.ts +0 -1
  743. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/getComputedStyle.js +0 -4
  744. package/dist/fields/rich-text/core/features/link/component/link-selector.css +0 -0
  745. package/dist/fields/rich-text/core/features/resource/resource.css +0 -0
  746. package/dist/panel/style/util.css +0 -3
  747. package/dist/panel/util/once.svelte.d.ts +0 -3
  748. package/dist/panel/util/once.svelte.js +0 -12
@@ -3,7 +3,7 @@ import { Hooks } from '../../pipeline/define-hook.js';
3
3
  import { dev } from '$app/env';
4
4
  import { RimeError, RimeFormError } from '../../errors/index.js';
5
5
  import { access } from '../access.js';
6
- import { t__ } from '../../i18n/index.js';
6
+ import { deleteAuthApiKey, deleteAuthUser } from '../better-auth-tables.server.js';
7
7
  import { BETTER_AUTH_ROLES } from '../constant.server.js';
8
8
  /** better-auth makes a user with no credential account when the password is missing. */
9
9
  const requirePassword = (data) => {
@@ -11,200 +11,147 @@ const requirePassword = (data) => {
11
11
  throw new RimeFormError({ password: RimeFormError.REQUIRED_FIELD });
12
12
  };
13
13
  /**
14
- * Create a better-auth user before a document creation
14
+ * Which way a new auth document gets its better-auth user. First match wins:
15
+ *
16
+ * ```
17
+ * init the dev-only init: better-auth made the first admin, the document copies its id
18
+ * admin a rime admin creates a user of any auth collection but an api-key one
19
+ * staff a staff member creates a user of any auth collection but an api-key one
20
+ * signup better-auth's `/sign-up/email`: better-auth made the user, and its after-hook calls
21
+ * this create with the new `authUserId`
22
+ * apiKey a signed-in caller with a better-auth user creates an api-key document
23
+ * ```
24
+ *
25
+ * `undefined` for anything else: an anonymous `POST /api/staff`, say. An `authUserId` sent
26
+ * outside a sign-up takes no part in the choice.
27
+ */
28
+ const creationPath = ({ config, event, data }) => {
29
+ const isApiKey = config.auth?.type === 'apiKey';
30
+ const { user, betterAuthUser } = event.locals;
31
+ if (event.locals.isInit && dev)
32
+ return 'init';
33
+ if (access.isAdmin(user) && !isApiKey)
34
+ return 'admin';
35
+ if (user?.isStaff && !isApiKey)
36
+ return 'staff';
37
+ if (event.locals.pendingSignInAfterSignUp && data.authUserId)
38
+ return 'signup';
39
+ if (isApiKey && user && betterAuthUser?.id)
40
+ return 'apiKey';
41
+ return undefined;
42
+ };
43
+ /**
44
+ * Makes the better-auth user of a new auth document, or copies the one better-auth already made,
45
+ * and puts its id on the document as `authUserId`. An api-key document gets a key, and the
46
+ * caller's better-auth user as its `authUserId`.
15
47
  */
16
48
  export const createBetterAuthUser = Hooks.beforeCreate(async function createBetterAuthUser(args) {
17
- const { config, event } = args;
18
- const { rime } = event.locals;
19
- const IS_API_KEY_OPERATION = config.auth?.type === 'apiKey';
20
- const ADMIN_ROLE_IN_DATA = Array.isArray(args.data.roles) && args.data.roles.includes(ROLES.ADMIN);
21
- const IS_CURRENT_USER_ADMIN = access.isAdmin(event.locals.user);
22
- const IS_CURRENT_USER_STAFF = Boolean(event.locals.user?.isStaff);
23
- const IS_STAFF_CREATION = config.slug === STAFF_SLUG;
24
- const ADMIN_ROLE_ALLOWED = IS_STAFF_CREATION &&
25
- Boolean(config.auth?.roles?.some((role) => (typeof role === 'string' ? role : role.value) === ROLES.ADMIN));
26
- const CREATION_CASE = {
27
- INIT: 'INIT',
28
- ADMIN_CREATE_USER: 'ADMIN_CREATE_USER',
29
- STAFF_CREATE_USER: 'STAFF_CREATE_USER',
30
- PUBLIC_SIGNUP: 'PUBLIC_SIGNUP',
31
- API_KEY_CREATION: 'API_KEY_CREATION'
32
- };
33
- /**
34
- * Which creation path this request is on. First match wins, read top to bottom.
35
- *
36
- * Written as a plain if/else-if chain: the conditions are not mutually exclusive and the
37
- * order between them is the actual logic, so it should read as control flow.
38
- */
39
- const resolveCase = () => {
40
- /**
41
- * 1. First-time Setup (Init)
42
- * - Description: Creating the first admin user when the system is initialized
43
- * - Actor: No authenticated user exists yet
44
- * - Auth Flow: better-auth's after-hook has made the user and set its 'admin'
45
- * role (`setAuthUserRole`); this case copies `data.authUserId`. It is the only
46
- * isSuperAdmin user.
47
- */
48
- if (Boolean(event.locals.isInit) && dev)
49
- return CREATION_CASE.INIT;
50
- /**
51
- * 2. Admin Creating Users
52
- * - Description: Admin creates any users through the panel
53
- * - Actor: Authenticated admin user
54
- * - Auth Flow:
55
- * - Use the admin plugin to create a user
56
- */
57
- if (IS_CURRENT_USER_ADMIN && !IS_API_KEY_OPERATION)
58
- return CREATION_CASE.ADMIN_CREATE_USER;
59
- /*
60
- * 3. Staff Creating users
61
- * - Description: Any panel user (staff collection) non admin, creating other users
62
- * - Actor: Authenticated staff user
63
- * - Auth Flow: the admin plugin creates the user with the 'staff' or 'user' role
64
- */
65
- if (IS_CURRENT_USER_STAFF && !IS_API_KEY_OPERATION)
66
- return CREATION_CASE.STAFF_CREATE_USER;
67
- /*
68
- * 4. Public User Signup
69
- * - Description: End users registering themselves or signing in with a social provider
70
- * - Actor: Unauthenticated visitor
71
- * - Auth Flow:
72
- * - User submits signup form
73
- * - Better-Auth creates user with 'user' role
74
- * - Better-Auth hook sets event.locals.pendingSignInAfterSignUp and calls
75
- * rime.collection(slug).create with the new authUserId
76
- * - An `authUserId` a caller sends without that flag takes no part in the choice
77
- */
78
- if (event.locals.pendingSignInAfterSignUp && args.data.authUserId) {
79
- return CREATION_CASE.PUBLIC_SIGNUP;
80
- }
81
- /**
82
- * 5. API Key Creation
83
- * - Description: Creating an API KEY
84
- * - Actor: Authenticated user
85
- * - Auth Flow:
86
- * - Admin creates API key user that forward current authenticated user
87
- * - API key generated and send by email
88
- */
89
- if (IS_API_KEY_OPERATION &&
90
- Boolean(event.locals.user) &&
91
- Boolean(event.locals.betterAuthUser?.id))
92
- return CREATION_CASE.API_KEY_CREATION;
93
- return undefined;
94
- };
95
- const CASE = resolveCase();
96
- // Prevent superAdmin value to be set on creation
97
- if ('isSuperAdmin' in args.data && CASE !== CREATION_CASE.INIT) {
49
+ const path = creationPath(args);
50
+ // Only the init sets `isSuperAdmin`.
51
+ if ('isSuperAdmin' in args.data && path !== 'init') {
98
52
  throw new RimeError(RimeError.UNAUTHORIZED);
99
53
  }
100
- let authUserId;
101
- switch (CASE) {
102
- case CREATION_CASE.INIT:
103
- authUserId = args.data.authUserId;
104
- break;
105
- case CREATION_CASE.ADMIN_CREATE_USER: {
106
- // Define better-auth role
107
- // First match wins, read top to bottom.
108
- const role = ADMIN_ROLE_IN_DATA && ADMIN_ROLE_ALLOWED
109
- ? BETTER_AUTH_ROLES.ADMIN
110
- : !ADMIN_ROLE_IN_DATA && IS_STAFF_CREATION
111
- ? BETTER_AUTH_ROLES.STAFF
112
- : BETTER_AUTH_ROLES.USER;
113
- requirePassword(args.data);
114
- const result = await rime.auth.api.createUser({
115
- headers: args.event.request.headers,
116
- body: {
117
- email: args.data.email,
118
- password: args.data.password,
119
- name: args.data.name,
120
- data: {
121
- type: config.slug
122
- },
123
- role
124
- }
125
- });
126
- authUserId = result.user.id;
127
- break;
128
- }
129
- case CREATION_CASE.STAFF_CREATE_USER: {
130
- // Define better-auth role, staff can't create admin
131
- const role = IS_STAFF_CREATION ? BETTER_AUTH_ROLES.STAFF : BETTER_AUTH_ROLES.USER;
132
- // Without headers: rime's create access already let this staff member in, and the role is
133
- // never 'admin'. With them, better-auth would ask for a `set-role` the staff role lacks.
134
- requirePassword(args.data);
135
- const result = await rime.auth.api.createUser({
136
- body: {
137
- email: args.data.email,
138
- password: args.data.password,
139
- name: args.data.name,
140
- data: {
141
- type: config.slug
142
- },
143
- role
144
- }
145
- });
146
- authUserId = result.user.id;
147
- break;
148
- }
149
- case CREATION_CASE.API_KEY_CREATION: {
150
- if (!event.locals.betterAuthUser || !event.locals.user) {
151
- throw new RimeError(RimeError.UNAUTHORIZED);
152
- }
153
- // A key document's `ownerId` names a staff member (auth/augment.server.ts)
154
- if (!event.locals.user.isStaff) {
155
- throw new RimeError(RimeError.UNAUTHORIZED, 'an api key belongs to a staff member');
156
- }
157
- if (!rime.mailer) {
158
- throw new RimeError(RimeError.OPERATION_ERROR, `Can't create API KEY without smtp config`);
159
- }
160
- if (!args.data.name) {
161
- throw new RimeFormError({ name: RimeFormError.REQUIRED_FIELD });
162
- }
163
- const apiKey = await rime.auth.api.createApiKey({
164
- body: {
165
- name: args.data.name,
166
- userId: event.locals.betterAuthUser.id,
167
- permissions: {
168
- roles: args.data.roles || [ROLES.USER]
169
- }
170
- }
171
- });
172
- // Send api key by email to the user
173
- // Cast as any because when no SMTP config provided by consumer rime.mailer is never
174
- await rime.mailer.sendMail({
175
- to: event.locals.user.email,
176
- subject: t__(`mail.api_key_created_subject`, args.data.name),
177
- text: t__(`mail.api_key_created_text`, args.data.name, apiKey.key)
178
- });
179
- return {
180
- ...args,
181
- context: {
182
- ...args.context,
183
- apiKey: apiKey.key
184
- },
185
- data: {
186
- ...args.data,
187
- apiKeyId: apiKey.id,
188
- authUserId: event.locals.betterAuthUser.id,
189
- ownerId: event.locals.user.id
190
- }
191
- };
192
- }
193
- case CREATION_CASE.PUBLIC_SIGNUP:
194
- authUserId = args.data.authUserId;
195
- break;
196
- /**
197
- * Any other case : throw UNAUTHORIZED
198
- * - unauthenticated user using direct API calls ex: POST /api/staff
199
- */
54
+ switch (path) {
55
+ case 'init':
56
+ case 'signup':
57
+ return withAuthUserId(args, args.data.authUserId);
58
+ case 'admin':
59
+ return withAuthUserId(args, await createAuthUser(args, adminRole(args), { headers: args.event.request.headers }));
60
+ case 'staff':
61
+ return withAuthUserId(args, await createAuthUser(args, staffRole(args)));
62
+ case 'apiKey':
63
+ return createKeyDocument(args);
200
64
  default:
201
65
  throw new RimeError(RimeError.UNAUTHORIZED);
202
66
  }
67
+ });
68
+ /** The args with `authUserId` on the data. */
69
+ const withAuthUserId = (args, authUserId) => ({
70
+ ...args,
71
+ data: { ...args.data, authUserId }
72
+ });
73
+ /**
74
+ * The better-auth role an admin's create gives: `admin` to a staff member whose roles hold it,
75
+ * `staff` to any other staff member, `user` on every other collection.
76
+ */
77
+ const adminRole = ({ config, data }) => {
78
+ if (config.slug !== STAFF_SLUG)
79
+ return BETTER_AUTH_ROLES.USER;
80
+ return Array.isArray(data.roles) && data.roles.includes(ROLES.ADMIN)
81
+ ? BETTER_AUTH_ROLES.ADMIN
82
+ : BETTER_AUTH_ROLES.STAFF;
83
+ };
84
+ /**
85
+ * The better-auth role a staff member's create gives: `staff` on the staff collection, `user` on
86
+ * any other. Never `admin`.
87
+ */
88
+ const staffRole = ({ config }) => config.slug === STAFF_SLUG ? BETTER_AUTH_ROLES.STAFF : BETTER_AUTH_ROLES.USER;
89
+ /**
90
+ * Makes the better-auth user and answers its id. With the caller's headers, better-auth checks
91
+ * its own `create` and `set-role` statements, as for an admin. Without them it checks nothing: a
92
+ * staff member's create, which rime's access already let in. The staff role lacks `set-role`.
93
+ */
94
+ const createAuthUser = async (args, role, request = {}) => {
95
+ requirePassword(args.data);
96
+ const result = await args.event.locals.rime.auth.api.createUser({
97
+ ...request,
98
+ body: {
99
+ email: args.data.email,
100
+ password: args.data.password,
101
+ name: args.data.name,
102
+ data: {
103
+ type: args.config.slug
104
+ },
105
+ role
106
+ }
107
+ });
108
+ // A failed create removes the user again, as a failed sign-up does
109
+ args.context.undo?.push(() => deleteAuthUser(args.event.locals.rime.adapter, { authUserId: result.user.id }));
110
+ return result.user.id;
111
+ };
112
+ /**
113
+ * Makes the api key for the caller's better-auth user, with the document's roles. The document
114
+ * gets the key's id, the caller's better-auth user, and the caller as its owner; `context.apiKey`
115
+ * holds the key for this request only, and `populateAPIKey` mails it once the document exists.
116
+ */
117
+ const createKeyDocument = async (args) => {
118
+ const { event } = args;
119
+ const { rime } = event.locals;
120
+ if (!event.locals.betterAuthUser || !event.locals.user) {
121
+ throw new RimeError(RimeError.UNAUTHORIZED);
122
+ }
123
+ // A key document's `ownerId` names a staff member (auth/augment.server.ts)
124
+ if (!event.locals.user.isStaff) {
125
+ throw new RimeError(RimeError.UNAUTHORIZED, 'an api key belongs to a staff member');
126
+ }
127
+ if (!rime.mailer) {
128
+ throw new RimeError(RimeError.OPERATION_ERROR, `Can't create API KEY without smtp config`);
129
+ }
130
+ if (!args.data.name) {
131
+ throw new RimeFormError({ name: RimeFormError.REQUIRED_FIELD });
132
+ }
133
+ const apiKey = await rime.auth.api.createApiKey({
134
+ body: {
135
+ name: args.data.name,
136
+ userId: event.locals.betterAuthUser.id,
137
+ permissions: {
138
+ roles: args.data.roles || [ROLES.USER]
139
+ }
140
+ }
141
+ });
142
+ // A failed create removes the key
143
+ args.context.undo?.push(() => deleteAuthApiKey(rime.adapter, { apiKeyId: apiKey.id }));
203
144
  return {
204
145
  ...args,
146
+ context: {
147
+ ...args.context,
148
+ apiKey: apiKey.key
149
+ },
205
150
  data: {
206
151
  ...args.data,
207
- authUserId: authUserId
152
+ apiKeyId: apiKey.id,
153
+ authUserId: event.locals.betterAuthUser.id,
154
+ ownerId: event.locals.user.id
208
155
  }
209
156
  };
210
- });
157
+ };
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Syncs a staff document's `roles` to its better-auth role: 'admin' when an admin grants admin,
3
- * 'staff' otherwise.
3
+ * 'staff' otherwise. Placed after `validateFields`: `roles` is in `data` only when the caller may
4
+ * change it, and a save refused by validation never reaches better-auth.
4
5
  *
5
6
  * Better-auth only knows one `role`: admin, staff, or user. On every other collection it is 'user'
6
7
  * from creation on and never changes, so there is nothing to forward.
@@ -6,7 +6,8 @@ import { BETTER_AUTH_ROLES } from '../constant.server.js';
6
6
  import { betterAuthApiKey, betterAuthUserId } from '../user.server.js';
7
7
  /**
8
8
  * Syncs a staff document's `roles` to its better-auth role: 'admin' when an admin grants admin,
9
- * 'staff' otherwise.
9
+ * 'staff' otherwise. Placed after `validateFields`: `roles` is in `data` only when the caller may
10
+ * change it, and a save refused by validation never reaches better-auth.
10
11
  *
11
12
  * Better-auth only knows one `role`: admin, staff, or user. On every other collection it is 'user'
12
13
  * from creation on and never changes, so there is nothing to forward.
@@ -32,8 +33,7 @@ export const forwardRolesToBetterAuth = Hooks.beforeUpdate(async function forwar
32
33
  const role = access.isAdmin(event.locals.user) && args.data.roles.includes(ROLES.ADMIN)
33
34
  ? BETTER_AUTH_ROLES.ADMIN
34
35
  : BETTER_AUTH_ROLES.STAFF;
35
- // With the caller's headers: better-auth's `set-role` check and the `roles` field's `update`
36
- // rule both say admins only.
36
+ // With the caller's headers: better-auth's `set-role` check asks for an admin too.
37
37
  await rime.auth.api.setRole({
38
38
  headers: args.event.request.headers,
39
39
  body: { userId: authUserId, role }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * After create populate the created API key
3
- * on document so user can see it once.
2
+ * After the create of an api-key document, mails the key to its creator and puts it on the
3
+ * document, so they see it once.
4
4
  */
5
5
  export declare const populateAPIKey: import("../../pipeline/types").Hook<"auth", "create", "after">;
@@ -1,15 +1,23 @@
1
1
  import { Hooks } from '../../pipeline/define-hook.js';
2
2
  import { RimeError } from '../../errors/index.js';
3
+ import { t__ } from '../../i18n/index.js';
3
4
  /**
4
- * After create populate the created API key
5
- * on document so user can see it once.
5
+ * After the create of an api-key document, mails the key to its creator and puts it on the
6
+ * document, so they see it once.
6
7
  */
7
8
  export const populateAPIKey = Hooks.afterCreate(async function populateAPIKey(args) {
8
- const { config } = args;
9
+ const { config, event } = args;
9
10
  const IS_API_AUTH = config.auth && config.auth.type === 'apiKey';
10
11
  if (IS_API_AUTH) {
11
12
  if (!args.context.apiKey)
12
13
  throw new RimeError(RimeError.OPERATION_ERROR, 'missing key @populateAPIKey');
14
+ // The key goes out once the document holding it exists. `rime.mailer` is typed `never` when
15
+ // the app has no smtp config.
16
+ await event.locals.rime.mailer.sendMail({
17
+ to: event.locals.user.email,
18
+ subject: t__(`mail.api_key_created_subject`, args.doc.name),
19
+ text: t__(`mail.api_key_created_text`, args.doc.name, args.context.apiKey)
20
+ });
13
21
  return {
14
22
  ...args,
15
23
  doc: {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Before update :
3
- * - prevent email/name/password to be changed
2
+ * Refuses an update of an auth document that sends any of `LOCKED_MEMBERS`, whoever the caller
3
+ * is, admins included. On an api-key collection `name` is the key's name.
4
4
  */
5
5
  export declare const preventUserMutations: import("../../pipeline/types").Hook<"auth", "update", "before">;
@@ -1,12 +1,13 @@
1
1
  import { Hooks } from '../../pipeline/define-hook.js';
2
2
  import { RimeError } from '../../errors/index.js';
3
+ /** What no update of an auth document may change: the sign-in identity and the better-auth link. */
4
+ const LOCKED_MEMBERS = ['email', 'name', 'password', 'authUserId'];
3
5
  /**
4
- * Before update :
5
- * - prevent email/name/password to be changed
6
+ * Refuses an update of an auth document that sends any of `LOCKED_MEMBERS`, whoever the caller
7
+ * is, admins included. On an api-key collection `name` is the key's name.
6
8
  */
7
9
  export const preventUserMutations = Hooks.beforeUpdate(async function preventUserMutations(args) {
8
- const IS_MUTATION_AUTH = 'email' in args.data || 'name' in args.data || 'password' in args.data;
9
- if (IS_MUTATION_AUTH && args.config.auth) {
10
+ if (args.config.auth && LOCKED_MEMBERS.some((key) => key in args.data)) {
10
11
  throw new RimeError(RimeError.UNAUTHORIZED);
11
12
  }
12
13
  return args;
@@ -1,10 +1,9 @@
1
1
  /**
2
- * Signs a user in as soon as their own sign-up created them.
2
+ * Sets `event.locals.user` to the user a sign-up just created, for the rest of this request: the
3
+ * hooks and the read that follow the create, and — when an app's form action calls
4
+ * `auth.api.signUpEmail` — the loads after that action. The session cookie is better-auth's.
3
5
  *
4
- * Rime's better-auth after-hook (`better-auth/hooks.server.ts`) sets
5
- * `event.locals.pendingSignInAfterSignUp`, and this reads it: the document exists by now, so
6
- * `event.locals.user` can be populated from it and the response comes back already
7
- * authenticated. Only the public sign-up path sets that flag — an admin creating a user from the
8
- * panel must not be signed in as them.
6
+ * Only the public sign-up path sets the flag this reads (`better-auth/hooks.server.ts`): an admin
7
+ * creating a user from the panel is not signed in as them.
9
8
  */
10
9
  export declare const signInNewUser: import("../../pipeline/types.js").Hook<"auth", "create", "after">;
@@ -2,13 +2,12 @@ import { RimeError } from '../../errors/index.js';
2
2
  import { Hooks } from '../../pipeline/define-hook.js';
3
3
  import { userAttributes } from '../user.server.js';
4
4
  /**
5
- * Signs a user in as soon as their own sign-up created them.
5
+ * Sets `event.locals.user` to the user a sign-up just created, for the rest of this request: the
6
+ * hooks and the read that follow the create, and — when an app's form action calls
7
+ * `auth.api.signUpEmail` — the loads after that action. The session cookie is better-auth's.
6
8
  *
7
- * Rime's better-auth after-hook (`better-auth/hooks.server.ts`) sets
8
- * `event.locals.pendingSignInAfterSignUp`, and this reads it: the document exists by now, so
9
- * `event.locals.user` can be populated from it and the response comes back already
10
- * authenticated. Only the public sign-up path sets that flag — an admin creating a user from the
11
- * panel must not be signed in as them.
9
+ * Only the public sign-up path sets the flag this reads (`better-auth/hooks.server.ts`): an admin
10
+ * creating a user from the panel is not signed in as them.
12
11
  */
13
12
  export const signInNewUser = Hooks.afterCreate(async function signInNewUser(args) {
14
13
  const { config, event, data } = args;
@@ -1,4 +1,14 @@
1
1
  import { STAFF_SLUG } from '../constant.js';
2
2
  import type { CollectionWithoutSlug } from '../../prototype/collection/types.js';
3
3
  import type { AdditionalStaffConfig } from '../types.js';
4
+ /**
5
+ * The staff collection, from `config.staff`. `admin` goes first among its roles when they do not
6
+ * list it, and `staff` is added when no other role is listed. `fields` go after the default ones,
7
+ * an authored `access` is merged over the defaults, and `panel.group` and `label` replace them.
8
+ *
9
+ * ```ts
10
+ * getStaffCollection({ roles: ['editor'] }).auth.roles // [{ value: 'admin' }, { value: 'editor' }]
11
+ * getStaffCollection().auth.roles // [{ value: 'admin' }, { value: 'staff' }]
12
+ * ```
13
+ */
4
14
  export declare const getStaffCollection: ({ roles: incomingRoles, fields, access, panel, label }?: AdditionalStaffConfig) => CollectionWithoutSlug<typeof STAFF_SLUG>;
@@ -26,6 +26,16 @@ const staffCollection = {
26
26
  update: (user, { id }) => access.isAdmin(user) || (access.isStaff(user) && access.isMe(user, id))
27
27
  }
28
28
  };
29
+ /**
30
+ * The staff collection, from `config.staff`. `admin` goes first among its roles when they do not
31
+ * list it, and `staff` is added when no other role is listed. `fields` go after the default ones,
32
+ * an authored `access` is merged over the defaults, and `panel.group` and `label` replace them.
33
+ *
34
+ * ```ts
35
+ * getStaffCollection({ roles: ['editor'] }).auth.roles // [{ value: 'admin' }, { value: 'editor' }]
36
+ * getStaffCollection().auth.roles // [{ value: 'admin' }, { value: 'staff' }]
37
+ * ```
38
+ */
29
39
  export const getStaffCollection = ({ roles: incomingRoles = [], fields = [], access, panel, label } = {}) => {
30
40
  const staffConfig = cloneDeep(staffCollection);
31
41
  let roles = incomingRoles.map((role) => typeof role === 'string' ? { value: role } : role);
@@ -1,4 +1,8 @@
1
1
  import type { ColumnDeclaration, TableDeclaration } from '../adapter.js';
2
+ /**
3
+ * The tables auth needs when some collection declares `auth`: better-auth's four (users,
4
+ * sessions, accounts, verifications) and `$apikey`. None otherwise.
5
+ */
2
6
  export declare const authTables: (config: {
3
7
  collections?: {
4
8
  auth?: unknown;
@@ -12,6 +12,10 @@ const authUserRef = {
12
12
  table: '$authUsers',
13
13
  onDelete: 'cascade'
14
14
  };
15
+ /**
16
+ * The tables auth needs when some collection declares `auth`: better-auth's four (users,
17
+ * sessions, accounts, verifications) and `$apikey`. None otherwise.
18
+ */
15
19
  export const authTables = (config) => {
16
20
  const collections = config.collections ?? [];
17
21
  // Nothing signs in, so no auth table is needed.
@@ -1,5 +1,10 @@
1
1
  import type { BaseDoc } from '../prototype/types.js';
2
2
  import type { Dic } from '../../util/types.js';
3
+ import type { Option } from '../../fields/types.js';
4
+ import type { Access } from '../config/types.js';
5
+ import type { CollectionLabel } from '../prototype/collection/types.js';
6
+ import type { FieldBuilder } from '../fields/builders/field-builder.js';
7
+ import type { Field } from '../../fields/types.js';
3
8
  /**
4
9
  * What a document of a collection that signs in carries beyond a plain one.
5
10
  */
@@ -13,6 +18,10 @@ declare module '../prototype/types.js' {
13
18
  auth: GenericAuthDoc;
14
19
  }
15
20
  }
21
+ /**
22
+ * The signed-in user, `event.locals.user`: built by `userAttributes` from the user's document, or
23
+ * by `apiKeyUser` for a request that sends an api key.
24
+ */
16
25
  export type User = {
17
26
  id: string;
18
27
  name: string;
@@ -21,11 +30,6 @@ export type User = {
21
30
  isStaff?: boolean;
22
31
  isSuperAdmin?: boolean;
23
32
  };
24
- import type { Option } from '../../fields/types.js';
25
- import type { Access } from '../config/types.js';
26
- import type { CollectionLabel } from '../prototype/collection/types.js';
27
- import type { FieldBuilder } from '../fields/builders/field-builder.js';
28
- import type { Field } from '../../fields/types.js';
29
33
  /** What an author writes under a collection's `auth`. */
30
34
  export type CollectionAuthConfig = ({
31
35
  type: 'password';
@@ -34,6 +38,7 @@ export type CollectionAuthConfig = ({
34
38
  }) & {
35
39
  roles?: (string | Option)[];
36
40
  };
41
+ /** What `config.staff` adds to the staff collection: roles, fields, access, panel group, label. */
37
42
  export type AdditionalStaffConfig = {
38
43
  roles?: (string | Option)[];
39
44
  panel?: {
@@ -41,9 +41,14 @@ export declare const userAttributes: (adapter: Adapter, args: {
41
41
  slug: CollectionSlug;
42
42
  }) => Promise<User | undefined>;
43
43
  /**
44
- * The session user of a request made with an api key: the key's own document, with the roles the
45
- * key carries. Not staff, so the panel stays closed to it. `slugs` are the api-key collections,
46
- * asked in turn.
44
+ * The user of a request made with an api key: the document that holds the key, found by the key's
45
+ * id in its `apiKeyId`, with the roles the key carries. It is not staff, so the panel stays closed
46
+ * to it, and it has no email. `slugs` are the api-key collections, asked in turn.
47
+ *
48
+ * ```ts
49
+ * apiKeyUser(adapter, { slugs: ['apps'], apiKeyId: 'k1', roles: ['sync'] })
50
+ * // { id: 'app1', name: 'Sync job', email: '', roles: ['sync'], isStaff: false }
51
+ * ```
47
52
  */
48
53
  export declare const apiKeyUser: (adapter: Adapter, args: {
49
54
  slugs: CollectionSlug[];
@@ -75,9 +75,14 @@ export const userAttributes = async (adapter, args) => {
75
75
  };
76
76
  };
77
77
  /**
78
- * The session user of a request made with an api key: the key's own document, with the roles the
79
- * key carries. Not staff, so the panel stays closed to it. `slugs` are the api-key collections,
80
- * asked in turn.
78
+ * The user of a request made with an api key: the document that holds the key, found by the key's
79
+ * id in its `apiKeyId`, with the roles the key carries. It is not staff, so the panel stays closed
80
+ * to it, and it has no email. `slugs` are the api-key collections, asked in turn.
81
+ *
82
+ * ```ts
83
+ * apiKeyUser(adapter, { slugs: ['apps'], apiKeyId: 'k1', roles: ['sync'] })
84
+ * // { id: 'app1', name: 'Sync job', email: '', roles: ['sync'], isStaff: false }
85
+ * ```
81
86
  */
82
87
  export const apiKeyUser = async (adapter, args) => {
83
88
  for (const slug of args.slugs) {
@@ -1,8 +1,6 @@
1
1
  import type { BuiltCollection } from '../config/types.js';
2
2
  /**
3
3
  * What a collection declaring `auth` has to look like. `config/validate.server.ts` asks it of every
4
- * collection.
5
- *
6
- * The messages are what a config author sees, and the e2e suite matches on some of them.
4
+ * collection. The messages are what a config author sees.
7
5
  */
8
6
  export declare const validateAuth: (config: BuiltCollection) => string[];
@@ -1,9 +1,7 @@
1
1
  import { SelectFieldBuilder } from '../../fields/select/index.js';
2
2
  /**
3
3
  * What a collection declaring `auth` has to look like. `config/validate.server.ts` asks it of every
4
- * collection.
5
- *
6
- * The messages are what a config author sees, and the e2e suite matches on some of them.
4
+ * collection. The messages are what a config author sees.
7
5
  */
8
6
  export const validateAuth = (config) => {
9
7
  // Not an auth collection: nothing here applies.
@@ -13,7 +11,7 @@ export const validateAuth = (config) => {
13
11
  // A versioned auth collection would put credentials on a version row and leave the sign-in path
14
12
  // reading whichever version happened to be published.
15
13
  if (config.versions) {
16
- errors.push(`Auth collections can't be versionned (${config.slug})`);
14
+ errors.push(`Auth collections can't be versioned (${config.slug})`);
17
15
  }
18
16
  const rolesField = config.fields
19
17
  .filter((f) => f.name === 'roles')