@noy-db/hub 0.2.0-pre.2 → 0.2.0-pre.21

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 (368) hide show
  1. package/README.md +126 -0
  2. package/dist/aggregate/index.cjs +643 -37
  3. package/dist/aggregate/index.cjs.map +1 -1
  4. package/dist/aggregate/index.d.cts +3 -2
  5. package/dist/aggregate/index.d.ts +3 -2
  6. package/dist/aggregate/index.js +9 -8
  7. package/dist/aggregate/index.js.map +1 -1
  8. package/dist/attestation/index.cjs.map +1 -1
  9. package/dist/attestation/index.d.cts +7 -5
  10. package/dist/attestation/index.d.ts +7 -5
  11. package/dist/attestation/index.js +6 -6
  12. package/dist/blobs/index.cjs +509 -22
  13. package/dist/blobs/index.cjs.map +1 -1
  14. package/dist/blobs/index.d.cts +9 -7
  15. package/dist/blobs/index.d.ts +9 -7
  16. package/dist/blobs/index.js +11 -6
  17. package/dist/blobs/index.js.map +1 -1
  18. package/dist/bundle/index.cjs +7886 -841
  19. package/dist/bundle/index.cjs.map +1 -1
  20. package/dist/bundle/index.d.cts +20 -18
  21. package/dist/bundle/index.d.ts +20 -18
  22. package/dist/bundle/index.js +24 -13
  23. package/dist/bundle/index.js.map +1 -1
  24. package/dist/{chunk-PFSNOPBQ.js → chunk-2XA2ZML4.js} +31 -3
  25. package/dist/chunk-2XA2ZML4.js.map +1 -0
  26. package/dist/{chunk-2PAQNPE3.js → chunk-37VGJM3T.js} +37 -2
  27. package/dist/chunk-37VGJM3T.js.map +1 -0
  28. package/dist/{chunk-7BRE6EUA.js → chunk-3HNKR65T.js} +4 -4
  29. package/dist/chunk-3HNKR65T.js.map +1 -0
  30. package/dist/{chunk-Y2RKOPNC.js → chunk-5YTXYPES.js} +46 -10
  31. package/dist/chunk-5YTXYPES.js.map +1 -0
  32. package/dist/{chunk-OVZDFEOR.js → chunk-6QAZ5O6X.js} +2 -2
  33. package/dist/chunk-6QAZ5O6X.js.map +1 -0
  34. package/dist/{chunk-RTZVQAJ7.js → chunk-6QE4DUYC.js} +19 -4
  35. package/dist/chunk-6QE4DUYC.js.map +1 -0
  36. package/dist/{chunk-7Q5PLD5C.js → chunk-7MRT7EPB.js} +3 -3
  37. package/dist/{chunk-E535SAN4.js → chunk-7PH4OPBZ.js} +4258 -520
  38. package/dist/chunk-7PH4OPBZ.js.map +1 -0
  39. package/dist/{chunk-PEULZC6M.js → chunk-A3JMGXPG.js} +8 -1
  40. package/dist/chunk-A3JMGXPG.js.map +1 -0
  41. package/dist/{chunk-UMLVJTYV.js → chunk-ADB7GPM3.js} +7 -4
  42. package/dist/chunk-ADB7GPM3.js.map +1 -0
  43. package/dist/{chunk-G6FRSBKK.js → chunk-AI4USDRI.js} +4 -4
  44. package/dist/chunk-BZW5IL43.js +151 -0
  45. package/dist/chunk-BZW5IL43.js.map +1 -0
  46. package/dist/chunk-C2RJVZZL.js +123 -0
  47. package/dist/chunk-C2RJVZZL.js.map +1 -0
  48. package/dist/{chunk-UND4XIB6.js → chunk-C6W5KVDV.js} +52 -38
  49. package/dist/chunk-C6W5KVDV.js.map +1 -0
  50. package/dist/chunk-CQYEDODS.js +125 -0
  51. package/dist/chunk-CQYEDODS.js.map +1 -0
  52. package/dist/{chunk-NWZ3I6R6.js → chunk-EYK72OTL.js} +5 -5
  53. package/dist/{chunk-7BUTTVMR.js → chunk-F5GWNSE2.js} +2 -2
  54. package/dist/{chunk-AHPFONIL.js → chunk-F5ILTHMU.js} +5 -5
  55. package/dist/{chunk-Q6W2CMEJ.js → chunk-FRRJIUSI.js} +18 -5
  56. package/dist/chunk-FRRJIUSI.js.map +1 -0
  57. package/dist/{chunk-YMYK7US4.js → chunk-GJTKMME7.js} +2 -2
  58. package/dist/chunk-GJTKMME7.js.map +1 -0
  59. package/dist/{chunk-EUYOGYGV.js → chunk-HYJMAV53.js} +6 -6
  60. package/dist/chunk-HYJMAV53.js.map +1 -0
  61. package/dist/{chunk-QPEXPHJR.js → chunk-I3IYTUUI.js} +4 -4
  62. package/dist/{chunk-3QAKZ37R.js → chunk-IVZWHIEK.js} +5 -5
  63. package/dist/{chunk-PLI5TV7N.js → chunk-IW4L4X65.js} +2 -2
  64. package/dist/chunk-IW4L4X65.js.map +1 -0
  65. package/dist/{chunk-3Z2TPHC4.js → chunk-IY24WS2P.js} +69 -5
  66. package/dist/chunk-IY24WS2P.js.map +1 -0
  67. package/dist/{chunk-HXJXPZRE.js → chunk-J6RGRZOY.js} +10 -3
  68. package/dist/chunk-J6RGRZOY.js.map +1 -0
  69. package/dist/{chunk-3S4BJX25.js → chunk-JBBWALNI.js} +2 -2
  70. package/dist/chunk-JBBWALNI.js.map +1 -0
  71. package/dist/{chunk-7Z23ZFLV.js → chunk-JDCPRJVS.js} +5 -5
  72. package/dist/chunk-JDCPRJVS.js.map +1 -0
  73. package/dist/{chunk-243PNUA6.js → chunk-JOK73NDT.js} +3 -3
  74. package/dist/chunk-JTI57WRT.js +164 -0
  75. package/dist/chunk-JTI57WRT.js.map +1 -0
  76. package/dist/{chunk-VRBCTEKQ.js → chunk-JYNH4FIM.js} +233 -11
  77. package/dist/chunk-JYNH4FIM.js.map +1 -0
  78. package/dist/{chunk-TBKOGSYR.js → chunk-KOAJ3TZM.js} +27 -5
  79. package/dist/chunk-KOAJ3TZM.js.map +1 -0
  80. package/dist/{chunk-YTXSFG3C.js → chunk-MBXKRHSS.js} +50 -20
  81. package/dist/chunk-MBXKRHSS.js.map +1 -0
  82. package/dist/{chunk-MUWOSVEP.js → chunk-NSXNXLYM.js} +10 -2
  83. package/dist/chunk-NSXNXLYM.js.map +1 -0
  84. package/dist/{chunk-J4KLMEUL.js → chunk-NV4IHBZS.js} +664 -51
  85. package/dist/chunk-NV4IHBZS.js.map +1 -0
  86. package/dist/{chunk-LRAZDV5X.js → chunk-O5XKZCUD.js} +31 -8
  87. package/dist/chunk-O5XKZCUD.js.map +1 -0
  88. package/dist/{chunk-W3XXT26A.js → chunk-OTWT6BAJ.js} +358 -3
  89. package/dist/chunk-OTWT6BAJ.js.map +1 -0
  90. package/dist/{chunk-XG3PTSCD.js → chunk-PDVP3C2I.js} +1 -1
  91. package/dist/chunk-PDVP3C2I.js.map +1 -0
  92. package/dist/{chunk-GIV6DWBG.js → chunk-S45MDEEF.js} +44 -5
  93. package/dist/chunk-S45MDEEF.js.map +1 -0
  94. package/dist/{chunk-VK5EER6C.js → chunk-SQKAECUL.js} +2 -2
  95. package/dist/{chunk-FAQVNJD4.js → chunk-SQOK5UM6.js} +12 -2
  96. package/dist/{chunk-FAQVNJD4.js.map → chunk-SQOK5UM6.js.map} +1 -1
  97. package/dist/chunk-STNPB3UM.js +9 -0
  98. package/dist/chunk-STNPB3UM.js.map +1 -0
  99. package/dist/{chunk-YS3POABP.js → chunk-TA6HPKWQ.js} +1 -1
  100. package/dist/chunk-TA6HPKWQ.js.map +1 -0
  101. package/dist/{chunk-4HIL6AHQ.js → chunk-TAMRU7A2.js} +4 -4
  102. package/dist/{chunk-QXQRKXCU.js → chunk-TGIJTNM3.js} +2 -2
  103. package/dist/chunk-TNH5SLCD.js +361 -0
  104. package/dist/chunk-TNH5SLCD.js.map +1 -0
  105. package/dist/{chunk-VPSUZLOJ.js → chunk-TYMDCIQM.js} +31 -5
  106. package/dist/chunk-TYMDCIQM.js.map +1 -0
  107. package/dist/chunk-U2XSUCDF.js +524 -0
  108. package/dist/chunk-U2XSUCDF.js.map +1 -0
  109. package/dist/{chunk-3Y53S2SA.js → chunk-UU6M64HI.js} +4 -4
  110. package/dist/{chunk-VCGTOS2A.js → chunk-WE2BUQD2.js} +3 -3
  111. package/dist/chunk-WE2BUQD2.js.map +1 -0
  112. package/dist/{chunk-JYQTXEIO.js → chunk-WWVJXBOT.js} +449 -29
  113. package/dist/chunk-WWVJXBOT.js.map +1 -0
  114. package/dist/chunk-YPIOFSN3.js +129 -0
  115. package/dist/chunk-YPIOFSN3.js.map +1 -0
  116. package/dist/chunk-ZC7J6ZYV.js +7 -0
  117. package/dist/chunk-ZC7J6ZYV.js.map +1 -0
  118. package/dist/{chunk-5ZGZ6HIZ.js → chunk-ZONKSLF2.js} +30 -7
  119. package/dist/chunk-ZONKSLF2.js.map +1 -0
  120. package/dist/consent/index.cjs.map +1 -1
  121. package/dist/consent/index.d.cts +8 -6
  122. package/dist/consent/index.d.ts +8 -6
  123. package/dist/consent/index.js +3 -3
  124. package/dist/{crypto-5ZDIY3NG.js → crypto-456N7UVX.js} +7 -3
  125. package/dist/{delegation-QYXZW25W.js → delegation-DP4COTXB.js} +5 -5
  126. package/dist/derivations/index.cjs +124 -6
  127. package/dist/derivations/index.cjs.map +1 -1
  128. package/dist/derivations/index.d.cts +11 -9
  129. package/dist/derivations/index.d.ts +11 -9
  130. package/dist/derivations/index.js +8 -6
  131. package/dist/{dev-unlock-DQCNDfFp.d.cts → dev-unlock-CY0HIZA0.d.cts} +1 -1
  132. package/dist/{dev-unlock-utkybTKb.d.ts → dev-unlock-CpKSkl2c.d.ts} +1 -1
  133. package/dist/discriminant-BN9REW3o.d.cts +60 -0
  134. package/dist/discriminant-BN9REW3o.d.ts +60 -0
  135. package/dist/errors-Dkc_fi-S.d.cts +1467 -0
  136. package/dist/errors-Dkc_fi-S.d.ts +1467 -0
  137. package/dist/executor-4IEW4KG5.js +8 -0
  138. package/dist/executor-KYJCJCIN.js +12 -0
  139. package/dist/executor-W7VIBOBZ.js +8 -0
  140. package/dist/{fanout-sidecar-VJ52RIEY.js → fanout-sidecar-YXNAEZ33.js} +2 -2
  141. package/dist/fanout-sidecar-YXNAEZ33.js.map +1 -0
  142. package/dist/forget/index.cjs +43 -0
  143. package/dist/forget/index.cjs.map +1 -0
  144. package/dist/forget/index.d.cts +1 -0
  145. package/dist/forget/index.d.ts +1 -0
  146. package/dist/forget/index.js +14 -0
  147. package/dist/guards/index.cjs +144 -4
  148. package/dist/guards/index.cjs.map +1 -1
  149. package/dist/guards/index.d.cts +16 -8
  150. package/dist/guards/index.d.ts +16 -8
  151. package/dist/guards/index.js +13 -7
  152. package/dist/{hash-jDowCrK2.d.cts → hash-BSd0-_L8.d.cts} +1 -1
  153. package/dist/{hash-DcoYWfJ_.d.ts → hash-BnBQx39y.d.ts} +1 -1
  154. package/dist/history/index.cjs +28 -5
  155. package/dist/history/index.cjs.map +1 -1
  156. package/dist/history/index.d.cts +9 -7
  157. package/dist/history/index.d.ts +9 -7
  158. package/dist/history/index.js +9 -7
  159. package/dist/history/index.js.map +1 -1
  160. package/dist/i18n/index.cjs +356 -26
  161. package/dist/i18n/index.cjs.map +1 -1
  162. package/dist/i18n/index.d.cts +8 -6
  163. package/dist/i18n/index.d.ts +8 -6
  164. package/dist/i18n/index.js +36 -15
  165. package/dist/i18n/index.js.map +1 -1
  166. package/dist/index-BMmajblo.d.cts +362 -0
  167. package/dist/index-BMmajblo.d.ts +362 -0
  168. package/dist/{index-BCKdioeh.d.ts → index-Bm9hIY7t.d.ts} +169 -1127
  169. package/dist/{index-BMjrzNZr.d.cts → index-tZqVB9g5.d.cts} +169 -1127
  170. package/dist/index.cjs +10286 -2168
  171. package/dist/index.cjs.map +1 -1
  172. package/dist/index.d.cts +258 -23
  173. package/dist/index.d.ts +258 -23
  174. package/dist/index.js +443 -110
  175. package/dist/index.js.map +1 -1
  176. package/dist/indexing/index.cjs +97 -32
  177. package/dist/indexing/index.cjs.map +1 -1
  178. package/dist/indexing/index.d.cts +3 -3
  179. package/dist/indexing/index.d.ts +3 -3
  180. package/dist/indexing/index.js +4 -4
  181. package/dist/issue-JXC6T2QR.js +12 -0
  182. package/dist/{lazy-builder-Rpd-V3jP.d.ts → lazy-builder-ChSqcF5t.d.ts} +2 -2
  183. package/dist/{lazy-builder-C-rPfWG0.d.cts → lazy-builder-eYZzLEL1.d.cts} +2 -2
  184. package/dist/{ledger-3IU5GMXA.js → ledger-I7JUYP4L.js} +6 -6
  185. package/dist/materialized-views/index.cjs +687 -13
  186. package/dist/materialized-views/index.cjs.map +1 -1
  187. package/dist/materialized-views/index.d.cts +23 -20
  188. package/dist/materialized-views/index.d.ts +23 -20
  189. package/dist/materialized-views/index.js +8 -7
  190. package/dist/mime-magic-BnJCGJzB.d.cts +103 -0
  191. package/dist/mime-magic-CjSyakO4.d.ts +103 -0
  192. package/dist/noydb-ZZCRF6TE.js +38 -0
  193. package/dist/overlay-views/index.cjs +58 -18
  194. package/dist/overlay-views/index.cjs.map +1 -1
  195. package/dist/overlay-views/index.d.cts +32 -12
  196. package/dist/overlay-views/index.d.ts +32 -12
  197. package/dist/overlay-views/index.js +6 -6
  198. package/dist/periods/index.cjs.map +1 -1
  199. package/dist/periods/index.d.cts +8 -6
  200. package/dist/periods/index.d.ts +8 -6
  201. package/dist/periods/index.js +6 -6
  202. package/dist/{predicate-Dnu81tsS.d.cts → predicate-BmhBSPCH.d.cts} +87 -5
  203. package/dist/{predicate-Dnu81tsS.d.ts → predicate-BmhBSPCH.d.ts} +87 -5
  204. package/dist/{public-envelope-U3CMEOMV.js → public-envelope-5XRTUNKF.js} +4 -4
  205. package/dist/query/index.cjs +1438 -130
  206. package/dist/query/index.cjs.map +1 -1
  207. package/dist/query/index.d.cts +4 -3
  208. package/dist/query/index.d.ts +4 -3
  209. package/dist/query/index.js +13 -6
  210. package/dist/read-only-facade-EX6WZZBP.js +7 -0
  211. package/dist/registry-ATRHOG5B.js +8 -0
  212. package/dist/registry-DKEXOJVO.js +7 -0
  213. package/dist/registry-LEHB26TY.js +8 -0
  214. package/dist/{registry-3ALP62P6.js → registry-NWHOLD5M.js} +3 -3
  215. package/dist/{revoke-KY2GB4KP.js → revoke-5IEK22KT.js} +6 -6
  216. package/dist/sealed-record/index.cjs +139 -0
  217. package/dist/sealed-record/index.cjs.map +1 -0
  218. package/dist/sealed-record/index.d.cts +123 -0
  219. package/dist/sealed-record/index.d.ts +123 -0
  220. package/dist/sealed-record/index.js +42 -0
  221. package/dist/sealed-record/index.js.map +1 -0
  222. package/dist/session/index.cjs.map +1 -1
  223. package/dist/session/index.d.cts +9 -7
  224. package/dist/session/index.d.ts +9 -7
  225. package/dist/session/index.js +3 -3
  226. package/dist/shadow/index.cjs.map +1 -1
  227. package/dist/shadow/index.d.cts +8 -6
  228. package/dist/shadow/index.d.ts +8 -6
  229. package/dist/shadow/index.js +2 -2
  230. package/dist/{signer-GRI5TZKH.js → signer-I6YARZQA.js} +5 -5
  231. package/dist/snapshots/index.cjs +937 -0
  232. package/dist/snapshots/index.cjs.map +1 -0
  233. package/dist/snapshots/index.d.cts +30 -0
  234. package/dist/snapshots/index.d.ts +30 -0
  235. package/dist/snapshots/index.js +152 -0
  236. package/dist/snapshots/index.js.map +1 -0
  237. package/dist/{stale-OTOF3FH7.js → stale-CPESGAPL.js} +2 -2
  238. package/dist/stale-CPESGAPL.js.map +1 -0
  239. package/dist/state-vault-JR3CFGNP.js +14 -0
  240. package/dist/state-vault-JR3CFGNP.js.map +1 -0
  241. package/dist/store/index.cjs +8 -0
  242. package/dist/store/index.cjs.map +1 -1
  243. package/dist/store/index.d.cts +15 -6
  244. package/dist/store/index.d.ts +15 -6
  245. package/dist/store/index.js +2 -2
  246. package/dist/{strategy-DSTrsZ8t.d.ts → strategy-54eIwox5.d.ts} +456 -7
  247. package/dist/{strategy-DSTrsZ8t.d.cts → strategy-WtB-jXYv.d.cts} +456 -7
  248. package/dist/sync/index.cjs.map +1 -1
  249. package/dist/sync/index.d.cts +7 -5
  250. package/dist/sync/index.d.ts +7 -5
  251. package/dist/sync/index.js +4 -4
  252. package/dist/team/index.cjs +1 -1
  253. package/dist/team/index.cjs.map +1 -1
  254. package/dist/team/index.d.cts +8 -6
  255. package/dist/team/index.d.ts +8 -6
  256. package/dist/team/index.js +8 -8
  257. package/dist/transition-guard-D4bfIAiW.d.ts +165 -0
  258. package/dist/transition-guard-Dmpqzg-_.d.cts +165 -0
  259. package/dist/tx/index.cjs +155 -5
  260. package/dist/tx/index.cjs.map +1 -1
  261. package/dist/tx/index.d.cts +27 -9
  262. package/dist/tx/index.d.ts +27 -9
  263. package/dist/tx/index.js +61 -4
  264. package/dist/tx/index.js.map +1 -1
  265. package/dist/{types-BoFFiskX.d.ts → types-DLfWFr6U.d.ts} +3997 -1262
  266. package/dist/{types-DJG8HG6F.d.cts → types-DyOI6XZ_.d.cts} +3997 -1262
  267. package/dist/{ulid-BmBgooGm.d.ts → ulid-B2L_aqVA.d.ts} +19 -19
  268. package/dist/{ulid-C7ms9oli.d.cts → ulid-LaxfH2tK.d.cts} +19 -19
  269. package/dist/util/index.cjs +7 -0
  270. package/dist/util/index.cjs.map +1 -1
  271. package/dist/util/index.d.cts +2 -0
  272. package/dist/util/index.d.ts +2 -0
  273. package/dist/util/index.js +5 -1
  274. package/dist/util/index.js.map +1 -1
  275. package/dist/vault-group-BB246VIM.js +804 -0
  276. package/dist/vault-group-BB246VIM.js.map +1 -0
  277. package/dist/{with-materialized-view-CqnRwI2S.d.ts → with-materialized-view-CeZYGJVf.d.cts} +2 -2
  278. package/dist/{with-materialized-view-BbEPFIIJ.d.cts → with-materialized-view-DNULSxoP.d.ts} +2 -2
  279. package/dist/{with-overlayed-view-Ct1fSJt-.d.ts → with-overlayed-view-C9joG7UZ.d.ts} +2 -2
  280. package/dist/{with-overlayed-view-bwlmmFjx.d.cts → with-overlayed-view-kdcPGHih.d.cts} +2 -2
  281. package/dist/with-rollup-DJDbrxjf.d.ts +47 -0
  282. package/dist/with-rollup-s58XAeWO.d.cts +47 -0
  283. package/package.json +35 -4
  284. package/dist/chunk-2PAQNPE3.js.map +0 -1
  285. package/dist/chunk-3S4BJX25.js.map +0 -1
  286. package/dist/chunk-3XHOCQK4.js +0 -118
  287. package/dist/chunk-3XHOCQK4.js.map +0 -1
  288. package/dist/chunk-3Z2TPHC4.js.map +0 -1
  289. package/dist/chunk-5ZGZ6HIZ.js.map +0 -1
  290. package/dist/chunk-7BRE6EUA.js.map +0 -1
  291. package/dist/chunk-7Z23ZFLV.js.map +0 -1
  292. package/dist/chunk-CXSCDO5T.js +0 -51
  293. package/dist/chunk-CXSCDO5T.js.map +0 -1
  294. package/dist/chunk-E535SAN4.js.map +0 -1
  295. package/dist/chunk-EUYOGYGV.js.map +0 -1
  296. package/dist/chunk-GIV6DWBG.js.map +0 -1
  297. package/dist/chunk-HXJXPZRE.js.map +0 -1
  298. package/dist/chunk-J4KLMEUL.js.map +0 -1
  299. package/dist/chunk-JYQTXEIO.js.map +0 -1
  300. package/dist/chunk-LRAZDV5X.js.map +0 -1
  301. package/dist/chunk-MRIBLZL3.js +0 -86
  302. package/dist/chunk-MRIBLZL3.js.map +0 -1
  303. package/dist/chunk-MUWOSVEP.js.map +0 -1
  304. package/dist/chunk-OVZDFEOR.js.map +0 -1
  305. package/dist/chunk-PEULZC6M.js.map +0 -1
  306. package/dist/chunk-PFSNOPBQ.js.map +0 -1
  307. package/dist/chunk-PLI5TV7N.js.map +0 -1
  308. package/dist/chunk-Q6W2CMEJ.js.map +0 -1
  309. package/dist/chunk-RTZVQAJ7.js.map +0 -1
  310. package/dist/chunk-TBKOGSYR.js.map +0 -1
  311. package/dist/chunk-UMLVJTYV.js.map +0 -1
  312. package/dist/chunk-UND4XIB6.js.map +0 -1
  313. package/dist/chunk-VCGTOS2A.js.map +0 -1
  314. package/dist/chunk-VE6YVP32.js +0 -19
  315. package/dist/chunk-VE6YVP32.js.map +0 -1
  316. package/dist/chunk-VPSUZLOJ.js.map +0 -1
  317. package/dist/chunk-VRBCTEKQ.js.map +0 -1
  318. package/dist/chunk-W3XXT26A.js.map +0 -1
  319. package/dist/chunk-XG3PTSCD.js.map +0 -1
  320. package/dist/chunk-Y2RKOPNC.js.map +0 -1
  321. package/dist/chunk-YMYK7US4.js.map +0 -1
  322. package/dist/chunk-YS3POABP.js.map +0 -1
  323. package/dist/chunk-YTXSFG3C.js.map +0 -1
  324. package/dist/executor-AS2IDHKZ.js +0 -11
  325. package/dist/executor-HLXFXNFM.js +0 -8
  326. package/dist/executor-HN6YBHZ5.js +0 -8
  327. package/dist/fanout-sidecar-VJ52RIEY.js.map +0 -1
  328. package/dist/issue-ORP37MVW.js +0 -12
  329. package/dist/mime-magic-CBBSOkjm.d.cts +0 -50
  330. package/dist/mime-magic-CBBSOkjm.d.ts +0 -50
  331. package/dist/noydb-5H3C24GG.js +0 -34
  332. package/dist/read-only-facade-ITU6L7BL.js +0 -7
  333. package/dist/registry-7HE6VJGC.js +0 -8
  334. package/dist/registry-PSIPG2QR.js +0 -8
  335. package/dist/registry-RFGGMVNJ.js +0 -7
  336. package/dist/with-derivation-BKXXa8Vt.d.ts +0 -13
  337. package/dist/with-derivation-BjQ7q4NE.d.cts +0 -13
  338. package/dist/with-guard-C25yNjzd.d.ts +0 -18
  339. package/dist/with-guard-DQme5DKE.d.cts +0 -18
  340. /package/dist/{chunk-7Q5PLD5C.js.map → chunk-7MRT7EPB.js.map} +0 -0
  341. /package/dist/{chunk-G6FRSBKK.js.map → chunk-AI4USDRI.js.map} +0 -0
  342. /package/dist/{chunk-NWZ3I6R6.js.map → chunk-EYK72OTL.js.map} +0 -0
  343. /package/dist/{chunk-7BUTTVMR.js.map → chunk-F5GWNSE2.js.map} +0 -0
  344. /package/dist/{chunk-AHPFONIL.js.map → chunk-F5ILTHMU.js.map} +0 -0
  345. /package/dist/{chunk-QPEXPHJR.js.map → chunk-I3IYTUUI.js.map} +0 -0
  346. /package/dist/{chunk-3QAKZ37R.js.map → chunk-IVZWHIEK.js.map} +0 -0
  347. /package/dist/{chunk-243PNUA6.js.map → chunk-JOK73NDT.js.map} +0 -0
  348. /package/dist/{chunk-VK5EER6C.js.map → chunk-SQKAECUL.js.map} +0 -0
  349. /package/dist/{chunk-4HIL6AHQ.js.map → chunk-TAMRU7A2.js.map} +0 -0
  350. /package/dist/{chunk-QXQRKXCU.js.map → chunk-TGIJTNM3.js.map} +0 -0
  351. /package/dist/{chunk-3Y53S2SA.js.map → chunk-UU6M64HI.js.map} +0 -0
  352. /package/dist/{crypto-5ZDIY3NG.js.map → crypto-456N7UVX.js.map} +0 -0
  353. /package/dist/{delegation-QYXZW25W.js.map → delegation-DP4COTXB.js.map} +0 -0
  354. /package/dist/{executor-AS2IDHKZ.js.map → executor-4IEW4KG5.js.map} +0 -0
  355. /package/dist/{executor-HLXFXNFM.js.map → executor-KYJCJCIN.js.map} +0 -0
  356. /package/dist/{executor-HN6YBHZ5.js.map → executor-W7VIBOBZ.js.map} +0 -0
  357. /package/dist/{issue-ORP37MVW.js.map → forget/index.js.map} +0 -0
  358. /package/dist/{ledger-3IU5GMXA.js.map → issue-JXC6T2QR.js.map} +0 -0
  359. /package/dist/{noydb-5H3C24GG.js.map → ledger-I7JUYP4L.js.map} +0 -0
  360. /package/dist/{public-envelope-U3CMEOMV.js.map → noydb-ZZCRF6TE.js.map} +0 -0
  361. /package/dist/{read-only-facade-ITU6L7BL.js.map → public-envelope-5XRTUNKF.js.map} +0 -0
  362. /package/dist/{registry-3ALP62P6.js.map → read-only-facade-EX6WZZBP.js.map} +0 -0
  363. /package/dist/{registry-7HE6VJGC.js.map → registry-ATRHOG5B.js.map} +0 -0
  364. /package/dist/{registry-PSIPG2QR.js.map → registry-DKEXOJVO.js.map} +0 -0
  365. /package/dist/{registry-RFGGMVNJ.js.map → registry-LEHB26TY.js.map} +0 -0
  366. /package/dist/{revoke-KY2GB4KP.js.map → registry-NWHOLD5M.js.map} +0 -0
  367. /package/dist/{signer-GRI5TZKH.js.map → revoke-5IEK22KT.js.map} +0 -0
  368. /package/dist/{stale-OTOF3FH7.js.map → signer-I6YARZQA.js.map} +0 -0
