@noy-db/hub 0.2.0-pre.12 → 0.2.0-pre.14

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 (249) hide show
  1. package/dist/aggregate/index.cjs.map +1 -1
  2. package/dist/aggregate/index.d.cts +2 -2
  3. package/dist/aggregate/index.d.ts +2 -2
  4. package/dist/aggregate/index.js +2 -2
  5. package/dist/attestation/index.cjs.map +1 -1
  6. package/dist/attestation/index.d.cts +3 -3
  7. package/dist/attestation/index.d.ts +3 -3
  8. package/dist/attestation/index.js +6 -6
  9. package/dist/blobs/index.cjs.map +1 -1
  10. package/dist/blobs/index.d.cts +4 -4
  11. package/dist/blobs/index.d.ts +4 -4
  12. package/dist/blobs/index.js +5 -5
  13. package/dist/bundle/index.cjs +683 -39
  14. package/dist/bundle/index.cjs.map +1 -1
  15. package/dist/bundle/index.d.cts +5 -5
  16. package/dist/bundle/index.d.ts +5 -5
  17. package/dist/bundle/index.js +9 -9
  18. package/dist/{chunk-OPDTLHFA.js → chunk-3EWA37FV.js} +2 -2
  19. package/dist/{chunk-ZCFS7U4J.js → chunk-4PEFEETV.js} +2 -2
  20. package/dist/{chunk-ZC7MNVYN.js → chunk-4TBBMHVC.js} +2 -2
  21. package/dist/{chunk-AGRC7NQQ.js → chunk-535SSHBS.js} +33 -1
  22. package/dist/chunk-535SSHBS.js.map +1 -0
  23. package/dist/{chunk-SJJQKNMP.js → chunk-56DJ7JVK.js} +4 -4
  24. package/dist/{chunk-C2CIIQRG.js → chunk-5LQG6ZO2.js} +2 -2
  25. package/dist/{chunk-6AD5TBF2.js → chunk-6AJBSQU4.js} +3 -3
  26. package/dist/{chunk-LWSD4QPT.js → chunk-6RR3MNMG.js} +3 -3
  27. package/dist/{chunk-O53RIZCC.js → chunk-7HT2MEZ5.js} +5 -5
  28. package/dist/{chunk-7LVRIW4G.js → chunk-7PS7EOCF.js} +4 -4
  29. package/dist/{chunk-GFPR7VJS.js → chunk-A5ZOOZFB.js} +4 -4
  30. package/dist/{chunk-B7GGYNKQ.js → chunk-AAVWKNZW.js} +2 -2
  31. package/dist/{chunk-TMHJEYW7.js → chunk-ACKFRSAH.js} +302 -137
  32. package/dist/chunk-ACKFRSAH.js.map +1 -0
  33. package/dist/{chunk-SZ4N3IL5.js → chunk-BIYRQQV6.js} +5 -5
  34. package/dist/{chunk-CILT6V3V.js → chunk-BQ65SS5A.js} +2 -2
  35. package/dist/{chunk-DLTU4M2I.js → chunk-COFPAMX6.js} +6 -6
  36. package/dist/{chunk-UA6G45ME.js → chunk-DKO2QFSA.js} +3 -3
  37. package/dist/{chunk-L6BYRCYB.js → chunk-DQU36Q7I.js} +2 -2
  38. package/dist/{chunk-VOXMU6LB.js → chunk-EGD5DXFT.js} +2 -2
  39. package/dist/{chunk-BXOUVUES.js → chunk-F4OJZIWQ.js} +4 -4
  40. package/dist/{chunk-P3Z5Y2TS.js → chunk-FWPKCXTN.js} +2 -2
  41. package/dist/{chunk-LYNNZEQD.js → chunk-GC4V7RU7.js} +1 -1
  42. package/dist/chunk-GC4V7RU7.js.map +1 -0
  43. package/dist/{chunk-6BYBVRZU.js → chunk-HOR4R722.js} +3 -3
  44. package/dist/{chunk-XSIFXX54.js → chunk-JD3OZAI4.js} +2 -2
  45. package/dist/{chunk-UOC7JMZO.js → chunk-KGCORI4L.js} +135 -10
  46. package/dist/chunk-KGCORI4L.js.map +1 -0
  47. package/dist/{chunk-RRDWXNBQ.js → chunk-KI6HAJWL.js} +3 -3
  48. package/dist/{chunk-LSEW3ZZ2.js → chunk-L2FE64BU.js} +3 -3
  49. package/dist/{chunk-HBAJDI2N.js → chunk-LX3CB26H.js} +5 -5
  50. package/dist/{chunk-LOA2VCMS.js → chunk-NSCVNK5K.js} +5 -5
  51. package/dist/{chunk-4BHFNKTP.js → chunk-OHVFWCJP.js} +2 -2
  52. package/dist/{chunk-7JJE3OMJ.js → chunk-PE4AQGFH.js} +5 -5
  53. package/dist/{chunk-RHQYVHFH.js → chunk-TS26M2SB.js} +2 -2
  54. package/dist/{chunk-EKNUBIIQ.js → chunk-UWNYBOOO.js} +4 -4
  55. package/dist/{chunk-WNRGOVLG.js → chunk-VU7SWWT5.js} +2 -2
  56. package/dist/{chunk-WUG3E423.js → chunk-WBAYSNUQ.js} +4 -4
  57. package/dist/{chunk-XHM2SARW.js → chunk-WGHU7BLI.js} +3 -3
  58. package/dist/{chunk-5ARRXIVR.js → chunk-X73VS74Y.js} +2 -2
  59. package/dist/{chunk-M45IRXDM.js → chunk-YHPM5D7Y.js} +3 -3
  60. package/dist/{chunk-P4EDT5ZP.js → chunk-YNTBADIY.js} +2 -2
  61. package/dist/{chunk-IUBHXEPJ.js → chunk-YULZKK4F.js} +2 -2
  62. package/dist/{chunk-IEPT7HVP.js → chunk-Z4DO7YSI.js} +2 -2
  63. package/dist/chunk-ZC7J6ZYV.js +7 -0
  64. package/dist/chunk-ZC7J6ZYV.js.map +1 -0
  65. package/dist/{chunk-HLGDYFWR.js → chunk-ZNQYHJXX.js} +2 -2
  66. package/dist/{chunk-CHBXWJZQ.js → chunk-ZWTNWAO4.js} +2 -2
  67. package/dist/consent/index.cjs.map +1 -1
  68. package/dist/consent/index.d.cts +4 -4
  69. package/dist/consent/index.d.ts +4 -4
  70. package/dist/consent/index.js +3 -3
  71. package/dist/{crypto-AJB72OKN.js → crypto-QXQOHMHF.js} +3 -3
  72. package/dist/{delegation-6FCWDRUS.js → delegation-NIQ43IPU.js} +5 -5
  73. package/dist/derivations/index.cjs.map +1 -1
  74. package/dist/derivations/index.d.cts +5 -5
  75. package/dist/derivations/index.d.ts +5 -5
  76. package/dist/derivations/index.js +4 -4
  77. package/dist/{dev-unlock-ckqa_Nso.d.cts → dev-unlock-BF4OSxRv.d.cts} +1 -1
  78. package/dist/{dev-unlock-D3mpVFRc.d.ts → dev-unlock-DV7ujTCI.d.ts} +1 -1
  79. package/dist/executor-6ZDSDZ6V.js +8 -0
  80. package/dist/executor-723ZP6TH.js +11 -0
  81. package/dist/executor-IDZDAFNH.js +8 -0
  82. package/dist/{fanout-sidecar-ZSKEQ6NI.js → fanout-sidecar-N6OJX6QR.js} +2 -2
  83. package/dist/guards/index.cjs.map +1 -1
  84. package/dist/guards/index.d.cts +5 -5
  85. package/dist/guards/index.d.ts +5 -5
  86. package/dist/guards/index.js +3 -3
  87. package/dist/{hash-rDSSd_oW.d.cts → hash-BcF5WQXl.d.cts} +1 -1
  88. package/dist/{hash-CTZVkXLx.d.ts → hash-DswxkLtW.d.ts} +1 -1
  89. package/dist/history/index.cjs.map +1 -1
  90. package/dist/history/index.d.cts +5 -5
  91. package/dist/history/index.d.ts +5 -5
  92. package/dist/history/index.js +5 -5
  93. package/dist/i18n/index.cjs.map +1 -1
  94. package/dist/i18n/index.d.cts +4 -4
  95. package/dist/i18n/index.d.ts +4 -4
  96. package/dist/i18n/index.js +6 -6
  97. package/dist/{immutable-guard-C51vAHuh.d.cts → immutable-guard-7KqslW2K.d.cts} +1 -1
  98. package/dist/{immutable-guard-DyD0qg2k.d.ts → immutable-guard-C8IYdzfu.d.ts} +1 -1
  99. package/dist/{index-Cmop06zJ.d.cts → index-CUVOMtgg.d.cts} +28 -2
  100. package/dist/{index-CkFHr4OP.d.ts → index-Cqzp4tt9.d.ts} +28 -2
  101. package/dist/index.cjs +699 -42
  102. package/dist/index.cjs.map +1 -1
  103. package/dist/index.d.cts +22 -13
  104. package/dist/index.d.ts +22 -13
  105. package/dist/index.js +59 -40
  106. package/dist/index.js.map +1 -1
  107. package/dist/indexing/index.cjs.map +1 -1
  108. package/dist/indexing/index.js +2 -2
  109. package/dist/issue-ADVS4OVP.js +12 -0
  110. package/dist/{ledger-5JMVF7PY.js → ledger-CWSE3BLF.js} +5 -5
  111. package/dist/materialized-views/index.cjs.map +1 -1
  112. package/dist/materialized-views/index.d.cts +5 -5
  113. package/dist/materialized-views/index.d.ts +5 -5
  114. package/dist/materialized-views/index.js +6 -6
  115. package/dist/noydb-VZ4JVW55.js +35 -0
  116. package/dist/overlay-views/index.cjs.map +1 -1
  117. package/dist/overlay-views/index.d.cts +5 -5
  118. package/dist/overlay-views/index.d.ts +5 -5
  119. package/dist/overlay-views/index.js +4 -4
  120. package/dist/periods/index.cjs.map +1 -1
  121. package/dist/periods/index.d.cts +4 -4
  122. package/dist/periods/index.d.ts +4 -4
  123. package/dist/periods/index.js +5 -5
  124. package/dist/{public-envelope-PFLZI5MO.js → public-envelope-SYHEYQ3X.js} +4 -4
  125. package/dist/query/index.cjs +89 -7
  126. package/dist/query/index.cjs.map +1 -1
  127. package/dist/query/index.d.cts +2 -2
  128. package/dist/query/index.d.ts +2 -2
  129. package/dist/query/index.js +3 -3
  130. package/dist/{registry-NCY445U5.js → registry-DK5YWAAA.js} +3 -3
  131. package/dist/registry-IUZQVVBB.js +8 -0
  132. package/dist/registry-XGLNADIE.js +8 -0
  133. package/dist/{revoke-7RLGQWZ7.js → revoke-ZDFKMR5E.js} +6 -6
  134. package/dist/session/index.cjs.map +1 -1
  135. package/dist/session/index.d.cts +5 -5
  136. package/dist/session/index.d.ts +5 -5
  137. package/dist/session/index.js +3 -3
  138. package/dist/shadow/index.cjs.map +1 -1
  139. package/dist/shadow/index.d.cts +4 -4
  140. package/dist/shadow/index.d.ts +4 -4
  141. package/dist/shadow/index.js +2 -2
  142. package/dist/{signer-6JF44I4A.js → signer-P5D7Y72U.js} +5 -5
  143. package/dist/snapshots/index.cjs.map +1 -1
  144. package/dist/snapshots/index.d.cts +4 -4
  145. package/dist/snapshots/index.d.ts +4 -4
  146. package/dist/snapshots/index.js +4 -4
  147. package/dist/{stale-UBLP3RJ3.js → stale-7FRJVHN6.js} +2 -2
  148. package/dist/state-vault-TMXZRTY5.js +147 -0
  149. package/dist/state-vault-TMXZRTY5.js.map +1 -0
  150. package/dist/store/index.cjs.map +1 -1
  151. package/dist/store/index.d.cts +4 -4
  152. package/dist/store/index.d.ts +4 -4
  153. package/dist/store/index.js +2 -2
  154. package/dist/{strategy-rtpKDfTC.d.ts → strategy-CrS7PnbE.d.cts} +20 -1
  155. package/dist/{strategy-rtpKDfTC.d.cts → strategy-CrS7PnbE.d.ts} +20 -1
  156. package/dist/sync/index.cjs.map +1 -1
  157. package/dist/sync/index.d.cts +3 -3
  158. package/dist/sync/index.d.ts +3 -3
  159. package/dist/sync/index.js +4 -4
  160. package/dist/team/index.cjs.map +1 -1
  161. package/dist/team/index.d.cts +4 -4
  162. package/dist/team/index.d.ts +4 -4
  163. package/dist/team/index.js +8 -8
  164. package/dist/tx/index.cjs.map +1 -1
  165. package/dist/tx/index.d.cts +4 -4
  166. package/dist/tx/index.d.ts +4 -4
  167. package/dist/tx/index.js +3 -3
  168. package/dist/{types-DRdfwgTG.d.ts → types-BFHQUjdy.d.ts} +341 -90
  169. package/dist/{types-BGwjsDef.d.cts → types-V5R2-pd4.d.cts} +341 -90
  170. package/dist/{ulid-D4d0Xto3.d.cts → ulid-CwNf9e6-.d.cts} +1 -1
  171. package/dist/{ulid-DOTPZ5_h.d.ts → ulid-p2nKiiKg.d.ts} +1 -1
  172. package/dist/util/index.cjs.map +1 -1
  173. package/dist/util/index.js +1 -1
  174. package/dist/{vault-group-Z4KB75ZH.js → vault-group-W7QC4UYW.js} +175 -18
  175. package/dist/vault-group-W7QC4UYW.js.map +1 -0
  176. package/dist/{with-derivation-CB1EdcFF.d.cts → with-derivation-C9K43BOB.d.cts} +1 -1
  177. package/dist/{with-derivation-B082Y_WQ.d.ts → with-derivation-Ds9yZgCj.d.ts} +1 -1
  178. package/dist/{with-materialized-view-CzRg1Dpr.d.cts → with-materialized-view-DgQcAjYv.d.cts} +1 -1
  179. package/dist/{with-materialized-view-Dw4SwjKl.d.ts → with-materialized-view-DwR4jkV5.d.ts} +1 -1
  180. package/dist/{with-overlayed-view-C9YFKXzn.d.cts → with-overlayed-view-7-rUB3vD.d.cts} +1 -1
  181. package/dist/{with-overlayed-view-CaCXeW26.d.ts → with-overlayed-view-ByyhHdVr.d.ts} +1 -1
  182. package/package.json +3 -3
  183. package/dist/chunk-AGRC7NQQ.js.map +0 -1
  184. package/dist/chunk-LYNNZEQD.js.map +0 -1
  185. package/dist/chunk-TMHJEYW7.js.map +0 -1
  186. package/dist/chunk-UOC7JMZO.js.map +0 -1
  187. package/dist/executor-7KSCEIFA.js +0 -8
  188. package/dist/executor-D2QMNGRJ.js +0 -8
  189. package/dist/executor-O5AZK7UW.js +0 -11
  190. package/dist/issue-YIYG4OW5.js +0 -12
  191. package/dist/noydb-D5SLAJ6V.js +0 -34
  192. package/dist/registry-BVQ5ITMF.js +0 -8
  193. package/dist/registry-JLP3QOLD.js +0 -8
  194. package/dist/vault-group-Z4KB75ZH.js.map +0 -1
  195. /package/dist/{chunk-OPDTLHFA.js.map → chunk-3EWA37FV.js.map} +0 -0
  196. /package/dist/{chunk-ZCFS7U4J.js.map → chunk-4PEFEETV.js.map} +0 -0
  197. /package/dist/{chunk-ZC7MNVYN.js.map → chunk-4TBBMHVC.js.map} +0 -0
  198. /package/dist/{chunk-SJJQKNMP.js.map → chunk-56DJ7JVK.js.map} +0 -0
  199. /package/dist/{chunk-C2CIIQRG.js.map → chunk-5LQG6ZO2.js.map} +0 -0
  200. /package/dist/{chunk-6AD5TBF2.js.map → chunk-6AJBSQU4.js.map} +0 -0
  201. /package/dist/{chunk-LWSD4QPT.js.map → chunk-6RR3MNMG.js.map} +0 -0
  202. /package/dist/{chunk-O53RIZCC.js.map → chunk-7HT2MEZ5.js.map} +0 -0
  203. /package/dist/{chunk-7LVRIW4G.js.map → chunk-7PS7EOCF.js.map} +0 -0
  204. /package/dist/{chunk-GFPR7VJS.js.map → chunk-A5ZOOZFB.js.map} +0 -0
  205. /package/dist/{chunk-B7GGYNKQ.js.map → chunk-AAVWKNZW.js.map} +0 -0
  206. /package/dist/{chunk-SZ4N3IL5.js.map → chunk-BIYRQQV6.js.map} +0 -0
  207. /package/dist/{chunk-CILT6V3V.js.map → chunk-BQ65SS5A.js.map} +0 -0
  208. /package/dist/{chunk-DLTU4M2I.js.map → chunk-COFPAMX6.js.map} +0 -0
  209. /package/dist/{chunk-UA6G45ME.js.map → chunk-DKO2QFSA.js.map} +0 -0
  210. /package/dist/{chunk-L6BYRCYB.js.map → chunk-DQU36Q7I.js.map} +0 -0
  211. /package/dist/{chunk-VOXMU6LB.js.map → chunk-EGD5DXFT.js.map} +0 -0
  212. /package/dist/{chunk-BXOUVUES.js.map → chunk-F4OJZIWQ.js.map} +0 -0
  213. /package/dist/{chunk-P3Z5Y2TS.js.map → chunk-FWPKCXTN.js.map} +0 -0
  214. /package/dist/{chunk-6BYBVRZU.js.map → chunk-HOR4R722.js.map} +0 -0
  215. /package/dist/{chunk-XSIFXX54.js.map → chunk-JD3OZAI4.js.map} +0 -0
  216. /package/dist/{chunk-RRDWXNBQ.js.map → chunk-KI6HAJWL.js.map} +0 -0
  217. /package/dist/{chunk-LSEW3ZZ2.js.map → chunk-L2FE64BU.js.map} +0 -0
  218. /package/dist/{chunk-HBAJDI2N.js.map → chunk-LX3CB26H.js.map} +0 -0
  219. /package/dist/{chunk-LOA2VCMS.js.map → chunk-NSCVNK5K.js.map} +0 -0
  220. /package/dist/{chunk-4BHFNKTP.js.map → chunk-OHVFWCJP.js.map} +0 -0
  221. /package/dist/{chunk-7JJE3OMJ.js.map → chunk-PE4AQGFH.js.map} +0 -0
  222. /package/dist/{chunk-RHQYVHFH.js.map → chunk-TS26M2SB.js.map} +0 -0
  223. /package/dist/{chunk-EKNUBIIQ.js.map → chunk-UWNYBOOO.js.map} +0 -0
  224. /package/dist/{chunk-WNRGOVLG.js.map → chunk-VU7SWWT5.js.map} +0 -0
  225. /package/dist/{chunk-WUG3E423.js.map → chunk-WBAYSNUQ.js.map} +0 -0
  226. /package/dist/{chunk-XHM2SARW.js.map → chunk-WGHU7BLI.js.map} +0 -0
  227. /package/dist/{chunk-5ARRXIVR.js.map → chunk-X73VS74Y.js.map} +0 -0
  228. /package/dist/{chunk-M45IRXDM.js.map → chunk-YHPM5D7Y.js.map} +0 -0
  229. /package/dist/{chunk-P4EDT5ZP.js.map → chunk-YNTBADIY.js.map} +0 -0
  230. /package/dist/{chunk-IUBHXEPJ.js.map → chunk-YULZKK4F.js.map} +0 -0
  231. /package/dist/{chunk-IEPT7HVP.js.map → chunk-Z4DO7YSI.js.map} +0 -0
  232. /package/dist/{chunk-HLGDYFWR.js.map → chunk-ZNQYHJXX.js.map} +0 -0
  233. /package/dist/{chunk-CHBXWJZQ.js.map → chunk-ZWTNWAO4.js.map} +0 -0
  234. /package/dist/{crypto-AJB72OKN.js.map → crypto-QXQOHMHF.js.map} +0 -0
  235. /package/dist/{delegation-6FCWDRUS.js.map → delegation-NIQ43IPU.js.map} +0 -0
  236. /package/dist/{executor-7KSCEIFA.js.map → executor-6ZDSDZ6V.js.map} +0 -0
  237. /package/dist/{executor-D2QMNGRJ.js.map → executor-723ZP6TH.js.map} +0 -0
  238. /package/dist/{executor-O5AZK7UW.js.map → executor-IDZDAFNH.js.map} +0 -0
  239. /package/dist/{fanout-sidecar-ZSKEQ6NI.js.map → fanout-sidecar-N6OJX6QR.js.map} +0 -0
  240. /package/dist/{issue-YIYG4OW5.js.map → issue-ADVS4OVP.js.map} +0 -0
  241. /package/dist/{ledger-5JMVF7PY.js.map → ledger-CWSE3BLF.js.map} +0 -0
  242. /package/dist/{noydb-D5SLAJ6V.js.map → noydb-VZ4JVW55.js.map} +0 -0
  243. /package/dist/{public-envelope-PFLZI5MO.js.map → public-envelope-SYHEYQ3X.js.map} +0 -0
  244. /package/dist/{registry-BVQ5ITMF.js.map → registry-DK5YWAAA.js.map} +0 -0
  245. /package/dist/{registry-JLP3QOLD.js.map → registry-IUZQVVBB.js.map} +0 -0
  246. /package/dist/{registry-NCY445U5.js.map → registry-XGLNADIE.js.map} +0 -0
  247. /package/dist/{revoke-7RLGQWZ7.js.map → revoke-ZDFKMR5E.js.map} +0 -0
  248. /package/dist/{signer-6JF44I4A.js.map → signer-P5D7Y72U.js.map} +0 -0
  249. /package/dist/{stale-UBLP3RJ3.js.map → stale-7FRJVHN6.js.map} +0 -0
