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

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 +551 -32
  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-P3Z5Y2TS.js → chunk-3OUCWHV6.js} +2 -2
  19. package/dist/{chunk-4BHFNKTP.js → chunk-3XZRRBFW.js} +2 -2
  20. package/dist/{chunk-XSIFXX54.js → chunk-4VCQH32J.js} +2 -2
  21. package/dist/{chunk-CHBXWJZQ.js → chunk-4YDZ7JPZ.js} +2 -2
  22. package/dist/{chunk-B7GGYNKQ.js → chunk-5NISHSBO.js} +2 -2
  23. package/dist/{chunk-O53RIZCC.js → chunk-7TEI2K2A.js} +5 -5
  24. package/dist/{chunk-ZCFS7U4J.js → chunk-AYNF7PVX.js} +2 -2
  25. package/dist/{chunk-GFPR7VJS.js → chunk-C3WRKABE.js} +4 -4
  26. package/dist/{chunk-EKNUBIIQ.js → chunk-CWFQTAD4.js} +4 -4
  27. package/dist/{chunk-P4EDT5ZP.js → chunk-D5Y3HIC6.js} +2 -2
  28. package/dist/{chunk-IUBHXEPJ.js → chunk-E3DIBDKA.js} +2 -2
  29. package/dist/{chunk-WNRGOVLG.js → chunk-FNVFT4HZ.js} +2 -2
  30. package/dist/{chunk-LYNNZEQD.js → chunk-GC4V7RU7.js} +1 -1
  31. package/dist/chunk-GC4V7RU7.js.map +1 -0
  32. package/dist/{chunk-5ARRXIVR.js → chunk-GL3Z7LH7.js} +2 -2
  33. package/dist/{chunk-WUG3E423.js → chunk-GZJ5JBED.js} +4 -4
  34. package/dist/{chunk-XHM2SARW.js → chunk-HHZ77DHM.js} +3 -3
  35. package/dist/{chunk-SJJQKNMP.js → chunk-HQXOEWLZ.js} +4 -4
  36. package/dist/{chunk-CILT6V3V.js → chunk-ILWQGTNH.js} +2 -2
  37. package/dist/{chunk-RRDWXNBQ.js → chunk-J67BP5EP.js} +3 -3
  38. package/dist/{chunk-HLGDYFWR.js → chunk-JPOQMXGT.js} +2 -2
  39. package/dist/{chunk-IEPT7HVP.js → chunk-JWFNOD2T.js} +2 -2
  40. package/dist/{chunk-BXOUVUES.js → chunk-KHQ3N5AB.js} +4 -4
  41. package/dist/{chunk-UA6G45ME.js → chunk-KJF7EPUE.js} +3 -3
  42. package/dist/{chunk-C2CIIQRG.js → chunk-KKB42D3Q.js} +2 -2
  43. package/dist/{chunk-M45IRXDM.js → chunk-M6KXHRIA.js} +3 -3
  44. package/dist/{chunk-VOXMU6LB.js → chunk-NIUXQDWD.js} +2 -2
  45. package/dist/{chunk-UOC7JMZO.js → chunk-NJMKHRQI.js} +135 -10
  46. package/dist/chunk-NJMKHRQI.js.map +1 -0
  47. package/dist/{chunk-AGRC7NQQ.js → chunk-NKGY3C53.js} +26 -1
  48. package/dist/chunk-NKGY3C53.js.map +1 -0
  49. package/dist/{chunk-LWSD4QPT.js → chunk-O2JW656W.js} +3 -3
  50. package/dist/{chunk-TMHJEYW7.js → chunk-P5MW7BG2.js} +302 -137
  51. package/dist/chunk-P5MW7BG2.js.map +1 -0
  52. package/dist/{chunk-LSEW3ZZ2.js → chunk-PW26DAXS.js} +3 -3
  53. package/dist/{chunk-HBAJDI2N.js → chunk-QAWCVWCX.js} +5 -5
  54. package/dist/{chunk-L6BYRCYB.js → chunk-QFYVGJLI.js} +2 -2
  55. package/dist/{chunk-6BYBVRZU.js → chunk-QIVFGU2M.js} +3 -3
  56. package/dist/{chunk-ZC7MNVYN.js → chunk-SJ24GHID.js} +2 -2
  57. package/dist/{chunk-SZ4N3IL5.js → chunk-SOU42FGB.js} +5 -5
  58. package/dist/{chunk-DLTU4M2I.js → chunk-SYSKC237.js} +6 -6
  59. package/dist/{chunk-6AD5TBF2.js → chunk-TDECYU4Y.js} +3 -3
  60. package/dist/{chunk-7JJE3OMJ.js → chunk-TEQGXA7L.js} +5 -5
  61. package/dist/{chunk-RHQYVHFH.js → chunk-UNQEWORI.js} +2 -2
  62. package/dist/{chunk-LOA2VCMS.js → chunk-VAK6NQAK.js} +5 -5
  63. package/dist/{chunk-7LVRIW4G.js → chunk-WQKZIQIL.js} +4 -4
  64. package/dist/{chunk-OPDTLHFA.js → chunk-YWBHS25M.js} +2 -2
  65. package/dist/chunk-ZC7J6ZYV.js +7 -0
  66. package/dist/chunk-ZC7J6ZYV.js.map +1 -0
  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-YXH6SAOW.js} +3 -3
  72. package/dist/{delegation-6FCWDRUS.js → delegation-K5ERUH6A.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-D3mpVFRc.d.ts → dev-unlock-BW0GNBEV.d.ts} +1 -1
  78. package/dist/{dev-unlock-ckqa_Nso.d.cts → dev-unlock-a7SOtaV0.d.cts} +1 -1
  79. package/dist/executor-AVJ7UEWA.js +8 -0
  80. package/dist/executor-IQO3KGXQ.js +11 -0
  81. package/dist/executor-VT7TKGE4.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-B0cLQcq_.d.cts} +1 -1
  88. package/dist/{hash-CTZVkXLx.d.ts → hash-uMNIAAW8.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-DyD0qg2k.d.ts → immutable-guard-B0h-ipLz.d.ts} +1 -1
  98. package/dist/{immutable-guard-C51vAHuh.d.cts → immutable-guard-BZIcYhYX.d.cts} +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 +567 -35
  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-ZH27C23Y.js +12 -0
  110. package/dist/{ledger-5JMVF7PY.js → ledger-64TTQMRS.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-O76SKBST.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-MHG6YVXW.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-2PKBQDCH.js +8 -0
  131. package/dist/registry-4VXFKCBJ.js +8 -0
  132. package/dist/{registry-NCY445U5.js → registry-PV4G3OPA.js} +3 -3
  133. package/dist/{revoke-7RLGQWZ7.js → revoke-5BOLVJ3N.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-GRIYBA22.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-LZYMMDDS.js} +2 -2
  148. package/dist/state-vault-QFJWU23A.js +147 -0
  149. package/dist/state-vault-QFJWU23A.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-BGwjsDef.d.cts → types-CDwSSXiI.d.cts} +290 -92
  169. package/dist/{types-DRdfwgTG.d.ts → types-pax34sec.d.ts} +290 -92
  170. package/dist/{ulid-D4d0Xto3.d.cts → ulid-7bCSgIgb.d.cts} +1 -1
  171. package/dist/{ulid-DOTPZ5_h.d.ts → ulid-C_t4hL3d.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-UO4YUZOG.js} +53 -10
  175. package/dist/vault-group-UO4YUZOG.js.map +1 -0
  176. package/dist/{with-derivation-B082Y_WQ.d.ts → with-derivation-BjdOxUBn.d.ts} +1 -1
  177. package/dist/{with-derivation-CB1EdcFF.d.cts → with-derivation-D8wFlb6V.d.cts} +1 -1
  178. package/dist/{with-materialized-view-CzRg1Dpr.d.cts → with-materialized-view-5QMF1rS_.d.cts} +1 -1
  179. package/dist/{with-materialized-view-Dw4SwjKl.d.ts → with-materialized-view-DJb-HO65.d.ts} +1 -1
  180. package/dist/{with-overlayed-view-CaCXeW26.d.ts → with-overlayed-view-CkqTefbz.d.ts} +1 -1
  181. package/dist/{with-overlayed-view-C9YFKXzn.d.cts → with-overlayed-view-DDNflPvC.d.cts} +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-P3Z5Y2TS.js.map → chunk-3OUCWHV6.js.map} +0 -0
  196. /package/dist/{chunk-4BHFNKTP.js.map → chunk-3XZRRBFW.js.map} +0 -0
  197. /package/dist/{chunk-XSIFXX54.js.map → chunk-4VCQH32J.js.map} +0 -0
  198. /package/dist/{chunk-CHBXWJZQ.js.map → chunk-4YDZ7JPZ.js.map} +0 -0
  199. /package/dist/{chunk-B7GGYNKQ.js.map → chunk-5NISHSBO.js.map} +0 -0
  200. /package/dist/{chunk-O53RIZCC.js.map → chunk-7TEI2K2A.js.map} +0 -0
  201. /package/dist/{chunk-ZCFS7U4J.js.map → chunk-AYNF7PVX.js.map} +0 -0
  202. /package/dist/{chunk-GFPR7VJS.js.map → chunk-C3WRKABE.js.map} +0 -0
  203. /package/dist/{chunk-EKNUBIIQ.js.map → chunk-CWFQTAD4.js.map} +0 -0
  204. /package/dist/{chunk-P4EDT5ZP.js.map → chunk-D5Y3HIC6.js.map} +0 -0
  205. /package/dist/{chunk-IUBHXEPJ.js.map → chunk-E3DIBDKA.js.map} +0 -0
  206. /package/dist/{chunk-WNRGOVLG.js.map → chunk-FNVFT4HZ.js.map} +0 -0
  207. /package/dist/{chunk-5ARRXIVR.js.map → chunk-GL3Z7LH7.js.map} +0 -0
  208. /package/dist/{chunk-WUG3E423.js.map → chunk-GZJ5JBED.js.map} +0 -0
  209. /package/dist/{chunk-XHM2SARW.js.map → chunk-HHZ77DHM.js.map} +0 -0
  210. /package/dist/{chunk-SJJQKNMP.js.map → chunk-HQXOEWLZ.js.map} +0 -0
  211. /package/dist/{chunk-CILT6V3V.js.map → chunk-ILWQGTNH.js.map} +0 -0
  212. /package/dist/{chunk-RRDWXNBQ.js.map → chunk-J67BP5EP.js.map} +0 -0
  213. /package/dist/{chunk-HLGDYFWR.js.map → chunk-JPOQMXGT.js.map} +0 -0
  214. /package/dist/{chunk-IEPT7HVP.js.map → chunk-JWFNOD2T.js.map} +0 -0
  215. /package/dist/{chunk-BXOUVUES.js.map → chunk-KHQ3N5AB.js.map} +0 -0
  216. /package/dist/{chunk-UA6G45ME.js.map → chunk-KJF7EPUE.js.map} +0 -0
  217. /package/dist/{chunk-C2CIIQRG.js.map → chunk-KKB42D3Q.js.map} +0 -0
  218. /package/dist/{chunk-M45IRXDM.js.map → chunk-M6KXHRIA.js.map} +0 -0
  219. /package/dist/{chunk-VOXMU6LB.js.map → chunk-NIUXQDWD.js.map} +0 -0
  220. /package/dist/{chunk-LWSD4QPT.js.map → chunk-O2JW656W.js.map} +0 -0
  221. /package/dist/{chunk-LSEW3ZZ2.js.map → chunk-PW26DAXS.js.map} +0 -0
  222. /package/dist/{chunk-HBAJDI2N.js.map → chunk-QAWCVWCX.js.map} +0 -0
  223. /package/dist/{chunk-L6BYRCYB.js.map → chunk-QFYVGJLI.js.map} +0 -0
  224. /package/dist/{chunk-6BYBVRZU.js.map → chunk-QIVFGU2M.js.map} +0 -0
  225. /package/dist/{chunk-ZC7MNVYN.js.map → chunk-SJ24GHID.js.map} +0 -0
  226. /package/dist/{chunk-SZ4N3IL5.js.map → chunk-SOU42FGB.js.map} +0 -0
  227. /package/dist/{chunk-DLTU4M2I.js.map → chunk-SYSKC237.js.map} +0 -0
  228. /package/dist/{chunk-6AD5TBF2.js.map → chunk-TDECYU4Y.js.map} +0 -0
  229. /package/dist/{chunk-7JJE3OMJ.js.map → chunk-TEQGXA7L.js.map} +0 -0
  230. /package/dist/{chunk-RHQYVHFH.js.map → chunk-UNQEWORI.js.map} +0 -0
  231. /package/dist/{chunk-LOA2VCMS.js.map → chunk-VAK6NQAK.js.map} +0 -0
  232. /package/dist/{chunk-7LVRIW4G.js.map → chunk-WQKZIQIL.js.map} +0 -0
  233. /package/dist/{chunk-OPDTLHFA.js.map → chunk-YWBHS25M.js.map} +0 -0
  234. /package/dist/{crypto-AJB72OKN.js.map → crypto-YXH6SAOW.js.map} +0 -0
  235. /package/dist/{delegation-6FCWDRUS.js.map → delegation-K5ERUH6A.js.map} +0 -0
  236. /package/dist/{executor-7KSCEIFA.js.map → executor-AVJ7UEWA.js.map} +0 -0
  237. /package/dist/{executor-D2QMNGRJ.js.map → executor-IQO3KGXQ.js.map} +0 -0
  238. /package/dist/{executor-O5AZK7UW.js.map → executor-VT7TKGE4.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-ZH27C23Y.js.map} +0 -0
  241. /package/dist/{ledger-5JMVF7PY.js.map → ledger-64TTQMRS.js.map} +0 -0
  242. /package/dist/{noydb-D5SLAJ6V.js.map → noydb-O76SKBST.js.map} +0 -0
  243. /package/dist/{public-envelope-PFLZI5MO.js.map → public-envelope-MHG6YVXW.js.map} +0 -0
  244. /package/dist/{registry-BVQ5ITMF.js.map → registry-2PKBQDCH.js.map} +0 -0
  245. /package/dist/{registry-JLP3QOLD.js.map → registry-4VXFKCBJ.js.map} +0 -0
  246. /package/dist/{registry-NCY445U5.js.map → registry-PV4G3OPA.js.map} +0 -0
  247. /package/dist/{revoke-7RLGQWZ7.js.map → revoke-5BOLVJ3N.js.map} +0 -0
  248. /package/dist/{signer-6JF44I4A.js.map → signer-GRIYBA22.js.map} +0 -0
  249. /package/dist/{stale-UBLP3RJ3.js.map → stale-LZYMMDDS.js.map} +0 -0
