@noy-db/hub 0.4.0-pre.1 → 0.4.0-pre.11

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 (605) hide show
  1. package/README.md +3 -4
  2. package/dist/api-ZDKTWNBB.js +20 -0
  3. package/dist/attestation/index.js +18 -18
  4. package/dist/{backup-LU2DTZTI.js → backup-2UX7PRM5.js} +13 -13
  5. package/dist/blobs/index.js +30 -15
  6. package/dist/blobs/index.js.map +1 -1
  7. package/dist/broker/index.js +12 -12
  8. package/dist/broker/index.js.map +1 -1
  9. package/dist/cargo/index.js +53 -43
  10. package/dist/{chunk-YTGDPCPW.js → chunk-2J6UEN2V.js} +42 -18
  11. package/dist/chunk-2J6UEN2V.js.map +1 -0
  12. package/dist/{chunk-IY23KFNZ.js → chunk-35NMVJ7I.js} +3 -3
  13. package/dist/{chunk-S3BFKGET.js → chunk-3HUYRN24.js} +4 -4
  14. package/dist/chunk-3HUYRN24.js.map +1 -0
  15. package/dist/{walk-XS3PKM6I.js → chunk-3V3XR4S4.js} +4 -13
  16. package/dist/{walk-XS3PKM6I.js.map → chunk-3V3XR4S4.js.map} +1 -1
  17. package/dist/{chunk-RTEK4C4I.js → chunk-4JQK3L4V.js} +2 -2
  18. package/dist/{chunk-3ELCWU56.js → chunk-4ZKNC6A6.js} +2 -2
  19. package/dist/{chunk-VQNJ7UZL.js → chunk-55LKVALY.js} +106 -10
  20. package/dist/chunk-55LKVALY.js.map +1 -0
  21. package/dist/{chunk-VAIS3SOM.js → chunk-55LX6FSX.js} +2 -2
  22. package/dist/chunk-5D2ALSM5.js +19 -0
  23. package/dist/chunk-5D2ALSM5.js.map +1 -0
  24. package/dist/{chunk-6HPG2YNX.js → chunk-5DRROK5W.js} +2 -2
  25. package/dist/{chunk-S6Q37VGE.js → chunk-5GQEU4DN.js} +2 -2
  26. package/dist/chunk-5JOFWL4G.js +25 -0
  27. package/dist/chunk-5JOFWL4G.js.map +1 -0
  28. package/dist/{chunk-TOPYT5U5.js → chunk-63FE525P.js} +6 -6
  29. package/dist/chunk-6LJY7X5A.js +18 -0
  30. package/dist/chunk-6LJY7X5A.js.map +1 -0
  31. package/dist/{chunk-JVBO4SZL.js → chunk-6UBZ6I5Z.js} +2 -2
  32. package/dist/{chunk-BOKIKJJB.js → chunk-6ZNSB3H6.js} +5 -17
  33. package/dist/chunk-6ZNSB3H6.js.map +1 -0
  34. package/dist/{chunk-BMQWTQZ4.js → chunk-7YVBQJ7K.js} +13 -355
  35. package/dist/chunk-7YVBQJ7K.js.map +1 -0
  36. package/dist/{chunk-UFEVO57O.js → chunk-ABS7FMMD.js} +6 -6
  37. package/dist/chunk-AFHQATY4.js +47 -0
  38. package/dist/chunk-AFHQATY4.js.map +1 -0
  39. package/dist/{chunk-HOONYZY2.js → chunk-AKKRXT23.js} +7 -7
  40. package/dist/chunk-AKKRXT23.js.map +1 -0
  41. package/dist/{chunk-DDHM2TLX.js → chunk-AT2JJEKJ.js} +4 -4
  42. package/dist/chunk-AT2JJEKJ.js.map +1 -0
  43. package/dist/{chunk-M75ZZHSR.js → chunk-BLBAQRBM.js} +2 -2
  44. package/dist/{chunk-3SV2EPMN.js → chunk-BLCWSJLN.js} +88 -81
  45. package/dist/chunk-BLCWSJLN.js.map +1 -0
  46. package/dist/chunk-CADUYBQD.js +151 -0
  47. package/dist/chunk-CADUYBQD.js.map +1 -0
  48. package/dist/{chunk-G6EQYAL6.js → chunk-CI32CAFS.js} +5 -5
  49. package/dist/{chunk-FH52K7EG.js → chunk-CUZLNGD5.js} +2 -6
  50. package/dist/{chunk-FH52K7EG.js.map → chunk-CUZLNGD5.js.map} +1 -1
  51. package/dist/{chunk-2P7EGNKF.js → chunk-CXQW2NWO.js} +145 -3
  52. package/dist/chunk-CXQW2NWO.js.map +1 -0
  53. package/dist/{chunk-6B4DYGWO.js → chunk-DABACXEF.js} +3 -3
  54. package/dist/{chunk-F6T6L2UK.js → chunk-DMH3VZU5.js} +4 -4
  55. package/dist/chunk-DSDXAKIP.js +50 -0
  56. package/dist/chunk-DSDXAKIP.js.map +1 -0
  57. package/dist/{chunk-MQ6WOPSY.js → chunk-DZ2JXHWK.js} +5 -5
  58. package/dist/chunk-DZFQVICS.js +23 -0
  59. package/dist/chunk-DZFQVICS.js.map +1 -0
  60. package/dist/chunk-E23UGFVC.js +63 -0
  61. package/dist/chunk-E23UGFVC.js.map +1 -0
  62. package/dist/{chunk-UBNCR3YK.js → chunk-EE7UHLKH.js} +4 -4
  63. package/dist/chunk-EIPVYUEP.js +654 -0
  64. package/dist/chunk-EIPVYUEP.js.map +1 -0
  65. package/dist/{chunk-EGCRBCNA.js → chunk-EKRSCRNM.js} +3 -3
  66. package/dist/{chunk-YMUGBZN2.js → chunk-FQ5CHJR7.js} +1 -1
  67. package/dist/chunk-FQ5CHJR7.js.map +1 -0
  68. package/dist/{chunk-LB6OH6K2.js → chunk-FQZ6XTQ7.js} +17 -20
  69. package/dist/chunk-FQZ6XTQ7.js.map +1 -0
  70. package/dist/{chunk-IRQY7IR5.js → chunk-FRMPM7WG.js} +4 -4
  71. package/dist/{chunk-DVUZMT2W.js → chunk-G2JUIDFA.js} +9 -9
  72. package/dist/{chunk-DVUZMT2W.js.map → chunk-G2JUIDFA.js.map} +1 -1
  73. package/dist/{chunk-RND5ZPNP.js → chunk-G6WWZNJP.js} +13 -13
  74. package/dist/chunk-G6WWZNJP.js.map +1 -0
  75. package/dist/chunk-GJW4HX2O.js +1 -0
  76. package/dist/{chunk-T6GU5PPZ.js → chunk-GU3IP74F.js} +6 -6
  77. package/dist/{chunk-5OI6BR4H.js → chunk-GWWOGNBK.js} +308 -18
  78. package/dist/chunk-GWWOGNBK.js.map +1 -0
  79. package/dist/{chunk-UNCOC7QH.js → chunk-H2GPHUZD.js} +12 -13
  80. package/dist/chunk-H2GPHUZD.js.map +1 -0
  81. package/dist/{chunk-7CI6CP7Z.js → chunk-HMU5P6RL.js} +5 -5
  82. package/dist/chunk-HMU5P6RL.js.map +1 -0
  83. package/dist/{chunk-YJV2UZ7H.js → chunk-I5GEJX3R.js} +5 -5
  84. package/dist/chunk-I5GEJX3R.js.map +1 -0
  85. package/dist/{chunk-GWKAVKHI.js → chunk-IG6KUWBX.js} +2 -2
  86. package/dist/chunk-IG6KUWBX.js.map +1 -0
  87. package/dist/{chunk-MTQPRQHB.js → chunk-IPUG56GJ.js} +15 -5
  88. package/dist/{chunk-MTQPRQHB.js.map → chunk-IPUG56GJ.js.map} +1 -1
  89. package/dist/{chunk-SMIRGMS7.js → chunk-IXNCZTWA.js} +2 -2
  90. package/dist/{chunk-RM2XV574.js → chunk-IXTSNGYY.js} +3 -3
  91. package/dist/{chunk-KUPKLSX5.js → chunk-IYZISPGD.js} +7 -5
  92. package/dist/chunk-IYZISPGD.js.map +1 -0
  93. package/dist/{chunk-SMGEYW6G.js → chunk-JDOMW53O.js} +26 -16
  94. package/dist/chunk-JDOMW53O.js.map +1 -0
  95. package/dist/{chunk-PK6QCH2C.js → chunk-JJZGIE4U.js} +6 -5
  96. package/dist/{chunk-DRWBEDYO.js → chunk-JYJFGD2H.js} +2 -2
  97. package/dist/{chunk-TAGR72IR.js → chunk-KRCBZYTZ.js} +26 -177
  98. package/dist/chunk-KRCBZYTZ.js.map +1 -0
  99. package/dist/{chunk-HPUWOVR7.js → chunk-L2DGWBCT.js} +14 -14
  100. package/dist/chunk-L2DGWBCT.js.map +1 -0
  101. package/dist/{chunk-VEALDPHW.js → chunk-L3YYLT4E.js} +15 -2
  102. package/dist/chunk-L3YYLT4E.js.map +1 -0
  103. package/dist/{chunk-A7JJLVGH.js → chunk-LNPUSMZL.js} +29 -31
  104. package/dist/chunk-LNPUSMZL.js.map +1 -0
  105. package/dist/{chunk-KUIB4B5Q.js → chunk-LNZKOUJR.js} +2 -2
  106. package/dist/{chunk-IM3QVF53.js → chunk-MBKVNOJS.js} +6 -6
  107. package/dist/chunk-MCHBCNCE.js +367 -0
  108. package/dist/chunk-MCHBCNCE.js.map +1 -0
  109. package/dist/{chunk-VCBHAE4R.js → chunk-MHMLXJ3I.js} +2 -2
  110. package/dist/chunk-MHMLXJ3I.js.map +1 -0
  111. package/dist/{chunk-WNGGJWF7.js → chunk-MSMJJB4J.js} +2 -2
  112. package/dist/chunk-MSMJJB4J.js.map +1 -0
  113. package/dist/{chunk-T36RFODW.js → chunk-MXUT7FTE.js} +2 -2
  114. package/dist/chunk-MXUT7FTE.js.map +1 -0
  115. package/dist/{chunk-BGK233EA.js → chunk-N4BBNYIB.js} +11 -9
  116. package/dist/chunk-N4BBNYIB.js.map +1 -0
  117. package/dist/{chunk-3PF6CRDT.js → chunk-NFIBXF4V.js} +1082 -1583
  118. package/dist/chunk-NFIBXF4V.js.map +1 -0
  119. package/dist/{chunk-LOF2W3JU.js → chunk-NFNJLRY7.js} +368 -52
  120. package/dist/chunk-NFNJLRY7.js.map +1 -0
  121. package/dist/{chunk-N6WF5PKC.js → chunk-NFZGZ4AK.js} +2 -2
  122. package/dist/{chunk-JRBNCUNT.js → chunk-NGSJZFGL.js} +21 -4
  123. package/dist/chunk-NGSJZFGL.js.map +1 -0
  124. package/dist/chunk-NJ4DYYO5.js +81 -0
  125. package/dist/chunk-NJ4DYYO5.js.map +1 -0
  126. package/dist/{chunk-2IALOXZS.js → chunk-NM5UYF6Q.js} +2 -2
  127. package/dist/chunk-NM5UYF6Q.js.map +1 -0
  128. package/dist/{chunk-JBBSYJHP.js → chunk-NYEFP7DY.js} +4 -4
  129. package/dist/chunk-NYEFP7DY.js.map +1 -0
  130. package/dist/{chunk-CCOP5XDW.js → chunk-NZ24MX4J.js} +8 -46
  131. package/dist/chunk-NZ24MX4J.js.map +1 -0
  132. package/dist/{chunk-KWVJAOIN.js → chunk-OLEPKFTW.js} +4 -4
  133. package/dist/chunk-OLEPKFTW.js.map +1 -0
  134. package/dist/{chunk-OF75ACKS.js → chunk-PEATRIYJ.js} +9 -9
  135. package/dist/chunk-PEOZ34EM.js +13 -0
  136. package/dist/chunk-PEOZ34EM.js.map +1 -0
  137. package/dist/{chunk-UC2ETWF3.js → chunk-PTHKZWEH.js} +2 -14
  138. package/dist/{chunk-UC2ETWF3.js.map → chunk-PTHKZWEH.js.map} +1 -1
  139. package/dist/chunk-PVEWA2DU.js +23 -0
  140. package/dist/chunk-PVEWA2DU.js.map +1 -0
  141. package/dist/{chunk-LSASLXGC.js → chunk-QBAC3GXA.js} +1 -1
  142. package/dist/chunk-QBAC3GXA.js.map +1 -0
  143. package/dist/{chunk-RDXW3OBQ.js → chunk-QD46HPZG.js} +2 -2
  144. package/dist/chunk-QD46HPZG.js.map +1 -0
  145. package/dist/{chunk-N55W7KUL.js → chunk-QDIH2744.js} +2 -2
  146. package/dist/{chunk-6HY2X62D.js → chunk-QJNCB5SK.js} +2 -2
  147. package/dist/{chunk-4BRCIYFG.js → chunk-QX76XVQH.js} +6 -6
  148. package/dist/chunk-QX76XVQH.js.map +1 -0
  149. package/dist/{chunk-W2OG6JOL.js → chunk-QZWTRENR.js} +24 -7
  150. package/dist/chunk-QZWTRENR.js.map +1 -0
  151. package/dist/{chunk-6NQMXTYC.js → chunk-RO5NM6UI.js} +2 -2
  152. package/dist/chunk-RO5NM6UI.js.map +1 -0
  153. package/dist/chunk-SGDPRCC4.js +1075 -0
  154. package/dist/chunk-SGDPRCC4.js.map +1 -0
  155. package/dist/{chunk-2PCAVW2I.js → chunk-SHEEBRZ4.js} +2 -2
  156. package/dist/chunk-SMY5X46Z.js +14 -0
  157. package/dist/chunk-SMY5X46Z.js.map +1 -0
  158. package/dist/{chunk-ISMV2QVG.js → chunk-TG634KCO.js} +11 -2
  159. package/dist/chunk-TG634KCO.js.map +1 -0
  160. package/dist/{chunk-J6Q7UVQE.js → chunk-TUXQSFHZ.js} +4 -16
  161. package/dist/{chunk-J6Q7UVQE.js.map → chunk-TUXQSFHZ.js.map} +1 -1
  162. package/dist/{chunk-GULTLPFB.js → chunk-UADPR6F4.js} +3 -3
  163. package/dist/{chunk-GULTLPFB.js.map → chunk-UADPR6F4.js.map} +1 -1
  164. package/dist/{chunk-ZEQWCBCM.js → chunk-UDHBXYGG.js} +27 -5
  165. package/dist/chunk-UDHBXYGG.js.map +1 -0
  166. package/dist/{chunk-RA5VTXXG.js → chunk-V6UQZA2H.js} +2 -2
  167. package/dist/chunk-VG2ZSFYD.js +32 -0
  168. package/dist/chunk-VG2ZSFYD.js.map +1 -0
  169. package/dist/chunk-VKQCVU2Z.js +21 -0
  170. package/dist/chunk-VKQCVU2Z.js.map +1 -0
  171. package/dist/{chunk-QDPZWTN2.js → chunk-W3G5REIU.js} +2 -2
  172. package/dist/{chunk-WEYZTLXN.js → chunk-W3L64Y3J.js} +2 -2
  173. package/dist/{chunk-ONTBCHCP.js → chunk-W66AM5IB.js} +2 -2
  174. package/dist/chunk-W66AM5IB.js.map +1 -0
  175. package/dist/{chunk-A5BDDEXK.js → chunk-WBKZUO5V.js} +26 -43
  176. package/dist/chunk-WBKZUO5V.js.map +1 -0
  177. package/dist/{chunk-CBSY2N76.js → chunk-WLXMTYGO.js} +2 -2
  178. package/dist/{chunk-3U3FBR7O.js → chunk-X3F5YJG2.js} +2 -2
  179. package/dist/{chunk-GQNGCEP5.js → chunk-X45JYIAY.js} +3 -3
  180. package/dist/chunk-X45JYIAY.js.map +1 -0
  181. package/dist/{chunk-6XE5TMPR.js → chunk-X4MVWPHV.js} +3 -3
  182. package/dist/chunk-X4MVWPHV.js.map +1 -0
  183. package/dist/chunk-XZHEOSQ2.js +16 -0
  184. package/dist/chunk-XZHEOSQ2.js.map +1 -0
  185. package/dist/chunk-Y2NBBT6K.js +18 -0
  186. package/dist/chunk-Y2NBBT6K.js.map +1 -0
  187. package/dist/{chunk-DDATL6PU.js → chunk-Y2NJBNX3.js} +8 -8
  188. package/dist/{chunk-DDATL6PU.js.map → chunk-Y2NJBNX3.js.map} +1 -1
  189. package/dist/chunk-YMUFFJCO.js +23 -0
  190. package/dist/chunk-YMUFFJCO.js.map +1 -0
  191. package/dist/{chunk-O7WJ47EF.js → chunk-YWWQM7KP.js} +5 -14
  192. package/dist/chunk-YWWQM7KP.js.map +1 -0
  193. package/dist/{chunk-7O3AYBC7.js → chunk-YZJSJOUI.js} +235 -65
  194. package/dist/chunk-YZJSJOUI.js.map +1 -0
  195. package/dist/{chunk-5WZXVULX.js → chunk-ZTLOXFPB.js} +2 -2
  196. package/dist/chunk-ZTLOXFPB.js.map +1 -0
  197. package/dist/classified/index.js +5 -5
  198. package/dist/{classified-marker-WQVIJAW2.js → classified-marker-7PKJBFCG.js} +3 -3
  199. package/dist/collection-facade-6I5K5IOD.js +45 -0
  200. package/dist/{computed-DSMPXG2Y.js → computed-AB45PS4V.js} +3 -3
  201. package/dist/consent/index.js +13 -9
  202. package/dist/consent/index.js.map +1 -1
  203. package/dist/cover/index.js +37 -0
  204. package/dist/crdt/index.js +4 -0
  205. package/dist/crdt/index.js.map +1 -1
  206. package/dist/custody/index.js +26 -0
  207. package/dist/{dead-filter-2A7IAJ3D.js → dead-filter-FL3WIUZS.js} +2 -2
  208. package/dist/{chunk-GYYCX5K6.js → delegation-QXZ4MPPH.js} +12 -6
  209. package/dist/{chunk-GYYCX5K6.js.map → delegation-QXZ4MPPH.js.map} +1 -1
  210. package/dist/derivations/index.js +12 -12
  211. package/dist/derive-VGS7FKE3.js +22 -0
  212. package/dist/directory/index.js +46 -0
  213. package/dist/dispatch-EGGC7UD7.js +72 -0
  214. package/dist/dispatch-EGGC7UD7.js.map +1 -0
  215. package/dist/dispatch-GDSTUTVP.js +194 -0
  216. package/dist/dispatch-GDSTUTVP.js.map +1 -0
  217. package/dist/{enclave-7MW6ZGXW.js → enclave-SPEEDYZ4.js} +11 -11
  218. package/dist/executor-IEBLTBCW.js +9 -0
  219. package/dist/executor-OTF556PL.js +28 -0
  220. package/dist/executor-RM7XWQDU.js +9 -0
  221. package/dist/export-accessible-P42BQ4PB.js +23 -0
  222. package/dist/extract-partition-TCYXRWBN.js +38 -0
  223. package/dist/{fanout-sidecar-WDYQ77VB.js → fanout-sidecar-SSMRSC2L.js} +9 -9
  224. package/dist/find-OZMTRIK3.js +11 -0
  225. package/dist/forget/index.js +11 -11
  226. package/dist/forget/index.js.map +1 -1
  227. package/dist/guards/index.js +6 -6
  228. package/dist/history/index.js +16 -12
  229. package/dist/history/index.js.map +1 -1
  230. package/dist/i18n/index.js +16 -14
  231. package/dist/i18n/index.js.map +1 -1
  232. package/dist/index.d.ts +42 -42
  233. package/dist/index.js +330 -2106
  234. package/dist/index.js.map +1 -1
  235. package/dist/indexing/index.js +4 -2
  236. package/dist/indexing/index.js.map +1 -1
  237. package/dist/introspection/index.js +28 -0
  238. package/dist/issue-FCKN5O6C.js +19 -0
  239. package/dist/kernel/best-effort-revert.d.ts +9 -1
  240. package/dist/kernel/collection-config.d.ts +12 -70
  241. package/dist/kernel/collection.d.ts +11 -23
  242. package/dist/kernel/enclave/crypto.d.ts +8 -8
  243. package/dist/kernel/enclave/index.d.ts +3 -3
  244. package/dist/kernel/errors.d.ts +41 -22
  245. package/dist/kernel/lazy.d.ts +30 -0
  246. package/dist/kernel/noydb.d.ts +81 -124
  247. package/dist/kernel/query/builder.d.ts +10 -10
  248. package/dist/kernel/query/index.d.ts +0 -6
  249. package/dist/kernel/query/scan-builder.d.ts +4 -4
  250. package/dist/kernel/sync-policy.d.ts +76 -4
  251. package/dist/kernel/types.d.ts +146 -86
  252. package/dist/kernel/validation.d.ts +33 -33
  253. package/dist/kernel/vault.d.ts +41 -229
  254. package/dist/kernel/via/dispatch.d.ts +7 -0
  255. package/dist/{ledger-33BC4TR7.js → ledger-6XBEVWYP.js} +11 -11
  256. package/dist/liberate-CYUOS4NC.js +24 -0
  257. package/dist/{link-set-QK22TDEX.js → link-set-NK6L2A5S.js} +11 -11
  258. package/dist/materialized-views/index.js +22 -19
  259. package/dist/money/index.js +31 -0
  260. package/dist/noydb-FZZIMLCI.js +81 -0
  261. package/dist/overlay-views/index.js +4 -4
  262. package/dist/periods/index.js +15 -13
  263. package/dist/pod/index.js +26 -12
  264. package/dist/{policy-NAHB2TUT.js → policy/index.js} +6 -6
  265. package/dist/port/with/archive-strategy.d.ts +31 -0
  266. package/dist/port/with/blob-strategy.d.ts +15 -5
  267. package/dist/port/with/collection-options.d.ts +171 -0
  268. package/dist/port/with/collection-registries.d.ts +62 -0
  269. package/dist/port/with/strategies.d.ts +134 -0
  270. package/dist/port/with/team-strategy.d.ts +3 -2
  271. package/dist/portability/index.js +8 -8
  272. package/dist/{post-register-JVTMJ6OW.js → post-register-VFIYISUK.js} +6 -6
  273. package/dist/query/index.js +6 -46
  274. package/dist/{aggregate → reduce}/index.js +24 -17
  275. package/dist/reduce/index.js.map +1 -0
  276. package/dist/register-UKU2J6MN.js +25 -0
  277. package/dist/registry-2VCWVHZS.js +19 -0
  278. package/dist/registry-7Y5WF7GS.js +9 -0
  279. package/dist/{registry-VW6P6A3J.js → registry-BWD2ED52.js} +2 -2
  280. package/dist/registry-DTWRJLSF.js +18 -0
  281. package/dist/request-withdrawal-JYDZ5XY2.js +31 -0
  282. package/dist/{reveal-LGBOM2BO.js → reveal-CL2BCW6A.js} +6 -6
  283. package/dist/revoke-2TSAD2T4.js +24 -0
  284. package/dist/satellites/index.js +1 -1
  285. package/dist/schema-update/index.js +26 -0
  286. package/dist/sealed-record/index.js +12 -12
  287. package/dist/search/index.js +36 -0
  288. package/dist/{seed-PWK45HDF.js → seed-NUVJEL7T.js} +12 -12
  289. package/dist/seed-NUVJEL7T.js.map +1 -0
  290. package/dist/sequence/index.js +30 -0
  291. package/dist/session/index.js +13 -9
  292. package/dist/session/index.js.map +1 -1
  293. package/dist/shadow/index.js +6 -2
  294. package/dist/shadow/index.js.map +1 -1
  295. package/dist/signer-K7Z2EOMG.js +25 -0
  296. package/dist/snapshots/index.js +14 -10
  297. package/dist/snapshots/index.js.map +1 -1
  298. package/dist/{stale-FJED42DM.js → stale-A4J26OIC.js} +11 -10
  299. package/dist/storage-YVHZUISN.js +23 -0
  300. package/dist/store/index.js +22 -0
  301. package/dist/{store-coordination-provider-APODTV4W.js → store-coordination-provider-EWRZL7XF.js} +3 -3
  302. package/dist/sync/index.js +15 -12
  303. package/dist/sync/index.js.map +1 -1
  304. package/dist/team/index.js +33 -48
  305. package/dist/tiers/index.js +10 -10
  306. package/dist/to/index.js +1 -1
  307. package/dist/{tx → transactions}/index.js +7 -3
  308. package/dist/transactions/index.js.map +1 -0
  309. package/dist/util/index.js +1 -1
  310. package/dist/{verify-26Y5GNMK.js → verify-7XWHJWUN.js} +5 -5
  311. package/dist/via/blob/active.d.ts +23 -7
  312. package/dist/via/blob/binding.d.ts +1 -1
  313. package/dist/via/blob/index.d.ts +7 -1
  314. package/dist/via/i18n/core.d.ts +1 -1
  315. package/dist/via/i18n/index.d.ts +2 -0
  316. package/dist/via/money/money-reducer.d.ts +2 -2
  317. package/dist/walk-P5D6CF4V.js +21 -0
  318. package/dist/with-audit/consent/index.d.ts +2 -0
  319. package/dist/with-audit/forget/active.d.ts +3 -3
  320. package/dist/with-audit/forget/index.d.ts +6 -5
  321. package/dist/with-audit/forget/strategy.d.ts +3 -3
  322. package/dist/with-audit/guards/executor.d.ts +4 -4
  323. package/dist/with-audit/guards/immutable-guard.d.ts +3 -3
  324. package/dist/with-audit/guards/index.d.ts +1 -1
  325. package/dist/with-audit/guards/registry.d.ts +3 -3
  326. package/dist/with-audit/guards/transition-guard.d.ts +3 -3
  327. package/dist/with-audit/guards/types.d.ts +10 -10
  328. package/dist/with-audit/guards/with-guard.d.ts +2 -2
  329. package/dist/with-audit/periods/index.d.ts +2 -0
  330. package/dist/with-audit/periods/vault-facade.d.ts +6 -0
  331. package/dist/with-audit/portability/export-accessible.d.ts +4 -4
  332. package/dist/with-audit/portability/request-withdrawal.d.ts +3 -3
  333. package/dist/with-audit/portability/withdraw-accessible.d.ts +2 -2
  334. package/dist/with-audit/sealed-record/strategy.d.ts +1 -1
  335. package/dist/with-audit/tiers/index.d.ts +1 -0
  336. package/dist/with-cargo/adopt-partition.d.ts +7 -7
  337. package/dist/{legacy/kernel.d.ts → with-cargo/floor.d.ts} +4 -4
  338. package/dist/with-cargo/index.d.ts +9 -2
  339. package/dist/with-commit/crdt/index.d.ts +2 -0
  340. package/dist/with-commit/history/index.d.ts +2 -0
  341. package/dist/with-commit/history/time-machine.d.ts +2 -2
  342. package/dist/with-commit/numbering/descriptor.d.ts +16 -6
  343. package/dist/with-commit/tx/active.d.ts +5 -5
  344. package/dist/with-commit/tx/index.d.ts +2 -2
  345. package/dist/with-commit/tx/invariants.d.ts +1 -1
  346. package/dist/with-commit/tx/strategy.d.ts +3 -3
  347. package/dist/with-fork/shadow/index.d.ts +2 -0
  348. package/dist/with-fork/snapshots/active.d.ts +2 -2
  349. package/dist/with-fork/snapshots/index.d.ts +3 -1
  350. package/dist/with-fork/snapshots/noydb-facade.d.ts +3 -3
  351. package/dist/with-fork/snapshots/strategy.d.ts +2 -2
  352. package/dist/with-formula/derivations/dispatch.d.ts +98 -0
  353. package/dist/with-formula/derivations/executor.d.ts +2 -2
  354. package/dist/with-formula/derivations/index.d.ts +4 -1
  355. package/dist/with-formula/derivations/registry.d.ts +3 -3
  356. package/dist/with-formula/derivations/stale.d.ts +2 -2
  357. package/dist/with-formula/derivations/types.d.ts +3 -3
  358. package/dist/with-formula/derivations/with-derivation.d.ts +2 -2
  359. package/dist/with-formula/derivations/with-rollup.d.ts +15 -8
  360. package/dist/with-formula/materialized-views/dependency-analyzer.d.ts +3 -3
  361. package/dist/with-formula/materialized-views/dispatch.d.ts +75 -0
  362. package/dist/with-formula/materialized-views/index.d.ts +2 -1
  363. package/dist/with-formula/materialized-views/registry.d.ts +4 -4
  364. package/dist/with-formula/materialized-views/types.d.ts +11 -11
  365. package/dist/with-formula/materialized-views/with-materialized-view.d.ts +2 -2
  366. package/dist/with-formula/overlay-views/index.d.ts +1 -1
  367. package/dist/with-formula/overlay-views/registry.d.ts +4 -4
  368. package/dist/with-formula/overlay-views/types.d.ts +3 -3
  369. package/dist/with-formula/overlay-views/virtual-collection.d.ts +2 -2
  370. package/dist/with-formula/overlay-views/with-overlayed-view.d.ts +2 -2
  371. package/dist/with-lookup/indexing/active.d.ts +5 -5
  372. package/dist/with-lookup/indexing/index.d.ts +3 -1
  373. package/dist/with-lookup/indexing/strategy.d.ts +3 -3
  374. package/dist/with-lookup/{aggregate → reduce}/active.d.ts +8 -8
  375. package/dist/with-lookup/{aggregate → reduce}/groupby.d.ts +21 -21
  376. package/dist/with-lookup/reduce/index.d.ts +34 -0
  377. package/dist/with-lookup/{aggregate → reduce}/reducers.d.ts +11 -12
  378. package/dist/with-lookup/{aggregate/aggregation.d.ts → reduce/reduction.d.ts} +21 -21
  379. package/dist/with-lookup/{aggregate → reduce}/strategy.d.ts +15 -15
  380. package/dist/with-lookup/search/build-docs.d.ts +7 -2
  381. package/dist/with-lookup/search/index.d.ts +1 -1
  382. package/dist/with-party/broker/index.d.ts +1 -0
  383. package/dist/with-party/broker/seed.d.ts +1 -1
  384. package/dist/with-party/custody/liberate.d.ts +3 -3
  385. package/dist/with-party/directory/cover/index.d.ts +1 -5
  386. package/dist/with-party/directory/cover/schema.d.ts +0 -6
  387. package/dist/with-party/directory/cover/storage.d.ts +0 -8
  388. package/dist/with-party/directory/cover/types.d.ts +0 -21
  389. package/dist/with-party/directory/index.d.ts +2 -0
  390. package/dist/with-party/session/dev-unlock.d.ts +2 -2
  391. package/dist/with-party/session/index.d.ts +2 -0
  392. package/dist/with-party/session/session.d.ts +2 -2
  393. package/dist/with-party/team/deed.d.ts +8 -8
  394. package/dist/with-party/team/index.d.ts +4 -7
  395. package/dist/with-party/team/keyring.d.ts +83 -35
  396. package/dist/with-party/team/{managed-passphrase.d.ts → managed-secret.d.ts} +27 -27
  397. package/dist/with-party/team/noydb-facade.d.ts +43 -42
  398. package/dist/with-party/team/peer-recover.d.ts +13 -13
  399. package/dist/with-party/team/recovery.d.ts +5 -5
  400. package/dist/with-party/team/rotate-recover.d.ts +30 -30
  401. package/dist/with-pod/bundle.d.ts +30 -32
  402. package/dist/with-pod/format.d.ts +2 -2
  403. package/dist/with-pod/index.d.ts +2 -1
  404. package/dist/with-shape/blobs/blob-compaction.d.ts +43 -3
  405. package/dist/with-shape/blobs/blob-pinning.d.ts +112 -0
  406. package/dist/with-shape/blobs/blob-set.d.ts +86 -2
  407. package/dist/with-shape/introspection/index.d.ts +6 -0
  408. package/dist/with-shape/schema-update/index.d.ts +1 -0
  409. package/dist/with-store/index.d.ts +3 -2
  410. package/dist/with-store/route-store.d.ts +1 -1
  411. package/dist/{with-party/team/sync-active.d.ts → with-sync/active.d.ts} +1 -1
  412. package/dist/{with-party/team/sync-credentials.d.ts → with-sync/credentials.d.ts} +3 -3
  413. package/dist/{with-party/team/sync.d.ts → with-sync/engine.d.ts} +5 -5
  414. package/dist/{with-party/sync → with-sync}/index.d.ts +4 -2
  415. package/dist/{with-party/team/sync-period-scope.d.ts → with-sync/period-scope.d.ts} +2 -2
  416. package/dist/{with-party/team → with-sync}/presence.d.ts +2 -2
  417. package/dist/{with-party/team/sync-strategy.d.ts → with-sync/strategy.d.ts} +6 -6
  418. package/dist/{with-party/team/sync-transaction.d.ts → with-sync/transaction.d.ts} +3 -3
  419. package/dist/withdraw-accessible-A2PWF5MZ.js +28 -0
  420. package/package.json +45 -36
  421. package/dist/aggregate/index.js.map +0 -1
  422. package/dist/api-IQFZJSQO.js +0 -20
  423. package/dist/as/index.js +0 -30
  424. package/dist/at/index.js +0 -1
  425. package/dist/bundle/index.js +0 -105
  426. package/dist/by/index.js +0 -11
  427. package/dist/chunk-2IALOXZS.js.map +0 -1
  428. package/dist/chunk-2MUZ3LY6.js +0 -205
  429. package/dist/chunk-2MUZ3LY6.js.map +0 -1
  430. package/dist/chunk-2P7EGNKF.js.map +0 -1
  431. package/dist/chunk-3PF6CRDT.js.map +0 -1
  432. package/dist/chunk-3SV2EPMN.js.map +0 -1
  433. package/dist/chunk-4BRCIYFG.js.map +0 -1
  434. package/dist/chunk-5OI6BR4H.js.map +0 -1
  435. package/dist/chunk-5WZXVULX.js.map +0 -1
  436. package/dist/chunk-6NQMXTYC.js.map +0 -1
  437. package/dist/chunk-6XE5TMPR.js.map +0 -1
  438. package/dist/chunk-7CI6CP7Z.js.map +0 -1
  439. package/dist/chunk-7O3AYBC7.js.map +0 -1
  440. package/dist/chunk-A5BDDEXK.js.map +0 -1
  441. package/dist/chunk-A7JJLVGH.js.map +0 -1
  442. package/dist/chunk-BGK233EA.js.map +0 -1
  443. package/dist/chunk-BMQWTQZ4.js.map +0 -1
  444. package/dist/chunk-BOKIKJJB.js.map +0 -1
  445. package/dist/chunk-CCOP5XDW.js.map +0 -1
  446. package/dist/chunk-CHFZDSE4.js +0 -1
  447. package/dist/chunk-DDHM2TLX.js.map +0 -1
  448. package/dist/chunk-GQNGCEP5.js.map +0 -1
  449. package/dist/chunk-GVZQ4NAM.js +0 -14
  450. package/dist/chunk-GVZQ4NAM.js.map +0 -1
  451. package/dist/chunk-GWKAVKHI.js.map +0 -1
  452. package/dist/chunk-HOONYZY2.js.map +0 -1
  453. package/dist/chunk-HPUWOVR7.js.map +0 -1
  454. package/dist/chunk-ISMV2QVG.js.map +0 -1
  455. package/dist/chunk-JBBSYJHP.js.map +0 -1
  456. package/dist/chunk-JRBNCUNT.js.map +0 -1
  457. package/dist/chunk-JZWWLLVY.js +0 -99
  458. package/dist/chunk-JZWWLLVY.js.map +0 -1
  459. package/dist/chunk-KUPKLSX5.js.map +0 -1
  460. package/dist/chunk-KWVJAOIN.js.map +0 -1
  461. package/dist/chunk-LB6OH6K2.js.map +0 -1
  462. package/dist/chunk-LB7FD65R.js +0 -163
  463. package/dist/chunk-LB7FD65R.js.map +0 -1
  464. package/dist/chunk-LOF2W3JU.js.map +0 -1
  465. package/dist/chunk-LSASLXGC.js.map +0 -1
  466. package/dist/chunk-O7WJ47EF.js.map +0 -1
  467. package/dist/chunk-ONTBCHCP.js.map +0 -1
  468. package/dist/chunk-PT37L5DV.js +0 -255
  469. package/dist/chunk-PT37L5DV.js.map +0 -1
  470. package/dist/chunk-RDXW3OBQ.js.map +0 -1
  471. package/dist/chunk-RND5ZPNP.js.map +0 -1
  472. package/dist/chunk-S3BFKGET.js.map +0 -1
  473. package/dist/chunk-SMGEYW6G.js.map +0 -1
  474. package/dist/chunk-T36RFODW.js.map +0 -1
  475. package/dist/chunk-TAGR72IR.js.map +0 -1
  476. package/dist/chunk-UNCOC7QH.js.map +0 -1
  477. package/dist/chunk-VCBHAE4R.js.map +0 -1
  478. package/dist/chunk-VEALDPHW.js.map +0 -1
  479. package/dist/chunk-VQNJ7UZL.js.map +0 -1
  480. package/dist/chunk-W2OG6JOL.js.map +0 -1
  481. package/dist/chunk-WNGGJWF7.js.map +0 -1
  482. package/dist/chunk-YJV2UZ7H.js.map +0 -1
  483. package/dist/chunk-YMUGBZN2.js.map +0 -1
  484. package/dist/chunk-YTGDPCPW.js.map +0 -1
  485. package/dist/chunk-ZEQWCBCM.js.map +0 -1
  486. package/dist/collection-facade-MJXSC3Q6.js +0 -44
  487. package/dist/cover-B5SJDHR3.js +0 -52
  488. package/dist/delegation-A5A75KQO.js +0 -25
  489. package/dist/derive-HJSMH7RA.js +0 -21
  490. package/dist/executor-AXE4XMLT.js +0 -26
  491. package/dist/executor-KGNLJD6M.js +0 -9
  492. package/dist/executor-XGIS6CR7.js +0 -9
  493. package/dist/export-accessible-VVBJM3MM.js +0 -23
  494. package/dist/extract-partition-LGGBTQET.js +0 -38
  495. package/dist/find-YS6XWB46.js +0 -11
  496. package/dist/in/index.js +0 -1
  497. package/dist/issue-LSR5PS6H.js +0 -19
  498. package/dist/legacy/bundle.d.ts +0 -30
  499. package/dist/liberate-GBSAYLPJ.js +0 -24
  500. package/dist/noydb-MTUBMWFE.js +0 -70
  501. package/dist/on/index.js +0 -17
  502. package/dist/port/as/index.d.ts +0 -26
  503. package/dist/port/at/index.d.ts +0 -18
  504. package/dist/port/in/index.d.ts +0 -21
  505. package/dist/port/on/index.d.ts +0 -27
  506. package/dist/port/ui/index.d.ts +0 -21
  507. package/dist/port/with/index.d.ts +0 -18
  508. package/dist/register-X462DNDM.js +0 -23
  509. package/dist/registry-3XMCT7MQ.js +0 -18
  510. package/dist/registry-KHD2I3M2.js +0 -19
  511. package/dist/registry-NPOWJHC4.js +0 -9
  512. package/dist/request-withdrawal-U7K3JTMY.js +0 -31
  513. package/dist/revoke-OCWDSWRQ.js +0 -24
  514. package/dist/seed-PWK45HDF.js.map +0 -1
  515. package/dist/signer-3YFBLZRN.js +0 -25
  516. package/dist/storage-W3GURVFU.js +0 -23
  517. package/dist/tx/index.js.map +0 -1
  518. package/dist/ui/index.js +0 -1
  519. package/dist/with/index.js +0 -31
  520. package/dist/with-lookup/aggregate/index.d.ts +0 -23
  521. package/dist/withdraw-accessible-Y3B2535F.js +0 -28
  522. /package/dist/{api-IQFZJSQO.js.map → api-ZDKTWNBB.js.map} +0 -0
  523. /package/dist/{backup-LU2DTZTI.js.map → backup-2UX7PRM5.js.map} +0 -0
  524. /package/dist/{chunk-IY23KFNZ.js.map → chunk-35NMVJ7I.js.map} +0 -0
  525. /package/dist/{chunk-RTEK4C4I.js.map → chunk-4JQK3L4V.js.map} +0 -0
  526. /package/dist/{chunk-3ELCWU56.js.map → chunk-4ZKNC6A6.js.map} +0 -0
  527. /package/dist/{chunk-VAIS3SOM.js.map → chunk-55LX6FSX.js.map} +0 -0
  528. /package/dist/{chunk-6HPG2YNX.js.map → chunk-5DRROK5W.js.map} +0 -0
  529. /package/dist/{chunk-S6Q37VGE.js.map → chunk-5GQEU4DN.js.map} +0 -0
  530. /package/dist/{chunk-TOPYT5U5.js.map → chunk-63FE525P.js.map} +0 -0
  531. /package/dist/{chunk-JVBO4SZL.js.map → chunk-6UBZ6I5Z.js.map} +0 -0
  532. /package/dist/{chunk-UFEVO57O.js.map → chunk-ABS7FMMD.js.map} +0 -0
  533. /package/dist/{chunk-M75ZZHSR.js.map → chunk-BLBAQRBM.js.map} +0 -0
  534. /package/dist/{chunk-G6EQYAL6.js.map → chunk-CI32CAFS.js.map} +0 -0
  535. /package/dist/{chunk-6B4DYGWO.js.map → chunk-DABACXEF.js.map} +0 -0
  536. /package/dist/{chunk-F6T6L2UK.js.map → chunk-DMH3VZU5.js.map} +0 -0
  537. /package/dist/{chunk-MQ6WOPSY.js.map → chunk-DZ2JXHWK.js.map} +0 -0
  538. /package/dist/{chunk-UBNCR3YK.js.map → chunk-EE7UHLKH.js.map} +0 -0
  539. /package/dist/{chunk-EGCRBCNA.js.map → chunk-EKRSCRNM.js.map} +0 -0
  540. /package/dist/{chunk-IRQY7IR5.js.map → chunk-FRMPM7WG.js.map} +0 -0
  541. /package/dist/{as/index.js.map → chunk-GJW4HX2O.js.map} +0 -0
  542. /package/dist/{chunk-T6GU5PPZ.js.map → chunk-GU3IP74F.js.map} +0 -0
  543. /package/dist/{chunk-SMIRGMS7.js.map → chunk-IXNCZTWA.js.map} +0 -0
  544. /package/dist/{chunk-RM2XV574.js.map → chunk-IXTSNGYY.js.map} +0 -0
  545. /package/dist/{chunk-PK6QCH2C.js.map → chunk-JJZGIE4U.js.map} +0 -0
  546. /package/dist/{chunk-DRWBEDYO.js.map → chunk-JYJFGD2H.js.map} +0 -0
  547. /package/dist/{chunk-KUIB4B5Q.js.map → chunk-LNZKOUJR.js.map} +0 -0
  548. /package/dist/{chunk-IM3QVF53.js.map → chunk-MBKVNOJS.js.map} +0 -0
  549. /package/dist/{chunk-N6WF5PKC.js.map → chunk-NFZGZ4AK.js.map} +0 -0
  550. /package/dist/{chunk-OF75ACKS.js.map → chunk-PEATRIYJ.js.map} +0 -0
  551. /package/dist/{chunk-N55W7KUL.js.map → chunk-QDIH2744.js.map} +0 -0
  552. /package/dist/{chunk-6HY2X62D.js.map → chunk-QJNCB5SK.js.map} +0 -0
  553. /package/dist/{chunk-2PCAVW2I.js.map → chunk-SHEEBRZ4.js.map} +0 -0
  554. /package/dist/{chunk-RA5VTXXG.js.map → chunk-V6UQZA2H.js.map} +0 -0
  555. /package/dist/{chunk-QDPZWTN2.js.map → chunk-W3G5REIU.js.map} +0 -0
  556. /package/dist/{chunk-WEYZTLXN.js.map → chunk-W3L64Y3J.js.map} +0 -0
  557. /package/dist/{chunk-CBSY2N76.js.map → chunk-WLXMTYGO.js.map} +0 -0
  558. /package/dist/{chunk-3U3FBR7O.js.map → chunk-X3F5YJG2.js.map} +0 -0
  559. /package/dist/{classified-marker-WQVIJAW2.js.map → classified-marker-7PKJBFCG.js.map} +0 -0
  560. /package/dist/{at/index.js.map → collection-facade-6I5K5IOD.js.map} +0 -0
  561. /package/dist/{bundle/index.js.map → computed-AB45PS4V.js.map} +0 -0
  562. /package/dist/{by → cover}/index.js.map +0 -0
  563. /package/dist/{in → custody}/index.js.map +0 -0
  564. /package/dist/{dead-filter-2A7IAJ3D.js.map → dead-filter-FL3WIUZS.js.map} +0 -0
  565. /package/dist/{chunk-CHFZDSE4.js.map → derive-VGS7FKE3.js.map} +0 -0
  566. /package/dist/{on → directory}/index.js.map +0 -0
  567. /package/dist/{collection-facade-MJXSC3Q6.js.map → enclave-SPEEDYZ4.js.map} +0 -0
  568. /package/dist/{computed-DSMPXG2Y.js.map → executor-IEBLTBCW.js.map} +0 -0
  569. /package/dist/{cover-B5SJDHR3.js.map → executor-OTF556PL.js.map} +0 -0
  570. /package/dist/{delegation-A5A75KQO.js.map → executor-RM7XWQDU.js.map} +0 -0
  571. /package/dist/{derive-HJSMH7RA.js.map → export-accessible-P42BQ4PB.js.map} +0 -0
  572. /package/dist/{enclave-7MW6ZGXW.js.map → extract-partition-TCYXRWBN.js.map} +0 -0
  573. /package/dist/{fanout-sidecar-WDYQ77VB.js.map → fanout-sidecar-SSMRSC2L.js.map} +0 -0
  574. /package/dist/{executor-AXE4XMLT.js.map → find-OZMTRIK3.js.map} +0 -0
  575. /package/dist/{ui → introspection}/index.js.map +0 -0
  576. /package/dist/{executor-KGNLJD6M.js.map → issue-FCKN5O6C.js.map} +0 -0
  577. /package/dist/{executor-XGIS6CR7.js.map → ledger-6XBEVWYP.js.map} +0 -0
  578. /package/dist/{export-accessible-VVBJM3MM.js.map → liberate-CYUOS4NC.js.map} +0 -0
  579. /package/dist/{extract-partition-LGGBTQET.js.map → link-set-NK6L2A5S.js.map} +0 -0
  580. /package/dist/{with → money}/index.js.map +0 -0
  581. /package/dist/{find-YS6XWB46.js.map → noydb-FZZIMLCI.js.map} +0 -0
  582. /package/dist/{issue-LSR5PS6H.js.map → policy/index.js.map} +0 -0
  583. /package/dist/{post-register-JVTMJ6OW.js.map → post-register-VFIYISUK.js.map} +0 -0
  584. /package/dist/{ledger-33BC4TR7.js.map → register-UKU2J6MN.js.map} +0 -0
  585. /package/dist/{liberate-GBSAYLPJ.js.map → registry-2VCWVHZS.js.map} +0 -0
  586. /package/dist/{link-set-QK22TDEX.js.map → registry-7Y5WF7GS.js.map} +0 -0
  587. /package/dist/{noydb-MTUBMWFE.js.map → registry-BWD2ED52.js.map} +0 -0
  588. /package/dist/{policy-NAHB2TUT.js.map → registry-DTWRJLSF.js.map} +0 -0
  589. /package/dist/{register-X462DNDM.js.map → request-withdrawal-JYDZ5XY2.js.map} +0 -0
  590. /package/dist/{reveal-LGBOM2BO.js.map → reveal-CL2BCW6A.js.map} +0 -0
  591. /package/dist/{registry-3XMCT7MQ.js.map → revoke-2TSAD2T4.js.map} +0 -0
  592. /package/dist/{registry-KHD2I3M2.js.map → schema-update/index.js.map} +0 -0
  593. /package/dist/{registry-NPOWJHC4.js.map → search/index.js.map} +0 -0
  594. /package/dist/{registry-VW6P6A3J.js.map → sequence/index.js.map} +0 -0
  595. /package/dist/{request-withdrawal-U7K3JTMY.js.map → signer-K7Z2EOMG.js.map} +0 -0
  596. /package/dist/{revoke-OCWDSWRQ.js.map → stale-A4J26OIC.js.map} +0 -0
  597. /package/dist/{signer-3YFBLZRN.js.map → storage-YVHZUISN.js.map} +0 -0
  598. /package/dist/{stale-FJED42DM.js.map → store/index.js.map} +0 -0
  599. /package/dist/{store-coordination-provider-APODTV4W.js.map → store-coordination-provider-EWRZL7XF.js.map} +0 -0
  600. /package/dist/{verify-26Y5GNMK.js.map → verify-7XWHJWUN.js.map} +0 -0
  601. /package/dist/{storage-W3GURVFU.js.map → walk-P5D6CF4V.js.map} +0 -0
  602. /package/dist/with-lookup/{aggregate → reduce}/canonical-key.d.ts +0 -0
  603. /package/dist/{with-party → with-sync}/tab-coordination.d.ts +0 -0
  604. /package/dist/{with-party → with-sync}/tab-write-relay.d.ts +0 -0
  605. /package/dist/{withdraw-accessible-Y3B2535F.js.map → withdraw-accessible-A2PWF5MZ.js.map} +0 -0