@@ -162,31 +162,156 @@ function buildLiveAggregation(recompute, upstreams) {
162
162
  return new LiveAggregationImpl(recompute, upstreams);
163
163
  }
164
164
 
165
- // src/query/predicate.ts
166
- function readPath(record, path) {
167
- if (record === null || record === void 0) return void 0;
168
- if (!path.includes(".")) {
169
- return record[path];
165
+ // src/money/fixed-point.ts
166
+ function expandExponent(s) {
167
+ const m = /^([+-]?)(\d+)(?:\.(\d+))?[eE]([+-]?\d+)$/.exec(s);
168
+ if (!m) return s;
169
+ const sign = m[1] === "-" ? "-" : "";
170
+ const intp = m[2];
171
+ const frac = m[3] ?? "";
172
+ const exp = Number(m[4]);
173
+ const digits = intp + frac;
174
+ const pointPos = intp.length + exp;
175
+ let body;
176
+ if (pointPos <= 0) {
177
+ body = "0." + "0".repeat(-pointPos) + digits;
178
+ } else if (pointPos >= digits.length) {
179
+ body = digits + "0".repeat(pointPos - digits.length);
180
+ } else {
181
+ body = digits.slice(0, pointPos) + "." + digits.slice(pointPos);
170
182
  }
171
- const segments = path.split(".");
172
- let cursor = record;
173
- for (const segment of segments) {
174
- if (cursor === null || cursor === void 0) return void 0;
175
- cursor = cursor[segment];
183
+ return sign + body;
184
+ }
185
+ function toCanonicalDecimalString(input) {
186
+ let s;
187
+ if (typeof input === "number") {
188
+ if (!Number.isFinite(input)) return null;
189
+ s = String(input);
190
+ } else {
191
+ s = input.trim();
176
192
  }
177
- return cursor;
193
+ s = expandExponent(s);
194
+ if (s.startsWith("+")) s = s.slice(1);
195
+ if (!/^-?(\d+(\.\d*)?|\.\d+)$/.test(s)) return null;
196
+ return s;
178
197
  }
179
-
180
- // src/aggregate/canonical-key.ts
181
- function canonicalGroupKey(fields, row) {
182
- const sorted = [...fields].sort();
183
- const parts = [];
184
- for (const name of sorted) {
185
- const v = row[name];
186
- const serialised = v === void 0 ? "undefined" : JSON.stringify(v);
187
- parts.push(`${name}=${serialised}`);
198
+ function shouldRoundUp(negative, lastKeptDigit, firstDiscarded, hasMoreNonZeroAfterFirst, mode) {
199
+ switch (mode) {
200
+ case "up":
201
+ return true;
202
+ case "down":
203
+ return false;
204
+ case "ceil":
205
+ return !negative;
206
+ case "floor":
207
+ return negative;
208
+ case "half-up":
209
+ return firstDiscarded >= 5;
210
+ case "half-down":
211
+ return firstDiscarded > 5 || firstDiscarded === 5 && hasMoreNonZeroAfterFirst;
212
+ case "half-even":
213
+ if (firstDiscarded > 5) return true;
214
+ if (firstDiscarded < 5) return false;
215
+ return hasMoreNonZeroAfterFirst || lastKeptDigit % 2 === 1;
188
216
  }
189
- return parts.join("|");
217
+ }
218
+ function parseToScaledInt(input, scale, rounding) {
219
+ const canonical = toCanonicalDecimalString(input);
220
+ if (canonical === null) return { ok: false, reason: "nonfinite" };
221
+ const negative = canonical.startsWith("-");
222
+ const unsigned = negative ? canonical.slice(1) : canonical;
223
+ const dot = unsigned.indexOf(".");
224
+ const intPart = dot === -1 ? unsigned : unsigned.slice(0, dot);
225
+ const fracPart = dot === -1 ? "" : unsigned.slice(dot + 1);
226
+ const intDigits = intPart === "" ? "0" : intPart;
227
+ if (fracPart.length <= scale) {
228
+ const keep2 = fracPart.padEnd(scale, "0");
229
+ const magnitude2 = BigInt(intDigits + keep2);
230
+ return { ok: true, value: negative && magnitude2 !== 0n ? -magnitude2 : magnitude2 };
231
+ }
232
+ const keep = fracPart.slice(0, scale);
233
+ const tail = fracPart.slice(scale);
234
+ const magnitudeDigits = intDigits + keep;
235
+ let magnitude = BigInt(magnitudeDigits);
236
+ if (/^0+$/.test(tail)) {
237
+ return { ok: true, value: negative && magnitude !== 0n ? -magnitude : magnitude };
238
+ }
239
+ if (rounding === void 0) return { ok: false, reason: "precision" };
240
+ const lastKeptDigit = Number(magnitudeDigits[magnitudeDigits.length - 1]);
241
+ const firstDiscarded = Number(tail[0]);
242
+ const hasMoreNonZeroAfterFirst = /[1-9]/.test(tail.slice(1));
243
+ if (shouldRoundUp(negative, lastKeptDigit, firstDiscarded, hasMoreNonZeroAfterFirst, rounding)) {
244
+ magnitude += 1n;
245
+ }
246
+ return { ok: true, value: negative && magnitude !== 0n ? -magnitude : magnitude };
247
+ }
248
+ function formatScaledInt(value, scale) {
249
+ const negative = value < 0n;
250
+ const abs = (negative ? -value : value).toString();
251
+ if (scale === 0) return (negative ? "-" : "") + abs;
252
+ const padded = abs.padStart(scale + 1, "0");
253
+ const cut = padded.length - scale;
254
+ const intPart = padded.slice(0, cut);
255
+ const fracPart = padded.slice(cut);
256
+ return (negative ? "-" : "") + intPart + "." + fracPart;
257
+ }
258
+
259
+ // src/money/iso4217.ts
260
+ var MINOR_UNITS = {
261
+ // 2-decimal majors
262
+ EUR: 2,
263
+ USD: 2,
264
+ GBP: 2,
265
+ CHF: 2,
266
+ CAD: 2,
267
+ AUD: 2,
268
+ NZD: 2,
269
+ SGD: 2,
270
+ HKD: 2,
271
+ CNY: 2,
272
+ INR: 2,
273
+ BRL: 2,
274
+ MXN: 2,
275
+ ZAR: 2,
276
+ RUB: 2,
277
+ TRY: 2,
278
+ PLN: 2,
279
+ SEK: 2,
280
+ NOK: 2,
281
+ DKK: 2,
282
+ CZK: 2,
283
+ HUF: 2,
284
+ RON: 2,
285
+ ILS: 2,
286
+ THB: 2,
287
+ PHP: 2,
288
+ MYR: 2,
289
+ IDR: 2,
290
+ AED: 2,
291
+ SAR: 2,
292
+ QAR: 2,
293
+ EGP: 2,
294
+ // 0-decimal
295
+ JPY: 0,
296
+ KRW: 0,
297
+ ISK: 0,
298
+ CLP: 0,
299
+ VND: 0,
300
+ XOF: 0,
301
+ XAF: 0,
302
+ PYG: 0,
303
+ // 3-decimal
304
+ BHD: 3,
305
+ KWD: 3,
306
+ OMR: 3,
307
+ TND: 3,
308
+ JOD: 3,
309
+ IQD: 3,
310
+ LYD: 3
311
+ };
312
+ function scaleForCurrency(code) {
313
+ const v = MINOR_UNITS[code];
314
+ return v === void 0 ? null : v;
190
315
  }
191
316
 
192
317
  // src/errors.ts
@@ -217,6 +342,435 @@ var GroupCardinalityError = class extends NoydbError {
217
342
  this.maxGroups = maxGroups;
218
343
  }
219
344
  };
345
+ var LocaleNotSpecifiedError = class extends NoydbError {
346
+ /** The field name that required a locale. */
347
+ field;
348
+ constructor(field, message) {
349
+ super(
350
+ "LOCALE_NOT_SPECIFIED",
351
+ message ?? `Cannot read i18nText field "${field}" without a locale. Pass { locale } to get()/list()/query() or set a default via openVault(name, { locale }).`
352
+ );
353
+ this.name = "LocaleNotSpecifiedError";
354
+ this.field = field;
355
+ }
356
+ };
357
+
358
+ // src/money/descriptor.ts
359
+ var MoneyUnsupportedError = class extends NoydbError {
360
+ constructor(field, message) {
361
+ super(
362
+ "MONEY_UNSUPPORTED",
363
+ message ?? `money: operation is not supported on field "${field}" \u2014 use sum() and count() and divide at the boundary`
364
+ );
365
+ this.field = field;
366
+ this.name = "MoneyUnsupportedError";
367
+ }
368
+ field;
369
+ };
370
+
371
+ // src/query/predicate.ts
372
+ function readPath(record, path) {
373
+ if (record === null || record === void 0) return void 0;
374
+ if (!path.includes(".")) {
375
+ return record[path];
376
+ }
377
+ const segments = path.split(".");
378
+ let cursor = record;
379
+ for (const segment of segments) {
380
+ if (cursor === null || cursor === void 0) return void 0;
381
+ cursor = cursor[segment];
382
+ }
383
+ return cursor;
384
+ }
385
+
386
+ // src/aggregate/canonical-key.ts
387
+ function canonicalGroupKey(fields, row) {
388
+ const sorted = [...fields].sort();
389
+ const parts = [];
390
+ for (const name of sorted) {
391
+ const v = row[name];
392
+ const serialised = v === void 0 ? "undefined" : JSON.stringify(v);
393
+ parts.push(`${name}=${serialised}`);
394
+ }
395
+ return parts.join("|");
396
+ }
397
+
398
+ // src/money/money-reducer.ts
399
+ function toScaledIntFromAny(v, scale) {
400
+ if (typeof v === "bigint") return v;
401
+ if (typeof v === "number") {
402
+ const r = parseToScaledInt(v, scale);
403
+ return r.ok ? r.value : null;
404
+ }
405
+ if (typeof v === "string") {
406
+ if (!v.includes(".")) {
407
+ try {
408
+ return BigInt(v);
409
+ } catch {
410
+ return null;
411
+ }
412
+ }
413
+ const r = parseToScaledInt(v, scale);
414
+ return r.ok ? r.value : null;
415
+ }
416
+ return null;
417
+ }
418
+ function readMoney(record, field, desc) {
419
+ const raw = readPath(record, field);
420
+ if (raw === null || raw === void 0) return null;
421
+ if (desc.mode === "fixed") {
422
+ const cur = desc.fixedCurrency;
423
+ const value2 = toScaledIntFromAny(raw, desc.scaleFor(cur));
424
+ return value2 === null ? null : { currency: cur, value: value2 };
425
+ }
426
+ if (typeof raw !== "object") return null;
427
+ const o = raw;
428
+ if (typeof o.currency !== "string") return null;
429
+ const scale = desc.allows(o.currency) ? desc.scaleFor(o.currency) : 0;
430
+ const value = toScaledIntFromAny(o.amount, scale);
431
+ return value === null ? null : { currency: o.currency, value };
432
+ }
433
+ function targetScaleFor(desc, currency) {
434
+ if (desc.allows(currency)) return desc.scaleFor(currency);
435
+ const s = scaleForCurrency(currency);
436
+ if (s === null) {
437
+ throw new Error(`money: cannot determine scale for conversion target "${currency}"`);
438
+ }
439
+ return s;
440
+ }
441
+ function parseRate(rate) {
442
+ const s = String(rate).trim();
443
+ const neg = s.startsWith("-");
444
+ const body = neg ? s.slice(1) : s;
445
+ const dot = body.indexOf(".");
446
+ const intPart = dot === -1 ? body : body.slice(0, dot);
447
+ const fracPart = dot === -1 ? "" : body.slice(dot + 1);
448
+ const int = BigInt((intPart === "" ? "0" : intPart) + fracPart);
449
+ return { int: neg ? -int : int, scale: fracPart.length };
450
+ }
451
+ function divRoundHalfEven(n, d) {
452
+ const q = n / d;
453
+ const r = n % d;
454
+ const twiceR = (r < 0n ? -r : r) * 2n;
455
+ if (twiceR < d) return q;
456
+ if (twiceR > d) return q + (n < 0n ? -1n : 1n);
457
+ return q % 2n === 0n ? q : q + (n < 0n ? -1n : 1n);
458
+ }
459
+ function convertScaled(value, srcScale, rate, targetScale) {
460
+ const { int: rateInt, scale: rateScale } = parseRate(rate);
461
+ const product = value * rateInt;
462
+ const curScale = srcScale + rateScale;
463
+ if (curScale === targetScale) return product;
464
+ if (curScale < targetScale) return product * 10n ** BigInt(targetScale - curScale);
465
+ return divRoundHalfEven(product, 10n ** BigInt(curScale - targetScale));
466
+ }
467
+ function finalizeSum(state, desc, convertTo, fx) {
468
+ if (convertTo !== void 0) {
469
+ if (fx === void 0) {
470
+ throw new Error(`money: sum convertTo "${convertTo}" requires an fx rate map`);
471
+ }
472
+ const targetScale = targetScaleFor(desc, convertTo);
473
+ let total = 0n;
474
+ for (const [cur, v] of state) {
475
+ if (cur === convertTo) {
476
+ total += convertScaled(v, desc.scaleFor(cur), 1, targetScale);
477
+ continue;
478
+ }
479
+ const rate = fx[`${cur}->${convertTo}`];
480
+ if (rate === void 0) {
481
+ throw new Error(`money: no fx rate for "${cur}->${convertTo}"`);
482
+ }
483
+ total += convertScaled(v, desc.scaleFor(cur), rate, targetScale);
484
+ }
485
+ return formatScaledInt(total, targetScale);
486
+ }
487
+ if (desc.mode === "fixed") {
488
+ const cur = desc.fixedCurrency;
489
+ return formatScaledInt(state.get(cur) ?? 0n, desc.scaleFor(cur));
490
+ }
491
+ const out = {};
492
+ for (const [cur, v] of state) out[cur] = formatScaledInt(v, desc.scaleFor(cur));
493
+ return out;
494
+ }
495
+ function moneySumReducer(field, desc, convertTo, fx) {
496
+ return {
497
+ op: "sum",
498
+ field,
499
+ init: () => /* @__PURE__ */ new Map(),
500
+ step: (state, record) => {
501
+ const m = readMoney(record, field, desc);
502
+ if (m) state.set(m.currency, (state.get(m.currency) ?? 0n) + m.value);
503
+ return state;
504
+ },
505
+ remove: (state, record) => {
506
+ const m = readMoney(record, field, desc);
507
+ if (m) state.set(m.currency, (state.get(m.currency) ?? 0n) - m.value);
508
+ return state;
509
+ },
510
+ finalize: (state) => finalizeSum(state, desc, convertTo, fx)
511
+ };
512
+ }
513
+ function extremum(values, op) {
514
+ let out = values[0];
515
+ for (let i = 1; i < values.length; i++) {
516
+ const v = values[i];
517
+ if (op === "min" ? v < out : v > out) out = v;
518
+ }
519
+ return out;
520
+ }
521
+ function moneyMinMaxReducer(op, field, desc) {
522
+ return {
523
+ op,
524
+ field,
525
+ init: () => /* @__PURE__ */ new Map(),
526
+ step: (state, record) => {
527
+ const m = readMoney(record, field, desc);
528
+ if (m) {
529
+ const arr = state.get(m.currency);
530
+ if (arr) arr.push(m.value);
531
+ else state.set(m.currency, [m.value]);
532
+ }
533
+ return state;
534
+ },
535
+ remove: (state, record) => {
536
+ const m = readMoney(record, field, desc);
537
+ if (m) {
538
+ const arr = state.get(m.currency);
539
+ if (arr) {
540
+ const idx = arr.indexOf(m.value);
541
+ if (idx >= 0) arr.splice(idx, 1);
542
+ }
543
+ }
544
+ return state;
545
+ },
546
+ finalize: (state) => {
547
+ if (desc.mode === "fixed") {
548
+ const cur = desc.fixedCurrency;
549
+ const arr = state.get(cur);
550
+ if (!arr || arr.length === 0) return null;
551
+ return formatScaledInt(extremum(arr, op), desc.scaleFor(cur));
552
+ }
553
+ const out = {};
554
+ for (const [cur, arr] of state) {
555
+ if (arr.length > 0) out[cur] = formatScaledInt(extremum(arr, op), desc.scaleFor(cur));
556
+ }
557
+ return out;
558
+ }
559
+ };
560
+ }
561
+ function wrapMoneyReducers(spec, moneyFields) {
562
+ let changed = false;
563
+ const out = {};
564
+ for (const [key, reducer] of Object.entries(spec)) {
565
+ const field = reducer.field;
566
+ const desc = field ? moneyFields[field] : void 0;
567
+ if (desc && reducer.op === "avg") {
568
+ throw new MoneyUnsupportedError(
569
+ field,
570
+ `avg() is not supported on money field "${field}" in v1 \u2014 use sum() and count() and divide at the boundary.`
571
+ );
572
+ }
573
+ if (desc && (reducer.op === "sum" || reducer.op === "min" || reducer.op === "max")) {
574
+ changed = true;
575
+ out[key] = reducer.op === "sum" ? moneySumReducer(field, desc, reducer.convertTo, reducer.fx) : moneyMinMaxReducer(reducer.op, field, desc);
576
+ } else {
577
+ out[key] = reducer;
578
+ }
579
+ }
580
+ return changed ? out : spec;
581
+ }
582
+
583
+ // src/i18n/policy.ts
584
+ function resolvePolicy(onMissing, layer) {
585
+ const explicit = onMissing && typeof onMissing === "object" ? onMissing[layer] : void 0;
586
+ const scalar = typeof onMissing === "string" ? onMissing : void 0;
587
+ const layerDefault = layer === "guard" ? "substitute" : void 0;
588
+ return explicit ?? layerDefault ?? scalar ?? "throw";
589
+ }
590
+
591
+ // src/i18n/script.ts
592
+ var LATIN_BASE = /* @__PURE__ */ new Set([
593
+ "en",
594
+ "fr",
595
+ "de",
596
+ "es",
597
+ "it",
598
+ "pt",
599
+ "nl",
600
+ "sv",
601
+ "no",
602
+ "da",
603
+ "fi",
604
+ "is",
605
+ "pl",
606
+ "cs",
607
+ "sk",
608
+ "hu",
609
+ "ro",
610
+ "hr",
611
+ "sl",
612
+ "et",
613
+ "lv",
614
+ "lt",
615
+ "tr",
616
+ "vi",
617
+ "id",
618
+ "ms",
619
+ "tl",
620
+ "sw",
621
+ "af",
622
+ "ca",
623
+ "gl",
624
+ "eu",
625
+ "cy",
626
+ "ga"
627
+ ]);
628
+ var SCRIPT_TABLE = {
629
+ th: ["Thai"],
630
+ ko: ["Hangul", "Han"],
631
+ ja: ["Han", "Hiragana", "Katakana"],
632
+ zh: ["Han"],
633
+ ar: ["Arabic"],
634
+ fa: ["Arabic"],
635
+ ur: ["Arabic"],
636
+ ru: ["Cyrillic"],
637
+ uk: ["Cyrillic"],
638
+ bg: ["Cyrillic"],
639
+ sr: ["Cyrillic"],
640
+ he: ["Hebrew"],
641
+ el: ["Greek"],
642
+ hi: ["Devanagari"],
643
+ ta: ["Tamil"],
644
+ km: ["Khmer"],
645
+ lo: ["Lao"],
646
+ my: ["Myanmar"]
647
+ };
648
+ var SUBTAG_SCRIPTS = {
649
+ Latn: ["Latin"],
650
+ Cyrl: ["Cyrillic", "Latin"],
651
+ Hans: ["Han", "Latin"],
652
+ Hant: ["Han", "Latin"],
653
+ Thai: ["Thai", "Latin"],
654
+ Arab: ["Arabic", "Latin"]
655
+ };
656
+ function inferScripts(locale) {
657
+ const parts = locale.split("-");
658
+ const subtag = parts.find((t) => /^[A-Z][a-z]{3}$/.test(t));
659
+ if (subtag && SUBTAG_SCRIPTS[subtag]) return SUBTAG_SCRIPTS[subtag];
660
+ const base = (parts[0] ?? "").toLowerCase();
661
+ if (LATIN_BASE.has(base)) return ["Latin"];
662
+ const primary = SCRIPT_TABLE[base];
663
+ if (primary) return [...primary, "Latin"];
664
+ return ["Latin"];
665
+ }
666
+ var BASELINE = String.raw`\p{White_Space}\p{Script=Common}\p{Script=Inherited}\p{Mark}`;
667
+
668
+ // src/i18n/core.ts
669
+ function toChain(fallback) {
670
+ return Array.isArray(fallback) ? fallback : fallback ? [fallback] : [];
671
+ }
672
+ function pickFromChain(value, chain) {
673
+ for (const fb of chain) {
674
+ if (fb === "any") {
675
+ const any = Object.values(value).find((v) => v !== "");
676
+ if (any !== void 0) return any;
677
+ } else if (value[fb] !== void 0 && value[fb] !== "") {
678
+ return value[fb];
679
+ }
680
+ }
681
+ return void 0;
682
+ }
683
+ function resolveI18nText(value, locale, fallback, field, opts) {
684
+ if (locale === "raw") {
685
+ return value;
686
+ }
687
+ if (!locale) {
688
+ throw new LocaleNotSpecifiedError(field ?? "<unknown>");
689
+ }
690
+ if (value[locale] !== void 0 && value[locale] !== "") {
691
+ return value[locale];
692
+ }
693
+ const policy = opts?.policy ?? "throw";
694
+ const callerChain = toChain(fallback);
695
+ const callerHit = pickFromChain(value, callerChain);
696
+ if (callerHit !== void 0) return callerHit;
697
+ if (policy === "substitute") {
698
+ const subHit = pickFromChain(value, toChain(opts?.substitute));
699
+ if (subHit !== void 0) return subHit;
700
+ if (opts?.smartSubstitute) {
701
+ const smartHit = pickNearestScript(value, locale);
702
+ if (smartHit !== void 0) return smartHit;
703
+ }
704
+ }
705
+ if (policy === "throw") {
706
+ throw new LocaleNotSpecifiedError(
707
+ field ?? "<unknown>",
708
+ `No translation available for locale "${locale}"` + (callerChain.length > 0 ? ` or fallback chain [${callerChain.join(", ")}]` : "") + "."
709
+ );
710
+ }
711
+ return null;
712
+ }
713
+ function pickNearestScript(value, target) {
714
+ const targetScript = inferScripts(target)[0] ?? "Latin";
715
+ let best;
716
+ for (const [loc, v] of Object.entries(value)) {
717
+ if (typeof v !== "string" || v === "") continue;
718
+ const s = inferScripts(loc)[0] ?? "Latin";
719
+ const score = s === targetScript ? 0 : s === "Latin" ? 1 : 2;
720
+ if (best === void 0 || score < best.score) best = { score, v };
721
+ if (score === 0) break;
722
+ }
723
+ return best?.v;
724
+ }
725
+ function applyAtPath(obj, path, locale, fallback, opts) {
726
+ const arrayIdx = path.indexOf("[].");
727
+ if (arrayIdx !== -1) {
728
+ const arrayKey = path.slice(0, arrayIdx);
729
+ const restPath = path.slice(arrayIdx + 3);
730
+ const arr = obj[arrayKey];
731
+ if (!Array.isArray(arr)) return obj;
732
+ return {
733
+ ...obj,
734
+ [arrayKey]: arr.map((item) => {
735
+ if (!item || typeof item !== "object" || Array.isArray(item)) return item;
736
+ return applyAtPath(item, restPath, locale, fallback, opts);
737
+ })
738
+ };
739
+ }
740
+ const dotIdx = path.indexOf(".");
741
+ if (dotIdx !== -1) {
742
+ const head = path.slice(0, dotIdx);
743
+ const rest = path.slice(dotIdx + 1);
744
+ const nested = obj[head];
745
+ if (!nested || typeof nested !== "object" || Array.isArray(nested)) return obj;
746
+ return {
747
+ ...obj,
748
+ [head]: applyAtPath(nested, rest, locale, fallback, opts)
749
+ };
750
+ }
751
+ const raw = obj[path];
752
+ if (raw === void 0 || raw === null) return obj;
753
+ if (typeof raw !== "object" || Array.isArray(raw)) return obj;
754
+ return {
755
+ ...obj,
756
+ [path]: resolveI18nText(raw, locale, fallback, path, opts)
757
+ };
758
+ }
759
+ function applyI18nLocale(record, i18nFields, locale, fallback, layer = "read") {
760
+ const fieldNames = Object.keys(i18nFields);
761
+ if (fieldNames.length === 0) return record;
762
+ let result = record;
763
+ for (const [field, descriptor] of Object.entries(i18nFields)) {
764
+ const { onMissing, substitute, smartSubstitute } = descriptor.options;
765
+ const opts = {
766
+ policy: resolvePolicy(onMissing, layer),
767
+ ...substitute !== void 0 ? { substitute } : {},
768
+ ...smartSubstitute ? { smartSubstitute } : {}
769
+ };
770
+ result = applyAtPath(result, field, locale, fallback, opts);
771
+ }
772
+ return result;
773
+ }
220
774
 
221
775
  // src/aggregate/groupby.ts
222
776
  var GROUPBY_WARN_CARDINALITY = 1e4;
@@ -235,15 +789,17 @@ function resetGroupByWarnings() {
235
789
  warnedCardinalityFields.clear();
236
790
  }
237
791
  var GroupedQueryBase = class {
238
- constructor(executeRecords, fieldOrFields, upstreams, dictLabelResolver) {
792
+ constructor(executeRecords, fieldOrFields, upstreams, dictLabelResolver, moneyFields) {
239
793
  this.executeRecords = executeRecords;
240
794
  this.upstreams = upstreams;
241
795
  this.dictLabelResolver = dictLabelResolver;
796
+ this.moneyFields = moneyFields;
242
797
  this.fields = typeof fieldOrFields === "string" ? [fieldOrFields] : [...fieldOrFields];
243
798
  }
244
799
  executeRecords;
245
800
  upstreams;
246
801
  dictLabelResolver;
802
+ moneyFields;
247
803
  /**
248
804
  * Field set this grouped query buckets on. Stored in declaration
249
805
  * order — the same order is preserved on every result row by
@@ -251,6 +807,10 @@ var GroupedQueryBase = class {
251
807
  * `[field]`.
252
808
  */
253
809
  fields;
810
+ /** Apply money-aware reducer rewriting when money fields are declared. */
811
+ wrapSpec(spec) {
812
+ return this.moneyFields ? wrapMoneyReducers(spec, this.moneyFields) : spec;
813
+ }
254
814
  };
255
815
  var GroupedQuery = class extends GroupedQueryBase {
256
816
  /**
@@ -263,7 +823,7 @@ var GroupedQuery = class extends GroupedQueryBase {
263
823
  return new GroupedAggregation(
264
824
  this.executeRecords,
265
825
  this.fields,
266
- spec,
826
+ this.wrapSpec(spec),
267
827
  this.upstreams,
268
828
  this.dictLabelResolver
269
829
  );
@@ -274,17 +834,20 @@ var GroupedQueryN = class extends GroupedQueryBase {
274
834
  return new GroupedAggregation(
275
835
  this.executeRecords,
276
836
  this.fields,
277
- spec,
837
+ this.wrapSpec(spec),
278
838
  this.upstreams,
279
839
  this.dictLabelResolver
280
840
  );
281
841
  }
282
842
  };
283
- function groupAndReduce(records, fieldOrFields, spec) {
843
+ function groupAndReduce(records, fieldOrFields, spec, moneyFields) {
284
844
  const fields = typeof fieldOrFields === "string" ? [fieldOrFields] : fieldOrFields;
285
845
  if (fields.length === 0) {
286
846
  throw new Error(".groupBy() requires at least one field");
287
847
  }
848
+ if (moneyFields) {
849
+ spec = wrapMoneyReducers(spec, moneyFields);
850
+ }
288
851
  const buckets = /* @__PURE__ */ new Map();
289
852
  const fieldLabel = fields.length === 1 ? fields[0] : `[${fields.join(", ")}]`;
290
853
  for (const record of records) {
@@ -346,9 +909,29 @@ var GroupedAggregation = class {
346
909
  upstreams;
347
910
  dictLabelResolver;
348
911
  fields;
349
- /** Execute the query, group, reduce, and return an array of rows. */
350
- run() {
351
- return groupAndReduce(this.executeRecords(), this.fields, this.spec);
912
+ /**
913
+ * Execute the query, group, reduce, and return an array of rows.
914
+ *
915
+ * `opts` (#285 query-form MV grouping): when a `locale` + `i18nFields` are
916
+ * given, the declared group-key `i18nText` fields are resolved to that locale
917
+ * at the `mv` layer BEFORE bucketing — so an i18n group key is a stable string
918
+ * instead of a raw `{locale}` map. The MV executor passes the MV's
919
+ * `i18nLocale`/`i18nFields`; ordinary `.run()` callers pass nothing and are
920
+ * unaffected.
921
+ */
922
+ run(opts) {
923
+ let records = this.executeRecords();
924
+ if (opts?.locale !== void 0 && opts.i18nFields !== void 0) {
925
+ const groupI18n = {};
926
+ for (const f of this.fields) {
927
+ const d = opts.i18nFields[f];
928
+ if (d !== void 0) groupI18n[f] = d;
929
+ }
930
+ if (Object.keys(groupI18n).length > 0) {
931
+ records = records.map((r) => applyI18nLocale(r, groupI18n, opts.locale, void 0, "mv"));
932
+ }
933
+ }
934
+ return groupAndReduce(records, this.fields, this.spec);
352
935
  }
353
936
  /**
354
937
  * Execute the query, group, reduce, and resolve `<field>Label` for
@@ -408,11 +991,11 @@ function withAggregate() {
408
991
  aggregate(executeRecords, spec, upstreams) {
409
992
  return new Aggregation(executeRecords, spec, upstreams);
410
993
  },
411
- groupBy(executeRecords, field, upstreams, dictLabelResolver) {
412
- return new GroupedQuery(executeRecords, field, upstreams, dictLabelResolver);
994
+ groupBy(executeRecords, field, upstreams, dictLabelResolver, moneyFields) {
995
+ return new GroupedQuery(executeRecords, field, upstreams, dictLabelResolver, moneyFields);
413
996
  },
414
- groupByN(executeRecords, fields, upstreams) {
415
- return new GroupedQueryN(executeRecords, fields, upstreams);
997
+ groupByN(executeRecords, fields, upstreams, moneyFields) {
998
+ return new GroupedQueryN(executeRecords, fields, upstreams, void 0, moneyFields);
416
999
  },
417
1000
  async scanAggregate(iter, spec) {
418
1001
  const collected = [];
@@ -427,26 +1010,37 @@ function count(opts) {
427
1010
  const _seed = opts?.seed;
428
1011
  void _seed;
429
1012
  return {
1013
+ op: "count",
430
1014
  init: () => 0,
431
1015
  step: (state) => state + 1,
432
1016
  remove: (state) => state - 1,
433
- finalize: (state) => state
1017
+ finalize: (state) => state,
1018
+ merge: (a, b) => a + b
434
1019
  };
435
1020
  }
436
1021
  function sum(field, opts) {
437
1022
  const _seed = opts?.seed;
438
1023
  void _seed;
439
1024
  return {
1025
+ op: "sum",
1026
+ field,
1027
+ // Money-only metadata, read by `wrapMoneyReducers`. No effect on a
1028
+ // generic numeric sum.
1029
+ ...opts?.convertTo !== void 0 ? { convertTo: opts.convertTo } : {},
1030
+ ...opts?.fx !== void 0 ? { fx: opts.fx } : {},
440
1031
  init: () => 0,
441
1032
  step: (state, record) => state + readNumber(record, field),
442
1033
  remove: (state, record) => state - readNumber(record, field),
443
- finalize: (state) => state
1034
+ finalize: (state) => state,
1035
+ merge: (a, b) => a + b
444
1036
  };
445
1037
  }
446
1038
  function avg(field, opts) {
447
1039
  const _seed = opts?.seed;
448
1040
  void _seed;
449
1041
  return {
1042
+ op: "avg",
1043
+ field,
450
1044
  init: () => ({ sum: 0, count: 0 }),
451
1045
  step: (state, record) => ({
452
1046
  sum: state.sum + readNumber(record, field),
@@ -456,7 +1050,8 @@ function avg(field, opts) {
456
1050
  sum: state.sum - readNumber(record, field),
457
1051
  count: state.count - 1
458
1052
  }),
459
- finalize: (state) => state.count === 0 ? null : state.sum / state.count
1053
+ finalize: (state) => state.count === 0 ? null : state.sum / state.count,
1054
+ merge: (a, b) => ({ sum: a.sum + b.sum, count: a.count + b.count })
460
1055
  };
461
1056
  }
462
1057
  function pushValue(state, value) {
@@ -473,6 +1068,8 @@ function min(field, opts) {
473
1068
  const _seed = opts?.seed;
474
1069
  void _seed;
475
1070
  return {
1071
+ op: "min",
1072
+ field,
476
1073
  init: () => ({ values: [] }),
477
1074
  step: (state, record) => pushValue(state, readNumber(record, field)),
478
1075
  remove: (state, record) => removeValue(state, readNumber(record, field)),
@@ -484,13 +1081,16 @@ function min(field, opts) {
484
1081
  if (v < out) out = v;
485
1082
  }
486
1083
  return out;
487
- }
1084
+ },
1085
+ merge: (a, b) => ({ values: [...a.values, ...b.values] })
488
1086
  };
489
1087
  }
490
1088
  function max(field, opts) {
491
1089
  const _seed = opts?.seed;
492
1090
  void _seed;
493
1091
  return {
1092
+ op: "max",
1093
+ field,
494
1094
  init: () => ({ values: [] }),
495
1095
  step: (state, record) => pushValue(state, readNumber(record, field)),
496
1096
  remove: (state, record) => removeValue(state, readNumber(record, field)),
@@ -502,11 +1102,17 @@ function max(field, opts) {
502
1102
  if (v > out) out = v;
503
1103
  }
504
1104
  return out;
505
- }
1105
+ },
1106
+ merge: (a, b) => ({ values: [...a.values, ...b.values] })
506
1107
  };
507
1108
  }
508
1109
  function readNumber(record, field) {
509
1110
  const value = readPath(record, field);
1111
+ if (typeof value === "object" && value !== null && "amount" in value && "currency" in value) {
1112
+ throw new Error(
1113
+ `aggregate: field "${field}" holds a money value but was not money-aware \u2014 declare it in the collection's moneyFields so sum/min/max stay exact`
1114
+ );
1115
+ }
510
1116
  return typeof value === "number" && Number.isFinite(value) ? value : 0;
511
1117
  }
512
1118
  // Annotate the CommonJS export names for ESM import in node: