@noy-db/hub 0.2.0-pre.2 → 0.2.0-pre.21

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 (368) hide show
  1. package/README.md +126 -0
  2. package/dist/aggregate/index.cjs +643 -37
  3. package/dist/aggregate/index.cjs.map +1 -1
  4. package/dist/aggregate/index.d.cts +3 -2
  5. package/dist/aggregate/index.d.ts +3 -2
  6. package/dist/aggregate/index.js +9 -8
  7. package/dist/aggregate/index.js.map +1 -1
  8. package/dist/attestation/index.cjs.map +1 -1
  9. package/dist/attestation/index.d.cts +7 -5
  10. package/dist/attestation/index.d.ts +7 -5
  11. package/dist/attestation/index.js +6 -6
  12. package/dist/blobs/index.cjs +509 -22
  13. package/dist/blobs/index.cjs.map +1 -1
  14. package/dist/blobs/index.d.cts +9 -7
  15. package/dist/blobs/index.d.ts +9 -7
  16. package/dist/blobs/index.js +11 -6
  17. package/dist/blobs/index.js.map +1 -1
  18. package/dist/bundle/index.cjs +7886 -841
  19. package/dist/bundle/index.cjs.map +1 -1
  20. package/dist/bundle/index.d.cts +20 -18
  21. package/dist/bundle/index.d.ts +20 -18
  22. package/dist/bundle/index.js +24 -13
  23. package/dist/bundle/index.js.map +1 -1
  24. package/dist/{chunk-PFSNOPBQ.js → chunk-2XA2ZML4.js} +31 -3
  25. package/dist/chunk-2XA2ZML4.js.map +1 -0
  26. package/dist/{chunk-2PAQNPE3.js → chunk-37VGJM3T.js} +37 -2
  27. package/dist/chunk-37VGJM3T.js.map +1 -0
  28. package/dist/{chunk-7BRE6EUA.js → chunk-3HNKR65T.js} +4 -4
  29. package/dist/chunk-3HNKR65T.js.map +1 -0
  30. package/dist/{chunk-Y2RKOPNC.js → chunk-5YTXYPES.js} +46 -10
  31. package/dist/chunk-5YTXYPES.js.map +1 -0
  32. package/dist/{chunk-OVZDFEOR.js → chunk-6QAZ5O6X.js} +2 -2
  33. package/dist/chunk-6QAZ5O6X.js.map +1 -0
  34. package/dist/{chunk-RTZVQAJ7.js → chunk-6QE4DUYC.js} +19 -4
  35. package/dist/chunk-6QE4DUYC.js.map +1 -0
  36. package/dist/{chunk-7Q5PLD5C.js → chunk-7MRT7EPB.js} +3 -3
  37. package/dist/{chunk-E535SAN4.js → chunk-7PH4OPBZ.js} +4258 -520
  38. package/dist/chunk-7PH4OPBZ.js.map +1 -0
  39. package/dist/{chunk-PEULZC6M.js → chunk-A3JMGXPG.js} +8 -1
  40. package/dist/chunk-A3JMGXPG.js.map +1 -0
  41. package/dist/{chunk-UMLVJTYV.js → chunk-ADB7GPM3.js} +7 -4
  42. package/dist/chunk-ADB7GPM3.js.map +1 -0
  43. package/dist/{chunk-G6FRSBKK.js → chunk-AI4USDRI.js} +4 -4
  44. package/dist/chunk-BZW5IL43.js +151 -0
  45. package/dist/chunk-BZW5IL43.js.map +1 -0
  46. package/dist/chunk-C2RJVZZL.js +123 -0
  47. package/dist/chunk-C2RJVZZL.js.map +1 -0
  48. package/dist/{chunk-UND4XIB6.js → chunk-C6W5KVDV.js} +52 -38
  49. package/dist/chunk-C6W5KVDV.js.map +1 -0
  50. package/dist/chunk-CQYEDODS.js +125 -0
  51. package/dist/chunk-CQYEDODS.js.map +1 -0
  52. package/dist/{chunk-NWZ3I6R6.js → chunk-EYK72OTL.js} +5 -5
  53. package/dist/{chunk-7BUTTVMR.js → chunk-F5GWNSE2.js} +2 -2
  54. package/dist/{chunk-AHPFONIL.js → chunk-F5ILTHMU.js} +5 -5
  55. package/dist/{chunk-Q6W2CMEJ.js → chunk-FRRJIUSI.js} +18 -5
  56. package/dist/chunk-FRRJIUSI.js.map +1 -0
  57. package/dist/{chunk-YMYK7US4.js → chunk-GJTKMME7.js} +2 -2
  58. package/dist/chunk-GJTKMME7.js.map +1 -0
  59. package/dist/{chunk-EUYOGYGV.js → chunk-HYJMAV53.js} +6 -6
  60. package/dist/chunk-HYJMAV53.js.map +1 -0
  61. package/dist/{chunk-QPEXPHJR.js → chunk-I3IYTUUI.js} +4 -4
  62. package/dist/{chunk-3QAKZ37R.js → chunk-IVZWHIEK.js} +5 -5
  63. package/dist/{chunk-PLI5TV7N.js → chunk-IW4L4X65.js} +2 -2
  64. package/dist/chunk-IW4L4X65.js.map +1 -0
  65. package/dist/{chunk-3Z2TPHC4.js → chunk-IY24WS2P.js} +69 -5
  66. package/dist/chunk-IY24WS2P.js.map +1 -0
  67. package/dist/{chunk-HXJXPZRE.js → chunk-J6RGRZOY.js} +10 -3
  68. package/dist/chunk-J6RGRZOY.js.map +1 -0
  69. package/dist/{chunk-3S4BJX25.js → chunk-JBBWALNI.js} +2 -2
  70. package/dist/chunk-JBBWALNI.js.map +1 -0
  71. package/dist/{chunk-7Z23ZFLV.js → chunk-JDCPRJVS.js} +5 -5
  72. package/dist/chunk-JDCPRJVS.js.map +1 -0
  73. package/dist/{chunk-243PNUA6.js → chunk-JOK73NDT.js} +3 -3
  74. package/dist/chunk-JTI57WRT.js +164 -0
  75. package/dist/chunk-JTI57WRT.js.map +1 -0
  76. package/dist/{chunk-VRBCTEKQ.js → chunk-JYNH4FIM.js} +233 -11
  77. package/dist/chunk-JYNH4FIM.js.map +1 -0
  78. package/dist/{chunk-TBKOGSYR.js → chunk-KOAJ3TZM.js} +27 -5
  79. package/dist/chunk-KOAJ3TZM.js.map +1 -0
  80. package/dist/{chunk-YTXSFG3C.js → chunk-MBXKRHSS.js} +50 -20
  81. package/dist/chunk-MBXKRHSS.js.map +1 -0
  82. package/dist/{chunk-MUWOSVEP.js → chunk-NSXNXLYM.js} +10 -2
  83. package/dist/chunk-NSXNXLYM.js.map +1 -0
  84. package/dist/{chunk-J4KLMEUL.js → chunk-NV4IHBZS.js} +664 -51
  85. package/dist/chunk-NV4IHBZS.js.map +1 -0
  86. package/dist/{chunk-LRAZDV5X.js → chunk-O5XKZCUD.js} +31 -8
  87. package/dist/chunk-O5XKZCUD.js.map +1 -0
  88. package/dist/{chunk-W3XXT26A.js → chunk-OTWT6BAJ.js} +358 -3
  89. package/dist/chunk-OTWT6BAJ.js.map +1 -0
  90. package/dist/{chunk-XG3PTSCD.js → chunk-PDVP3C2I.js} +1 -1
  91. package/dist/chunk-PDVP3C2I.js.map +1 -0
  92. package/dist/{chunk-GIV6DWBG.js → chunk-S45MDEEF.js} +44 -5
  93. package/dist/chunk-S45MDEEF.js.map +1 -0
  94. package/dist/{chunk-VK5EER6C.js → chunk-SQKAECUL.js} +2 -2
  95. package/dist/{chunk-FAQVNJD4.js → chunk-SQOK5UM6.js} +12 -2
  96. package/dist/{chunk-FAQVNJD4.js.map → chunk-SQOK5UM6.js.map} +1 -1
  97. package/dist/chunk-STNPB3UM.js +9 -0
  98. package/dist/chunk-STNPB3UM.js.map +1 -0
  99. package/dist/{chunk-YS3POABP.js → chunk-TA6HPKWQ.js} +1 -1
  100. package/dist/chunk-TA6HPKWQ.js.map +1 -0
  101. package/dist/{chunk-4HIL6AHQ.js → chunk-TAMRU7A2.js} +4 -4
  102. package/dist/{chunk-QXQRKXCU.js → chunk-TGIJTNM3.js} +2 -2
  103. package/dist/chunk-TNH5SLCD.js +361 -0
  104. package/dist/chunk-TNH5SLCD.js.map +1 -0
  105. package/dist/{chunk-VPSUZLOJ.js → chunk-TYMDCIQM.js} +31 -5
  106. package/dist/chunk-TYMDCIQM.js.map +1 -0
  107. package/dist/chunk-U2XSUCDF.js +524 -0
  108. package/dist/chunk-U2XSUCDF.js.map +1 -0
  109. package/dist/{chunk-3Y53S2SA.js → chunk-UU6M64HI.js} +4 -4
  110. package/dist/{chunk-VCGTOS2A.js → chunk-WE2BUQD2.js} +3 -3
  111. package/dist/chunk-WE2BUQD2.js.map +1 -0
  112. package/dist/{chunk-JYQTXEIO.js → chunk-WWVJXBOT.js} +449 -29
  113. package/dist/chunk-WWVJXBOT.js.map +1 -0
  114. package/dist/chunk-YPIOFSN3.js +129 -0
  115. package/dist/chunk-YPIOFSN3.js.map +1 -0
  116. package/dist/chunk-ZC7J6ZYV.js +7 -0
  117. package/dist/chunk-ZC7J6ZYV.js.map +1 -0
  118. package/dist/{chunk-5ZGZ6HIZ.js → chunk-ZONKSLF2.js} +30 -7
  119. package/dist/chunk-ZONKSLF2.js.map +1 -0
  120. package/dist/consent/index.cjs.map +1 -1
  121. package/dist/consent/index.d.cts +8 -6
  122. package/dist/consent/index.d.ts +8 -6
  123. package/dist/consent/index.js +3 -3
  124. package/dist/{crypto-5ZDIY3NG.js → crypto-456N7UVX.js} +7 -3
  125. package/dist/{delegation-QYXZW25W.js → delegation-DP4COTXB.js} +5 -5
  126. package/dist/derivations/index.cjs +124 -6
  127. package/dist/derivations/index.cjs.map +1 -1
  128. package/dist/derivations/index.d.cts +11 -9
  129. package/dist/derivations/index.d.ts +11 -9
  130. package/dist/derivations/index.js +8 -6
  131. package/dist/{dev-unlock-DQCNDfFp.d.cts → dev-unlock-CY0HIZA0.d.cts} +1 -1
  132. package/dist/{dev-unlock-utkybTKb.d.ts → dev-unlock-CpKSkl2c.d.ts} +1 -1
  133. package/dist/discriminant-BN9REW3o.d.cts +60 -0
  134. package/dist/discriminant-BN9REW3o.d.ts +60 -0
  135. package/dist/errors-Dkc_fi-S.d.cts +1467 -0
  136. package/dist/errors-Dkc_fi-S.d.ts +1467 -0
  137. package/dist/executor-4IEW4KG5.js +8 -0
  138. package/dist/executor-KYJCJCIN.js +12 -0
  139. package/dist/executor-W7VIBOBZ.js +8 -0
  140. package/dist/{fanout-sidecar-VJ52RIEY.js → fanout-sidecar-YXNAEZ33.js} +2 -2
  141. package/dist/fanout-sidecar-YXNAEZ33.js.map +1 -0
  142. package/dist/forget/index.cjs +43 -0
  143. package/dist/forget/index.cjs.map +1 -0
  144. package/dist/forget/index.d.cts +1 -0
  145. package/dist/forget/index.d.ts +1 -0
  146. package/dist/forget/index.js +14 -0
  147. package/dist/guards/index.cjs +144 -4
  148. package/dist/guards/index.cjs.map +1 -1
  149. package/dist/guards/index.d.cts +16 -8
  150. package/dist/guards/index.d.ts +16 -8
  151. package/dist/guards/index.js +13 -7
  152. package/dist/{hash-jDowCrK2.d.cts → hash-BSd0-_L8.d.cts} +1 -1
  153. package/dist/{hash-DcoYWfJ_.d.ts → hash-BnBQx39y.d.ts} +1 -1
  154. package/dist/history/index.cjs +28 -5
  155. package/dist/history/index.cjs.map +1 -1
  156. package/dist/history/index.d.cts +9 -7
  157. package/dist/history/index.d.ts +9 -7
  158. package/dist/history/index.js +9 -7
  159. package/dist/history/index.js.map +1 -1
  160. package/dist/i18n/index.cjs +356 -26
  161. package/dist/i18n/index.cjs.map +1 -1
  162. package/dist/i18n/index.d.cts +8 -6
  163. package/dist/i18n/index.d.ts +8 -6
  164. package/dist/i18n/index.js +36 -15
  165. package/dist/i18n/index.js.map +1 -1
  166. package/dist/index-BMmajblo.d.cts +362 -0
  167. package/dist/index-BMmajblo.d.ts +362 -0
  168. package/dist/{index-BCKdioeh.d.ts → index-Bm9hIY7t.d.ts} +169 -1127
  169. package/dist/{index-BMjrzNZr.d.cts → index-tZqVB9g5.d.cts} +169 -1127
  170. package/dist/index.cjs +10286 -2168
  171. package/dist/index.cjs.map +1 -1
  172. package/dist/index.d.cts +258 -23
  173. package/dist/index.d.ts +258 -23
  174. package/dist/index.js +443 -110
  175. package/dist/index.js.map +1 -1
  176. package/dist/indexing/index.cjs +97 -32
  177. package/dist/indexing/index.cjs.map +1 -1
  178. package/dist/indexing/index.d.cts +3 -3
  179. package/dist/indexing/index.d.ts +3 -3
  180. package/dist/indexing/index.js +4 -4
  181. package/dist/issue-JXC6T2QR.js +12 -0
  182. package/dist/{lazy-builder-Rpd-V3jP.d.ts → lazy-builder-ChSqcF5t.d.ts} +2 -2
  183. package/dist/{lazy-builder-C-rPfWG0.d.cts → lazy-builder-eYZzLEL1.d.cts} +2 -2
  184. package/dist/{ledger-3IU5GMXA.js → ledger-I7JUYP4L.js} +6 -6
  185. package/dist/materialized-views/index.cjs +687 -13
  186. package/dist/materialized-views/index.cjs.map +1 -1
  187. package/dist/materialized-views/index.d.cts +23 -20
  188. package/dist/materialized-views/index.d.ts +23 -20
  189. package/dist/materialized-views/index.js +8 -7
  190. package/dist/mime-magic-BnJCGJzB.d.cts +103 -0
  191. package/dist/mime-magic-CjSyakO4.d.ts +103 -0
  192. package/dist/noydb-ZZCRF6TE.js +38 -0
  193. package/dist/overlay-views/index.cjs +58 -18
  194. package/dist/overlay-views/index.cjs.map +1 -1
  195. package/dist/overlay-views/index.d.cts +32 -12
  196. package/dist/overlay-views/index.d.ts +32 -12
  197. package/dist/overlay-views/index.js +6 -6
  198. package/dist/periods/index.cjs.map +1 -1
  199. package/dist/periods/index.d.cts +8 -6
  200. package/dist/periods/index.d.ts +8 -6
  201. package/dist/periods/index.js +6 -6
  202. package/dist/{predicate-Dnu81tsS.d.cts → predicate-BmhBSPCH.d.cts} +87 -5
  203. package/dist/{predicate-Dnu81tsS.d.ts → predicate-BmhBSPCH.d.ts} +87 -5
  204. package/dist/{public-envelope-U3CMEOMV.js → public-envelope-5XRTUNKF.js} +4 -4
  205. package/dist/query/index.cjs +1438 -130
  206. package/dist/query/index.cjs.map +1 -1
  207. package/dist/query/index.d.cts +4 -3
  208. package/dist/query/index.d.ts +4 -3
  209. package/dist/query/index.js +13 -6
  210. package/dist/read-only-facade-EX6WZZBP.js +7 -0
  211. package/dist/registry-ATRHOG5B.js +8 -0
  212. package/dist/registry-DKEXOJVO.js +7 -0
  213. package/dist/registry-LEHB26TY.js +8 -0
  214. package/dist/{registry-3ALP62P6.js → registry-NWHOLD5M.js} +3 -3
  215. package/dist/{revoke-KY2GB4KP.js → revoke-5IEK22KT.js} +6 -6
  216. package/dist/sealed-record/index.cjs +139 -0
  217. package/dist/sealed-record/index.cjs.map +1 -0
  218. package/dist/sealed-record/index.d.cts +123 -0
  219. package/dist/sealed-record/index.d.ts +123 -0
  220. package/dist/sealed-record/index.js +42 -0
  221. package/dist/sealed-record/index.js.map +1 -0
  222. package/dist/session/index.cjs.map +1 -1
  223. package/dist/session/index.d.cts +9 -7
  224. package/dist/session/index.d.ts +9 -7
  225. package/dist/session/index.js +3 -3
  226. package/dist/shadow/index.cjs.map +1 -1
  227. package/dist/shadow/index.d.cts +8 -6
  228. package/dist/shadow/index.d.ts +8 -6
  229. package/dist/shadow/index.js +2 -2
  230. package/dist/{signer-GRI5TZKH.js → signer-I6YARZQA.js} +5 -5
  231. package/dist/snapshots/index.cjs +937 -0
  232. package/dist/snapshots/index.cjs.map +1 -0
  233. package/dist/snapshots/index.d.cts +30 -0
  234. package/dist/snapshots/index.d.ts +30 -0
  235. package/dist/snapshots/index.js +152 -0
  236. package/dist/snapshots/index.js.map +1 -0
  237. package/dist/{stale-OTOF3FH7.js → stale-CPESGAPL.js} +2 -2
  238. package/dist/stale-CPESGAPL.js.map +1 -0
  239. package/dist/state-vault-JR3CFGNP.js +14 -0
  240. package/dist/state-vault-JR3CFGNP.js.map +1 -0
  241. package/dist/store/index.cjs +8 -0
  242. package/dist/store/index.cjs.map +1 -1
  243. package/dist/store/index.d.cts +15 -6
  244. package/dist/store/index.d.ts +15 -6
  245. package/dist/store/index.js +2 -2
  246. package/dist/{strategy-DSTrsZ8t.d.ts → strategy-54eIwox5.d.ts} +456 -7
  247. package/dist/{strategy-DSTrsZ8t.d.cts → strategy-WtB-jXYv.d.cts} +456 -7
  248. package/dist/sync/index.cjs.map +1 -1
  249. package/dist/sync/index.d.cts +7 -5
  250. package/dist/sync/index.d.ts +7 -5
  251. package/dist/sync/index.js +4 -4
  252. package/dist/team/index.cjs +1 -1
  253. package/dist/team/index.cjs.map +1 -1
  254. package/dist/team/index.d.cts +8 -6
  255. package/dist/team/index.d.ts +8 -6
  256. package/dist/team/index.js +8 -8
  257. package/dist/transition-guard-D4bfIAiW.d.ts +165 -0
  258. package/dist/transition-guard-Dmpqzg-_.d.cts +165 -0
  259. package/dist/tx/index.cjs +155 -5
  260. package/dist/tx/index.cjs.map +1 -1
  261. package/dist/tx/index.d.cts +27 -9
  262. package/dist/tx/index.d.ts +27 -9
  263. package/dist/tx/index.js +61 -4
  264. package/dist/tx/index.js.map +1 -1
  265. package/dist/{types-BoFFiskX.d.ts → types-DLfWFr6U.d.ts} +3997 -1262
  266. package/dist/{types-DJG8HG6F.d.cts → types-DyOI6XZ_.d.cts} +3997 -1262
  267. package/dist/{ulid-BmBgooGm.d.ts → ulid-B2L_aqVA.d.ts} +19 -19
  268. package/dist/{ulid-C7ms9oli.d.cts → ulid-LaxfH2tK.d.cts} +19 -19
  269. package/dist/util/index.cjs +7 -0
  270. package/dist/util/index.cjs.map +1 -1
  271. package/dist/util/index.d.cts +2 -0
  272. package/dist/util/index.d.ts +2 -0
  273. package/dist/util/index.js +5 -1
  274. package/dist/util/index.js.map +1 -1
  275. package/dist/vault-group-BB246VIM.js +804 -0
  276. package/dist/vault-group-BB246VIM.js.map +1 -0
  277. package/dist/{with-materialized-view-CqnRwI2S.d.ts → with-materialized-view-CeZYGJVf.d.cts} +2 -2
  278. package/dist/{with-materialized-view-BbEPFIIJ.d.cts → with-materialized-view-DNULSxoP.d.ts} +2 -2
  279. package/dist/{with-overlayed-view-Ct1fSJt-.d.ts → with-overlayed-view-C9joG7UZ.d.ts} +2 -2
  280. package/dist/{with-overlayed-view-bwlmmFjx.d.cts → with-overlayed-view-kdcPGHih.d.cts} +2 -2
  281. package/dist/with-rollup-DJDbrxjf.d.ts +47 -0
  282. package/dist/with-rollup-s58XAeWO.d.cts +47 -0
  283. package/package.json +35 -4
  284. package/dist/chunk-2PAQNPE3.js.map +0 -1
  285. package/dist/chunk-3S4BJX25.js.map +0 -1
  286. package/dist/chunk-3XHOCQK4.js +0 -118
  287. package/dist/chunk-3XHOCQK4.js.map +0 -1
  288. package/dist/chunk-3Z2TPHC4.js.map +0 -1
  289. package/dist/chunk-5ZGZ6HIZ.js.map +0 -1
  290. package/dist/chunk-7BRE6EUA.js.map +0 -1
  291. package/dist/chunk-7Z23ZFLV.js.map +0 -1
  292. package/dist/chunk-CXSCDO5T.js +0 -51
  293. package/dist/chunk-CXSCDO5T.js.map +0 -1
  294. package/dist/chunk-E535SAN4.js.map +0 -1
  295. package/dist/chunk-EUYOGYGV.js.map +0 -1
  296. package/dist/chunk-GIV6DWBG.js.map +0 -1
  297. package/dist/chunk-HXJXPZRE.js.map +0 -1
  298. package/dist/chunk-J4KLMEUL.js.map +0 -1
  299. package/dist/chunk-JYQTXEIO.js.map +0 -1
  300. package/dist/chunk-LRAZDV5X.js.map +0 -1
  301. package/dist/chunk-MRIBLZL3.js +0 -86
  302. package/dist/chunk-MRIBLZL3.js.map +0 -1
  303. package/dist/chunk-MUWOSVEP.js.map +0 -1
  304. package/dist/chunk-OVZDFEOR.js.map +0 -1
  305. package/dist/chunk-PEULZC6M.js.map +0 -1
  306. package/dist/chunk-PFSNOPBQ.js.map +0 -1
  307. package/dist/chunk-PLI5TV7N.js.map +0 -1
  308. package/dist/chunk-Q6W2CMEJ.js.map +0 -1
  309. package/dist/chunk-RTZVQAJ7.js.map +0 -1
  310. package/dist/chunk-TBKOGSYR.js.map +0 -1
  311. package/dist/chunk-UMLVJTYV.js.map +0 -1
  312. package/dist/chunk-UND4XIB6.js.map +0 -1
  313. package/dist/chunk-VCGTOS2A.js.map +0 -1
  314. package/dist/chunk-VE6YVP32.js +0 -19
  315. package/dist/chunk-VE6YVP32.js.map +0 -1
  316. package/dist/chunk-VPSUZLOJ.js.map +0 -1
  317. package/dist/chunk-VRBCTEKQ.js.map +0 -1
  318. package/dist/chunk-W3XXT26A.js.map +0 -1
  319. package/dist/chunk-XG3PTSCD.js.map +0 -1
  320. package/dist/chunk-Y2RKOPNC.js.map +0 -1
  321. package/dist/chunk-YMYK7US4.js.map +0 -1
  322. package/dist/chunk-YS3POABP.js.map +0 -1
  323. package/dist/chunk-YTXSFG3C.js.map +0 -1
  324. package/dist/executor-AS2IDHKZ.js +0 -11
  325. package/dist/executor-HLXFXNFM.js +0 -8
  326. package/dist/executor-HN6YBHZ5.js +0 -8
  327. package/dist/fanout-sidecar-VJ52RIEY.js.map +0 -1
  328. package/dist/issue-ORP37MVW.js +0 -12
  329. package/dist/mime-magic-CBBSOkjm.d.cts +0 -50
  330. package/dist/mime-magic-CBBSOkjm.d.ts +0 -50
  331. package/dist/noydb-5H3C24GG.js +0 -34
  332. package/dist/read-only-facade-ITU6L7BL.js +0 -7
  333. package/dist/registry-7HE6VJGC.js +0 -8
  334. package/dist/registry-PSIPG2QR.js +0 -8
  335. package/dist/registry-RFGGMVNJ.js +0 -7
  336. package/dist/with-derivation-BKXXa8Vt.d.ts +0 -13
  337. package/dist/with-derivation-BjQ7q4NE.d.cts +0 -13
  338. package/dist/with-guard-C25yNjzd.d.ts +0 -18
  339. package/dist/with-guard-DQme5DKE.d.cts +0 -18
  340. /package/dist/{chunk-7Q5PLD5C.js.map → chunk-7MRT7EPB.js.map} +0 -0
  341. /package/dist/{chunk-G6FRSBKK.js.map → chunk-AI4USDRI.js.map} +0 -0
  342. /package/dist/{chunk-NWZ3I6R6.js.map → chunk-EYK72OTL.js.map} +0 -0
  343. /package/dist/{chunk-7BUTTVMR.js.map → chunk-F5GWNSE2.js.map} +0 -0
  344. /package/dist/{chunk-AHPFONIL.js.map → chunk-F5ILTHMU.js.map} +0 -0
  345. /package/dist/{chunk-QPEXPHJR.js.map → chunk-I3IYTUUI.js.map} +0 -0
  346. /package/dist/{chunk-3QAKZ37R.js.map → chunk-IVZWHIEK.js.map} +0 -0
  347. /package/dist/{chunk-243PNUA6.js.map → chunk-JOK73NDT.js.map} +0 -0
  348. /package/dist/{chunk-VK5EER6C.js.map → chunk-SQKAECUL.js.map} +0 -0
  349. /package/dist/{chunk-4HIL6AHQ.js.map → chunk-TAMRU7A2.js.map} +0 -0
  350. /package/dist/{chunk-QXQRKXCU.js.map → chunk-TGIJTNM3.js.map} +0 -0
  351. /package/dist/{chunk-3Y53S2SA.js.map → chunk-UU6M64HI.js.map} +0 -0
  352. /package/dist/{crypto-5ZDIY3NG.js.map → crypto-456N7UVX.js.map} +0 -0
  353. /package/dist/{delegation-QYXZW25W.js.map → delegation-DP4COTXB.js.map} +0 -0
  354. /package/dist/{executor-AS2IDHKZ.js.map → executor-4IEW4KG5.js.map} +0 -0
  355. /package/dist/{executor-HLXFXNFM.js.map → executor-KYJCJCIN.js.map} +0 -0
  356. /package/dist/{executor-HN6YBHZ5.js.map → executor-W7VIBOBZ.js.map} +0 -0
  357. /package/dist/{issue-ORP37MVW.js.map → forget/index.js.map} +0 -0
  358. /package/dist/{ledger-3IU5GMXA.js.map → issue-JXC6T2QR.js.map} +0 -0
  359. /package/dist/{noydb-5H3C24GG.js.map → ledger-I7JUYP4L.js.map} +0 -0
  360. /package/dist/{public-envelope-U3CMEOMV.js.map → noydb-ZZCRF6TE.js.map} +0 -0
  361. /package/dist/{read-only-facade-ITU6L7BL.js.map → public-envelope-5XRTUNKF.js.map} +0 -0
  362. /package/dist/{registry-3ALP62P6.js.map → read-only-facade-EX6WZZBP.js.map} +0 -0
  363. /package/dist/{registry-7HE6VJGC.js.map → registry-ATRHOG5B.js.map} +0 -0
  364. /package/dist/{registry-PSIPG2QR.js.map → registry-DKEXOJVO.js.map} +0 -0
  365. /package/dist/{registry-RFGGMVNJ.js.map → registry-LEHB26TY.js.map} +0 -0
  366. /package/dist/{revoke-KY2GB4KP.js.map → registry-NWHOLD5M.js.map} +0 -0
  367. /package/dist/{signer-GRI5TZKH.js.map → revoke-5IEK22KT.js.map} +0 -0
  368. /package/dist/{stale-OTOF3FH7.js.map → signer-I6YARZQA.js.map} +0 -0
