@beechcms/core 0.8.0 → 0.9.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 (389) hide show
  1. package/dist/auth/account-email.d.ts +3 -0
  2. package/dist/auth/account-email.d.ts.map +1 -0
  3. package/dist/auth/account-email.js +9 -0
  4. package/dist/auth/password-reset-token.repository.d.ts +13 -2
  5. package/dist/auth/password-reset-token.repository.d.ts.map +1 -1
  6. package/dist/auth/user.repository.d.ts +69 -4
  7. package/dist/auth/user.repository.d.ts.map +1 -1
  8. package/dist/automations-grammar-words.d.ts +2 -0
  9. package/dist/automations-grammar-words.d.ts.map +1 -0
  10. package/dist/automations-grammar-words.js +8 -0
  11. package/dist/automations.repository.interface.d.ts +19 -0
  12. package/dist/automations.repository.interface.d.ts.map +1 -0
  13. package/dist/automations.repository.interface.js +3 -0
  14. package/dist/automations.runner.interface.d.ts +10 -0
  15. package/dist/automations.runner.interface.d.ts.map +1 -0
  16. package/dist/automations.runner.interface.js +3 -0
  17. package/dist/automations.runner.stub.d.ts +5 -0
  18. package/dist/automations.runner.stub.d.ts.map +1 -0
  19. package/dist/automations.runner.stub.js +7 -0
  20. package/dist/automations.types.d.ts +75 -0
  21. package/dist/automations.types.d.ts.map +1 -0
  22. package/dist/automations.types.js +3 -0
  23. package/dist/clock.d.ts +25 -0
  24. package/dist/clock.d.ts.map +1 -0
  25. package/dist/clock.js +11 -0
  26. package/dist/common/canonical-json.d.ts +31 -0
  27. package/dist/common/canonical-json.d.ts.map +1 -0
  28. package/dist/common/canonical-json.js +91 -0
  29. package/dist/content/content-scan.repository.d.ts +1 -1
  30. package/dist/content/content.repository.d.ts +154 -3
  31. package/dist/content/content.repository.d.ts.map +1 -1
  32. package/dist/content/content.repository.js +62 -0
  33. package/dist/content/deletion-ledger.d.ts +39 -0
  34. package/dist/content/deletion-ledger.d.ts.map +1 -0
  35. package/dist/content/deletion-ledger.js +3 -0
  36. package/dist/content/seed-media-purge.repository.d.ts +34 -0
  37. package/dist/content/seed-media-purge.repository.d.ts.map +1 -0
  38. package/dist/content/seed-media-purge.repository.js +3 -0
  39. package/dist/content/seed.repository.d.ts +14 -0
  40. package/dist/content/seed.repository.d.ts.map +1 -1
  41. package/dist/content-scan.repository.d.ts +9 -0
  42. package/dist/content-scan.repository.d.ts.map +1 -0
  43. package/dist/content-scan.repository.js +3 -0
  44. package/dist/content.repository.d.ts +247 -0
  45. package/dist/content.repository.d.ts.map +1 -0
  46. package/dist/content.repository.js +59 -0
  47. package/dist/dashboard-layout/content-view.d.ts +757 -0
  48. package/dist/dashboard-layout/content-view.d.ts.map +1 -0
  49. package/dist/dashboard-layout/content-view.js +285 -0
  50. package/dist/dashboard-layout/content-view.repository.d.ts +39 -0
  51. package/dist/dashboard-layout/content-view.repository.d.ts.map +1 -0
  52. package/dist/dashboard-layout/content-view.repository.js +3 -0
  53. package/dist/dashboard-layout/dashboard-layout.d.ts +5 -0
  54. package/dist/dashboard-layout/dashboard-layout.d.ts.map +1 -1
  55. package/dist/dashboard-layout/dashboard-layout.js +17 -9
  56. package/dist/dashboard-layout/kanban/kanban.d.ts +32 -18
  57. package/dist/dashboard-layout/kanban/kanban.d.ts.map +1 -1
  58. package/dist/dashboard-layout/kanban/kanban.js +45 -21
  59. package/dist/dashboard-layout/seed-layout.d.ts +22 -31
  60. package/dist/dashboard-layout/seed-layout.d.ts.map +1 -1
  61. package/dist/dashboard-layout/seed-layout.js +93 -18
  62. package/dist/dashboard-layout/seed-layout.repository.d.ts +1 -5
  63. package/dist/dashboard-layout/seed-layout.repository.d.ts.map +1 -1
  64. package/dist/dashboard-layout.d.ts +154 -0
  65. package/dist/dashboard-layout.d.ts.map +1 -0
  66. package/dist/dashboard-layout.js +186 -0
  67. package/dist/dashboard-layout.repository.d.ts +18 -0
  68. package/dist/dashboard-layout.repository.d.ts.map +1 -0
  69. package/dist/dashboard-layout.repository.js +3 -0
  70. package/dist/dashboard-permissions.d.ts +3 -0
  71. package/dist/dashboard-permissions.d.ts.map +1 -0
  72. package/dist/dashboard-permissions.js +11 -0
  73. package/dist/dashboard-scopes.d.ts +12 -0
  74. package/dist/dashboard-scopes.d.ts.map +1 -0
  75. package/dist/dashboard-scopes.js +30 -0
  76. package/dist/define-seed.d.ts +3 -0
  77. package/dist/define-seed.d.ts.map +1 -0
  78. package/dist/define-seed.js +5 -0
  79. package/dist/demo-data.repository.d.ts +5 -0
  80. package/dist/demo-data.repository.d.ts.map +1 -0
  81. package/dist/demo-data.repository.js +3 -0
  82. package/dist/email.provider.d.ts +32 -0
  83. package/dist/email.provider.d.ts.map +1 -0
  84. package/dist/email.provider.js +4 -0
  85. package/dist/engine/ddl/ddl.d.ts +247 -0
  86. package/dist/engine/ddl/ddl.d.ts.map +1 -0
  87. package/dist/engine/ddl/ddl.js +653 -0
  88. package/dist/engine/ddl/schema-mutator.d.ts +29 -0
  89. package/dist/engine/ddl/schema-mutator.d.ts.map +1 -0
  90. package/dist/engine/ddl/schema-mutator.js +3 -0
  91. package/dist/engine/ddl/seed-ddl-destructive.d.ts +40 -0
  92. package/dist/engine/ddl/seed-ddl-destructive.d.ts.map +1 -0
  93. package/dist/engine/ddl/seed-ddl-destructive.js +149 -0
  94. package/dist/engine/ddl/seed-ddl.d.ts +43 -0
  95. package/dist/engine/ddl/seed-ddl.d.ts.map +1 -0
  96. package/dist/engine/ddl/seed-ddl.js +115 -0
  97. package/dist/engine/ddl/seed-purge-guards.d.ts +7 -0
  98. package/dist/engine/ddl/seed-purge-guards.d.ts.map +1 -0
  99. package/dist/engine/ddl/seed-purge-guards.js +19 -0
  100. package/dist/engine/engine.d.ts +4 -3
  101. package/dist/engine/engine.d.ts.map +1 -1
  102. package/dist/engine/engine.js +4 -3
  103. package/dist/engine/introspection/introspection.d.ts +101 -0
  104. package/dist/engine/introspection/introspection.d.ts.map +1 -0
  105. package/dist/engine/introspection/introspection.js +127 -0
  106. package/dist/engine/introspection/relation-audit.d.ts +46 -0
  107. package/dist/engine/introspection/relation-audit.d.ts.map +1 -0
  108. package/dist/engine/introspection/relation-audit.js +103 -0
  109. package/dist/engine/introspection/schema-fingerprint.d.ts +74 -0
  110. package/dist/engine/introspection/schema-fingerprint.d.ts.map +1 -0
  111. package/dist/engine/introspection/schema-fingerprint.js +102 -0
  112. package/dist/engine/introspection.d.ts +101 -0
  113. package/dist/engine/introspection.d.ts.map +1 -0
  114. package/dist/engine/introspection.js +127 -0
  115. package/dist/engine/localization/localization.d.ts +127 -0
  116. package/dist/engine/localization/localization.d.ts.map +1 -0
  117. package/dist/engine/localization/localization.js +212 -0
  118. package/dist/engine/localization.d.ts +127 -0
  119. package/dist/engine/localization.d.ts.map +1 -0
  120. package/dist/engine/localization.js +212 -0
  121. package/dist/engine/privacy/policies.d.ts +58 -0
  122. package/dist/engine/privacy/policies.d.ts.map +1 -0
  123. package/dist/engine/privacy/policies.js +191 -0
  124. package/dist/engine/privacy/privacy.service.d.ts +78 -0
  125. package/dist/engine/privacy/privacy.service.d.ts.map +1 -0
  126. package/dist/engine/privacy/privacy.service.js +138 -0
  127. package/dist/engine/privacy.service.d.ts.map +1 -1
  128. package/dist/engine/query/active-clause.d.ts +19 -0
  129. package/dist/engine/query/active-clause.d.ts.map +1 -0
  130. package/dist/engine/query/active-clause.js +27 -0
  131. package/dist/engine/query/query.d.ts +36 -0
  132. package/dist/engine/query/query.d.ts.map +1 -0
  133. package/dist/engine/query/query.js +393 -0
  134. package/dist/engine/query/relations.d.ts +28 -0
  135. package/dist/engine/query/relations.d.ts.map +1 -0
  136. package/dist/engine/query/relations.js +25 -0
  137. package/dist/engine/query/serialize.d.ts +22 -0
  138. package/dist/engine/query/serialize.d.ts.map +1 -0
  139. package/dist/engine/query/serialize.js +175 -0
  140. package/dist/engine/schema-fingerprint.d.ts +73 -0
  141. package/dist/engine/schema-fingerprint.d.ts.map +1 -0
  142. package/dist/engine/schema-fingerprint.js +97 -0
  143. package/dist/engine/seed-registry.d.ts.map +1 -1
  144. package/dist/engine/seeds/candidate-ids.d.ts +14 -0
  145. package/dist/engine/seeds/candidate-ids.d.ts.map +1 -0
  146. package/dist/engine/seeds/candidate-ids.js +40 -0
  147. package/dist/engine/seeds/define-seed.d.ts +3 -0
  148. package/dist/engine/seeds/define-seed.d.ts.map +1 -0
  149. package/dist/engine/seeds/define-seed.js +5 -0
  150. package/dist/engine/seeds/seed-definition-diff.d.ts +38 -0
  151. package/dist/engine/seeds/seed-definition-diff.d.ts.map +1 -0
  152. package/dist/engine/seeds/seed-definition-diff.js +51 -0
  153. package/dist/engine/seeds/seed-registry.d.ts +88 -0
  154. package/dist/engine/seeds/seed-registry.d.ts.map +1 -0
  155. package/dist/engine/seeds/seed-registry.js +194 -0
  156. package/dist/engine/seeds/seed-types-generator.d.ts +25 -0
  157. package/dist/engine/seeds/seed-types-generator.d.ts.map +1 -0
  158. package/dist/engine/seeds/seed-types-generator.js +116 -0
  159. package/dist/engine/seeds/seed-validation.d.ts +35 -0
  160. package/dist/engine/seeds/seed-validation.d.ts.map +1 -0
  161. package/dist/engine/seeds/seed-validation.js +384 -0
  162. package/dist/engine/seeds/seeds.d.ts +20 -0
  163. package/dist/engine/seeds/seeds.d.ts.map +1 -0
  164. package/dist/engine/seeds/seeds.js +21 -0
  165. package/dist/engine/seeds/tag-migration.d.ts +73 -0
  166. package/dist/engine/seeds/tag-migration.d.ts.map +1 -0
  167. package/dist/engine/seeds/tag-migration.js +212 -0
  168. package/dist/engine/seeds/tag-options.d.ts +15 -0
  169. package/dist/engine/seeds/tag-options.d.ts.map +1 -0
  170. package/dist/engine/seeds/tag-options.js +111 -0
  171. package/dist/engine/seeds/tag-value.d.ts +31 -0
  172. package/dist/engine/seeds/tag-value.d.ts.map +1 -0
  173. package/dist/engine/seeds/tag-value.js +51 -0
  174. package/dist/engine/types.d.ts +59 -7
  175. package/dist/engine/types.d.ts.map +1 -1
  176. package/dist/engine/validation/cache.d.ts.map +1 -1
  177. package/dist/engine/validation/cache.js +20 -4
  178. package/dist/engine/validation/emptiness.d.ts +12 -0
  179. package/dist/engine/validation/emptiness.d.ts.map +1 -0
  180. package/dist/engine/validation/emptiness.js +33 -0
  181. package/dist/engine/validation/index.d.ts +11 -0
  182. package/dist/engine/validation/index.d.ts.map +1 -1
  183. package/dist/engine/validation/index.js +29 -33
  184. package/dist/engine/validation/primitives.d.ts +12 -0
  185. package/dist/engine/validation/primitives.d.ts.map +1 -1
  186. package/dist/engine/validation/primitives.js +22 -0
  187. package/dist/engine/validation/richtext-sanitizer.d.ts +9 -1
  188. package/dist/engine/validation/richtext-sanitizer.d.ts.map +1 -1
  189. package/dist/engine/validation/richtext-sanitizer.js +36 -7
  190. package/dist/engine/validation/schema-builders.d.ts +16 -0
  191. package/dist/engine/validation/schema-builders.d.ts.map +1 -1
  192. package/dist/engine/validation/schema-builders.js +125 -18
  193. package/dist/engine.d.ts +144 -0
  194. package/dist/engine.d.ts.map +1 -0
  195. package/dist/engine.js +741 -0
  196. package/dist/file-types.d.ts +13 -0
  197. package/dist/file-types.d.ts.map +1 -0
  198. package/dist/file-types.js +85 -0
  199. package/dist/hooks.d.ts +29 -0
  200. package/dist/hooks.d.ts.map +1 -0
  201. package/dist/hooks.js +3 -0
  202. package/dist/id-generator.d.ts +26 -0
  203. package/dist/id-generator.d.ts.map +1 -0
  204. package/dist/id-generator.js +12 -0
  205. package/dist/idempotency.repository.d.ts +13 -0
  206. package/dist/idempotency.repository.d.ts.map +1 -0
  207. package/dist/idempotency.repository.js +3 -0
  208. package/dist/index.d.ts +34 -11
  209. package/dist/index.d.ts.map +1 -1
  210. package/dist/index.js +34 -11
  211. package/dist/kanban-position.repository.d.ts +19 -0
  212. package/dist/kanban-position.repository.d.ts.map +1 -0
  213. package/dist/kanban-position.repository.js +3 -0
  214. package/dist/kanban.d.ts +75 -0
  215. package/dist/kanban.d.ts.map +1 -0
  216. package/dist/kanban.js +82 -0
  217. package/dist/layout-permissions.d.ts +3 -0
  218. package/dist/layout-permissions.d.ts.map +1 -0
  219. package/dist/layout-permissions.js +11 -0
  220. package/dist/media/file-types.d.ts +12 -0
  221. package/dist/media/file-types.d.ts.map +1 -1
  222. package/dist/media/file-types.js +24 -4
  223. package/dist/media/image-transformer.d.ts +34 -0
  224. package/dist/media/image-transformer.d.ts.map +1 -0
  225. package/dist/media/image-transformer.js +3 -0
  226. package/dist/media/magic-bytes.d.ts.map +1 -1
  227. package/dist/media/magic-bytes.js +19 -9
  228. package/dist/media/media-transform.d.ts +92 -0
  229. package/dist/media/media-transform.d.ts.map +1 -0
  230. package/dist/media/media-transform.js +197 -0
  231. package/dist/media/media.repository.d.ts +5 -0
  232. package/dist/media/media.repository.d.ts.map +1 -1
  233. package/dist/media.repository.d.ts +61 -0
  234. package/dist/media.repository.d.ts.map +1 -0
  235. package/dist/media.repository.js +3 -0
  236. package/dist/notifications/notification.repository.d.ts +11 -2
  237. package/dist/notifications/notification.repository.d.ts.map +1 -1
  238. package/dist/oauth/authorization-code.repository.d.ts +10 -5
  239. package/dist/oauth/authorization-code.repository.d.ts.map +1 -1
  240. package/dist/oauth/role-guard.d.ts +30 -11
  241. package/dist/oauth/role-guard.d.ts.map +1 -1
  242. package/dist/oauth/role-guard.js +27 -5
  243. package/dist/oauth/token.repository.d.ts +2 -0
  244. package/dist/oauth/token.repository.d.ts.map +1 -1
  245. package/dist/policies.d.ts +10 -0
  246. package/dist/policies.d.ts.map +1 -0
  247. package/dist/policies.js +33 -0
  248. package/dist/queue/queue.interface.d.ts +9 -1
  249. package/dist/queue/queue.interface.d.ts.map +1 -1
  250. package/dist/queue/queue.stub.d.ts +1 -1
  251. package/dist/queue/queue.stub.d.ts.map +1 -1
  252. package/dist/queue/queue.stub.js +2 -3
  253. package/dist/queue.interface.d.ts +39 -0
  254. package/dist/queue.interface.d.ts.map +1 -0
  255. package/dist/queue.interface.js +3 -0
  256. package/dist/queue.stub.d.ts +6 -0
  257. package/dist/queue.stub.d.ts.map +1 -0
  258. package/dist/queue.stub.js +8 -0
  259. package/dist/rate-limit/token-bucket-rate-limiter.d.ts +7 -0
  260. package/dist/rate-limit/token-bucket-rate-limiter.d.ts.map +1 -1
  261. package/dist/rate-limit/token-bucket-rate-limiter.js +66 -0
  262. package/dist/rbac/evaluate.d.ts +57 -0
  263. package/dist/rbac/evaluate.d.ts.map +1 -0
  264. package/dist/rbac/evaluate.js +113 -0
  265. package/dist/rbac/invitation.repository.d.ts +84 -0
  266. package/dist/rbac/invitation.repository.d.ts.map +1 -0
  267. package/dist/rbac/invitation.repository.js +3 -0
  268. package/dist/rbac/permissions.d.ts +39 -0
  269. package/dist/rbac/permissions.d.ts.map +1 -0
  270. package/dist/rbac/permissions.js +43 -0
  271. package/dist/rbac/types.d.ts +130 -0
  272. package/dist/rbac/types.d.ts.map +1 -0
  273. package/dist/rbac/types.js +4 -0
  274. package/dist/relations.d.ts +28 -0
  275. package/dist/relations.d.ts.map +1 -0
  276. package/dist/relations.js +25 -0
  277. package/dist/richtext-render.d.ts +11 -0
  278. package/dist/richtext-render.d.ts.map +1 -0
  279. package/dist/richtext-render.js +87 -0
  280. package/dist/richtext.d.ts +11 -0
  281. package/dist/richtext.d.ts.map +1 -0
  282. package/dist/richtext.js +13 -0
  283. package/dist/scheduler.interface.d.ts +4 -0
  284. package/dist/scheduler.interface.d.ts.map +1 -0
  285. package/dist/scheduler.interface.js +3 -0
  286. package/dist/scheduler.stub.d.ts +5 -0
  287. package/dist/scheduler.stub.d.ts.map +1 -0
  288. package/dist/scheduler.stub.js +7 -0
  289. package/dist/schema/canonical.d.ts +15 -0
  290. package/dist/schema/canonical.d.ts.map +1 -0
  291. package/dist/schema/canonical.js +37 -0
  292. package/dist/schema/define.d.ts +42 -0
  293. package/dist/schema/define.d.ts.map +1 -0
  294. package/dist/schema/define.js +56 -0
  295. package/dist/schema/emit.d.ts +14 -0
  296. package/dist/schema/emit.d.ts.map +1 -0
  297. package/dist/schema/emit.js +43 -0
  298. package/dist/schema/index.d.ts +12 -0
  299. package/dist/schema/index.d.ts.map +1 -0
  300. package/dist/schema/index.js +13 -0
  301. package/dist/schema/manifest-seeds.d.ts +12 -0
  302. package/dist/schema/manifest-seeds.d.ts.map +1 -0
  303. package/dist/schema/manifest-seeds.js +48 -0
  304. package/dist/schema/manifest-validation.d.ts +13 -0
  305. package/dist/schema/manifest-validation.d.ts.map +1 -0
  306. package/dist/schema/manifest-validation.js +41 -0
  307. package/dist/schema/manifest.types.d.ts +54 -0
  308. package/dist/schema/manifest.types.d.ts.map +1 -0
  309. package/dist/schema/manifest.types.js +7 -0
  310. package/dist/schema-mutator.d.ts +26 -0
  311. package/dist/schema-mutator.d.ts.map +1 -0
  312. package/dist/schema-mutator.js +3 -0
  313. package/dist/search/search.repository.d.ts +5 -4
  314. package/dist/search/search.repository.d.ts.map +1 -1
  315. package/dist/search/vector-extractor.d.ts.map +1 -1
  316. package/dist/search/vector-extractor.js +23 -2
  317. package/dist/search/vector.repository.d.ts +2 -1
  318. package/dist/search/vector.repository.d.ts.map +1 -1
  319. package/dist/security/time-trap-token.repository.d.ts +5 -3
  320. package/dist/security/time-trap-token.repository.d.ts.map +1 -1
  321. package/dist/seed-ddl-destructive.d.ts +40 -0
  322. package/dist/seed-ddl-destructive.d.ts.map +1 -0
  323. package/dist/seed-ddl-destructive.js +149 -0
  324. package/dist/seed-ddl.d.ts +40 -0
  325. package/dist/seed-ddl.d.ts.map +1 -0
  326. package/dist/seed-ddl.js +100 -0
  327. package/dist/seed-layout.d.ts +145 -0
  328. package/dist/seed-layout.d.ts.map +1 -0
  329. package/dist/seed-layout.js +192 -0
  330. package/dist/seed-layout.repository.d.ts +22 -0
  331. package/dist/seed-layout.repository.d.ts.map +1 -0
  332. package/dist/seed-layout.repository.js +3 -0
  333. package/dist/seed-registry.d.ts +71 -0
  334. package/dist/seed-registry.d.ts.map +1 -0
  335. package/dist/seed-registry.js +143 -0
  336. package/dist/seed-types-generator.d.ts +1 -1
  337. package/dist/seed-types-generator.d.ts.map +1 -1
  338. package/dist/seed-validation.d.ts +23 -0
  339. package/dist/seed-validation.d.ts.map +1 -0
  340. package/dist/seed-validation.js +224 -0
  341. package/dist/seed.repository.d.ts +37 -0
  342. package/dist/seed.repository.d.ts.map +1 -0
  343. package/dist/seed.repository.js +3 -0
  344. package/dist/seeds.d.ts +20 -0
  345. package/dist/seeds.d.ts.map +1 -0
  346. package/dist/seeds.js +21 -0
  347. package/dist/settings/site-settings.repository.d.ts +8 -0
  348. package/dist/settings/site-settings.repository.d.ts.map +1 -1
  349. package/dist/site-settings.repository.d.ts +16 -0
  350. package/dist/site-settings.repository.d.ts.map +1 -0
  351. package/dist/site-settings.repository.js +3 -0
  352. package/dist/slug-utils.d.ts +18 -0
  353. package/dist/slug-utils.d.ts.map +1 -0
  354. package/dist/slug-utils.js +32 -0
  355. package/dist/storage.d.ts +46 -0
  356. package/dist/storage.d.ts.map +1 -0
  357. package/dist/storage.js +3 -0
  358. package/dist/transfer/csv.d.ts +34 -0
  359. package/dist/transfer/csv.d.ts.map +1 -0
  360. package/dist/transfer/csv.js +135 -0
  361. package/dist/transfer/flat-seed.d.ts +13 -0
  362. package/dist/transfer/flat-seed.d.ts.map +1 -0
  363. package/dist/transfer/flat-seed.js +50 -0
  364. package/dist/transfer/index.d.ts +7 -0
  365. package/dist/transfer/index.d.ts.map +1 -0
  366. package/dist/transfer/index.js +8 -0
  367. package/dist/transfer/ndjson.d.ts +25 -0
  368. package/dist/transfer/ndjson.d.ts.map +1 -0
  369. package/dist/transfer/ndjson.js +62 -0
  370. package/dist/transfer/row-mapping.d.ts +36 -0
  371. package/dist/transfer/row-mapping.d.ts.map +1 -0
  372. package/dist/transfer/row-mapping.js +97 -0
  373. package/dist/transfer/transfer.constants.d.ts +20 -0
  374. package/dist/transfer/transfer.constants.d.ts.map +1 -0
  375. package/dist/transfer/transfer.constants.js +21 -0
  376. package/dist/transfer/transfer.types.d.ts +46 -0
  377. package/dist/transfer/transfer.types.d.ts.map +1 -0
  378. package/dist/transfer/transfer.types.js +6 -0
  379. package/dist/types.d.ts +243 -0
  380. package/dist/types.d.ts.map +1 -0
  381. package/dist/types.js +3 -0
  382. package/dist/validation.d.ts +50 -0
  383. package/dist/validation.d.ts.map +1 -0
  384. package/dist/validation.js +660 -0
  385. package/dist/webhook-validation.d.ts +3 -0
  386. package/dist/webhook-validation.d.ts.map +1 -0
  387. package/dist/webhook-validation.js +6 -0
  388. package/package.json +11 -6
  389. package/dist/.tsbuildinfo +0 -1