package/dist/index.js CHANGED
@@ -1,11 +1,3 @@
1
- import {
2
- DEFAULT_FRESHNESS_MS,
3
- PERSONAL_POLICY,
4
- STRICT_POLICY,
5
- checkGate,
6
- describeGate,
7
- mergePolicy
8
- } from "./chunk-RND5ZPNP.js";
9
1
  import {
10
2
  Collection,
11
3
  ELEVATION_AUDIT_COLLECTION,
@@ -17,10 +9,6 @@ import {
17
9
  RefScopeError,
18
10
  Vault,
19
11
  createNoydb,
20
- describeAllUsersAuth,
21
- describeAuthConfig,
22
- describeUserAuth,
23
- diagramAuthConfig,
24
12
  isRefArray,
25
13
  isViaFieldSpec,
26
14
  memoryStore,
@@ -28,180 +16,253 @@ import {
28
16
  refArray,
29
17
  via,
30
18
  withArchive
31
- } from "./chunk-3PF6CRDT.js";
32
- import {
33
- META_COLLECTION,
34
- POLICY_RECORD_ID,
35
- loadVaultPolicy,
36
- saveVaultPolicy
37
- } from "./chunk-CBSY2N76.js";
19
+ } from "./chunk-NFIBXF4V.js";
20
+ import "./chunk-NJ4DYYO5.js";
38
21
  import {
39
- DELEGATIONS_COLLECTION,
40
- issueDelegation,
41
- loadActiveDelegations,
42
- revokeDelegation
43
- } from "./chunk-GYYCX5K6.js";
44
- import "./chunk-VYYM3MEN.js";
45
- import {
46
- COVER_FIELDS,
47
- DEFAULT_COVER_SCHEMA,
48
- DEFAULT_PUBLIC_ENVELOPE_SCHEMA,
49
- PUBLIC_ENVELOPE_FIELDS,
50
- resolveSchema
51
- } from "./chunk-FH52K7EG.js";
52
- import {
53
- NO_SEQUENCE,
54
- SequenceStore,
55
- compileSequenceFormat,
56
- resolveSequenceKey,
57
- withSequence
58
- } from "./chunk-HPUWOVR7.js";
59
- import {
60
- UserApi
61
- } from "./chunk-6B4DYGWO.js";
22
+ persistSchemaIfNeeded
23
+ } from "./chunk-NZ24MX4J.js";
62
24
  import {
63
25
  LinkEndpointError
64
- } from "./chunk-IM3QVF53.js";
26
+ } from "./chunk-MBKVNOJS.js";
65
27
  import {
66
28
  LinkIntegrityError,
67
29
  isLinkCollectionName
68
- } from "./chunk-RTEK4C4I.js";
69
- import "./chunk-2PCAVW2I.js";
30
+ } from "./chunk-4JQK3L4V.js";
31
+ import "./chunk-SHEEBRZ4.js";
70
32
  import {
71
33
  ComputedFieldError,
72
34
  evalComputedFields
73
- } from "./chunk-6HPG2YNX.js";
74
- import {
75
- persistSchemaIfNeeded
76
- } from "./chunk-CCOP5XDW.js";
35
+ } from "./chunk-5DRROK5W.js";
77
36
  import {
78
37
  WithdrawalRequestError,
79
38
  approveWithdrawal,
80
39
  listWithdrawalRequests,
81
40
  rejectWithdrawal,
82
41
  requestWithdrawal
83
- } from "./chunk-7CI6CP7Z.js";
84
- import "./chunk-KUIB4B5Q.js";
42
+ } from "./chunk-HMU5P6RL.js";
43
+ import "./chunk-LNZKOUJR.js";
44
+ import "./chunk-7YVBQJ7K.js";
85
45
  import {
86
- NO_SEARCH,
87
- tokenize,
88
- withSearch
89
- } from "./chunk-BMQWTQZ4.js";
46
+ COVER_FIELDS,
47
+ DEFAULT_COVER_SCHEMA,
48
+ resolveSchema
49
+ } from "./chunk-CUZLNGD5.js";
90
50
  import {
91
- derivePersistedSchema,
92
- isZodSchema
93
- } from "./chunk-BOKIKJJB.js";
51
+ additiveOnly,
52
+ blindUpdate,
53
+ coordinatedCutover,
54
+ lockSchema
55
+ } from "./chunk-E23UGFVC.js";
56
+ import "./chunk-6LJY7X5A.js";
57
+ import "./chunk-DSDXAKIP.js";
58
+ import {
59
+ DEFAULT_FRESHNESS_MS,
60
+ PERSONAL_POLICY,
61
+ STRICT_POLICY,
62
+ checkGate,
63
+ describeGate,
64
+ mergePolicy
65
+ } from "./chunk-G6WWZNJP.js";
66
+ import "./chunk-GJW4HX2O.js";
67
+ import {
68
+ UserApi
69
+ } from "./chunk-DABACXEF.js";
94
70
  import "./chunk-GYGLAVCX.js";