@@ -1,40 +1,43 @@
1
+ import {
2
+ STATE_VAULT_NAME
3
+ } from "./chunk-ZC7J6ZYV.js";
1
4
  import {
2
5
  resolveSchema
3
6
  } from "./chunk-EMIGCR7X.js";
4
7
  import {
5
8
  TxContext,
6
9
  revertExecuted
7
- } from "./chunk-M45IRXDM.js";
10
+ } from "./chunk-YHPM5D7Y.js";
8
11
  import {
9
12
  OverlayedCollection
10
- } from "./chunk-4BHFNKTP.js";
13
+ } from "./chunk-OHVFWCJP.js";
11
14
  import {
12
15
  LazyQuery,
13
16
  decodeIdxId,
14
17
  encodeIdxId
15
- } from "./chunk-P4EDT5ZP.js";
18
+ } from "./chunk-YNTBADIY.js";
16
19
  import {
17
20
  SCHEMAS_COLLECTION,
18
21
  loadPersistedSchema,
19
22
  resolveManagedSecret,
20
23
  savePersistedSchema,
21
24
  saveSealedPassphrase
22
- } from "./chunk-XHM2SARW.js";
25
+ } from "./chunk-WGHU7BLI.js";
23
26
  import {
24
27
  loadPublicEnvelope,
25
28
  readPublicEnvelope,
26
29
  savePublicEnvelope,
27
30
  validatePublicEnvelopeInput
28
- } from "./chunk-UA6G45ME.js";
31
+ } from "./chunk-DKO2QFSA.js";
29
32
  import {
30
33
  PERIODS_COLLECTION
31
- } from "./chunk-RRDWXNBQ.js";
34
+ } from "./chunk-KI6HAJWL.js";
32
35
  import {
33
36
  getAtPath,
34
37
  isDictCollectionName,
35
38
  resolvePolicy,
36
39
  setAtPathInPlace
37
- } from "./chunk-O53RIZCC.js";
40
+ } from "./chunk-7HT2MEZ5.js";
38
41
  import {
39
42
  ManagedRecoveryNotEnrolledError,
40
43
  PolicyDeniedError,
@@ -56,11 +59,11 @@ import {
56
59
  saveShamirRecoveryEntries,
57
60
  updateAuthenticator,
58
61
  writeMagicLinkGrant
59
- } from "./chunk-DLTU4M2I.js";
62
+ } from "./chunk-COFPAMX6.js";
60
63
  import {
61
64
  assertTierAccess,
62
65
  dekKey
63
- } from "./chunk-ZC7MNVYN.js";
66
+ } from "./chunk-4TBBMHVC.js";
64
67
  import {
65
68
  USER_ENVELOPE_COLLECTION,
66
69
  assertKeyringOpenAllowed,
@@ -85,7 +88,7 @@ import {
85
88
  rotateKeys,
86
89
  saveUserEnvelope,
87
90
  updateKeyringIdentity
88
- } from "./chunk-GFPR7VJS.js";
91
+ } from "./chunk-A5ZOOZFB.js";
89
92
  import {
90
93
  INDEXED_STORE_POLICY
91
94
  } from "./chunk-2QR2PQTT.js";