@@ -1,10 +1,12 @@
1
- import { aO as NoydbStore, aM as UnlockedKeyring } from '../types-DJG8HG6F.cjs';
2
- export { bc as BundleRecipient, bW as EnrollAuthenticatorOptions, bX as EnrollAuthenticatorWrappingDEKsOptions, bY as EnrollAuthenticatorWrappingKEKOptions, cn as ListUsersOptions, cM as PaperRecoveryEntry, cU as PresenceHandle, dd as RecoverPassphraseInput, de as RecoverPassphraseResult, df as RecoverUserOptions, dg as RecoveryProof, dj as RotatePassphraseInput, du as SlotRewrapCeremony, dv as SlotRewrapContext, dC as SyncEngine, dK as SyncTransaction, dS as UpdateAuthenticatorOptions, e4 as WrappedDeksBlob, e6 as buildRecipientKeyringFile, e7 as burnPaperRecoveryEntry, eS as changeSecret, eT as createOwnerKeyring, ea as deriveMagicLinkContentKey, eb as enrollAuthenticator, eU as ensureCollectionDEK, ed as evaluateExportCapability, ee as evaluateImportCapability, ef as findAuthenticator, eV as grant, eg as hasExportCapability, eh as hasImportCapability, ej as isMagicLinkGrantExpired, eo as listMagicLinkGrants, ep as listUsers, eq as listUsersWithEnvelopes, eW as loadKeyring, es as loadPaperRecoveryEntries, ev as magicLinkGrantRecordId, ew as mintPaperRecoveryEntry, ey as mintWrappedDeksBlob, eX as persistKeyring, eA as readMagicLinkGrantRecord, em as recoverPassphrase, eB as recoverUser, eC as removeAuthenticator, eY as revoke, eF as revokeMagicLinkGrant, en as rotatePassphrase, eG as savePaperRecoveryEntries, eJ as unwrapDeksFromBlob, eK as unwrapDeksFromPaperEntry, eM as unwrapMagicLinkGrant, eZ as updateAuthenticator, e_ as updateKeyringIdentity, eR as writeMagicLinkGrant } from '../types-DJG8HG6F.cjs';
3
- import '../lazy-builder-C-rPfWG0.cjs';
4
- import '../predicate-Dnu81tsS.cjs';
5
- import '../strategy-DSTrsZ8t.cjs';
1
+ import { aW as NoydbStore, aU as UnlockedKeyring } from '../types-DyOI6XZ_.cjs';
2
+ export { be as BundleRecipient, ck as EnrollAuthenticatorOptions, cl as EnrollAuthenticatorWrappingDEKsOptions, cm as EnrollAuthenticatorWrappingKEKOptions, c$ as ListUsersOptions, ds as PaperRecoveryEntry, dA as PresenceHandle, dV as RecoverPassphraseInput, dW as RecoverPassphraseResult, dX as RecoverUserOptions, dY as RecoveryProof, e0 as RotatePassphraseInput, eo as SlotRewrapCeremony, ep as SlotRewrapContext, ey as SyncEngine, eG as SyncTransaction, eW as UpdateAuthenticatorOptions, fe as WrappedDeksBlob, fl as buildRecipientKeyringFile, fm as burnPaperRecoveryEntry, ge as changeSecret, gf as createOwnerKeyring, fq as deriveMagicLinkContentKey, fr as enrollAuthenticator, gg as ensureCollectionDEK, fu as evaluateExportCapability, fv as evaluateImportCapability, fw as findAuthenticator, gh as grant, fx as hasExportCapability, fy as hasImportCapability, fB as isMagicLinkGrantExpired, fG as listMagicLinkGrants, fH as listUsers, fI as listUsersWithEnvelopes, gi as loadKeyring, fK as loadPaperRecoveryEntries, fN as magicLinkGrantRecordId, fO as mintPaperRecoveryEntry, fQ as mintWrappedDeksBlob, gj as persistKeyring, fT as readMagicLinkGrantRecord, fE as recoverPassphrase, fU as recoverUser, fV as removeAuthenticator, gk as revoke, fZ as revokeMagicLinkGrant, fF as rotatePassphrase, f$ as savePaperRecoveryEntries, g3 as unwrapDeksFromBlob, g4 as unwrapDeksFromPaperEntry, g6 as unwrapMagicLinkGrant, gl as updateAuthenticator, gm as updateKeyringIdentity, gd as writeMagicLinkGrant } from '../types-DyOI6XZ_.cjs';
3
+ import '../lazy-builder-eYZzLEL1.cjs';
4
+ import '../predicate-BmhBSPCH.cjs';
5
+ import '../strategy-WtB-jXYv.cjs';
6
+ import '../errors-Dkc_fi-S.cjs';
6
7
  import '../strategy-BSxFXGzb.cjs';
