rimecms 1.3.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 (729) 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/generate-schema/column.server.d.ts +8 -6
  5. package/dist/adapter-sqlite/generate-schema/column.server.js +13 -49
  6. package/dist/adapter-sqlite/generate-schema/index.server.d.ts +1 -0
  7. package/dist/adapter-sqlite/generate-schema/index.server.js +6 -0
  8. package/dist/adapter-sqlite/generate-schema/relations/junction.server.d.ts +3 -3
  9. package/dist/adapter-sqlite/generate-schema/relations/junction.server.js +3 -3
  10. package/dist/adapter-sqlite/generate-schema/root.server.d.ts +4 -0
  11. package/dist/adapter-sqlite/generate-schema/root.server.js +26 -33
  12. package/dist/adapter-sqlite/generate-schema/templates.server.d.ts +0 -22
  13. package/dist/adapter-sqlite/generate-schema/templates.server.js +0 -33
  14. package/dist/adapter-sqlite/generate-schema/write.server.d.ts +6 -0
  15. package/dist/adapter-sqlite/generate-schema/write.server.js +6 -0
  16. package/dist/adapter-sqlite/index.server.js +5 -0
  17. package/dist/adapter-sqlite/locales.server.js +1 -4
  18. package/dist/adapter-sqlite/order-by.server.d.ts +6 -0
  19. package/dist/adapter-sqlite/order-by.server.js +6 -0
  20. package/dist/adapter-sqlite/read.server.d.ts +12 -1
  21. package/dist/adapter-sqlite/read.server.js +94 -38
  22. package/dist/adapter-sqlite/registry.server.d.ts +2 -2
  23. package/dist/adapter-sqlite/registry.server.js +2 -2
  24. package/dist/adapter-sqlite/relations.server.d.ts +5 -0
  25. package/dist/adapter-sqlite/relations.server.js +27 -7
  26. package/dist/adapter-sqlite/repeatable.server.d.ts +4 -1
  27. package/dist/adapter-sqlite/repeatable.server.js +4 -1
  28. package/dist/adapter-sqlite/select.server.d.ts +6 -0
  29. package/dist/adapter-sqlite/select.server.js +56 -113
  30. package/dist/adapter-sqlite/table.server.js +7 -0
  31. package/dist/adapter-sqlite/transform.server.js +8 -2
  32. package/dist/adapter-sqlite/where.server.d.ts +11 -0
  33. package/dist/adapter-sqlite/where.server.js +237 -236
  34. package/dist/adapter-sqlite/write.server.d.ts +5 -0
  35. package/dist/adapter-sqlite/write.server.js +9 -7
  36. package/dist/core/adapter.d.ts +36 -12
  37. package/dist/core/auth/access.d.ts +3 -5
  38. package/dist/core/auth/access.js +3 -5
  39. package/dist/core/auth/augment.js +3 -4
  40. package/dist/core/auth/augment.server.d.ts +4 -0
  41. package/dist/core/auth/augment.server.js +4 -0
  42. package/dist/core/auth/better-auth/config.server.d.ts +24 -16
  43. package/dist/core/auth/better-auth/config.server.js +6 -0
  44. package/dist/core/auth/better-auth/hooks.server.js +17 -5
  45. package/dist/core/auth/better-auth/instance.server.d.ts +38 -32
  46. package/dist/core/auth/better-auth/permissions.d.ts +8 -7
  47. package/dist/core/auth/better-auth/permissions.js +1 -0
  48. package/dist/core/auth/better-auth-tables.server.d.ts +5 -6
  49. package/dist/core/auth/better-auth-tables.server.js +5 -6
  50. package/dist/core/auth/constant.d.ts +3 -3
  51. package/dist/core/auth/constant.js +3 -3
  52. package/dist/core/auth/constant.server.d.ts +3 -3
  53. package/dist/core/auth/constant.server.js +3 -3
  54. package/dist/core/auth/handler/index.server.js +2 -6
  55. package/dist/core/auth/hooks/create-better-auth-user.server.d.ts +4 -2
  56. package/dist/core/auth/hooks/create-better-auth-user.server.js +132 -185
  57. package/dist/core/auth/hooks/forward-roles.server.d.ts +2 -1
  58. package/dist/core/auth/hooks/forward-roles.server.js +3 -3
  59. package/dist/core/auth/hooks/populate-api-key.server.d.ts +2 -2
  60. package/dist/core/auth/hooks/populate-api-key.server.js +11 -3
  61. package/dist/core/auth/hooks/prevent-user-mutations.server.d.ts +2 -2
  62. package/dist/core/auth/hooks/prevent-user-mutations.server.js +5 -4
  63. package/dist/core/auth/hooks/sign-in-new-user.server.d.ts +5 -6
  64. package/dist/core/auth/hooks/sign-in-new-user.server.js +5 -6
  65. package/dist/core/auth/staff/derive.d.ts +10 -0
  66. package/dist/core/auth/staff/derive.js +10 -0
  67. package/dist/core/auth/tables.d.ts +4 -0
  68. package/dist/core/auth/tables.js +4 -0
  69. package/dist/core/auth/types.d.ts +10 -5
  70. package/dist/core/auth/validate-config.d.ts +1 -3
  71. package/dist/core/auth/validate-config.js +2 -4
  72. package/dist/core/boot.server.d.ts +38 -32
  73. package/dist/core/codegen.server.js +8 -2
  74. package/dist/core/config/build.d.ts +1 -1
  75. package/dist/core/config/build.server.d.ts +2 -1
  76. package/dist/core/config/build.server.js +1 -0
  77. package/dist/core/config/context.server.d.ts +3 -9
  78. package/dist/core/config/context.server.js +3 -9
  79. package/dist/core/config/index.server.d.ts +4 -2
  80. package/dist/core/config/index.server.js +4 -2
  81. package/dist/core/config/types.d.ts +13 -4
  82. package/dist/core/config/validate.server.d.ts +4 -0
  83. package/dist/core/config/validate.server.js +100 -90
  84. package/dist/core/constants.d.ts +13 -5
  85. package/dist/core/constants.js +13 -5
  86. package/dist/core/constants.server.d.ts +7 -0
  87. package/dist/core/constants.server.js +7 -0
  88. package/dist/core/dev/cache.server.d.ts +10 -7
  89. package/dist/core/dev/cache.server.js +10 -11
  90. package/dist/core/dev/cli/commands/build.d.ts +5 -0
  91. package/dist/core/dev/cli/commands/build.js +17 -2
  92. package/dist/core/dev/cli/commands/clear.server.d.ts +1 -0
  93. package/dist/core/dev/cli/commands/clear.server.js +3 -2
  94. package/dist/core/dev/cli/commands/generate-exports.server.js +25 -4
  95. package/dist/core/dev/cli/commands/generate.server.d.ts +5 -0
  96. package/dist/core/dev/cli/commands/generate.server.js +7 -8
  97. package/dist/core/dev/cli/commands/init.server.d.ts +7 -0
  98. package/dist/core/dev/cli/commands/init.server.js +34 -7
  99. package/dist/core/dev/cli/index.js +16 -14
  100. package/dist/core/dev/cli/templates/build.d.ts +4 -0
  101. package/dist/core/dev/cli/templates/build.js +4 -0
  102. package/dist/core/dev/cli/templates/init.d.ts +2 -1
  103. package/dist/core/dev/cli/templates/init.js +17 -9
  104. package/dist/core/dev/cli/util/package-manager.server.d.ts +6 -1
  105. package/dist/core/dev/cli/util/package-manager.server.js +14 -10
  106. package/dist/core/dev/cli/util/package.server.d.ts +1 -0
  107. package/dist/core/dev/cli/util/package.server.js +2 -2
  108. package/dist/core/dev/cli/util/project-name.d.ts +2 -1
  109. package/dist/core/dev/cli/util/project-name.js +6 -4
  110. package/dist/core/dev/cli/util/prompt.server.d.ts +2 -1
  111. package/dist/core/dev/cli/util/prompt.server.js +2 -1
  112. package/dist/core/dev/codegen/routes/common.server.d.ts +12 -0
  113. package/dist/core/dev/codegen/routes/common.server.js +9 -17
  114. package/dist/core/dev/codegen/routes/custom-css.server.d.ts +3 -9
  115. package/dist/core/dev/codegen/routes/custom-css.server.js +8 -34
  116. package/dist/core/dev/codegen/routes/index.server.d.ts +4 -5
  117. package/dist/core/dev/codegen/routes/index.server.js +33 -17
  118. package/dist/core/dev/codegen/routes/util.server.d.ts +13 -23
  119. package/dist/core/dev/codegen/routes/util.server.js +15 -25
  120. package/dist/core/dev/codegen/runtime/index.server.d.ts +2 -3
  121. package/dist/core/dev/codegen/runtime/index.server.js +2 -3
  122. package/dist/core/dev/codegen/runtime/parse-exports.server.js +10 -3
  123. package/dist/core/dev/codegen/sanitize/index.server.d.ts +11 -1
  124. package/dist/core/dev/codegen/sanitize/index.server.js +81 -50
  125. package/dist/core/dev/codegen/types/index.server.d.ts +2 -4
  126. package/dist/core/dev/codegen/types/index.server.js +6 -10
  127. package/dist/core/dev/codegen/types/templates.server.d.ts +4 -2
  128. package/dist/core/dev/codegen/types/templates.server.js +13 -26
  129. package/dist/core/dev/config-memo.server.js +6 -7
  130. package/dist/core/dev/constants.server.d.ts +4 -2
  131. package/dist/core/dev/constants.server.js +7 -4
  132. package/dist/core/dev/ensure.server.d.ts +5 -0
  133. package/dist/core/dev/ensure.server.js +11 -6
  134. package/dist/core/dev/env.server.d.ts +3 -1
  135. package/dist/core/dev/env.server.js +3 -1
  136. package/dist/core/dev/vite.server.d.ts +10 -0
  137. package/dist/core/dev/vite.server.js +13 -1
  138. package/dist/core/errors/handler.server.d.ts +9 -3
  139. package/dist/core/errors/handler.server.js +11 -6
  140. package/dist/core/errors/index.d.ts +21 -1
  141. package/dist/core/errors/index.js +23 -3
  142. package/dist/core/fields/builders/boolean-builder.d.ts +4 -0
  143. package/dist/core/fields/builders/boolean-builder.js +6 -1
  144. package/dist/core/fields/builders/field-builder.d.ts +16 -4
  145. package/dist/core/fields/builders/field-builder.js +11 -0
  146. package/dist/core/fields/builders/form-field-builder.d.ts +46 -2
  147. package/dist/core/fields/builders/form-field-builder.js +47 -2
  148. package/dist/core/fields/builders/index.d.ts +0 -2
  149. package/dist/core/fields/builders/index.js +0 -2
  150. package/dist/core/fields/builders/select-builder.d.ts +13 -2
  151. package/dist/core/fields/builders/select-builder.js +13 -1
  152. package/dist/core/fields/initial.d.ts +4 -1
  153. package/dist/core/fields/types.d.ts +5 -6
  154. package/dist/core/fields/util.d.ts +9 -14
  155. package/dist/core/fields/util.js +10 -15
  156. package/dist/core/fields/validate.d.ts +3 -0
  157. package/dist/core/fields/validate.js +3 -0
  158. package/dist/core/fields/walk.d.ts +4 -1
  159. package/dist/core/fields/walk.js +1 -2
  160. package/dist/core/handler.server.d.ts +5 -0
  161. package/dist/core/handler.server.js +15 -1
  162. package/dist/core/i18n/en/common.d.ts +28 -0
  163. package/dist/core/i18n/en/common.js +28 -0
  164. package/dist/core/i18n/en/errors.d.ts +6 -0
  165. package/dist/core/i18n/en/errors.js +6 -0
  166. package/dist/core/i18n/en/fields.d.ts +11 -0
  167. package/dist/core/i18n/en/fields.js +12 -1
  168. package/dist/core/i18n/fr/common.d.ts +28 -0
  169. package/dist/core/i18n/fr/common.js +29 -0
  170. package/dist/core/i18n/fr/errors.d.ts +6 -0
  171. package/dist/core/i18n/fr/errors.js +6 -0
  172. package/dist/core/i18n/fr/fields.d.ts +11 -0
  173. package/dist/core/i18n/fr/fields.js +12 -1
  174. package/dist/core/i18n/index.d.ts +1 -0
  175. package/dist/core/i18n/index.js +7 -0
  176. package/dist/core/i18n/register.server.js +1 -1
  177. package/dist/core/locale/types.d.ts +2 -6
  178. package/dist/core/logger.server.js +8 -2
  179. package/dist/core/panel/configure.js +2 -2
  180. package/dist/core/panel/types.d.ts +4 -2
  181. package/dist/core/pipeline/build-document.server.d.ts +2 -2
  182. package/dist/core/pipeline/build-document.server.js +2 -2
  183. package/dist/core/pipeline/build.server.js +2 -12
  184. package/dist/core/{prototype/shared/versions/hooks → pipeline}/fallback-data-from-original.d.ts +6 -6
  185. package/dist/core/{prototype/shared/versions/hooks → pipeline}/fallback-data-from-original.js +5 -5
  186. package/dist/core/pipeline/hooks/original-config-map.server.d.ts +3 -2
  187. package/dist/core/pipeline/hooks/original-config-map.server.js +3 -2
  188. package/dist/core/pipeline/hooks/process-document-fields.server.d.ts +2 -1
  189. package/dist/core/pipeline/hooks/process-document-fields.server.js +4 -9
  190. package/dist/core/pipeline/hooks/sort-document-props.server.js +4 -3
  191. package/dist/core/pipeline/hooks/validate-fields.server.d.ts +15 -1
  192. package/dist/core/pipeline/hooks/validate-fields.server.js +142 -47
  193. package/dist/core/pipeline/persist/blocks/extract.server.d.ts +5 -0
  194. package/dist/core/pipeline/persist/blocks/extract.server.js +5 -0
  195. package/dist/core/pipeline/persist/blocks/index.server.d.ts +3 -7
  196. package/dist/core/pipeline/persist/blocks/index.server.js +3 -8
  197. package/dist/core/pipeline/persist/relations/diff.server.js +1 -0
  198. package/dist/core/pipeline/persist/relations/extract.server.d.ts +1 -0
  199. package/dist/core/pipeline/persist/relations/extract.server.js +2 -0
  200. package/dist/core/pipeline/persist/relations/index.server.d.ts +6 -0
  201. package/dist/core/pipeline/persist/relations/index.server.js +31 -8
  202. package/dist/core/pipeline/persist/repeatable.server.d.ts +21 -12
  203. package/dist/core/pipeline/persist/repeatable.server.js +28 -4
  204. package/dist/core/pipeline/persist/tree/extract.server.d.ts +5 -0
  205. package/dist/core/pipeline/persist/tree/extract.server.js +6 -8
  206. package/dist/core/pipeline/persist/tree/index.server.d.ts +5 -0
  207. package/dist/core/pipeline/persist/tree/index.server.js +5 -0
  208. package/dist/core/pipeline/populate-relations.server.d.ts +1 -0
  209. package/dist/core/pipeline/populate-relations.server.js +1 -0
  210. package/dist/core/pipeline/run.server.d.ts +26 -17
  211. package/dist/core/pipeline/run.server.js +51 -9
  212. package/dist/core/pipeline/types.d.ts +30 -7
  213. package/dist/core/pipeline/without-denied-fields.d.ts +15 -0
  214. package/dist/core/pipeline/without-denied-fields.js +53 -2
  215. package/dist/core/plugins/api-init/index.server.d.ts +8 -0
  216. package/dist/core/plugins/api-init/index.server.js +8 -0
  217. package/dist/core/plugins/cache/HeaderButton.svelte +15 -6
  218. package/dist/core/plugins/cache/cache.server.d.ts +9 -0
  219. package/dist/core/plugins/cache/cache.server.js +9 -0
  220. package/dist/core/plugins/cache/handler.server.d.ts +5 -0
  221. package/dist/core/plugins/cache/handler.server.js +5 -0
  222. package/dist/core/plugins/cache/module.server.d.ts +4 -19
  223. package/dist/core/plugins/cache/module.server.js +5 -1
  224. package/dist/core/plugins/cache/types.d.ts +6 -0
  225. package/dist/core/plugins/index.d.ts +1 -0
  226. package/dist/core/plugins/index.js +1 -0
  227. package/dist/core/plugins/mailer/index.server.d.ts +5 -2
  228. package/dist/core/plugins/mailer/index.server.js +4 -0
  229. package/dist/core/plugins/plugins.server.d.ts +1 -0
  230. package/dist/core/plugins/plugins.server.js +1 -0
  231. package/dist/core/plugins/sse/client.js +4 -0
  232. package/dist/core/prototype/area/definition.server.d.ts +2 -3
  233. package/dist/core/prototype/area/definition.server.js +2 -3
  234. package/dist/core/prototype/area/operations/find.d.ts +5 -0
  235. package/dist/core/prototype/area/operations/find.js +5 -0
  236. package/dist/core/prototype/area/rest/endpoint.server.d.ts +3 -3
  237. package/dist/core/prototype/area/rest/endpoint.server.js +3 -3
  238. package/dist/core/prototype/area/rest/get.server.d.ts +2 -1
  239. package/dist/core/prototype/area/rest/get.server.js +2 -1
  240. package/dist/core/prototype/area/rest/update.server.d.ts +2 -1
  241. package/dist/core/prototype/area/rest/update.server.js +2 -1
  242. package/dist/core/prototype/collection/api.server.d.ts +15 -1
  243. package/dist/core/prototype/collection/api.server.js +16 -0
  244. package/dist/core/prototype/collection/augment-label.d.ts +9 -0
  245. package/dist/core/prototype/collection/augment-label.js +9 -0
  246. package/dist/core/prototype/collection/definition.d.ts +1 -1
  247. package/dist/core/prototype/collection/definition.js +1 -1
  248. package/dist/core/prototype/collection/hooks/merge-with-initial.server.d.ts +3 -3
  249. package/dist/core/prototype/collection/hooks/merge-with-initial.server.js +3 -3
  250. package/dist/core/prototype/collection/hooks.server.d.ts +2 -6
  251. package/dist/core/prototype/collection/hooks.server.js +8 -9
  252. package/dist/core/prototype/collection/nested/hooks/add-children.server.d.ts +3 -1
  253. package/dist/core/prototype/collection/nested/hooks/add-children.server.js +19 -11
  254. package/dist/core/prototype/collection/nested/hooks/index.server.d.ts +1 -0
  255. package/dist/core/prototype/collection/nested/hooks/index.server.js +1 -0
  256. package/dist/core/prototype/collection/nested/hooks/place-at-end.server.d.ts +10 -0
  257. package/dist/core/prototype/collection/nested/hooks/place-at-end.server.js +24 -0
  258. package/dist/core/prototype/collection/nested/move.server.d.ts +35 -0
  259. package/dist/core/prototype/collection/nested/move.server.js +74 -0
  260. package/dist/core/prototype/collection/operations/count.d.ts +19 -0
  261. package/dist/core/prototype/collection/operations/count.js +23 -0
  262. package/dist/core/prototype/collection/operations/create.d.ts +16 -0
  263. package/dist/core/prototype/collection/operations/create.js +46 -26
  264. package/dist/core/prototype/collection/operations/delete-by-id.d.ts +5 -0
  265. package/dist/core/prototype/collection/operations/delete-by-id.js +5 -0
  266. package/dist/core/prototype/collection/operations/delete.d.ts +8 -0
  267. package/dist/core/prototype/collection/operations/delete.js +8 -0
  268. package/dist/core/prototype/collection/operations/duplicate.d.ts +8 -0
  269. package/dist/core/prototype/collection/operations/duplicate.js +12 -0
  270. package/dist/core/prototype/collection/operations/find-by-id.d.ts +5 -0
  271. package/dist/core/prototype/collection/operations/find-by-id.js +5 -0
  272. package/dist/core/prototype/collection/operations/find.d.ts +6 -1
  273. package/dist/core/prototype/collection/operations/find.js +7 -2
  274. package/dist/core/prototype/collection/rest/count.server.d.ts +5 -0
  275. package/dist/core/prototype/collection/rest/count.server.js +12 -0
  276. package/dist/core/prototype/collection/rest/create.server.d.ts +2 -1
  277. package/dist/core/prototype/collection/rest/create.server.js +2 -1
  278. package/dist/core/prototype/collection/rest/delete-by-id.server.d.ts +1 -3
  279. package/dist/core/prototype/collection/rest/delete-by-id.server.js +1 -3
  280. package/dist/core/prototype/collection/rest/get-by-id.server.d.ts +2 -1
  281. package/dist/core/prototype/collection/rest/get-by-id.server.js +2 -1
  282. package/dist/core/prototype/collection/rest/get.server.d.ts +2 -1
  283. package/dist/core/prototype/collection/rest/get.server.js +2 -1
  284. package/dist/core/prototype/collection/rest/index.server.js +5 -0
  285. package/dist/core/prototype/collection/rest/lock.server.js +0 -5
  286. package/dist/core/prototype/collection/rest/move.server.d.ts +11 -0
  287. package/dist/core/prototype/collection/rest/move.server.js +34 -0
  288. package/dist/core/prototype/collection/rest/update-by-id.server.d.ts +3 -1
  289. package/dist/core/prototype/collection/rest/update-by-id.server.js +3 -1
  290. package/dist/core/prototype/collection/thumbnail/hooks/set-document-thumbnail.server.js +17 -9
  291. package/dist/core/prototype/collection/upload/boot/index.server.d.ts +3 -5
  292. package/dist/core/prototype/collection/upload/boot/index.server.js +3 -5
  293. package/dist/core/prototype/collection/upload/directories/configure.server.js +1 -2
  294. package/dist/core/prototype/collection/upload/directories/create.server.d.ts +15 -0
  295. package/dist/core/prototype/collection/upload/directories/create.server.js +19 -0
  296. package/dist/core/prototype/collection/upload/directories/derive.js +2 -2
  297. package/dist/core/prototype/collection/upload/directories/pipeline.server.js +5 -4
  298. package/dist/core/prototype/collection/upload/disk/save.server.d.ts +9 -5
  299. package/dist/core/prototype/collection/upload/disk/save.server.js +19 -6
  300. package/dist/core/prototype/collection/upload/ensure.server.d.ts +2 -7
  301. package/dist/core/prototype/collection/upload/ensure.server.js +2 -7
  302. package/dist/core/prototype/collection/upload/handler.server.d.ts +4 -0
  303. package/dist/core/prototype/collection/upload/handler.server.js +13 -4
  304. package/dist/core/prototype/collection/upload/hooks/convert-base64.server.d.ts +3 -10
  305. package/dist/core/prototype/collection/upload/hooks/convert-base64.server.js +5 -18
  306. package/dist/core/prototype/collection/upload/hooks/delete-folder-contents.server.d.ts +10 -0
  307. package/dist/core/prototype/collection/upload/hooks/delete-folder-contents.server.js +30 -0
  308. package/dist/core/prototype/collection/upload/hooks/extract-path.server.d.ts +1 -1
  309. package/dist/core/prototype/collection/upload/hooks/extract-path.server.js +1 -1
  310. package/dist/core/prototype/collection/upload/hooks/handle-path-creation.server.js +8 -20
  311. package/dist/core/prototype/collection/upload/hooks/index.server.d.ts +2 -5
  312. package/dist/core/prototype/collection/upload/hooks/index.server.js +2 -5
  313. package/dist/core/prototype/collection/upload/hooks/populate-sizes.server.d.ts +4 -2
  314. package/dist/core/prototype/collection/upload/hooks/populate-sizes.server.js +18 -19
  315. package/dist/core/prototype/collection/upload/hooks/process-file-upload.server.d.ts +3 -1
  316. package/dist/core/prototype/collection/upload/hooks/process-file-upload.server.js +16 -3
  317. package/dist/core/prototype/collection/upload/hooks/update-directory-children.server.js +3 -2
  318. package/dist/core/prototype/collection/upload/module.d.ts +4 -2
  319. package/dist/core/prototype/collection/upload/module.js +12 -17
  320. package/dist/core/prototype/collection/upload/module.server.d.ts +3 -4
  321. package/dist/core/prototype/collection/upload/module.server.js +3 -4
  322. package/dist/core/prototype/collection/upload/types.d.ts +21 -6
  323. package/dist/core/prototype/collection/upload/util/client.d.ts +2 -2
  324. package/dist/core/prototype/collection/upload/util/client.js +2 -2
  325. package/dist/core/prototype/collection/upload/util/config.d.ts +1 -0
  326. package/dist/core/prototype/collection/upload/util/converter.server.d.ts +5 -0
  327. package/dist/core/prototype/collection/upload/util/converter.server.js +16 -24
  328. package/dist/core/prototype/collection/upload/util/mime.d.ts +60 -0
  329. package/dist/core/prototype/collection/upload/util/mime.js +94 -4
  330. package/dist/core/prototype/collection/upload/util/path.d.ts +5 -1
  331. package/dist/core/prototype/collection/upload/util/path.js +9 -12
  332. package/dist/core/prototype/define.d.ts +14 -0
  333. package/dist/core/prototype/define.js +14 -0
  334. package/dist/core/prototype/shared/title/find-title.js +1 -0
  335. package/dist/core/prototype/shared/title/select.d.ts +2 -2
  336. package/dist/core/prototype/shared/title/select.js +2 -2
  337. package/dist/core/prototype/shared/url/hooks/set-live-url.server.js +2 -3
  338. package/dist/core/prototype/shared/versions/augment.js +8 -4
  339. package/dist/core/prototype/shared/versions/hooks/handle-new-version.server.js +6 -2
  340. package/dist/core/prototype/shared/versions/validate-config.server.js +1 -2
  341. package/dist/core/prototype/types.d.ts +0 -5
  342. package/dist/core/rime.server.d.ts +3 -2
  343. package/dist/core/rime.server.js +3 -2
  344. package/dist/core/routes/context.server.d.ts +11 -0
  345. package/dist/core/routes/context.server.js +11 -0
  346. package/dist/core/routes/handler.server.d.ts +4 -3
  347. package/dist/core/routes/handler.server.js +4 -3
  348. package/dist/core/routes/panel-navigation.d.ts +4 -5
  349. package/dist/core/routes/panel-navigation.js +4 -8
  350. package/dist/core/routes/util.d.ts +8 -2
  351. package/dist/core/routes/util.js +10 -4
  352. package/dist/fields/blocks/component/AddBlockButton.svelte +1 -0
  353. package/dist/fields/blocks/component/Blocks.svelte +15 -11
  354. package/dist/fields/blocks/component/focus/BlocksFocus.svelte +22 -10
  355. package/dist/fields/blocks/component/focus/LayersList.svelte +5 -0
  356. package/dist/fields/blocks/component/focus/Palette.svelte +0 -1
  357. package/dist/fields/blocks/component/focus/Renders.svelte +5 -4
  358. package/dist/fields/blocks/component/focus/Renders.svelte.d.ts +2 -1
  359. package/dist/fields/blocks/component/focus/focus.svelte.js +42 -13
  360. package/dist/fields/blocks/component/picker/BlockPicker.svelte +2 -2
  361. package/dist/fields/blocks/index.d.ts +16 -0
  362. package/dist/fields/blocks/index.js +15 -2
  363. package/dist/fields/checkbox/component/Checkbox.svelte +1 -0
  364. package/dist/fields/combobox/component/ComboBox.svelte +3 -2
  365. package/dist/fields/combobox/index.d.ts +1 -0
  366. package/dist/fields/combobox/index.js +1 -0
  367. package/dist/fields/component/index.d.ts +3 -0
  368. package/dist/fields/component/index.js +3 -0
  369. package/dist/fields/date/component/Date.svelte +8 -5
  370. package/dist/fields/date/index.d.ts +1 -0
  371. package/dist/fields/date/index.js +1 -0
  372. package/dist/fields/email/component/Email.svelte +8 -5
  373. package/dist/fields/email/index.d.ts +1 -0
  374. package/dist/fields/email/index.js +1 -0
  375. package/dist/fields/group/component/Group.svelte +8 -15
  376. package/dist/fields/group/index.d.ts +7 -1
  377. package/dist/fields/group/index.js +5 -4
  378. package/dist/fields/link/component/Link.svelte +19 -8
  379. package/dist/fields/link/component/RessourceInput.svelte +68 -47
  380. package/dist/fields/link/index.d.ts +12 -0
  381. package/dist/fields/link/index.js +14 -1
  382. package/dist/fields/number/component/Number.svelte +1 -0
  383. package/dist/fields/number/index.js +5 -3
  384. package/dist/fields/radio/component/Radio.svelte +12 -3
  385. package/dist/fields/radio/index.d.ts +1 -0
  386. package/dist/fields/radio/index.js +1 -0
  387. package/dist/fields/relation/component/Cell.svelte +4 -4
  388. package/dist/fields/relation/component/Relation.svelte +92 -131
  389. package/dist/fields/relation/component/Relation.svelte.d.ts +0 -1
  390. package/dist/fields/relation/component/RelationInline.svelte +22 -27
  391. package/dist/fields/relation/component/default/Default.svelte +50 -19
  392. package/dist/fields/relation/component/default/Default.svelte.d.ts +12 -1
  393. package/dist/fields/relation/component/types.d.ts +5 -3
  394. package/dist/fields/relation/component/upload/Browse.svelte +50 -41
  395. package/dist/fields/relation/component/upload/Browse.svelte.d.ts +6 -1
  396. package/dist/fields/relation/component/upload/Upload.svelte +8 -3
  397. package/dist/fields/relation/component/upload/Upload.svelte.d.ts +0 -1
  398. package/dist/fields/relation/index.d.ts +27 -10
  399. package/dist/fields/relation/index.js +16 -0
  400. package/dist/fields/relation/populate.js +1 -0
  401. package/dist/fields/relation/query.d.ts +22 -0
  402. package/dist/fields/relation/query.js +29 -0
  403. package/dist/fields/relation/relation.test-d.js +11 -0
  404. package/dist/fields/repeatable/RepeatableActions.svelte +4 -0
  405. package/dist/fields/repeatable/RepeatableActions.svelte.d.ts +4 -0
  406. package/dist/fields/repeatable.js +3 -21
  407. package/dist/fields/rich-text/client.d.ts +26 -0
  408. package/dist/fields/rich-text/client.js +26 -0
  409. package/dist/fields/rich-text/component/RichTextInline.svelte +2 -9
  410. package/dist/fields/rich-text/component/RichTextInline.svelte.d.ts +2 -9
  411. package/dist/fields/rich-text/component/bubble-menu/bubble-menu.svelte +2 -0
  412. package/dist/fields/rich-text/component/bubble-menu/icon-button/icon-button.css +0 -1
  413. package/dist/fields/rich-text/component/bubble-menu/icon-button/icon-button.svelte +1 -2
  414. package/dist/fields/rich-text/component/bubble-menu/node-selector/node-selector.css +0 -1
  415. package/dist/fields/rich-text/component/bubble-menu/node-selector/node-selector.svelte +9 -6
  416. package/dist/fields/rich-text/component/context.svelte.d.ts +1 -0
  417. package/dist/fields/rich-text/component/context.svelte.js +1 -0
  418. package/dist/fields/rich-text/component/drag-handle/drag-handle.css +0 -1
  419. package/dist/fields/rich-text/component/drag-handle/drag-handle.svelte +1 -0
  420. package/dist/fields/rich-text/component/styles/editor.css +0 -1
  421. package/dist/fields/rich-text/component/styles/field.css +10 -11
  422. package/dist/fields/rich-text/core/build-editor-config.d.ts +15 -6
  423. package/dist/fields/rich-text/core/build-editor-config.js +47 -66
  424. package/dist/fields/rich-text/core/extensions/current-node/current-node.css +1 -0
  425. package/dist/fields/rich-text/core/extensions/current-node/current-node.d.ts +2 -2
  426. package/dist/fields/rich-text/core/extensions/current-node/current-node.js +3 -4
  427. package/dist/fields/rich-text/core/extensions/drag-handle/drag-handle-plugin.d.ts +5 -0
  428. package/dist/fields/rich-text/core/extensions/drag-handle/drag-handle-plugin.js +40 -77
  429. package/dist/fields/rich-text/core/extensions/drag-handle/drag-handle.d.ts +1 -1
  430. package/dist/fields/rich-text/core/extensions/drag-handle/drag-handle.js +1 -1
  431. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/cloneElement.d.ts +4 -0
  432. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/cloneElement.js +5 -0
  433. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/dragHandler.d.ts +5 -0
  434. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/dragHandler.js +11 -13
  435. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/findNextElementFromCursor.d.ts +6 -8
  436. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/findNextElementFromCursor.js +9 -14
  437. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/getInnerCoords.d.ts +1 -0
  438. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/getInnerCoords.js +6 -5
  439. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/getOuterNode.d.ts +3 -1
  440. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/getOuterNode.js +8 -21
  441. package/dist/fields/rich-text/core/features/blockquote.js +5 -1
  442. package/dist/fields/rich-text/core/features/bold.js +0 -3
  443. package/dist/fields/rich-text/core/features/bullet-list.js +5 -1
  444. package/dist/fields/rich-text/core/features/fields/extension.d.ts +1 -0
  445. package/dist/fields/rich-text/core/features/fields/extension.js +1 -0
  446. package/dist/fields/rich-text/core/features/fields/fields-form.svelte +54 -0
  447. package/dist/fields/rich-text/core/features/fields/fields-form.svelte.d.ts +14 -0
  448. package/dist/fields/rich-text/core/features/fields/fields.svelte +30 -35
  449. package/dist/fields/rich-text/core/features/fields/index.d.ts +2 -0
  450. package/dist/fields/rich-text/core/features/fields/index.js +1 -0
  451. package/dist/fields/rich-text/core/features/heading.js +19 -68
  452. package/dist/fields/rich-text/core/features/hr/hr.css +1 -2
  453. package/dist/fields/rich-text/core/features/hr/hr.js +5 -1
  454. package/dist/fields/rich-text/core/features/index.d.ts +1 -0
  455. package/dist/fields/rich-text/core/features/index.js +1 -0
  456. package/dist/fields/rich-text/core/features/json-attribute.d.ts +1 -1
  457. package/dist/fields/rich-text/core/features/json-attribute.js +1 -1
  458. package/dist/fields/rich-text/core/features/link/component/link-selector.svelte +61 -58
  459. package/dist/fields/rich-text/core/features/link/component/link-selector.svelte.d.ts +3 -1
  460. package/dist/fields/rich-text/core/features/link/index.d.ts +5 -0
  461. package/dist/fields/rich-text/core/features/link/index.js +2 -14
  462. package/dist/fields/rich-text/core/features/ordered-list.js +5 -1
  463. package/dist/fields/rich-text/core/features/paragraph.js +5 -1
  464. package/dist/fields/rich-text/core/features/pick-dialog.svelte +16 -4
  465. package/dist/fields/rich-text/core/features/pick-dialog.svelte.d.ts +7 -3
  466. package/dist/fields/rich-text/core/features/resource/index.d.ts +1 -0
  467. package/dist/fields/rich-text/core/features/resource/index.js +1 -0
  468. package/dist/fields/rich-text/core/features/resource/resource-extension.d.ts +1 -0
  469. package/dist/fields/rich-text/core/features/resource/resource-extension.js +8 -6
  470. package/dist/fields/rich-text/core/features/resource/resource.svelte +38 -49
  471. package/dist/fields/rich-text/core/features/resource/types.d.ts +1 -0
  472. package/dist/fields/rich-text/core/features/upload/index.d.ts +1 -0
  473. package/dist/fields/rich-text/core/features/upload/index.js +2 -1
  474. package/dist/fields/rich-text/core/features/upload/upload-extension.d.ts +6 -0
  475. package/dist/fields/rich-text/core/features/upload/upload-extension.js +2 -2
  476. package/dist/fields/{relation/component → rich-text/core/features}/upload/upload.css +1 -2
  477. package/dist/fields/rich-text/core/features/upload/upload.svelte +47 -73
  478. package/dist/fields/rich-text/core/features/upload/upload.svelte.d.ts +1 -0
  479. package/dist/fields/rich-text/core/render-rich-text.svelte +30 -16
  480. package/dist/fields/rich-text/core/rich-text-editor-core.svelte +8 -3
  481. package/dist/fields/rich-text/core/rich-text-editor-core.svelte.d.ts +1 -0
  482. package/dist/fields/rich-text/core/svelte/constant.d.ts +1 -0
  483. package/dist/fields/rich-text/core/svelte/constant.js +1 -0
  484. package/dist/fields/rich-text/core/svelte/node-view-renderer.svelte.d.ts +10 -0
  485. package/dist/fields/rich-text/core/svelte/node-view-renderer.svelte.js +23 -6
  486. package/dist/fields/rich-text/core/svelte/node-view-wrapper.svelte +6 -2
  487. package/dist/fields/rich-text/core/svelte/node-view-wrapper.svelte.d.ts +1 -0
  488. package/dist/fields/rich-text/core/svelte/renderer.d.ts +1 -0
  489. package/dist/fields/rich-text/core/svelte/renderer.js +1 -0
  490. package/dist/fields/rich-text/core/types.d.ts +11 -0
  491. package/dist/fields/rich-text/index.d.ts +2 -0
  492. package/dist/fields/rich-text/index.js +12 -7
  493. package/dist/fields/rich-text/json.d.ts +6 -4
  494. package/dist/fields/rich-text/json.js +6 -4
  495. package/dist/fields/select/component/Select.svelte +37 -12
  496. package/dist/fields/select/index.d.ts +2 -1
  497. package/dist/fields/select/index.js +1 -0
  498. package/dist/fields/separator/index.d.ts +1 -0
  499. package/dist/fields/separator/index.js +1 -0
  500. package/dist/fields/slug/component/Slug.svelte +14 -13
  501. package/dist/fields/slug/index.d.ts +11 -0
  502. package/dist/fields/slug/index.js +11 -0
  503. package/dist/fields/tabs/component/Tabs.svelte +4 -7
  504. package/dist/fields/tabs/index.d.ts +10 -0
  505. package/dist/fields/tabs/index.js +10 -0
  506. package/dist/fields/text/component/TextInline.svelte +12 -10
  507. package/dist/fields/text/index.d.ts +7 -0
  508. package/dist/fields/text/index.js +9 -2
  509. package/dist/fields/textarea/index.d.ts +3 -0
  510. package/dist/fields/textarea/index.js +5 -2
  511. package/dist/fields/time/index.d.ts +1 -0
  512. package/dist/fields/time/index.js +4 -6
  513. package/dist/fields/toggle/component/Toggle.svelte +1 -0
  514. package/dist/fields/toggle/index.d.ts +1 -0
  515. package/dist/fields/toggle/index.js +1 -0
  516. package/dist/fields/tree/component/AddItemButton.svelte +3 -2
  517. package/dist/fields/tree/component/AddItemButton.svelte.d.ts +1 -1
  518. package/dist/fields/tree/component/Tree.svelte +16 -57
  519. package/dist/fields/tree/component/TreeBlock.svelte +26 -40
  520. package/dist/fields/tree/component/props.d.ts +3 -2
  521. package/dist/fields/tree/index.js +14 -2
  522. package/dist/fields/tree/util.js +0 -3
  523. package/dist/fields/types.d.ts +23 -1
  524. package/dist/index.d.ts +1 -0
  525. package/dist/index.js +1 -0
  526. package/dist/live/Consumer.svelte +6 -0
  527. package/dist/live/LiveEdit.svelte +23 -5
  528. package/dist/live/LiveEdit.svelte.d.ts +2 -1
  529. package/dist/live/Provider.svelte +5 -1
  530. package/dist/live/context.svelte.d.ts +3 -4
  531. package/dist/live/context.svelte.js +9 -6
  532. package/dist/panel/components/Root.svelte +7 -1
  533. package/dist/panel/components/fields/FieldsPreview.svelte +15 -1
  534. package/dist/panel/components/fields/Label.svelte +2 -0
  535. package/dist/panel/components/fields/RenderFields.svelte +12 -1
  536. package/dist/panel/components/fields/fieldset.svelte.d.ts +7 -1
  537. package/dist/panel/components/fields/fieldset.svelte.js +7 -1
  538. package/dist/panel/components/fields/setting.css +7 -0
  539. package/dist/panel/components/sections/auth/AuthForm.svelte +4 -1
  540. package/dist/panel/components/sections/collection/Avatar.svelte +1 -1
  541. package/dist/panel/components/sections/collection/bulk-upload/FileDrop.svelte +3 -0
  542. package/dist/panel/components/sections/collection/bulk-upload/PageDrop.svelte +11 -1
  543. package/dist/panel/components/sections/collection/folder/FolderEdit.svelte +10 -1
  544. package/dist/panel/components/sections/collection/folder/FolderWithActions.svelte +45 -34
  545. package/dist/panel/components/sections/collection/folder/Folders.svelte +1 -0
  546. package/dist/panel/components/sections/collection/grid/CollectionGrid.svelte +8 -3
  547. package/dist/panel/components/sections/collection/grid/CollectionGrid.svelte.d.ts +2 -1
  548. package/dist/panel/components/sections/collection/grid/create-directory-dialog/CreateDirectoryDialog.svelte +3 -1
  549. package/dist/panel/components/sections/collection/grid/grid-item/GridItem.svelte +4 -0
  550. package/dist/panel/components/sections/collection/header/ButtonCreate.svelte +1 -5
  551. package/dist/panel/components/sections/collection/header/SearchInput.svelte +2 -0
  552. package/dist/panel/components/sections/collection/header/SelectUI.svelte +25 -5
  553. package/dist/panel/components/sections/collection/list/CollectionList.svelte +4 -1
  554. package/dist/panel/components/sections/collection/list/row/Row.svelte +16 -16
  555. package/dist/panel/components/sections/collection/list/row/Row.svelte.d.ts +4 -4
  556. package/dist/panel/components/sections/collection/tree/CollectionTree.svelte +4 -80
  557. package/dist/panel/components/sections/collection/tree/CollectionTreeNode.svelte +18 -8
  558. package/dist/panel/components/sections/collection/tree/sortable.d.ts +11 -0
  559. package/dist/panel/components/sections/collection/tree/sortable.js +45 -0
  560. package/dist/panel/components/sections/collection/upload-thumb-cell/UploadThumbCell.svelte +5 -3
  561. package/dist/panel/components/sections/collection/upload-thumb-cell/UploadThumbCell.svelte.d.ts +0 -1
  562. package/dist/panel/components/sections/commands/CommandPalette.svelte +5 -0
  563. package/dist/panel/components/sections/document/AuthAPIKeyDialog.svelte +14 -4
  564. package/dist/panel/components/sections/document/AuthAPIKeyDialog.svelte.d.ts +2 -0
  565. package/dist/panel/components/sections/document/AuthFooter.svelte +37 -31
  566. package/dist/panel/components/sections/document/AuthFooter.svelte.d.ts +0 -2
  567. package/dist/panel/components/sections/document/ButtonSave.svelte +2 -6
  568. package/dist/panel/components/sections/document/ButtonSave.svelte.d.ts +1 -3
  569. package/dist/panel/components/sections/document/ButtonStatus.svelte +24 -11
  570. package/dist/panel/components/sections/document/ChangeSlugDialog.svelte +16 -0
  571. package/dist/panel/components/sections/document/CurrentlyEdited.svelte +5 -3
  572. package/dist/panel/components/sections/document/CurrentlyEdited.svelte.d.ts +1 -0
  573. package/dist/panel/components/sections/document/Document.svelte +29 -18
  574. package/dist/panel/components/sections/document/DocumentChildren.svelte +48 -41
  575. package/dist/panel/components/sections/document/Header.svelte +13 -11
  576. package/dist/panel/components/sections/document/Settings.svelte +127 -157
  577. package/dist/panel/components/sections/document/Versions.svelte +11 -2
  578. package/dist/panel/components/sections/document/upload-header/UploadHeader.svelte +32 -13
  579. package/dist/panel/components/sections/document/upload-header/UploadHeader.svelte.d.ts +2 -0
  580. package/dist/panel/components/sections/document/upload-header/drop-zone/DropZone.svelte +24 -10
  581. package/dist/panel/components/sections/document/upload-header/drop-zone/DropZone.svelte.d.ts +3 -0
  582. package/dist/panel/components/sections/live/LiveEditPanel.svelte +11 -5
  583. package/dist/panel/components/sections/live/LiveEditPanel.svelte.d.ts +10 -3
  584. package/dist/panel/components/sections/live/LiveFloatingUI.svelte +18 -2
  585. package/dist/panel/components/sections/live/LiveFloatingUI.svelte.d.ts +3 -0
  586. package/dist/panel/components/ui/button/button.svelte +0 -3
  587. package/dist/panel/components/ui/calendar/calendar.css +0 -1
  588. package/dist/panel/components/ui/calendar/calendar.svelte.d.ts +1 -1
  589. package/dist/panel/components/ui/card-resource/card-resource.svelte +17 -3
  590. package/dist/panel/components/ui/card-resource/card-resource.svelte.d.ts +2 -0
  591. package/dist/panel/components/ui/checkbox/checkbox.svelte.d.ts +1 -1
  592. package/dist/panel/components/ui/command/command-count.css +6 -0
  593. package/dist/panel/components/ui/command/command-count.svelte +15 -0
  594. package/dist/panel/components/ui/command/command-count.svelte.d.ts +9 -0
  595. package/dist/panel/components/ui/command/command-dialog.css +2 -0
  596. package/dist/panel/components/ui/command/command-input-select.svelte +5 -0
  597. package/dist/panel/components/ui/command/filter.d.ts +10 -0
  598. package/dist/panel/components/ui/command/filter.js +11 -0
  599. package/dist/panel/components/ui/command/index.d.ts +2 -1
  600. package/dist/panel/components/ui/command/index.js +2 -1
  601. package/dist/panel/components/ui/context-menu/context-menu.css +2 -2
  602. package/dist/panel/components/ui/dialog/dialog-content.css +4 -1
  603. package/dist/panel/components/ui/dialog/dialog-content.svelte +8 -1
  604. package/dist/panel/components/ui/dialog/dialog-overlay.css +2 -1
  605. package/dist/panel/components/ui/dropdown-menu/dropdown-menu-content.css +2 -2
  606. package/dist/panel/components/ui/input/input.svelte +3 -0
  607. package/dist/panel/components/ui/language-switcher/LanguageSwitcher.svelte +1 -1
  608. package/dist/panel/components/ui/layer/layer.svelte.d.ts +22 -0
  609. package/dist/panel/components/ui/layer/layer.svelte.js +37 -0
  610. package/dist/panel/components/ui/nav/Nav.svelte +4 -9
  611. package/dist/panel/components/ui/nav/NavGroup.svelte +6 -6
  612. package/dist/panel/components/ui/nav/NavItem.svelte +1 -0
  613. package/dist/panel/components/ui/nav/NavItem.svelte.d.ts +1 -0
  614. package/dist/panel/components/ui/nav/UserButton.svelte +4 -4
  615. package/dist/panel/components/ui/page-header/PageHeader.svelte +1 -5
  616. package/dist/panel/components/ui/page-header/PageHeader.svelte.d.ts +1 -0
  617. package/dist/panel/components/ui/popover/popover-content.css +2 -1
  618. package/dist/panel/components/ui/radio-row-group/radio-row-group.css +0 -1
  619. package/dist/panel/components/ui/scroll-area/scroll-area-scrollbar.svelte +3 -4
  620. package/dist/panel/components/ui/scroll-area/scroll-area-scrollbar.svelte.d.ts +1 -1
  621. package/dist/panel/components/ui/scroll-area/scroll-area.css +0 -6
  622. package/dist/panel/components/ui/scroll-area/scroll-area.svelte +4 -1
  623. package/dist/panel/components/ui/sheet/index.d.ts +1 -1
  624. package/dist/panel/components/ui/sheet/sheet-content.svelte +13 -2
  625. package/dist/panel/components/ui/sheet/sheet-content.svelte.d.ts +3 -0
  626. package/dist/panel/components/ui/sheet/sheet.css +11 -43
  627. package/dist/panel/components/ui/sonner/sonner.css +5 -0
  628. package/dist/panel/components/ui/switch/switch.svelte.d.ts +1 -1
  629. package/dist/panel/components/ui/tag/tag.svelte +8 -1
  630. package/dist/panel/components/ui/tooltip/tooltip-content.svelte +1 -1
  631. package/dist/panel/components/ui/tree/tree-rows.css +1 -8
  632. package/dist/panel/context/api-proxy.svelte.d.ts +2 -0
  633. package/dist/panel/context/api-proxy.svelte.js +30 -4
  634. package/dist/panel/context/blocks-ops.d.ts +6 -0
  635. package/dist/panel/context/blocks-ops.js +6 -0
  636. package/dist/panel/context/bulk-delete.d.ts +4 -3
  637. package/dist/panel/context/bulk-delete.js +13 -7
  638. package/dist/panel/context/collection.svelte.d.ts +10 -22
  639. package/dist/panel/context/collection.svelte.js +73 -115
  640. package/dist/panel/context/commands.svelte.js +5 -0
  641. package/dist/panel/context/config.svelte.js +2 -0
  642. package/dist/panel/context/createContext.svelte.d.ts +1 -0
  643. package/dist/panel/context/createContext.svelte.js +1 -0
  644. package/dist/panel/context/documentForm.svelte.d.ts +4 -2
  645. package/dist/panel/context/documentForm.svelte.js +87 -159
  646. package/dist/panel/context/errors.svelte.d.ts +8 -0
  647. package/dist/panel/context/errors.svelte.js +8 -0
  648. package/dist/panel/context/form.svelte.d.ts +8 -1
  649. package/dist/panel/context/form.svelte.js +37 -40
  650. package/dist/panel/context/livePanel.svelte.d.ts +3 -0
  651. package/dist/panel/context/locale.svelte.js +3 -0
  652. package/dist/panel/context/nav.svelte.js +9 -21
  653. package/dist/panel/context/tree-ops.d.ts +14 -0
  654. package/dist/panel/context/tree-ops.js +70 -0
  655. package/dist/panel/context/versions.svelte.d.ts +6 -0
  656. package/dist/panel/context/versions.svelte.js +18 -0
  657. package/dist/panel/index.d.ts +1 -10
  658. package/dist/panel/pages/area/Area.svelte +1 -1
  659. package/dist/panel/pages/area/actions.server.js +1 -0
  660. package/dist/panel/pages/area/load.server.d.ts +1 -0
  661. package/dist/panel/pages/area/load.server.js +1 -1
  662. package/dist/panel/pages/auth/forgot-password/ForgotPassword.svelte +23 -16
  663. package/dist/panel/pages/auth/forgot-password/load.server.d.ts +1 -0
  664. package/dist/panel/pages/auth/forgot-password/load.server.js +3 -5
  665. package/dist/panel/pages/auth/image.server.d.ts +6 -0
  666. package/dist/panel/pages/auth/image.server.js +19 -0
  667. package/dist/panel/pages/auth/reset-password/ResetPassword.svelte +22 -15
  668. package/dist/panel/pages/auth/reset-password/load.server.d.ts +3 -0
  669. package/dist/panel/pages/auth/reset-password/load.server.js +5 -5
  670. package/dist/panel/pages/auth/sign-in/actions.server.js +33 -25
  671. package/dist/panel/pages/auth/sign-in/load.server.d.ts +4 -0
  672. package/dist/panel/pages/auth/sign-in/load.server.js +6 -5
  673. package/dist/panel/pages/collection/Collection.svelte.d.ts +1 -1
  674. package/dist/panel/pages/collection/CollectionPage.svelte +31 -27
  675. package/dist/panel/pages/collection/CollectionPage.svelte.d.ts +1 -1
  676. package/dist/panel/pages/collection/load.server.d.ts +5 -2
  677. package/dist/panel/pages/collection/load.server.js +53 -54
  678. package/dist/panel/pages/collection-document/CollectionDocument.svelte +1 -1
  679. package/dist/panel/pages/collection-document/actions.server.js +3 -11
  680. package/dist/panel/pages/collection-document/load.server.d.ts +5 -0
  681. package/dist/panel/pages/collection-document/load.server.js +10 -3
  682. package/dist/panel/pages/dashboard/load.server.d.ts +3 -0
  683. package/dist/panel/pages/dashboard/load.server.js +19 -8
  684. package/dist/panel/pages/live/Live.svelte +45 -45
  685. package/dist/panel/pages/live/load.server.d.ts +5 -0
  686. package/dist/panel/pages/live/load.server.js +5 -0
  687. package/dist/panel/pages/shared/DocumentPage.svelte +9 -5
  688. package/dist/panel/pages/shared/DocumentPage.svelte.d.ts +0 -1
  689. package/dist/panel/style/font.css +1 -1
  690. package/dist/panel/style/index.css +21 -6
  691. package/dist/panel/style/palette.css +1 -1
  692. package/dist/panel/style/size.css +1 -0
  693. package/dist/panel/style/z-index.css +18 -0
  694. package/dist/panel/types.d.ts +0 -1
  695. package/dist/panel/util/Sortable.d.ts +6 -1
  696. package/dist/panel/util/Sortable.js +6 -1
  697. package/dist/panel/util/auth.d.ts +18 -0
  698. package/dist/panel/util/auth.js +25 -0
  699. package/dist/panel/util/candidates.svelte.d.ts +118 -0
  700. package/dist/panel/util/candidates.svelte.js +176 -0
  701. package/dist/panel/util/count.d.ts +19 -0
  702. package/dist/panel/util/count.js +20 -0
  703. package/dist/panel/util/dataError.d.ts +1 -0
  704. package/dist/panel/util/dataError.js +1 -0
  705. package/dist/panel/util/storage.d.ts +13 -0
  706. package/dist/panel/util/storage.js +37 -0
  707. package/dist/panel/util/time.d.ts +7 -1
  708. package/dist/panel/util/time.js +19 -5
  709. package/dist/panel/util/upload-file.d.ts +0 -8
  710. package/dist/panel/util/upload-file.js +6 -12
  711. package/dist/server.js +3 -0
  712. package/dist/util/form-data.d.ts +3 -3
  713. package/dist/util/form-data.js +4 -2
  714. package/dist/util/function.d.ts +7 -6
  715. package/dist/util/function.js +7 -6
  716. package/dist/util/object.d.ts +10 -11
  717. package/dist/util/object.js +21 -55
  718. package/dist/util/random.d.ts +8 -12
  719. package/dist/util/random.js +34 -88
  720. package/dist/util/string.js +76 -114
  721. package/dist/util/types.d.ts +2 -0
  722. package/package.json +12 -15
  723. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/getComputedStyle.d.ts +0 -1
  724. package/dist/fields/rich-text/core/extensions/drag-handle/helpers/getComputedStyle.js +0 -4
  725. package/dist/fields/rich-text/core/features/link/component/link-selector.css +0 -0
  726. package/dist/fields/rich-text/core/features/resource/resource.css +0 -0
  727. package/dist/panel/style/util.css +0 -3
  728. package/dist/panel/util/once.svelte.d.ts +0 -3
  729. package/dist/panel/util/once.svelte.js +0 -12