95
- import "./chunk-M75ZZHSR.js";
71
+ import "./chunk-Y2NJBNX3.js";
72
+ import "./chunk-BLBAQRBM.js";
96
73
  import {
74
+ decryptExtractedPartition,
75
+ diffVault,
97
76
  withCargo
98
- } from "./chunk-GVZQ4NAM.js";
77
+ } from "./chunk-YZJSJOUI.js";
99
78
  import {
100
- CustodyApi,
101
- NO_CARGO,
102
- NO_CUSTODY,
103
- withCustody
104
- } from "./chunk-O7WJ47EF.js";
79
+ NO_CARGO
80
+ } from "./chunk-TG634KCO.js";
81
+ import "./chunk-PEATRIYJ.js";
105
82
  import {
106
- DEED_RECORD_ID,
107
83
  createDeedOwner,
108
84
  isDeedVault,
109
85
  liberateVault,
110
86
  loadDeedMarker
111
- } from "./chunk-UNCOC7QH.js";
112
- import {
113
- fuseRetrieval
114
- } from "./chunk-AURFOK3D.js";
87
+ } from "./chunk-H2GPHUZD.js";
115
88
  import {
116
- diffVault
117
- } from "./chunk-LB7FD65R.js";
89
+ MemoryRecipientSealer,
90
+ MemorySealingKeyProvider,
91
+ aesGcmOpen,
92
+ parseRsaOaepTlv,
93
+ sealRsaOaepTlv
94
+ } from "./chunk-FQZ6XTQ7.js";
118
95
  import {
119
96
  withdrawAccessibleData
120
- } from "./chunk-YJV2UZ7H.js";
97
+ } from "./chunk-I5GEJX3R.js";
121
98
  import {
122
99
  exportAccessibleData
123
- } from "./chunk-GQNGCEP5.js";
124
- import "./chunk-PT37L5DV.js";
125
- import "./chunk-ISMV2QVG.js";
100
+ } from "./chunk-X45JYIAY.js";
101
+ import {
102
+ routeStore,
103
+ withCache,
104
+ withCircuitBreaker,
105
+ withHealthCheck,
106
+ withLogging,
107
+ withMetrics,
108
+ withRetry,
109
+ wrapStore
110
+ } from "./chunk-EIPVYUEP.js";
111
+ import {
112
+ applyListProjection
113
+ } from "./chunk-VG2ZSFYD.js";
114
+ import "./chunk-VYYM3MEN.js";
115
+ import {
116
+ derivePersistedSchema,
117
+ isZodSchema
118
+ } from "./chunk-6ZNSB3H6.js";
119
+ import "./chunk-Y2NBBT6K.js";
120
+ import {
121
+ SCHEMAS_COLLECTION,
122
+ loadPersistedSchema,
123
+ savePersistedSchema
124
+ } from "./chunk-DMH3VZU5.js";
125
+ import {
126
+ MoneyCurrencyError,
127
+ MoneyPrecisionError,
128
+ MoneyUnsupportedError,
129
+ allocate,
130
+ asMoney,
131
+ isMoneyDescriptor,
132
+ isMoneyString,
133
+ money,
134
+ moneyNumber,
135
+ mulRate,
136
+ scaleForCurrency
137
+ } from "./chunk-SGDPRCC4.js";
138
+ import {
139
+ withDerivation,
140
+ withRollup
141
+ } from "./chunk-NYEFP7DY.js";
142
+ import "./chunk-AT2JJEKJ.js";
143
+ import "./chunk-4ZKNC6A6.js";
144
+ import "./chunk-MHMLXJ3I.js";
145
+ import {
146
+ withMaterializedView
147
+ } from "./chunk-MXUT7FTE.js";
148
+ import "./chunk-N4BBNYIB.js";
149
+ import {
150
+ buildLookupSnapshot
151
+ } from "./chunk-IPUG56GJ.js";
152
+ import "./chunk-3HUYRN24.js";
153
+ import "./chunk-IYZISPGD.js";
126
154
  import {
127
155
  withOverlayedView
128
- } from "./chunk-WNGGJWF7.js";
129
- import "./chunk-5WZXVULX.js";
130
- import "./chunk-GWKAVKHI.js";
156
+ } from "./chunk-MSMJJB4J.js";
157
+ import "./chunk-ZTLOXFPB.js";
158
+ import "./chunk-IG6KUWBX.js";
159
+ import {
160
+ PresenceHandle,
161
+ SyncEngine,
162
+ SyncTransaction
163
+ } from "./chunk-JDOMW53O.js";
164
+ import {
165
+ BUNDLE_STORE_POLICY,
166
+ INDEXED_STORE_POLICY,
167
+ POD_STORE_POLICY,
168
+ SyncScheduler
169
+ } from "./chunk-55LKVALY.js";
131
170
  import {
132
171
  isDiscriminant
133
172
  } from "./chunk-PY4KJPYU.js";
134
- import "./chunk-S6Q37VGE.js";
173
+ import "./chunk-5GQEU4DN.js";
135
174
  import {
136
175
  classified,
137
176
  luhnCheck
138
- } from "./chunk-T6GU5PPZ.js";
177
+ } from "./chunk-GU3IP74F.js";
139
178
  import {
140
179
  ClassifiedNeverStoredError,
141
180
  ClassifiedValidationError,
142
181
  isClassifiedFieldSpec,
143
182
  isClassifiedGroup,
144
183
  resolveClassifiedFields
145
- } from "./chunk-UBNCR3YK.js";
146
- import "./chunk-DDATL6PU.js";
147
- import {
148
- CONSENT_AUDIT_COLLECTION
149
- } from "./chunk-EGCRBCNA.js";
150
- import "./chunk-N55W7KUL.js";
151
- import "./chunk-ZEQWCBCM.js";
184
+ } from "./chunk-EE7UHLKH.js";
185
+ import "./chunk-QDIH2744.js";
186
+ import "./chunk-UDHBXYGG.js";
152
187
  import "./chunk-GHVIKOHT.js";
188
+ import {
189
+ PERIODS_COLLECTION
190
+ } from "./chunk-NM5UYF6Q.js";
153
191
  import {
154
192
  immutableGuard,
155
193
  transitionGuard,
156
194
  withGuard
157
- } from "./chunk-6NQMXTYC.js";
195
+ } from "./chunk-RO5NM6UI.js";
196
+ import "./chunk-FQ5CHJR7.js";
158
197
  import "./chunk-JK733I5V.js";
159
- import "./chunk-YMUGBZN2.js";
160
- import "./chunk-ONTBCHCP.js";
198
+ import "./chunk-W66AM5IB.js";
161
199
  import {
162
200
  CollectionFrame,
163
201
  VaultFrame
164
- } from "./chunk-VAIS3SOM.js";
202
+ } from "./chunk-55LX6FSX.js";
203
+ import "./chunk-SMY5X46Z.js";
204
+ import "./chunk-DZFQVICS.js";
165
205
  import {
166
206
  TxCollection,
167
207
  TxContext,
168
208
  TxVault,
169
209
  runTransaction
170
- } from "./chunk-JRBNCUNT.js";
210
+ } from "./chunk-NGSJZFGL.js";
211
+ import "./chunk-5D2ALSM5.js";
171
212
  import {
172
- withDerivation,
173
- withRollup
174
- } from "./chunk-JBBSYJHP.js";
175
- import "./chunk-DDHM2TLX.js";
176
- import "./chunk-3ELCWU56.js";
177
- import "./chunk-VCBHAE4R.js";
213
+ NO_SEARCH,
214
+ tokenize,
215
+ withSearch
216
+ } from "./chunk-MCHBCNCE.js";
178
217
  import {
179
- withMaterializedView
180
- } from "./chunk-T36RFODW.js";
181
- import "./chunk-BGK233EA.js";
218
+ fuseRetrieval
219
+ } from "./chunk-AURFOK3D.js";
182
220
  import {
183
- buildLookupSnapshot
184
- } from "./chunk-MTQPRQHB.js";
185
- import "./chunk-S3BFKGET.js";
186
- import "./chunk-KUPKLSX5.js";
221
+ NO_SEQUENCE,
222
+ SequenceStore,
223
+ compileSequenceFormat,
224
+ resolveSequenceKey,
225
+ withSequence
226
+ } from "./chunk-L2DGWBCT.js";
227
+ import {
228
+ CustodyApi,
229
+ NO_CUSTODY,
230
+ withCustody
231
+ } from "./chunk-YWWQM7KP.js";
187
232
  import {
188
233
  DEFAULT_CROSS_JOIN_MAX_ROWS,
189
234
  Query,
190
235
  ScanBuilder,
191
236
  buildLiveQuery,
192
237
  executePlan
193
- } from "./chunk-A5BDDEXK.js";
238
+ } from "./chunk-WBKZUO5V.js";
194
239
  import {
195
240
  DEFAULT_JOIN_MAX_ROWS,
196
- applyJoins,
197
- resetJoinWarnings
198
- } from "./chunk-RA5VTXXG.js";
241
+ applyJoins
242
+ } from "./chunk-V6UQZA2H.js";
199
243
  import {
200
244
  importExternalObjects,
201
245
  memoryObjectProjection
202
246
  } from "./chunk-4Q6HSHHL.js";