7
- import '../index-BMjrzNZr.cjs';
8
+ import '../index-BMmajblo.cjs';
9
+ import '../index-tZqVB9g5.cjs';
8
10
  import '@noy-db/attestation';
9
11
 
10
12
  /**
@@ -1,10 +1,12 @@
1
- import { aO as NoydbStore, aM as UnlockedKeyring } from '../types-BoFFiskX.js';
2
- export { bc as BundleRecipient, bW as EnrollAuthenticatorOptions, bX as EnrollAuthenticatorWrappingDEKsOptions, bY as EnrollAuthenticatorWrappingKEKOptions, cn as ListUsersOptions, cM as PaperRecoveryEntry, cU as PresenceHandle, dd as RecoverPassphraseInput, de as RecoverPassphraseResult, df as RecoverUserOptions, dg as RecoveryProof, dj as RotatePassphraseInput, du as SlotRewrapCeremony, dv as SlotRewrapContext, dC as SyncEngine, dK as SyncTransaction, dS as UpdateAuthenticatorOptions, e4 as WrappedDeksBlob, e6 as buildRecipientKeyringFile, e7 as burnPaperRecoveryEntry, eS as changeSecret, eT as createOwnerKeyring, ea as deriveMagicLinkContentKey, eb as enrollAuthenticator, eU as ensureCollectionDEK, ed as evaluateExportCapability, ee as evaluateImportCapability, ef as findAuthenticator, eV as grant, eg as hasExportCapability, eh as hasImportCapability, ej as isMagicLinkGrantExpired, eo as listMagicLinkGrants, ep as listUsers, eq as listUsersWithEnvelopes, eW as loadKeyring, es as loadPaperRecoveryEntries, ev as magicLinkGrantRecordId, ew as mintPaperRecoveryEntry, ey as mintWrappedDeksBlob, eX as persistKeyring, eA as readMagicLinkGrantRecord, em as recoverPassphrase, eB as recoverUser, eC as removeAuthenticator, eY as revoke, eF as revokeMagicLinkGrant, en as rotatePassphrase, eG as savePaperRecoveryEntries, eJ as unwrapDeksFromBlob, eK as unwrapDeksFromPaperEntry, eM as unwrapMagicLinkGrant, eZ as updateAuthenticator, e_ as updateKeyringIdentity, eR as writeMagicLinkGrant } from '../types-BoFFiskX.js';
3
- import '../lazy-builder-Rpd-V3jP.js';
4
- import '../predicate-Dnu81tsS.js';
5
- import '../strategy-DSTrsZ8t.js';
1
+ import { aW as NoydbStore, aU as UnlockedKeyring } from '../types-DLfWFr6U.js';
2
+ export { be as BundleRecipient, ck as EnrollAuthenticatorOptions, cl as EnrollAuthenticatorWrappingDEKsOptions, cm as EnrollAuthenticatorWrappingKEKOptions, c$ as ListUsersOptions, ds as PaperRecoveryEntry, dA as PresenceHandle, dV as RecoverPassphraseInput, dW as RecoverPassphraseResult, dX as RecoverUserOptions, dY as RecoveryProof, e0 as RotatePassphraseInput, eo as SlotRewrapCeremony, ep as SlotRewrapContext, ey as SyncEngine, eG as SyncTransaction, eW as UpdateAuthenticatorOptions, fe as WrappedDeksBlob, fl as buildRecipientKeyringFile, fm as burnPaperRecoveryEntry, ge as changeSecret, gf as createOwnerKeyring, fq as deriveMagicLinkContentKey, fr as enrollAuthenticator, gg as ensureCollectionDEK, fu as evaluateExportCapability, fv as evaluateImportCapability, fw as findAuthenticator, gh as grant, fx as hasExportCapability, fy as hasImportCapability, fB as isMagicLinkGrantExpired, fG as listMagicLinkGrants, fH as listUsers, fI as listUsersWithEnvelopes, gi as loadKeyring, fK as loadPaperRecoveryEntries, fN as magicLinkGrantRecordId, fO as mintPaperRecoveryEntry, fQ as mintWrappedDeksBlob, gj as persistKeyring, fT as readMagicLinkGrantRecord, fE as recoverPassphrase, fU as recoverUser, fV as removeAuthenticator, gk as revoke, fZ as revokeMagicLinkGrant, fF as rotatePassphrase, f$ as savePaperRecoveryEntries, g3 as unwrapDeksFromBlob, g4 as unwrapDeksFromPaperEntry, g6 as unwrapMagicLinkGrant, gl as updateAuthenticator, gm as updateKeyringIdentity, gd as writeMagicLinkGrant } from '../types-DLfWFr6U.js';
3
+ import '../lazy-builder-ChSqcF5t.js';
4
+ import '../predicate-BmhBSPCH.js';
5
+ import '../strategy-54eIwox5.js';
6
+ import '../errors-Dkc_fi-S.js';
6
7
  import '../strategy-BSxFXGzb.js';
7
- import '../index-BCKdioeh.js';
8
+ import '../index-BMmajblo.js';
9
+ import '../index-Bm9hIY7t.js';
8
10
  import '@noy-db/attestation';
9
11
 
10
12
  /**
@@ -5,7 +5,7 @@ import {
5
5
  getCredential,
6
6
  listCredentials,
7
7
  putCredential
8
- } from "../chunk-NWZ3I6R6.js";
8
+ } from "../chunk-EYK72OTL.js";
9
9
  import {
10
10
  burnPaperRecoveryEntry,
11
11
  deriveMagicLinkContentKey,
@@ -29,13 +29,13 @@ import {
29
29
  unwrapMagicLinkGrant,
30
30
  updateAuthenticator,
31
31
  writeMagicLinkGrant
32
- } from "../chunk-EUYOGYGV.js";
33
- import "../chunk-7BUTTVMR.js";
32
+ } from "../chunk-HYJMAV53.js";
33
+ import "../chunk-F5GWNSE2.js";
34
34
  import {
35
35
  PresenceHandle,
36
36
  SyncEngine,
37
37
  SyncTransaction
38
- } from "../chunk-3Y53S2SA.js";
38
+ } from "../chunk-UU6M64HI.js";
39
39
  import {
40
40
  buildRecipientKeyringFile,
41
41
  changeSecret,
@@ -52,11 +52,11 @@ import {
52
52
  persistKeyring,
53
53
  revoke,
54
54
  updateKeyringIdentity
55
- } from "../chunk-Q6W2CMEJ.js";
55
+ } from "../chunk-FRRJIUSI.js";
56
56
  import "../chunk-2QR2PQTT.js";
57
- import "../chunk-YS3POABP.js";
58
- import "../chunk-2PAQNPE3.js";
59
- import "../chunk-W3XXT26A.js";
57
+ import "../chunk-TA6HPKWQ.js";
58
+ import "../chunk-37VGJM3T.js";
59
+ import "../chunk-OTWT6BAJ.js";
60
60
  export {
61
61
  PresenceHandle,
62
62
  SYNC_CREDENTIALS_COLLECTION,
@@ -0,0 +1,165 @@
1
+ import { an as GuardStrategy, ar as GuardStrategyHandle, ao as GuardChange, ap as GuardContext } from './types-DLfWFr6U.js';
2
+
3
+ /**
4
+ * Register a guard for a collection. Guards run on every `put()` /
5
+ * `delete()` for the named collection (after permissions, before
6
+ * encryption) and may:
7
+ *
8
+ * - `check` — block writes by throwing (typically `RecordLockedError`)
9
+ * - `frozenFields` — freeze specific fields once a condition is true
10
+ * - `amendment` — declare an authorized-override path with invariant
11
+ *
12
+ * Pass the returned handle to `createNoydb({ strategies: [...] })`.
13
+ *
14
+ * @see docs/superpowers/specs/2026-05-18-guards-design.md
15
+ */
16
+ declare function withGuard<T extends Record<string, unknown>>(strategy: GuardStrategy<T>): GuardStrategyHandle<T>;
17
+
18
+ /**
19
+ * `immutableGuard` — declarative WORM / append-only sugar over the guard
20
+ * subsystem.
21
+ *
22
+ * Issued fiscal documents (invoices, DDTs) must be immutable after issue.
23
+ * That is expressible today with a hand-rolled `withGuard` (block on
24
+ * `check`/`onDelete`, allow an admin `amendment`), but the boilerplate is
25
+ * repetitive and easy to get subtly wrong. `immutableGuard` generates
26
+ * exactly that guard from a declarative config, reusing the guard
27
+ * machinery wholesale — `check`/`onDelete` rejection, the ledgered
28
+ * `amendment` override, and composition with `periods`/`history`.
29
+ *
30
+ * ```ts
31
+ * createNoydb({ guardStrategies: [
32
+ * immutableGuard({
33
+ * collection: 'invoices',
34
+ * after: (r) => r.status === 'issued', // immutable once issued
35
+ * }),
36
+ * ] })
37
+ * ```
38
+ *
39
+ * A record is mutable until `after(record)` holds; from then on, updates
40
+ * and deletes throw `RecordLockedError` unless performed inside an
41
+ * `amendment` transaction by an authorized role (the override is
42
+ * ledgered by the guard amendment mechanism). `appendOnly: true` is
43
+ * shorthand for `after: () => true` — immutable from creation.
44
+ */
45
+
46
+ interface ImmutableGuardConfig<T extends Record<string, unknown>> {
47
+ /** The collection to make WORM. */
48
+ collection: string;
49
+ /**
50
+ * A record becomes immutable once this predicate holds. Evaluated on
51
+ * the *existing* (already-persisted) record, so the write that first
52
+ * makes it true is still allowed; subsequent writes are blocked.
53
+ * Mutually exclusive with `appendOnly`.
54
+ */
55
+ after?: (record: T) => boolean;
56
+ /** Shorthand for `after: () => true` — immutable from creation. */
57
+ appendOnly?: boolean;
58
+ /** Roles permitted to override via an amendment transaction. Default `['admin', 'owner']`. */
59
+ amendmentRoles?: ReadonlyArray<'admin' | 'owner'>;
60
+ /**
61
+ * Optional set-level invariant run over the amendment change-set after
62
+ * the writes execute. Signature matches `GuardStrategy.amendment.invariant`
63
+ * exactly: it receives every {before, after} pair touching this
64
+ * collection in the amendment plus the guard context; throwing reverts
65
+ * the whole amendment and surfaces as `InvariantError`.
66
+ *
67
+ * Use this to keep a constraint inviolable EVEN under amendment — e.g.
68
+ * forbid deleting an issued document by re-throwing on any
69
+ * `before !== null && after === null` change, or assert a cross-record
70
+ * sum is preserved. When omitted the amendment is unconditionally
71
+ * allowed (the amendment itself is the sanctioned, ledgered override) —
72
+ * this is the backward-compatible default.
73
+ */
74
+ amendmentInvariant?: (changes: ReadonlyArray<GuardChange<T>>, ctx: GuardContext<T>) => Promise<void> | void;
75
+ }
76
+ /**
77
+ * Build an immutability guard. Pass the returned handle to
78
+ * `createNoydb({ guardStrategies: [...] })`.
79
+ */
80
+ declare function immutableGuard<T extends Record<string, unknown>>(config: ImmutableGuardConfig<T>): GuardStrategyHandle<T>;
81
+
82
+ /**
83
+ * `transitionGuard` — declarative state-machine sugar over the guard
84
+ * subsystem.
85
+ *
86
+ * Any record with a lifecycle field (invoice `status`, order state,
87
+ * ticket workflow, subscription phase) needs transition validation: a
88
+ * write may only move the field along a declared arc. That is expressible
89
+ * with a hand-rolled `withGuard({ check })`, but every consumer
90
+ * re-implements the same graph lookup + error. `transitionGuard`
91
+ * generates exactly that guard from a state graph, reusing the guard
92
+ * machinery wholesale — `check` rejection, the ledgered `amendment`
93
+ * override, and composition with `periods`/`history`.
94
+ *
95
+ * It generalizes {@link immutableGuard}: WORM is the special case "every
96
+ * state has no outgoing arcs", i.e. `transitions` mapping each state to `[]`.
97
+ *
98
+ * ```ts
99
+ * createNoydb({ guardStrategies: [
100
+ * transitionGuard<Sale>({
101
+ * collection: 'sales', field: 'status',
102
+ * transitions: { // absence of an arc = forbidden
103
+ * draft: ['to_verify', 'cancelled'],
104
+ * to_verify: ['proforma', 'draft', 'cancelled'],
105
+ * proforma: ['invoiced', 'cancelled'],
106
+ * invoiced: ['paid'], paid: [], cancelled: [],
107
+ * },
108
+ * initial: ['draft', 'to_verify'], // allowed status on insert
109
+ * }),
110
+ * ] })
111
+ * ```
112
+ *
113
+ * Semantics:
114
+ * - **Insert** (`ctx.existing === null`): `incoming[field]` must be in
115
+ * `initial`. When `initial` is omitted, any value is allowed on insert.
116
+ * - **Update**: the arc `(existing[field] → incoming[field])` must be
117
+ * listed in `transitions[from]`, else `IllegalTransitionError`. A
118
+ * same-value write (`from === to`) is allowed when `allowIdempotent`
119
+ * (default `true`) — so writes that touch other fields without moving
120
+ * state pass.
121
+ * - **Override**: inside an `amendment` transaction by an authorized role
122
+ * the check is skipped and the change is ledgered (mirrors every guard).
123
+ *
124
+ * The status graph is caller-supplied data — no UI, no domain logic.
125
+ */
126
+
127
+ interface TransitionGuardConfig<T extends Record<string, unknown>> {
128
+ /** The collection whose state field is governed. */
129
+ collection: string;
130
+ /** The state field on the record (e.g. `'status'`). */
131
+ field: keyof T & string;
132
+ /**
133
+ * The transition graph: each state maps to the states it may move to.
134
+ * A state absent from the map (or mapped to `[]`) is terminal — no
135
+ * outgoing arc, so any non-idempotent write from it is rejected.
136
+ */
137
+ transitions: Readonly<Record<string, readonly string[]>>;
138
+ /**
139
+ * States allowed as the initial value on insert (`existing === null`).
140
+ * Omit to allow any value on insert.
141
+ */
142
+ initial?: readonly string[];
143
+ /**
144
+ * Allow a same-value write (`from === to`) on update. Default `true` —
145
+ * lets a put that changes other fields, but not the state, through.
146
+ */
147
+ allowIdempotent?: boolean;
148
+ /** Roles permitted to override via an amendment transaction. Default `['admin', 'owner']`. */
149
+ amendmentRoles?: ReadonlyArray<'admin' | 'owner'>;
150
+ /**
151
+ * Optional set-level invariant run over the amendment change-set after
152
+ * the writes execute. Signature matches `GuardStrategy.amendment.invariant`
153
+ * exactly. When omitted the amendment is unconditionally allowed (the
154
+ * amendment itself is the sanctioned, ledgered override) — the
155
+ * backward-compatible default. Mirrors {@link immutableGuard}.
156
+ */
157
+ amendmentInvariant?: (changes: ReadonlyArray<GuardChange<T>>, ctx: GuardContext<T>) => Promise<void> | void;
158
+ }
159
+ /**
160
+ * Build a state-machine transition guard. Pass the returned handle to
161
+ * `createNoydb({ guardStrategies: [...] })`.
162
+ */
163
+ declare function transitionGuard<T extends Record<string, unknown>>(config: TransitionGuardConfig<T>): GuardStrategyHandle<T>;
164
+
165
+ export { type ImmutableGuardConfig as I, type TransitionGuardConfig as T, immutableGuard as i, transitionGuard as t, withGuard as w };
@@ -0,0 +1,165 @@
1
+ import { an as GuardStrategy, ar as GuardStrategyHandle, ao as GuardChange, ap as GuardContext } from './types-DyOI6XZ_.cjs';
2
+
3
+ /**
4
+ * Register a guard for a collection. Guards run on every `put()` /
5
+ * `delete()` for the named collection (after permissions, before
6
+ * encryption) and may:
7
+ *
8
+ * - `check` — block writes by throwing (typically `RecordLockedError`)
9
+ * - `frozenFields` — freeze specific fields once a condition is true
10
+ * - `amendment` — declare an authorized-override path with invariant
11
+ *
12
+ * Pass the returned handle to `createNoydb({ strategies: [...] })`.
13
+ *
14
+ * @see docs/superpowers/specs/2026-05-18-guards-design.md
15
+ */
16
+ declare function withGuard<T extends Record<string, unknown>>(strategy: GuardStrategy<T>): GuardStrategyHandle<T>;
17
+
18
+ /**
19
+ * `immutableGuard` — declarative WORM / append-only sugar over the guard
20
+ * subsystem.
21
+ *
22
+ * Issued fiscal documents (invoices, DDTs) must be immutable after issue.
23
+ * That is expressible today with a hand-rolled `withGuard` (block on
24
+ * `check`/`onDelete`, allow an admin `amendment`), but the boilerplate is
25
+ * repetitive and easy to get subtly wrong. `immutableGuard` generates
26
+ * exactly that guard from a declarative config, reusing the guard
27
+ * machinery wholesale — `check`/`onDelete` rejection, the ledgered
28
+ * `amendment` override, and composition with `periods`/`history`.
29
+ *
30
+ * ```ts
31
+ * createNoydb({ guardStrategies: [
32
+ * immutableGuard({
33
+ * collection: 'invoices',
34
+ * after: (r) => r.status === 'issued', // immutable once issued
35
+ * }),
36
+ * ] })
37
+ * ```
38
+ *
39
+ * A record is mutable until `after(record)` holds; from then on, updates
40
+ * and deletes throw `RecordLockedError` unless performed inside an
41
+ * `amendment` transaction by an authorized role (the override is
42
+ * ledgered by the guard amendment mechanism). `appendOnly: true` is
43
+ * shorthand for `after: () => true` — immutable from creation.
44
+ */
45
+
46
+ interface ImmutableGuardConfig<T extends Record<string, unknown>> {
47
+ /** The collection to make WORM. */
48
+ collection: string;
49
+ /**
50
+ * A record becomes immutable once this predicate holds. Evaluated on
51
+ * the *existing* (already-persisted) record, so the write that first
52
+ * makes it true is still allowed; subsequent writes are blocked.
53
+ * Mutually exclusive with `appendOnly`.
54
+ */
55
+ after?: (record: T) => boolean;
56
+ /** Shorthand for `after: () => true` — immutable from creation. */
57
+ appendOnly?: boolean;
58
+ /** Roles permitted to override via an amendment transaction. Default `['admin', 'owner']`. */
59
+ amendmentRoles?: ReadonlyArray<'admin' | 'owner'>;
60
+ /**
61
+ * Optional set-level invariant run over the amendment change-set after
62
+ * the writes execute. Signature matches `GuardStrategy.amendment.invariant`
63
+ * exactly: it receives every {before, after} pair touching this
64
+ * collection in the amendment plus the guard context; throwing reverts
65
+ * the whole amendment and surfaces as `InvariantError`.
66
+ *
67
+ * Use this to keep a constraint inviolable EVEN under amendment — e.g.
68
+ * forbid deleting an issued document by re-throwing on any
69
+ * `before !== null && after === null` change, or assert a cross-record
70
+ * sum is preserved. When omitted the amendment is unconditionally
71
+ * allowed (the amendment itself is the sanctioned, ledgered override) —
72
+ * this is the backward-compatible default.
73
+ */
74
+ amendmentInvariant?: (changes: ReadonlyArray<GuardChange<T>>, ctx: GuardContext<T>) => Promise<void> | void;
75
+ }
76
+ /**
77
+ * Build an immutability guard. Pass the returned handle to
78
+ * `createNoydb({ guardStrategies: [...] })`.
79
+ */
80
+ declare function immutableGuard<T extends Record<string, unknown>>(config: ImmutableGuardConfig<T>): GuardStrategyHandle<T>;
81
+
82
+ /**
83
+ * `transitionGuard` — declarative state-machine sugar over the guard
84
+ * subsystem.
85
+ *
86
+ * Any record with a lifecycle field (invoice `status`, order state,
87
+ * ticket workflow, subscription phase) needs transition validation: a
88
+ * write may only move the field along a declared arc. That is expressible
89
+ * with a hand-rolled `withGuard({ check })`, but every consumer
90
+ * re-implements the same graph lookup + error. `transitionGuard`
91
+ * generates exactly that guard from a state graph, reusing the guard
92
+ * machinery wholesale — `check` rejection, the ledgered `amendment`
93
+ * override, and composition with `periods`/`history`.
94
+ *
95
+ * It generalizes {@link immutableGuard}: WORM is the special case "every
96
+ * state has no outgoing arcs", i.e. `transitions` mapping each state to `[]`.
97
+ *
98
+ * ```ts
99
+ * createNoydb({ guardStrategies: [
100
+ * transitionGuard<Sale>({
101
+ * collection: 'sales', field: 'status',
102
+ * transitions: { // absence of an arc = forbidden
103
+ * draft: ['to_verify', 'cancelled'],
104
+ * to_verify: ['proforma', 'draft', 'cancelled'],
105
+ * proforma: ['invoiced', 'cancelled'],
106
+ * invoiced: ['paid'], paid: [], cancelled: [],
107
+ * },
108
+ * initial: ['draft', 'to_verify'], // allowed status on insert
109
+ * }),
110
+ * ] })
111
+ * ```
112
+ *
113
+ * Semantics:
114
+ * - **Insert** (`ctx.existing === null`): `incoming[field]` must be in
115
+ * `initial`. When `initial` is omitted, any value is allowed on insert.
116
+ * - **Update**: the arc `(existing[field] → incoming[field])` must be
117
+ * listed in `transitions[from]`, else `IllegalTransitionError`. A
118
+ * same-value write (`from === to`) is allowed when `allowIdempotent`
119
+ * (default `true`) — so writes that touch other fields without moving
120
+ * state pass.
121
+ * - **Override**: inside an `amendment` transaction by an authorized role
122
+ * the check is skipped and the change is ledgered (mirrors every guard).
123
+ *
124
+ * The status graph is caller-supplied data — no UI, no domain logic.
125
+ */
126
+
127
+ interface TransitionGuardConfig<T extends Record<string, unknown>> {
128
+ /** The collection whose state field is governed. */
129
+ collection: string;
130
+ /** The state field on the record (e.g. `'status'`). */
131
+ field: keyof T & string;
132
+ /**
133
+ * The transition graph: each state maps to the states it may move to.
134
+ * A state absent from the map (or mapped to `[]`) is terminal — no
135
+ * outgoing arc, so any non-idempotent write from it is rejected.
136
+ */
137
+ transitions: Readonly<Record<string, readonly string[]>>;
138
+ /**
139
+ * States allowed as the initial value on insert (`existing === null`).
140
+ * Omit to allow any value on insert.
141
+ */
142
+ initial?: readonly string[];
143
+ /**
144
+ * Allow a same-value write (`from === to`) on update. Default `true` —
145
+ * lets a put that changes other fields, but not the state, through.
146
+ */
147
+ allowIdempotent?: boolean;
148
+ /** Roles permitted to override via an amendment transaction. Default `['admin', 'owner']`. */
149
+ amendmentRoles?: ReadonlyArray<'admin' | 'owner'>;
150
+ /**
151
+ * Optional set-level invariant run over the amendment change-set after
152
+ * the writes execute. Signature matches `GuardStrategy.amendment.invariant`
153
+ * exactly. When omitted the amendment is unconditionally allowed (the
154
+ * amendment itself is the sanctioned, ledgered override) — the
155
+ * backward-compatible default. Mirrors {@link immutableGuard}.
156
+ */
157
+ amendmentInvariant?: (changes: ReadonlyArray<GuardChange<T>>, ctx: GuardContext<T>) => Promise<void> | void;
158
+ }
159
+ /**
160
+ * Build a state-machine transition guard. Pass the returned handle to
161
+ * `createNoydb({ guardStrategies: [...] })`.
162
+ */
163
+ declare function transitionGuard<T extends Record<string, unknown>>(config: TransitionGuardConfig<T>): GuardStrategyHandle<T>;
164
+
165
+ export { type ImmutableGuardConfig as I, type TransitionGuardConfig as T, immutableGuard as i, transitionGuard as t, withGuard as w };
package/dist/tx/index.cjs CHANGED
@@ -125,14 +125,21 @@ var init_executor = __esm({
125
125
  * Compare existing vs incoming for each `frozenFields.fields` entry
126
126
  * when `frozenFields.when(existing)` is true. Throws
127
127
  * `FieldFrozenError` listing every changed frozen field.
128
+ *
129
+ * @param skipFields — field names that are schema-owned computed fields.
130
+ * These are excluded from the comparison because `incoming` carries the
131
+ * raw user input (computed fields not yet evaluated), so comparing
132
+ * `existing[field]` vs `incoming[field]` would always look like a
133
+ * change even when the computed result is unchanged.
128
134
  */
129
- async checkFrozenFields(guard, id, existing, incoming) {
135
+ async checkFrozenFields(guard, id, existing, incoming, skipFields) {
130
136
  const ff = guard.frozenFields;
131
137
  if (!ff) return;
132
138
  if (existing === null) return;
133
139
  if (!ff.when(existing)) return;
134
140
  const changed = [];
135
141
  for (const f of ff.fields) {
142
+ if (skipFields?.has(String(f))) continue;
136
143
  if (existing[f] !== incoming[f]) {
137
144
  if (!deepEqual(existing[f], incoming[f])) changed.push(String(f));
138
145
  }
@@ -174,7 +181,35 @@ module.exports = __toCommonJS(tx_exports);
174
181
 
175
182
  // src/tx/transaction.ts
176
183
  init_errors();
184
+
185
+ // src/bundle/ulid.ts
186
+ var CROCKFORD_ALPHABET = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
187
+ function encodeBase32(value, length) {
188
+ let out = "";
189
+ let v = value;
190
+ for (let i = 0; i < length; i++) {
191
+ out = CROCKFORD_ALPHABET[v % 32] + out;
192
+ v = Math.floor(v / 32);
193
+ }
194
+ return out;
195
+ }
196
+ function generateULID() {
197
+ const now = Date.now();
198
+ const timestampHigh = Math.floor(now / 16777216);
199
+ const timestampLow = now & 16777215;
200
+ const tsPart = encodeBase32(timestampHigh, 5) + encodeBase32(timestampLow, 5);
201
+ const randBytes = new Uint8Array(10);
202
+ crypto.getRandomValues(randBytes);
203
+ const rand1 = randBytes[0] * 2 ** 32 + (randBytes[1] << 24 >>> 0) + (randBytes[2] << 16) + (randBytes[3] << 8) + randBytes[4];
204
+ const rand2 = randBytes[5] * 2 ** 32 + (randBytes[6] << 24 >>> 0) + (randBytes[7] << 16) + (randBytes[8] << 8) + randBytes[9];
205
+ const randPart = encodeBase32(rand1, 8) + encodeBase32(rand2, 8);
206
+ return tsPart + randPart;
207
+ }
208
+
209
+ // src/tx/transaction.ts
177
210
  var TxContext = class {
211
+ /** Stable id for this transaction; shared by all writes it performs. */
212
+ txId = generateULID();
178
213
  /** @internal */
179
214
  _ops = [];
180
215
  /**
@@ -183,7 +218,7 @@ var TxContext = class {
183
218
  * restore prior state via `revertExecuted`. Side-effect writes (e.g.
184
219
  * recursive derivation outputs fired inside `Collection.put`) are
185
220
  * appended here in execution order so they roll back alongside the
186
- * main staged ops (#133).
221
+ * main staged ops.
187
222
  */
188
223
  _executed = [];
189
224
  /** @internal */
@@ -300,7 +335,7 @@ var TxCollection = class {
300
335
  this._ctx._ops.push(op);
301
336
  }
302
337
  };
303
- async function runTransaction(db, fn, options) {
338
+ async function runTransaction(db, fn, options, txInvariants) {
304
339
  if (options?.amendment) {
305
340
  if (typeof options.reason !== "string" || options.reason.trim().length === 0) {
306
341
  throw new ValidationError(
@@ -324,12 +359,19 @@ async function runTransaction(db, fn, options) {
324
359
  }
325
360
  const priorEnvelopes = /* @__PURE__ */ new Map();
326
361
  const store = db._store;
362
+ const invariants = txInvariants ?? [];
363
+ const watchedScopes = new Set(invariants.map((i) => i.scope));
364
+ const plainBefore = /* @__PURE__ */ new Map();
327
365
  for (const op of ctx._ops) {
328
366
  const key = keyOf(op);
329
367
  if (!priorEnvelopes.has(key)) {
330
368
  const env = await store.get(op.vaultName, op.collectionName, op.id);
331
369
  priorEnvelopes.set(key, env);
332
370
  }
371
+ if (watchedScopes.has(op.collectionName) && !plainBefore.has(key)) {
372
+ const prior = await db.vault(op.vaultName).collection(op.collectionName).get(op.id);
373
+ plainBefore.set(key, prior ?? null);
374
+ }
333
375
  if (op.expectedVersion !== void 0) {
334
376
  const env = priorEnvelopes.get(key) ?? null;
335
377
  const actual = env?._v ?? 0;
@@ -427,6 +469,58 @@ async function runTransaction(db, fn, options) {
427
469
  );
428
470
  }
429
471
  }
472
+ if (invariants.length > 0) {
473
+ const lastOp = /* @__PURE__ */ new Map();
474
+ const order = [];
475
+ for (const op of ctx._ops) {
476
+ const key = keyOf(op);
477
+ if (!lastOp.has(key)) order.push(key);
478
+ lastOp.set(key, op);
479
+ }
480
+ const changesByScope = /* @__PURE__ */ new Map();
481
+ const scopeVault = /* @__PURE__ */ new Map();
482
+ for (const key of order) {
483
+ const op = lastOp.get(key);
484
+ if (!watchedScopes.has(op.collectionName)) continue;
485
+ const before = plainBefore.get(key) ?? null;
486
+ const after = op.type === "delete" ? null : op.record ?? null;
487
+ const change = { before, after };
488
+ const arr = changesByScope.get(op.collectionName);
489
+ if (arr) arr.push(change);
490
+ else changesByScope.set(op.collectionName, [change]);
491
+ scopeVault.set(op.collectionName, op.vaultName);
492
+ }
493
+ try {
494
+ for (const inv of invariants) {
495
+ const changes = changesByScope.get(inv.scope);
496
+ if (changes === void 0 || changes.length === 0) continue;
497
+ const vaultName = scopeVault.get(inv.scope);
498
+ const v = db.vault(vaultName);
499
+ const facade = v._getReadOnlyFacade() ?? {
500
+ collection(name) {
501
+ const c = v.collection(name);
502
+ return {
503
+ get: (id) => c.get(id),
504
+ list: () => c.list(),
505
+ query: () => c.query()
506
+ };
507
+ }
508
+ };
509
+ const ctxForInv = {
510
+ existing: null,
511
+ vault: facade,
512
+ userId: v.userId,
513
+ role: v.role
514
+ };
515
+ await inv.check(changes, ctxForInv);
516
+ }
517
+ } catch (err) {
518
+ await revertExecuted(ctx._executed, store, db);
519
+ throw err instanceof InvariantError ? err : new InvariantError(
520
+ err instanceof Error ? err.message : `invariant violated: ${String(err)}`
521
+ );
522
+ }
523
+ }
430
524
  return bodyResult;
431
525
  }
432
526
  async function revertExecuted(executed, store, db) {
@@ -449,9 +543,65 @@ function keyOf(op) {
449
543
  return `${op.vaultName}\0${op.collectionName}\0${op.id}`;
450
544
  }
451
545
 
546
+ // src/tx/dry-run.ts
547
+ var SEP = " ";
548
+ var keyOf2 = (op) => `${op.vaultName}${SEP}${op.collectionName}${SEP}${op.id}`;
549
+ async function runDryRun(db, fn) {
550
+ const ctx = new TxContext(db);
551
+ await fn(ctx);
552
+ const lastOp = /* @__PURE__ */ new Map();
553
+ for (const op of ctx._ops) lastOp.set(keyOf2(op), op);
554
+ const affected = [];
555
+ const guardViolations = [];
556
+ for (const op of lastOp.values()) {
557
+ const v = db.vault(op.vaultName);
558
+ const coll = v.collection(op.collectionName);
559
+ const before = await coll.get(op.id);
560
+ if (op.type === "delete") {
561
+ affected.push({ vault: op.vaultName, op: "delete", collection: op.collectionName, docId: op.id, before, after: null });
562
+ continue;
563
+ }
564
+ const after = op.record ?? null;
565
+ affected.push({
566
+ vault: op.vaultName,
567
+ op: before === null ? "create" : "update",
568
+ collection: op.collectionName,
569
+ docId: op.id,
570
+ before,
571
+ after
572
+ });
573
+ const registry = v._getGuardRegistry();
574
+ if (!registry) continue;
575
+ const guards = registry.guardsFor(op.collectionName);
576
+ if (guards.length === 0) continue;
577
+ const facade = v._getReadOnlyFacade();
578
+ if (!facade) continue;
579
+ const gctx = { existing: before, vault: facade, userId: v.userId, role: v.role };
580
+ try {
581
+ await registry.runChecks(op.collectionName, after, gctx);
582
+ const { GuardExecutor: GuardExecutor2 } = await Promise.resolve().then(() => (init_executor(), executor_exports));
583
+ for (const g of guards) {
584
+ await GuardExecutor2.checkFrozenFields(g, op.id, before, after);
585
+ }
586
+ } catch (err) {
587
+ guardViolations.push({
588
+ vault: op.vaultName,
589
+ collection: op.collectionName,
590
+ docId: op.id,
591
+ message: err instanceof Error ? err.message : String(err)
592
+ });
593
+ }
594
+ }
595
+ return { affected, guardViolations };
596
+ }
597
+
452
598
  // src/tx/active.ts
453
- function withTransactions() {
454
- return { runTransaction };
599
+ function withTransactions(opts) {
600
+ const invariants = opts?.invariants ?? [];
601
+ return {
602
+ runTransaction: (db, fn, options) => runTransaction(db, fn, options, invariants),
603
+ runDryRun
604
+ };
455
605
  }
456
606
  // Annotate the CommonJS export names for ESM import in node:
457
607
  0 && (module.exports = {