@@ -1,5 +1,5 @@
1
1
  import { bundles } from './rows.server.js';
2
- import { findManyPrototypes, readPrototype } from './read.server.js';
2
+ import { countPrototypes, findManyPrototypes, readPrototype } from './read.server.js';
3
3
  import { deletePrototype, insertPrototype, updatePrototype, updateWherePrototype } from './write.server.js';
4
4
  /**
5
5
  * What the adapter can do to one registered collection.
@@ -16,6 +16,7 @@ export const createCollectionHandle = (deps) => {
16
16
  versions: deps.versions,
17
17
  find: (args) => readPrototype(read, { ...args, ...self }),
18
18
  findMany: (args = {}) => findManyPrototypes(read, { ...args, ...self }),
19
+ count: (args = {}) => countPrototypes(read, { ...args, ...self }),
19
20
  insert: (args) => insertPrototype(write, { ...args, slug, versions: deps.versions }),
20
21
  update: (args) => updatePrototype(write, { ...args, slug, versions: deps.versions }),
21
22
  updateWhere: (args) => updateWherePrototype(read, { ...args, slug }),
@@ -17,14 +17,12 @@ export declare function updateTableRecord(db: any, tables: any, tableName: strin
17
17
  recordId: string;
18
18
  data: any;
19
19
  }): Promise<void>;
20
- /**
21
- * Inserts a new record into a database table
22
- * @returns The ID of the inserted record
23
- */
20
+ /** Inserts `data` as a new row of `tableName` and answers its id: `data.id`, or a new UUID. */
24
21
  export declare function insertTableRecord(db: any, tables: any, tableName: string, data: any): Promise<string>;