@@ -95,21 +98,20 @@ import {
95
98
  import {
96
99
  LEDGER_COLLECTION,
97
100
  LEDGER_DELTAS_COLLECTION
98
- } from "./chunk-SJJQKNMP.js";
101
+ } from "./chunk-56DJ7JVK.js";
99
102
  import {
100
103
  sha256Hex as sha256Hex2
101
104
  } from "./chunk-Z6FNBOTC.js";
102
105
  import {
103
106
  NO_AGGREGATE,
104
107
  Query,
105
- ScanBuilder
106
- } from "./chunk-UOC7JMZO.js";
108
+ ScanBuilder,
109
+ decodeMoneyFields,
110
+ quantizeMoneyFields
111
+ } from "./chunk-KGCORI4L.js";
107
112
  import {
108
- MoneyPrecisionError,
109
- canonicalGroupKey,
110
- formatScaledInt,
111
- parseToScaledInt
112
- } from "./chunk-OPDTLHFA.js";
113
+ canonicalGroupKey
114
+ } from "./chunk-3EWA37FV.js";
113
115
  import {
114
116
  readPath
115
117
  } from "./chunk-TV3YZ35S.js";
@@ -117,17 +119,17 @@ import {
117
119
  EXPORT_AUDIT_COLLECTION,
118
120
  createExportBlobsHandle,
119
121
  runCompaction
120
- } from "./chunk-6AD5TBF2.js";
122
+ } from "./chunk-6AJBSQU4.js";
121
123
  import {
122
124
  NOYDB_BACKUP_VERSION,
123
125
  NOYDB_FORMAT_VERSION
124
- } from "./chunk-LYNNZEQD.js";
126
+ } from "./chunk-GC4V7RU7.js";
125
127
  import {
126
128
  decrypt,
127
129
  encrypt,
128
130
  encryptDeterministic,
129
131
  sha256Hex
130
- } from "./chunk-IUBHXEPJ.js";
132
+ } from "./chunk-YULZKK4F.js";
131
133
  import {
132
134
  AlreadyElevatedError,
133
135
  AttestationError,
@@ -144,10 +146,12 @@ import {
144
146
  MigrationRequiredError,
145
147
  NoAccessError,
146
148
  NoydbError,
149
+ NumberingUncertaintyError,
147
150
  PermissionDeniedError,
148
151
  QuiesceTimeoutError,
149
152
  ReadOnlyError,
150
153
  ReservedCollectionNameError,
154
+ ReservedVaultNameError,
151
155
  SchemaFenceError,
152
156
  SchemaValidationError,
153
157
  SequenceContentionError,
@@ -160,7 +164,7 @@ import {
160
164
  UnsupportedIndexOptionError,
161
165
  ValidationError,
162
166
  VaultTemplateNotFoundError
163
- } from "./chunk-AGRC7NQQ.js";
167
+ } from "./chunk-535SSHBS.js";
164
168
 
165
169
  // src/policy/storage.ts
166
170
  var META_COLLECTION = "_meta";
@@ -335,88 +339,6 @@ var NO_CRDT = {
335
339
  }
336
340
  };