@@ -31,7 +31,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
32
 
33
33
  // src/errors.ts
34
- var NoydbError, DecryptionError, TamperedError, InvalidKeyError, KeyringCorruptError, NoAccessError, ReadOnlyError, PermissionDeniedError, ExportCapabilityError, KeyringExpiredError, ImportCapabilityError, StoreCapabilityError, PrivilegeEscalationError, FieldFrozenError, InvariantError, AmendmentForbiddenError, TierNotGrantedError, ElevationExpiredError, AlreadyElevatedError, TierDemoteDeniedError, DelegationTargetMissingError, ConflictError, LedgerContentionError, SequenceContentionError, SequenceOfflineError, BundleVersionConflictError, ValidationError, SchemaValidationError, SchemaUpdateError, SchemaFenceError, MigrationRequiredError, QuiesceTimeoutError, GroupCardinalityError, IndexRequiredError, UniqueConstraintError, UnsupportedIndexOptionError, IndexWriteFailureError, BundleIntegrityError, BundleSealMismatchError, ReservedCollectionNameError, LocaleNotSpecifiedError, TranslatorNotConfiguredError, BackupLedgerError, BackupCorruptedError, PartitionExtractionError, TransferSealError, AdoptionStateError, AttestationError, JoinTooLargeError, CrossJoinTooLargeError, CrossJoinSourceUnknownError, DanglingReferenceError, DerivationCycleError, DerivationOutputShapeError, DerivationCapExceededError, MaterializedViewCycleError, MaterializedViewSourceUnknownError, MaterializedViewTooLargeError, OverlayBaseIsVirtualError, OverlayCollectionUnavailableError, OverlayNameCollisionError, OverlayIdMismatchError, UnknownShardError, ShardProvisioningError, VaultTemplateNotFoundError;
34
+ var NoydbError, DecryptionError, TamperedError, InvalidKeyError, KeyringCorruptError, NoAccessError, ReadOnlyError, PermissionDeniedError, ExportCapabilityError, KeyringExpiredError, ImportCapabilityError, StoreCapabilityError, PrivilegeEscalationError, ReservedVaultNameError, FieldFrozenError, InvariantError, AmendmentForbiddenError, TierNotGrantedError, ElevationExpiredError, AlreadyElevatedError, TierDemoteDeniedError, DelegationTargetMissingError, ConflictError, LedgerContentionError, SequenceContentionError, SequenceOfflineError, NumberingUncertaintyError, BundleVersionConflictError, ValidationError, SchemaValidationError, SchemaUpdateError, SchemaFenceError, MigrationRequiredError, QuiesceTimeoutError, GroupCardinalityError, IndexRequiredError, UniqueConstraintError, UnsupportedIndexOptionError, IndexWriteFailureError, BundleIntegrityError, BundleSealMismatchError, ReservedCollectionNameError, LocaleNotSpecifiedError, TranslatorNotConfiguredError, BackupLedgerError, BackupCorruptedError, PartitionExtractionError, TransferSealError, AdoptionStateError, AttestationError, JoinTooLargeError, CrossJoinTooLargeError, CrossJoinSourceUnknownError, DanglingReferenceError, DerivationCycleError, DerivationOutputShapeError, DerivationCapExceededError, MaterializedViewCycleError, MaterializedViewSourceUnknownError, MaterializedViewTooLargeError, OverlayBaseIsVirtualError, OverlayCollectionUnavailableError, OverlayNameCollisionError, OverlayIdMismatchError, UnknownShardError, ShardProvisioningError, VaultTemplateNotFoundError;
35
35
  var init_errors = __esm({
36
36
  "src/errors.ts"() {
37
37
  "use strict";
@@ -155,6 +155,18 @@ var init_errors = __esm({
155
155
  this.offendingCollection = offendingCollection;
156
156
  }
157
157
  };
158
+ ReservedVaultNameError = class extends NoydbError {
159
+ /** The rejected vault name. */
160
+ vaultName;
161
+ constructor(vaultName) {
162
+ super(
163
+ "RESERVED_VAULT_NAME",
164
+ `"${vaultName}" is a reserved internal vault name and cannot be used as a group name or partition key`
165
+ );
166
+ this.name = "ReservedVaultNameError";
167
+ this.vaultName = vaultName;
168
+ }
169
+ };
158
170
  FieldFrozenError = class extends NoydbError {
159
171
  collection;
160
172
  id;
@@ -288,6 +300,17 @@ var init_errors = __esm({
288
300
  this.name = "SequenceOfflineError";
289
301
  }
290
302
  };
303
+ NumberingUncertaintyError = class extends NoydbError {
304
+ series;
305
+ constructor(series) {
306
+ super(
307
+ "NUMBERING_UNCERTAINTY",
308
+ `Deferred numbering for series "${series}" cannot run: the store does not expose getStoreTime() (capabilities.serverWriteTime). Use a CAS sequence or a store with serverWriteTime.`
309
+ );
310
+ this.name = "NumberingUncertaintyError";
311
+ this.series = series;
312
+ }
313
+ };
291
314
  BundleVersionConflictError = class extends NoydbError {
292
315
  /** The bundle handle of the newer remote version that rejected the push. */
293
316
  remoteVersion;
@@ -2716,6 +2739,15 @@ var init_store = __esm({
2716
2739
  }
2717
2740
  });
2718
2741
 
2742
+ // src/federation/constants.ts
2743
+ var STATE_VAULT_NAME;
2744
+ var init_constants2 = __esm({
2745
+ "src/federation/constants.ts"() {
2746
+ "use strict";
2747
+ STATE_VAULT_NAME = "__noydb_state__";
2748
+ }
2749
+ });
2750
+
2719
2751
  // src/policy/errors.ts
2720
2752
  var PolicyDeniedError, RecoveryNotEnrolledError, ManagedRecoveryNotEnrolledError, RecoveryProfileNotImplementedError;
2721
2753
  var init_errors2 = __esm({
@@ -3712,10 +3744,10 @@ function shouldRoundUp(negative, lastKeptDigit, firstDiscarded, hasMoreNonZeroAf
3712
3744
  }
3713
3745
  }
3714
3746
  function parseToScaledInt(input, scale, rounding) {
3715
- const canonical = toCanonicalDecimalString(input);
3716
- if (canonical === null) return { ok: false, reason: "nonfinite" };
3717
- const negative = canonical.startsWith("-");
3718
- const unsigned = negative ? canonical.slice(1) : canonical;
3747
+ const canonical2 = toCanonicalDecimalString(input);
3748
+ if (canonical2 === null) return { ok: false, reason: "nonfinite" };
3749
+ const negative = canonical2.startsWith("-");
3750
+ const unsigned = negative ? canonical2.slice(1) : canonical2;
3719
3751
  const dot = unsigned.indexOf(".");
3720
3752
  const intPart = dot === -1 ? unsigned : unsigned.slice(0, dot);
3721
3753
  const fracPart = dot === -1 ? "" : unsigned.slice(dot + 1);
@@ -4869,7 +4901,7 @@ function serializeClause(clause) {
4869
4901
  }
4870
4902
  function canonicalCtxHash(ctx) {
4871
4903
  if (ctx === void 0) return "";
4872
- const canonical = JSON.stringify(ctx, (_key, value) => {
4904
+ const canonical2 = JSON.stringify(ctx, (_key, value) => {
4873
4905
  if (value && typeof value === "object" && !Array.isArray(value)) {
4874
4906
  const sorted = {};
4875
4907
  for (const k of Object.keys(value).sort()) {
@@ -4880,8 +4912,8 @@ function canonicalCtxHash(ctx) {
4880
4912
  return value;
4881
4913
  });
4882
4914
  let h = 5381;
4883
- for (let i = 0; i < canonical.length; i++) {
4884
- h = (h << 5) + h ^ canonical.charCodeAt(i);
4915
+ for (let i = 0; i < canonical2.length; i++) {
4916
+ h = (h << 5) + h ^ canonical2.charCodeAt(i);
4885
4917
  }
4886
4918
  return (h >>> 0).toString(16).padStart(8, "0");
4887
4919
  }
@@ -4924,6 +4956,7 @@ var init_builder = __esm({
4924
4956
  init_live();
4925
4957
  init_strategy4();
4926
4958
  init_money_reducer();
4959
+ init_normalize();
4927
4960
  EMPTY_PLAN = {
4928
4961
  clauses: [],
4929
4962
  orderBy: [],
@@ -5292,7 +5325,7 @@ var init_builder = __esm({
5292
5325
  * for the ordering rationale.
5293
5326
  */
5294
5327
  toArray() {
5295
- const base = executePlanWithSource(this.source, this.plan, this.joinContext);
5328
+ const base = this.decodeMoney(executePlanWithSource(this.source, this.plan, this.joinContext));
5296
5329
  if (this.plan.joins.length === 0) return base;
5297
5330
  if (!this.joinContext) {
5298
5331
  throw new Error(
@@ -5301,6 +5334,23 @@ var init_builder = __esm({
5301
5334
  }
5302
5335
  return applyJoins(base, this.plan.joins, this.joinContext);
5303
5336
  }
5337
+ /**
5338
+ * Decode this source's money fields on read (stored scaled-int → canonical
5339
+ * decimal), so `query().toArray()` agrees with `get()`/`sum()` on the value.
5340
+ * No-op when the source declares no money fields.
5341
+ *
5342
+ * The query layer carries no locale context, so we decode with `'raw'` —
5343
+ * canonical decimal, WITHOUT fabricating locale-formatted `<field>Formatted`
5344
+ * / `<field>Number` virtuals. Producing a guessed-locale string here would
5345
+ * just reintroduce #322's "two read paths disagree" failure on the virtual
5346
+ * field (e.g. it-IT via `get()` vs en-US here). Consumers who need formatted
5347
+ * money read through `get()`/`list()` with a locale.
5348
+ */
5349
+ decodeMoney(records) {
5350
+ const moneyFields = this.source.moneyFields;
5351
+ if (!moneyFields || Object.keys(moneyFields).length === 0) return records;
5352
+ return records.map((r) => decodeMoneyFields(r, moneyFields, "raw"));
5353
+ }
5304
5354
  /** Return the first matching record, or null. Joins are applied. */
5305
5355
  first() {
5306
5356
  const arr = this.limit(1).toArray();
@@ -5678,6 +5728,7 @@ var init_scan_builder = __esm({
5678
5728
  "use strict";
5679
5729
  init_predicate();
5680
5730
  init_errors();
5731
+ init_normalize();
5681
5732
  DEFAULT_SCAN_PAGE_SIZE = 100;
5682
5733
  ScanBuilder = class _ScanBuilder {
5683
5734
  pageProvider;
@@ -5703,12 +5754,29 @@ var init_scan_builder = __esm({
5703
5754
  * context throws with an actionable error.
5704
5755
  */
5705
5756
  joinContext;
5706
- constructor(pageProvider, pageSize = DEFAULT_SCAN_PAGE_SIZE, clauses = [], joins = [], joinContext) {
5757
+ /**
5758
+ * Money field descriptors for the backing collection. When present, yielded
5759
+ * records are decoded (stored scaled-int → canonical decimal) so `scan()`
5760
+ * agrees with `get()`/`list()`/`query().toArray()` — #322. Decoded with
5761
+ * `'raw'` (canonical decimal, no locale-formatted virtuals) since the scan
5762
+ * stream carries no locale context, mirroring `Query.toArray()`.
5763
+ */
5764
+ moneyFields;
5765
+ constructor(pageProvider, pageSize = DEFAULT_SCAN_PAGE_SIZE, clauses = [], joins = [], joinContext, moneyFields) {
5707
5766
  this.pageProvider = pageProvider;
5708
5767
  this.pageSize = pageSize;
5709
5768
  this.clauses = clauses;
5710
5769
  this.joins = joins;
5711
5770
  this.joinContext = joinContext;
5771
+ this.moneyFields = moneyFields;
5772
+ }
5773
+ /**
5774
+ * Decode this scan's money fields on a record (stored scaled-int → canonical
5775
+ * decimal). No-op when no money fields are declared. See {@link moneyFields}.
5776
+ */
5777
+ decodeMoney(record) {
5778
+ if (!this.moneyFields || Object.keys(this.moneyFields).length === 0) return record;
5779
+ return decodeMoneyFields(record, this.moneyFields, "raw");
5712
5780
  }
5713
5781
  /**
5714
5782
  * Add a field comparison. Runs per record as the scan stream
@@ -5730,7 +5798,8 @@ var init_scan_builder = __esm({
5730
5798
  this.pageSize,
5731
5799
  [...this.clauses, clause],
5732
5800
  this.joins,
5733
- this.joinContext
5801
+ this.joinContext,
5802
+ this.moneyFields
5734
5803
  );
5735
5804
  }
5736
5805
  /**
@@ -5749,7 +5818,8 @@ var init_scan_builder = __esm({
5749
5818
  this.pageSize,
5750
5819
  [...this.clauses, clause],
5751
5820
  this.joins,
5752
- this.joinContext
5821
+ this.joinContext,
5822
+ this.moneyFields
5753
5823
  );
5754
5824
  }
5755
5825
  /**
@@ -5860,7 +5930,8 @@ var init_scan_builder = __esm({
5860
5930
  this.pageSize,
5861
5931
  this.clauses,
5862
5932
  [...this.joins, leg],
5863
- this.joinContext
5933
+ this.joinContext,
5934
+ this.moneyFields
5864
5935
  );
5865
5936
  }
5866
5937
  /**
@@ -5877,10 +5948,11 @@ var init_scan_builder = __esm({
5877
5948
  while (true) {
5878
5949
  for (const record of page.items) {
5879
5950
  if (!this.recordMatches(record)) continue;
5951
+ const decoded = this.decodeMoney(record);
5880
5952
  if (joinResolvers === null) {
5881
- yield record;
5953
+ yield decoded;
5882
5954
  } else {
5883
- let attached = record;
5955
+ let attached = decoded;
5884
5956
  for (const resolver of joinResolvers) {
5885
5957
  attached = this.applyOneJoinStreaming(attached, resolver);
5886
5958
  }
@@ -7048,12 +7120,12 @@ var init_dependency_analyzer = __esm({
7048
7120
 
7049
7121
  // src/materialized-views/query-hash.ts
7050
7122
  async function computeQueryHash(mvName, dependencies, queryPlanSummary) {
7051
- const canonical = JSON.stringify({
7123
+ const canonical2 = JSON.stringify({
7052
7124
  mvName,
7053
7125
  dependencies: [...dependencies].sort(),
7054
7126
  queryPlanSummary
7055
7127
  });
7056
- const bytes = new TextEncoder().encode(canonical);
7128
+ const bytes = new TextEncoder().encode(canonical2);
7057
7129
  const digest = await crypto.subtle.digest("SHA-256", bytes);
7058
7130
  return Array.from(new Uint8Array(digest)).map((b) => b.toString(16).padStart(2, "0")).join("");
7059
7131
  }
@@ -8914,9 +8986,17 @@ var init_collection = __esm({
8914
8986
  }
8915
8987
  await this.ensureHydrated();
8916
8988
  const records = [...this.cache.values()].map((e) => e.record);
8917
- if (!locale) return records;
8989
+ if (!this.hasReadTransforms()) return records;
8918
8990
  return Promise.all(records.map((r) => this.applyLocaleToRecord(r, locale)));
8919
8991
  }
8992
+ /**
8993
+ * @internal — whether any read-side record transform is registered
8994
+ * (money decode, i18nText resolution, dictKey labels). Gates the
8995
+ * no-transform fast path in {@link list}.
8996
+ */
8997
+ hasReadTransforms() {
8998
+ 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;
8999
+ }
8920
9000
  // ─── Bulk operations ─────────────────────────────────────
8921
9001
  /**
8922
9002
  * Put many records in one call. Each item is processed sequentially
@@ -9422,7 +9502,8 @@ var init_collection = __esm({
9422
9502
  pageSize,
9423
9503
  [],
9424
9504
  [],
9425
- joinContext
9505
+ joinContext,
9506
+ this.moneyFields
9426
9507
  );
9427
9508
  }
9428
9509
  /** Decrypt a page of envelopes returned by `adapter.listPage`. */
@@ -10790,6 +10871,168 @@ var init_sequence = __esm({
10790
10871
  }
10791
10872
  });
10792
10873
 
10874
+ // src/numbering/index.ts
10875
+ var NUMBERING_HEAD_COLLECTION, NUMBERING_PENDING_COLLECTION, DeferredNumberingStore;
10876
+ var init_numbering = __esm({
10877
+ "src/numbering/index.ts"() {
10878
+ "use strict";
10879
+ init_types();
10880
+ init_crypto();
10881
+ init_errors();
10882
+ NUMBERING_HEAD_COLLECTION = "_numbering_head";
10883
+ NUMBERING_PENDING_COLLECTION = "_numbering_pending";
10884
+ DeferredNumberingStore = class {
10885
+ adapter;
10886
+ vault;
10887
+ encrypted;
10888
+ getDEK;
10889
+ actor;
10890
+ configs;
10891
+ /**
10892
+ * Stamp a serial onto a USER record THROUGH the Collection layer (so the
10893
+ * cache, indexes, and MVs stay coherent — the engine must NOT write user
10894
+ * collections at the raw adapter level). Returns false if the record is
10895
+ * gone (the engine then skips it without burning a serial). Provided by the
10896
+ * vault; unit tests pass a Map-backed double.
10897
+ */
10898
+ stamp;
10899
+ /** In-process registry: `${series}::${recordId}` → resolver for the live next() Promise. */
10900
+ waiters = /* @__PURE__ */ new Map();
10901
+ dekCache = /* @__PURE__ */ new Map();
10902
+ constructor(opts) {
10903
+ this.adapter = opts.adapter;
10904
+ this.vault = opts.vault;
10905
+ this.encrypted = opts.encrypted;
10906
+ this.getDEK = opts.getDEK;
10907
+ this.actor = opts.actor;
10908
+ this.configs = opts.configs;
10909
+ this.stamp = opts.stamp;
10910
+ }
10911
+ has(series) {
10912
+ return this.configs.has(series);
10913
+ }
10914
+ dek(collection) {
10915
+ let p = this.dekCache.get(collection);
10916
+ if (!p) {
10917
+ p = this.getDEK(collection);
10918
+ this.dekCache.set(collection, p);
10919
+ }
10920
+ return p;
10921
+ }
10922
+ async readJson(collection, id) {
10923
+ const env = await this.adapter.get(this.vault, collection, id);
10924
+ if (!env) return { env: null, value: null };
10925
+ const json = this.encrypted ? await decrypt(env._iv, env._data, await this.dek(collection)) : env._data;
10926
+ return { env, value: JSON.parse(json) };
10927
+ }
10928
+ async writeJson(collection, id, value, expectedVersion) {
10929
+ const json = JSON.stringify(value);
10930
+ let env;
10931
+ if (!this.encrypted) {
10932
+ env = { _noydb: NOYDB_FORMAT_VERSION, _v: expectedVersion + 1, _ts: (/* @__PURE__ */ new Date()).toISOString(), _iv: "", _data: json, _by: this.actor };
10933
+ } else {
10934
+ const { iv, data } = await encrypt(json, await this.dek(collection));
10935
+ env = { _noydb: NOYDB_FORMAT_VERSION, _v: expectedVersion + 1, _ts: (/* @__PURE__ */ new Date()).toISOString(), _iv: iv, _data: data, _by: this.actor };
10936
+ }
10937
+ await this.adapter.put(this.vault, collection, id, env, expectedVersion);
10938
+ }
10939
+ pendingId(series, recordId2) {
10940
+ return `${series}::${recordId2}`;
10941
+ }
10942
+ /** Current last-assigned serial for a series (0 if none). */
10943
+ async peek(series) {
10944
+ const { value } = await this.readJson(NUMBERING_HEAD_COLLECTION, series);
10945
+ return value?.lastSerial ?? 0;
10946
+ }
10947
+ /**
10948
+ * Enqueue a record for numbering: stamp it with the current store clock and
10949
+ * durably write a pending entry. The returned Promise resolves once the
10950
+ * record is durably enqueued; its `assigned` field resolves with the serial
10951
+ * at the next pass (the record's `field` is the durable source of truth —
10952
+ * `assigned` is an in-process convenience that a crash may drop).
10953
+ */
10954
+ async enqueue(series, recordId2) {
10955
+ const cfg = this.configs.get(series);
10956
+ if (!cfg) throw new NumberingUncertaintyError(series);
10957
+ if (typeof this.adapter.getStoreTime !== "function") throw new NumberingUncertaintyError(series);
10958
+ const st = await this.adapter.getStoreTime();
10959
+ const id = this.pendingId(series, recordId2);
10960
+ const { env } = await this.readJson(NUMBERING_PENDING_COLLECTION, id);
10961
+ const entry = {
10962
+ series,
10963
+ recordId: recordId2,
10964
+ collection: cfg.collection,
10965
+ field: cfg.field,
10966
+ storeEarliest: st.earliest,
10967
+ storeLatest: st.latest,
10968
+ enqueuedAt: Date.now()
10969
+ };
10970
+ await this.writeJson(NUMBERING_PENDING_COLLECTION, id, entry, env?._v ?? 0);
10971
+ const assigned = new Promise((resolve, reject) => {
10972
+ this.waiters.set(id, { resolve, reject });
10973
+ });
10974
+ return { assigned };
10975
+ }
10976
+ async listPending(series) {
10977
+ const ids = await this.adapter.list(this.vault, NUMBERING_PENDING_COLLECTION);
10978
+ const prefix = `${series}::`;
10979
+ const out = [];
10980
+ for (const id of ids) {
10981
+ if (!id.startsWith(prefix)) continue;
10982
+ const { value } = await this.readJson(NUMBERING_PENDING_COLLECTION, id);
10983
+ if (value) out.push({ id, entry: value });
10984
+ }
10985
+ return out;
10986
+ }
10987
+ /**
10988
+ * Run a numbering pass for `series`: select entries provably settled
10989
+ * (`storeLatest ≤ now.earliest` — commit-wait), order by
10990
+ * `(storeEarliest, recordId)`, assign serials after the head, stamp each
10991
+ * record's field, advance the head with one CAS, and consume the entries.
10992
+ * Idempotent/convergent: a losing concurrent pass returns `[]` and the next
10993
+ * pass reconciles. Resolves any in-process enqueue() `assigned` Promises.
10994
+ */
10995
+ async runPass(series) {
10996
+ const cfg = this.configs.get(series);
10997
+ if (!cfg) throw new NumberingUncertaintyError(series);
10998
+ if (typeof this.adapter.getStoreTime !== "function") throw new NumberingUncertaintyError(series);
10999
+ const now = await this.adapter.getStoreTime();
11000
+ const settled = (await this.listPending(series)).filter((p) => p.entry.storeLatest <= now.earliest).sort(
11001
+ (a, b) => a.entry.storeEarliest - b.entry.storeEarliest || (a.entry.recordId < b.entry.recordId ? -1 : a.entry.recordId > b.entry.recordId ? 1 : 0)
11002
+ );
11003
+ if (settled.length === 0) return [];
11004
+ const { env: headEnv, value: head } = await this.readJson(NUMBERING_HEAD_COLLECTION, series);
11005
+ let serial = head?.lastSerial ?? 0;
11006
+ const assignments = [];
11007
+ for (const { entry } of settled) {
11008
+ serial += 1;
11009
+ const ok = await this.stamp(entry.collection, entry.recordId, entry.field, serial);
11010
+ if (!ok) {
11011
+ serial -= 1;
11012
+ continue;
11013
+ }
11014
+ assignments.push({ recordId: entry.recordId, serial });
11015
+ }
11016
+ try {
11017
+ await this.writeJson(NUMBERING_HEAD_COLLECTION, series, { series, lastSerial: serial, watermark: now.earliest }, headEnv?._v ?? 0);
11018
+ } catch (err) {
11019
+ if (err instanceof ConflictError) return [];
11020
+ throw err;
11021
+ }
11022
+ for (const { id, entry } of settled) {
11023
+ await this.adapter.delete(this.vault, NUMBERING_PENDING_COLLECTION, id);
11024
+ const a = assignments.find((x) => x.recordId === entry.recordId);
11025
+ if (a) {
11026
+ this.waiters.get(id)?.resolve(a.serial);
11027
+ this.waiters.delete(id);
11028
+ }
11029
+ }
11030
+ return assignments;
11031
+ }
11032
+ };
11033
+ }
11034
+ });
11035
+
10793
11036
  // src/shadow/strategy.ts
10794
11037
  var NOT_ENABLED3, NO_SHADOW;
10795
11038
  var init_strategy7 = __esm({
@@ -11598,8 +11841,8 @@ async function derivePersistedSchema(validator) {
11598
11841
  if (kind === "Zod") {
11599
11842
  const convert = await loadZodConverter();
11600
11843
  const jsonSchema = convert(validator);
11601
- const canonical = canonicalize(jsonSchema);
11602
- const hash = await sha256Hex2(new TextEncoder().encode(canonical));
11844
+ const canonical2 = canonicalize(jsonSchema);
11845
+ const hash = await sha256Hex2(new TextEncoder().encode(canonical2));
11603
11846
  return { _noydb_schema: 1, kind, jsonSchema, hash, derivedAt };
11604
11847
  }
11605
11848
  return {
@@ -12639,12 +12882,12 @@ var init_read_only_facade = __esm({
12639
12882
 
12640
12883
  // src/derivations/strategy-hash.ts
12641
12884
  async function computeStrategyHash(source, outputKeys, derive) {
12642
- const canonical = JSON.stringify({
12885
+ const canonical2 = JSON.stringify({
12643
12886
  source,
12644
12887
  outputs: [...outputKeys].sort(),
12645
12888
  derive: derive.toString()
12646
12889
  });
12647
- const bytes = new TextEncoder().encode(canonical);
12890
+ const bytes = new TextEncoder().encode(canonical2);
12648
12891
  const digest = await crypto.subtle.digest("SHA-256", bytes);
12649
12892
  return Array.from(new Uint8Array(digest)).map((b) => b.toString(16).padStart(2, "0")).join("");
12650
12893
  }
@@ -12919,6 +13162,7 @@ var init_vault = __esm({
12919
13162
  init_errors();
12920
13163
  init_archive();
12921
13164
  init_sequence();
13165
+ init_numbering();
12922
13166
  init_constants();
12923
13167
  init_entry();
12924
13168
  init_strategy3();
@@ -13086,6 +13330,10 @@ var init_vault = __esm({
13086
13330
  ledgerStore = null;
13087
13331
  /** Lazily-built atomic-sequence store. See {@link sequence}. */
13088
13332
  sequenceStore = null;
13333
+ /** Lazily-built deferred-numbering engine. See {@link runNumberingPass}. */
13334
+ deferredNumbering = null;
13335
+ /** Registered deferred-numbering series, keyed by series name. */
13336
+ numberingConfigs;
13089
13337
  /**
13090
13338
  * Background writes for persisted-schema envelopes (#schema-dump v0
13091
13339
  * slice 1). One promise per `collection({ persistJsonSchema: true })`
@@ -13172,6 +13420,7 @@ var init_vault = __esm({
13172
13420
  constructor(opts) {
13173
13421
  this.adapter = opts.adapter;
13174
13422
  this.name = opts.name;
13423
+ this.numberingConfigs = new Map((opts.numberingConfigs ?? []).map((c) => [c.series, c]));
13175
13424
  this.noydb = opts.noydb;
13176
13425
  this.keyring = opts.keyring;
13177
13426
  this.encrypted = opts.encrypted;
@@ -13846,6 +14095,18 @@ var init_vault = __esm({
13846
14095
  * ```
13847
14096
  */
13848
14097
  sequence(name) {
14098
+ if (this.numberingConfigs.has(name)) {
14099
+ const eng = this.deferred();
14100
+ return {
14101
+ next: async (opts) => {
14102
+ if (!opts?.for) {
14103
+ throw new ValidationError(`sequence("${name}") is a deferred-numbering series; call next({ for: recordId }).`);
14104
+ }
14105
+ return (await eng.enqueue(name, opts.for)).assigned;
14106
+ },
14107
+ peek: () => eng.peek(name)
14108
+ };
14109
+ }
13849
14110
  if (!this.sequenceStore) {
13850
14111
  this.sequenceStore = new SequenceStore({
13851
14112
  adapter: this.adapter,
@@ -13857,6 +14118,38 @@ var init_vault = __esm({
13857
14118
  }
13858
14119
  return this.sequenceStore.handle(name);
13859
14120
  }
14121
+ /** @internal — lazily build the deferred-numbering engine with a cache-coherent stamp. */
14122
+ deferred() {
14123
+ if (!this.deferredNumbering) {
14124
+ this.deferredNumbering = new DeferredNumberingStore({
14125
+ adapter: this.adapter,
14126
+ vault: this.name,
14127
+ encrypted: this.encrypted,
14128
+ getDEK: this.getDEK,
14129
+ actor: this.keyring.userId,
14130
+ configs: this.numberingConfigs,
14131
+ // Stamp THROUGH the Collection layer so cache/indexes/MVs stay coherent —
14132
+ // `this.collection(name)` returns the shared cached instance, so a
14133
+ // subsequent user `collection.get(id)` sees the assigned serial.
14134
+ stamp: async (collection, recordId2, field, serial) => {
14135
+ const coll = this.collection(collection);
14136
+ const rec = await coll.get(recordId2);
14137
+ if (!rec) return false;
14138
+ await coll.put(recordId2, { ...rec, [field]: serial });
14139
+ return true;
14140
+ }
14141
+ });
14142
+ }
14143
+ return this.deferredNumbering;
14144
+ }
14145
+ /**
14146
+ * Run a deferred-numbering pass for `series`: assign gap-free serials to all
14147
+ * records whose store-commit-time interval has settled, in store-time order.
14148
+ * Returns the assignments made. See {@link sequence} / `withDeferredNumbering`.
14149
+ */
14150
+ async runNumberingPass(series) {
14151
+ return this.deferred().runPass(series);
14152
+ }
13860
14153
  async compact(options = {}) {
13861
14154
  return runCompaction({
13862
14155
  adapter: this.adapter,
@@ -17117,6 +17410,9 @@ function assertSafePartitionKey(partitionKey) {
17117
17410
  if (partitionKey.length === 0) {
17118
17411
  throw new ValidationError("partitionKey must be a non-empty string");
17119
17412
  }
17413
+ if (partitionKey === STATE_VAULT_NAME) {
17414
+ throw new ReservedVaultNameError(partitionKey);
17415
+ }
17120
17416
  if (!SAFE_PARTITION_KEY.test(partitionKey)) {
17121
17417
  throw new ValidationError(
17122
17418
  `partitionKey "${partitionKey}" contains characters outside [A-Za-z0-9._-]. Map your records to a store-safe key in sharding.keyOf.`
@@ -17133,6 +17429,7 @@ var init_vault_group = __esm({
17133
17429
  "src/federation/vault-group.ts"() {
17134
17430
  "use strict";
17135
17431
  init_errors();
17432
+ init_constants2();
17136
17433
  init_classify_skip();
17137
17434
  init_cross_vault_live();
17138
17435
  init_aggregate_across();
@@ -17156,15 +17453,38 @@ var init_vault_group = __esm({
17156
17453
  registry;
17157
17454
  sharding;
17158
17455
  template;
17456
+ /** @internal — set when the group is managed (no explicit registry). */
17457
+ stateVault;
17458
+ /** @internal */
17459
+ _attachStateVault(sv) {
17460
+ this.stateVault = sv;
17461
+ }
17159
17462
  /** Deterministic vault name for a partition key, namespaced by the group. */
17160
17463
  shardVaultId(partitionKey) {
17161
17464
  assertSafePartitionKey(partitionKey);
17162
17465
  return `${this.name}${SHARD_SEPARATOR}${partitionKey}`;
17163
17466
  }
17164
- /** All registry rows (hydrates the registry collection first). */
17467
+ /**
17468
+ * @internal — group-qualified registry record key (avoids cross-group key
17469
+ * collisions). Identical to the shard vault id by design — the registry row
17470
+ * for a shard is keyed by that shard's vault id — so it delegates to
17471
+ * `shardVaultId`, reusing its partition-key validation.
17472
+ */
17473
+ registryId(partitionKey) {
17474
+ return this.shardVaultId(partitionKey);
17475
+ }
17476
+ /**
17477
+ * Registry rows for THIS group (hydrates the registry collection first).
17478
+ * The registry may be shared across groups (the auto-wired StateManagement
17479
+ * vault holds one `vaultRegistry` for the whole instance), so rows are
17480
+ * filtered by `group` — without this, a group's fan-out reads would leak
17481
+ * across into other groups' shards. Mirrors the `${group}--` scoping that
17482
+ * `liveBinding().isRelevant` already applies to the reactive path.
17483
+ */
17165
17484
  async allRows() {
17166
17485
  await this.registry.list();
17167
- return this.registry.query().toArray();
17486
+ const rows = this.registry.query().toArray();
17487
+ return rows.filter((r) => r.group === this.name);
17168
17488
  }
17169
17489
  /** Open an existing shard and apply the template. */
17170
17490
  async openShard(partitionKey) {
@@ -17182,19 +17502,32 @@ var init_vault_group = __esm({
17182
17502
  */
17183
17503
  async createShard(partitionKey) {
17184
17504
  const vaultId = this.shardVaultId(partitionKey);
17185
- const row = await this.registry.get(partitionKey);
17505
+ const row = await this.registry.get(this.registryId(partitionKey));
17186
17506
  const provisioned = await this.db._shardVaultProvisioned(vaultId);
17187
17507
  if (row && !provisioned) throw new ShardProvisioningError(vaultId, partitionKey);
17188
17508
  if (row && provisioned) return this.openShard(partitionKey);
17189
17509
  const vault = await this.db.openVault(vaultId);
17190
17510
  this.template.configure(vault);
17191
- await this.registry.put(partitionKey, {
17511
+ await this.registry.put(this.registryId(partitionKey), {
17192
17512
  vaultId,
17193
17513
  partitionKey,
17194
17514
  templateName: this.sharding.vaultTemplate,
17195
17515
  schemaVersion: this.template.version,
17196
- createdAt: Date.now()
17516
+ createdAt: Date.now(),
17517
+ group: this.name
17197
17518
  });
17519
+ if (this.stateVault) {
17520
+ try {
17521
+ await this.stateVault.appendEvent({
17522
+ type: "shard-created",
17523
+ group: this.name,
17524
+ vaultId,
17525
+ templateName: this.sharding.vaultTemplate,
17526
+ version: this.template.version
17527
+ });
17528
+ } catch {
17529
+ }
17530
+ }
17198
17531
  return vault;
17199
17532
  }
17200
17533
  /**
@@ -17204,7 +17537,7 @@ var init_vault_group = __esm({
17204
17537
  */
17205
17538
  async shard(partitionKey) {
17206
17539
  const vaultId = this.shardVaultId(partitionKey);
17207
- const row = await this.registry.get(partitionKey);
17540
+ const row = await this.registry.get(this.registryId(partitionKey));
17208
17541
  if (!row) throw new UnknownShardError(partitionKey, this.name);
17209
17542
  const provisioned = await this.db._shardVaultProvisioned(vaultId);
17210
17543
  if (!provisioned) throw new ShardProvisioningError(vaultId, partitionKey);
@@ -17243,7 +17576,7 @@ var init_vault_group = __esm({
17243
17576
  /** Route a write to the shard owning `keyOf(record)`. */
17244
17577
  async put(id, record) {
17245
17578
  const key = this.group.sharding.keyOf(record);
17246
- const row = await this.group.registry.get(key);
17579
+ const row = await this.group.registry.get(this.group.registryId(key));
17247
17580
  let vault;
17248
17581
  if (!row) {
17249
17582
  if (this.group.sharding.autoCreate === false) {
@@ -17369,6 +17702,159 @@ var init_vault_group = __esm({
17369
17702
  }
17370
17703
  });
17371
17704
 
17705
+ // src/federation/schema-manifest.ts
17706
+ function captureBlueprint(configure) {
17707
+ const recorded = [];
17708
+ const collectionStub = new Proxy(
17709
+ {},
17710
+ {
17711
+ get: () => () => collectionStub
17712
+ }
17713
+ );
17714
+ const proxy = new Proxy(
17715
+ {},
17716
+ {
17717
+ get: (_t, prop) => {
17718
+ if (prop === "collection") {
17719
+ return (name, opts) => {
17720
+ recorded.push({
17721
+ name,
17722
+ indexes: opts?.indexes ?? [],
17723
+ persistJsonSchema: !!opts?.persistJsonSchema
17724
+ });
17725
+ return collectionStub;
17726
+ };
17727
+ }
17728
+ return () => proxy;
17729
+ }
17730
+ }
17731
+ );
17732
+ configure(proxy);
17733
+ const sorted = [...recorded].sort((a, b) => a.name.localeCompare(b.name));
17734
+ const indexes = {};
17735
+ const persistJsonSchema = [];
17736
+ for (const c of sorted) {
17737
+ indexes[c.name] = c.indexes;
17738
+ if (c.persistJsonSchema) persistJsonSchema.push(c.name);
17739
+ }
17740
+ return {
17741
+ // `persistJsonSchema` is already name-sorted: it is populated while
17742
+ // iterating `sorted` (collections in name order).
17743
+ collections: sorted.map((c) => c.name),
17744
+ indexes,
17745
+ persistJsonSchema
17746
+ };
17747
+ }
17748
+ function canonical(value) {
17749
+ if (value === null || typeof value !== "object") return JSON.stringify(value);
17750
+ if (Array.isArray(value)) return `[${value.map(canonical).join(",")}]`;
17751
+ const obj = value;
17752
+ const keys = Object.keys(obj).sort();
17753
+ return `{${keys.map((k) => `${JSON.stringify(k)}:${canonical(obj[k])}`).join(",")}}`;
17754
+ }
17755
+ async function fingerprintBlueprint(bp) {
17756
+ return sha256Hex2(new TextEncoder().encode(canonical(bp)));
17757
+ }
17758
+ var init_schema_manifest = __esm({
17759
+ "src/federation/schema-manifest.ts"() {
17760
+ "use strict";
17761
+ init_crypto();
17762
+ }
17763
+ });
17764
+
17765
+ // src/federation/state-vault.ts
17766
+ var state_vault_exports = {};
17767
+ __export(state_vault_exports, {
17768
+ STATE_VAULT_NAME: () => STATE_VAULT_NAME,
17769
+ StateManagementVault: () => StateManagementVault
17770
+ });
17771
+ var REGISTRY, MANIFEST, EVENTS, StateManagementVault;
17772
+ var init_state_vault = __esm({
17773
+ "src/federation/state-vault.ts"() {
17774
+ "use strict";
17775
+ init_schema_manifest();
17776
+ init_constants2();
17777
+ init_ulid();
17778
+ init_constants2();
17779
+ REGISTRY = "vaultRegistry";
17780
+ MANIFEST = "schemaManifest";
17781
+ EVENTS = "deploymentEvents";
17782
+ StateManagementVault = class _StateManagementVault {
17783
+ constructor(registry, schemaManifest, events) {
17784
+ this.registry = registry;
17785
+ this.schemaManifest = schemaManifest;
17786
+ this.#events = events;
17787
+ }
17788
+ registry;
17789
+ schemaManifest;
17790
+ /**
17791
+ * The append-only deployment-events log is kept truly private so the raw
17792
+ * mutable Collection is never surfaced — events may only be written via
17793
+ * `appendEvent` and read via `queryEvents`. (`registry` and
17794
+ * `schemaManifest` are deliberately public: consumers read and write them.)
17795
+ */
17796
+ #events;
17797
+ /** Idempotently open the reserved state vault and bind the three control-plane collections. */
17798
+ static async open(db) {
17799
+ const vault = await db.openVault(STATE_VAULT_NAME);
17800
+ return new _StateManagementVault(
17801
+ vault.collection(REGISTRY),
17802
+ vault.collection(MANIFEST),
17803
+ vault.collection(EVENTS)
17804
+ );
17805
+ }
17806
+ /** Read-only query over the append-only deployment-events log. */
17807
+ queryEvents() {
17808
+ return this.#events.query();
17809
+ }
17810
+ /**
17811
+ * Append a deployment event with a fresh unique (ULID) id. This is the
17812
+ * only write path to the events log; no update/delete is exposed.
17813
+ * Callers should treat failures as non-fatal — this method does not
17814
+ * swallow errors, so wrap the call site in try/catch where appropriate.
17815
+ */
17816
+ async appendEvent(event) {
17817
+ const ts = event.ts ?? Date.now();
17818
+ const id = generateULID();
17819
+ await this.#events.put(id, { ...event, id, ts });
17820
+ }
17821
+ /**
17822
+ * Ensure a manifest row exists for `(templateName, template.version)`.
17823
+ * Safe to call repeatedly: the `fingerprint` is a deterministic hash of
17824
+ * the template's declared shape (stable across calls), though each call
17825
+ * refreshes `recordedAt`.
17826
+ */
17827
+ async recordManifest(templateName, template) {
17828
+ const bp = captureBlueprint(template.configure);
17829
+ const fingerprint = await fingerprintBlueprint(bp);
17830
+ await this.schemaManifest.put(`${templateName}:${template.version}`, {
17831
+ templateName,
17832
+ version: template.version,
17833
+ collections: bp.collections,
17834
+ indexes: bp.indexes,
17835
+ persistJsonSchema: bp.persistJsonSchema,
17836
+ fingerprint,
17837
+ recordedAt: Date.now()
17838
+ });
17839
+ return fingerprint;
17840
+ }
17841
+ /**
17842
+ * True when `template`'s current declared shape does not match the recorded
17843
+ * manifest for `(templateName, template.version)`. Because shards carry no
17844
+ * schema state independent of their template, this catches "a template's
17845
+ * shape changed without bumping `version`" — not independent per-shard drift.
17846
+ * A missing manifest is treated as drift (nothing to verify against).
17847
+ */
17848
+ async detectDrift(templateName, template) {
17849
+ const row = await this.schemaManifest.get(`${templateName}:${template.version}`);
17850
+ if (!row) return true;
17851
+ const current = await fingerprintBlueprint(captureBlueprint(template.configure));
17852
+ return current !== row.fingerprint;
17853
+ }
17854
+ };
17855
+ }
17856
+ });
17857
+
17372
17858
  // src/noydb.ts
17373
17859
  var noydb_exports = {};
17374
17860
  __export(noydb_exports, {
@@ -17428,6 +17914,7 @@ var init_noydb = __esm({
17428
17914
  "src/noydb.ts"() {
17429
17915
  "use strict";
17430
17916
  init_errors();
17917
+ init_constants2();
17431
17918
  init_storage3();
17432
17919
  init_rotate_recover();
17433
17920
  init_peer_recover();
@@ -17767,6 +18254,7 @@ var init_noydb = __esm({
17767
18254
  ...this.options.i18nStrategy !== void 0 ? { i18nStrategy: this.options.i18nStrategy } : {},
17768
18255
  ...this.options.syncStrategy !== void 0 ? { syncStrategy: this.options.syncStrategy } : {},
17769
18256
  ...this.options.guardStrategies !== void 0 ? { guardStrategies: this.options.guardStrategies } : {},
18257
+ ...this.options.numbering !== void 0 ? { numberingConfigs: this.options.numbering } : {},
17770
18258
  locale: opts?.locale,
17771
18259
  // Thread the translator hook so Collection.put() can invoke it
17772
18260
  plaintextTranslator: this.options.plaintextTranslator ? (text, from, to, field, collection) => this.invokeTranslator(text, from, to, field, collection) : void 0,
@@ -17820,7 +18308,8 @@ var init_noydb = __esm({
17820
18308
  ...this.options.historyStrategy !== void 0 ? { historyStrategy: this.options.historyStrategy } : {},
17821
18309
  ...this.options.i18nStrategy !== void 0 ? { i18nStrategy: this.options.i18nStrategy } : {},
17822
18310
  ...this.options.syncStrategy !== void 0 ? { syncStrategy: this.options.syncStrategy } : {},
17823
- ...this.options.guardStrategies !== void 0 ? { guardStrategies: this.options.guardStrategies } : {}
18311
+ ...this.options.guardStrategies !== void 0 ? { guardStrategies: this.options.guardStrategies } : {},
18312
+ ...this.options.numbering !== void 0 ? { numberingConfigs: this.options.numbering } : {}
17824
18313
  });
17825
18314
  this.vaultCache.set(name, comp2);
17826
18315
  return comp2;
@@ -17850,6 +18339,7 @@ var init_noydb = __esm({
17850
18339
  ...this.options.i18nStrategy !== void 0 ? { i18nStrategy: this.options.i18nStrategy } : {},
17851
18340
  ...this.options.syncStrategy !== void 0 ? { syncStrategy: this.options.syncStrategy } : {},
17852
18341
  ...this.options.guardStrategies !== void 0 ? { guardStrategies: this.options.guardStrategies } : {},
18342
+ ...this.options.numbering !== void 0 ? { numberingConfigs: this.options.numbering } : {},
17853
18343
  emitter: this.emitter
17854
18344
  });
17855
18345
  this.vaultCache.set(name, comp);
@@ -18168,10 +18658,39 @@ var init_noydb = __esm({
18168
18658
  */
18169
18659
  async openVaultGroup(name, opts) {
18170
18660
  if (this.closed) throw new ValidationError("Instance is closed");
18661
+ if (name === STATE_VAULT_NAME) throw new ReservedVaultNameError(name);
18171
18662
  const template = this.vaultTemplates.get(opts.sharding.vaultTemplate);
18172
18663
  if (!template) throw new VaultTemplateNotFoundError(opts.sharding.vaultTemplate);
18173
18664
  const { VaultGroup: VaultGroup2 } = await Promise.resolve().then(() => (init_vault_group(), vault_group_exports));
18174
- return new VaultGroup2(this, name, opts.registry, opts.sharding, template);
18665
+ const { StateManagementVault: StateManagementVault2 } = await Promise.resolve().then(() => (init_state_vault(), state_vault_exports));
18666
+ const stateVault = opts.registry ? void 0 : await StateManagementVault2.open(this);
18667
+ const registry = opts.registry ?? stateVault.registry;
18668
+ const group = new VaultGroup2(this, name, registry, opts.sharding, template);
18669
+ if (stateVault) {
18670
+ group._attachStateVault(stateVault);
18671
+ await stateVault.recordManifest(opts.sharding.vaultTemplate, template);
18672
+ try {
18673
+ await stateVault.appendEvent({
18674
+ type: "manifest-recorded",
18675
+ group: name,
18676
+ templateName: opts.sharding.vaultTemplate,
18677
+ version: template.version
18678
+ });
18679
+ await stateVault.appendEvent({ type: "group-opened", group: name });
18680
+ } catch {
18681
+ }
18682
+ }
18683
+ return group;
18684
+ }
18685
+ /**
18686
+ * Open the reserved StateManagement control-plane vault (registry +
18687
+ * schema-manifest + deployment-events). Lazy-loaded so the federation
18688
+ * chunk stays out of the core graph until used.
18689
+ */
18690
+ async openStateManagementVault() {
18691
+ if (this.closed) throw new ValidationError("Instance is closed");
18692
+ const { StateManagementVault: StateManagementVault2 } = await Promise.resolve().then(() => (init_state_vault(), state_vault_exports));
18693
+ return StateManagementVault2.open(this);
18175
18694
  }
18176
18695
  /**
18177
18696
  * @internal — true when an encrypted shard vault is provisioned