@@ -0,0 +1,7 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2024–2026 Flavio De Musso
3
+ export class NoOpScheduler {
4
+ waitUntil(_promise) {
5
+ // intentionally empty
6
+ }
7
+ }
@@ -0,0 +1,15 @@
1
+ import type { BeechSchemaManifest } from './manifest.types.js';
2
+ /**
3
+ * Thrown when a manifest carries a value that cannot survive a JSON round-trip.
4
+ * Re-exported under its historical name: it is the SAME class object as
5
+ * `CanonicalSerializationError`, so existing `instanceof` checks keep working.
6
+ */
7
+ export { CanonicalSerializationError as ManifestSerializationError } from '../common/canonical-json.js';
8
+ /**
9
+ * Serializes a manifest to its canonical form: seeds sorted by slug, keys sorted, two-space
10
+ * indentation, trailing newline. Stable across authoring order and across key insertion order.
11
+ */
12
+ export declare function toCanonicalJson(manifest: BeechSchemaManifest): string;
13
+ /** Parses canonical JSON back into a manifest, refusing an unknown format version. */
14
+ export declare function fromCanonicalJson(json: string): BeechSchemaManifest;
15
+ //# sourceMappingURL=canonical.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical.d.ts","sourceRoot":"","sources":["../../src/schema/canonical.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAE9D;;;;GAIG;AACH,OAAO,EAAE,2BAA2B,IAAI,0BAA0B,EAAE,MAAM,6BAA6B,CAAA;AAEvG;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,mBAAmB,GAAG,MAAM,CAGrE;AAED,sFAAsF;AACtF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,mBAAmB,CASnE"}
@@ -0,0 +1,37 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2024–2026 Flavio De Musso
3
+ /**
4
+ * @module schema/canonical
5
+ * Deterministic serialization of a manifest. The bytes produced here are the input the schema
6
+ * fingerprint hashes, so this format is a compatibility surface: changing it invalidates every
7
+ * already-published client. Treat it as frozen.
8
+ *
9
+ * The serializer itself moved to `common/canonical-json.ts` in sprint 2 so the Worker-side
10
+ * fingerprint can share it without importing this authoring-only module.
11
+ */
12
+ import { canonicalStringify } from '../common/canonical-json.js';
13
+ import { MANIFEST_VERSION } from './manifest.types.js';
14
+ /**
15
+ * Thrown when a manifest carries a value that cannot survive a JSON round-trip.
16
+ * Re-exported under its historical name: it is the SAME class object as
17
+ * `CanonicalSerializationError`, so existing `instanceof` checks keep working.
18
+ */
19
+ export { CanonicalSerializationError as ManifestSerializationError } from '../common/canonical-json.js';
20
+ /**
21
+ * Serializes a manifest to its canonical form: seeds sorted by slug, keys sorted, two-space
22
+ * indentation, trailing newline. Stable across authoring order and across key insertion order.
23
+ */
24
+ export function toCanonicalJson(manifest) {
25
+ const seeds = [...manifest.seeds].sort((a, b) => a.slug.localeCompare(b.slug));
26
+ return canonicalStringify({ version: manifest.version, seeds });
27
+ }
28
+ /** Parses canonical JSON back into a manifest, refusing an unknown format version. */
29
+ export function fromCanonicalJson(json) {
30
+ const parsed = JSON.parse(json);
31
+ if (parsed.version !== MANIFEST_VERSION) {
32
+ throw new Error(`Unsupported manifest version ${String(parsed.version)}; this build understands ${MANIFEST_VERSION}.`);
33
+ }
34
+ if (!Array.isArray(parsed.seeds))
35
+ throw new Error('Manifest is missing a `seeds` array.');
36
+ return { version: MANIFEST_VERSION, seeds: parsed.seeds };
37
+ }
@@ -0,0 +1,42 @@
1
+ import type { BeechSchemaManifest, FieldGroup, ManifestBranch, ManifestSeed } from './manifest.types.js';
2
+ /** A field bundle, or the fields themselves, as accepted by `defineSeed`. */
3
+ type BranchInput = ManifestBranch | FieldGroup;
4
+ /**
5
+ * Declares the root manifest. Seeds are stored in authoring order here; canonical ordering is
6
+ * applied by `toCanonicalJson`, so a reordered manifest file produces byte-identical canonical JSON.
7
+ */
8
+ export declare function defineSchema(input: {
9
+ seeds: ManifestSeed[];
10
+ }): BeechSchemaManifest;
11
+ /**
12
+ * Declares one content type, flattening any `defineGroup()` bundles into the branch list.
13
+ * Branch ORDER is preserved: it is the physical column order `planCreateSeed` will emit.
14
+ */
15
+ export declare function defineSeed(input: Omit<ManifestSeed, 'branches'> & {
16
+ branches: BranchInput[];
17
+ }): ManifestSeed;
18
+ /** Declares a reusable field bundle. Expanded at author time by `defineSeed`; never persisted. */
19
+ export declare function defineGroup(name: string, branches: ManifestBranch[]): FieldGroup;
20
+ /**
21
+ * Typed field constructors. `relation` and `repeater` narrow their input because the engine treats
22
+ * `targetSeed` / `fields` as required for those types — making the compiler enforce what
23
+ * `validateSeedDefinitions` would otherwise only catch at apply time.
24
+ */
25
+ export declare const defineField: {
26
+ readonly text: (input: Omit<ManifestBranch, "type">) => ManifestBranch;
27
+ readonly number: (input: Omit<ManifestBranch, "type">) => ManifestBranch;
28
+ readonly boolean: (input: Omit<ManifestBranch, "type">) => ManifestBranch;
29
+ readonly json: (input: Omit<ManifestBranch, "type">) => ManifestBranch;
30
+ readonly date: (input: Omit<ManifestBranch, "type">) => ManifestBranch;
31
+ readonly richtext: (input: Omit<ManifestBranch, "type">) => ManifestBranch;
32
+ readonly file: (input: Omit<ManifestBranch, "type">) => ManifestBranch;
33
+ readonly tags: (input: Omit<ManifestBranch, "type">) => ManifestBranch;
34
+ readonly relation: (input: Omit<ManifestBranch, "type" | "targetSeed"> & {
35
+ targetSeed: string;
36
+ }) => ManifestBranch;
37
+ readonly repeater: (input: Omit<ManifestBranch, "type" | "fields"> & {
38
+ fields: ManifestBranch[];
39
+ }) => ManifestBranch;
40
+ };
41
+ export {};
42
+ //# sourceMappingURL=define.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../src/schema/define.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EACV,mBAAmB,EACnB,UAAU,EACV,cAAc,EACd,YAAY,EACb,MAAM,qBAAqB,CAAA;AAE5B,6EAA6E;AAC7E,KAAK,WAAW,GAAG,cAAc,GAAG,UAAU,CAAA;AAM9C;;;GAGG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,YAAY,EAAE,CAAA;CAAE,GAAG,mBAAmB,CAElF;AAED;;;GAGG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,GAAG;IAAE,QAAQ,EAAE,WAAW,EAAE,CAAA;CAAE,GAClE,YAAY,CAOd;AAED,kGAAkG;AAClG,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,UAAU,CAEhF;AAMD;;;;GAIG;AACH,eAAO,MAAM,WAAW;2BARP,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,KAAG,cAAc;6BAA7C,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,KAAG,cAAc;8BAA7C,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,KAAG,cAAc;2BAA7C,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,KAAG,cAAc;2BAA7C,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,KAAG,cAAc;+BAA7C,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,KAAG,cAAc;2BAA7C,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,KAAG,cAAc;2BAA7C,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,KAAG,cAAc;+BAkBnD,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,YAAY,CAAC,GAAG;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,KAC1E,cAAc;+BAER,IAAI,CAAC,cAAc,EAAE,MAAM,GAAG,QAAQ,CAAC,GAAG;QAAE,MAAM,EAAE,cAAc,EAAE,CAAA;KAAE,KAC5E,cAAc;CACT,CAAA"}
@@ -0,0 +1,56 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2024–2026 Flavio De Musso
3
+ /**
4
+ * @module schema/define
5
+ * Authoring DSL for `beech.schema.ts`. Pure, allocation-only helpers: they give the author
6
+ * inference and autocomplete, and they never validate, throw, or touch I/O.
7
+ */
8
+ import { MANIFEST_VERSION } from './manifest.types.js';
9
+ function isFieldGroup(input) {
10
+ return Array.isArray(input.branches);
11
+ }
12
+ /**
13
+ * Declares the root manifest. Seeds are stored in authoring order here; canonical ordering is
14
+ * applied by `toCanonicalJson`, so a reordered manifest file produces byte-identical canonical JSON.
15
+ */
16
+ export function defineSchema(input) {
17
+ return { version: MANIFEST_VERSION, seeds: input.seeds };
18
+ }
19
+ /**
20
+ * Declares one content type, flattening any `defineGroup()` bundles into the branch list.
21
+ * Branch ORDER is preserved: it is the physical column order `planCreateSeed` will emit.
22
+ */
23
+ export function defineSeed(input) {
24
+ const branches = [];
25
+ for (const item of input.branches) {
26
+ if (isFieldGroup(item))
27
+ branches.push(...item.branches);
28
+ else
29
+ branches.push(item);
30
+ }
31
+ return { ...input, branches };
32
+ }
33
+ /** Declares a reusable field bundle. Expanded at author time by `defineSeed`; never persisted. */
34
+ export function defineGroup(name, branches) {
35
+ return { name, branches };
36
+ }
37
+ function field(type) {
38
+ return (input) => ({ ...input, type });
39
+ }
40
+ /**
41
+ * Typed field constructors. `relation` and `repeater` narrow their input because the engine treats
42
+ * `targetSeed` / `fields` as required for those types — making the compiler enforce what
43
+ * `validateSeedDefinitions` would otherwise only catch at apply time.
44
+ */
45
+ export const defineField = {
46
+ text: field('text'),
47
+ number: field('number'),
48
+ boolean: field('boolean'),
49
+ json: field('json'),
50
+ date: field('date'),
51
+ richtext: field('richtext'),
52
+ file: field('file'),
53
+ tags: field('tags'),
54
+ relation: (input) => ({ ...input, type: 'relation' }),
55
+ repeater: (input) => ({ ...input, type: 'repeater' }),
56
+ };
@@ -0,0 +1,14 @@
1
+ import type { BeechSchemaManifest } from './manifest.types.js';
2
+ /**
3
+ * Emits the full module source for a `beech.schema.ts`.
4
+ *
5
+ * Seeds are sorted by slug so two exports of the same database are byte-identical and a Git diff
6
+ * shows schema change only. `version` is NOT passed to `defineSchema` — the DSL adds it, and an
7
+ * excess property would fail the consumer's own typecheck.
8
+ *
9
+ * @throws CanonicalSerializationError when a seed carries a value that cannot survive a JSON
10
+ * round-trip. That can only happen if a non-serializable value reached the `seeds` table, which is
11
+ * a corrupt-state fault worth surfacing, not worth silently dropping.
12
+ */
13
+ export declare function emitManifestModule(manifest: BeechSchemaManifest): string;
14
+ //# sourceMappingURL=emit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../src/schema/emit.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAU9D;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,MAAM,CASxE"}
@@ -0,0 +1,43 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2024–2026 Flavio De Musso
3
+ /**
4
+ * @module schema/emit
5
+ * Renders a manifest as the source of a `beech.schema.ts` module — the inverse of the authoring DSL.
6
+ *
7
+ * The seed payload is embedded as the FROZEN canonical JSON literal (sprint 1's serializer), not as
8
+ * a tree of `defineField.*` calls. Three reasons a future reader must not "improve" this:
9
+ * 1. a call-tree emitter is a second serializer for the manifest shape, free to drift from
10
+ * `define.ts` the moment a branch type is added;
11
+ * 2. the bytes here must match what `toCanonicalJson` produces, because that is what the validator
12
+ * and the diff compare — one format, one producer;
13
+ * 3. a JSON object literal IS a valid TypeScript expression, so the emitted file typechecks in the
14
+ * consumer's project with zero extra machinery.
15
+ *
16
+ * A hand-authored manifest using the full DSL round-trips through this emitter unchanged in meaning:
17
+ * `defineSchema`/`defineSeed`/`defineField` all erase to the same `BeechSchemaManifest`.
18
+ */
19
+ import { canonicalStringify } from '../common/canonical-json.js';
20
+ /** Header written at the top of every exported manifest. */
21
+ const HEADER = `// Generated by \`beech schema export\` from live D1 state.\n` +
22
+ `//\n` +
23
+ `// This file is DESIRED STATE, not runtime authority: the Worker never imports it and no deploy\n` +
24
+ `// applies it. Edit it, review the diff in Git, then reconcile with \`beech schema plan\` /\n` +
25
+ `// \`beech schema apply\`. Re-export at any time to refresh the snapshot.\n`;
26
+ /**
27
+ * Emits the full module source for a `beech.schema.ts`.
28
+ *
29
+ * Seeds are sorted by slug so two exports of the same database are byte-identical and a Git diff
30
+ * shows schema change only. `version` is NOT passed to `defineSchema` — the DSL adds it, and an
31
+ * excess property would fail the consumer's own typecheck.
32
+ *
33
+ * @throws CanonicalSerializationError when a seed carries a value that cannot survive a JSON
34
+ * round-trip. That can only happen if a non-serializable value reached the `seeds` table, which is
35
+ * a corrupt-state fault worth surfacing, not worth silently dropping.
36
+ */
37
+ export function emitManifestModule(manifest) {
38
+ const seeds = [...manifest.seeds].sort((a, b) => a.slug.localeCompare(b.slug));
39
+ const literal = canonicalStringify({ seeds }).trimEnd();
40
+ return (`${HEADER}\n` +
41
+ `import { defineSchema } from '@beechcms/core/schema'\n\n` +
42
+ `export default defineSchema(${literal})\n`);
43
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @module schema
3
+ * Authoring surface for `beech.schema.ts`. Imported by authoring tools and the CLI — NEVER by the
4
+ * Worker, which is why this module is a separate subpath and is absent from `src/index.ts`.
5
+ */
6
+ export * from './manifest.types.js';
7
+ export * from './define.js';
8
+ export * from './canonical.js';
9
+ export * from './manifest-seeds.js';
10
+ export * from './manifest-validation.js';
11
+ export * from './emit.js';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AAEH,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,0BAA0B,CAAA;AACxC,cAAc,WAAW,CAAA"}
@@ -0,0 +1,13 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2024–2026 Flavio De Musso
3
+ /**
4
+ * @module schema
5
+ * Authoring surface for `beech.schema.ts`. Imported by authoring tools and the CLI — NEVER by the
6
+ * Worker, which is why this module is a separate subpath and is absent from `src/index.ts`.
7
+ */
8
+ export * from './manifest.types.js';
9
+ export * from './define.js';
10
+ export * from './canonical.js';
11
+ export * from './manifest-seeds.js';
12
+ export * from './manifest-validation.js';
13
+ export * from './emit.js';
@@ -0,0 +1,12 @@
1
+ import type { BeechSchemaManifest } from './manifest.types.js';
2
+ import type { Seed } from '../engine/types.js';
3
+ /** Manifest → engine `Seed[]`, ready for `validateSeedDefinitions` or an MCP plan candidate. */
4
+ export declare function manifestToSeeds(manifest: BeechSchemaManifest): Seed[];
5
+ /**
6
+ * Engine `Seed[]` → manifest, for a future `beech schema export`.
7
+ *
8
+ * `layout` is stripped: it is server-populated presentation state, not schema. Seeds are sorted by
9
+ * slug so an export is diffable; branch order is preserved because it is the physical column order.
10
+ */
11
+ export declare function seedsToManifest(seeds: Seed[]): BeechSchemaManifest;
12
+ //# sourceMappingURL=manifest-seeds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-seeds.d.ts","sourceRoot":"","sources":["../../src/schema/manifest-seeds.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,mBAAmB,EAAgC,MAAM,qBAAqB,CAAA;AAC5F,OAAO,KAAK,EAAU,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAuBtD,gGAAgG;AAChG,wBAAgB,eAAe,CAAC,QAAQ,EAAE,mBAAmB,GAAG,IAAI,EAAE,CAKrE;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,mBAAmB,CAMlE"}
@@ -0,0 +1,48 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2024–2026 Flavio De Musso
3
+ /**
4
+ * @module schema/manifest-seeds
5
+ * Bridges the manifest shape and the engine's `Seed` shape, in both directions.
6
+ */
7
+ import { nextBranchId } from '../engine/seeds/seed-registry.js';
8
+ import { MANIFEST_VERSION } from './manifest.types.js';
9
+ /**
10
+ * Fills in ids for branches authored without one, in declaration order.
11
+ *
12
+ * These ids are AUTHORING-LOCAL and non-authoritative — they exist so `validateSeedDefinitions`,
13
+ * which fatals on a missing id, has a complete `Seed` to check. NEVER send this output to plan/apply:
14
+ * a minted id looks authoritative to the server and shadows the stored one. The CLI sends the raw
15
+ * manifest seeds instead, so `resolveCandidateIds()` matches stored ids by alias.
16
+ */
17
+ function withBranchIds(branches) {
18
+ const accumulated = [];
19
+ for (const branch of branches) {
20
+ const resolved = {
21
+ ...branch,
22
+ id: branch.id ?? nextBranchId({ branches: accumulated }),
23
+ ...(branch.fields ? { fields: withBranchIds(branch.fields) } : {}),
24
+ };
25
+ accumulated.push(resolved);
26
+ }
27
+ return accumulated;
28
+ }
29
+ /** Manifest → engine `Seed[]`, ready for `validateSeedDefinitions` or an MCP plan candidate. */
30
+ export function manifestToSeeds(manifest) {
31
+ return manifest.seeds.map((seed) => ({
32
+ ...seed,
33
+ branches: withBranchIds(seed.branches),
34
+ }));
35
+ }
36
+ /**
37
+ * Engine `Seed[]` → manifest, for a future `beech schema export`.
38
+ *
39
+ * `layout` is stripped: it is server-populated presentation state, not schema. Seeds are sorted by
40
+ * slug so an export is diffable; branch order is preserved because it is the physical column order.
41
+ */
42
+ export function seedsToManifest(seeds) {
43
+ const sorted = [...seeds].sort((a, b) => a.slug.localeCompare(b.slug));
44
+ return {
45
+ version: MANIFEST_VERSION,
46
+ seeds: sorted.map(({ layout: _layout, ...seed }) => seed),
47
+ };
48
+ }
@@ -0,0 +1,13 @@
1
+ import type { SeedValidationIssue } from '../engine/seeds/seed-validation.js';
2
+ import type { BeechSchemaManifest } from './manifest.types.js';
3
+ /**
4
+ * Validates a manifest end to end:
5
+ * 1. format version is one this build understands;
6
+ * 2. every value survives canonical serialization (no callbacks or executable code persisted);
7
+ * 3. the derived `Seed[]` passes the engine's whole-set validation — including cross-seed relation
8
+ * targets, which is exactly why this is a manifest-level and not a seed-level function.
9
+ *
10
+ * Returns issues; never throws. A caller decides whether a non-fatal issue blocks.
11
+ */
12
+ export declare function validateManifest(manifest: BeechSchemaManifest): SeedValidationIssue[];
13
+ //# sourceMappingURL=manifest-validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-validation.d.ts","sourceRoot":"","sources":["../../src/schema/manifest-validation.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAA;AAI7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAE9D;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,mBAAmB,GAAG,mBAAmB,EAAE,CAqBrF"}
@@ -0,0 +1,41 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2024–2026 Flavio De Musso
3
+ /**
4
+ * @module schema/manifest-validation
5
+ * Whole-manifest validation. Reuses the engine's `validateSeedDefinitions` rather than
6
+ * reimplementing it: a manifest that passes here is a candidate set the API would also accept.
7
+ */
8
+ import { validateSeedDefinitions } from '../engine/seeds/seed-validation.js';
9
+ import { MANIFEST_VERSION } from './manifest.types.js';
10
+ import { toCanonicalJson, ManifestSerializationError } from './canonical.js';
11
+ import { manifestToSeeds } from './manifest-seeds.js';
12
+ /**
13
+ * Validates a manifest end to end:
14
+ * 1. format version is one this build understands;
15
+ * 2. every value survives canonical serialization (no callbacks or executable code persisted);
16
+ * 3. the derived `Seed[]` passes the engine's whole-set validation — including cross-seed relation
17
+ * targets, which is exactly why this is a manifest-level and not a seed-level function.
18
+ *
19
+ * Returns issues; never throws. A caller decides whether a non-fatal issue blocks.
20
+ */
21
+ export function validateManifest(manifest) {
22
+ if (manifest.version !== MANIFEST_VERSION) {
23
+ return [{
24
+ slug: '*',
25
+ fatal: true,
26
+ messages: [
27
+ `unsupported manifest version ${String(manifest.version)}; this build understands ${MANIFEST_VERSION}.`,
28
+ ],
29
+ }];
30
+ }
31
+ try {
32
+ toCanonicalJson(manifest);
33
+ }
34
+ catch (error) {
35
+ if (error instanceof ManifestSerializationError) {
36
+ return [{ slug: '*', fatal: true, messages: [error.message] }];
37
+ }
38
+ throw error;
39
+ }
40
+ return validateSeedDefinitions(manifestToSeeds(manifest));
41
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @module schema/manifest.types
3
+ * Data shapes for the `beech.schema.ts` desired-state manifest. Pure types — no runtime logic.
4
+ *
5
+ * A manifest is NOT a runtime authority: D1 remains the sole runtime source of truth. These types
6
+ * describe an artifact that is authored, reviewed in Git, and reconciled through an explicit
7
+ * plan/apply step.
8
+ */
9
+ import type { Branch, Seed } from '../engine/types.js';
10
+ /**
11
+ * Manifest format version. Bumped ONLY on a breaking change to the manifest shape — never on an
12
+ * additive field. `fromCanonicalJson` refuses any other value rather than guessing.
13
+ */
14
+ export declare const MANIFEST_VERSION = 1;
15
+ /**
16
+ * A field as written by hand in a manifest.
17
+ *
18
+ * `id` is optional at authoring time: nobody hand-writes `br_07`, and an author-invented id would
19
+ * collide with the ids the engine already minted. It is filled in by `manifestToSeeds()` purely so
20
+ * validation has a complete `Seed`; the AUTHORITATIVE assignment happens at plan/apply time, where
21
+ * `normalizeCandidate()` preserves the stored id by alias match before minting a new one.
22
+ * `fields` is recursive for `repeater` sub-fields, which carry the same rule.
23
+ */
24
+ export type ManifestBranch = Omit<Branch, 'id' | 'fields'> & {
25
+ id?: string;
26
+ fields?: ManifestBranch[];
27
+ };
28
+ /**
29
+ * A content type as written in a manifest.
30
+ *
31
+ * `layout` is deliberately absent: it is typed `unknown`, is populated server-side by
32
+ * `GET /api/schema`, and is not a schema concern. Round-tripping it would make a future
33
+ * `beech schema diff` report permanent false drift.
34
+ */
35
+ export type ManifestSeed = Omit<Seed, 'branches' | 'layout'> & {
36
+ branches: ManifestBranch[];
37
+ };
38
+ /**
39
+ * A reusable bundle of fields (e.g. an SEO block shared by several seeds).
40
+ *
41
+ * Author-time only: `defineSeed()` splices `branches` into the seed's own list and the group leaves
42
+ * ZERO trace in canonical JSON. It is a macro, not a persisted concept — there is exactly one
43
+ * grouping mechanism in D1, and this is not it.
44
+ */
45
+ export interface FieldGroup {
46
+ name: string;
47
+ branches: ManifestBranch[];
48
+ }
49
+ /** The root artifact: the whole desired schema state. */
50
+ export interface BeechSchemaManifest {
51
+ version: typeof MANIFEST_VERSION;
52
+ seeds: ManifestSeed[];
53
+ }
54
+ //# sourceMappingURL=manifest.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.types.d.ts","sourceRoot":"","sources":["../../src/schema/manifest.types.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAEtD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,IAAI,CAAA;AAEjC;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,GAAG,QAAQ,CAAC,GAAG;IAC3D,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,MAAM,CAAC,EAAE,cAAc,EAAE,CAAA;CAC1B,CAAA;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,QAAQ,CAAC,GAAG;IAC7D,QAAQ,EAAE,cAAc,EAAE,CAAA;CAC3B,CAAA;AAED;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,cAAc,EAAE,CAAA;CAC3B;AAED,yDAAyD;AACzD,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,gBAAgB,CAAA;IAChC,KAAK,EAAE,YAAY,EAAE,CAAA;CACtB"}
@@ -0,0 +1,7 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2024–2026 Flavio De Musso
3
+ /**
4
+ * Manifest format version. Bumped ONLY on a breaking change to the manifest shape — never on an
5
+ * additive field. `fromCanonicalJson` refuses any other value rather than guessing.
6
+ */
7
+ export const MANIFEST_VERSION = 1;
@@ -0,0 +1,26 @@
1
+ /** Executes additive schema DDL against the live database and introspects columns.
2
+ * Implemented by D1SchemaMutator in apps/api/src/shared/schema-mutator.d1.ts.
3
+ * This is the ONLY sanctioned channel for runtime DDL — handlers never touch env.DB. */
4
+ export interface ISchemaMutator {
5
+ /** Column names currently on a table, or null if the table does not exist. */
6
+ getColumns(table: string): Promise<Set<string> | null>;
7
+ /** Runs the given DDL statements in order as a single D1 batch.
8
+ * All statements must be additive (CREATE … IF NOT EXISTS / ALTER … ADD COLUMN /
9
+ * CREATE INDEX IF NOT EXISTS). Throws on the first failing statement. */
10
+ execDdl(statements: string[]): Promise<void>;
11
+ /** `DROP TABLE IF EXISTS {table}`. */
12
+ dropTable(table: string): Promise<void>;
13
+ /** `ALTER TABLE {table} DROP COLUMN {column}`. */
14
+ dropColumn(table: string, column: string): Promise<void>;
15
+ /** `ALTER TABLE {table} RENAME COLUMN {from} TO {to}`. */
16
+ renameColumn(table: string, from: string, to: string): Promise<void>;
17
+ /** Runs a multi-statement destructive batch atomically (FTS rebuild,
18
+ * type-change column rebuild, full type drop). The caller assembles the
19
+ * statements; the impl validates identifiers and runs them as one D1 batch. */
20
+ execDestructive(statements: string[]): Promise<void>;
21
+ /** Reads all rows from a table for the specified columns only.
22
+ * Used before DROP TABLE to collect R2 keys for media cleanup.
23
+ * All identifiers are validated against `^[A-Za-z0-9_]+$`. */
24
+ fetchRows(table: string, columns: string[]): Promise<Record<string, unknown>[]>;
25
+ }
26
+ //# sourceMappingURL=schema-mutator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-mutator.d.ts","sourceRoot":"","sources":["../src/schema-mutator.ts"],"names":[],"mappings":"AAGA;;yFAEyF;AACzF,MAAM,WAAW,cAAc;IAC7B,8EAA8E;IAC9E,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;IACtD;;8EAE0E;IAC1E,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAS5C,sCAAsC;IACtC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACvC,kDAAkD;IAClD,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxD,0DAA0D;IAC1D,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACpE;;oFAEgF;IAChF,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEpD;;mEAE+D;IAC/D,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;CAChF"}
@@ -0,0 +1,3 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) 2024–2026 Flavio De Musso
3
+ export {};
@@ -30,15 +30,16 @@ export interface ISearchRepository {
30
30
  * Executes a UNION ALL full-text search across all FTS-enabled seed tables.
31
31
  * Returns at most options.limit + 1 rows so the caller can detect hasMore
32
32
  * without a separate count query for the cursor case.
33
- * Implementations must propagate the EMPTY_QUERY error thrown by
34
- * buildFtsQuery so the route handler can return an empty result set rather
35
- * than a 500.
33
+ * A query with no usable terms (EMPTY_QUERY from buildFtsQuery) must resolve
34
+ * to an empty array rather than throw, so the route handler never returns a
35
+ * 500 for it.
36
36
  */
37
37
  search(options: SearchQueryOptions, seeds: Seed[]): Promise<SearchResultRow[]>;
38
38
  /**
39
39
  * Runs the count variant of the FTS query to support the `total` field in
40
40
  * the search response. Called in parallel with search() by the route handler
41
- * with the same filter inputs but without limit/cursor.
41
+ * with the same filter inputs but without limit/cursor. An EMPTY_QUERY
42
+ * resolves to `{ total: 0 }` rather than throwing.
42
43
  */
43
44
  count(options: Omit<SearchQueryOptions, 'limit' | 'cursor'>, seeds: Seed[]): Promise<SearchCountResult>;
44
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"search.repository.d.ts","sourceRoot":"","sources":["../../src/search/search.repository.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAE9C,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;;OAOG;IACH,MAAM,CAAC,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAA;IAE9E;;;;OAIG;IACH,KAAK,CACH,OAAO,EAAE,IAAI,CAAC,kBAAkB,EAAE,OAAO,GAAG,QAAQ,CAAC,EACrD,KAAK,EAAE,IAAI,EAAE,GACZ,OAAO,CAAC,iBAAiB,CAAC,CAAA;CAC9B"}
1
+ {"version":3,"file":"search.repository.d.ts","sourceRoot":"","sources":["../../src/search/search.repository.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAE9C,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAA;CACd;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;;OAOG;IACH,MAAM,CAAC,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAA;IAE9E;;;;;OAKG;IACH,KAAK,CACH,OAAO,EAAE,IAAI,CAAC,kBAAkB,EAAE,OAAO,GAAG,QAAQ,CAAC,EACrD,KAAK,EAAE,IAAI,EAAE,GACZ,OAAO,CAAC,iBAAiB,CAAC,CAAA;CAC9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"vector-extractor.d.ts","sourceRoot":"","sources":["../../src/search/vector-extractor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAG9C;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,GAAG,IAAI,CAc1F"}
1
+ {"version":3,"file":"vector-extractor.d.ts","sourceRoot":"","sources":["../../src/search/vector-extractor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAK9C;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,GAAG,IAAI,CA4B1F"}
@@ -1,6 +1,8 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Copyright (c) 2024–2026 Flavio De Musso
3
- import { indexableSearchBranches } from '../engine/ddl.js';
3
+ import { indexableSearchBranches } from '../engine/ddl/ddl.js';
4
+ import { isLocaleDictionary, isLocalizedBranch } from '../engine/localization/localization.js';
5
+ import { extractRichtextText } from '../engine/validation/richtext-sanitizer.js';
4
6
  /**
5
7
  * Extracts and concatenates text from all public indexable text/richtext branches of a seed.
6
8
  * Enforces privacy policies by utilizing indexableSearchBranches.
@@ -16,9 +18,28 @@ export function extractIndexableText(seed, entry) {
16
18
  const texts = [];
17
19
  for (const branch of branches) {
18
20
  const val = entry[branch.alias];
19
- if (val && typeof val === 'string') {
21
+ if (isLocalizedBranch(branch) && isLocaleDictionary(val)) {
22
+ // Every language is indexed, so a query matches regardless of the language it is typed in.
23
+ for (const localeValue of Object.values(val)) {
24
+ if (typeof localeValue === 'string' && localeValue) {
25
+ texts.push(localeValue);
26
+ }
27
+ else if (branch.type === 'richtext') {
28
+ const text = extractRichtextText(localeValue);
29
+ if (text)
30
+ texts.push(text);
31
+ }
32
+ }
33
+ }
34
+ else if (typeof val === 'string' && val) {
20
35
  texts.push(val);
21
36
  }
37
+ else if (branch.type === 'richtext') {
38
+ // Deserialized richtext is always a TipTap doc object (or v1 envelope), never a string.
39
+ const text = extractRichtextText(val);
40
+ if (text)
41
+ texts.push(text);
42
+ }
22
43
  }
23
44
  const combined = texts.join(' ').trim();
24
45
  return combined.length > 0 ? combined : null;
@@ -4,10 +4,11 @@ export interface IVectorRepository {
4
4
  saveVector(seed: Seed, entryId: string, vector: Float32Array): Promise<void>;
5
5
  /** Removes the embedding vector (used when unpublished/deleted) */
6
6
  deleteVector(seed: Seed, entryId: string): Promise<void>;
7
- /** Retrieves all vectors for a given seed to compile to R2 */
7
+ /** Retrieves all vectors (with entry title) for a given seed to compile to R2 */
8
8
  getAllVectors(seed: Seed): Promise<{
9
9
  entryId: string;
10
10
  vector: Float32Array;
11
+ title: string;
11
12
  }[]>;
12
13
  }
13
14
  //# sourceMappingURL=vector.repository.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vector.repository.d.ts","sourceRoot":"","sources":["../../src/search/vector.repository.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAE9C,MAAM,WAAW,iBAAiB;IAChC,yDAAyD;IACzD,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE5E,mEAAmE;IACnE,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAExD,8DAA8D;IAC9D,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,YAAY,CAAA;KAAE,EAAE,CAAC,CAAA;CAChF"}
1
+ {"version":3,"file":"vector.repository.d.ts","sourceRoot":"","sources":["../../src/search/vector.repository.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAA;AAE9C,MAAM,WAAW,iBAAiB;IAChC,yDAAyD;IACzD,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE5E,mEAAmE;IACnE,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAExD,iFAAiF;IACjF,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,YAAY,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC,CAAA;CAC/F"}
@@ -1,8 +1,10 @@
1
1
  export interface ITimeTrapTokenRepository {
2
- /** Checks if a time-trap token hash has already been consumed. */
2
+ /** Cheap, non-atomic pre-check used only to fail fast before expensive validation. */
3
3
  isTokenUsed(tokenHash: string): Promise<boolean>;
4
- /** Marks a time-trap token hash as consumed with an expiration timestamp. */
5
- markTokenUsed(tokenHash: string, usedAt: number, expiresAt: number): Promise<void>;
4
+ /** Atomically claims a token hash as consumed. Returns false if it was already claimed. */
5
+ claimToken(tokenHash: string, usedAt: number, expiresAt: number): Promise<boolean>;
6
+ /** Releases a previously claimed token hash, allowing retry after a failed content creation. */
7
+ releaseToken(tokenHash: string): Promise<void>;
6
8
  /** Cleans up expired token entries. */
7
9
  cleanup(nowSeconds: number): Promise<void>;
8
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"time-trap-token.repository.d.ts","sourceRoot":"","sources":["../../src/security/time-trap-token.repository.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,wBAAwB;IACvC,kEAAkE;IAClE,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAChD,6EAA6E;IAC7E,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAClF,uCAAuC;IACvC,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3C"}
1
+ {"version":3,"file":"time-trap-token.repository.d.ts","sourceRoot":"","sources":["../../src/security/time-trap-token.repository.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,wBAAwB;IACvC,sFAAsF;IACtF,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAChD,2FAA2F;IAC3F,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAClF,gGAAgG;IAChG,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9C,uCAAuC;IACvC,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC3C"}