@noy-db/hub 0.2.0-pre.9 → 0.3.0-pre.2

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 (541) hide show
  1. package/README.md +129 -3
  2. package/dist/adapter/index.d.ts +5 -0
  3. package/dist/adapter/index.js +15 -0
  4. package/dist/aggregate/index.d.ts +6 -2
  5. package/dist/aggregate/index.js +24 -16
  6. package/dist/aggregate/index.js.map +1 -1
  7. package/dist/api-RW3KP7WU.js +14 -0
  8. package/dist/as/index.d.ts +7 -0
  9. package/dist/as/index.js +24 -0
  10. package/dist/at/index.d.ts +5 -0
  11. package/dist/at/index.js +1 -0
  12. package/dist/attestation/index.d.ts +15 -47
  13. package/dist/attestation/index.js +54 -10
  14. package/dist/attestation/index.js.map +1 -1
  15. package/dist/backup-KMJQ66MF.js +219 -0
  16. package/dist/backup-KMJQ66MF.js.map +1 -0
  17. package/dist/blobs/index.d.ts +6 -8
  18. package/dist/blobs/index.js +19 -12
  19. package/dist/blobs/index.js.map +1 -1
  20. package/dist/bundle/index.d.ts +16 -70
  21. package/dist/bundle/index.js +39 -476
  22. package/dist/bundle/index.js.map +1 -1
  23. package/dist/{ulid-CJ8RzRrm.d.ts → bundle-PwBGkhpe.d.ts} +31 -86
  24. package/dist/by/index.d.ts +1 -0
  25. package/dist/by/index.js +11 -0
  26. package/dist/cargo/index.d.ts +9 -0
  27. package/dist/cargo/index.js +89 -0
  28. package/dist/chunk-26LGBE4T.js +42 -0
  29. package/dist/chunk-26LGBE4T.js.map +1 -0
  30. package/dist/{chunk-K3DK3NU5.js → chunk-3YFXJ3ZP.js} +20 -5
  31. package/dist/chunk-3YFXJ3ZP.js.map +1 -0
  32. package/dist/chunk-4Q6HSHHL.js +90 -0
  33. package/dist/chunk-4Q6HSHHL.js.map +1 -0
  34. package/dist/chunk-5LUY7UTV.js +380 -0
  35. package/dist/chunk-5LUY7UTV.js.map +1 -0
  36. package/dist/chunk-5N6CZTCY.js +367 -0
  37. package/dist/chunk-5N6CZTCY.js.map +1 -0
  38. package/dist/chunk-5O3AOPDT.js +992 -0
  39. package/dist/chunk-5O3AOPDT.js.map +1 -0
  40. package/dist/chunk-5R3ERCDH.js +239 -0
  41. package/dist/chunk-5R3ERCDH.js.map +1 -0
  42. package/dist/chunk-5TDJ56JE.js +32 -0
  43. package/dist/chunk-5TDJ56JE.js.map +1 -0
  44. package/dist/{chunk-T7JEBOGN.js → chunk-62QYRORB.js} +18 -11
  45. package/dist/chunk-62QYRORB.js.map +1 -0
  46. package/dist/{chunk-J66GRPNH.js → chunk-6S7T6WC4.js} +2 -2
  47. package/dist/chunk-6S7T6WC4.js.map +1 -0
  48. package/dist/chunk-76722EBH.js +451 -0
  49. package/dist/chunk-76722EBH.js.map +1 -0
  50. package/dist/{chunk-Z6FNBOTC.js → chunk-AIWULCUO.js} +13 -17
  51. package/dist/chunk-AIWULCUO.js.map +1 -0
  52. package/dist/{chunk-O3VZPBZG.js → chunk-AQTBSL7R.js} +47 -11
  53. package/dist/chunk-AQTBSL7R.js.map +1 -0
  54. package/dist/chunk-AURFOK3D.js +35 -0
  55. package/dist/chunk-AURFOK3D.js.map +1 -0
  56. package/dist/{chunk-53XBRIRT.js → chunk-AXRXJTE2.js} +9 -9
  57. package/dist/chunk-AXRXJTE2.js.map +1 -0
  58. package/dist/chunk-AZAOEIKW.js +155 -0
  59. package/dist/chunk-AZAOEIKW.js.map +1 -0
  60. package/dist/{chunk-HNRHLRDC.js → chunk-BG3SPSR4.js} +3 -3
  61. package/dist/chunk-BG3SPSR4.js.map +1 -0
  62. package/dist/chunk-BGIZAFY7.js +1 -0
  63. package/dist/chunk-CHFZDSE4.js +1 -0
  64. package/dist/{chunk-DJHHA6XH.js → chunk-CMGR4ZEW.js} +50 -20
  65. package/dist/chunk-CMGR4ZEW.js.map +1 -0
  66. package/dist/chunk-CWPPNPOH.js +23 -0
  67. package/dist/chunk-CWPPNPOH.js.map +1 -0
  68. package/dist/{chunk-QODLLGQ7.js → chunk-DFEMTNPJ.js} +371 -38
  69. package/dist/chunk-DFEMTNPJ.js.map +1 -0
  70. package/dist/{chunk-ZYWZWG6G.js → chunk-DGDI2D4M.js} +10 -10
  71. package/dist/chunk-DGDI2D4M.js.map +1 -0
  72. package/dist/{chunk-SYMWGEET.js → chunk-EIZUR2XW.js} +3 -3
  73. package/dist/chunk-EIZUR2XW.js.map +1 -0
  74. package/dist/{chunk-BVRYKATC.js → chunk-FISN7WE4.js} +36 -33
  75. package/dist/chunk-FISN7WE4.js.map +1 -0
  76. package/dist/chunk-GHVIKOHT.js +1 -0
  77. package/dist/chunk-GYGWYIOZ.js +200 -0
  78. package/dist/chunk-GYGWYIOZ.js.map +1 -0
  79. package/dist/chunk-HCIPRAGS.js +45 -0
  80. package/dist/chunk-HCIPRAGS.js.map +1 -0
  81. package/dist/{chunk-PX35GA7L.js → chunk-I2NOIW44.js} +10 -10
  82. package/dist/chunk-I2NOIW44.js.map +1 -0
  83. package/dist/{chunk-OIF6LZUR.js → chunk-I3TIKTJO.js} +3 -3
  84. package/dist/chunk-I3TIKTJO.js.map +1 -0
  85. package/dist/chunk-I7FD46FF.js +9 -0
  86. package/dist/chunk-I7FD46FF.js.map +1 -0
  87. package/dist/chunk-IAGBDSCS.js +40 -0
  88. package/dist/chunk-IAGBDSCS.js.map +1 -0
  89. package/dist/{chunk-JWRVQKRZ.js → chunk-IELYAOGG.js} +6 -18
  90. package/dist/chunk-IELYAOGG.js.map +1 -0
  91. package/dist/chunk-IGUYVGGI.js +205 -0
  92. package/dist/chunk-IGUYVGGI.js.map +1 -0
  93. package/dist/{chunk-U26HQ6KJ.js → chunk-IO6GRPT6.js} +4 -4
  94. package/dist/chunk-IO6GRPT6.js.map +1 -0
  95. package/dist/chunk-IPB7FTQX.js +273 -0
  96. package/dist/chunk-IPB7FTQX.js.map +1 -0
  97. package/dist/chunk-ITNUCOXM.js +148 -0
  98. package/dist/chunk-ITNUCOXM.js.map +1 -0
  99. package/dist/{chunk-WPLVTJ5D.js → chunk-IUEN57TV.js} +10 -10
  100. package/dist/chunk-IUEN57TV.js.map +1 -0
  101. package/dist/{chunk-DL3HWOQ5.js → chunk-JNUWZ6D3.js} +9 -9
  102. package/dist/chunk-JNUWZ6D3.js.map +1 -0
  103. package/dist/chunk-K2WCO3NX.js +1 -0
  104. package/dist/chunk-KVOXU4T5.js +30 -0
  105. package/dist/chunk-KVOXU4T5.js.map +1 -0
  106. package/dist/chunk-KXGNJJXB.js +135 -0
  107. package/dist/chunk-KXGNJJXB.js.map +1 -0
  108. package/dist/chunk-LB7FD65R.js +163 -0
  109. package/dist/chunk-LB7FD65R.js.map +1 -0
  110. package/dist/{chunk-22DWZL57.js → chunk-LFLXAY2W.js} +43 -218
  111. package/dist/chunk-LFLXAY2W.js.map +1 -0
  112. package/dist/chunk-LMTH2RM6.js +129 -0
  113. package/dist/chunk-LMTH2RM6.js.map +1 -0
  114. package/dist/{aggregate/index.cjs → chunk-LV7M27WM.js} +390 -219
  115. package/dist/chunk-LV7M27WM.js.map +1 -0
  116. package/dist/{chunk-PE2FR4J3.js → chunk-LXQT4WMP.js} +16 -18
  117. package/dist/chunk-LXQT4WMP.js.map +1 -0
  118. package/dist/chunk-M2YKN37S.js +524 -0
  119. package/dist/chunk-M2YKN37S.js.map +1 -0
  120. package/dist/chunk-M6OST55S.js +14 -0
  121. package/dist/chunk-M6OST55S.js.map +1 -0
  122. package/dist/{chunk-F3GDRNUT.js → chunk-MD3Y6J3L.js} +35 -69
  123. package/dist/chunk-MD3Y6J3L.js.map +1 -0
  124. package/dist/{chunk-XJFLDA7A.js → chunk-MTMJVJ5W.js} +8 -7
  125. package/dist/chunk-MTMJVJ5W.js.map +1 -0
  126. package/dist/{chunk-DFMLEQZB.js → chunk-NF5JWERG.js} +5 -10
  127. package/dist/chunk-NF5JWERG.js.map +1 -0
  128. package/dist/{chunk-DO7C2TOG.js → chunk-PKHL44ER.js} +3 -3
  129. package/dist/{chunk-DO7C2TOG.js.map → chunk-PKHL44ER.js.map} +1 -1
  130. package/dist/{chunk-6CME4UEK.js → chunk-PSHOXR6C.js} +7008 -4827
  131. package/dist/chunk-PSHOXR6C.js.map +1 -0
  132. package/dist/chunk-PSMV73A5.js +117 -0
  133. package/dist/chunk-PSMV73A5.js.map +1 -0
  134. package/dist/chunk-PY4KJPYU.js +9 -0
  135. package/dist/chunk-PY4KJPYU.js.map +1 -0
  136. package/dist/chunk-PZ5AY32C.js +10 -0
  137. package/dist/{chunk-DE6GKS6G.js → chunk-Q7SS3IME.js} +50 -9
  138. package/dist/chunk-Q7SS3IME.js.map +1 -0
  139. package/dist/chunk-QHJW5EXU.js +54 -0
  140. package/dist/chunk-QHJW5EXU.js.map +1 -0
  141. package/dist/chunk-QZISFCVG.js +233 -0
  142. package/dist/chunk-QZISFCVG.js.map +1 -0
  143. package/dist/{chunk-NONAAENK.js → chunk-RUEKROOS.js} +11 -4
  144. package/dist/chunk-RUEKROOS.js.map +1 -0
  145. package/dist/chunk-RUIMKQTA.js +23 -0
  146. package/dist/chunk-RUIMKQTA.js.map +1 -0
  147. package/dist/{chunk-TFBP23BX.js → chunk-SKF73JOP.js} +66 -7
  148. package/dist/chunk-SKF73JOP.js.map +1 -0
  149. package/dist/chunk-SM3AVUHC.js +42 -0
  150. package/dist/chunk-SM3AVUHC.js.map +1 -0
  151. package/dist/{chunk-ML236QKC.js → chunk-SMXWYP24.js} +5 -5
  152. package/dist/chunk-SMXWYP24.js.map +1 -0
  153. package/dist/chunk-SRB2XEWB.js +148 -0
  154. package/dist/chunk-SRB2XEWB.js.map +1 -0
  155. package/dist/chunk-SVLR4POP.js +64 -0
  156. package/dist/chunk-SVLR4POP.js.map +1 -0
  157. package/dist/chunk-TA66UMI4.js +123 -0
  158. package/dist/chunk-TA66UMI4.js.map +1 -0
  159. package/dist/chunk-TEILUWOI.js +664 -0
  160. package/dist/chunk-TEILUWOI.js.map +1 -0
  161. package/dist/chunk-TJYQIGAP.js +82 -0
  162. package/dist/chunk-TJYQIGAP.js.map +1 -0
  163. package/dist/{chunk-H2X3ISXG.js → chunk-UAG5KWVA.js} +7 -7
  164. package/dist/chunk-UAG5KWVA.js.map +1 -0
  165. package/dist/chunk-UDRIWL7A.js +382 -0
  166. package/dist/chunk-UDRIWL7A.js.map +1 -0
  167. package/dist/{chunk-2GLDA55J.js → chunk-UIU2THRG.js} +498 -133
  168. package/dist/chunk-UIU2THRG.js.map +1 -0
  169. package/dist/{chunk-3YPCK6JX.js → chunk-UPJNJGGA.js} +165 -423
  170. package/dist/chunk-UPJNJGGA.js.map +1 -0
  171. package/dist/chunk-UV5MFVO3.js +21 -0
  172. package/dist/chunk-UV5MFVO3.js.map +1 -0
  173. package/dist/{chunk-2WUSG3IT.js → chunk-V7RWQRG7.js} +5 -5
  174. package/dist/chunk-V7RWQRG7.js.map +1 -0
  175. package/dist/{chunk-VTKGMEPP.js → chunk-VCTFO5CO.js} +13 -3
  176. package/dist/chunk-VCTFO5CO.js.map +1 -0
  177. package/dist/{chunk-5T22KDPN.js → chunk-VFQGRQIH.js} +8 -8
  178. package/dist/chunk-VFQGRQIH.js.map +1 -0
  179. package/dist/{chunk-2QR2PQTT.js → chunk-VQNJ7UZL.js} +5 -3
  180. package/dist/chunk-VQNJ7UZL.js.map +1 -0
  181. package/dist/{chunk-DONMZAD2.js → chunk-WWGT2MDV.js} +43 -165
  182. package/dist/chunk-WWGT2MDV.js.map +1 -0
  183. package/dist/{chunk-EMIGCR7X.js → chunk-WXSYDNBT.js} +2 -2
  184. package/dist/chunk-WXSYDNBT.js.map +1 -0
  185. package/dist/chunk-WYSO2NIH.js +30 -0
  186. package/dist/chunk-WYSO2NIH.js.map +1 -0
  187. package/dist/chunk-XXYIOFUB.js +164 -0
  188. package/dist/chunk-XXYIOFUB.js.map +1 -0
  189. package/dist/{chunk-3BFJOWSU.js → chunk-Y22T3KQE.js} +35 -7
  190. package/dist/chunk-Y22T3KQE.js.map +1 -0
  191. package/dist/{chunk-A3JMGXPG.js → chunk-YMUGBZN2.js} +2 -2
  192. package/dist/chunk-YMUGBZN2.js.map +1 -0
  193. package/dist/{chunk-I5FOWO4J.js → chunk-ZCGAHGUS.js} +52 -73
  194. package/dist/chunk-ZCGAHGUS.js.map +1 -0
  195. package/dist/{chunk-FZU343FL.js → chunk-ZJADGNYF.js} +2 -2
  196. package/dist/chunk-ZJADGNYF.js.map +1 -0
  197. package/dist/{chunk-B6PB7JLN.js → chunk-ZYUC53LT.js} +427 -6
  198. package/dist/chunk-ZYUC53LT.js.map +1 -0
  199. package/dist/collection-facade-GQAOGJP2.js +33 -0
  200. package/dist/consent/index.d.ts +5 -7
  201. package/dist/consent/index.js +7 -5
  202. package/dist/consent/index.js.map +1 -1
  203. package/dist/crdt/index.d.ts +6 -2
  204. package/dist/crdt/index.js +3 -2
  205. package/dist/crdt/index.js.map +1 -1
  206. package/dist/decrypt-partition-IHtxEnTi.d.ts +21 -0
  207. package/dist/delegation-UL5HKLER.js +19 -0
  208. package/dist/derivations/index.d.ts +7 -9
  209. package/dist/derivations/index.js +11 -6
  210. package/dist/describe/index.d.ts +1 -0
  211. package/dist/describe/index.js +1 -0
  212. package/dist/describe-Ccd1hS7a.d.ts +143 -0
  213. package/dist/{dev-unlock-B4kDxep_.d.ts → dev-unlock-h0K-UZTk.d.ts} +1 -1
  214. package/dist/discriminant-BN9REW3o.d.ts +60 -0
  215. package/dist/enclave-UL5LW66V.js +88 -0
  216. package/dist/executor-2FWQRLMG.js +15 -0
  217. package/dist/executor-QZ7BXICW.js +9 -0
  218. package/dist/executor-Z5ZLJVTV.js +9 -0
  219. package/dist/export-accessible-KRV5W4GH.js +17 -0
  220. package/dist/extract-partition-GLKBOXFQ.js +30 -0
  221. package/dist/{fanout-sidecar-OKPMMPLG.js → fanout-sidecar-GF3DJ6KR.js} +34 -14
  222. package/dist/fanout-sidecar-GF3DJ6KR.js.map +1 -0
  223. package/dist/forget/index.d.ts +36 -0
  224. package/dist/forget/index.js +19 -0
  225. package/dist/forget/index.js.map +1 -0
  226. package/dist/guards/index.d.ts +13 -9
  227. package/dist/guards/index.js +12 -5
  228. package/dist/{hash-DdpVypUp.d.cts → hash-CdSr06sm.d.ts} +5 -1
  229. package/dist/history/index.d.ts +6 -8
  230. package/dist/history/index.js +19 -12
  231. package/dist/history/index.js.map +1 -1
  232. package/dist/i18n/index.d.ts +5 -7
  233. package/dist/i18n/index.js +104 -15
  234. package/dist/i18n/index.js.map +1 -1
  235. package/dist/in/index.d.ts +5 -0
  236. package/dist/in/index.js +1 -0
  237. package/dist/in/index.js.map +1 -0
  238. package/dist/index-B9QdHytu.d.ts +123 -0
  239. package/dist/index-CGLLRtFc.d.ts +123 -0
  240. package/dist/{types-Df28QFKb.d.ts → index-_6At2_9_.d.ts} +16270 -8358
  241. package/dist/index.d.ts +1088 -450
  242. package/dist/index.js +1165 -293
  243. package/dist/index.js.map +1 -1
  244. package/dist/indexing/index.d.ts +6 -3
  245. package/dist/indexing/index.js +6 -5
  246. package/dist/indexing/index.js.map +1 -1
  247. package/dist/issue-Y6UVIR43.js +13 -0
  248. package/dist/issue-Y6UVIR43.js.map +1 -0
  249. package/dist/kernel/index.d.ts +32 -0
  250. package/dist/kernel/index.js +53 -0
  251. package/dist/kernel/index.js.map +1 -0
  252. package/dist/{ledger-TMRZYNVJ.js → ledger-RYI35CDS.js} +12 -9
  253. package/dist/ledger-RYI35CDS.js.map +1 -0
  254. package/dist/liberate-CRPZEV7O.js +18 -0
  255. package/dist/liberate-CRPZEV7O.js.map +1 -0
  256. package/dist/materialized-views/index.d.ts +6 -19
  257. package/dist/materialized-views/index.js +16 -12
  258. package/dist/mime-magic-B4RoFj3B.d.ts +103 -0
  259. package/dist/noydb-LDEBLNHY.js +50 -0
  260. package/dist/noydb-LDEBLNHY.js.map +1 -0
  261. package/dist/on/index.d.ts +5 -0
  262. package/dist/on/index.js +11 -0
  263. package/dist/on/index.js.map +1 -0
  264. package/dist/overlay-views/index.d.ts +27 -11
  265. package/dist/overlay-views/index.js +7 -6
  266. package/dist/periods/index.d.ts +5 -7
  267. package/dist/periods/index.js +13 -9
  268. package/dist/pod/index.d.ts +63 -0
  269. package/dist/pod/index.js +61 -0
  270. package/dist/pod/index.js.map +1 -0
  271. package/dist/policy-IXK4FVXP.js +41 -0
  272. package/dist/policy-IXK4FVXP.js.map +1 -0
  273. package/dist/portability/index.d.ts +20 -0
  274. package/dist/portability/index.js +43 -0
  275. package/dist/portability/index.js.map +1 -0
  276. package/dist/{public-envelope-BW6OXORV.js → public-envelope-JHDQCPSX.js} +6 -5
  277. package/dist/public-envelope-JHDQCPSX.js.map +1 -0
  278. package/dist/query/index.d.ts +5 -3
  279. package/dist/query/index.js +21 -13
  280. package/dist/read-only-facade-5ADRJVTM.js +8 -0
  281. package/dist/read-only-facade-5ADRJVTM.js.map +1 -0
  282. package/dist/registry-45RJNWGU.js +9 -0
  283. package/dist/registry-45RJNWGU.js.map +1 -0
  284. package/dist/registry-5GRV5VXI.js +13 -0
  285. package/dist/registry-5GRV5VXI.js.map +1 -0
  286. package/dist/registry-VW6P6A3J.js +8 -0
  287. package/dist/registry-VW6P6A3J.js.map +1 -0
  288. package/dist/registry-WEUCHBO4.js +11 -0
  289. package/dist/registry-WEUCHBO4.js.map +1 -0
  290. package/dist/request-withdrawal-GBPH2FDY.js +25 -0
  291. package/dist/request-withdrawal-GBPH2FDY.js.map +1 -0
  292. package/dist/revoke-TUFRGI6S.js +18 -0
  293. package/dist/revoke-TUFRGI6S.js.map +1 -0
  294. package/dist/sealed-record/index.d.ts +69 -0
  295. package/dist/sealed-record/index.js +65 -0
  296. package/dist/sealed-record/index.js.map +1 -0
  297. package/dist/session/index.d.ts +6 -8
  298. package/dist/session/index.js +7 -5
  299. package/dist/session/index.js.map +1 -1
  300. package/dist/shadow/index.d.ts +5 -7
  301. package/dist/shadow/index.js +4 -3
  302. package/dist/shadow/index.js.map +1 -1
  303. package/dist/{signer-72QAUSVW.js → signer-PNKTBVF7.js} +6 -5
  304. package/dist/signer-PNKTBVF7.js.map +1 -0
  305. package/dist/snapshots/index.d.ts +6 -8
  306. package/dist/snapshots/index.js +13 -11
  307. package/dist/snapshots/index.js.map +1 -1
  308. package/dist/{stale-6ZDBTQT7.js → stale-3JWHNDIY.js} +3 -2
  309. package/dist/stale-3JWHNDIY.js.map +1 -0
  310. package/dist/store-coordination-provider-3I7XWZZK.js +142 -0
  311. package/dist/store-coordination-provider-3I7XWZZK.js.map +1 -0
  312. package/dist/subject-index-O75wKshW.d.ts +362 -0
  313. package/dist/sync/index.d.ts +4 -6
  314. package/dist/sync/index.js +7 -6
  315. package/dist/sync/index.js.map +1 -1
  316. package/dist/team/index.d.ts +5 -7
  317. package/dist/team/index.js +20 -16
  318. package/dist/tiers/index.d.ts +5 -0
  319. package/dist/tiers/index.js +33 -0
  320. package/dist/tiers/index.js.map +1 -0
  321. package/dist/to/index.d.ts +5 -0
  322. package/dist/to/index.js +17 -0
  323. package/dist/to/index.js.map +1 -0
  324. package/dist/transition-guard-DqodPNKw.d.ts +165 -0
  325. package/dist/tx/index.d.ts +23 -9
  326. package/dist/tx/index.js +13 -8
  327. package/dist/tx/index.js.map +1 -1
  328. package/dist/ui/index.d.ts +1 -0
  329. package/dist/ui/index.js +1 -0
  330. package/dist/ui/index.js.map +1 -0
  331. package/dist/ulid-DRH25k3y.d.ts +66 -0
  332. package/dist/ulid-PTAIMDG4.js +10 -0
  333. package/dist/ulid-PTAIMDG4.js.map +1 -0
  334. package/dist/util/index.d.ts +2 -0
  335. package/dist/util/index.js +7 -2
  336. package/dist/util/index.js.map +1 -1
  337. package/dist/vault-diff-BtpiBvic.d.ts +147 -0
  338. package/dist/with/index.d.ts +38 -0
  339. package/dist/with/index.js +25 -0
  340. package/dist/with/index.js.map +1 -0
  341. package/dist/{with-materialized-view-BLkQxoQN.d.ts → with-materialized-view-DMmWtYfJ.d.ts} +1 -1
  342. package/dist/{with-overlayed-view-CRsSEwHR.d.ts → with-overlayed-view-D_IB2nkM.d.ts} +2 -3
  343. package/dist/with-rollup-em2wxoHP.d.ts +47 -0
  344. package/dist/withdraw-accessible-FFS46EOD.js +22 -0
  345. package/dist/withdraw-accessible-FFS46EOD.js.map +1 -0
  346. package/dist/zod-HAJM7LMS.js +14763 -0
  347. package/dist/zod-HAJM7LMS.js.map +1 -0
  348. package/package.json +121 -201
  349. package/dist/aggregate/index.cjs.map +0 -1
  350. package/dist/aggregate/index.d.cts +0 -38
  351. package/dist/attestation/index.cjs +0 -305
  352. package/dist/attestation/index.cjs.map +0 -1
  353. package/dist/attestation/index.d.cts +0 -52
  354. package/dist/blobs/index.cjs +0 -1480
  355. package/dist/blobs/index.cjs.map +0 -1
  356. package/dist/blobs/index.d.cts +0 -46
  357. package/dist/bundle/index.cjs +0 -19264
  358. package/dist/bundle/index.cjs.map +0 -1
  359. package/dist/bundle/index.d.cts +0 -176
  360. package/dist/chunk-22DWZL57.js.map +0 -1
  361. package/dist/chunk-2GLDA55J.js.map +0 -1
  362. package/dist/chunk-2QR2PQTT.js.map +0 -1
  363. package/dist/chunk-2WUSG3IT.js.map +0 -1
  364. package/dist/chunk-3BFJOWSU.js.map +0 -1
  365. package/dist/chunk-3YPCK6JX.js.map +0 -1
  366. package/dist/chunk-53XBRIRT.js.map +0 -1
  367. package/dist/chunk-5T22KDPN.js.map +0 -1
  368. package/dist/chunk-5XHKQ56N.js +0 -340
  369. package/dist/chunk-5XHKQ56N.js.map +0 -1
  370. package/dist/chunk-6CME4UEK.js.map +0 -1
  371. package/dist/chunk-6STK5TQP.js +0 -139
  372. package/dist/chunk-6STK5TQP.js.map +0 -1
  373. package/dist/chunk-A3JMGXPG.js.map +0 -1
  374. package/dist/chunk-B6PB7JLN.js.map +0 -1
  375. package/dist/chunk-BVRYKATC.js.map +0 -1
  376. package/dist/chunk-DE6GKS6G.js.map +0 -1
  377. package/dist/chunk-DFMLEQZB.js.map +0 -1
  378. package/dist/chunk-DJHHA6XH.js.map +0 -1
  379. package/dist/chunk-DL3HWOQ5.js.map +0 -1
  380. package/dist/chunk-DONMZAD2.js.map +0 -1
  381. package/dist/chunk-EMIGCR7X.js.map +0 -1
  382. package/dist/chunk-F3GDRNUT.js.map +0 -1
  383. package/dist/chunk-FZU343FL.js.map +0 -1
  384. package/dist/chunk-H2X3ISXG.js.map +0 -1
  385. package/dist/chunk-HNRHLRDC.js.map +0 -1
  386. package/dist/chunk-I5FOWO4J.js.map +0 -1
  387. package/dist/chunk-J66GRPNH.js.map +0 -1
  388. package/dist/chunk-JWRVQKRZ.js.map +0 -1
  389. package/dist/chunk-K3DK3NU5.js.map +0 -1
  390. package/dist/chunk-ML236QKC.js.map +0 -1
  391. package/dist/chunk-NONAAENK.js.map +0 -1
  392. package/dist/chunk-O3VZPBZG.js.map +0 -1
  393. package/dist/chunk-OIF6LZUR.js.map +0 -1
  394. package/dist/chunk-OQ6PIGHA.js +0 -19
  395. package/dist/chunk-OQ6PIGHA.js.map +0 -1
  396. package/dist/chunk-PE2FR4J3.js.map +0 -1
  397. package/dist/chunk-PP6W64Y3.js +0 -275
  398. package/dist/chunk-PP6W64Y3.js.map +0 -1
  399. package/dist/chunk-PX35GA7L.js.map +0 -1
  400. package/dist/chunk-QEILDE6R.js +0 -793
  401. package/dist/chunk-QEILDE6R.js.map +0 -1
  402. package/dist/chunk-QODLLGQ7.js.map +0 -1
  403. package/dist/chunk-RAZ4OVLL.js +0 -51
  404. package/dist/chunk-RAZ4OVLL.js.map +0 -1
  405. package/dist/chunk-SYMWGEET.js.map +0 -1
  406. package/dist/chunk-T7JEBOGN.js.map +0 -1
  407. package/dist/chunk-TFBP23BX.js.map +0 -1
  408. package/dist/chunk-TV3YZ35S.js +0 -90
  409. package/dist/chunk-TV3YZ35S.js.map +0 -1
  410. package/dist/chunk-U26HQ6KJ.js.map +0 -1
  411. package/dist/chunk-UF3BUNQZ.js +0 -1
  412. package/dist/chunk-UMLVJTYV.js +0 -20
  413. package/dist/chunk-UMLVJTYV.js.map +0 -1
  414. package/dist/chunk-VTKGMEPP.js.map +0 -1
  415. package/dist/chunk-W6EQLGMB.js +0 -100
  416. package/dist/chunk-W6EQLGMB.js.map +0 -1
  417. package/dist/chunk-WIRRPTFH.js +0 -17
  418. package/dist/chunk-WIRRPTFH.js.map +0 -1
  419. package/dist/chunk-WPLVTJ5D.js.map +0 -1
  420. package/dist/chunk-XJFLDA7A.js.map +0 -1
  421. package/dist/chunk-Z6FNBOTC.js.map +0 -1
  422. package/dist/chunk-ZYWZWG6G.js.map +0 -1
  423. package/dist/consent/index.cjs +0 -204
  424. package/dist/consent/index.cjs.map +0 -1
  425. package/dist/consent/index.d.cts +0 -25
  426. package/dist/crdt/index.cjs +0 -152
  427. package/dist/crdt/index.cjs.map +0 -1
  428. package/dist/crdt/index.d.cts +0 -30
  429. package/dist/crypto-HTZ4FJOP.js +0 -44
  430. package/dist/delegation-RI54P6I5.js +0 -17
  431. package/dist/derivations/index.cjs +0 -351
  432. package/dist/derivations/index.cjs.map +0 -1
  433. package/dist/derivations/index.d.cts +0 -72
  434. package/dist/dev-unlock-BIoEFbwm.d.cts +0 -263
  435. package/dist/executor-5PNY7LGW.js +0 -8
  436. package/dist/executor-B4QIYGZX.js +0 -8
  437. package/dist/executor-BWXXDQ7K.js +0 -11
  438. package/dist/fanout-sidecar-OKPMMPLG.js.map +0 -1
  439. package/dist/guards/index.cjs +0 -322
  440. package/dist/guards/index.cjs.map +0 -1
  441. package/dist/guards/index.d.cts +0 -31
  442. package/dist/hash-HJqD14vS.d.ts +0 -63
  443. package/dist/history/index.cjs +0 -1222
  444. package/dist/history/index.cjs.map +0 -1
  445. package/dist/history/index.d.cts +0 -63
  446. package/dist/i18n/index.cjs +0 -1100
  447. package/dist/i18n/index.cjs.map +0 -1
  448. package/dist/i18n/index.d.cts +0 -39
  449. package/dist/index-4fBVt8j9.d.cts +0 -2387
  450. package/dist/index-D8I_pyJD.d.ts +0 -2387
  451. package/dist/index.cjs +0 -24487
  452. package/dist/index.cjs.map +0 -1
  453. package/dist/index.d.cts +0 -776
  454. package/dist/indexing/index.cjs +0 -742
  455. package/dist/indexing/index.cjs.map +0 -1
  456. package/dist/indexing/index.d.cts +0 -36
  457. package/dist/issue-VGDPP4B5.js +0 -12
  458. package/dist/lazy-builder-7tIpFyWN.d.ts +0 -304
  459. package/dist/lazy-builder-wY4pMCEe.d.cts +0 -304
  460. package/dist/materialized-views/index.cjs +0 -854
  461. package/dist/materialized-views/index.cjs.map +0 -1
  462. package/dist/materialized-views/index.d.cts +0 -186
  463. package/dist/mime-magic-CBBSOkjm.d.cts +0 -50
  464. package/dist/mime-magic-CBBSOkjm.d.ts +0 -50
  465. package/dist/noydb-G725ZSZG.js +0 -34
  466. package/dist/overlay-views/index.cjs +0 -359
  467. package/dist/overlay-views/index.cjs.map +0 -1
  468. package/dist/overlay-views/index.d.cts +0 -82
  469. package/dist/periods/index.cjs +0 -1041
  470. package/dist/periods/index.cjs.map +0 -1
  471. package/dist/periods/index.d.cts +0 -22
  472. package/dist/predicate-BSAGEyu5.d.cts +0 -209
  473. package/dist/predicate-BSAGEyu5.d.ts +0 -209
  474. package/dist/query/index.cjs +0 -2375
  475. package/dist/query/index.cjs.map +0 -1
  476. package/dist/query/index.d.cts +0 -3
  477. package/dist/read-only-facade-ITU6L7BL.js +0 -7
  478. package/dist/registry-3QP3YKQS.js +0 -8
  479. package/dist/registry-DKEXOJVO.js +0 -7
  480. package/dist/registry-OJIOSBV6.js +0 -10
  481. package/dist/registry-USRVT6YF.js +0 -8
  482. package/dist/revoke-JCC7N56X.js +0 -17
  483. package/dist/session/index.cjs +0 -495
  484. package/dist/session/index.cjs.map +0 -1
  485. package/dist/session/index.d.cts +0 -46
  486. package/dist/shadow/index.cjs +0 -133
  487. package/dist/shadow/index.cjs.map +0 -1
  488. package/dist/shadow/index.d.cts +0 -17
  489. package/dist/snapshots/index.cjs +0 -937
  490. package/dist/snapshots/index.cjs.map +0 -1
  491. package/dist/snapshots/index.d.cts +0 -28
  492. package/dist/store/index.cjs +0 -1083
  493. package/dist/store/index.cjs.map +0 -1
  494. package/dist/store/index.d.cts +0 -492
  495. package/dist/store/index.d.ts +0 -492
  496. package/dist/store/index.js +0 -37
  497. package/dist/strategy-BSxFXGzb.d.cts +0 -110
  498. package/dist/strategy-BSxFXGzb.d.ts +0 -110
  499. package/dist/strategy-DSTrsZ8t.d.cts +0 -601
  500. package/dist/strategy-DSTrsZ8t.d.ts +0 -601
  501. package/dist/sync/index.cjs +0 -1062
  502. package/dist/sync/index.cjs.map +0 -1
  503. package/dist/sync/index.d.cts +0 -43
  504. package/dist/team/index.cjs +0 -2798
  505. package/dist/team/index.cjs.map +0 -1
  506. package/dist/team/index.d.cts +0 -118
  507. package/dist/tx/index.cjs +0 -544
  508. package/dist/tx/index.cjs.map +0 -1
  509. package/dist/tx/index.d.cts +0 -21
  510. package/dist/types-DyXYr8rE.d.cts +0 -12818
  511. package/dist/ulid-COREQ2RQ.js +0 -9
  512. package/dist/ulid-Drr7ykr6.d.cts +0 -603
  513. package/dist/util/index.cjs +0 -230
  514. package/dist/util/index.cjs.map +0 -1
  515. package/dist/util/index.d.cts +0 -77
  516. package/dist/with-derivation-DFnFByiQ.d.ts +0 -13
  517. package/dist/with-derivation-DU3Sjazm.d.cts +0 -13
  518. package/dist/with-guard-ByyxmEe7.d.cts +0 -18
  519. package/dist/with-guard-qube6BMI.d.ts +0 -18
  520. package/dist/with-materialized-view-BmEToIR1.d.cts +0 -27
  521. package/dist/with-overlayed-view-BMsQQbWm.d.cts +0 -13
  522. /package/dist/{store → adapter}/index.js.map +0 -0
  523. /package/dist/{chunk-UF3BUNQZ.js.map → api-RW3KP7WU.js.map} +0 -0
  524. /package/dist/{crypto-HTZ4FJOP.js.map → as/index.js.map} +0 -0
  525. /package/dist/{delegation-RI54P6I5.js.map → at/index.js.map} +0 -0
  526. /package/dist/{executor-5PNY7LGW.js.map → by/index.js.map} +0 -0
  527. /package/dist/{executor-B4QIYGZX.js.map → cargo/index.js.map} +0 -0
  528. /package/dist/{executor-BWXXDQ7K.js.map → chunk-BGIZAFY7.js.map} +0 -0
  529. /package/dist/{issue-VGDPP4B5.js.map → chunk-CHFZDSE4.js.map} +0 -0
  530. /package/dist/{ledger-TMRZYNVJ.js.map → chunk-GHVIKOHT.js.map} +0 -0
  531. /package/dist/{noydb-G725ZSZG.js.map → chunk-K2WCO3NX.js.map} +0 -0
  532. /package/dist/{public-envelope-BW6OXORV.js.map → chunk-PZ5AY32C.js.map} +0 -0
  533. /package/dist/{read-only-facade-ITU6L7BL.js.map → collection-facade-GQAOGJP2.js.map} +0 -0
  534. /package/dist/{registry-3QP3YKQS.js.map → delegation-UL5HKLER.js.map} +0 -0
  535. /package/dist/{registry-DKEXOJVO.js.map → describe/index.js.map} +0 -0
  536. /package/dist/{registry-OJIOSBV6.js.map → enclave-UL5LW66V.js.map} +0 -0
  537. /package/dist/{registry-USRVT6YF.js.map → executor-2FWQRLMG.js.map} +0 -0
  538. /package/dist/{revoke-JCC7N56X.js.map → executor-QZ7BXICW.js.map} +0 -0
  539. /package/dist/{signer-72QAUSVW.js.map → executor-Z5ZLJVTV.js.map} +0 -0
  540. /package/dist/{stale-6ZDBTQT7.js.map → export-accessible-KRV5W4GH.js.map} +0 -0
  541. /package/dist/{ulid-COREQ2RQ.js.map → extract-partition-GLKBOXFQ.js.map} +0 -0