337
341
 
338
- // src/money/normalize.ts
339
- function isMoneyValueObject(v) {
340
- return typeof v === "object" && v !== null && "currency" in v;
341
- }
342
- function quantizeAmount(field, input, scale, rounding) {
343
- const r = parseToScaledInt(input, scale, rounding);
344
- if (!r.ok) {
345
- if (r.reason === "precision") throw new MoneyPrecisionError(field, input, scale);
346
- throw new TypeError(`money: field "${field}" value ${JSON.stringify(input)} is not a finite decimal`);
347
- }
348
- return r.value.toString();
349
- }
350
- function quantizeMoneyFields(record, moneyFields) {
351
- const out = { ...record };
352
- for (const [field, desc] of Object.entries(moneyFields)) {
353
- const raw = out[field];
354
- if (raw === null || raw === void 0) continue;
355
- if (desc.mode === "fixed") {
356
- const currency2 = desc.fixedCurrency;
357
- out[field] = quantizeAmount(field, raw, desc.scaleFor(currency2), desc.rounding);
358
- continue;
359
- }
360
- let amount;
361
- let currency;
362
- if (isMoneyValueObject(raw)) {
363
- currency = String(raw.currency);
364
- amount = raw.amount;
365
- } else {
366
- const sole = desc.soleCurrency();
367
- if (sole === void 0) {
368
- throw new TypeError(
369
- `money: field "${field}" is multi-currency \u2014 write { amount, currency }, not a bare amount`
370
- );
371
- }
372
- currency = sole;
373
- amount = raw;
374
- }
375
- const scale = desc.scaleFor(currency);
376
- out[field] = { amount: quantizeAmount(field, amount, scale, desc.rounding), currency };
377
- }
378
- return out;
379
- }
380
- function formatCurrency(decimal, currency, scale, locale) {
381
- const fmt = new Intl.NumberFormat(locale, {
382
- style: "currency",
383
- currency,
384
- minimumFractionDigits: scale,
385
- maximumFractionDigits: scale
386
- });
387
- return fmt.format(decimal);
388
- }
389
- function decodeMoneyFields(record, moneyFields, locale) {
390
- const out = { ...record };
391
- const format = locale !== "raw";
392
- const fmtLocale = typeof locale === "string" && locale !== "raw" ? locale : "en-US";
393
- for (const [field, desc] of Object.entries(moneyFields)) {
394
- const stored = out[field];
395
- if (stored === null || stored === void 0) continue;
396
- let currency;
397
- let scaledIntString;
398
- if (desc.mode === "fixed") {
399
- if (typeof stored !== "string" && typeof stored !== "number") continue;
400
- currency = desc.fixedCurrency;
401
- scaledIntString = String(stored);
402
- } else {
403
- if (!isMoneyValueObject(stored)) continue;
404
- const amount = stored.amount;
405
- if (typeof stored.currency !== "string" || typeof amount !== "string" && typeof amount !== "number") continue;
406
- currency = stored.currency;
407
- scaledIntString = String(amount);
408
- }
409
- const scale = desc.scaleFor(currency);
410
- const decimal = formatScaledInt(BigInt(scaledIntString), scale);
411
- out[field] = desc.mode === "fixed" ? decimal : { amount: decimal, currency };
412
- if (format) {
413
- out[`${field}Formatted`] = formatCurrency(decimal, currency, scale, fmtLocale);
414
- out[`${field}Number`] = Number(decimal);
415
- }
416
- }
417
- return out;
418
- }
419
-
420
342
  // src/computed/index.ts