203
- import "./chunk-2P7EGNKF.js";
204
- import "./chunk-VEALDPHW.js";
247
+ import "./chunk-CXQW2NWO.js";
248
+ import {
249
+ BLOB_CHUNKS_COLLECTION,
250
+ BLOB_COLLECTION,
251
+ BLOB_INDEX_COLLECTION,
252
+ BLOB_INTENT_COLLECTION,
253
+ BLOB_SLOTS_PREFIX,
254
+ BLOB_VERSIONS_PREFIX,
255
+ BlobSet,
256
+ DEFAULT_CHUNK_SIZE,
257
+ createIntent,
258
+ deleteIntent,
259
+ detectMagic,
260
+ detectMimeType,
261
+ getIntent,
262
+ isPreCompressed,
263
+ sweepBlobIntents
264
+ } from "./chunk-GWWOGNBK.js";
265
+ import "./chunk-L3YYLT4E.js";
205
266
  import {
206
267
  CollectionIndexes
207
268
  } from "./chunk-KPZS5QAQ.js";
@@ -213,25 +274,10 @@ import {
213
274
  estimateRecordBytes,
214
275
  parseBytes
215
276
  } from "./chunk-NO272T7Q.js";
216
- import {
217
- Aggregation,
218
- GROUPBY_MAX_CARDINALITY,
219
- GROUPBY_WARN_CARDINALITY,
220
- GroupedAggregation,
221
- GroupedQuery,
222
- GroupedQueryN,
223
- avg,
224
- count,
225
- groupAndReduce,
226
- max,
227
- min,
228
- moneyMax,
229
- moneyMin,
230
- moneySum,
231
- reduceRecords,
232
- reducerBuilder,
233
- sum
234
- } from "./chunk-TAGR72IR.js";
277
+ import "./chunk-KRCBZYTZ.js";
278
+ import "./chunk-XZHEOSQ2.js";
279
+ import "./chunk-YMUFFJCO.js";
280
+ import "./chunk-CADUYBQD.js";
235
281
  import {
236
282
  evaluateClause,
237
283
  evaluateFieldClause,
@@ -241,49 +287,13 @@ import {
241
287
  mergeCrdtStates,
242
288
  resolveCrdtSnapshot
243
289
  } from "./chunk-4GPE63GU.js";
244
- import {
245
- decryptExtractedPartition
246
- } from "./chunk-7O3AYBC7.js";
247
- import "./chunk-OF75ACKS.js";
248
- import {
249
- MemoryRecipientSealer,
250
- MemorySealingKeyProvider,
251
- SEALED_PASSPHRASE_RECORD_ID,
252
- aesGcmOpen,
253
- loadSealedPassphrase,
254
- parseRsaOaepTlv,
255
- parseSealedEnvelope,
256
- saveSealedPassphrase,
257
- sealRsaOaepTlv
258
- } from "./chunk-LB6OH6K2.js";
259
- import {
260
- SCHEMAS_COLLECTION,
261
- loadPersistedSchema,
262
- savePersistedSchema
263
- } from "./chunk-F6T6L2UK.js";
264
- import {
265
- BLOB_CHUNKS_COLLECTION,
266
- BLOB_COLLECTION,
267
- BLOB_INDEX_COLLECTION,
268
- BLOB_INTENT_COLLECTION,
269
- BLOB_SLOTS_PREFIX,
270
- BLOB_VERSIONS_PREFIX,
271
- BlobSet,
272
- DEFAULT_CHUNK_SIZE,
273
- createIntent,
274
- deleteIntent,
275
- detectMagic,
276
- detectMimeType,
277
- getIntent,
278
- isPreCompressed,
279
- sweepBlobIntents
280
- } from "./chunk-5OI6BR4H.js";
290
+ import "./chunk-PVEWA2DU.js";
281
291
  import {
282
292
  createBundleStore,
283
293
  createPodStore,
284
294
  wrapBundleStore,
285
295
  wrapPodStore
286
- } from "./chunk-YTGDPCPW.js";
296
+ } from "./chunk-2J6UEN2V.js";
287
297
  import {
288
298
  NOYDB_BUNDLE_FORMAT_VERSION,
289
299
  NOYDB_BUNDLE_MAGIC,
@@ -291,38 +301,34 @@ import {
291
301
  hasNoydbBundleMagic,
292
302
  readNoydbBundle,
293
303
  readNoydbBundleHeader,
294
- readNoydbBundlePublicEnvelope,
295
304
  readPod,
296
305
  readPodCover,
297
306
  readPodHeader,
298
- resetBrotliSupportCache,
299
307
  writeNoydbBundle,
300
308
  writePod
301
- } from "./chunk-A7JJLVGH.js";
309
+ } from "./chunk-LNPUSMZL.js";
302
310
  import {
303
311
  COVER_RECORD_ID,
304
- PUBLIC_ENVELOPE_RECORD_ID,
305
312
  isCover,
306
- isPublicEnvelope,
307
313
  loadCover,
308
- loadPublicEnvelope,
309
314
  readCover,
310
- readPublicEnvelope,
311
315
  saveCover,
312
- savePublicEnvelope,
313
- validateCoverInput,
314
- validatePublicEnvelopeInput
315
- } from "./chunk-J6Q7UVQE.js";
316
- import "./chunk-3U3FBR7O.js";
316
+ validateCoverInput
317
+ } from "./chunk-TUXQSFHZ.js";
318
+ import {
319
+ CONSENT_AUDIT_COLLECTION
320
+ } from "./chunk-EKRSCRNM.js";
321
+ import "./chunk-PEOZ34EM.js";
322
+ import "./chunk-X3F5YJG2.js";
317
323
  import {
318
324
  dictKey,
319
325
  staticDict
320
- } from "./chunk-QDPZWTN2.js";
326
+ } from "./chunk-W3G5REIU.js";
321
327
  import {
322
328
  DICT_COLLECTION_PREFIX,
323
329
  LookupHandle,
324
330
  dictCollectionName
325
- } from "./chunk-IRQY7IR5.js";
331
+ } from "./chunk-FRMPM7WG.js";
326
332
  import {
327
333
  applyI18nLocale,
328
334
  enforceScript,
@@ -337,71 +343,53 @@ import {
337
343
  resolvePolicy,
338
344
  setAtPathInPlace,
339
345
  validateI18nTextValue
340
- } from "./chunk-GULTLPFB.js";
346
+ } from "./chunk-UADPR6F4.js";
341
347
  import {
342
348
  installViaBinder
343
- } from "./chunk-JVBO4SZL.js";
349
+ } from "./chunk-6UBZ6I5Z.js";
344
350
  import {
345
- credentialStatus,
346
- deleteCredential,
347
- getCredential,
348
- listCredentials,
349
- putCredential,
350
351
  withTeam
351
- } from "./chunk-JZWWLLVY.js";
352
+ } from "./chunk-5JOFWL4G.js";
352
353
  import {
353
- MAGIC_LINK_CONTENT_INFO_PREFIX,
354
354
  MAGIC_LINK_GRANTS_COLLECTION,
355
- MAGIC_LINK_KEK_INFO_PREFIX,
356
355
  NO_TEAM,
356
+ burnPaperRecoveryEntry,
357
357
  deriveMagicLinkContentKey,
358
+ describeAllUsersAuth,
359
+ describeAuthConfig,
360
+ describeUserAuth,
361
+ diagramAuthConfig,
358
362
  enrollAuthenticator,
359
363
  findAuthenticator,
360
364
  isMagicLinkGrantExpired,
361
365
  listMagicLinkGrants,
366
+ loadPaperRecoveryEntries,
362
367
  magicLinkGrantRecordId,
368
+ mintPaperRecoveryEntry,
369
+ mintWrappedDeksBlob,
363
370
  readMagicLinkGrantRecord,
364
- recoverPassphrase,
365
371
  recoverUser,
366
372
  removeAuthenticator,
367
373
  revokeMagicLinkGrant,
368
- rotatePassphrase,
369
- unwrapMagicLinkGrant,
370
- writeMagicLinkGrant
371
- } from "./chunk-LOF2W3JU.js";
372
- import {
373
- burnPaperRecoveryEntry,
374
- hasRecoveryEnrolled,
375
- loadPaperRecoveryEntries,
376
- loadShamirRecoveryEntries,
377
- mintPaperRecoveryEntry,
378
- mintShamirRecoveryEntry,
379
- mintWrappedDeksBlob,
374
+ rotateSecret,
380
375
  savePaperRecoveryEntries,
381
- saveShamirRecoveryEntries,
382
376
  unwrapDeksFromBlob,
383
377
  unwrapDeksFromPaperEntry,
384
- unwrapDeksFromShamirEntry
385
- } from "./chunk-2MUZ3LY6.js";
386
- import {
387
- PresenceHandle,
388
- SyncEngine,
389
- SyncTransaction
390
- } from "./chunk-SMGEYW6G.js";
391
- import {
392
- BUNDLE_STORE_POLICY,
393
- INDEXED_STORE_POLICY,
394
- POD_STORE_POLICY,
395
- SyncScheduler
396
- } from "./chunk-VQNJ7UZL.js";
378
+ unwrapMagicLinkGrant,
379
+ writeMagicLinkGrant
380
+ } from "./chunk-NFNJLRY7.js";
397
381
  import {
398
- PERIODS_COLLECTION
399
- } from "./chunk-2IALOXZS.js";
382
+ META_COLLECTION,
383
+ POLICY_RECORD_ID,
384
+ loadVaultPolicy,
385
+ saveVaultPolicy
386
+ } from "./chunk-WLXMTYGO.js";
400
387
  import {
401
388
  SYNC_CREDENTIALS_COLLECTION,
402
- WeakPassphraseError,
403
- assertStrongPassphrase,
389
+ WeakSecretError,
390
+ assertStrongSecret,
404
391
  buildRecipientKeyringFile,
392
+ ensureCollectionDEK,
405
393
  estimateEntropy,
406
394
  evaluateExportCapability,
407
395
  evaluateImportCapability,
@@ -409,8 +397,8 @@ import {
409
397
  hasImportCapability,
410
398
  listUsers,
411
399
  listUsersWithEnvelopes,
412
- validatePassphrase
413
- } from "./chunk-3SV2EPMN.js";
400
+ validateSecret
401
+ } from "./chunk-BLCWSJLN.js";
414
402
  import {
415
403
  DIRECTORY_RECORD_ID,
416
404
  VISIBILITY_RECORD_PREFIX,
@@ -424,13 +412,9 @@ import {
424
412
  readUserVisibility,
425
413
  saveUserEnvelope,
426
414
  visibilityRecordId
427
- } from "./chunk-PK6QCH2C.js";
428
- import {
429
- assertTierAccess,
430
- dekKey,
431
- effectiveClearance
432
- } from "./chunk-UC2ETWF3.js";
433
- import "./chunk-SMIRGMS7.js";
415
+ } from "./chunk-JJZGIE4U.js";
416
+ import "./chunk-PTHKZWEH.js";
417
+ import "./chunk-IXNCZTWA.js";
434
418
  import {
435
419
  PolicyEnforcer,
436
420
  activeSessionCount,
@@ -445,7 +429,8 @@ import {
445
429
  revokeAllSessions,
446
430
  revokeSession,
447
431
  validateSessionPolicy
448
- } from "./chunk-6XE5TMPR.js";
432
+ } from "./chunk-X4MVWPHV.js";
433
+ import "./chunk-VKQCVU2Z.js";
449
434
  import {
450
435
  generateULID,
451
436
  isULID
@@ -453,7 +438,8 @@ import {
453
438
  import {
454
439
  CollectionInstant,
455
440
  VaultInstant
456
- } from "./chunk-4BRCIYFG.js";
441
+ } from "./chunk-QX76XVQH.js";
442
+ import "./chunk-AFHQATY4.js";
457
443
  import {
458
444
  diff,
459
445
  formatDiff
@@ -462,12 +448,12 @@ import {
462
448
  LedgerStore,
463
449
  applyPatch,
464
450
  computePatch
465
- } from "./chunk-UFEVO57O.js";
451
+ } from "./chunk-ABS7FMMD.js";
466
452
  import {
467
453
  LEDGER_COLLECTION,
468
454
  LEDGER_DELTAS_COLLECTION
469
455
  } from "./chunk-I7FD46FF.js";
470
- import "./chunk-DRWBEDYO.js";
456
+ import "./chunk-JYJFGD2H.js";
471
457
  import {
472
458
  canonicalJson,
473
459
  envelopePayloadHash,
@@ -475,17 +461,18 @@ import {
475
461
  paddedIndex,
476
462
  parseIndex,
477
463
  sha256Hex
478
- } from "./chunk-RM2XV574.js";
479
- import "./chunk-KWVJAOIN.js";
480
- import "./chunk-RDXW3OBQ.js";
464
+ } from "./chunk-IXTSNGYY.js";
465
+ import "./chunk-OLEPKFTW.js";
466
+ import "./chunk-QD46HPZG.js";
481
467
  import {
468
+ openEnvelopeJson,
482
469
  validateSchemaInput,
483
470
  validateSchemaOutput
484
- } from "./chunk-DVUZMT2W.js";
485
- import "./chunk-WEYZTLXN.js";
486
- import "./chunk-IY23KFNZ.js";
487
- import "./chunk-N6WF5PKC.js";
488
- import "./chunk-6HY2X62D.js";
471
+ } from "./chunk-G2JUIDFA.js";
472
+ import "./chunk-W3L64Y3J.js";
473
+ import "./chunk-35NMVJ7I.js";
474
+ import "./chunk-NFZGZ4AK.js";
475
+ import "./chunk-QJNCB5SK.js";
489
476
  import "./chunk-LP7BEXCT.js";