25
22
  /**
26
- * Updates or inserts localized data for a record. The row is the one `ownerId` and `locale` name;
27
- * the `ROW_ADDRESS` keys of `data` are dropped.
23
+ * Writes `data` on the locales row of `ownerId` in `locale`: updates the row when it exists,
24
+ * inserts it otherwise. The `ROW_ADDRESS` keys of `data` are dropped. Empty `data` writes nothing,
25
+ * so a locale nothing was written in has no row.
28
26
  */
29
27
  export declare function upsertLocalizedData(db: any, tables: any, tableLocalesName: string, options: {
30
28
  ownerId: string;
@@ -32,14 +30,24 @@ export declare function upsertLocalizedData(db: any, tables: any, tableLocalesNa
32
30
  locale: string;
33
31
  }): Promise<void>;
34
32
  /**
35
- * Prepares data for database operations by transforming it according to table schemas
33
+ * Splits a document's data between a table and its `__$$locales` branch: each key named like a
34
+ * column of one of them is copied there, bookkeeping columns (`id`, `ownerId`, `locale`)
35
+ * included. Without a `locale`, or without a branch, everything goes to the table.
36
+ *
37
+ * ```ts
38
+ * // title localized, slug not
39
+ * prepareSchemaData(
40
+ * { title: 'Home', slug: 'home' },
41
+ * { mainTableName: 'pages', localesTableName: 'pages__$$locales', locale: 'en', tables }
42
+ * )
43
+ * // { mainData: { slug: 'home' }, localizedData: { title: 'Home' }, isLocalized: true }
44
+ * ```
36
45
  */
37
46
  export declare function prepareSchemaData(data: any, options: {
38
47
  mainTableName: string;
39
48
  localesTableName: string;
40
49
  locale?: string;
41
50
  tables: any;
42
- fillNotNull?: boolean;
43
51
  }): {
44
52
  mainData: Record<string, any>;
45
53
  localizedData: Record<string, any>;
@@ -66,75 +74,48 @@ export declare function prepareSchemaData(data: any, options: {
66
74
  export declare function mergeContentRow(doc: RawDoc, contentTable: string, config: {
67
75
  fields: FieldBuilder[];
68
76
  }, select?: string[]): RawDoc;
77
+ /**
78
+ * The drizzle `columns` of a read with `select`: `id`, plus each selected path that is a column
79
+ * of `table` (`attributes.title` -> `attributes__title`). `undefined` without a `select`, which
80
+ * reads every column.
81
+ */
69
82
  export declare function columnsParams({ table, select }: {
70
83
  table: Dic;
71
84
  select?: string[];
72
85
  }): Dic | undefined;
73
86
  /**
74
- * Convert a document path using dot notation to a database schema path using double underscores.
75
- * This transformation is needed because SQL databases don't support dots in column names.
76
- *
77
- * @param path - The document path with dot notation
78
- * @returns The database column path with double underscore notation
87
+ * A document path as a column name: SQL names hold no dot, so `.` becomes `__`.
79
88
  *
80
- * @example
81
- * // Returns 'attributes__hero__title'
82
- * pathToDatabaseColumn('attributes.hero.title');
89
+ * ```ts
90
+ * pathToDatabaseColumn('attributes.hero.title') // 'attributes__hero__title'
91
+ * ```
83
92
  */
84
93
  export declare const pathToDatabaseColumn: (path: string) => string;
85
94
  /**
86
- * Convert a database schema path using double underscores to a document path using dot notation.
87
- * This transforms database column names back to document property paths.
88
- *
89
- * @param path - The database column path with double underscore notation
90
- * @returns The document path with dot notation
95
+ * A column name as a document path. A table key (it holds a `$`) stays as it is.
91
96
  *
92
- * @example
93
- * // Returns 'attributes.hero.title'
94
- * databaseColumnToPath('attributes__hero__title');
97
+ * ```ts
98
+ * databaseColumnToPath('attributes__hero__title') // 'attributes.hero.title'
99
+ * ```
95
100
  */
96
101
  export declare const databaseColumnToPath: (path: string) => string;
97
102
  /**
98
- * Converts an object's keys from database schema format (double underscores) to document format (dot notation).
99
- *
100
- * This function takes an object with keys using database column naming (e.g., 'attributes__title')
101
- * and transforms them to document path format (e.g., 'attributes.title') while preserving the values.
103
+ * The object with each key turned from a column name into a document path.
102
104
  *
103
- * @param obj - The object with database column keys
104
- * @returns A new object with keys converted to document paths
105
- *
106
- * @example
107
- * // Returns { 'attributes.title': 'Home' }
108
- * transformDatabaseColumnsToPaths({ 'attributes__title': 'Home' });
105
+ * ```ts
106
+ * transformDatabaseColumnsToPaths({ attributes__title: 'Home' }) // { 'attributes.title': 'Home' }
107
+ * ```
109
108
  */
110
109
  export declare const transformDatabaseColumnsToPaths: (obj: Record<string, any>) => Record<string, any>;
111
110
  /**
112
- * Extracts values from a data object and maps them to database column names using schema paths.
111
+ * The values of `data` for `columns`, keyed by column name: each column's path is read from the
112
+ * nested data (`attributes__title` from `data.attributes.title`). A missing value is left out,
113
+ * `null` is kept.
113
114
  *
114
- * This function converts document data (which may use nested objects with dot notation paths)
115
- * into a flat object with keys that match the database schema (using double underscore notation).
116
- * It only includes fields that exist in the provided columns schema.
117
- *
118
- * @param data - The document data object (may be nested)
119
- * @param columns - The database schema columns definition
120
- * @param params - Optional parameters for transformation
121
- * @param params.fillNotNull - If true, adds default values for NOT NULL columns
122
- * @returns A flat object with database column names and values
123
- *
124
- * @example
125
- * // Returns { 'attributes__title': 'Home' }
126
- * transformDataToSchema(
127
- * { attributes: { title: 'Home' } },
128
- * { 'attributes__title': { dataType: 'string', notNull: true } }
129
- * );
130
- *
131
- * // With fillNotNull, provides defaults for missing NOT NULL columns
132
- * transformDataToSchema(
133
- * { attributes: {} },
134
- * { 'attributes__title': { dataType: 'string', notNull: true } },
135
- * { fillNotNull: true }
136
- * ); // Returns { 'attributes__title': '' }
115
+ * ```ts
116
+ * transformDataToSchema({ attributes: { title: 'Home' } }, columns) // { attributes__title: 'Home' }
117
+ * transformDataToSchema({ attributes: {} }, columns) // {}
118
+ * transformDataToSchema({ attributes: null }, columns) // { attributes__title: null }
119
+ * ```
137
120
  */
138
- export declare const transformDataToSchema: (data: Record<string, any>, columns: Record<string, any>, params?: {
139
- fillNotNull?: boolean;
140
- }) => Record<string, any>;
121
+ export declare const transformDataToSchema: (data: Record<string, any>, columns: Record<string, any>) => Record<string, any>;
@@ -1,6 +1,5 @@
1
1
  import { RimeError } from '../core/errors/index.js';
2
2
  import { omit, pick } from '../util/object.js';
3
- import { randomId } from '../util/random.js';
4
3
  import { baseFieldNames } from '../core/fields/util.js';
5
4
  import { and, eq, getTableColumns } from 'drizzle-orm';
6
5
  import { isPathsTable, JOIN_SUFFIX } from './naming.server.js';
@@ -24,10 +23,7 @@ export async function updateTableRecord(db, tables, tableName, options) {
24
23
  await db.update(tables[tableName]).set(data).where(eq(tables[tableName].id, recordId));
25
24
  }
26
25
  }
27
- /**
28
- * Inserts a new record into a database table
29
- * @returns The ID of the inserted record
30
- */
26
+ /** Inserts `data` as a new row of `tableName` and answers its id: `data.id`, or a new UUID. */
31
27
  export async function insertTableRecord(db, tables, tableName, data) {
32
28
  const recordId = data.id || generatePK();
33
29
  await db.insert(tables[tableName]).values({
@@ -37,8 +33,9 @@ export async function insertTableRecord(db, tables, tableName, data) {
37
33
  return recordId;
38
34
  }
39
35
  /**
40
- * Updates or inserts localized data for a record. The row is the one `ownerId` and `locale` name;
41
- * the `ROW_ADDRESS` keys of `data` are dropped.
36
+ * Writes `data` on the locales row of `ownerId` in `locale`: updates the row when it exists,
37
+ * inserts it otherwise. The `ROW_ADDRESS` keys of `data` are dropped. Empty `data` writes nothing,
38
+ * so a locale nothing was written in has no row.
42
39
  */
43
40
  export async function upsertLocalizedData(db, tables, tableLocalesName, options) {
44
41
  const { ownerId, locale } = options;
@@ -49,14 +46,12 @@ export async function upsertLocalizedData(db, tables, tableLocalesName, options)
49
46
  where: { ownerId, locale }
50
47
  });
51
48
  if (localizedRow) {
52
- // Update existing localized data
53
49
  await db
54
50
  .update(tableLocales)
55
51
  .set(data)
56
52
  .where(and(eq(tableLocales.ownerId, ownerId), eq(tableLocales.locale, locale)));
57
53
  }
58
54
  else {
59
- // Insert new localized data
60
55
  await db.insert(tableLocales).values({
61
56
  ...data,
62
57
  id: generatePK(),
@@ -67,25 +62,34 @@ export async function upsertLocalizedData(db, tables, tableLocalesName, options)
67
62
  }
68
63
  }
69
64
  /**
70
- * Prepares data for database operations by transforming it according to table schemas
65
+ * Splits a document's data between a table and its `__$$locales` branch: each key named like a
66
+ * column of one of them is copied there, bookkeeping columns (`id`, `ownerId`, `locale`)
67
+ * included. Without a `locale`, or without a branch, everything goes to the table.
68
+ *
69
+ * ```ts
70
+ * // title localized, slug not
71
+ * prepareSchemaData(
72
+ * { title: 'Home', slug: 'home' },
73
+ * { mainTableName: 'pages', localesTableName: 'pages__$$locales', locale: 'en', tables }
74
+ * )
75
+ * // { mainData: { slug: 'home' }, localizedData: { title: 'Home' }, isLocalized: true }
76
+ * ```
71
77
  */
72
78
  export function prepareSchemaData(data, options) {
73
- const { mainTableName, localesTableName, locale, tables, fillNotNull } = options;
79
+ const { mainTableName, localesTableName, locale, tables } = options;
74
80
  if (locale && localesTableName in tables) {
75
- // Handle localized fields
76
81
  const unlocalizedColumns = getTableColumns(tables[mainTableName]);
77
82
  const localizedColumns = getTableColumns(tables[localesTableName]);
78
83
  return {
79
- mainData: transformDataToSchema(data, unlocalizedColumns, { fillNotNull }),
80
- localizedData: transformDataToSchema(data, localizedColumns, { fillNotNull }),
84
+ mainData: transformDataToSchema(data, unlocalizedColumns),
85
+ localizedData: transformDataToSchema(data, localizedColumns),
81
86
  isLocalized: true
82
87
  };
83
88
  }
84
89
  else {
85
- // Handle non-localized fields
86
90
  const columns = getTableColumns(tables[mainTableName]);
87
91
  return {
88
- mainData: transformDataToSchema(data, columns, { fillNotNull }),
92
+ mainData: transformDataToSchema(data, columns),
89
93
  localizedData: {},
90
94
  isLocalized: false
91
95
  };
@@ -110,8 +114,7 @@ export function prepareSchemaData(data, options) {
110
114
  * written.
111
115
  */
112
116
  export function mergeContentRow(doc, contentTable, config, select) {
113
- // A base row with no content row is as good as absent — note this can be empty when a query
114
- // returns no result.
117
+ // A base row with no content row is as good as absent.
115
118
  if (!doc[contentTable] || doc[contentTable].length === 0) {
116
119
  throw new RimeError(RimeError.NOT_FOUND);
117
120
  }
@@ -127,7 +130,7 @@ export function mergeContentRow(doc, contentTable, config, select) {
127
130
  ? pick([...select.filter((field) => rootProps.includes(field)), 'id', ...joined], doc)
128
131
  : pick(['id', ...joined], doc);
129
132
  // Filter out root props as they should come from the doc,
130
- // plus the ownerId wich is equals to doc.id
133
+ // plus the ownerId which is equals to doc.id
131
134
  const contentFields = omit([...rootProps, 'ownerId'], contentRow);
132
135
  // `pick`/`omit` return generic Dic types, so TS can't statically confirm
133
136
  // `id` survived — it always does, since we explicitly pick it above.
@@ -148,17 +151,20 @@ export function mergeContentRow(doc, contentTable, config, select) {
148
151
  contentId: contentRow.id
149
152
  };
150
153
  }
154
+ /**
155
+ * The drizzle `columns` of a read with `select`: `id`, plus each selected path that is a column
156
+ * of `table` (`attributes.title` -> `attributes__title`). `undefined` without a `select`, which
157
+ * reads every column.
158
+ */
151
159
  export function columnsParams({ table, select }) {
152
160
  // Create an object to hold the columns we want to select
153
161
  const selectColumns = {};
154
162
  // If select fields are specified, build the select columns object
155
163
  if (select && select.length > 0) {
156
- // Always include the ID column for the version
157
164
  selectColumns.id = true;
158
165
  // Process each requested field
159
166
  for (const path of select) {
160
167
  const sqlPath = pathToDatabaseColumn(path);
161
- // If this column exists on the content table, add it to our select
162
168
  if (sqlPath in table) {
163
169
  selectColumns[sqlPath] = true;
164
170
  }
@@ -167,27 +173,19 @@ export function columnsParams({ table, select }) {
167
173
  return Object.keys(selectColumns).length ? selectColumns : undefined;
168
174
  }
169
175
  /**
170
- * Convert a document path using dot notation to a database schema path using double underscores.
171
- * This transformation is needed because SQL databases don't support dots in column names.
172
- *
173
- * @param path - The document path with dot notation
174
- * @returns The database column path with double underscore notation
176
+ * A document path as a column name: SQL names hold no dot, so `.` becomes `__`.
175
177
  *
176
- * @example
177
- * // Returns 'attributes__hero__title'
178
- * pathToDatabaseColumn('attributes.hero.title');
178
+ * ```ts
179
+ * pathToDatabaseColumn('attributes.hero.title') // 'attributes__hero__title'
180
+ * ```
179
181
  */
180
182
  export const pathToDatabaseColumn = (path) => path.replace(/\./g, '__');
181
183
  /**
182
- * Convert a database schema path using double underscores to a document path using dot notation.
183
- * This transforms database column names back to document property paths.
184
- *
185
- * @param path - The database column path with double underscore notation
186
- * @returns The document path with dot notation
184
+ * A column name as a document path. A table key (it holds a `$`) stays as it is.
187
185
  *
188
- * @example
189
- * // Returns 'attributes.hero.title'
190
- * databaseColumnToPath('attributes__hero__title');
186
+ * ```ts
187
+ * databaseColumnToPath('attributes__hero__title') // 'attributes.hero.title'
188
+ * ```
191
189
  */
192
190
  export const databaseColumnToPath = (path) => isStructuralKey(path) ? path : path.replace(/__/g, '.');
193
191
  /**
@@ -204,17 +202,11 @@ export const databaseColumnToPath = (path) => isStructuralKey(path) ? path : pat
204
202
  */
205
203
  const isStructuralKey = (key) => key.includes('$');
206
204
  /**
207
- * Converts an object's keys from database schema format (double underscores) to document format (dot notation).
208
- *
209
- * This function takes an object with keys using database column naming (e.g., 'attributes__title')
210
- * and transforms them to document path format (e.g., 'attributes.title') while preserving the values.
211
- *
212
- * @param obj - The object with database column keys
213
- * @returns A new object with keys converted to document paths
205
+ * The object with each key turned from a column name into a document path.
214
206
  *
215
- * @example
216
- * // Returns { 'attributes.title': 'Home' }
217
- * transformDatabaseColumnsToPaths({ 'attributes__title': 'Home' });
207
+ * ```ts
208
+ * transformDatabaseColumnsToPaths({ attributes__title: 'Home' }) // { 'attributes.title': 'Home' }
209
+ * ```
218
210
  */
219
211
  export const transformDatabaseColumnsToPaths = (obj) => {
220
212
  const result = {};
@@ -224,36 +216,19 @@ export const transformDatabaseColumnsToPaths = (obj) => {
224
216
  return result;
225
217
  };
226
218
  /**
227
- * Extracts values from a data object and maps them to database column names using schema paths.
228
- *
229
- * This function converts document data (which may use nested objects with dot notation paths)
230
- * into a flat object with keys that match the database schema (using double underscore notation).
231
- * It only includes fields that exist in the provided columns schema.
232
- *
233
- * @param data - The document data object (may be nested)
234
- * @param columns - The database schema columns definition
235
- * @param params - Optional parameters for transformation
236
- * @param params.fillNotNull - If true, adds default values for NOT NULL columns
237
- * @returns A flat object with database column names and values
238
- *
239
- * @example
240
- * // Returns { 'attributes__title': 'Home' }
241
- * transformDataToSchema(
242
- * { attributes: { title: 'Home' } },
243
- * { 'attributes__title': { dataType: 'string', notNull: true } }
244
- * );
245
- *
246
- * // With fillNotNull, provides defaults for missing NOT NULL columns
247
- * transformDataToSchema(
248
- * { attributes: {} },
249
- * { 'attributes__title': { dataType: 'string', notNull: true } },
250
- * { fillNotNull: true }
251
- * ); // Returns { 'attributes__title': '' }
219
+ * The values of `data` for `columns`, keyed by column name: each column's path is read from the
220
+ * nested data (`attributes__title` from `data.attributes.title`). A missing value is left out,
221
+ * `null` is kept.
222
+ *
223
+ * ```ts
224
+ * transformDataToSchema({ attributes: { title: 'Home' } }, columns) // { attributes__title: 'Home' }
225
+ * transformDataToSchema({ attributes: {} }, columns) // {}
226
+ * transformDataToSchema({ attributes: null }, columns) // { attributes__title: null }
227
+ * ```
252
228
  */
253
- export const transformDataToSchema = (data, columns, params = { fillNotNull: false }) => {
229
+ export const transformDataToSchema = (data, columns) => {
254
230
  const result = {};
255
231
  for (const column of Object.keys(columns)) {
256
- const columnConfig = columns[column];
257
232
  // Convert schema path (with __) to doc path (with .)
258
233
  const docPath = databaseColumnToPath(column);
259
234
  // Get value from nested path
@@ -265,45 +240,9 @@ export const transformDataToSchema = (data, columns, params = { fillNotNull: fal
265
240
  break;
266
241
  value = value[part];
267
242
  }
268
- // Case 1: Value exists and is not null - always use it
269
- if (value !== undefined && value !== null) {
243
+ if (value !== undefined) {
270
244
  result[column] = value;
271
- continue;
272
- }
273
- // Case 2: Value is null - use it unless we need to fill it
274
- if (value === null && !params.fillNotNull) {
275
- result[column] = null;
276
- continue;
277
- }
278
- // Case 3: Add placeholders for missing or null values in not-null columns
279
- if (params.fillNotNull && columnConfig.notNull) {
280
- if (column === 'id') {
281
- result[column] = randomId(32);
282
- continue;
283
- }
284
- // A column with a default of its own takes it: the insert leaves it out
285
- if (columnConfig.hasDefault)
286
- continue;
287
- console.warn(`No default value provided for ${column}, setting it with a placeholder`);
288
- const empty = placeholder(columnConfig.dataType);
289
- if (empty !== undefined) {
290
- result[column] = empty;
291
- }
292
245
  }
293
246
  }
294
247
  return result;
295
248
  };
296
- /** A placeholder of a column's type, by drizzle's `dataType`: `'number double'`, `'object date'`… */
297
- const placeholder = (dataType) => {
298
- if (dataType.startsWith('string'))
299
- return '';
300
- if (dataType.startsWith('number'))
301
- return 0;
302
- if (dataType === 'boolean')
303
- return false;
304
- if (dataType === 'object date')
305
- return new Date();
306
- if (dataType === 'object json')
307
- return {};
308
- return undefined;
309
- };
@@ -1,13 +1,15 @@
1
1
  import type { FormFieldBuilder } from '../../core/fields/builders/form-field-builder.js';
2
2
  import type { FormField } from '../../fields/types.js';
3
3
  /**
4
- * Renders a single Drizzle column definition for any leaf FormFieldBuilder,
5
- * driven by the field's own `dataType` (storage type) and `_references`
6
- * (foreign key) — the adapter owns all Drizzle syntax, fields only declare
7
- * storage semantics via `dataType`.
4
+ * Renders a single Drizzle column definition for any leaf FormFieldBuilder, driven by the
5
+ * field's own `dataType` (storage type) and `_references` (foreign key). A field column is
6
+ * nullable and has no default, `NULL` being a value nobody wrote, unless the field says
7
+ * `$notNull()`. A `.unique()` field gets no constraint either: `validateFields` checks it.
8
8
  *
9
9
  * @example
10
- * // returns "title: text('title').notNull().default(\"\"),"
11
- * toSchemaColumn(text('title').required())
10
+ * toSchemaColumn(text('title').required()) // "title: text('title')"
11
+ * toSchemaColumn(slug('slug').unique()) // "slug: text('slug')"
12
+ * toSchemaColumn(toggle('ok').$notNull({ default: false }))
13
+ * // "ok: integer('ok', { mode: 'boolean' }).notNull().default(false)"
12
14
  */
13
15
  export declare function toSchemaColumn(field: FormFieldBuilder<FormField>, parentPath?: string): string;
@@ -1,5 +1,6 @@
1
- import { templateReferences, templateUniqueRequired } from './templates.server.js';
1
+ import { templateReferences } from './templates.server.js';
2
2
  import { getSchemaColumnNames } from '../naming.server.js';
3
+ /** How each field `dataType` is spelled in drizzle. */
3
4
  const COLUMN_EXPR = {
4
5
  text: (snake) => `text('${snake}')`,
5
6
  boolean: (snake) => `integer('${snake}', { mode: 'boolean' })`,
@@ -7,60 +8,23 @@ const COLUMN_EXPR = {
7
8
  timestamp: (snake) => `integer('${snake}', { mode: 'timestamp_ms' })`,
8
9
  json: (snake) => `text('${snake}', { mode: 'json' })`
9
10
  };
10
- /** Whether a value can be written as a column's DEFAULT, by the column's storage type. */
11
- const FITS = {
12
- text: (value) => typeof value === 'string',
13
- boolean: (value) => typeof value === 'boolean',
14
- number: (value) => typeof value === 'number',
15
- timestamp: (value) => value instanceof Date,
16
- json: (value) => typeof value === 'object' && value !== null
17
- };
18
- /** The empty value of each storage type: what rows written before the column was added hold. */
19
- const EMPTY = {
20
- text: '',
21
- boolean: false,
22
- number: 0,
23
- timestamp: new Date(0),
24
- json: {}
25
- };
26
- /** The field types whose empty value is not their storage type's. */
27
- const EMPTY_BY_TYPE = {
28
- time: () => '00:00',
29
- select: (field) => (field.get.many ? [] : '')
30
- };
31
- /**
32
- * The DEFAULT of a required column: the field's own `defaultValue` when the column can hold it,
33
- * else an empty value of the column's type. A function default is not a value and is skipped.
34
- *
35
- * ```ts
36
- * columnDefault(select('kind').options('a').required()) // ''
37
- * columnDefault(number('n').required().defaultValue(3)) // 3
38
- * columnDefault(checkbox('ok').required().defaultValue(() => 1)) // false
39
- * ```
40
- */
41
- const columnDefault = (field) => {
42
- const own = field.get.defaultValue;
43
- if (FITS[field.dataType](own))
44
- return own;
45
- return EMPTY_BY_TYPE[field.type]?.(field) ?? EMPTY[field.dataType];
46
- };
47
11
  /**
48
- * Renders a single Drizzle column definition for any leaf FormFieldBuilder,
49
- * driven by the field's own `dataType` (storage type) and `_references`
50
- * (foreign key) — the adapter owns all Drizzle syntax, fields only declare
51
- * storage semantics via `dataType`.
12
+ * Renders a single Drizzle column definition for any leaf FormFieldBuilder, driven by the
13
+ * field's own `dataType` (storage type) and `_references` (foreign key). A field column is
14
+ * nullable and has no default, `NULL` being a value nobody wrote, unless the field says
15
+ * `$notNull()`. A `.unique()` field gets no constraint either: `validateFields` checks it.
52
16
  *
53
17
  * @example
54
- * // returns "title: text('title').notNull().default(\"\"),"
55
- * toSchemaColumn(text('title').required())
18
+ * toSchemaColumn(text('title').required()) // "title: text('title')"
19
+ * toSchemaColumn(slug('slug').unique()) // "slug: text('slug')"
20
+ * toSchemaColumn(toggle('ok').$notNull({ default: false }))
21
+ * // "ok: integer('ok', { mode: 'boolean' }).notNull().default(false)"
56
22
  */
57
23
  export function toSchemaColumn(field, parentPath) {
58
24
  const { camel, snake } = getSchemaColumnNames({ name: field.name, parentPath });
59
- // `unique` only exists on text, email and slug, so reading it off the generic FormField needs
60
- // a narrow cast.
61
- const { unique, required } = field.get;
25
+ const { notNull } = field.get;
62
26
  const columnExpr = COLUMN_EXPR[field.dataType](snake);
63
27
  const referencesStr = field._references ? templateReferences(field._references) : '';
64
- const suffix = templateUniqueRequired({ unique, required }, columnDefault(field));
65
- return `${camel}: ${columnExpr}${referencesStr}${suffix}`;
28
+ const notNullStr = notNull ? `.notNull().default(${JSON.stringify(notNull.default)})` : '';
29
+ return `${camel}: ${columnExpr}${referencesStr}${notNullStr}`;
66
30
  }
@@ -1,3 +1,4 @@
1
1
  import type { BuiltConfig } from '../../core/config/types.js';
2
+ /** Builds the schema source and hands it to `write`, which writes the file and runs drizzle-kit. */
2
3
  declare const generateSchema: (config: BuiltConfig) => Promise<void>;
3
4
  export default generateSchema;
@@ -5,6 +5,11 @@ import { generateJunctionTableDefinition } from './relations/junction.server.js'
5
5
  import buildRootTable, {} from './root.server.js';
6
6
  import { templateDeclaredTable, templateExportSchema, templateExportTables, templateHead, templateImports, templatePathsTable, templateRelations } from './templates.server.js';
7
7
  import write from './write.server.js';
8
+ /**
9
+ * The source of the generated drizzle schema: per prototype its table (two for a versioned one),
10
+ * locales branches, child tables, relations junction and, with `$url`, paths table; then the
11
+ * declared tables, the `tables` export, the one `relations` block and the `schema` export.
12
+ */
8
13
  async function generateSchemaString(config) {
9
14
  // Every prototype config that generates a schema, collections and areas alike.
10
15
  const prototypes = [...config.collections, ...config.areas].filter((prototype) => prototype._generateSchema !== false);
@@ -94,6 +99,7 @@ async function generateSchemaString(config) {
94
99
  schema.push(templateExportSchema({ enumTables }));
95
100
  return schema.join('\n').replace(/\n{3,}/g, '\n\n');
96
101
  }
102
+ /** Builds the schema source and hands it to `write`, which writes the file and runs drizzle-kit. */
97
103
  const generateSchema = async (config) => {
98
104
  const result = await generateSchemaString(config);
99
105
  write(result);
@@ -1,9 +1,9 @@
1
1
  import type { RelationTargets } from '../root.server.js';
2
2
  import type { TableName } from '../../naming.server.js';
3
3
  /**
4
- * Generates a junction table definition for many-to-many relationships
5
- * Takes a table name, the collections its relation fields point at, and locale flag to create:
6
- * - A junction table (e.g. 'pages__$relations') with references to related tables
4
+ * The one junction table of a prototype: the rows of every relation field, told apart by `path`,
5
+ * with one target column per related collection. `junctionTable` is empty when no relation field
6
+ * points anywhere.
7
7
  *
8
8
  * @example
9
9
  * {
@@ -1,9 +1,9 @@
1
1
  import { tableName as buildTableName } from '../../naming.server.js';
2
2
  import { templateRelationFieldsTable } from '../templates.server.js';
3
3
  /**
4
- * Generates a junction table definition for many-to-many relationships
5
- * Takes a table name, the collections its relation fields point at, and locale flag to create:
6
- * - A junction table (e.g. 'pages__$relations') with references to related tables
4
+ * The one junction table of a prototype: the rows of every relation field, told apart by `path`,
5
+ * with one target column per related collection. `junctionTable` is empty when no relation field
6
+ * points anywhere.
7
7
  *
8
8
  * @example
9
9
  * {
@@ -18,6 +18,10 @@ type Args = {
18
18
  locales?: LocaleConfig[];
19
19
  hasParent?: boolean;
20
20
  relationTargets?: RelationTargets;
21
+ /**
22
+ * Parent table -> its child tables, for the `defineRelations` block. The nested calls add to
23
+ * the same one.
24
+ */
21
25
  relationsDic?: Record<string, string[]>;
22
26
  /**
23
27
  * Storage-only columns to append to this config's table, in order.