@noy-db/hub 0.4.0-pre.0 → 0.4.0-pre.10

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