490
477
  import {
491
478
  base64ToBuffer,
@@ -493,9 +480,10 @@ import {
493
480
  decryptBytes,
494
481
  decryptDeterministic,
495
482
  derivePresenceKey,
483
+ encrypt,
496
484
  encryptBytes,
497
485
  encryptDeterministic
498
- } from "./chunk-HOONYZY2.js";
486
+ } from "./chunk-AKKRXT23.js";
499
487
  import {
500
488
  NOYDB_BACKUP_VERSION,
501
489
  NOYDB_FORMAT_VERSION,
@@ -503,7 +491,7 @@ import {
503
491
  NOYDB_SYNC_VERSION,
504
492
  SealedHandle,
505
493
  createStore
506
- } from "./chunk-LSASLXGC.js";
494
+ } from "./chunk-QBAC3GXA.js";
507
495
  import {
508
496
  AlreadyElevatedError,
509
497
  AmendmentForbiddenError,
@@ -512,6 +500,7 @@ import {
512
500
  BackupCorruptedError,
513
501
  BackupLedgerError,
514
502
  BlobIntentPendingError,
503
+ BlobOfflineError,
515
504
  BundleIntegrityError,
516
505
  BundleSealMismatchError,
517
506
  BundleVersionConflictError,
@@ -527,8 +516,6 @@ import {
527
516
  CustodyNotEnabledError,
528
517
  DanglingReferenceError,
529
518
  DataResidencyError,
530
- DebugPlaintextError,
531
- DebugReservedFieldError,
532
519
  DecryptionError,
533
520
  DelegationTargetMissingError,
534
521
  DerivationCapExceededError,
@@ -634,1820 +621,53 @@ import {
634
621
  UserEnvelopeOversizedError,
635
622
  ValidationError,
636
623
  VaultTemplateNotFoundError
637
- } from "./chunk-W2OG6JOL.js";
624
+ } from "./chunk-QZWTRENR.js";
638
625
  import "./chunk-PZ5AY32C.js";
639
626
 
640
- // src/kernel/debug.ts
641
- function readPlaintextRecord(envelope) {
642
- if (envelope._iv !== "") {
643
- throw new Error(
644
- "readPlaintextRecord: envelope is encrypted (non-empty _iv) \u2014 decrypt via the vault, not this helper"
645
- );
646
- }
647
- if (envelope._debug !== void 0) {
648
- const record = {};
649
- for (const [key, value] of Object.entries(envelope)) {
650
- if (!key.startsWith("_")) record[key] = value;
651
- }
652
- return record;
653
- }
654
- if (!envelope._data) return null;
655
- return JSON.parse(envelope._data);
656
- }
657
-
658
- // src/with-shape/introspection/projection.ts
659
- function applyListProjection(desc, record, opts) {
660
- const out = { ...record };
661
- for (const f of desc.fields) {
662
- if (f.classified !== void 0) {
663
- const list = f.classified.list;
664
- if (list === "omit") {
665
- delete out[f.key];
666
- continue;
667
- }
668
- if ("mask" in list) {
669
- out[f.key] = list.mask.replace(/\$\{(\w+)\}/g, (_m, rider) => {
670
- const v = record[`${f.key}_${rider}`];
671
- return v === void 0 || v === null ? "\u2022" : `${v}`;
672
- });
673
- continue;
674
- }
675
- out[f.key] = record[`${f.key}_${list.rider}`];
676
- continue;
677
- }
678
- if (opts?.sensitivity !== void 0 && (f.sensitivity === "pii" || f.sensitivity === "secret")) {
679
- if (opts.sensitivity === "omit") delete out[f.key];
680
- else out[f.key] = "\u2022\u2022\u2022";
681
- }
682
- }
683
- return out;
627
+ // src/with-commit/numbering/descriptor.ts
628
+ function withDeferredNumbering(opts) {
629
+ return {
630
+ series: opts.series,
631
+ collection: opts.collection,
632
+ field: opts.field,
633
+ settleWindowMs: opts.settleWindowMs ?? 0
634
+ };
684
635
  }
685
636
 
686
- // src/with-shape/schema-update/strategies.ts
687
- function blindUpdate() {
688
- return { name: "blindUpdate", onSchemaDelta: () => ({ action: "allow" }) };
689
- }
690
- function additiveOnly() {
637
+ // src/via/computed/binding.ts
638
+ var VIRTUAL_POSTURE = { encryptedAtRest: "envelope", queryable: "none", exportable: true, forgettable: false };
639
+ function computedBinding(cfg) {
640
+ const fields = cfg.virtualFields;
691
641
  return {
692
- name: "additiveOnly",
693
- onSchemaDelta(delta) {
694
- if (delta.kind === "non-additive") {
695
- return {
696
- action: "reject",
697
- error: new NonAdditiveSchemaChangeError(
698
- `Non-additive schema change to "${delta.collection}" (added: [${delta.added.join(", ")}], removed: [${delta.removed.join(", ")}], changed: [${delta.changed.map((c) => c.field).join(", ")}]). Register a coordinatedCutover() strategy to migrate, or revert the change.`
699
- )
700
- };
642
+ brand: "computed",
643
+ posture: VIRTUAL_POSTURE,
644
+ covers: (field) => fields.has(field),
645
+ present: (record) => {
646
+ let r = record;
647
+ for (const [field, desc] of fields) {
648
+ if (r === record) r = { ...record };
649
+ r[field] = desc.fn(r);
701
650
  }
702
- return { action: "allow" };
651
+ return r;
703
652
  }
704
653
  };
705
654
  }
706
- function lockSchema(opts) {
707
- const fields = opts?.fields;
708
- return {
709
- name: "lockSchema",
710
- onSchemaDelta(delta) {
711
- if (delta.kind === "none") return { action: "allow" };
712
- const touched = fields ? [...delta.added, ...delta.removed, ...delta.changed.map((c) => c.field)].filter((f) => fields.includes(f)) : ["<any>"];
713
- if (touched.length === 0) return { action: "allow" };
714
- return {
715
- action: "reject",
716
- error: new SchemaLockedError(
717
- `Schema for "${delta.collection}" is locked` + (fields ? ` on fields [${fields.join(", ")}] (touched: [${touched.join(", ")}])` : "") + `; the change was refused.`
718
- )
719
- };
720
- }
721
- };
655
+ function linkComputedVia() {
656
+ installViaBinder("computed", (cfg) => computedBinding(cfg));
722
657
  }
723
658
 
724
- // src/with-shape/schema-update/cutover.ts
725
- function coordinatedCutover(opts) {
659
+ // src/via/computed/descriptor.ts
660
+ function computed(fn, opts) {
661
+ linkComputedVia();
726
662
  return {
727
- name: "coordinatedCutover",
728
- onSchemaDelta(delta) {
729
- if (delta.kind === "non-additive") {
730
- return { action: "cutover", transform: opts.transform };
731
- }
732
- return { action: "allow" };
733
- }
663
+ _viaBrand: "computed",
664
+ fn,
665
+ ...opts?.deps !== void 0 ? { deps: opts.deps } : {},
666
+ mode: opts?.mode ?? "materialized"
734
667
  };
735
- }
736
-
737
- // src/with-store/route-store.ts
738
- var BLOB_CHUNKS = "_blob_chunks";
739
- var BLOB_INDEX = "_blob_index";
740
- var BLOB_SLOTS = "_blob_slots_";
741
- var BLOB_VERSIONS = "_blob_versions_";
742
- function routeStore(opts) {
743
- const primary = opts.default;
744
- const blobsIsSimple = opts.blobs && "get" in opts.blobs;
745
- const simpleBlobStore = blobsIsSimple ? opts.blobs : void 0;
746
- const tieredBlobs = !blobsIsSimple ? opts.blobs : void 0;
747
- const blobThreshold = tieredBlobs?.threshold ?? 400 * 1024;
748
- const allStores = /* @__PURE__ */ new Set([primary]);
749
- if (simpleBlobStore) allStores.add(simpleBlobStore);
750
- if (tieredBlobs?.large) allStores.add(tieredBlobs.large);
751
- if (tieredBlobs?.small) allStores.add(tieredBlobs.small);
752
- if (opts.age?.cold) allStores.add(opts.age.cold);
753
- if (opts.routes) for (const s of Object.values(opts.routes)) allStores.add(s);
754
- if (opts.vaultRoutes) for (const s of Object.values(opts.vaultRoutes)) allStores.add(s);
755
- if (opts.blobRoutes) for (const s of Object.values(opts.blobRoutes)) allStores.add(s);
756
- if (opts.overflow) allStores.add(opts.overflow);
757
- if (opts.blobLifecycle?.archiveStore) allStores.add(opts.blobLifecycle.archiveStore);
758
- const overrides = /* @__PURE__ */ new Map();
759
- const suspended = /* @__PURE__ */ new Set();
760
- const writeQueues = /* @__PURE__ */ new Map();
761
- const NULL_STORE = {
762
- name: "suspended",
763
- async get() {
764
- return null;
765
- },
766
- async put() {
767
- },
768
- async delete() {
769
- },
770
- async list() {
771
- return [];
772
- },
773
- async loadAll() {
774
- return {};
775
- },
776
- async saveAll() {
777
- }
778
- };
779
- function routeNameFor(vault, collection) {
780
- if (opts.vaultRoutes) {
781
- for (const prefix of Object.keys(opts.vaultRoutes)) {
782
- if (vault.startsWith(prefix)) return prefix;
783
- }
784
- }
785
- if (opts.routes && !collection.startsWith("_") && opts.routes[collection]) {
786
- return collection;
787
- }
788
- if (isBlobChunks(collection) && (simpleBlobStore || tieredBlobs)) return "blobs";
789
- if (opts.routeBlobMeta && isBlobMeta(collection) && (simpleBlobStore || tieredBlobs)) return "blobs";
790
- if (opts.age && !collection.startsWith("_")) {
791
- }
792
- return "default";
793
- }
794
- const quotaExceeded = false;
795
- function resolveOriginalStore(route) {
796
- if (route === "blobs") return simpleBlobStore ?? tieredBlobs?.large ?? primary;
797
- if (route === "cold") return opts.age?.cold ?? primary;
798
- if (opts.routes?.[route]) return opts.routes[route];
799
- if (opts.vaultRoutes?.[route]) return opts.vaultRoutes[route];
800
- return primary;
801
- }
802
- function maybeQueueWrite(routeName, method, vault, collection, id, envelope, expectedVersion) {
803
- if (!suspended.has(routeName)) return false;
804
- const queue = writeQueues.get(routeName);
805
- if (!queue) return false;
806
- if (queue.writes.length >= queue.maxSize) {
807
- queue.writes.shift();
808
- }
809
- queue.writes.push({
810
- method,
811
- vault,
812
- collection,
813
- id,
814
- ...envelope !== void 0 ? { envelope } : {},
815
- ...expectedVersion !== void 0 ? { expectedVersion } : {}
816
- });
817
- return true;
818
- }
819
- function isBlobChunks(collection) {
820
- return collection === BLOB_CHUNKS;
821
- }
822
- function isBlobMeta(collection) {
823
- return collection === BLOB_INDEX || collection.startsWith(BLOB_SLOTS) || collection.startsWith(BLOB_VERSIONS);
824
- }
825
- function isInternal(collection) {
826
- return collection.startsWith("_");
827
- }
828
- function storeFor(vault, collection) {
829
- const rName = routeNameFor(vault, collection);
830
- if (suspended.has(rName)) return NULL_STORE;
831
- if (overrides.has(rName)) return overrides.get(rName);
832
- if (opts.vaultRoutes) {
833
- for (const [prefix, store2] of Object.entries(opts.vaultRoutes)) {
834
- if (vault.startsWith(prefix)) return store2;
835
- }
836
- }
837
- if (opts.routes && !isInternal(collection) && opts.routes[collection]) {
838
- return opts.routes[collection];
839
- }
840
- if (isBlobChunks(collection)) {
841
- if (simpleBlobStore) return simpleBlobStore;
842
- if (tieredBlobs) return tieredBlobs.large;
843
- }
844
- if (opts.routeBlobMeta && isBlobMeta(collection)) {
845
- if (simpleBlobStore) return simpleBlobStore;
846
- if (tieredBlobs) return tieredBlobs.large;
847
- }
848
- if (quotaExceeded && opts.overflow) return opts.overflow;
849
- return primary;
850
- }
851
- function blobStoreForSize(dataSize) {
852
- if (!tieredBlobs) return simpleBlobStore ?? primary;
853
- if (dataSize <= blobThreshold) {
854
- return tieredBlobs.small ?? primary;
855
- }
856
- return tieredBlobs.large;
857
- }
858
- function isCold(collection, envelope, before) {
859
- if (!opts.age) return false;
860
- if (isInternal(collection)) return false;
861
- if (opts.age.collections && opts.age.collections.length > 0) {
862
- if (!opts.age.collections.includes(collection)) return false;
863
- }
864
- const cutoffIso = before ?? (opts.age.coldAfterDays != null ? new Date(Date.now() - opts.age.coldAfterDays * 24 * 60 * 60 * 1e3).toISOString() : void 0);
865
- if (cutoffIso === void 0) return false;
866
- return envelope._ts < cutoffIso;
867
- }
868
- const store = {
869
- name: buildName(),
870
- ...opts.age?.cold ? { capabilities: { ...primary.capabilities, coldArchival: true } } : primary.capabilities ? { capabilities: { ...primary.capabilities, coldArchival: false } } : {},
871
- async get(vault, collection, id) {
872
- const s = storeFor(vault, collection);
873
- const result = await s.get(vault, collection, id);
874
- if (result === null && opts.age && !isInternal(collection)) {
875
- if (!opts.age.collections?.length || opts.age.collections.includes(collection)) {
876
- return opts.age.cold.get(vault, collection, id);
877
- }
878
- }
879
- return result;
880
- },
881
- async put(vault, collection, id, envelope, expectedVersion) {
882
- const rn = routeNameFor(vault, collection);
883
- if (maybeQueueWrite(rn, "put", vault, collection, id, envelope, expectedVersion)) return;
884
- if (isBlobChunks(collection) && tieredBlobs) {
885
- const dataSize = envelope._data.length;
886
- const s2 = blobStoreForSize(dataSize);
887
- return s2.put(vault, collection, id, envelope, expectedVersion);
888
- }
889
- const s = storeFor(vault, collection);
890
- if (opts.age && !isInternal(collection)) {
891
- opts.age.cold.delete(vault, collection, id).catch(() => {
892
- });
893
- }
894
- return s.put(vault, collection, id, envelope, expectedVersion);
895
- },
896
- async delete(vault, collection, id) {
897
- const rn = routeNameFor(vault, collection);
898
- if (maybeQueueWrite(rn, "delete", vault, collection, id)) return;
899
- const s = storeFor(vault, collection);
900
- await s.delete(vault, collection, id);
901
- if (opts.age && !isInternal(collection)) {
902
- await opts.age.cold.delete(vault, collection, id).catch(() => {
903
- });
904
- }
905
- },
906
- async list(vault, collection) {
907
- const s = storeFor(vault, collection);
908
- const ids = await s.list(vault, collection);
909
- if (opts.age && !isInternal(collection)) {
910
- if (!opts.age.collections?.length || opts.age.collections.includes(collection)) {
911
- const coldIds = await opts.age.cold.list(vault, collection).catch(() => []);
912
- if (coldIds.length > 0) {
913
- const merged = new Set(ids);
914
- for (const id of coldIds) merged.add(id);
915
- return [...merged];
916
- }
917
- }
918
- }
919
- return ids;
920
- },
921
- async loadAll(vault) {
922
- const stores = getStoresForVault(vault);
923
- const snapshots = await Promise.all(
924
- stores.map((s) => s.loadAll(vault).catch(() => ({})))
925
- );
926
- return mergeSnapshots(snapshots);
927
- },
928
- async saveAll(vault, data) {
929
- const partitioned = /* @__PURE__ */ new Map();
930
- for (const [collection, records] of Object.entries(data)) {
931
- const s = storeFor(vault, collection);
932
- if (!partitioned.has(s)) partitioned.set(s, {});
933
- partitioned.get(s)[collection] = records;
934
- }
935
- await Promise.all(
936
- [...partitioned.entries()].map(([s, snap]) => s.saveAll(vault, snap))
937
- );
938
- },
939
- async compact(vault, compactOpts) {
940
- if (!opts.age) return 0;
941
- let migrated = 0;
942
- const collections = opts.age.collections?.length ? opts.age.collections : Object.keys(await primary.loadAll(vault).catch(() => ({})));
943
- for (const collection of collections) {
944
- const ids = await primary.list(vault, collection).catch(() => []);
945
- for (const id of ids) {
946
- const envelope = await primary.get(vault, collection, id);
947
- if (!envelope) continue;
948
- if (isCold(collection, envelope, compactOpts?.before)) {
949
- await opts.age.cold.put(vault, collection, id, envelope);
950
- await primary.delete(vault, collection, id);
951
- migrated++;
952
- }
953
- }
954
- }
955
- return migrated;
956
- },
957
- // ── Runtime override / suspend ──────────────────────
958
- override(route, overrideStore, overrideOpts) {
959
- if (overrideOpts?.hydrate) {
960
- return (async () => {
961
- overrides.set(route, overrideStore);
962
- })();
963
- }
964
- overrides.set(route, overrideStore);
965
- },
966
- clearOverride(route) {
967
- overrides.delete(route);
968
- },
969
- suspend(route, suspendOpts) {
970
- suspended.add(route);
971
- if (suspendOpts?.queue) {
972
- writeQueues.set(route, {
973
- writes: [],
974
- maxSize: suspendOpts.maxQueueSize ?? 1e4
975
- });
976
- }
977
- },
978
- async resume(route) {
979
- suspended.delete(route);
980
- const queue = writeQueues.get(route);
981
- if (!queue || queue.writes.length === 0) {
982
- writeQueues.delete(route);
983
- return 0;
984
- }
985
- let replayed = 0;
986
- const target = overrides.get(route) ?? resolveOriginalStore(route);
987
- for (const write of queue.writes) {
988
- try {
989
- if (write.method === "put" && write.envelope) {
990
- await target.put(write.vault, write.collection, write.id, write.envelope, write.expectedVersion);
991
- } else if (write.method === "delete") {
992
- await target.delete(write.vault, write.collection, write.id);
993
- }
994
- replayed++;
995
- } catch {
996
- }
997
- }
998
- writeQueues.delete(route);
999
- return replayed;
1000
- },
1001
- routeStatus() {
1002
- const ov = {};
1003
- for (const [k, v] of overrides) ov[k] = v.name ?? "unnamed";
1004
- const q = {};
1005
- for (const [k, v] of writeQueues) q[k] = v.writes.length;
1006
- return { overrides: ov, suspended: [...suspended], queued: q };
1007
- },
1008
- resolveBackend(vaultId) {
1009
- if (opts.vaultRoutes) {
1010
- for (const [prefix, s] of Object.entries(opts.vaultRoutes)) {
1011
- if (vaultId.startsWith(prefix)) return s;
1012
- }
1013
- }
1014
- return primary;
1015
- }
1016
- };
1017
- if (anyHas("listVaults")) {
1018
- store.listVaults = async () => {
1019
- const results = await Promise.all(
1020
- [...allStores].filter((s) => s.listVaults !== void 0).map((s) => s.listVaults().catch(() => []))
1021
- );
1022
- return [...new Set(results.flat())];
1023
- };
1024
- }
1025
- if (anyHas("ping")) {
1026
- store.ping = async () => {
1027
- const results = await Promise.all(
1028
- [...allStores].filter((s) => s.ping !== void 0).map((s) => s.ping().catch(() => false))
1029
- );
1030
- return results.some(Boolean);
1031
- };
1032
- }
1033
- return store;
1034
- function buildName() {
1035
- const names = [...allStores].map((s) => s.name ?? "?").join("+");
1036
- return `route(${names})`;
1037
- }
1038
- function anyHas(method) {
1039
- return [...allStores].some((s) => s[method]);
1040
- }
1041
- function getStoresForVault(vault) {
1042
- const stores = /* @__PURE__ */ new Set();
1043
- if (opts.vaultRoutes) {
1044
- for (const [prefix, s] of Object.entries(opts.vaultRoutes)) {
1045
- if (vault.startsWith(prefix)) {
1046
- stores.add(s);
1047
- return [...stores];
1048
- }
1049
- }
1050
- }
1051
- stores.add(primary);
1052
- if (simpleBlobStore) stores.add(simpleBlobStore);
1053
- if (tieredBlobs?.large) stores.add(tieredBlobs.large);
1054
- if (tieredBlobs?.small && tieredBlobs.small !== primary) stores.add(tieredBlobs.small);
1055
- if (opts.age?.cold) stores.add(opts.age.cold);
1056
- if (opts.routes) {
1057
- for (const s of Object.values(opts.routes)) stores.add(s);
1058
- }
1059
- return [...stores];
1060
- }
1061
- }
1062
- function mergeSnapshots(snapshots) {
1063
- const merged = {};
1064
- for (const snap of snapshots) {
1065
- for (const [collection, records] of Object.entries(snap)) {
1066
- if (!merged[collection]) {
1067
- merged[collection] = { ...records };
1068
- continue;
1069
- }
1070
- for (const [id, envelope] of Object.entries(records)) {
1071
- const existing = merged[collection][id];
1072
- if (!existing || envelope._ts >= existing._ts) {
1073
- merged[collection][id] = envelope;
1074
- }
1075
- }
1076
- }
1077
- }
1078
- return merged;
1079
- }
1080
-
1081
- // src/with-store/store-middleware.ts
1082
- function wrapStore(store, ...middlewares) {
1083
- let result = store;
1084
- for (let i = middlewares.length - 1; i >= 0; i--) {
1085
- result = middlewares[i](result);
1086
- }
1087
- return result;
1088
- }
1089
- function withRetry(opts = {}) {
1090
- const maxRetries = opts.maxRetries ?? 3;
1091
- const backoffMs = opts.backoffMs ?? 500;
1092
- const jitter = opts.jitter ?? 0.3;
1093
- const retryOn = opts.retryOn ? new Set(opts.retryOn) : null;
1094
- function shouldRetry(err) {
1095
- if (!retryOn) return true;
1096
- if (err && typeof err === "object" && "code" in err) {
1097
- return retryOn.has(err.code);
1098
- }
1099
- return true;
1100
- }
1101
- async function retryable(fn) {
1102
- let lastError;
1103
- for (let attempt = 0; attempt <= maxRetries; attempt++) {
1104
- try {
1105
- return await fn();
1106
- } catch (err) {
1107
- lastError = err;
1108
- if (attempt >= maxRetries || !shouldRetry(err)) throw err;
1109
- const delay = backoffMs * Math.pow(2, attempt) * (1 + Math.random() * jitter);
1110
- await new Promise((r) => setTimeout(r, delay));
1111
- }
1112
- }
1113
- throw lastError;
1114
- }
1115
- return (next) => ({
1116
- ...next,
1117
- name: next.name ? `retry(${next.name})` : "retry",
1118
- get: (v, c, id) => retryable(() => next.get(v, c, id)),
1119
- put: (v, c, id, env, ev) => retryable(() => next.put(v, c, id, env, ev)),
1120
- delete: (v, c, id) => retryable(() => next.delete(v, c, id)),
1121
- list: (v, c) => retryable(() => next.list(v, c)),
1122
- loadAll: (v) => retryable(() => next.loadAll(v)),
1123
- saveAll: (v, d) => retryable(() => next.saveAll(v, d))
1124
- });
1125
- }
1126
- var LOG_LEVELS = { debug: 0, info: 1, warn: 2, error: 3 };
1127
- function withLogging(opts = {}) {
1128
- const minLevel = LOG_LEVELS[opts.level ?? "info"];
1129
- const logger = opts.logger ?? console;
1130
- const logData = opts.logData ?? false;
1131
- function log(level, method, args, durationMs) {
1132
- if (LOG_LEVELS[level] < minLevel) return;
1133
- const parts = [`[noydb:${method}]`, ...Object.entries(args).map(([k, v]) => `${k}=${String(v)}`)];
1134
- if (durationMs !== void 0) parts.push(`${durationMs}ms`);
1135
- logger[level](parts.join(" "));
1136
- }
1137
- function timed(method, args, fn) {
1138
- const start = Date.now();
1139
- return fn().then(
1140
- (result) => {
1141
- log("debug", method, args, Date.now() - start);
1142
- return result;
1143
- },
1144
- (err) => {
1145
- log("error", method, { ...args, error: err.message }, Date.now() - start);
1146
- throw err;
1147
- }
1148
- );
1149
- }
1150
- return (next) => ({
1151
- ...next,
1152
- name: next.name ? `log(${next.name})` : "log",
1153
- get: (v, c, id) => timed("get", { vault: v, collection: c, id }, () => next.get(v, c, id)),
1154
- put: (v, c, id, env, ev) => timed("put", {
1155
- vault: v,
1156
- collection: c,
1157
- id,
1158
- version: env._v,
1159
- ...logData ? { data: env._data.slice(0, 40) + "..." } : {}
1160
- }, () => next.put(v, c, id, env, ev)),
1161
- delete: (v, c, id) => timed("delete", { vault: v, collection: c, id }, () => next.delete(v, c, id)),
1162
- list: (v, c) => timed("list", { vault: v, collection: c }, () => next.list(v, c)),
1163
- loadAll: (v) => timed("loadAll", { vault: v }, () => next.loadAll(v)),
1164
- saveAll: (v, d) => timed("saveAll", { vault: v }, () => next.saveAll(v, d))
1165
- });
1166
- }
1167
- function withMetrics(opts) {
1168
- function tracked(method, vault, fn, collection, id) {
1169
- const start = Date.now();
1170
- return fn().then(
1171
- (result) => {
1172
- opts.onOperation({
1173
- method,
1174
- vault,
1175
- ...collection !== void 0 ? { collection } : {},
1176
- ...id !== void 0 ? { id } : {},
1177
- durationMs: Date.now() - start,
1178
- success: true
1179
- });
1180
- return result;
1181
- },
1182
- (err) => {
1183
- opts.onOperation({
1184
- method,
1185
- vault,
1186
- ...collection !== void 0 ? { collection } : {},
1187
- ...id !== void 0 ? { id } : {},
1188
- durationMs: Date.now() - start,
1189
- success: false,
1190
- error: err
1191
- });
1192
- throw err;
1193
- }
1194
- );
1195
- }
1196
- return (next) => ({
1197
- ...next,
1198
- name: next.name ? `metrics(${next.name})` : "metrics",
1199
- get: (v, c, id) => tracked("get", v, () => next.get(v, c, id), c, id),
1200
- put: (v, c, id, env, ev) => tracked("put", v, () => next.put(v, c, id, env, ev), c, id),
1201
- delete: (v, c, id) => tracked("delete", v, () => next.delete(v, c, id), c, id),
1202
- list: (v, c) => tracked("list", v, () => next.list(v, c), c),
1203
- loadAll: (v) => tracked("loadAll", v, () => next.loadAll(v)),
1204
- saveAll: (v, d) => tracked("saveAll", v, () => next.saveAll(v, d))
1205
- });
1206
- }
1207
- function withCircuitBreaker(opts = {}) {
1208
- const threshold = opts.failureThreshold ?? 5;
1209
- const resetMs = opts.resetTimeoutMs ?? 3e4;
1210
- let state = "closed";
1211
- let failures = 0;
1212
- let lastFailureTime = 0;
1213
- function recordSuccess() {
1214
- if (state === "half-open") {
1215
- state = "closed";
1216
- failures = 0;
1217
- opts.onClose?.();
1218
- }
1219
- failures = 0;
1220
- }
1221
- function recordFailure() {
1222
- failures++;
1223
- lastFailureTime = Date.now();
1224
- if (failures >= threshold && state === "closed") {
1225
- state = "open";
1226
- opts.onOpen?.();
1227
- }
1228
- }
1229
- function canAttempt() {
1230
- if (state === "closed") return true;
1231
- if (state === "open") {
1232
- if (Date.now() - lastFailureTime >= resetMs) {
1233
- state = "half-open";
1234
- return true;
1235
- }
1236
- return false;
1237
- }
1238
- return true;
1239
- }
1240
- async function guarded(fn, fallback) {
1241
- if (!canAttempt()) return fallback;
1242
- try {
1243
- const result = await fn();
1244
- recordSuccess();
1245
- return result;
1246
- } catch (err) {
1247
- recordFailure();
1248
- throw err;
1249
- }
1250
- }
1251
- return (next) => ({
1252
- ...next,
1253
- name: next.name ? `cb(${next.name})` : "cb",
1254
- get: (v, c, id) => guarded(() => next.get(v, c, id), null),
1255
- put: (v, c, id, env, ev) => guarded(() => next.put(v, c, id, env, ev), void 0),
1256
- delete: (v, c, id) => guarded(() => next.delete(v, c, id), void 0),
1257
- list: (v, c) => guarded(() => next.list(v, c), []),
1258
- loadAll: (v) => guarded(() => next.loadAll(v), {}),
1259
- saveAll: (v, d) => guarded(() => next.saveAll(v, d), void 0)
1260
- });
1261
- }
1262
- function withCache(opts = {}) {
1263
- const maxEntries = opts.maxEntries ?? 500;
1264
- const ttlMs = opts.ttlMs ?? 6e4;
1265
- const cache = /* @__PURE__ */ new Map();
1266
- function cacheKey(vault, collection, id) {
1267
- return `${vault}\0${collection}\0${id}`;
1268
- }
1269
- function getFromCache(key) {
1270
- const entry = cache.get(key);
1271
- if (!entry) return void 0;
1272
- if (ttlMs > 0 && Date.now() - entry.cachedAt > ttlMs) {
1273
- cache.delete(key);
1274
- return void 0;
1275
- }
1276
- cache.delete(key);
1277
- cache.set(key, entry);
1278
- return entry.envelope;
1279
- }
1280
- function setInCache(key, envelope) {
1281
- if (cache.size >= maxEntries) {
1282
- const oldest = cache.keys().next().value;
1283
- if (oldest !== void 0) cache.delete(oldest);
1284
- }
1285
- cache.set(key, { envelope, cachedAt: Date.now() });
1286
- }
1287
- function invalidate(key) {
1288
- cache.delete(key);
1289
- }
1290
- return (next) => ({
1291
- ...next,
1292
- name: next.name ? `cache(${next.name})` : "cache",
1293
- async get(vault, collection, id) {
1294
- const key = cacheKey(vault, collection, id);
1295
- const cached = getFromCache(key);
1296
- if (cached !== void 0) return cached;
1297
- const result = await next.get(vault, collection, id);
1298
- setInCache(key, result);
1299
- return result;
1300
- },
1301
- async put(vault, collection, id, env, ev) {
1302
- invalidate(cacheKey(vault, collection, id));
1303
- await next.put(vault, collection, id, env, ev);
1304
- setInCache(cacheKey(vault, collection, id), env);
1305
- },
1306
- async delete(vault, collection, id) {
1307
- invalidate(cacheKey(vault, collection, id));
1308
- await next.delete(vault, collection, id);
1309
- },
1310
- list: (v, c) => next.list(v, c),
1311
- loadAll: (v) => next.loadAll(v),
1312
- saveAll: (v, d) => next.saveAll(v, d)
1313
- });
1314
- }
1315
- function withHealthCheck(opts = {}) {
1316
- const intervalMs = opts.checkIntervalMs ?? 3e4;
1317
- const failThreshold = opts.suspendAfterFailures ?? 3;
1318
- const successThreshold = opts.resumeAfterSuccess ?? 1;
1319
- let isSuspended = false;
1320
- let consecutiveFailures = 0;
1321
- let consecutiveSuccesses = 0;
1322
- return (next) => {
1323
- const checkFn = opts.check ?? (next.ping ? () => next.ping() : async () => {
1324
- await next.list("__health__", "__ping__");
1325
- return true;
1326
- });
1327
- async function doCheck() {
1328
- try {
1329
- const ok = await checkFn();
1330
- if (ok) {
1331
- consecutiveFailures = 0;
1332
- consecutiveSuccesses++;
1333
- if (isSuspended && consecutiveSuccesses >= successThreshold) {
1334
- isSuspended = false;
1335
- consecutiveSuccesses = 0;
1336
- opts.onResume?.();
1337
- }
1338
- } else {
1339
- throw new Error("Health check returned false");
1340
- }
1341
- } catch {
1342
- consecutiveSuccesses = 0;
1343
- consecutiveFailures++;
1344
- if (!isSuspended && consecutiveFailures >= failThreshold) {
1345
- isSuspended = true;
1346
- consecutiveFailures = 0;
1347
- opts.onSuspend?.();
1348
- }
1349
- }
1350
- }
1351
- setInterval(() => {
1352
- void doCheck();
1353
- }, intervalMs);
1354
- const wrapped = {
1355
- ...next,
1356
- name: next.name ? `health(${next.name})` : "health",
1357
- async get(v, c, id) {
1358
- return isSuspended ? null : next.get(v, c, id);
1359
- },
1360
- async put(v, c, id, env, ev) {
1361
- if (!isSuspended) await next.put(v, c, id, env, ev);
1362
- },
1363
- async delete(v, c, id) {
1364
- if (!isSuspended) await next.delete(v, c, id);
1365
- },
1366
- async list(v, c) {
1367
- return isSuspended ? [] : next.list(v, c);
1368
- },
1369
- async loadAll(v) {
1370
- return isSuspended ? {} : next.loadAll(v);
1371
- },
1372
- async saveAll(v, d) {
1373
- if (!isSuspended) await next.saveAll(v, d);
1374
- }
1375
- };
1376
- return wrapped;
1377
- };
1378
- }
1379
-
1380
- // src/with-commit/numbering/descriptor.ts
1381
- function withDeferredNumbering(config) {
1382
- return {
1383
- series: config.series,
1384
- collection: config.collection,
1385
- field: config.field,
1386
- settleWindowMs: config.settleWindowMs ?? 0
1387
- };
1388
- }
1389
-
1390
- // src/via/money/iso4217.ts
1391
- var MINOR_UNITS = {
1392
- // 2-decimal majors
1393
- EUR: 2,
1394
- USD: 2,
1395
- GBP: 2,
1396
- CHF: 2,
1397
- CAD: 2,
1398
- AUD: 2,
1399
- NZD: 2,
1400
- SGD: 2,
1401
- HKD: 2,
1402
- CNY: 2,
1403
- INR: 2,
1404
- BRL: 2,
1405
- MXN: 2,
1406
- ZAR: 2,
1407
- RUB: 2,
1408
- TRY: 2,
1409
- PLN: 2,
1410
- SEK: 2,
1411
- NOK: 2,
1412
- DKK: 2,
1413
- CZK: 2,
1414
- HUF: 2,
1415
- RON: 2,
1416
- ILS: 2,
1417
- THB: 2,
1418
- PHP: 2,
1419
- MYR: 2,
1420
- IDR: 2,
1421
- AED: 2,
1422
- SAR: 2,
1423
- QAR: 2,
1424
- EGP: 2,
1425
- // 0-decimal
1426
- JPY: 0,
1427
- KRW: 0,
1428
- ISK: 0,
1429
- CLP: 0,
1430
- VND: 0,
1431
- XOF: 0,
1432
- XAF: 0,
1433
- PYG: 0,
1434
- // 3-decimal
1435
- BHD: 3,
1436
- KWD: 3,
1437
- OMR: 3,
1438
- TND: 3,
1439
- JOD: 3,
1440
- IQD: 3,
1441
- LYD: 3
1442
- };
1443
- function scaleForCurrency(code) {
1444
- const v = MINOR_UNITS[code];
1445
- return v === void 0 ? null : v;
1446
- }
1447
-
1448
- // src/via/money/fixed-point.ts
1449
- function expandExponent(s) {
1450
- const m = /^([+-]?)(\d+)(?:\.(\d+))?[eE]([+-]?\d+)$/.exec(s);
1451
- if (!m) return s;
1452
- const sign = m[1] === "-" ? "-" : "";
1453
- const intp = m[2];
1454
- const frac = m[3] ?? "";
1455
- const exp = Number(m[4]);
1456
- const digits = intp + frac;
1457
- const pointPos = intp.length + exp;
1458
- let body;
1459
- if (pointPos <= 0) {
1460
- body = "0." + "0".repeat(-pointPos) + digits;
1461
- } else if (pointPos >= digits.length) {
1462
- body = digits + "0".repeat(pointPos - digits.length);
1463
- } else {
1464
- body = digits.slice(0, pointPos) + "." + digits.slice(pointPos);
1465
- }
1466
- return sign + body;
1467
- }
1468
- function toCanonicalDecimalString(input) {
1469
- let s;
1470
- if (typeof input === "number") {
1471
- if (!Number.isFinite(input)) return null;
1472
- s = String(input);
1473
- } else {
1474
- s = input.trim();
1475
- }
1476
- s = expandExponent(s);
1477
- if (s.startsWith("+")) s = s.slice(1);
1478
- if (!/^-?(\d+(\.\d*)?|\.\d+)$/.test(s)) return null;
1479
- return s;
1480
- }
1481
- function shouldRoundUp(negative, lastKeptDigit, firstDiscarded, hasMoreNonZeroAfterFirst, mode) {
1482
- switch (mode) {
1483
- case "up":
1484
- return true;
1485
- case "down":
1486
- return false;
1487
- case "ceil":
1488
- return !negative;
1489
- case "floor":
1490
- return negative;
1491
- case "half-up":
1492
- return firstDiscarded >= 5;
1493
- case "half-down":
1494
- return firstDiscarded > 5 || firstDiscarded === 5 && hasMoreNonZeroAfterFirst;
1495
- case "half-even":
1496
- if (firstDiscarded > 5) return true;
1497
- if (firstDiscarded < 5) return false;
1498
- return hasMoreNonZeroAfterFirst || lastKeptDigit % 2 === 1;
1499
- }
1500
- }
1501
- function parseToScaledInt(input, scale, rounding) {
1502
- const canonical = toCanonicalDecimalString(input);
1503
- if (canonical === null) return { ok: false, reason: "nonfinite" };
1504
- const negative = canonical.startsWith("-");
1505
- const unsigned = negative ? canonical.slice(1) : canonical;
1506
- const dot = unsigned.indexOf(".");
1507
- const intPart = dot === -1 ? unsigned : unsigned.slice(0, dot);
1508
- const fracPart = dot === -1 ? "" : unsigned.slice(dot + 1);
1509
- const intDigits = intPart === "" ? "0" : intPart;
1510
- if (fracPart.length <= scale) {
1511
- const keep2 = fracPart.padEnd(scale, "0");
1512
- const magnitude2 = BigInt(intDigits + keep2);
1513
- return { ok: true, value: negative && magnitude2 !== 0n ? -magnitude2 : magnitude2 };
1514
- }
1515
- const keep = fracPart.slice(0, scale);
1516
- const tail = fracPart.slice(scale);
1517
- const magnitudeDigits = intDigits + keep;
1518
- let magnitude = BigInt(magnitudeDigits);
1519
- if (/^0+$/.test(tail)) {
1520
- return { ok: true, value: negative && magnitude !== 0n ? -magnitude : magnitude };
1521
- }
1522
- if (rounding === void 0) return { ok: false, reason: "precision" };
1523
- const lastKeptDigit = Number(magnitudeDigits[magnitudeDigits.length - 1]);
1524
- const firstDiscarded = Number(tail[0]);
1525
- const hasMoreNonZeroAfterFirst = /[1-9]/.test(tail.slice(1));
1526
- if (shouldRoundUp(negative, lastKeptDigit, firstDiscarded, hasMoreNonZeroAfterFirst, rounding)) {
1527
- magnitude += 1n;
1528
- }
1529
- return { ok: true, value: negative && magnitude !== 0n ? -magnitude : magnitude };
1530
- }
1531
- function decimalScaleOf(input) {
1532
- const s = toCanonicalDecimalString(input);
1533
- if (s === null) return null;
1534
- const dot = s.indexOf(".");
1535
- return dot === -1 ? 0 : s.length - dot - 1;
1536
- }
1537
- function rescaleScaledInt(value, fromScale, toScale, rounding = "half-up") {
1538
- if (toScale >= fromScale) return value * 10n ** BigInt(toScale - fromScale);
1539
- const drop = fromScale - toScale;
1540
- const negative = value < 0n;
1541
- const absStr = (negative ? -value : value).toString().padStart(drop + 1, "0");
1542
- const keptStr = absStr.slice(0, absStr.length - drop);
1543
- const tail = absStr.slice(absStr.length - drop);
1544
- let magnitude = BigInt(keptStr);
1545
- if (!/^0+$/.test(tail)) {
1546
- const lastKeptDigit = Number(keptStr[keptStr.length - 1]);
1547
- const firstDiscarded = Number(tail[0]);
1548
- const hasMoreNonZeroAfterFirst = /[1-9]/.test(tail.slice(1));
1549
- if (shouldRoundUp(negative, lastKeptDigit, firstDiscarded, hasMoreNonZeroAfterFirst, rounding)) {
1550
- magnitude += 1n;
1551
- }
1552
- }
1553
- return negative && magnitude !== 0n ? -magnitude : magnitude;
1554
- }
1555
- function formatScaledInt(value, scale) {
1556
- const negative = value < 0n;
1557
- const abs = (negative ? -value : value).toString();
1558
- if (scale === 0) return (negative ? "-" : "") + abs;
1559
- const padded = abs.padStart(scale + 1, "0");
1560
- const cut = padded.length - scale;
1561
- const intPart = padded.slice(0, cut);
1562
- const fracPart = padded.slice(cut);
1563
- return (negative ? "-" : "") + intPart + "." + fracPart;
1564
- }
1565
-
1566
- // src/via/money/paths.ts
1567
- var SEGMENT_RE = /^(\*|[^.[\]*]+)(\[\])?$/;
1568
- var parseCache = /* @__PURE__ */ new Map();
1569
- function parseMoneyPath(path) {
1570
- const cached = parseCache.get(path);
1571
- if (cached) return cached;
1572
- if (typeof path !== "string" || path.length === 0) {
1573
- throw new ValidationError("moneyFields: path must be a non-empty string");
1574
- }
1575
- const segments = [];
1576
- for (const part of path.split(".")) {
1577
- const m = SEGMENT_RE.exec(part);
1578
- if (!m) {
1579
- throw new ValidationError(
1580
- `moneyFields: invalid path "${path}" \u2014 segment "${part}" must be a key, "key[]", "*", or "*[]"`
1581
- );
1582
- }
1583
- const array = m[2] === "[]";
1584
- segments.push(
1585
- m[1] === "*" ? { kind: "wildcard", array } : { kind: "key", key: m[1], array }
1586
- );
1587
- }
1588
- parseCache.set(path, segments);
1589
- return segments;
1590
- }
1591
- function isSimpleMoneyPath(path) {
1592
- return !path.includes(".") && !path.includes("[") && !path.includes("*");
1593
- }
1594
- function validateMoneyFieldPaths(moneyFields) {
1595
- for (const path of Object.keys(moneyFields)) parseMoneyPath(path);
1596
- }
1597
- function transformAtMoneyPath(node, path, segments, index, visit, lenient) {
1598
- if (node === null || node === void 0) return node;
1599
- const seg = segments[index];
1600
- const last = index === segments.length - 1;
1601
- if (seg.kind === "key") {
1602
- if (typeof node !== "object" || Array.isArray(node)) {
1603
- if (lenient) return node;
1604
- throw new ValidationError(
1605
- `moneyFields: path "${path}" expected an object at segment "${seg.key}", got ${Array.isArray(node) ? "an array" : typeof node}`
1606
- );
1607
- }
1608
- const obj2 = node;
1609
- if (!(seg.key in obj2) || obj2[seg.key] === null || obj2[seg.key] === void 0) return node;
1610
- if (seg.array) {
1611
- const arr = obj2[seg.key];
1612
- if (!Array.isArray(arr)) {
1613
- if (lenient) return node;
1614
- throw new ValidationError(
1615
- `moneyFields: path "${path}" declares "${seg.key}[]" but the value is not an array`
1616
- );
1617
- }
1618
- const cloned = [...arr];
1619
- if (last) {
1620
- for (let i = 0; i < cloned.length; i++) visit(cloned, i);
1621
- } else {
1622
- for (let i = 0; i < cloned.length; i++) {
1623
- cloned[i] = transformAtMoneyPath(cloned[i], path, segments, index + 1, visit, lenient);
1624
- }
1625
- }
1626
- return { ...obj2, [seg.key]: cloned };
1627
- }
1628
- const clone2 = { ...obj2 };
1629
- if (last) {
1630
- visit(clone2, seg.key);
1631
- } else {
1632
- clone2[seg.key] = transformAtMoneyPath(clone2[seg.key], path, segments, index + 1, visit, lenient);
1633
- }
1634
- return clone2;
1635
- }
1636
- if (seg.array) {
1637
- if (!Array.isArray(node)) {
1638
- if (lenient) return node;
1639
- throw new ValidationError(`moneyFields: path "${path}" declares "*[]" but the value is not an array`);
1640
- }
1641
- const cloned = [...node];
1642
- if (last) {
1643
- for (let i = 0; i < cloned.length; i++) visit(cloned, i);
1644
- } else {
1645
- for (let i = 0; i < cloned.length; i++) {
1646
- cloned[i] = transformAtMoneyPath(cloned[i], path, segments, index + 1, visit, lenient);
1647
- }
1648
- }
1649
- return cloned;
1650
- }
1651
- if (typeof node !== "object" || Array.isArray(node)) {
1652
- if (lenient) return node;
1653
- throw new ValidationError(
1654
- `moneyFields: path "${path}" applies "*" to a non-object (${Array.isArray(node) ? 'array \u2014 use "*[]"' : typeof node})`
1655
- );
1656
- }
1657
- const obj = node;
1658
- const clone = { ...obj };
1659
- for (const key of Object.keys(obj)) {
1660
- const v = clone[key];
1661
- if (v === null || v === void 0) continue;
1662
- if (last) visit(clone, key);
1663
- else clone[key] = transformAtMoneyPath(v, path, segments, index + 1, visit, lenient);
1664
- }
1665
- return clone;
1666
- }
1667
-
1668
- // src/via/money/normalize.ts
1669
- function isMoneyValueObject(v) {
1670
- return typeof v === "object" && v !== null && "currency" in v;
1671
- }
1672
- function quantizeAmount(field, input, scale, rounding) {
1673
- const r = parseToScaledInt(input, scale, rounding);
1674
- if (!r.ok) {
1675
- if (r.reason === "precision") throw new MoneyPrecisionError(field, input, scale);
1676
- throw new TypeError(`money: field "${field}" value ${JSON.stringify(input)} is not a finite decimal`);
1677
- }
1678
- return r.value.toString();
1679
- }
1680
- function canonicalizeStoredMoney(record, moneyFields) {
1681
- if (record === null || record === void 0) return record;
1682
- if (!moneyFields || Object.keys(moneyFields).length === 0) return record;
1683
- return decodeMoneyFields(record, moneyFields, "raw");
1684
- }
1685
- function canonicalizeIncomingMoney(record, moneyFields) {
1686
- if (!moneyFields || Object.keys(moneyFields).length === 0) return record;
1687
- try {
1688
- return decodeMoneyFields(
1689
- quantizeMoneyFields(record, moneyFields),
1690
- moneyFields,
1691
- "raw"
1692
- );
1693
- } catch {
1694
- return record;
1695
- }
1696
- }
1697
- function quantizeValue(field, raw, desc) {
1698
- if (desc.mode === "fixed") {
1699
- const currency2 = desc.fixedCurrency;
1700
- return quantizeAmount(field, raw, desc.scaleFor(currency2), desc.rounding);
1701
- }
1702
- let amount;
1703
- let currency;
1704
- if (isMoneyValueObject(raw)) {
1705
- currency = String(raw.currency);
1706
- amount = raw.amount;
1707
- } else {
1708
- const sole = desc.soleCurrency();
1709
- if (sole === void 0) {
1710
- throw new TypeError(
1711
- `money: field "${field}" is multi-currency \u2014 write { amount, currency }, not a bare amount`
1712
- );
1713
- }
1714
- currency = sole;
1715
- amount = raw;
1716
- }
1717
- const scale = desc.scaleFor(currency);
1718
- return { amount: quantizeAmount(field, amount, scale, desc.rounding), currency };
1719
- }
1720
- function quantizeMoneyFields(record, moneyFields) {
1721
- let out = { ...record };
1722
- for (const [path, desc] of Object.entries(moneyFields)) {
1723
- if (isSimpleMoneyPath(path)) {
1724
- const raw = out[path];
1725
- if (raw === null || raw === void 0) continue;
1726
- out[path] = quantizeValue(path, raw, desc);
1727
- continue;
1728
- }
1729
- out = transformAtMoneyPath(
1730
- out,
1731
- path,
1732
- parseMoneyPath(path),
1733
- 0,
1734
- (container, key) => {
1735
- const raw = container[key];
1736
- if (raw === null || raw === void 0) return;
1737
- container[key] = quantizeValue(path, raw, desc);
1738
- },
1739
- /* lenient */
1740
- false
1741
- );
1742
- }
1743
- return out;
1744
- }
1745
- function formatCurrency(decimal, currency, scale, locale) {
1746
- const fmt = new Intl.NumberFormat(locale, {
1747
- style: "currency",
1748
- currency,
1749
- minimumFractionDigits: scale,
1750
- maximumFractionDigits: scale
1751
- });
1752
- return fmt.format(decimal);
1753
- }
1754
- function moneyScaledValue(stored, desc) {
1755
- let raw;
1756
- if (desc.mode === "fixed") {
1757
- raw = stored;
1758
- } else {
1759
- if (!isMoneyValueObject(stored)) return null;
1760
- raw = stored.amount;
1761
- }
1762
- if (typeof raw !== "string" && typeof raw !== "number") return null;
1763
- try {
1764
- return BigInt(String(raw));
1765
- } catch {
1766
- return null;
1767
- }
1768
- }
1769
- function canonicalizeMoneyIndexKey(field, rawValue, moneyFields) {
1770
- const desc = moneyFields[field];
1771
- if (!desc || desc.mode !== "fixed") return void 0;
1772
- return moneyScaledValue(rawValue, desc)?.toString();
1773
- }
1774
- function decodeValue(stored, desc) {
1775
- let currency;
1776
- let scaledIntString;
1777
- if (desc.mode === "fixed") {
1778
- if (typeof stored !== "string" && typeof stored !== "number") return null;
1779
- currency = desc.fixedCurrency;
1780
- scaledIntString = String(stored);
1781
- } else {
1782
- if (!isMoneyValueObject(stored)) return null;
1783
- const amount = stored.amount;
1784
- if (typeof stored.currency !== "string" || typeof amount !== "string" && typeof amount !== "number") return null;
1785
- currency = stored.currency;
1786
- scaledIntString = String(amount);
1787
- }
1788
- const scale = desc.scaleFor(currency);
1789
- let decimal;
1790
- try {
1791
- decimal = formatScaledInt(BigInt(scaledIntString), scale);
1792
- } catch {
1793
- return null;
1794
- }
1795
- return {
1796
- decoded: desc.mode === "fixed" ? decimal : { amount: decimal, currency },
1797
- decimal,
1798
- currency,
1799
- scale
1800
- };
1801
- }
1802
- function presentVirtualMoneyFields(record, moneyFields, virtualMoney, locale) {
1803
- let out = record;
1804
- const format = locale !== "raw";
1805
- const fmtLocale = typeof locale === "string" && locale !== "raw" ? locale : "en-US";
1806
- for (const field of virtualMoney) {
1807
- const desc = moneyFields[field];
1808
- if (!desc || desc.mode !== "fixed") continue;
1809
- const raw = out[field];
1810
- if (raw === null || raw === void 0) continue;
1811
- if (typeof raw !== "number" && typeof raw !== "string") continue;
1812
- const currency = desc.fixedCurrency;
1813
- const scale = desc.scaleFor(currency);
1814
- const r = parseToScaledInt(raw, scale, desc.rounding);
1815
- if (!r.ok) continue;
1816
- if (out === record) out = { ...record };
1817
- const decimal = formatScaledInt(r.value, scale);
1818
- out[field] = decimal;
1819
- if (format) {
1820
- out[`${field}Formatted`] = formatCurrency(decimal, currency, scale, fmtLocale);
1821
- out[`${field}Number`] = Number(decimal);
1822
- }
1823
- }
1824
- return out;
1825
- }
1826
- function decodeMoneyFields(record, moneyFields, locale) {
1827
- let out = { ...record };
1828
- const format = locale !== "raw";
1829
- const fmtLocale = typeof locale === "string" && locale !== "raw" ? locale : "en-US";
1830
- for (const [path, desc] of Object.entries(moneyFields)) {
1831
- if (isSimpleMoneyPath(path)) {
1832
- const stored = out[path];
1833
- if (stored === null || stored === void 0) continue;
1834
- const r = decodeValue(stored, desc);
1835
- if (r === null) continue;
1836
- out[path] = r.decoded;
1837
- if (format) {
1838
- out[`${path}Formatted`] = formatCurrency(r.decimal, r.currency, r.scale, fmtLocale);
1839
- out[`${path}Number`] = Number(r.decimal);
1840
- }
1841
- continue;
1842
- }
1843
- out = transformAtMoneyPath(
1844
- out,
1845
- path,
1846
- parseMoneyPath(path),
1847
- 0,
1848
- (container, key) => {
1849
- const stored = container[key];
1850
- if (stored === null || stored === void 0) return;
1851
- const r = decodeValue(stored, desc);
1852
- if (r === null) return;
1853
- container[key] = r.decoded;
1854
- if (format && typeof key === "string" && !Array.isArray(container)) {
1855
- container[`${key}Formatted`] = formatCurrency(r.decimal, r.currency, r.scale, fmtLocale);
1856
- container[`${key}Number`] = Number(r.decimal);
1857
- }
1858
- },
1859
- /* lenient */
1860
- true
1861
- );
1862
- }
1863
- return out;
1864
- }
1865
-
1866
- // src/via/money/where.ts
1867
- function isMoneyValueObject2(v) {
1868
- return typeof v === "object" && v !== null && "currency" in v;
1869
- }
1870
- function parseOperand(field, raw, desc) {
1871
- let amount;
1872
- let currency;
1873
- if (desc.mode === "fixed") {
1874
- currency = desc.fixedCurrency;
1875
- amount = raw;
1876
- } else if (isMoneyValueObject2(raw)) {
1877
- currency = String(raw.currency);
1878
- amount = raw.amount;
1879
- } else {
1880
- const sole = desc.soleCurrency();
1881
- if (sole === void 0) {
1882
- throw new MoneyUnsupportedError(
1883
- `where("${field}"): field is multi-currency \u2014 compare against { amount, currency }, not a bare amount`
1884
- );
1885
- }
1886
- currency = sole;
1887
- amount = raw;
1888
- }
1889
- if (typeof amount !== "number" && typeof amount !== "string") {
1890
- throw new MoneyUnsupportedError(
1891
- `where("${field}"): operand ${JSON.stringify(raw)} is not a money amount`
1892
- );
1893
- }
1894
- const r = parseToScaledInt(amount, desc.scaleFor(currency), desc.rounding);
1895
- if (!r.ok) {
1896
- throw new MoneyUnsupportedError(
1897
- `where("${field}"): operand ${JSON.stringify(amount)} is not a finite decimal`
1898
- );
1899
- }
1900
- return { scaled: r.value.toString(), currency };
1901
- }
1902
- function moneyFieldClause(field, op, value, desc) {
1903
- switch (op) {
1904
- case "==":
1905
- case "!=":
1906
- case "<":
1907
- case "<=":
1908
- case ">":
1909
- case ">=": {
1910
- const e = parseOperand(field, value, desc);
1911
- return { mode: desc.mode, entries: [e] };
1912
- }
1913
- case "between": {
1914
- if (!Array.isArray(value) || value.length !== 2) {
1915
- throw new MoneyUnsupportedError(`where("${field}"): 'between' needs a [lo, hi] tuple`);
1916
- }
1917
- const lo = parseOperand(field, value[0], desc);
1918
- const hi = parseOperand(field, value[1], desc);
1919
- if (lo.currency !== hi.currency) {
1920
- throw new MoneyUnsupportedError(
1921
- `where("${field}"): 'between' bounds mix currencies (${lo.currency} vs ${hi.currency})`
1922
- );
1923
- }
1924
- return { mode: desc.mode, entries: [lo, hi] };
1925
- }
1926
- case "in": {
1927
- if (!Array.isArray(value)) {
1928
- throw new MoneyUnsupportedError(`where("${field}"): 'in' needs an array of amounts`);
1929
- }
1930
- return { mode: desc.mode, entries: value.map((v) => parseOperand(field, v, desc)) };
1931
- }
1932
- default:
1933
- throw new MoneyUnsupportedError(
1934
- `where("${field}"): operator '${op}' is not supported on a money field`
1935
- );
1936
- }
1937
- }
1938
- function moneyIndexProbe(op, payload) {
1939
- if (payload.mode !== "fixed") return void 0;
1940
- if (op === "==") return payload.entries[0]?.scaled;
1941
- if (op === "in") return payload.entries.map((e) => e.scaled);
1942
- return void 0;
1943
- }
1944
- function readStored(actual, operand) {
1945
- let amount;
1946
- let currency;
1947
- if (operand.mode === "fixed") {
1948
- if (typeof actual !== "string" && typeof actual !== "number") return null;
1949
- amount = actual;
1950
- currency = operand.entries[0]?.currency ?? "";
1951
- } else {
1952
- if (!isMoneyValueObject2(actual)) return null;
1953
- if (typeof actual.currency !== "string") return null;
1954
- amount = actual.amount;
1955
- currency = actual.currency;
1956
- }
1957
- if (typeof amount !== "string" && typeof amount !== "number") return null;
1958
- try {
1959
- return { scaled: BigInt(amount).toString(), currency };
1960
- } catch {
1961
- return null;
1962
- }
1963
- }
1964
- function evaluateMoneyClause(actual, op, operand) {
1965
- const stored = readStored(actual, operand);
1966
- if (stored === null) return op === "!=";
1967
- const a = BigInt(stored.scaled);
1968
- if (op === "in") {
1969
- return operand.entries.some(
1970
- (e2) => e2.currency === stored.currency && BigInt(e2.scaled) === a
1971
- );
1972
- }
1973
- if (op === "between") {
1974
- const [lo, hi] = operand.entries;
1975
- if (!lo || !hi || lo.currency !== stored.currency) return false;
1976
- return a >= BigInt(lo.scaled) && a <= BigInt(hi.scaled);
1977
- }
1978
- const e = operand.entries[0];
1979
- if (!e) return false;
1980
- if (e.currency !== stored.currency) return op === "!=";
1981
- const b = BigInt(e.scaled);
1982
- switch (op) {
1983
- case "==":
1984
- return a === b;
1985
- case "!=":
1986
- return a !== b;
1987
- case "<":
1988
- return a < b;
1989
- case "<=":
1990
- return a <= b;
1991
- case ">":
1992
- return a > b;
1993
- case ">=":
1994
- return a >= b;
1995
- default:
1996
- return false;
1997
- }
1998
- }
1999
-
2000
- // src/via/money/money-reducer.ts
2001
- function toScaledIntFromAny(v, scale) {
2002
- if (typeof v === "bigint") return v;
2003
- if (typeof v === "number") {
2004
- const r = parseToScaledInt(v, scale);
2005
- return r.ok ? r.value : null;
2006
- }
2007
- if (typeof v === "string") {
2008
- if (!v.includes(".")) {
2009
- try {
2010
- return BigInt(v);
2011
- } catch {
2012
- return null;
2013
- }
2014
- }
2015
- const r = parseToScaledInt(v, scale);
2016
- return r.ok ? r.value : null;
2017
- }
2018
- return null;
2019
- }
2020
- function readMoney(record, field, desc) {
2021
- const raw = readPath(record, field);
2022
- if (raw === null || raw === void 0) return null;
2023
- if (desc.mode === "fixed") {
2024
- const cur = desc.fixedCurrency;
2025
- const value2 = toScaledIntFromAny(raw, desc.scaleFor(cur));
2026
- return value2 === null ? null : { currency: cur, value: value2 };
2027
- }
2028
- if (typeof raw !== "object") return null;
2029
- const o = raw;
2030
- if (typeof o.currency !== "string") return null;
2031
- const scale = desc.allows(o.currency) ? desc.scaleFor(o.currency) : 0;
2032
- const value = toScaledIntFromAny(o.amount, scale);
2033
- return value === null ? null : { currency: o.currency, value };
2034
- }
2035
- function targetScaleFor(desc, currency) {
2036
- if (desc.allows(currency)) return desc.scaleFor(currency);
2037
- const s = scaleForCurrency(currency);
2038
- if (s === null) {
2039
- throw new Error(`money: cannot determine scale for conversion target "${currency}"`);
2040
- }
2041
- return s;
2042
- }
2043
- function parseRate(rate) {
2044
- const s = String(rate).trim();
2045
- const neg = s.startsWith("-");
2046
- const body = neg ? s.slice(1) : s;
2047
- const dot = body.indexOf(".");
2048
- const intPart = dot === -1 ? body : body.slice(0, dot);
2049
- const fracPart = dot === -1 ? "" : body.slice(dot + 1);
2050
- const int = BigInt((intPart === "" ? "0" : intPart) + fracPart);
2051
- return { int: neg ? -int : int, scale: fracPart.length };
2052
- }
2053
- function divRoundHalfEven(n, d) {
2054
- const q = n / d;
2055
- const r = n % d;
2056
- const twiceR = (r < 0n ? -r : r) * 2n;
2057
- if (twiceR < d) return q;
2058
- if (twiceR > d) return q + (n < 0n ? -1n : 1n);
2059
- return q % 2n === 0n ? q : q + (n < 0n ? -1n : 1n);
2060
- }
2061
- function convertScaled(value, srcScale, rate, targetScale) {
2062
- const { int: rateInt, scale: rateScale } = parseRate(rate);
2063
- const product = value * rateInt;
2064
- const curScale = srcScale + rateScale;
2065
- if (curScale === targetScale) return product;
2066
- if (curScale < targetScale) return product * 10n ** BigInt(targetScale - curScale);
2067
- return divRoundHalfEven(product, 10n ** BigInt(curScale - targetScale));
2068
- }
2069
- function finalizeSum(state, desc, convertTo, fx) {
2070
- if (convertTo !== void 0) {
2071
- if (fx === void 0) {
2072
- throw new Error(`money: sum convertTo "${convertTo}" requires an fx rate map`);
2073
- }
2074
- const targetScale = targetScaleFor(desc, convertTo);
2075
- let total = 0n;
2076
- for (const [cur, v] of state) {
2077
- if (cur === convertTo) {
2078
- total += convertScaled(v, desc.scaleFor(cur), 1, targetScale);
2079
- continue;
2080
- }
2081
- const rate = fx[`${cur}->${convertTo}`];
2082
- if (rate === void 0) {
2083
- throw new Error(`money: no fx rate for "${cur}->${convertTo}"`);
2084
- }
2085
- total += convertScaled(v, desc.scaleFor(cur), rate, targetScale);
2086
- }
2087
- return formatScaledInt(total, targetScale);
2088
- }
2089
- if (desc.mode === "fixed") {
2090
- const cur = desc.fixedCurrency;
2091
- return formatScaledInt(state.get(cur) ?? 0n, desc.scaleFor(cur));
2092
- }
2093
- const out = {};
2094
- for (const [cur, v] of state) out[cur] = formatScaledInt(v, desc.scaleFor(cur));
2095
- return out;
2096
- }
2097
- function moneySumReducer(field, desc, convertTo, fx) {
2098
- return {
2099
- op: "sum",
2100
- field,
2101
- init: () => /* @__PURE__ */ new Map(),
2102
- step: (state, record) => {
2103
- const m = readMoney(record, field, desc);
2104
- if (m) state.set(m.currency, (state.get(m.currency) ?? 0n) + m.value);
2105
- return state;
2106
- },
2107
- remove: (state, record) => {
2108
- const m = readMoney(record, field, desc);
2109
- if (m) state.set(m.currency, (state.get(m.currency) ?? 0n) - m.value);
2110
- return state;
2111
- },
2112
- finalize: (state) => finalizeSum(state, desc, convertTo, fx)
2113
- };
2114
- }
2115
- function extremum(values, op) {
2116
- let out = values[0];
2117
- for (let i = 1; i < values.length; i++) {
2118
- const v = values[i];
2119
- if (op === "min" ? v < out : v > out) out = v;
2120
- }
2121
- return out;
2122
- }
2123
- function moneyMinMaxReducer(op, field, desc) {
2124
- return {
2125
- op,
2126
- field,
2127
- init: () => /* @__PURE__ */ new Map(),
2128
- step: (state, record) => {
2129
- const m = readMoney(record, field, desc);
2130
- if (m) {
2131
- const arr = state.get(m.currency);
2132
- if (arr) arr.push(m.value);
2133
- else state.set(m.currency, [m.value]);
2134
- }
2135
- return state;
2136
- },
2137
- remove: (state, record) => {
2138
- const m = readMoney(record, field, desc);
2139
- if (m) {
2140
- const arr = state.get(m.currency);
2141
- if (arr) {
2142
- const idx = arr.indexOf(m.value);
2143
- if (idx >= 0) arr.splice(idx, 1);
2144
- }
2145
- }
2146
- return state;
2147
- },
2148
- finalize: (state) => {
2149
- if (desc.mode === "fixed") {
2150
- const cur = desc.fixedCurrency;
2151
- const arr = state.get(cur);
2152
- if (!arr || arr.length === 0) return null;
2153
- return formatScaledInt(extremum(arr, op), desc.scaleFor(cur));
2154
- }
2155
- const out = {};
2156
- for (const [cur, arr] of state) {
2157
- if (arr.length > 0) out[cur] = formatScaledInt(extremum(arr, op), desc.scaleFor(cur));
2158
- }
2159
- return out;
2160
- }
2161
- };
2162
- }
2163
- function wrapMoneyReducers(spec, moneyFields) {
2164
- let changed = false;
2165
- const out = {};
2166
- for (const [key, reducer] of Object.entries(spec)) {
2167
- const field = reducer.field;
2168
- const desc = field ? moneyFields[field] : void 0;
2169
- if (desc && reducer.op === "avg") {
2170
- throw new MoneyUnsupportedError(
2171
- field,
2172
- `avg() is not supported on money field "${field}" in v1 \u2014 use sum() and count() and divide at the boundary.`
2173
- );
2174
- }
2175
- if (desc && (reducer.op === "sum" || reducer.op === "min" || reducer.op === "max")) {
2176
- changed = true;
2177
- out[key] = reducer.op === "sum" ? moneySumReducer(field, desc, reducer.convertTo, reducer.fx) : moneyMinMaxReducer(reducer.op, field, desc);
2178
- } else {
2179
- out[key] = reducer;
2180
- }
2181
- }
2182
- return changed ? out : spec;
2183
- }
2184
-
2185
- // src/via/money/binding.ts
2186
- function moneyBinding(moneyFields, virtualMoneyFields) {
2187
- validateMoneyFieldPaths(moneyFields);
2188
- const hasVirtualMoney = virtualMoneyFields !== void 0 && virtualMoneyFields.size > 0;
2189
- const ordinaryPresentFields = hasVirtualMoney ? Object.fromEntries(Object.entries(moneyFields).filter(([f]) => !virtualMoneyFields.has(f))) : moneyFields;
2190
- return {
2191
- brand: "money",
2192
- posture: { encryptedAtRest: "envelope", queryable: "ordered", exportable: true, forgettable: true },
2193
- covers: (field) => field in moneyFields,
2194
- ingest: (r) => canonicalizeIncomingMoney(r, moneyFields),
2195
- canonicalizeStored: (r) => canonicalizeStoredMoney(r, moneyFields),
2196
- encodeWrite: (r) => quantizeMoneyFields(r, moneyFields),
2197
- present: (r, ctx) => decodeMoneyFields(r, ordinaryPresentFields, typeof ctx.locale === "string" ? ctx.locale : void 0),
2198
- ...hasVirtualMoney ? {
2199
- presentLate: (r, ctx) => presentVirtualMoneyFields(r, moneyFields, virtualMoneyFields, typeof ctx.locale === "string" ? ctx.locale : void 0)
2200
- } : {},
2201
- buildClause: (field, op, value) => {
2202
- const desc = moneyFields[field];
2203
- if (!desc) return void 0;
2204
- return moneyFieldClause(field, op, value, desc);
2205
- },
2206
- evaluateClause: (actual, op, payload) => evaluateMoneyClause(actual, op, payload),
2207
- indexProbe: (op, payload) => moneyIndexProbe(op, payload),
2208
- canonicalizeIndexKey: (field, rawValue) => canonicalizeMoneyIndexKey(field, rawValue, moneyFields),
2209
- decodeResults: (r) => decodeMoneyFields(r, moneyFields, "raw"),
2210
- compareForOrder: (field, a, b) => {
2211
- const desc = moneyFields[field];
2212
- if (!desc) return void 0;
2213
- const av = moneyScaledValue(a, desc);
2214
- const bv = moneyScaledValue(b, desc);
2215
- if (av === null) return bv === null ? 0 : 1;
2216
- if (bv === null) return -1;
2217
- return av < bv ? -1 : av > bv ? 1 : 0;
2218
- },
2219
- wrapReducers: (spec) => wrapMoneyReducers(spec, moneyFields)
2220
- };
2221
- }
2222
- function linkMoneyVia() {
2223
- installViaBinder("money", (cfg) => {
2224
- const c = cfg;
2225
- return moneyBinding(c.moneyFields, c.virtualMoneyFields);
2226
- });
2227
- }
2228
-
2229
- // src/via/money/descriptor.ts
2230
- var MoneyPrecisionError = class extends NoydbError {
2231
- constructor(field, value, scale) {
2232
- super(
2233
- "MONEY_PRECISION",
2234
- `money: value ${JSON.stringify(value)} for field "${field}" exceeds scale ${scale} and no rounding mode is configured`
2235
- );
2236
- this.field = field;
2237
- this.value = value;
2238
- this.scale = scale;
2239
- this.name = "MoneyPrecisionError";
2240
- }
2241
- field;
2242
- value;
2243
- scale;
2244
- };
2245
- var MoneyCurrencyError = class extends NoydbError {
2246
- constructor(currency, reason, field) {
2247
- super(
2248
- "MONEY_CURRENCY",
2249
- reason === "not-allowed" ? `money: currency "${currency}" is not allowed${field ? ` for field "${field}"` : ""}` : `money: no scale known for currency "${currency}"${field ? ` (field "${field}")` : ""} \u2014 pass an explicit scale / scaleOverrides`
2250
- );
2251
- this.currency = currency;
2252
- this.reason = reason;
2253
- this.field = field;
2254
- this.name = "MoneyCurrencyError";
2255
- }
2256
- currency;
2257
- reason;
2258
- field;
2259
- };
2260
- var MoneyUnsupportedError = class extends NoydbError {
2261
- constructor(field, message) {
2262
- super(
2263
- "MONEY_UNSUPPORTED",
2264
- message ?? `money: operation is not supported on field "${field}" \u2014 use sum() and count() and divide at the boundary`
2265
- );
2266
- this.field = field;
2267
- this.name = "MoneyUnsupportedError";
2268
- }
2269
- field;
2270
- };
2271
- function isMultiOptions(o) {
2272
- return "currencies" in o;
2273
- }
2274
- function money(options) {
2275
- linkMoneyVia();
2276
- const hasFixed = "currency" in options;
2277
- const hasMulti = "currencies" in options;
2278
- if (hasFixed && hasMulti) {
2279
- throw new TypeError("money: `currency` and `currencies` are mutually exclusive");
2280
- }
2281
- if (!hasFixed && !hasMulti) {
2282
- throw new TypeError("money: one of `currency` or `currencies` is required");
2283
- }
2284
- const rounding = options.rounding;
2285
- if (isMultiOptions(options)) {
2286
- const overrides = options.scaleOverrides ?? {};
2287
- const allowList = options.currencies;
2288
- const allows = (c) => allowList === "any" ? true : allowList.includes(c);
2289
- const scaleFor = (c) => {
2290
- if (!allows(c)) throw new MoneyCurrencyError(c, "not-allowed");
2291
- const s = overrides[c] ?? scaleForCurrency(c);
2292
- if (s === null || s === void 0) throw new MoneyCurrencyError(c, "unknown-scale");
2293
- return s;
2294
- };
2295
- if (allowList !== "any") for (const c of allowList) scaleFor(c);
2296
- const soleCurrency = () => allowList !== "any" && allowList.length === 1 ? allowList[0] : void 0;
2297
- return {
2298
- _noydbMoney: true,
2299
- _viaBrand: "money",
2300
- mode: "multi",
2301
- options,
2302
- rounding,
2303
- fixedCurrency: void 0,
2304
- scaleFor,
2305
- allows,
2306
- soleCurrency
2307
- };
2308
- }
2309
- const currency = options.currency;
2310
- const resolvedScale = options.scale ?? scaleForCurrency(currency);
2311
- if (resolvedScale === null || resolvedScale === void 0) {
2312
- throw new MoneyCurrencyError(currency, "unknown-scale");
2313
- }
2314
- return {
2315
- _noydbMoney: true,
2316
- _viaBrand: "money",
2317
- mode: "fixed",
2318
- options,
2319
- rounding,
2320
- fixedCurrency: currency,
2321
- scaleFor(c) {
2322
- if (c !== currency) throw new MoneyCurrencyError(c, "not-allowed");
2323
- return resolvedScale;
2324
- },
2325
- allows: (c) => c === currency,
2326
- soleCurrency: () => currency
2327
- };
2328
- }
2329
- function isMoneyDescriptor(x) {
2330
- return typeof x === "object" && x !== null && x._noydbMoney === true;
2331
- }
2332
-
2333
- // src/via/money/arith.ts
2334
- function parseAmount(label, amount, scale, rounding) {
2335
- const r = parseToScaledInt(amount, scale, rounding);
2336
- if (!r.ok) {
2337
- throw new MoneyUnsupportedError(
2338
- 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`
2339
- );
2340
- }
2341
- return r.value;
2342
- }
2343
- function resolveScale(label, amount, explicit) {
2344
- if (explicit !== void 0) {
2345
- if (!Number.isInteger(explicit) || explicit < 0) {
2346
- throw new MoneyUnsupportedError(`${label}: scale must be a non-negative integer`);
2347
- }
2348
- return explicit;
2349
- }
2350
- const inferred = decimalScaleOf(amount);
2351
- if (inferred === null) {
2352
- throw new MoneyUnsupportedError(`${label}: amount ${JSON.stringify(amount)} is not a finite decimal`);
2353
- }
2354
- return inferred;
2355
- }
2356
- function mulRate(amount, rate, opts = {}) {
2357
- const scale = resolveScale("mulRate", amount, opts.scale);
2358
- const rounding = opts.rounding ?? "half-up";
2359
- const a = parseAmount("mulRate", amount, scale, rounding);
2360
- const rateScale = decimalScaleOf(rate);
2361
- if (rateScale === null) {
2362
- throw new MoneyUnsupportedError(`mulRate: rate ${JSON.stringify(rate)} is not a finite decimal`);
2363
- }
2364
- const r = parseToScaledInt(rate, rateScale);
2365
- if (!r.ok) {
2366
- throw new MoneyUnsupportedError(`mulRate: rate ${JSON.stringify(rate)} is not a finite decimal`);
2367
- }
2368
- const product = a * r.value;
2369
- return formatScaledInt(rescaleScaledInt(product, scale + rateScale, scale, rounding), scale);
2370
- }
2371
- function allocate(amount, weights, opts = {}) {
2372
- if (weights.length === 0) {
2373
- throw new MoneyUnsupportedError("allocate: weights must not be empty");
2374
- }
2375
- const scale = resolveScale("allocate", amount, opts.scale);
2376
- const a = parseAmount("allocate", amount, scale);
2377
- let weightScale = 0;
2378
- for (const w of weights) {
2379
- const s = decimalScaleOf(w);
2380
- if (s === null) {
2381
- throw new MoneyUnsupportedError(`allocate: weight ${JSON.stringify(w)} is not a finite decimal`);
2382
- }
2383
- if (s > weightScale) weightScale = s;
2384
- }
2385
- const scaledWeights = weights.map((w) => {
2386
- const r = parseToScaledInt(w, weightScale);
2387
- if (!r.ok || r.value < 0n) {
2388
- throw new MoneyUnsupportedError(`allocate: weight ${JSON.stringify(w)} must be a non-negative decimal`);
2389
- }
2390
- return r.value;
2391
- });
2392
- const sumW = scaledWeights.reduce((acc, w) => acc + w, 0n);
2393
- if (sumW === 0n) {
2394
- throw new MoneyUnsupportedError("allocate: weights must not all be zero");
2395
- }
2396
- const negative = a < 0n;
2397
- const mag = negative ? -a : a;
2398
- const base = [];
2399
- const remainders = [];
2400
- let distributed = 0n;
2401
- for (let i = 0; i < scaledWeights.length; i++) {
2402
- const product = mag * scaledWeights[i];
2403
- const share = product / sumW;
2404
- base.push(share);
2405
- distributed += share;
2406
- remainders.push({ index: i, rem: product % sumW });
2407
- }
2408
- let leftover = mag - distributed;
2409
- remainders.sort((x, y) => y.rem > x.rem ? 1 : y.rem < x.rem ? -1 : x.index - y.index);
2410
- for (const { index } of remainders) {
2411
- if (leftover === 0n) break;
2412
- base[index] = base[index] + 1n;
2413
- leftover -= 1n;
2414
- }
2415
- return base.map((p) => formatScaledInt(negative && p !== 0n ? -p : p, scale));
2416
- }
2417
-
2418
- // src/via/money/branded.ts
2419
- function asMoney(value) {
2420
- if (!isMoneyLike(value)) {
2421
- throw new MoneyUnsupportedError(`asMoney: ${JSON.stringify(value)} is not a finite decimal`);
2422
- }
2423
- return String(value).trim();
2424
- }
2425
- function isMoneyString(value) {
2426
- return typeof value === "string" && isMoneyLike(value);
2427
- }
2428
- function moneyNumber(value) {
2429
- if (!isMoneyLike(value)) {
2430
- throw new MoneyUnsupportedError(`moneyNumber: ${JSON.stringify(value)} is not a finite decimal`);
2431
- }
2432
- return Number(value);
2433
- }
2434
- function isMoneyLike(value) {
2435
- if (typeof value === "number") return Number.isFinite(value);
2436
- if (typeof value !== "string") return false;
2437
- return decimalScaleOf(value) !== null;
2438
- }
2439
-
2440
- // src/via/computed/descriptor.ts
2441
- function computed(fn, opts) {
2442
- return {
2443
- _viaBrand: "computed",
2444
- fn,
2445
- ...opts?.deps !== void 0 ? { deps: opts.deps } : {},
2446
- mode: opts?.mode ?? "materialized"
2447
- };
2448
- }
2449
- function isComputedDescriptor(x) {
2450
- return typeof x === "object" && x !== null && x._viaBrand === "computed";
668
+ }
669
+ function isComputedDescriptor(x) {
670
+ return typeof x === "object" && x !== null && x._viaBrand === "computed";
2451
671
  }
2452
672
 
2453
673
  // src/via/lookup/binding.ts
@@ -2726,8 +946,62 @@ function dict(dimension, opts) {
2726
946
  ...opts?.substitute !== void 0 ? { substitute: opts.substitute } : {}
2727
947
  };
2728
948
  }
949
+
950
+ // src/with-sync/credentials.ts
951
+ function requireAdminAccess(keyring) {
952
+ if (keyring.role !== "owner" && keyring.role !== "admin") {
953
+ throw new PermissionDeniedError(
954
+ `Sync credentials require owner or admin role. Current role: "${keyring.role}"`
955
+ );
956
+ }
957
+ }
958
+ async function putCredential(adapter, vault, keyring, credential) {
959
+ requireAdminAccess(keyring);
960
+ const getDek = await ensureCollectionDEK(adapter, vault, keyring);
961
+ const dek = await getDek(SYNC_CREDENTIALS_COLLECTION);
962
+ const { iv, data } = await encrypt(JSON.stringify(credential), dek);
963
+ const existing = await adapter.get(vault, SYNC_CREDENTIALS_COLLECTION, credential.adapterId);
964
+ const version = existing ? existing._v + 1 : 1;
965
+ const envelope = {
966
+ _noydb: NOYDB_FORMAT_VERSION,
967
+ _v: version,
968
+ _ts: (/* @__PURE__ */ new Date()).toISOString(),
969
+ _iv: iv,
970
+ _data: data,
971
+ _by: keyring.userId
972
+ };
973
+ await adapter.put(
974
+ vault,
975
+ SYNC_CREDENTIALS_COLLECTION,
976
+ credential.adapterId,
977
+ envelope,
978
+ existing ? existing._v : void 0
979
+ );
980
+ }
981
+ async function getCredential(adapter, vault, keyring, adapterId) {
982
+ requireAdminAccess(keyring);
983
+ const getDek = await ensureCollectionDEK(adapter, vault, keyring);
984
+ const dek = await getDek(SYNC_CREDENTIALS_COLLECTION);
985
+ const envelope = await adapter.get(vault, SYNC_CREDENTIALS_COLLECTION, adapterId);
986
+ if (!envelope) return null;
987
+ const plaintext = await openEnvelopeJson(envelope, dek);
988
+ return JSON.parse(plaintext);
989
+ }
990
+ async function deleteCredential(adapter, vault, keyring, adapterId) {
991
+ requireAdminAccess(keyring);
992
+ await adapter.delete(vault, SYNC_CREDENTIALS_COLLECTION, adapterId);
993
+ }
994
+ async function listCredentials(adapter, vault, keyring) {
995
+ requireAdminAccess(keyring);
996
+ return adapter.list(vault, SYNC_CREDENTIALS_COLLECTION);
997
+ }
998
+ async function credentialStatus(adapter, vault, keyring, adapterId) {
999
+ const credential = await getCredential(adapter, vault, keyring, adapterId);
1000
+ if (!credential) return { exists: false };
1001
+ const expired = credential.expiresAt ? Date.now() > new Date(credential.expiresAt).getTime() : false;
1002
+ return { exists: true, expired };
1003
+ }
2729
1004
  export {
2730
- Aggregation,
2731
1005
  AlreadyElevatedError,
2732
1006
  AmendmentForbiddenError,
2733
1007
  AttestationError,
@@ -2742,6 +1016,7 @@ export {
2742
1016
  BackupCorruptedError,
2743
1017
  BackupLedgerError,
2744
1018
  BlobIntentPendingError,
1019
+ BlobOfflineError,
2745
1020
  BlobSet,
2746
1021
  BundleIntegrityError,
2747
1022
  BundleSealMismatchError,
@@ -2767,20 +1042,15 @@ export {
2767
1042
  CrossJoinTooLargeError,
2768
1043
  CustodyApi,
2769
1044
  CustodyNotEnabledError,
2770
- DEED_RECORD_ID,
2771
1045
  DEFAULT_CHUNK_SIZE,
2772
1046
  DEFAULT_COVER_SCHEMA,
2773
1047
  DEFAULT_CROSS_JOIN_MAX_ROWS,
2774
1048
  DEFAULT_FRESHNESS_MS,
2775
1049
  DEFAULT_JOIN_MAX_ROWS,
2776
- DEFAULT_PUBLIC_ENVELOPE_SCHEMA,
2777
- DELEGATIONS_COLLECTION,
2778
1050
  DICT_COLLECTION_PREFIX,
2779
1051
  DIRECTORY_RECORD_ID,
2780
1052
  DanglingReferenceError,
2781
1053
  DataResidencyError,
2782
- DebugPlaintextError,
2783
- DebugReservedFieldError,
2784
1054
  DecryptionError,
2785
1055
  DelegationTargetMissingError,
2786
1056
  DerivationCapExceededError,
@@ -2803,12 +1073,7 @@ export {
2803
1073
  FieldNotQueryableError,
2804
1074
  FilenameSanitizationError,
2805
1075
  ForgetStrategyNotConfiguredError,
2806
- GROUPBY_MAX_CARDINALITY,
2807
- GROUPBY_WARN_CARDINALITY,
2808
1076
  GroupCardinalityError,
2809
- GroupedAggregation,
2810
- GroupedQuery,
2811
- GroupedQueryN,
2812
1077
  INDEXED_STORE_POLICY,
2813
1078
  IllegalTransitionError,
2814
1079
  ImportCapabilityError,
@@ -2827,9 +1092,7 @@ export {
2827
1092
  LinkIntegrityError,
2828
1093
  LocaleNotSpecifiedError,
2829
1094
  Lru,
2830
- MAGIC_LINK_CONTENT_INFO_PREFIX,
2831
1095
  MAGIC_LINK_GRANTS_COLLECTION,
2832
- MAGIC_LINK_KEK_INFO_PREFIX,
2833
1096
  META_COLLECTION,
2834
1097
  ManagedRecoveryNotEnrolledError,
2835
1098
  MaterializedViewConfigError,
@@ -2870,8 +1133,6 @@ export {
2870
1133
  PERSONAL_POLICY,
2871
1134
  POD_STORE_POLICY,
2872
1135
  POLICY_RECORD_ID,
2873
- PUBLIC_ENVELOPE_FIELDS,
2874
- PUBLIC_ENVELOPE_RECORD_ID,
2875
1136
  PathEscapeError,
2876
1137
  PeriodClosedError,
2877
1138
  PermissionDeniedError,
@@ -2899,7 +1160,6 @@ export {
2899
1160
  ReservedVaultNameError,
2900
1161
  RestrictRefUnresolvableError,
2901
1162
  SCHEMAS_COLLECTION,
2902
- SEALED_PASSPHRASE_RECORD_ID,
2903
1163
  STATE_VAULT_NAME,
2904
1164
  STRICT_POLICY,
2905
1165
  SYNC_CREDENTIALS_COLLECTION,
@@ -2954,7 +1214,7 @@ export {
2954
1214
  VaultFrame,
2955
1215
  VaultInstant,
2956
1216
  VaultTemplateNotFoundError,
2957
- WeakPassphraseError,
1217
+ WeakSecretError,
2958
1218
  WithdrawalRequestError,
2959
1219
  activeSessionCount,
2960
1220
  additiveOnly,
@@ -2966,9 +1226,7 @@ export {
2966
1226
  applyPatch,
2967
1227
  approveWithdrawal,
2968
1228
  asMoney,
2969
- assertStrongPassphrase,
2970
- assertTierAccess,
2971
- avg,
1229
+ assertStrongSecret,
2972
1230
  base64ToBuffer,
2973
1231
  blindUpdate,
2974
1232
  bufferToBase64,
@@ -2983,7 +1241,6 @@ export {
2983
1241
  computePatch,
2984
1242
  computed,
2985
1243
  coordinatedCutover,
2986
- count,
2987
1244
  createBundleStore,
2988
1245
  createDeedOwner,
2989
1246
  createEnforcer,
@@ -2996,7 +1253,6 @@ export {
2996
1253
  decryptBytes,
2997
1254
  decryptDeterministic,
2998
1255
  decryptExtractedPartition,
2999
- dekKey,
3000
1256
  deleteCredential,
3001
1257
  deleteIntent,
3002
1258
  deleteUserEnvelope,
@@ -3016,7 +1272,6 @@ export {
3016
1272
  dictKey,
3017
1273
  diff,
3018
1274
  diffVault,
3019
- effectiveClearance,
3020
1275
  enableDevUnlock,
3021
1276
  encryptBytes,
3022
1277
  encryptDeterministic,
@@ -3040,11 +1295,9 @@ export {
3040
1295
  generateULID,
3041
1296
  getCredential,
3042
1297
  getIntent,
3043
- groupAndReduce,
3044
1298
  hasExportCapability,
3045
1299
  hasImportCapability,
3046
1300
  hasNoydbBundleMagic,
3047
- hasRecoveryEnrolled,
3048
1301
  hashEntry,
3049
1302
  i18nText,
3050
1303
  immutableGuard,
@@ -3065,16 +1318,13 @@ export {
3065
1318
  isMoneyDescriptor,
3066
1319
  isMoneyString,
3067
1320
  isPreCompressed,
3068
- isPublicEnvelope,
3069
1321
  isRefArray,
3070
1322
  isSessionAlive,
3071
1323
  isStaticDictDescriptor,
3072
1324
  isULID,
3073
1325
  isViaFieldSpec,
3074
1326
  isZodSchema,
3075
- issueDelegation,
3076
- recoverPassphrase as keyringRecoverPassphrase,
3077
- rotatePassphrase as keyringRotatePassphrase,
1327
+ rotateSecret as keyringRotateSecret,
3078
1328
  liberateVault,
3079
1329
  listCredentials,
3080
1330
  listMagicLinkGrants,
@@ -3082,41 +1332,30 @@ export {
3082
1332
  listUsers,
3083
1333
  listUsersWithEnvelopes,
3084
1334
  listWithdrawalRequests,
3085
- loadActiveDelegations,
3086
1335
  loadCover,
3087
1336
  loadDeedMarker,
3088
1337
  loadDevUnlock,
3089
1338
  loadPaperRecoveryEntries,
3090
1339
  loadPersistedSchema,
3091
- loadPublicEnvelope,
3092
- loadSealedPassphrase,
3093
- loadShamirRecoveryEntries,
3094
1340
  loadUserEnvelope,
3095
1341
  loadVaultPolicy,
3096
1342
  lockSchema,
3097
1343
  lookup,
3098
1344
  luhnCheck,
3099
1345
  magicLinkGrantRecordId,
3100
- max,
3101
1346
  memoryObjectProjection,
3102
1347
  memoryStore,
3103
1348
  mergeCrdtStates,
3104
1349
  mergePolicy,
3105
- min,
3106
1350
  mintPaperRecoveryEntry,
3107
- mintShamirRecoveryEntry,
3108
1351
  mintWrappedDeksBlob,
3109
1352
  money,
3110
- moneyMax,
3111
- moneyMin,
3112
1353
  moneyNumber,
3113
- moneySum,
3114
1354
  mulRate,
3115
1355
  paddedIndex,
3116
1356
  parseBytes,
3117
1357
  parseIndex,
3118
1358
  parseRsaOaepTlv,
3119
- parseSealedEnvelope,
3120
1359
  persistDirectoryConfig,
3121
1360
  persistSchemaIfNeeded,
3122
1361
  persistUserVisibility,
@@ -3126,34 +1365,25 @@ export {
3126
1365
  readMagicLinkGrantRecord,
3127
1366
  readNoydbBundle,
3128
1367
  readNoydbBundleHeader,
3129
- readNoydbBundlePublicEnvelope,
3130
1368
  readPath,
3131
- readPlaintextRecord,
3132
1369
  readPod,
3133
1370
  readPodCover,
3134
1371
  readPodHeader,
3135
- readPublicEnvelope,
3136
1372
  readUserVisibility,
3137
1373
  recoverUser,
3138
- reduceRecords,
3139
- reducerBuilder,
3140
1374
  ref,
3141
1375
  refArray,
3142
1376
  rejectWithdrawal,
3143
1377
  removeAuthenticator,
3144
1378
  requestWithdrawal,
3145
- resetBrotliSupportCache,
3146
- resetJoinWarnings,
3147
1379
  resolveClassifiedFields,
3148
1380
  resolveSchema as resolveCoverSchema,
3149
1381
  resolveCrdtSnapshot,
3150
1382
  resolveI18nText,
3151
1383
  resolvePolicy,
3152
- resolveSchema as resolvePublicEnvelopeSchema,
3153
1384
  resolveSequenceKey,
3154
1385
  resolveSession,
3155
1386
  revokeAllSessions,
3156
- revokeDelegation,
3157
1387
  revokeMagicLinkGrant,
3158
1388
  revokeSession,
3159
1389
  routeStore,
@@ -3161,29 +1391,23 @@ export {
3161
1391
  saveCover,
3162
1392
  savePaperRecoveryEntries,
3163
1393
  savePersistedSchema,
3164
- savePublicEnvelope,
3165
- saveSealedPassphrase,
3166
- saveShamirRecoveryEntries,
3167
1394
  saveUserEnvelope,
3168
1395
  saveVaultPolicy,
3169
1396
  scaleForCurrency,
3170
1397
  sealRsaOaepTlv,
3171
1398
  sha256Hex,
3172
1399
  staticDict,
3173
- sum,
3174
1400
  sweepBlobIntents,
3175
1401
  tokenize,
3176
1402
  transitionGuard,
3177
1403
  unwrapDeksFromBlob,
3178
1404
  unwrapDeksFromPaperEntry,
3179
- unwrapDeksFromShamirEntry,
3180
1405
  unwrapMagicLinkGrant,
3181
1406
  validateCoverInput,
3182
1407
  validateI18nTextValue,
3183
- validatePassphrase,
3184
- validatePublicEnvelopeInput,
3185
1408
  validateSchemaInput,
3186
1409
  validateSchemaOutput,
1410
+ validateSecret,
3187
1411
  validateSessionPolicy,
3188
1412
  via,
3189
1413
  visibilityRecordId,