package/dist/index.js CHANGED
@@ -1,88 +1,202 @@
1
1
  import {
2
- DELEGATIONS_COLLECTION,
3
- issueDelegation,
4
- loadActiveDelegations,
5
- revokeDelegation
6
- } from "./chunk-5T22KDPN.js";
2
+ DEFAULT_FRESHNESS_MS,
3
+ PERSONAL_POLICY,
4
+ STRICT_POLICY,
5
+ checkGate,
6
+ describeGate,
7
+ mergePolicy
8
+ } from "./chunk-5N6CZTCY.js";
7
9
  import {
8
10
  Collection,
9
- DEFAULT_FRESHNESS_MS,
11
+ ComputedFieldError,
10
12
  ELEVATION_AUDIT_COLLECTION,
11
13
  ElevatedHandle,
14
+ LinkEndpointError,
15
+ LinkIntegrityError,
12
16
  Lru,
13
- META_COLLECTION,
14
17
  Noydb,
15
- PERSONAL_POLICY,
16
- POLICY_RECORD_ID,
17
18
  QuickUnlockStore,
18
19
  RefIntegrityError,
19
20
  RefRegistry,
20
21
  RefScopeError,
21
- STRICT_POLICY,
22
- UserApi,
23
22
  Vault,
24
- checkGate,
25
23
  createNoydb,
26
24
  derivePersistedSchema,
27
25
  describeAllUsersAuth,
28
26
  describeAuthConfig,
29
- describeGate,
30
27
  describeUserAuth,
31
28
  diagramAuthConfig,
32
29
  estimateRecordBytes,
30
+ evalComputedFields,
31
+ isLinkCollectionName,
32
+ isRefArray,
33
33
  isZodSchema,
34
- loadVaultPolicy,
35
- mergePolicy,
34
+ memoryStore,
36
35
  parseBytes,
37
36
  persistSchemaIfNeeded,
38
37
  ref,
39
- saveVaultPolicy,
40
- validateSchemaInput,
41
- validateSchemaOutput
42
- } from "./chunk-6CME4UEK.js";
38
+ refArray,
39
+ withArchive
40
+ } from "./chunk-PSHOXR6C.js";
41
+ import {
42
+ META_COLLECTION,
43
+ POLICY_RECORD_ID,
44
+ loadVaultPolicy,
45
+ saveVaultPolicy
46
+ } from "./chunk-SM3AVUHC.js";
47
+ import {
48
+ DELEGATIONS_COLLECTION,
49
+ issueDelegation,
50
+ loadActiveDelegations,
51
+ revokeDelegation
52
+ } from "./chunk-VFQGRQIH.js";
43
53
  import {
44
54
  DEFAULT_PUBLIC_ENVELOPE_SCHEMA,
45
55
  PUBLIC_ENVELOPE_FIELDS,
46
56
  resolveSchema
47
- } from "./chunk-EMIGCR7X.js";
57
+ } from "./chunk-WXSYDNBT.js";
58
+ import {
59
+ NO_SEQUENCE,
60
+ SequenceStore,
61
+ compileSequenceFormat,
62
+ resolveSequenceKey,
63
+ withSequence
64
+ } from "./chunk-GYGWYIOZ.js";
65
+ import {
66
+ UserApi
67
+ } from "./chunk-UDRIWL7A.js";
68
+ import {
69
+ WithdrawalRequestError,
70
+ approveWithdrawal,
71
+ listWithdrawalRequests,
72
+ rejectWithdrawal,
73
+ requestWithdrawal
74
+ } from "./chunk-XXYIOFUB.js";
75
+ import "./chunk-IAGBDSCS.js";
76
+ import {
77
+ NO_SEARCH,
78
+ tokenize,
79
+ withSearch
80
+ } from "./chunk-TEILUWOI.js";
81
+ import "./chunk-5R3ERCDH.js";
82
+ import {
83
+ isDiscriminant
84
+ } from "./chunk-PY4KJPYU.js";
85
+ import "./chunk-WYSO2NIH.js";
86
+ import "./chunk-IPB7FTQX.js";
87
+ import "./chunk-KVOXU4T5.js";
88
+ import {
89
+ withCargo
90
+ } from "./chunk-M6OST55S.js";
91
+ import {
92
+ CustodyApi,
93
+ NO_CARGO,
94
+ NO_CUSTODY,
95
+ withCustody
96
+ } from "./chunk-TJYQIGAP.js";
97
+ import {
98
+ DEED_RECORD_ID,
99
+ createDeedOwner,
100
+ isDeedVault,
101
+ liberateVault,
102
+ loadDeedMarker
103
+ } from "./chunk-KXGNJJXB.js";
104
+ import {
105
+ withdrawAccessibleData
106
+ } from "./chunk-PSMV73A5.js";
107
+ import {
108
+ exportAccessibleData
109
+ } from "./chunk-HCIPRAGS.js";
110
+ import {
111
+ diffVault
112
+ } from "./chunk-LB7FD65R.js";
113
+ import "./chunk-BGIZAFY7.js";
114
+ import {
115
+ fuseRetrieval
116
+ } from "./chunk-AURFOK3D.js";
117
+ import "./chunk-QHJW5EXU.js";
118
+ import {
119
+ immutableGuard,
120
+ transitionGuard,
121
+ withGuard
122
+ } from "./chunk-TA66UMI4.js";
123
+ import "./chunk-YMUGBZN2.js";
124
+ import "./chunk-RUIMKQTA.js";
125
+ import "./chunk-RUEKROOS.js";
126
+ import {
127
+ CollectionFrame,
128
+ VaultFrame
129
+ } from "./chunk-NF5JWERG.js";
48
130
  import {
49
131
  TxCollection,
50
132
  TxContext,
51
133
  TxVault,
52
134
  runTransaction
53
- } from "./chunk-TFBP23BX.js";
135
+ } from "./chunk-SKF73JOP.js";
54
136
  import {
55
- withDerivation
56
- } from "./chunk-RAZ4OVLL.js";
57
- import "./chunk-DE6GKS6G.js";
58
- import "./chunk-DO7C2TOG.js";
137
+ withDerivation,
138
+ withRollup
139
+ } from "./chunk-LMTH2RM6.js";
140
+ import "./chunk-Q7SS3IME.js";
141
+ import "./chunk-PKHL44ER.js";
59
142
  import {
60
143
  withMaterializedView
61
- } from "./chunk-K3DK3NU5.js";
62
- import "./chunk-HNRHLRDC.js";
63
- import "./chunk-O3VZPBZG.js";
64
- import "./chunk-T7JEBOGN.js";
144
+ } from "./chunk-3YFXJ3ZP.js";
145
+ import "./chunk-AQTBSL7R.js";
146
+ import "./chunk-62QYRORB.js";
147
+ import "./chunk-BG3SPSR4.js";
65
148
  import {
66
149
  withOverlayedView
67
- } from "./chunk-SYMWGEET.js";
68
- import "./chunk-VTKGMEPP.js";
69
- import "./chunk-DJHHA6XH.js";
70
- import "./chunk-2WUSG3IT.js";
150
+ } from "./chunk-EIZUR2XW.js";
151
+ import "./chunk-CMGR4ZEW.js";
152
+ import "./chunk-VCTFO5CO.js";
153
+ import {
154
+ importExternalObjects,
155
+ memoryObjectProjection
156
+ } from "./chunk-4Q6HSHHL.js";
157
+ import "./chunk-Y22T3KQE.js";
158
+ import "./chunk-V7RWQRG7.js";
71
159
  import {
72
160
  mergeCrdtStates,
73
161
  resolveCrdtSnapshot
74
- } from "./chunk-J66GRPNH.js";
162
+ } from "./chunk-6S7T6WC4.js";
163
+ import {
164
+ decryptExtractedPartition
165
+ } from "./chunk-QZISFCVG.js";
166
+ import {
167
+ SCHEMAS_COLLECTION,
168
+ loadPersistedSchema,
169
+ savePersistedSchema
170
+ } from "./chunk-26LGBE4T.js";
75
171
  import {
76
172
  MemoryRecipientSealer,
77
173
  MemorySealingKeyProvider,
78
- SCHEMAS_COLLECTION,
79
174
  SEALED_PASSPHRASE_RECORD_ID,
80
- loadPersistedSchema,
175
+ aesGcmOpen,
81
176
  loadSealedPassphrase,
177
+ parseRsaOaepTlv,
82
178
  parseSealedEnvelope,
83
- savePersistedSchema,
84
- saveSealedPassphrase
85
- } from "./chunk-I5FOWO4J.js";
179
+ saveSealedPassphrase,
180
+ sealRsaOaepTlv
181
+ } from "./chunk-ZCGAHGUS.js";
182
+ import {
183
+ BLOB_CHUNKS_COLLECTION,
184
+ BLOB_COLLECTION,
185
+ BLOB_INDEX_COLLECTION,
186
+ BLOB_SLOTS_PREFIX,
187
+ BLOB_VERSIONS_PREFIX,
188
+ BlobSet,
189
+ DEFAULT_CHUNK_SIZE,
190
+ detectMagic,
191
+ detectMimeType,
192
+ isPreCompressed
193
+ } from "./chunk-DFEMTNPJ.js";
194
+ import {
195
+ createBundleStore,
196
+ createPodStore,
197
+ wrapBundleStore,
198
+ wrapPodStore
199
+ } from "./chunk-AZAOEIKW.js";
86
200
  import {
87
201
  NOYDB_BUNDLE_FORMAT_VERSION,
88
202
  NOYDB_BUNDLE_MAGIC,
@@ -91,9 +205,12 @@ import {
91
205
  readNoydbBundle,
92
206
  readNoydbBundleHeader,
93
207
  readNoydbBundlePublicEnvelope,
208
+ readPod,
209
+ readPodHeader,
94
210
  resetBrotliSupportCache,
95
- writeNoydbBundle
96
- } from "./chunk-BVRYKATC.js";
211
+ writeNoydbBundle,
212
+ writePod
213
+ } from "./chunk-FISN7WE4.js";
97
214
  import {
98
215
  PUBLIC_ENVELOPE_RECORD_ID,
99
216
  isPublicEnvelope,
@@ -101,54 +218,25 @@ import {
101
218
  readPublicEnvelope,
102
219
  savePublicEnvelope,
103
220
  validatePublicEnvelopeInput
104
- } from "./chunk-ML236QKC.js";
221
+ } from "./chunk-SMXWYP24.js";
105
222
  import {
106
223
  CONSENT_AUDIT_COLLECTION
107
- } from "./chunk-XJFLDA7A.js";
224
+ } from "./chunk-MTMJVJ5W.js";
225
+ import "./chunk-CWPPNPOH.js";
108
226
  import {
109
227
  PERIODS_COLLECTION
110
- } from "./chunk-JWRVQKRZ.js";
111
- import "./chunk-UF3BUNQZ.js";
112
- import {
113
- withGuard
114
- } from "./chunk-OQ6PIGHA.js";
115
- import "./chunk-A3JMGXPG.js";
116
- import "./chunk-UMLVJTYV.js";
117
- import "./chunk-NONAAENK.js";
118
- import {
119
- CollectionFrame,
120
- VaultFrame
121
- } from "./chunk-DFMLEQZB.js";
122
- import {
123
- enforceScript,
124
- inferScripts
125
- } from "./chunk-6STK5TQP.js";
228
+ } from "./chunk-IELYAOGG.js";
229
+ import "./chunk-GHVIKOHT.js";
126
230
  import {
127
231
  DICT_COLLECTION_PREFIX,
128
232
  DictionaryHandle,
129
- applyI18nLocale,
130
233
  dictCollectionName,
131
234
  dictKey,
132
- i18nText,
133
235
  isDictCollectionName,
134
236
  isDictKeyDescriptor,
135
- isI18nTextDescriptor,
136
- resolveI18nText,
137
- resolvePolicy,
138
- validateI18nTextValue
139
- } from "./chunk-22DWZL57.js";
140
- import {
141
- createBundleStore,
142
- routeStore,
143
- withCache,
144
- withCircuitBreaker,
145
- withHealthCheck,
146
- withLogging,
147
- withMetrics,
148
- withRetry,
149
- wrapBundleStore,
150
- wrapStore
151
- } from "./chunk-QEILDE6R.js";
237
+ isStaticDictDescriptor,
238
+ staticDict
239
+ } from "./chunk-LFLXAY2W.js";
152
240
  import {
153
241
  SYNC_CREDENTIALS_COLLECTION,
154
242
  credentialStatus,
@@ -156,85 +244,83 @@ import {
156
244
  getCredential,
157
245
  listCredentials,
158
246
  putCredential
159
- } from "./chunk-ZYWZWG6G.js";
247
+ } from "./chunk-DGDI2D4M.js";
160
248
  import {
161
249
  MAGIC_LINK_CONTENT_INFO_PREFIX,
162
250
  MAGIC_LINK_GRANTS_COLLECTION,
163
251
  MAGIC_LINK_KEK_INFO_PREFIX,
164
- ManagedRecoveryNotEnrolledError,
165
- PolicyDeniedError,
166
- RecoveryNotEnrolledError,
167
- RecoveryProfileNotImplementedError,
168
- burnPaperRecoveryEntry,
169
252
  deriveMagicLinkContentKey,
170
253
  enrollAuthenticator,
171
254
  findAuthenticator,
172
- hasRecoveryEnrolled,
173
255
  isMagicLinkGrantExpired,
174
256
  listMagicLinkGrants,
175
- loadPaperRecoveryEntries,
176
- loadShamirRecoveryEntries,
177
257
  magicLinkGrantRecordId,
178
- mintPaperRecoveryEntry,
179
- mintShamirRecoveryEntry,
180
- mintWrappedDeksBlob,
181
258
  readMagicLinkGrantRecord,
182
259
  recoverPassphrase,
183
260
  recoverUser,
184
261
  removeAuthenticator,
185
262
  revokeMagicLinkGrant,
186
263
  rotatePassphrase,
264
+ unwrapMagicLinkGrant,
265
+ writeMagicLinkGrant
266
+ } from "./chunk-UPJNJGGA.js";
267
+ import {
268
+ burnPaperRecoveryEntry,
269
+ hasRecoveryEnrolled,
270
+ loadPaperRecoveryEntries,
271
+ loadShamirRecoveryEntries,
272
+ mintPaperRecoveryEntry,
273
+ mintShamirRecoveryEntry,
274
+ mintWrappedDeksBlob,
187
275
  savePaperRecoveryEntries,
188
276
  saveShamirRecoveryEntries,
189
277
  unwrapDeksFromBlob,
190
278
  unwrapDeksFromPaperEntry,
191
- unwrapDeksFromShamirEntry,
192
- unwrapMagicLinkGrant,
193
- writeMagicLinkGrant
194
- } from "./chunk-3YPCK6JX.js";
279
+ unwrapDeksFromShamirEntry
280
+ } from "./chunk-IGUYVGGI.js";
195
281
  import {
196
282
  assertTierAccess,
197
283
  dekKey,
198
284
  effectiveClearance
199
- } from "./chunk-U26HQ6KJ.js";
285
+ } from "./chunk-IO6GRPT6.js";
200
286
  import {
201
287
  PresenceHandle,
202
288
  SyncEngine,
203
289
  SyncTransaction
204
- } from "./chunk-WPLVTJ5D.js";
290
+ } from "./chunk-IUEN57TV.js";
291
+ import {
292
+ BUNDLE_STORE_POLICY,
293
+ INDEXED_STORE_POLICY,
294
+ POD_STORE_POLICY,
295
+ SyncScheduler
296
+ } from "./chunk-VQNJ7UZL.js";
205
297
  import {
206
- DIRECTORY_RECORD_ID,
207
- USER_ENVELOPE_COLLECTION,
208
- USER_ENVELOPE_MAX_BYTES,
209
- UserEnvelopeOversizedError,
210
- VISIBILITY_RECORD_PREFIX,
211
298
  WeakPassphraseError,
212
299
  assertStrongPassphrase,
213
300
  buildRecipientKeyringFile,
214
- deleteUserEnvelope,
215
- deleteUserVisibility,
216
301
  estimateEntropy,
217
302
  evaluateExportCapability,
218
303
  evaluateImportCapability,
219
304
  hasExportCapability,
220
305
  hasImportCapability,
221
- listUserEnvelopeIds,
222
306
  listUsers,
223
307
  listUsersWithEnvelopes,
308
+ validatePassphrase
309
+ } from "./chunk-WWGT2MDV.js";
310
+ import {
311
+ DIRECTORY_RECORD_ID,
312
+ VISIBILITY_RECORD_PREFIX,
313
+ deleteUserEnvelope,
314
+ deleteUserVisibility,
315
+ listUserEnvelopeIds,
224
316
  loadUserEnvelope,
225
317
  persistDirectoryConfig,
226
318
  persistUserVisibility,
227
319
  readDirectoryConfig,
228
320
  readUserVisibility,
229
321
  saveUserEnvelope,
230
- validatePassphrase,
231
322
  visibilityRecordId
232
- } from "./chunk-DONMZAD2.js";
233
- import {
234
- BUNDLE_STORE_POLICY,
235
- INDEXED_STORE_POLICY,
236
- SyncScheduler
237
- } from "./chunk-2QR2PQTT.js";
323
+ } from "./chunk-ITNUCOXM.js";
238
324
  import {
239
325
  PolicyEnforcer,
240
326
  activeSessionCount,
@@ -249,24 +335,28 @@ import {
249
335
  revokeAllSessions,
250
336
  revokeSession,
251
337
  validateSessionPolicy
252
- } from "./chunk-H2X3ISXG.js";
338
+ } from "./chunk-UAG5KWVA.js";
253
339
  import {
254
340
  generateULID,
255
341
  isULID
256
- } from "./chunk-FZU343FL.js";
342
+ } from "./chunk-ZJADGNYF.js";
257
343
  import {
258
344
  CollectionInstant,
259
- VaultInstant,
345
+ VaultInstant
346
+ } from "./chunk-MD3Y6J3L.js";
347
+ import {
260
348
  diff,
261
349
  formatDiff
262
- } from "./chunk-F3GDRNUT.js";
350
+ } from "./chunk-SVLR4POP.js";
263
351
  import {
264
- LEDGER_COLLECTION,
265
- LEDGER_DELTAS_COLLECTION,
266
352
  LedgerStore,
267
353
  applyPatch,
268
354
  computePatch
269
- } from "./chunk-PE2FR4J3.js";
355
+ } from "./chunk-LXQT4WMP.js";
356
+ import {
357
+ LEDGER_COLLECTION,
358
+ LEDGER_DELTAS_COLLECTION
359
+ } from "./chunk-I7FD46FF.js";
270
360
  import {
271
361
  canonicalJson,
272
362
  envelopePayloadHash,
@@ -274,7 +364,28 @@ import {
274
364
  paddedIndex,
275
365
  parseIndex,
276
366
  sha256Hex
277
- } from "./chunk-Z6FNBOTC.js";
367
+ } from "./chunk-AIWULCUO.js";
368
+ import "./chunk-SRB2XEWB.js";
369
+ import "./chunk-UV5MFVO3.js";
370
+ import {
371
+ base64ToBuffer,
372
+ bufferToBase64,
373
+ decryptBytes,
374
+ decryptDeterministic,
375
+ derivePresenceKey,
376
+ encryptBytes,
377
+ encryptDeterministic,
378
+ validateSchemaInput,
379
+ validateSchemaOutput
380
+ } from "./chunk-5O3AOPDT.js";
381
+ import {
382
+ NOYDB_BACKUP_VERSION,
383
+ NOYDB_FORMAT_VERSION,
384
+ NOYDB_KEYRING_VERSION,
385
+ NOYDB_SYNC_VERSION,
386
+ SealedHandle,
387
+ createStore
388
+ } from "./chunk-5TDJ56JE.js";
278
389
  import {
279
390
  DEFAULT_CROSS_JOIN_MAX_ROWS,
280
391
  DEFAULT_JOIN_MAX_ROWS,
@@ -284,17 +395,10 @@ import {
284
395
  buildLiveQuery,
285
396
  executePlan,
286
397
  resetJoinWarnings
287
- } from "./chunk-2GLDA55J.js";
398
+ } from "./chunk-UIU2THRG.js";
288
399
  import {
289
400
  CollectionIndexes
290
- } from "./chunk-OIF6LZUR.js";
291
- import {
292
- avg,
293
- count,
294
- max,
295
- min,
296
- sum
297
- } from "./chunk-W6EQLGMB.js";
401
+ } from "./chunk-I3TIKTJO.js";
298
402
  import {
299
403
  Aggregation,
300
404
  GROUPBY_MAX_CARDINALITY,
@@ -302,56 +406,62 @@ import {
302
406
  GroupedAggregation,
303
407
  GroupedQuery,
304
408
  GroupedQueryN,
409
+ avg,
410
+ count,
305
411
  groupAndReduce,
306
- reduceRecords
307
- } from "./chunk-5XHKQ56N.js";
412
+ max,
413
+ min,
414
+ moneyMax,
415
+ moneyMin,
416
+ moneySum,
417
+ reduceRecords,
418
+ reducerBuilder,
419
+ sum
420
+ } from "./chunk-LV7M27WM.js";
308
421
  import {
422
+ MoneyCurrencyError,
423
+ MoneyPrecisionError,
424
+ MoneyUnsupportedError,
425
+ decimalScaleOf,
309
426
  evaluateClause,
310
427
  evaluateFieldClause,
311
- readPath
312
- } from "./chunk-TV3YZ35S.js";
313
- import {
314
- BLOB_CHUNKS_COLLECTION,
315
- BLOB_COLLECTION,
316
- BLOB_INDEX_COLLECTION,
317
- BLOB_SLOTS_PREFIX,
318
- BLOB_VERSIONS_PREFIX,
319
- BlobSet,
320
- DEFAULT_CHUNK_SIZE,
321
- detectMagic,
322
- detectMimeType,
323
- isPreCompressed
324
- } from "./chunk-QODLLGQ7.js";
325
- import "./chunk-3BFJOWSU.js";
326
- import {
327
- NOYDB_BACKUP_VERSION,
328
- NOYDB_FORMAT_VERSION,
329
- NOYDB_KEYRING_VERSION,
330
- NOYDB_SYNC_VERSION,
331
- createStore
332
- } from "./chunk-WIRRPTFH.js";
428
+ formatScaledInt,
429
+ isMoneyDescriptor,
430
+ money,
431
+ parseToScaledInt,
432
+ readPath,
433
+ rescaleScaledInt,
434
+ scaleForCurrency
435
+ } from "./chunk-M2YKN37S.js";
333
436
  import {
334
- base64ToBuffer,
335
- bufferToBase64,
336
- decryptBytes,
337
- decryptDeterministic,
338
- derivePresenceKey,
339
- encryptBytes,
340
- encryptDeterministic
341
- } from "./chunk-PP6W64Y3.js";
437
+ applyI18nLocale,
438
+ enforceScript,
439
+ i18nText,
440
+ inferScripts,
441
+ isI18nTextDescriptor,
442
+ resolveI18nText,
443
+ resolvePolicy,
444
+ validateI18nTextValue
445
+ } from "./chunk-5LUY7UTV.js";
342
446
  import {
343
447
  AlreadyElevatedError,
344
448
  AmendmentForbiddenError,
345
449
  AttestationError,
450
+ AttestationNotEnabledError,
346
451
  BackupCorruptedError,
347
452
  BackupLedgerError,
348
453
  BundleIntegrityError,
349
454
  BundleSealMismatchError,
350
455
  BundleVersionConflictError,
456
+ CargoNotEnabledError,
351
457
  ConflictError,
352
458
  CrossJoinSourceUnknownError,
353
459
  CrossJoinTooLargeError,
460
+ CustodyNotEnabledError,
354
461
  DanglingReferenceError,
462
+ DataResidencyError,
463
+ DebugPlaintextError,
464
+ DebugReservedFieldError,
355
465
  DecryptionError,
356
466
  DelegationTargetMissingError,
357
467
  DerivationCapExceededError,
@@ -363,10 +473,15 @@ import {
363
473
  DictKeyMissingError,
364
474
  DirectoryDisabledError,
365
475
  ElevationExpiredError,
476
+ EmbeddingDimMismatchError,
477
+ EmbeddingModelMismatchError,
478
+ EnclaveNotSupportedError,
366
479
  ExportCapabilityError,
367
480
  FieldFrozenError,
368
481
  FilenameSanitizationError,
482
+ ForgetStrategyNotConfiguredError,
369
483
  GroupCardinalityError,
484
+ IllegalTransitionError,
370
485
  ImportCapabilityError,
371
486
  IndexRequiredError,
372
487
  IndexWriteFailureError,
@@ -377,6 +492,7 @@ import {
377
492
  KeyringExpiredError,
378
493
  LedgerContentionError,
379
494
  LocaleNotSpecifiedError,
495
+ ManagedRecoveryNotEnrolledError,
380
496
  MaterializedViewConfigError,
381
497
  MaterializedViewCycleError,
382
498
  MaterializedViewSourceUnknownError,
@@ -388,6 +504,7 @@ import {
388
504
  NonAdditiveSchemaChangeError,
389
505
  NotFoundError,
390
506
  NoydbError,
507
+ NumberingUncertaintyError,
391
508
  OverlayBaseIsVirtualError,
392
509
  OverlayCollectionUnavailableError,
393
510
  OverlayIdMismatchError,
@@ -395,31 +512,76 @@ import {
395
512
  PathEscapeError,
396
513
  PeriodClosedError,
397
514
  PermissionDeniedError,
515
+ PodVersionConflictError,
516
+ PolicyDeniedError,
517
+ PortabilityNotEnabledError,
398
518
  PrivilegeEscalationError,
399
519
  QuiesceTimeoutError,
400
520
  ReadOnlyAtInstantError,
401
521
  ReadOnlyError,
402
522
  ReadOnlyFrameError,
523
+ RecordCekNotFoundError,
403
524
  RecordLockedError,
525
+ RecoveryNotEnrolledError,
526
+ RecoveryProfileNotImplementedError,
404
527
  ReservedCollectionNameError,
528
+ ReservedVaultNameError,
529
+ STATE_VAULT_NAME,
405
530
  SchemaFenceError,
406
531
  SchemaLockedError,
407
532
  SchemaUpdateError,
408
533
  SchemaValidationError,
409
534
  ScriptViolationError,
535
+ SealedRecordExpiredError,
536
+ SealedRecordMismatchError,
537
+ SealedRecordNotEnabledError,
538
+ SearchNotEnabledError,
539
+ SequenceContentionError,
540
+ SequenceNotEnabledError,
541
+ SequenceOfflineError,
410
542
  SessionExpiredError,
411
543
  SessionNotFoundError,
412
544
  SessionPolicyError,
545
+ ShardProvisioningError,
413
546
  SnapshotNotFoundError,
547
+ StaticDictReadonlyError,
414
548
  StoreCapabilityError,
415
549
  TamperedError,
416
550
  TierDemoteDeniedError,
417
551
  TierNotGrantedError,
552
+ TiersNotEnabledError,
418
553
  TranslatorNotConfiguredError,
419
- ValidationError
420
- } from "./chunk-B6PB7JLN.js";
554
+ USER_ENVELOPE_COLLECTION,
555
+ USER_ENVELOPE_MAX_BYTES,
556
+ UniqueConstraintError,
557
+ UnknownDictCodeError,
558
+ UnknownShardError,
559
+ UnsupportedIndexOptionError,
560
+ UserEnvelopeOversizedError,
561
+ ValidationError,
562
+ VaultTemplateNotFoundError
563
+ } from "./chunk-ZYUC53LT.js";
564
+ import "./chunk-PZ5AY32C.js";
421
565
 
422
- // src/schema-update/strategies.ts
566
+ // src/kernel/debug.ts
567
+ function readPlaintextRecord(envelope) {
568
+ if (envelope._iv !== "") {
569
+ throw new Error(
570
+ "readPlaintextRecord: envelope is encrypted (non-empty _iv) \u2014 decrypt via the vault, not this helper"
571
+ );
572
+ }
573
+ if (envelope._debug !== void 0) {
574
+ const record = {};
575
+ for (const [key, value] of Object.entries(envelope)) {
576
+ if (!key.startsWith("_")) record[key] = value;
577
+ }
578
+ return record;
579
+ }
580
+ if (!envelope._data) return null;
581
+ return JSON.parse(envelope._data);
582
+ }
583
+
584
+ // src/with-shape/schema-update/strategies.ts
423
585
  function blindUpdate() {
424
586
  return { name: "blindUpdate", onSchemaDelta: () => ({ action: "allow" }) };
425
587
  }
@@ -457,7 +619,7 @@ function lockSchema(opts) {
457
619
  };
458
620
  }
459
621
 
460
- // src/schema-update/cutover.ts
622
+ // src/with-shape/schema-update/cutover.ts
461
623
  function coordinatedCutover(opts) {
462
624
  return {
463
625
  name: "coordinatedCutover",
@@ -470,162 +632,770 @@ function coordinatedCutover(opts) {
470
632
  };
471
633
  }
472
634
 
473
- // src/vault-diff.ts
474
- async function diffVault(vault, candidate, options = {}) {
475
- const idKey = options.idKey ?? "id";
476
- const filter = options.collections ? new Set(options.collections) : null;
477
- const compareFn = options.compareFn ?? ((a, b) => diff(a, b).length === 0);
478
- const live = /* @__PURE__ */ new Map();
479
- for await (const chunk of vault.exportStream({ granularity: "collection" })) {
480
- if (filter && !filter.has(chunk.collection)) continue;
481
- const collection = live.get(chunk.collection) ?? /* @__PURE__ */ new Map();
482
- for (const record of chunk.records) {
483
- const id = readIdField(record, idKey);
484
- if (!id) continue;
485
- collection.set(id, record);
635
+ // src/with-store/route-store.ts
636
+ var BLOB_CHUNKS = "_blob_chunks";
637
+ var BLOB_INDEX = "_blob_index";
638
+ var BLOB_SLOTS = "_blob_slots_";
639
+ var BLOB_VERSIONS = "_blob_versions_";
640
+ function routeStore(opts) {
641
+ const primary = opts.default;
642
+ const blobsIsSimple = opts.blobs && "get" in opts.blobs;
643
+ const simpleBlobStore = blobsIsSimple ? opts.blobs : void 0;
644
+ const tieredBlobs = !blobsIsSimple ? opts.blobs : void 0;
645
+ const blobThreshold = tieredBlobs?.threshold ?? 400 * 1024;
646
+ const allStores = /* @__PURE__ */ new Set([primary]);
647
+ if (simpleBlobStore) allStores.add(simpleBlobStore);
648
+ if (tieredBlobs?.large) allStores.add(tieredBlobs.large);
649
+ if (tieredBlobs?.small) allStores.add(tieredBlobs.small);
650
+ if (opts.age?.cold) allStores.add(opts.age.cold);
651
+ if (opts.routes) for (const s of Object.values(opts.routes)) allStores.add(s);
652
+ if (opts.vaultRoutes) for (const s of Object.values(opts.vaultRoutes)) allStores.add(s);
653
+ if (opts.blobRoutes) for (const s of Object.values(opts.blobRoutes)) allStores.add(s);
654
+ if (opts.overflow) allStores.add(opts.overflow);
655
+ if (opts.blobLifecycle?.archiveStore) allStores.add(opts.blobLifecycle.archiveStore);
656
+ const overrides = /* @__PURE__ */ new Map();
657
+ const suspended = /* @__PURE__ */ new Set();
658
+ const writeQueues = /* @__PURE__ */ new Map();
659
+ const NULL_STORE = {
660
+ name: "suspended",
661
+ async get() {
662
+ return null;
663
+ },
664
+ async put() {
665
+ },
666
+ async delete() {
667
+ },
668
+ async list() {
669
+ return [];
670
+ },
671
+ async loadAll() {
672
+ return {};
673
+ },
674
+ async saveAll() {
486
675
  }
487
- live.set(chunk.collection, collection);
488
- }
489
- const cand = await normaliseCandidate(candidate, idKey, filter);
490
- const added = [];
491
- const modified = [];
492
- const deleted = [];
493
- const unchanged = options.includeUnchanged ? [] : void 0;
494
- const collectionNames = /* @__PURE__ */ new Set([...live.keys(), ...cand.keys()]);
495
- for (const collection of [...collectionNames].sort()) {
496
- const liveColl = live.get(collection) ?? /* @__PURE__ */ new Map();
497
- const candColl = cand.get(collection) ?? /* @__PURE__ */ new Map();
498
- const allIds = /* @__PURE__ */ new Set([...liveColl.keys(), ...candColl.keys()]);
499
- for (const id of [...allIds].sort()) {
500
- const before = liveColl.get(id);
501
- const after = candColl.get(id);
502
- if (before === void 0 && after !== void 0) {
503
- added.push({ collection, id, record: after });
504
- } else if (before !== void 0 && after === void 0) {
505
- deleted.push({ collection, id, record: before });
506
- } else if (before !== void 0 && after !== void 0) {
507
- if (compareFn(before, after)) {
508
- unchanged?.push({ collection, id, record: after });
509
- } else {
510
- const fieldDiffs = diff(before, after);
511
- const fieldsChanged = uniqueTopLevelKeys(fieldDiffs);
512
- modified.push({
513
- collection,
514
- id,
515
- record: after,
516
- before,
517
- fieldsChanged,
518
- fieldDiffs
519
- });
520
- }
676
+ };
677
+ function routeNameFor(vault, collection) {
678
+ if (opts.vaultRoutes) {
679
+ for (const prefix of Object.keys(opts.vaultRoutes)) {
680
+ if (vault.startsWith(prefix)) return prefix;
521
681
  }
522
682
  }
683
+ if (opts.routes && !collection.startsWith("_") && opts.routes[collection]) {
684
+ return collection;
685
+ }
686
+ if (isBlobChunks(collection) && (simpleBlobStore || tieredBlobs)) return "blobs";
687
+ if (opts.routeBlobMeta && isBlobMeta(collection) && (simpleBlobStore || tieredBlobs)) return "blobs";
688
+ if (opts.age && !collection.startsWith("_")) {
689
+ }
690
+ return "default";
523
691
  }
524
- const summary = {
525
- add: added.length,
526
- modify: modified.length,
527
- delete: deleted.length,
528
- total: added.length + modified.length + deleted.length
529
- };
530
- return {
531
- added,
532
- modified,
533
- deleted,
534
- unchanged,
535
- summary,
536
- format(opts) {
537
- return formatDiff2(opts?.detail ?? "full", { added, modified, deleted, summary });
692
+ const quotaExceeded = false;
693
+ function resolveOriginalStore(route) {
694
+ if (route === "blobs") return simpleBlobStore ?? tieredBlobs?.large ?? primary;
695
+ if (route === "cold") return opts.age?.cold ?? primary;
696
+ if (opts.routes?.[route]) return opts.routes[route];
697
+ if (opts.vaultRoutes?.[route]) return opts.vaultRoutes[route];
698
+ return primary;
699
+ }
700
+ function maybeQueueWrite(routeName, method, vault, collection, id, envelope, expectedVersion) {
701
+ if (!suspended.has(routeName)) return false;
702
+ const queue = writeQueues.get(routeName);
703
+ if (!queue) return false;
704
+ if (queue.writes.length >= queue.maxSize) {
705
+ queue.writes.shift();
706
+ }
707
+ queue.writes.push({
708
+ method,
709
+ vault,
710
+ collection,
711
+ id,
712
+ ...envelope !== void 0 ? { envelope } : {},
713
+ ...expectedVersion !== void 0 ? { expectedVersion } : {}
714
+ });
715
+ return true;
716
+ }
717
+ function isBlobChunks(collection) {
718
+ return collection === BLOB_CHUNKS;
719
+ }
720
+ function isBlobMeta(collection) {
721
+ return collection === BLOB_INDEX || collection.startsWith(BLOB_SLOTS) || collection.startsWith(BLOB_VERSIONS);
722
+ }
723
+ function isInternal(collection) {
724
+ return collection.startsWith("_");
725
+ }
726
+ function storeFor(vault, collection) {
727
+ const rName = routeNameFor(vault, collection);
728
+ if (suspended.has(rName)) return NULL_STORE;
729
+ if (overrides.has(rName)) return overrides.get(rName);
730
+ if (opts.vaultRoutes) {
731
+ for (const [prefix, store2] of Object.entries(opts.vaultRoutes)) {
732
+ if (vault.startsWith(prefix)) return store2;
733
+ }
734
+ }
735
+ if (opts.routes && !isInternal(collection) && opts.routes[collection]) {
736
+ return opts.routes[collection];
737
+ }
738
+ if (isBlobChunks(collection)) {
739
+ if (simpleBlobStore) return simpleBlobStore;
740
+ if (tieredBlobs) return tieredBlobs.large;
741
+ }
742
+ if (opts.routeBlobMeta && isBlobMeta(collection)) {
743
+ if (simpleBlobStore) return simpleBlobStore;
744
+ if (tieredBlobs) return tieredBlobs.large;
745
+ }
746
+ if (quotaExceeded && opts.overflow) return opts.overflow;
747
+ return primary;
748
+ }
749
+ function blobStoreForSize(dataSize) {
750
+ if (!tieredBlobs) return simpleBlobStore ?? primary;
751
+ if (dataSize <= blobThreshold) {
752
+ return tieredBlobs.small ?? primary;
753
+ }
754
+ return tieredBlobs.large;
755
+ }
756
+ function isCold(collection, envelope) {
757
+ if (!opts.age) return false;
758
+ if (isInternal(collection)) return false;
759
+ if (opts.age.collections && opts.age.collections.length > 0) {
760
+ if (!opts.age.collections.includes(collection)) return false;
761
+ }
762
+ const cutoff = Date.now() - opts.age.coldAfterDays * 24 * 60 * 60 * 1e3;
763
+ const ts = new Date(envelope._ts).getTime();
764
+ return ts < cutoff;
765
+ }
766
+ const store = {
767
+ name: buildName(),
768
+ async get(vault, collection, id) {
769
+ const s = storeFor(vault, collection);
770
+ const result = await s.get(vault, collection, id);
771
+ if (result === null && opts.age && !isInternal(collection)) {
772
+ if (!opts.age.collections?.length || opts.age.collections.includes(collection)) {
773
+ return opts.age.cold.get(vault, collection, id);
774
+ }
775
+ }
776
+ return result;
777
+ },
778
+ async put(vault, collection, id, envelope, expectedVersion) {
779
+ const rn = routeNameFor(vault, collection);
780
+ if (maybeQueueWrite(rn, "put", vault, collection, id, envelope, expectedVersion)) return;
781
+ if (isBlobChunks(collection) && tieredBlobs) {
782
+ const dataSize = envelope._data.length;
783
+ const s2 = blobStoreForSize(dataSize);
784
+ return s2.put(vault, collection, id, envelope, expectedVersion);
785
+ }
786
+ const s = storeFor(vault, collection);
787
+ if (opts.age && !isInternal(collection)) {
788
+ opts.age.cold.delete(vault, collection, id).catch(() => {
789
+ });
790
+ }
791
+ return s.put(vault, collection, id, envelope, expectedVersion);
792
+ },
793
+ async delete(vault, collection, id) {
794
+ const rn = routeNameFor(vault, collection);
795
+ if (maybeQueueWrite(rn, "delete", vault, collection, id)) return;
796
+ const s = storeFor(vault, collection);
797
+ await s.delete(vault, collection, id);
798
+ if (opts.age && !isInternal(collection)) {
799
+ await opts.age.cold.delete(vault, collection, id).catch(() => {
800
+ });
801
+ }
802
+ },
803
+ async list(vault, collection) {
804
+ const s = storeFor(vault, collection);
805
+ const ids = await s.list(vault, collection);
806
+ if (opts.age && !isInternal(collection)) {
807
+ if (!opts.age.collections?.length || opts.age.collections.includes(collection)) {
808
+ const coldIds = await opts.age.cold.list(vault, collection).catch(() => []);
809
+ if (coldIds.length > 0) {
810
+ const merged = new Set(ids);
811
+ for (const id of coldIds) merged.add(id);
812
+ return [...merged];
813
+ }
814
+ }
815
+ }
816
+ return ids;
817
+ },
818
+ async loadAll(vault) {
819
+ const stores = getStoresForVault(vault);
820
+ const snapshots = await Promise.all(
821
+ stores.map((s) => s.loadAll(vault).catch(() => ({})))
822
+ );
823
+ return mergeSnapshots(snapshots);
824
+ },
825
+ async saveAll(vault, data) {
826
+ const partitioned = /* @__PURE__ */ new Map();
827
+ for (const [collection, records] of Object.entries(data)) {
828
+ const s = storeFor(vault, collection);
829
+ if (!partitioned.has(s)) partitioned.set(s, {});
830
+ partitioned.get(s)[collection] = records;
831
+ }
832
+ await Promise.all(
833
+ [...partitioned.entries()].map(([s, snap]) => s.saveAll(vault, snap))
834
+ );
835
+ },
836
+ async compact(vault) {
837
+ if (!opts.age) return 0;
838
+ let migrated = 0;
839
+ const collections = opts.age.collections?.length ? opts.age.collections : await primary.list(vault, "").catch(() => []);
840
+ for (const collection of collections) {
841
+ const ids = await primary.list(vault, collection).catch(() => []);
842
+ for (const id of ids) {
843
+ const envelope = await primary.get(vault, collection, id);
844
+ if (!envelope) continue;
845
+ if (isCold(collection, envelope)) {
846
+ await opts.age.cold.put(vault, collection, id, envelope);
847
+ await primary.delete(vault, collection, id);
848
+ migrated++;
849
+ }
850
+ }
851
+ }
852
+ return migrated;
853
+ },
854
+ // ── Runtime override / suspend ──────────────────────
855
+ override(route, overrideStore, overrideOpts) {
856
+ if (overrideOpts?.hydrate) {
857
+ return (async () => {
858
+ overrides.set(route, overrideStore);
859
+ })();
860
+ }
861
+ overrides.set(route, overrideStore);
862
+ },
863
+ clearOverride(route) {
864
+ overrides.delete(route);
865
+ },
866
+ suspend(route, suspendOpts) {
867
+ suspended.add(route);
868
+ if (suspendOpts?.queue) {
869
+ writeQueues.set(route, {
870
+ writes: [],
871
+ maxSize: suspendOpts.maxQueueSize ?? 1e4
872
+ });
873
+ }
874
+ },
875
+ async resume(route) {
876
+ suspended.delete(route);
877
+ const queue = writeQueues.get(route);
878
+ if (!queue || queue.writes.length === 0) {
879
+ writeQueues.delete(route);
880
+ return 0;
881
+ }
882
+ let replayed = 0;
883
+ const target = overrides.get(route) ?? resolveOriginalStore(route);
884
+ for (const write of queue.writes) {
885
+ try {
886
+ if (write.method === "put" && write.envelope) {
887
+ await target.put(write.vault, write.collection, write.id, write.envelope, write.expectedVersion);
888
+ } else if (write.method === "delete") {
889
+ await target.delete(write.vault, write.collection, write.id);
890
+ }
891
+ replayed++;
892
+ } catch {
893
+ }
894
+ }
895
+ writeQueues.delete(route);
896
+ return replayed;
897
+ },
898
+ routeStatus() {
899
+ const ov = {};
900
+ for (const [k, v] of overrides) ov[k] = v.name ?? "unnamed";
901
+ const q = {};
902
+ for (const [k, v] of writeQueues) q[k] = v.writes.length;
903
+ return { overrides: ov, suspended: [...suspended], queued: q };
904
+ },
905
+ resolveBackend(vaultId) {
906
+ if (opts.vaultRoutes) {
907
+ for (const [prefix, s] of Object.entries(opts.vaultRoutes)) {
908
+ if (vaultId.startsWith(prefix)) return s;
909
+ }
910
+ }
911
+ return primary;
538
912
  }
539
913
  };
914
+ if (anyHas("listVaults")) {
915
+ store.listVaults = async () => {
916
+ const results = await Promise.all(
917
+ [...allStores].filter((s) => s.listVaults !== void 0).map((s) => s.listVaults().catch(() => []))
918
+ );
919
+ return [...new Set(results.flat())];
920
+ };
921
+ }
922
+ if (anyHas("ping")) {
923
+ store.ping = async () => {
924
+ const results = await Promise.all(
925
+ [...allStores].filter((s) => s.ping !== void 0).map((s) => s.ping().catch(() => false))
926
+ );
927
+ return results.some(Boolean);
928
+ };
929
+ }
930
+ return store;
931
+ function buildName() {
932
+ const names = [...allStores].map((s) => s.name ?? "?").join("+");
933
+ return `route(${names})`;
934
+ }
935
+ function anyHas(method) {
936
+ return [...allStores].some((s) => s[method]);
937
+ }
938
+ function getStoresForVault(vault) {
939
+ const stores = /* @__PURE__ */ new Set();
940
+ if (opts.vaultRoutes) {
941
+ for (const [prefix, s] of Object.entries(opts.vaultRoutes)) {
942
+ if (vault.startsWith(prefix)) {
943
+ stores.add(s);
944
+ return [...stores];
945
+ }
946
+ }
947
+ }
948
+ stores.add(primary);
949
+ if (simpleBlobStore) stores.add(simpleBlobStore);
950
+ if (tieredBlobs?.large) stores.add(tieredBlobs.large);
951
+ if (tieredBlobs?.small && tieredBlobs.small !== primary) stores.add(tieredBlobs.small);
952
+ if (opts.age?.cold) stores.add(opts.age.cold);
953
+ if (opts.routes) {
954
+ for (const s of Object.values(opts.routes)) stores.add(s);
955
+ }
956
+ return [...stores];
957
+ }
958
+ }
959
+ function mergeSnapshots(snapshots) {
960
+ const merged = {};
961
+ for (const snap of snapshots) {
962
+ for (const [collection, records] of Object.entries(snap)) {
963
+ if (!merged[collection]) {
964
+ merged[collection] = { ...records };
965
+ continue;
966
+ }
967
+ for (const [id, envelope] of Object.entries(records)) {
968
+ const existing = merged[collection][id];
969
+ if (!existing || envelope._ts >= existing._ts) {
970
+ merged[collection][id] = envelope;
971
+ }
972
+ }
973
+ }
974
+ }
975
+ return merged;
976
+ }
977
+
978
+ // src/with-store/store-middleware.ts
979
+ function wrapStore(store, ...middlewares) {
980
+ let result = store;
981
+ for (let i = middlewares.length - 1; i >= 0; i--) {
982
+ result = middlewares[i](result);
983
+ }
984
+ return result;
985
+ }
986
+ function withRetry(opts = {}) {
987
+ const maxRetries = opts.maxRetries ?? 3;
988
+ const backoffMs = opts.backoffMs ?? 500;
989
+ const jitter = opts.jitter ?? 0.3;
990
+ const retryOn = opts.retryOn ? new Set(opts.retryOn) : null;
991
+ function shouldRetry(err) {
992
+ if (!retryOn) return true;
993
+ if (err && typeof err === "object" && "code" in err) {
994
+ return retryOn.has(err.code);
995
+ }
996
+ return true;
997
+ }
998
+ async function retryable(fn) {
999
+ let lastError;
1000
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
1001
+ try {
1002
+ return await fn();
1003
+ } catch (err) {
1004
+ lastError = err;
1005
+ if (attempt >= maxRetries || !shouldRetry(err)) throw err;
1006
+ const delay = backoffMs * Math.pow(2, attempt) * (1 + Math.random() * jitter);
1007
+ await new Promise((r) => setTimeout(r, delay));
1008
+ }
1009
+ }
1010
+ throw lastError;
1011
+ }
1012
+ return (next) => ({
1013
+ ...next,
1014
+ name: next.name ? `retry(${next.name})` : "retry",
1015
+ get: (v, c, id) => retryable(() => next.get(v, c, id)),
1016
+ put: (v, c, id, env, ev) => retryable(() => next.put(v, c, id, env, ev)),
1017
+ delete: (v, c, id) => retryable(() => next.delete(v, c, id)),
1018
+ list: (v, c) => retryable(() => next.list(v, c)),
1019
+ loadAll: (v) => retryable(() => next.loadAll(v)),
1020
+ saveAll: (v, d) => retryable(() => next.saveAll(v, d))
1021
+ });
1022
+ }
1023
+ var LOG_LEVELS = { debug: 0, info: 1, warn: 2, error: 3 };
1024
+ function withLogging(opts = {}) {
1025
+ const minLevel = LOG_LEVELS[opts.level ?? "info"];
1026
+ const logger = opts.logger ?? console;
1027
+ const logData = opts.logData ?? false;
1028
+ function log(level, method, args, durationMs) {
1029
+ if (LOG_LEVELS[level] < minLevel) return;
1030
+ const parts = [`[noydb:${method}]`, ...Object.entries(args).map(([k, v]) => `${k}=${String(v)}`)];
1031
+ if (durationMs !== void 0) parts.push(`${durationMs}ms`);
1032
+ logger[level](parts.join(" "));
1033
+ }
1034
+ function timed(method, args, fn) {
1035
+ const start = Date.now();
1036
+ return fn().then(
1037
+ (result) => {
1038
+ log("debug", method, args, Date.now() - start);
1039
+ return result;
1040
+ },
1041
+ (err) => {
1042
+ log("error", method, { ...args, error: err.message }, Date.now() - start);
1043
+ throw err;
1044
+ }
1045
+ );
1046
+ }
1047
+ return (next) => ({
1048
+ ...next,
1049
+ name: next.name ? `log(${next.name})` : "log",
1050
+ get: (v, c, id) => timed("get", { vault: v, collection: c, id }, () => next.get(v, c, id)),
1051
+ put: (v, c, id, env, ev) => timed("put", {
1052
+ vault: v,
1053
+ collection: c,
1054
+ id,
1055
+ version: env._v,
1056
+ ...logData ? { data: env._data.slice(0, 40) + "..." } : {}
1057
+ }, () => next.put(v, c, id, env, ev)),
1058
+ delete: (v, c, id) => timed("delete", { vault: v, collection: c, id }, () => next.delete(v, c, id)),
1059
+ list: (v, c) => timed("list", { vault: v, collection: c }, () => next.list(v, c)),
1060
+ loadAll: (v) => timed("loadAll", { vault: v }, () => next.loadAll(v)),
1061
+ saveAll: (v, d) => timed("saveAll", { vault: v }, () => next.saveAll(v, d))
1062
+ });
1063
+ }
1064
+ function withMetrics(opts) {
1065
+ function tracked(method, vault, fn, collection, id) {
1066
+ const start = Date.now();
1067
+ return fn().then(
1068
+ (result) => {
1069
+ opts.onOperation({
1070
+ method,
1071
+ vault,
1072
+ ...collection !== void 0 ? { collection } : {},
1073
+ ...id !== void 0 ? { id } : {},
1074
+ durationMs: Date.now() - start,
1075
+ success: true
1076
+ });
1077
+ return result;
1078
+ },
1079
+ (err) => {
1080
+ opts.onOperation({
1081
+ method,
1082
+ vault,
1083
+ ...collection !== void 0 ? { collection } : {},
1084
+ ...id !== void 0 ? { id } : {},
1085
+ durationMs: Date.now() - start,
1086
+ success: false,
1087
+ error: err
1088
+ });
1089
+ throw err;
1090
+ }
1091
+ );
1092
+ }
1093
+ return (next) => ({
1094
+ ...next,
1095
+ name: next.name ? `metrics(${next.name})` : "metrics",
1096
+ get: (v, c, id) => tracked("get", v, () => next.get(v, c, id), c, id),
1097
+ put: (v, c, id, env, ev) => tracked("put", v, () => next.put(v, c, id, env, ev), c, id),
1098
+ delete: (v, c, id) => tracked("delete", v, () => next.delete(v, c, id), c, id),
1099
+ list: (v, c) => tracked("list", v, () => next.list(v, c), c),
1100
+ loadAll: (v) => tracked("loadAll", v, () => next.loadAll(v)),
1101
+ saveAll: (v, d) => tracked("saveAll", v, () => next.saveAll(v, d))
1102
+ });
540
1103
  }
541
- async function normaliseCandidate(candidate, idKey, filter) {
542
- const out = /* @__PURE__ */ new Map();
543
- if (typeof candidate === "object" && candidate !== null && "exportStream" in candidate && typeof candidate.exportStream === "function") {
544
- for await (const chunk of candidate.exportStream({ granularity: "collection" })) {
545
- if (filter && !filter.has(chunk.collection)) continue;
546
- const collection = out.get(chunk.collection) ?? /* @__PURE__ */ new Map();
547
- for (const record of chunk.records) {
548
- const id = readIdField(record, idKey);
549
- if (!id) continue;
550
- collection.set(id, record);
1104
+ function withCircuitBreaker(opts = {}) {
1105
+ const threshold = opts.failureThreshold ?? 5;
1106
+ const resetMs = opts.resetTimeoutMs ?? 3e4;
1107
+ let state = "closed";
1108
+ let failures = 0;
1109
+ let lastFailureTime = 0;
1110
+ function recordSuccess() {
1111
+ if (state === "half-open") {
1112
+ state = "closed";
1113
+ failures = 0;
1114
+ opts.onClose?.();
1115
+ }
1116
+ failures = 0;
1117
+ }
1118
+ function recordFailure() {
1119
+ failures++;
1120
+ lastFailureTime = Date.now();
1121
+ if (failures >= threshold && state === "closed") {
1122
+ state = "open";
1123
+ opts.onOpen?.();
1124
+ }
1125
+ }
1126
+ function canAttempt() {
1127
+ if (state === "closed") return true;
1128
+ if (state === "open") {
1129
+ if (Date.now() - lastFailureTime >= resetMs) {
1130
+ state = "half-open";
1131
+ return true;
551
1132
  }
552
- out.set(chunk.collection, collection);
1133
+ return false;
553
1134
  }
554
- return out;
1135
+ return true;
555
1136
  }
556
- if (typeof candidate === "string") {
557
- let parsed;
1137
+ async function guarded(fn, fallback) {
1138
+ if (!canAttempt()) return fallback;
558
1139
  try {
559
- parsed = JSON.parse(candidate);
1140
+ const result = await fn();
1141
+ recordSuccess();
1142
+ return result;
560
1143
  } catch (err) {
561
- throw new Error(
562
- `diffVault: candidate string is not valid JSON (${err.message})`
563
- );
1144
+ recordFailure();
1145
+ throw err;
1146
+ }
1147
+ }
1148
+ return (next) => ({
1149
+ ...next,
1150
+ name: next.name ? `cb(${next.name})` : "cb",
1151
+ get: (v, c, id) => guarded(() => next.get(v, c, id), null),
1152
+ put: (v, c, id, env, ev) => guarded(() => next.put(v, c, id, env, ev), void 0),
1153
+ delete: (v, c, id) => guarded(() => next.delete(v, c, id), void 0),
1154
+ list: (v, c) => guarded(() => next.list(v, c), []),
1155
+ loadAll: (v) => guarded(() => next.loadAll(v), {}),
1156
+ saveAll: (v, d) => guarded(() => next.saveAll(v, d), void 0)
1157
+ });
1158
+ }
1159
+ function withCache(opts = {}) {
1160
+ const maxEntries = opts.maxEntries ?? 500;
1161
+ const ttlMs = opts.ttlMs ?? 6e4;
1162
+ const cache = /* @__PURE__ */ new Map();
1163
+ function cacheKey(vault, collection, id) {
1164
+ return `${vault}\0${collection}\0${id}`;
1165
+ }
1166
+ function getFromCache(key) {
1167
+ const entry = cache.get(key);
1168
+ if (!entry) return void 0;
1169
+ if (ttlMs > 0 && Date.now() - entry.cachedAt > ttlMs) {
1170
+ cache.delete(key);
1171
+ return void 0;
1172
+ }
1173
+ cache.delete(key);
1174
+ cache.set(key, entry);
1175
+ return entry.envelope;
1176
+ }
1177
+ function setInCache(key, envelope) {
1178
+ if (cache.size >= maxEntries) {
1179
+ const oldest = cache.keys().next().value;
1180
+ if (oldest !== void 0) cache.delete(oldest);
1181
+ }
1182
+ cache.set(key, { envelope, cachedAt: Date.now() });
1183
+ }
1184
+ function invalidate(key) {
1185
+ cache.delete(key);
1186
+ }
1187
+ return (next) => ({
1188
+ ...next,
1189
+ name: next.name ? `cache(${next.name})` : "cache",
1190
+ async get(vault, collection, id) {
1191
+ const key = cacheKey(vault, collection, id);
1192
+ const cached = getFromCache(key);
1193
+ if (cached !== void 0) return cached;
1194
+ const result = await next.get(vault, collection, id);
1195
+ setInCache(key, result);
1196
+ return result;
1197
+ },
1198
+ async put(vault, collection, id, env, ev) {
1199
+ invalidate(cacheKey(vault, collection, id));
1200
+ await next.put(vault, collection, id, env, ev);
1201
+ setInCache(cacheKey(vault, collection, id), env);
1202
+ },
1203
+ async delete(vault, collection, id) {
1204
+ invalidate(cacheKey(vault, collection, id));
1205
+ await next.delete(vault, collection, id);
1206
+ },
1207
+ list: (v, c) => next.list(v, c),
1208
+ loadAll: (v) => next.loadAll(v),
1209
+ saveAll: (v, d) => next.saveAll(v, d)
1210
+ });
1211
+ }
1212
+ function withHealthCheck(opts = {}) {
1213
+ const intervalMs = opts.checkIntervalMs ?? 3e4;
1214
+ const failThreshold = opts.suspendAfterFailures ?? 3;
1215
+ const successThreshold = opts.resumeAfterSuccess ?? 1;
1216
+ let isSuspended = false;
1217
+ let consecutiveFailures = 0;
1218
+ let consecutiveSuccesses = 0;
1219
+ return (next) => {
1220
+ const checkFn = opts.check ?? (next.ping ? () => next.ping() : async () => {
1221
+ await next.list("__health__", "__ping__");
1222
+ return true;
1223
+ });
1224
+ async function doCheck() {
1225
+ try {
1226
+ const ok = await checkFn();
1227
+ if (ok) {
1228
+ consecutiveFailures = 0;
1229
+ consecutiveSuccesses++;
1230
+ if (isSuspended && consecutiveSuccesses >= successThreshold) {
1231
+ isSuspended = false;
1232
+ consecutiveSuccesses = 0;
1233
+ opts.onResume?.();
1234
+ }
1235
+ } else {
1236
+ throw new Error("Health check returned false");
1237
+ }
1238
+ } catch {
1239
+ consecutiveSuccesses = 0;
1240
+ consecutiveFailures++;
1241
+ if (!isSuspended && consecutiveFailures >= failThreshold) {
1242
+ isSuspended = true;
1243
+ consecutiveFailures = 0;
1244
+ opts.onSuspend?.();
1245
+ }
1246
+ }
1247
+ }
1248
+ setInterval(() => {
1249
+ void doCheck();
1250
+ }, intervalMs);
1251
+ const wrapped = {
1252
+ ...next,
1253
+ name: next.name ? `health(${next.name})` : "health",
1254
+ async get(v, c, id) {
1255
+ return isSuspended ? null : next.get(v, c, id);
1256
+ },
1257
+ async put(v, c, id, env, ev) {
1258
+ if (!isSuspended) await next.put(v, c, id, env, ev);
1259
+ },
1260
+ async delete(v, c, id) {
1261
+ if (!isSuspended) await next.delete(v, c, id);
1262
+ },
1263
+ async list(v, c) {
1264
+ return isSuspended ? [] : next.list(v, c);
1265
+ },
1266
+ async loadAll(v) {
1267
+ return isSuspended ? {} : next.loadAll(v);
1268
+ },
1269
+ async saveAll(v, d) {
1270
+ if (!isSuspended) await next.saveAll(v, d);
1271
+ }
1272
+ };
1273
+ return wrapped;
1274
+ };
1275
+ }
1276
+
1277
+ // src/with-commit/numbering/descriptor.ts
1278
+ function withDeferredNumbering(config) {
1279
+ return {
1280
+ series: config.series,
1281
+ collection: config.collection,
1282
+ field: config.field,
1283
+ settleWindowMs: config.settleWindowMs ?? 0
1284
+ };
1285
+ }
1286
+
1287
+ // src/with-shape/money/arith.ts
1288
+ function parseAmount(label, amount, scale, rounding) {
1289
+ const r = parseToScaledInt(amount, scale, rounding);
1290
+ if (!r.ok) {
1291
+ throw new MoneyUnsupportedError(
1292
+ r.reason === "precision" ? `${label}: amount ${JSON.stringify(amount)} has more precision than scale ${scale} and no rounding mode is configured` : `${label}: amount ${JSON.stringify(amount)} is not a finite decimal`
1293
+ );
1294
+ }
1295
+ return r.value;
1296
+ }
1297
+ function resolveScale(label, amount, explicit) {
1298
+ if (explicit !== void 0) {
1299
+ if (!Number.isInteger(explicit) || explicit < 0) {
1300
+ throw new MoneyUnsupportedError(`${label}: scale must be a non-negative integer`);
564
1301
  }
565
- return collectionsFromObject(parsed, idKey, filter);
1302
+ return explicit;
1303
+ }
1304
+ const inferred = decimalScaleOf(amount);
1305
+ if (inferred === null) {
1306
+ throw new MoneyUnsupportedError(`${label}: amount ${JSON.stringify(amount)} is not a finite decimal`);
566
1307
  }
567
- return collectionsFromObject(candidate, idKey, filter);
1308
+ return inferred;
568
1309
  }
569
- function collectionsFromObject(raw, idKey, filter) {
570
- const out = /* @__PURE__ */ new Map();
571
- if (raw === null || typeof raw !== "object") {
572
- throw new Error("diffVault: candidate must be a Vault, an object, or a JSON string");
573
- }
574
- for (const [key, value] of Object.entries(raw)) {
575
- if (key.startsWith("_")) continue;
576
- if (filter && !filter.has(key)) continue;
577
- if (!Array.isArray(value)) continue;
578
- const collection = /* @__PURE__ */ new Map();
579
- for (const record of value) {
580
- if (record === null || typeof record !== "object") continue;
581
- const id = readIdField(record, idKey);
582
- if (!id) continue;
583
- collection.set(id, record);
1310
+ function mulRate(amount, rate, opts = {}) {
1311
+ const scale = resolveScale("mulRate", amount, opts.scale);
1312
+ const rounding = opts.rounding ?? "half-up";
1313
+ const a = parseAmount("mulRate", amount, scale, rounding);
1314
+ const rateScale = decimalScaleOf(rate);
1315
+ if (rateScale === null) {
1316
+ throw new MoneyUnsupportedError(`mulRate: rate ${JSON.stringify(rate)} is not a finite decimal`);
1317
+ }
1318
+ const r = parseToScaledInt(rate, rateScale);
1319
+ if (!r.ok) {
1320
+ throw new MoneyUnsupportedError(`mulRate: rate ${JSON.stringify(rate)} is not a finite decimal`);
1321
+ }
1322
+ const product = a * r.value;
1323
+ return formatScaledInt(rescaleScaledInt(product, scale + rateScale, scale, rounding), scale);
1324
+ }
1325
+ function allocate(amount, weights, opts = {}) {
1326
+ if (weights.length === 0) {
1327
+ throw new MoneyUnsupportedError("allocate: weights must not be empty");
1328
+ }
1329
+ const scale = resolveScale("allocate", amount, opts.scale);
1330
+ const a = parseAmount("allocate", amount, scale);
1331
+ let weightScale = 0;
1332
+ for (const w of weights) {
1333
+ const s = decimalScaleOf(w);
1334
+ if (s === null) {
1335
+ throw new MoneyUnsupportedError(`allocate: weight ${JSON.stringify(w)} is not a finite decimal`);
1336
+ }
1337
+ if (s > weightScale) weightScale = s;
1338
+ }
1339
+ const scaledWeights = weights.map((w) => {
1340
+ const r = parseToScaledInt(w, weightScale);
1341
+ if (!r.ok || r.value < 0n) {
1342
+ throw new MoneyUnsupportedError(`allocate: weight ${JSON.stringify(w)} must be a non-negative decimal`);
584
1343
  }
585
- out.set(key, collection);
1344
+ return r.value;
1345
+ });
1346
+ const sumW = scaledWeights.reduce((acc, w) => acc + w, 0n);
1347
+ if (sumW === 0n) {
1348
+ throw new MoneyUnsupportedError("allocate: weights must not all be zero");
1349
+ }
1350
+ const negative = a < 0n;
1351
+ const mag = negative ? -a : a;
1352
+ const base = [];
1353
+ const remainders = [];
1354
+ let distributed = 0n;
1355
+ for (let i = 0; i < scaledWeights.length; i++) {
1356
+ const product = mag * scaledWeights[i];
1357
+ const share = product / sumW;
1358
+ base.push(share);
1359
+ distributed += share;
1360
+ remainders.push({ index: i, rem: product % sumW });
1361
+ }
1362
+ let leftover = mag - distributed;
1363
+ remainders.sort((x, y) => y.rem > x.rem ? 1 : y.rem < x.rem ? -1 : x.index - y.index);
1364
+ for (const { index } of remainders) {
1365
+ if (leftover === 0n) break;
1366
+ base[index] = base[index] + 1n;
1367
+ leftover -= 1n;
586
1368
  }
587
- return out;
1369
+ return base.map((p) => formatScaledInt(negative && p !== 0n ? -p : p, scale));
588
1370
  }
589
- function uniqueTopLevelKeys(diffs) {
590
- const keys = /* @__PURE__ */ new Set();
591
- for (const d of diffs) {
592
- const m = /^[^.[]+/.exec(d.path);
593
- if (m) keys.add(m[0]);
1371
+
1372
+ // src/with-shape/money/branded.ts
1373
+ function asMoney(value) {
1374
+ if (!isMoneyLike(value)) {
1375
+ throw new MoneyUnsupportedError(`asMoney: ${JSON.stringify(value)} is not a finite decimal`);
594
1376
  }
595
- return [...keys];
1377
+ return String(value).trim();
596
1378
  }
597
- function readIdField(record, idKey) {
598
- if (record === null || typeof record !== "object") return "";
599
- const v = record[idKey];
600
- if (typeof v === "string") return v;
601
- if (typeof v === "number" && Number.isFinite(v)) return String(v);
602
- return "";
1379
+ function isMoneyString(value) {
1380
+ return typeof value === "string" && isMoneyLike(value);
603
1381
  }
604
- function formatDiff2(detail, b) {
605
- const head = `${b.summary.add} added \xB7 ${b.summary.modify} modified \xB7 ${b.summary.delete} deleted`;
606
- if (detail === "count") return head;
607
- if (b.summary.total === 0) return head + "\n(no changes)";
608
- if (detail === "one-line") return head;
609
- const rows = [head, ""];
610
- for (const e of b.added) rows.push(`${e.collection}/${e.id} added`);
611
- for (const e of b.modified) {
612
- const fields = e.fieldDiffs.map((f) => `${f.path}: ${shortJSON(f.from)} \u2192 ${shortJSON(f.to)}`).join(", ");
613
- rows.push(`${e.collection}/${e.id} modified ${fields}`);
614
- }
615
- for (const e of b.deleted) rows.push(`${e.collection}/${e.id} deleted`);
616
- return rows.join("\n");
1382
+ function moneyNumber(value) {
1383
+ if (!isMoneyLike(value)) {
1384
+ throw new MoneyUnsupportedError(`moneyNumber: ${JSON.stringify(value)} is not a finite decimal`);
1385
+ }
1386
+ return Number(value);
617
1387
  }
618
- function shortJSON(value) {
619
- if (value === void 0) return "undefined";
620
- const s = JSON.stringify(value);
621
- if (typeof s !== "string") return "<unrepresentable>";
622
- return s.length > 60 ? s.slice(0, 57) + "..." : s;
1388
+ function isMoneyLike(value) {
1389
+ if (typeof value === "number") return Number.isFinite(value);
1390
+ if (typeof value !== "string") return false;
1391
+ return decimalScaleOf(value) !== null;
623
1392
  }
624
1393
  export {
625
1394
  Aggregation,
626
1395
  AlreadyElevatedError,
627
1396
  AmendmentForbiddenError,
628
1397
  AttestationError,
1398
+ AttestationNotEnabledError,
629
1399
  BLOB_CHUNKS_COLLECTION,
630
1400
  BLOB_COLLECTION,
631
1401
  BLOB_INDEX_COLLECTION,
@@ -639,13 +1409,18 @@ export {
639
1409
  BundleSealMismatchError,
640
1410
  BundleVersionConflictError,
641
1411
  CONSENT_AUDIT_COLLECTION,
1412
+ CargoNotEnabledError,
642
1413
  Collection,
643
1414
  CollectionFrame,
644
1415
  CollectionIndexes,
645
1416
  CollectionInstant,
1417
+ ComputedFieldError,
646
1418
  ConflictError,
647
1419
  CrossJoinSourceUnknownError,
648
1420
  CrossJoinTooLargeError,
1421
+ CustodyApi,
1422
+ CustodyNotEnabledError,
1423
+ DEED_RECORD_ID,
649
1424
  DEFAULT_CHUNK_SIZE,
650
1425
  DEFAULT_CROSS_JOIN_MAX_ROWS,
651
1426
  DEFAULT_FRESHNESS_MS,
@@ -655,6 +1430,9 @@ export {
655
1430
  DICT_COLLECTION_PREFIX,
656
1431
  DIRECTORY_RECORD_ID,
657
1432
  DanglingReferenceError,
1433
+ DataResidencyError,
1434
+ DebugPlaintextError,
1435
+ DebugReservedFieldError,
658
1436
  DecryptionError,
659
1437
  DelegationTargetMissingError,
660
1438
  DerivationCapExceededError,
@@ -669,9 +1447,13 @@ export {
669
1447
  ELEVATION_AUDIT_COLLECTION,
670
1448
  ElevatedHandle,
671
1449
  ElevationExpiredError,
1450
+ EmbeddingDimMismatchError,
1451
+ EmbeddingModelMismatchError,
1452
+ EnclaveNotSupportedError,
672
1453
  ExportCapabilityError,
673
1454
  FieldFrozenError,
674
1455
  FilenameSanitizationError,
1456
+ ForgetStrategyNotConfiguredError,
675
1457
  GROUPBY_MAX_CARDINALITY,
676
1458
  GROUPBY_WARN_CARDINALITY,
677
1459
  GroupCardinalityError,
@@ -679,6 +1461,7 @@ export {
679
1461
  GroupedQuery,
680
1462
  GroupedQueryN,
681
1463
  INDEXED_STORE_POLICY,
1464
+ IllegalTransitionError,
682
1465
  ImportCapabilityError,
683
1466
  IndexRequiredError,
684
1467
  IndexWriteFailureError,
@@ -691,6 +1474,8 @@ export {
691
1474
  LEDGER_DELTAS_COLLECTION,
692
1475
  LedgerContentionError,
693
1476
  LedgerStore,
1477
+ LinkEndpointError,
1478
+ LinkIntegrityError,
694
1479
  LocaleNotSpecifiedError,
695
1480
  Lru,
696
1481
  MAGIC_LINK_CONTENT_INFO_PREFIX,
@@ -706,6 +1491,9 @@ export {
706
1491
  MemorySealingKeyProvider,
707
1492
  MigrationRequiredError,
708
1493
  MissingTranslationError,
1494
+ MoneyCurrencyError,
1495
+ MoneyPrecisionError,
1496
+ MoneyUnsupportedError,
709
1497
  NOYDB_BACKUP_VERSION,
710
1498
  NOYDB_BUNDLE_FORMAT_VERSION,
711
1499
  NOYDB_BUNDLE_MAGIC,
@@ -713,26 +1501,34 @@ export {
713
1501
  NOYDB_FORMAT_VERSION,
714
1502
  NOYDB_KEYRING_VERSION,
715
1503
  NOYDB_SYNC_VERSION,
1504
+ NO_CARGO,
1505
+ NO_CUSTODY,
1506
+ NO_SEARCH,
1507
+ NO_SEQUENCE,
716
1508
  NetworkError,
717
1509
  NoAccessError,
718
1510
  NonAdditiveSchemaChangeError,
719
1511
  NotFoundError,
720
1512
  Noydb,
721
1513
  NoydbError,
1514
+ NumberingUncertaintyError,
722
1515
  OverlayBaseIsVirtualError,
723
1516
  OverlayCollectionUnavailableError,
724
1517
  OverlayIdMismatchError,
725
1518
  OverlayNameCollisionError,
726
1519
  PERIODS_COLLECTION,
727
1520
  PERSONAL_POLICY,
1521
+ POD_STORE_POLICY,
728
1522
  POLICY_RECORD_ID,
729
1523
  PUBLIC_ENVELOPE_FIELDS,
730
1524
  PUBLIC_ENVELOPE_RECORD_ID,
731
1525
  PathEscapeError,
732
1526
  PeriodClosedError,
733
1527
  PermissionDeniedError,
1528
+ PodVersionConflictError,
734
1529
  PolicyDeniedError,
735
1530
  PolicyEnforcer,
1531
+ PortabilityNotEnabledError,
736
1532
  PresenceHandle,
737
1533
  PrivilegeEscalationError,
738
1534
  Query,
@@ -741,6 +1537,7 @@ export {
741
1537
  ReadOnlyAtInstantError,
742
1538
  ReadOnlyError,
743
1539
  ReadOnlyFrameError,
1540
+ RecordCekNotFoundError,
744
1541
  RecordLockedError,
745
1542
  RecoveryNotEnrolledError,
746
1543
  RecoveryProfileNotImplementedError,
@@ -748,8 +1545,10 @@ export {
748
1545
  RefRegistry,
749
1546
  RefScopeError,
750
1547
  ReservedCollectionNameError,
1548
+ ReservedVaultNameError,
751
1549
  SCHEMAS_COLLECTION,
752
1550
  SEALED_PASSPHRASE_RECORD_ID,
1551
+ STATE_VAULT_NAME,
753
1552
  STRICT_POLICY,
754
1553
  SYNC_CREDENTIALS_COLLECTION,
755
1554
  ScanBuilder,
@@ -758,10 +1557,21 @@ export {
758
1557
  SchemaUpdateError,
759
1558
  SchemaValidationError,
760
1559
  ScriptViolationError,
1560
+ SealedHandle,
1561
+ SealedRecordExpiredError,
1562
+ SealedRecordMismatchError,
1563
+ SealedRecordNotEnabledError,
1564
+ SearchNotEnabledError,
1565
+ SequenceContentionError,
1566
+ SequenceNotEnabledError,
1567
+ SequenceOfflineError,
1568
+ SequenceStore,
761
1569
  SessionExpiredError,
762
1570
  SessionNotFoundError,
763
1571
  SessionPolicyError,
1572
+ ShardProvisioningError,
764
1573
  SnapshotNotFoundError,
1574
+ StaticDictReadonlyError,
765
1575
  StoreCapabilityError,
766
1576
  SyncEngine,
767
1577
  SyncScheduler,
@@ -769,12 +1579,17 @@ export {
769
1579
  TamperedError,
770
1580
  TierDemoteDeniedError,
771
1581
  TierNotGrantedError,
1582
+ TiersNotEnabledError,
772
1583
  TranslatorNotConfiguredError,
773
1584
  TxCollection,
774
1585
  TxContext,
775
1586
  TxVault,
776
1587
  USER_ENVELOPE_COLLECTION,
777
1588
  USER_ENVELOPE_MAX_BYTES,
1589
+ UniqueConstraintError,
1590
+ UnknownDictCodeError,
1591
+ UnknownShardError,
1592
+ UnsupportedIndexOptionError,
778
1593
  UserApi,
779
1594
  UserEnvelopeOversizedError,
780
1595
  VISIBILITY_RECORD_PREFIX,
@@ -782,12 +1597,18 @@ export {
782
1597
  Vault,
783
1598
  VaultFrame,
784
1599
  VaultInstant,
1600
+ VaultTemplateNotFoundError,
785
1601
  WeakPassphraseError,
1602
+ WithdrawalRequestError,
786
1603
  activeSessionCount,
787
1604
  additiveOnly,
1605
+ aesGcmOpen,
1606
+ allocate,
788
1607
  applyI18nLocale,
789
1608
  applyJoins,
790
1609
  applyPatch,
1610
+ approveWithdrawal,
1611
+ asMoney,
791
1612
  assertStrongPassphrase,
792
1613
  assertTierAccess,
793
1614
  avg,
@@ -800,17 +1621,21 @@ export {
800
1621
  canonicalJson,
801
1622
  checkGate,
802
1623
  clearDevUnlock,
1624
+ compileSequenceFormat,
803
1625
  computePatch,
804
1626
  coordinatedCutover,
805
1627
  count,
806
1628
  createBundleStore,
1629
+ createDeedOwner,
807
1630
  createEnforcer,
808
1631
  createNoydb,
1632
+ createPodStore,
809
1633
  createSession,
810
1634
  createStore,
811
1635
  credentialStatus,
812
1636
  decryptBytes,
813
1637
  decryptDeterministic,
1638
+ decryptExtractedPartition,
814
1639
  dekKey,
815
1640
  deleteCredential,
816
1641
  deleteUserEnvelope,
@@ -838,13 +1663,16 @@ export {
838
1663
  envelopePayloadHash,
839
1664
  estimateEntropy,
840
1665
  estimateRecordBytes,
1666
+ evalComputedFields,
841
1667
  evaluateClause,
842
1668
  evaluateExportCapability,
843
1669
  evaluateFieldClause,
844
1670
  evaluateImportCapability,
845
1671
  executePlan,
1672
+ exportAccessibleData,
846
1673
  findAuthenticator,
847
1674
  formatDiff,
1675
+ fuseRetrieval,
848
1676
  generateULID,
849
1677
  getCredential,
850
1678
  groupAndReduce,
@@ -854,26 +1682,38 @@ export {
854
1682
  hasRecoveryEnrolled,
855
1683
  hashEntry,
856
1684
  i18nText,
1685
+ immutableGuard,
1686
+ importExternalObjects,
857
1687
  inferScripts,
1688
+ isDeedVault,
858
1689
  isDevUnlockActive,
859
1690
  isDictCollectionName,
860
1691
  isDictKeyDescriptor,
1692
+ isDiscriminant,
861
1693
  isI18nTextDescriptor,
1694
+ isLinkCollectionName,
862
1695
  isMagicLinkGrantExpired,
1696
+ isMoneyDescriptor,
1697
+ isMoneyString,
863
1698
  isPreCompressed,
864
1699
  isPublicEnvelope,
1700
+ isRefArray,
865
1701
  isSessionAlive,
1702
+ isStaticDictDescriptor,
866
1703
  isULID,
867
1704
  isZodSchema,
868
1705
  issueDelegation,
869
1706
  recoverPassphrase as keyringRecoverPassphrase,
870
1707
  rotatePassphrase as keyringRotatePassphrase,
1708
+ liberateVault,
871
1709
  listCredentials,
872
1710
  listMagicLinkGrants,
873
1711
  listUserEnvelopeIds,
874
1712
  listUsers,
875
1713
  listUsersWithEnvelopes,
1714
+ listWithdrawalRequests,
876
1715
  loadActiveDelegations,
1716
+ loadDeedMarker,
877
1717
  loadDevUnlock,
878
1718
  loadPaperRecoveryEntries,
879
1719
  loadPersistedSchema,
@@ -885,15 +1725,24 @@ export {
885
1725
  lockSchema,
886
1726
  magicLinkGrantRecordId,
887
1727
  max,
1728
+ memoryObjectProjection,
1729
+ memoryStore,
888
1730
  mergeCrdtStates,
889
1731
  mergePolicy,
890
1732
  min,
891
1733
  mintPaperRecoveryEntry,
892
1734
  mintShamirRecoveryEntry,
893
1735
  mintWrappedDeksBlob,
1736
+ money,
1737
+ moneyMax,
1738
+ moneyMin,
1739
+ moneyNumber,
1740
+ moneySum,
1741
+ mulRate,
894
1742
  paddedIndex,
895
1743
  parseBytes,
896
1744
  parseIndex,
1745
+ parseRsaOaepTlv,
897
1746
  parseSealedEnvelope,
898
1747
  persistDirectoryConfig,
899
1748
  persistSchemaIfNeeded,
@@ -905,18 +1754,26 @@ export {
905
1754
  readNoydbBundleHeader,
906
1755
  readNoydbBundlePublicEnvelope,
907
1756
  readPath,
1757
+ readPlaintextRecord,
1758
+ readPod,
1759
+ readPodHeader,
908
1760
  readPublicEnvelope,
909
1761
  readUserVisibility,
910
1762
  recoverUser,
911
1763
  reduceRecords,
1764
+ reducerBuilder,
912
1765
  ref,
1766
+ refArray,
1767
+ rejectWithdrawal,
913
1768
  removeAuthenticator,
1769
+ requestWithdrawal,
914
1770
  resetBrotliSupportCache,
915
1771
  resetJoinWarnings,
916
1772
  resolveCrdtSnapshot,
917
1773
  resolveI18nText,
918
1774
  resolvePolicy,
919
1775
  resolveSchema as resolvePublicEnvelopeSchema,
1776
+ resolveSequenceKey,
920
1777
  resolveSession,
921
1778
  revokeAllSessions,
922
1779
  revokeDelegation,
@@ -931,8 +1788,13 @@ export {
931
1788
  saveShamirRecoveryEntries,
932
1789
  saveUserEnvelope,
933
1790
  saveVaultPolicy,
1791
+ scaleForCurrency,
1792
+ sealRsaOaepTlv,
934
1793
  sha256Hex,
1794
+ staticDict,
935
1795
  sum,
1796
+ tokenize,
1797
+ transitionGuard,
936
1798
  unwrapDeksFromBlob,
937
1799
  unwrapDeksFromPaperEntry,
938
1800
  unwrapDeksFromShamirEntry,
@@ -944,8 +1806,12 @@ export {
944
1806
  validateSchemaOutput,
945
1807
  validateSessionPolicy,
946
1808
  visibilityRecordId,
1809
+ withArchive,
947
1810
  withCache,
1811
+ withCargo,
948
1812
  withCircuitBreaker,
1813
+ withCustody,
1814
+ withDeferredNumbering,
949
1815
  withDerivation,
950
1816
  withGuard,
951
1817
  withHealthCheck,
@@ -954,9 +1820,15 @@ export {
954
1820
  withMetrics,
955
1821
  withOverlayedView,
956
1822
  withRetry,
1823
+ withRollup,
1824
+ withSearch,
1825
+ withSequence,
1826
+ withdrawAccessibleData,
957
1827
  wrapBundleStore,
1828
+ wrapPodStore,
958
1829
  wrapStore,
959
1830
  writeMagicLinkGrant,
960
- writeNoydbBundle
1831
+ writeNoydbBundle,
1832
+ writePod
961
1833
  };
962
1834
  //# sourceMappingURL=index.js.map