421
343
  var ComputedFieldError = class extends NoydbError {
422
344
  constructor(field, id, cause) {
@@ -885,7 +807,7 @@ async function resolveStaleOnRead(accessor, outputCollection, id) {
885
807
  }
886
808
  const sourceWithId = { ...source, id };
887
809
  if (DerivationExecutor === null) {
888
- ({ DerivationExecutor } = await import("./executor-D2QMNGRJ.js"));
810
+ ({ DerivationExecutor } = await import("./executor-6ZDSDZ6V.js"));
889
811
  }
890
812
  const ctx = { vault: accessor.getReadOnlyFacade() };
891
813
  const result = await DerivationExecutor.run(spec, sourceWithId, 0, strategyHash, ctx);
@@ -1391,7 +1313,7 @@ var Collection = class {
1391
1313
  }
1392
1314
  }
1393
1315
  if (this.materializedViewSource !== void 0) {
1394
- const { resolveStaleMVOnRead } = await import("./stale-UBLP3RJ3.js");
1316
+ const { resolveStaleMVOnRead } = await import("./stale-7FRJVHN6.js");
1395
1317
  await resolveStaleMVOnRead(this.materializedViewSource, this.name);
1396
1318
  }
1397
1319
  let record;
@@ -1788,7 +1710,7 @@ var Collection = class {
1788
1710
  if (mode === "eager") {
1789
1711
  if (executor === null) {
1790
1712
  ;
1791
- ({ MaterializedViewExecutor: executor } = await import("./executor-O5AZK7UW.js"));
1713
+ ({ MaterializedViewExecutor: executor } = await import("./executor-723ZP6TH.js"));
1792
1714
  }
1793
1715
  await executor.refresh(reg, {
1794
1716
  getCollection: (name) => this.materializedViewSource.getCollection(name),
@@ -1797,7 +1719,7 @@ var Collection = class {
1797
1719
  });
1798
1720
  } else if (mode === "lazy") {
1799
1721
  if (staleHelpers === null) {
1800
- staleHelpers = await import("./stale-UBLP3RJ3.js");
1722
+ staleHelpers = await import("./stale-7FRJVHN6.js");
1801
1723
  }
1802
1724
  staleHelpers.markMVStale(registry, reg.spec.name);
1803
1725
  }
@@ -1826,7 +1748,7 @@ var Collection = class {
1826
1748
  const mode = typeof spec.lifecycle === "string" ? spec.lifecycle : spec.lifecycle.mode;
1827
1749
  if (mode === "eager") {
1828
1750
  if (DerivationExecutor === null) {
1829
- ({ DerivationExecutor } = await import("./executor-D2QMNGRJ.js"));
1751
+ ({ DerivationExecutor } = await import("./executor-6ZDSDZ6V.js"));
1830
1752
  }
1831
1753
  const sourceWithId = { ...incoming, id };
1832
1754
  const ctx = { vault: this.derivationSource.getReadOnlyFacade() };
@@ -1845,7 +1767,7 @@ var Collection = class {
1845
1767
  const outputCollection = this.derivationSource.getCollection(outSpec.collection);
1846
1768
  const txCtx = this.derivationSource.getActiveTxContext();
1847
1769
  if (out.kind === "array") {
1848
- const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-ZSKEQ6NI.js");
1770
+ const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-N6OJX6QR.js");
1849
1771
  const prior = await loadFanoutSidecar(
1850
1772
  this.adapter,
1851
1773
  this.vault,
@@ -2138,7 +2060,7 @@ var Collection = class {
2138
2060
  for (const [outputKey, outSpec] of Object.entries(spec.outputs)) {
2139
2061
  if (outSpec.shape !== "array") continue;
2140
2062
  if (helpers === null) {
2141
- helpers = await import("./fanout-sidecar-ZSKEQ6NI.js");
2063
+ helpers = await import("./fanout-sidecar-N6OJX6QR.js");
2142
2064
  }
2143
2065
  const sidecar = await helpers.loadFanoutSidecar(
2144
2066
  this.adapter,
@@ -2178,7 +2100,7 @@ var Collection = class {
2178
2100
  if (mode === "eager") {
2179
2101
  if (executor === null) {
2180
2102
  ;
2181
- ({ MaterializedViewExecutor: executor } = await import("./executor-O5AZK7UW.js"));
2103
+ ({ MaterializedViewExecutor: executor } = await import("./executor-723ZP6TH.js"));
2182
2104
  }
2183
2105
  await executor.refresh(reg, {
2184
2106
  getCollection: (name) => this.materializedViewSource.getCollection(name),
@@ -2187,7 +2109,7 @@ var Collection = class {
2187
2109
  });
2188
2110
  } else if (mode === "lazy") {
2189
2111
  if (staleHelpers === null) {
2190
- staleHelpers = await import("./stale-UBLP3RJ3.js");
2112
+ staleHelpers = await import("./stale-7FRJVHN6.js");
2191
2113
  }
2192
2114
  staleHelpers.markMVStale(registry, reg.spec.name);
2193
2115
  }
@@ -2210,14 +2132,22 @@ var Collection = class {
2210
2132
  );
2211
2133
  }
2212
2134
  if (this.materializedViewSource !== void 0) {
2213
- const { resolveStaleMVOnRead } = await import("./stale-UBLP3RJ3.js");
2135
+ const { resolveStaleMVOnRead } = await import("./stale-7FRJVHN6.js");
2214
2136
  await resolveStaleMVOnRead(this.materializedViewSource, this.name);
2215
2137
  }
2216
2138
  await this.ensureHydrated();
2217
2139
  const records = [...this.cache.values()].map((e) => e.record);
2218
- if (!locale) return records;
2140
+ if (!this.hasReadTransforms()) return records;
2219
2141
  return Promise.all(records.map((r) => this.applyLocaleToRecord(r, locale)));
2220
2142
  }
2143
+ /**
2144
+ * @internal — whether any read-side record transform is registered
2145
+ * (money decode, i18nText resolution, dictKey labels). Gates the
2146
+ * no-transform fast path in {@link list}.
2147
+ */
2148
+ hasReadTransforms() {
2149
+ return this.moneyFields !== void 0 && Object.keys(this.moneyFields).length > 0 || this.i18nFields !== void 0 && Object.keys(this.i18nFields).length > 0 || this.dictKeyFields !== void 0 && Object.keys(this.dictKeyFields).length > 0;
2150
+ }
2221
2151
  // ─── Bulk operations ─────────────────────────────────────
2222
2152
  /**
2223
2153
  * Put many records in one call. Each item is processed sequentially
@@ -2723,7 +2653,8 @@ var Collection = class {
2723
2653
  pageSize,
2724
2654
  [],
2725
2655
  [],
2726
- joinContext
2656
+ joinContext,
2657
+ this.moneyFields
2727
2658
  );
2728
2659
  }
2729
2660
  /** Decrypt a page of envelopes returned by `adapter.listPage`. */
@@ -3931,6 +3862,159 @@ var SequenceStore = class {
3931
3862
  }
3932
3863
  };
3933
3864
 
3865
+ // src/numbering/index.ts
3866
+ var NUMBERING_HEAD_COLLECTION = "_numbering_head";
3867
+ var NUMBERING_PENDING_COLLECTION = "_numbering_pending";
3868
+ var DeferredNumberingStore = class {
3869
+ adapter;
3870
+ vault;
3871
+ encrypted;
3872
+ getDEK;
3873
+ actor;
3874
+ configs;
3875
+ /**
3876
+ * Stamp a serial onto a USER record THROUGH the Collection layer (so the
3877
+ * cache, indexes, and MVs stay coherent — the engine must NOT write user
3878
+ * collections at the raw adapter level). Returns false if the record is
3879
+ * gone (the engine then skips it without burning a serial). Provided by the
3880
+ * vault; unit tests pass a Map-backed double.
3881
+ */
3882
+ stamp;
3883
+ /** In-process registry: `${series}::${recordId}` → resolver for the live next() Promise. */
3884
+ waiters = /* @__PURE__ */ new Map();
3885
+ dekCache = /* @__PURE__ */ new Map();
3886
+ constructor(opts) {
3887
+ this.adapter = opts.adapter;
3888
+ this.vault = opts.vault;
3889
+ this.encrypted = opts.encrypted;
3890
+ this.getDEK = opts.getDEK;
3891
+ this.actor = opts.actor;
3892
+ this.configs = opts.configs;
3893
+ this.stamp = opts.stamp;
3894
+ }
3895
+ has(series) {
3896
+ return this.configs.has(series);
3897
+ }
3898
+ dek(collection) {
3899
+ let p = this.dekCache.get(collection);
3900
+ if (!p) {
3901
+ p = this.getDEK(collection);
3902
+ this.dekCache.set(collection, p);
3903
+ }
3904
+ return p;
3905
+ }
3906
+ async readJson(collection, id) {
3907
+ const env = await this.adapter.get(this.vault, collection, id);
3908
+ if (!env) return { env: null, value: null };
3909
+ const json = this.encrypted ? await decrypt(env._iv, env._data, await this.dek(collection)) : env._data;
3910
+ return { env, value: JSON.parse(json) };
3911
+ }
3912
+ async writeJson(collection, id, value, expectedVersion) {
3913
+ const json = JSON.stringify(value);
3914
+ let env;
3915
+ if (!this.encrypted) {
3916
+ env = { _noydb: NOYDB_FORMAT_VERSION, _v: expectedVersion + 1, _ts: (/* @__PURE__ */ new Date()).toISOString(), _iv: "", _data: json, _by: this.actor };
3917
+ } else {
3918
+ const { iv, data } = await encrypt(json, await this.dek(collection));
3919
+ env = { _noydb: NOYDB_FORMAT_VERSION, _v: expectedVersion + 1, _ts: (/* @__PURE__ */ new Date()).toISOString(), _iv: iv, _data: data, _by: this.actor };
3920
+ }
3921
+ await this.adapter.put(this.vault, collection, id, env, expectedVersion);
3922
+ }
3923
+ pendingId(series, recordId) {
3924
+ return `${series}::${recordId}`;
3925
+ }
3926
+ /** Current last-assigned serial for a series (0 if none). */
3927
+ async peek(series) {
3928
+ const { value } = await this.readJson(NUMBERING_HEAD_COLLECTION, series);
3929
+ return value?.lastSerial ?? 0;
3930
+ }
3931
+ /**
3932
+ * Enqueue a record for numbering: stamp it with the current store clock and
3933
+ * durably write a pending entry. The returned Promise resolves once the
3934
+ * record is durably enqueued; its `assigned` field resolves with the serial
3935
+ * at the next pass (the record's `field` is the durable source of truth —
3936
+ * `assigned` is an in-process convenience that a crash may drop).
3937
+ */
3938
+ async enqueue(series, recordId) {
3939
+ const cfg = this.configs.get(series);
3940
+ if (!cfg) throw new NumberingUncertaintyError(series);
3941
+ if (typeof this.adapter.getStoreTime !== "function") throw new NumberingUncertaintyError(series);
3942
+ const st = await this.adapter.getStoreTime();
3943
+ const id = this.pendingId(series, recordId);
3944
+ const { env } = await this.readJson(NUMBERING_PENDING_COLLECTION, id);
3945
+ const entry = {
3946
+ series,
3947
+ recordId,
3948
+ collection: cfg.collection,
3949
+ field: cfg.field,
3950
+ storeEarliest: st.earliest,
3951
+ storeLatest: st.latest,
3952
+ enqueuedAt: Date.now()
3953
+ };
3954
+ await this.writeJson(NUMBERING_PENDING_COLLECTION, id, entry, env?._v ?? 0);
3955
+ const assigned = new Promise((resolve, reject) => {
3956
+ this.waiters.set(id, { resolve, reject });
3957
+ });
3958
+ return { assigned };
3959
+ }
3960
+ async listPending(series) {
3961
+ const ids = await this.adapter.list(this.vault, NUMBERING_PENDING_COLLECTION);
3962
+ const prefix = `${series}::`;
3963
+ const out = [];
3964
+ for (const id of ids) {
3965
+ if (!id.startsWith(prefix)) continue;
3966
+ const { value } = await this.readJson(NUMBERING_PENDING_COLLECTION, id);
3967
+ if (value) out.push({ id, entry: value });
3968
+ }
3969
+ return out;
3970
+ }
3971
+ /**
3972
+ * Run a numbering pass for `series`: select entries provably settled
3973
+ * (`storeLatest ≤ now.earliest` — commit-wait), order by
3974
+ * `(storeEarliest, recordId)`, assign serials after the head, stamp each
3975
+ * record's field, advance the head with one CAS, and consume the entries.
3976
+ * Idempotent/convergent: a losing concurrent pass returns `[]` and the next
3977
+ * pass reconciles. Resolves any in-process enqueue() `assigned` Promises.
3978
+ */
3979
+ async runPass(series) {
3980
+ const cfg = this.configs.get(series);
3981
+ if (!cfg) throw new NumberingUncertaintyError(series);
3982
+ if (typeof this.adapter.getStoreTime !== "function") throw new NumberingUncertaintyError(series);
3983
+ const now = await this.adapter.getStoreTime();
3984
+ const settled = (await this.listPending(series)).filter((p) => p.entry.storeLatest <= now.earliest).sort(
3985
+ (a, b) => a.entry.storeEarliest - b.entry.storeEarliest || (a.entry.recordId < b.entry.recordId ? -1 : a.entry.recordId > b.entry.recordId ? 1 : 0)
3986
+ );
3987
+ if (settled.length === 0) return [];
3988
+ const { env: headEnv, value: head } = await this.readJson(NUMBERING_HEAD_COLLECTION, series);
3989
+ let serial = head?.lastSerial ?? 0;
3990
+ const assignments = [];
3991
+ for (const { entry } of settled) {
3992
+ serial += 1;
3993
+ const ok = await this.stamp(entry.collection, entry.recordId, entry.field, serial);
3994
+ if (!ok) {
3995
+ serial -= 1;
3996
+ continue;
3997
+ }
3998
+ assignments.push({ recordId: entry.recordId, serial });
3999
+ }
4000
+ try {
4001
+ await this.writeJson(NUMBERING_HEAD_COLLECTION, series, { series, lastSerial: serial, watermark: now.earliest }, headEnv?._v ?? 0);
4002
+ } catch (err) {
4003
+ if (err instanceof ConflictError) return [];
4004
+ throw err;
4005
+ }
4006
+ for (const { id, entry } of settled) {
4007
+ await this.adapter.delete(this.vault, NUMBERING_PENDING_COLLECTION, id);
4008
+ const a = assignments.find((x) => x.recordId === entry.recordId);
4009
+ if (a) {
4010
+ this.waiters.get(id)?.resolve(a.serial);
4011
+ this.waiters.delete(id);
4012
+ }
4013
+ }
4014
+ return assignments;
4015
+ }
4016
+ };
4017
+
3934
4018
  // src/shadow/strategy.ts
3935
4019
  var NOT_ENABLED2 = new Error(
3936
4020
  'VaultFrame requires the shadow strategy. Import `{ withShadow }` from "@noy-db/hub/shadow" and pass it to `createNoydb({ shadowStrategy: withShadow() })`.'
@@ -5150,6 +5234,10 @@ var Vault = class {
5150
5234
  ledgerStore = null;
5151
5235
  /** Lazily-built atomic-sequence store. See {@link sequence}. */
5152
5236
  sequenceStore = null;
5237
+ /** Lazily-built deferred-numbering engine. See {@link runNumberingPass}. */
5238
+ deferredNumbering = null;
5239
+ /** Registered deferred-numbering series, keyed by series name. */
5240
+ numberingConfigs;
5153
5241
  /**
5154
5242
  * Background writes for persisted-schema envelopes (#schema-dump v0
5155
5243
  * slice 1). One promise per `collection({ persistJsonSchema: true })`
@@ -5236,6 +5324,7 @@ var Vault = class {
5236
5324
  constructor(opts) {
5237
5325
  this.adapter = opts.adapter;
5238
5326
  this.name = opts.name;
5327
+ this.numberingConfigs = new Map((opts.numberingConfigs ?? []).map((c) => [c.series, c]));
5239
5328
  this.noydb = opts.noydb;
5240
5329
  this.keyring = opts.keyring;
5241
5330
  this.encrypted = opts.encrypted;
@@ -5910,6 +5999,18 @@ var Vault = class {
5910
5999
  * ```
5911
6000
  */
5912
6001
  sequence(name) {
6002
+ if (this.numberingConfigs.has(name)) {
6003
+ const eng = this.deferred();
6004
+ return {
6005
+ next: async (opts) => {
6006
+ if (!opts?.for) {
6007
+ throw new ValidationError(`sequence("${name}") is a deferred-numbering series; call next({ for: recordId }).`);
6008
+ }
6009
+ return (await eng.enqueue(name, opts.for)).assigned;
6010
+ },
6011
+ peek: () => eng.peek(name)
6012
+ };
6013
+ }
5913
6014
  if (!this.sequenceStore) {
5914
6015
  this.sequenceStore = new SequenceStore({
5915
6016
  adapter: this.adapter,
@@ -5921,6 +6022,38 @@ var Vault = class {
5921
6022
  }
5922
6023
  return this.sequenceStore.handle(name);
5923
6024
  }
6025
+ /** @internal — lazily build the deferred-numbering engine with a cache-coherent stamp. */
6026
+ deferred() {
6027
+ if (!this.deferredNumbering) {
6028
+ this.deferredNumbering = new DeferredNumberingStore({
6029
+ adapter: this.adapter,
6030
+ vault: this.name,
6031
+ encrypted: this.encrypted,
6032
+ getDEK: this.getDEK,
6033
+ actor: this.keyring.userId,
6034
+ configs: this.numberingConfigs,
6035
+ // Stamp THROUGH the Collection layer so cache/indexes/MVs stay coherent —
6036
+ // `this.collection(name)` returns the shared cached instance, so a
6037
+ // subsequent user `collection.get(id)` sees the assigned serial.
6038
+ stamp: async (collection, recordId, field, serial) => {
6039
+ const coll = this.collection(collection);
6040
+ const rec = await coll.get(recordId);
6041
+ if (!rec) return false;
6042
+ await coll.put(recordId, { ...rec, [field]: serial });
6043
+ return true;
6044
+ }
6045
+ });
6046
+ }
6047
+ return this.deferredNumbering;
6048
+ }
6049
+ /**
6050
+ * Run a deferred-numbering pass for `series`: assign gap-free serials to all
6051
+ * records whose store-commit-time interval has settled, in store-time order.
6052
+ * Returns the assignments made. See {@link sequence} / `withDeferredNumbering`.
6053
+ */
6054
+ async runNumberingPass(series) {
6055
+ return this.deferred().runPass(series);
6056
+ }
5924
6057
  async compact(options = {}) {
5925
6058
  return runCompaction({
5926
6059
  adapter: this.adapter,
@@ -6002,12 +6135,12 @@ var Vault = class {
6002
6135
  if (!fieldSchema) {
6003
6136
  throw new AttestationError(`issueAttestation: collection '${collectionName}' has no attestation field-schema. Declare it via vault.collection('${collectionName}', { attestation: { fields: [...] } }).`);
6004
6137
  }
6005
- const { issueAttestationCore } = await import("./issue-YIYG4OW5.js");
6138
+ const { issueAttestationCore } = await import("./issue-ADVS4OVP.js");
6006
6139
  const out = await issueAttestationCore(this.makeIssueContext(), { collection: collectionName, id, fieldSchema });
6007
6140
  return { docId: out.docId, qr: out.qr, keyId: out.keyId, publicKeyB64: out.publicKeyB64 };
6008
6141
  }
6009
6142
  async getDocumentSigningPublicKey() {
6010
- const { loadSigner, loadOrCreateSigner } = await import("./signer-6JF44I4A.js");
6143
+ const { loadSigner, loadOrCreateSigner } = await import("./signer-P5D7Y72U.js");
6011
6144
  const existing = await loadSigner(this.adapter, this.name, this.getDEK);
6012
6145
  if (existing) return { keyId: existing.keyId, publicKeyB64: existing.publicKeyB64 };
6013
6146
  if (this.keyring.role !== "owner") {
@@ -6033,19 +6166,19 @@ var Vault = class {
6033
6166
  };
6034
6167
  }
6035
6168
  async revokeAttestation(docId) {
6036
- const { revokeDocCore } = await import("./revoke-7RLGQWZ7.js");
6169
+ const { revokeDocCore } = await import("./revoke-ZDFKMR5E.js");
6037
6170
  await revokeDocCore(this.makeRevokeContext(), docId);
6038
6171
  }
6039
6172
  async unrevokeAttestation(docId) {
6040
- const { unrevokeDocCore } = await import("./revoke-7RLGQWZ7.js");
6173
+ const { unrevokeDocCore } = await import("./revoke-ZDFKMR5E.js");
6041
6174
  await unrevokeDocCore(this.makeRevokeContext(), docId);
6042
6175
  }
6043
6176
  async getRevokedDocIds() {
6044
- const { getRevokedDocIdsCore } = await import("./revoke-7RLGQWZ7.js");
6177
+ const { getRevokedDocIdsCore } = await import("./revoke-ZDFKMR5E.js");
6045
6178
  return getRevokedDocIdsCore(this.makeRevokeContext());
6046
6179
  }
6047
6180
  async publishRevocationList() {
6048
- const { publishRevocationListCore } = await import("./revoke-7RLGQWZ7.js");
6181
+ const { publishRevocationListCore } = await import("./revoke-ZDFKMR5E.js");
6049
6182
  return publishRevocationListCore(this.makeRevokeContext());
6050
6183
  }
6051
6184
  makeRevokeContext() {
@@ -6362,7 +6495,7 @@ var Vault = class {
6362
6495
  async _initDerivations(handles) {
6363
6496
  if (handles.length === 0) return;
6364
6497
  const [{ DerivationRegistry }, { ReadOnlyVaultFacade }] = await Promise.all([
6365
- import("./registry-JLP3QOLD.js"),
6498
+ import("./registry-XGLNADIE.js"),
6366
6499
  import("./read-only-facade-ITU6L7BL.js")
6367
6500
  ]);
6368
6501
  const registry = new DerivationRegistry();
@@ -6393,7 +6526,7 @@ var Vault = class {
6393
6526
  */
6394
6527
  async _initMaterializedViews(handles) {
6395
6528
  if (handles.length === 0) return;
6396
- const { MaterializedViewRegistry } = await import("./registry-NCY445U5.js");
6529
+ const { MaterializedViewRegistry } = await import("./registry-DK5YWAAA.js");
6397
6530
  const registry = new MaterializedViewRegistry();
6398
6531
  this.materializedViewRegistry = registry;
6399
6532
  const db = this;
@@ -6417,7 +6550,7 @@ var Vault = class {
6417
6550
  */
6418
6551
  async _initOverlayedViews(handles) {
6419
6552
  if (handles.length === 0) return;
6420
- const { OverlayedViewRegistry } = await import("./registry-BVQ5ITMF.js");
6553
+ const { OverlayedViewRegistry } = await import("./registry-IUZQVVBB.js");
6421
6554
  const registry = new OverlayedViewRegistry();
6422
6555
  const mvRegistry = this.materializedViewRegistry;
6423
6556
  const overlayNames = /* @__PURE__ */ new Set();
@@ -6464,13 +6597,13 @@ var Vault = class {
6464
6597
  if (!reg) {
6465
6598
  throw new Error(`refreshView: no MV registered with name "${name}"`);
6466
6599
  }
6467
- const { MaterializedViewExecutor } = await import("./executor-O5AZK7UW.js");
6600
+ const { MaterializedViewExecutor } = await import("./executor-723ZP6TH.js");
6468
6601
  const result = await MaterializedViewExecutor.refresh(reg, {
6469
6602
  getCollection: (n) => this.collection(n),
6470
6603
  getActiveTxContext: () => this.noydb._activeTxContextOrNull,
6471
6604
  getQueryContext: () => this
6472
6605
  });
6473
- const { clearMVStale } = await import("./stale-UBLP3RJ3.js");
6606
+ const { clearMVStale } = await import("./stale-7FRJVHN6.js");
6474
6607
  clearMVStale(registry, name);
6475
6608
  return result;
6476
6609
  }
@@ -6486,7 +6619,7 @@ var Vault = class {
6486
6619
  if (registry === null) return { derived: 0, failed: 0 };
6487
6620
  const strategies = registry.strategiesForSource(sourceCollection);
6488
6621
  if (strategies.length === 0) return { derived: 0, failed: 0 };
6489
- const { DerivationExecutor } = await import("./executor-D2QMNGRJ.js");
6622
+ const { DerivationExecutor } = await import("./executor-6ZDSDZ6V.js");
6490
6623
  const sourceColl = this.collection(sourceCollection);
6491
6624
  const records = await sourceColl.list();
6492
6625
  const ctx = { vault: this.readOnlyFacade ?? new (await import("./read-only-facade-ITU6L7BL.js")).ReadOnlyVaultFacade(this) };
@@ -6511,7 +6644,7 @@ var Vault = class {
6511
6644
  if (!outSpec) continue;
6512
6645
  const outputColl = this.collection(outSpec.collection);
6513
6646
  if (out.kind === "array") {
6514
- const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-ZSKEQ6NI.js");
6647
+ const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-N6OJX6QR.js");
6515
6648
  const prior = await loadFanoutSidecar(this.adapter, this.name, spec.source, id, key);
6516
6649
  const prevKeys = new Set(prior?.keys ?? []);
6517
6650
  const newKeysList = out.entries.map((e) => e.key);
@@ -6732,7 +6865,7 @@ var Vault = class {
6732
6865
  * collection.
6733
6866
  */
6734
6867
  async delegate(opts) {
6735
- const { issueDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-6FCWDRUS.js");
6868
+ const { issueDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-NIQ43IPU.js");
6736
6869
  if (!this.keyring.kek) {
6737
6870
  throw new ValidationError(
6738
6871
  "issueDelegation: keyring.kek is null \u2014 issuing a delegation requires a tier-1 unlock. Re-authenticate at tier 1 (passphrase) first."
@@ -6754,7 +6887,7 @@ var Vault = class {
6754
6887
  * if the id does not exist.
6755
6888
  */
6756
6889
  async revokeDelegation(id) {
6757
- const { revokeDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-6FCWDRUS.js");
6890
+ const { revokeDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-NIQ43IPU.js");
6758
6891
  await revokeDelegation(this.adapter, this.name, id);
6759
6892
  void DELEGATIONS_COLLECTION;
6760
6893
  }
@@ -7223,7 +7356,7 @@ var Vault = class {
7223
7356
  * @see docs/subsystems/public-envelope.md
7224
7357
  */
7225
7358
  async getPublicEnvelope(opts = {}) {
7226
- const { readPublicEnvelope: readPublicEnvelope2 } = await import("./public-envelope-PFLZI5MO.js");
7359
+ const { readPublicEnvelope: readPublicEnvelope2 } = await import("./public-envelope-SYHEYQ3X.js");
7227
7360
  return readPublicEnvelope2(this.adapter, this.name, opts);
7228
7361
  }
7229
7362
  /**
@@ -8833,7 +8966,7 @@ var Noydb = class {
8833
8966
  if (!facade) return;
8834
8967
  const ctx = { existing, vault: facade, userId: e.userId, role: e.role };
8835
8968
  await registry.runChecks(e.collection, incoming, ctx);
8836
- const { GuardExecutor } = await import("./executor-7KSCEIFA.js");
8969
+ const { GuardExecutor } = await import("./executor-IDZDAFNH.js");
8837
8970
  for (const g of guards) {
8838
8971
  await GuardExecutor.checkFrozenFields(g, e.docId, existing, incoming, e.computedFieldNames);
8839
8972
  }
@@ -9025,6 +9158,7 @@ var Noydb = class {
9025
9158
  ...this.options.i18nStrategy !== void 0 ? { i18nStrategy: this.options.i18nStrategy } : {},
9026
9159
  ...this.options.syncStrategy !== void 0 ? { syncStrategy: this.options.syncStrategy } : {},
9027
9160
  ...this.options.guardStrategies !== void 0 ? { guardStrategies: this.options.guardStrategies } : {},
9161
+ ...this.options.numbering !== void 0 ? { numberingConfigs: this.options.numbering } : {},
9028
9162
  locale: opts?.locale,
9029
9163
  // Thread the translator hook so Collection.put() can invoke it
9030
9164
  plaintextTranslator: this.options.plaintextTranslator ? (text, from, to, field, collection) => this.invokeTranslator(text, from, to, field, collection) : void 0,
@@ -9078,7 +9212,8 @@ var Noydb = class {
9078
9212
  ...this.options.historyStrategy !== void 0 ? { historyStrategy: this.options.historyStrategy } : {},
9079
9213
  ...this.options.i18nStrategy !== void 0 ? { i18nStrategy: this.options.i18nStrategy } : {},
9080
9214
  ...this.options.syncStrategy !== void 0 ? { syncStrategy: this.options.syncStrategy } : {},
9081
- ...this.options.guardStrategies !== void 0 ? { guardStrategies: this.options.guardStrategies } : {}
9215
+ ...this.options.guardStrategies !== void 0 ? { guardStrategies: this.options.guardStrategies } : {},
9216
+ ...this.options.numbering !== void 0 ? { numberingConfigs: this.options.numbering } : {}
9082
9217
  });
9083
9218
  this.vaultCache.set(name, comp2);
9084
9219
  return comp2;
@@ -9108,6 +9243,7 @@ var Noydb = class {
9108
9243
  ...this.options.i18nStrategy !== void 0 ? { i18nStrategy: this.options.i18nStrategy } : {},
9109
9244
  ...this.options.syncStrategy !== void 0 ? { syncStrategy: this.options.syncStrategy } : {},
9110
9245
  ...this.options.guardStrategies !== void 0 ? { guardStrategies: this.options.guardStrategies } : {},
9246
+ ...this.options.numbering !== void 0 ? { numberingConfigs: this.options.numbering } : {},
9111
9247
  emitter: this.emitter
9112
9248
  });
9113
9249
  this.vaultCache.set(name, comp);
@@ -9426,10 +9562,39 @@ var Noydb = class {
9426
9562
  */
9427
9563
  async openVaultGroup(name, opts) {
9428
9564
  if (this.closed) throw new ValidationError("Instance is closed");
9565
+ if (name === STATE_VAULT_NAME) throw new ReservedVaultNameError(name);
9429
9566
  const template = this.vaultTemplates.get(opts.sharding.vaultTemplate);
9430
9567
  if (!template) throw new VaultTemplateNotFoundError(opts.sharding.vaultTemplate);
9431
- const { VaultGroup } = await import("./vault-group-Z4KB75ZH.js");
9432
- return new VaultGroup(this, name, opts.registry, opts.sharding, template);
9568
+ const { VaultGroup } = await import("./vault-group-W7QC4UYW.js");
9569
+ const { StateManagementVault } = await import("./state-vault-TMXZRTY5.js");
9570
+ const stateVault = opts.registry ? void 0 : await StateManagementVault.open(this);
9571
+ const registry = opts.registry ?? stateVault.registry;
9572
+ const group = new VaultGroup(this, name, registry, opts.sharding, template);
9573
+ if (stateVault) {
9574
+ group._attachStateVault(stateVault);
9575
+ await stateVault.recordManifest(opts.sharding.vaultTemplate, template);
9576
+ try {
9577
+ await stateVault.appendEvent({
9578
+ type: "manifest-recorded",
9579
+ group: name,
9580
+ templateName: opts.sharding.vaultTemplate,
9581
+ version: template.version
9582
+ });
9583
+ await stateVault.appendEvent({ type: "group-opened", group: name });
9584
+ } catch {
9585
+ }
9586
+ }
9587
+ return group;
9588
+ }
9589
+ /**
9590
+ * Open the reserved StateManagement control-plane vault (registry +
9591
+ * schema-manifest + deployment-events). Lazy-loaded so the federation
9592
+ * chunk stays out of the core graph until used.
9593
+ */
9594
+ async openStateManagementVault() {
9595
+ if (this.closed) throw new ValidationError("Instance is closed");
9596
+ const { StateManagementVault } = await import("./state-vault-TMXZRTY5.js");
9597
+ return StateManagementVault.open(this);
9433
9598
  }
9434
9599
  /**
9435
9600
  * @internal — true when an encrypted shard vault is provisioned
@@ -10968,4 +11133,4 @@ export {
10968
11133
  Noydb,
10969
11134
  createNoydb
10970
11135
  };
10971
- //# sourceMappingURL=chunk-TMHJEYW7.js.map
11136
+ //# sourceMappingURL=chunk-ACKFRSAH.js.map