@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
@@ -21,7 +21,7 @@ var __copyProps = (to, from, except, desc) => {
21
21
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
22
 
23
23
  // src/errors.ts
24
- var NoydbError, ValidationError, GroupCardinalityError, MaterializedViewCycleError, MaterializedViewSourceUnknownError, MaterializedViewTooLargeError, MaterializedViewConfigError;
24
+ var NoydbError, ValidationError, GroupCardinalityError, LocaleNotSpecifiedError, MaterializedViewCycleError, MaterializedViewSourceUnknownError, MaterializedViewTooLargeError, MaterializedViewConfigError;
25
25
  var init_errors = __esm({
26
26
  "src/errors.ts"() {
27
27
  "use strict";
@@ -58,6 +58,18 @@ var init_errors = __esm({
58
58
  this.maxGroups = maxGroups;
59
59
  }
60
60
  };
61
+ LocaleNotSpecifiedError = class extends NoydbError {
62
+ /** The field name that required a locale. */
63
+ field;
64
+ constructor(field, message) {
65
+ super(
66
+ "LOCALE_NOT_SPECIFIED",
67
+ message ?? `Cannot read i18nText field "${field}" without a locale. Pass { locale } to get()/list()/query() or set a default via openVault(name, { locale }).`
68
+ );
69
+ this.name = "LocaleNotSpecifiedError";
70
+ this.field = field;
71
+ }
72
+ };
61
73
  MaterializedViewCycleError = class extends NoydbError {
62
74
  path;
63
75
  constructor(path) {
@@ -120,6 +132,11 @@ function analyzeDependencies(query) {
120
132
  for (const leg of plan.joins) {
121
133
  deps.add(leg.target);
122
134
  }
135
+ for (const clause of plan.clauses) {
136
+ if (clause.type === "crossJoin") {
137
+ deps.add(clause.target);
138
+ }
139
+ }
123
140
  walkClausesForJoins(plan, deps, ctx);
124
141
  return deps;
125
142
  }
@@ -135,7 +152,19 @@ function summarizeQueryPlan(query) {
135
152
  const ctx = query._joinContext();
136
153
  return JSON.stringify({
137
154
  root: ctx?.leftCollection ?? null,
138
- clauses: plan.clauses,
155
+ clauses: plan.clauses.map((c) => {
156
+ if (c.type === "crossJoin") {
157
+ return {
158
+ type: "crossJoin",
159
+ target: c.target,
160
+ as: c.as,
161
+ // Inline on: callback: use sentinel — drift detection disabled for this MV
162
+ onPredicateName: c.onPredicateName ?? (c.on ? "[inline]" : null),
163
+ maxRows: c.maxRows ?? null
164
+ };
165
+ }
166
+ return c;
167
+ }),
139
168
  orderBy: plan.orderBy,
140
169
  limit: plan.limit ?? null,
141
170
  offset: plan.offset,
@@ -143,10 +172,14 @@ function summarizeQueryPlan(query) {
143
172
  });
144
173
  }
145
174
  function summarizeUnionPlan(spec) {
146
- const arms = (spec.unionSources ?? []).map((s) => s.collection).join(",");
175
+ const arms = (spec.unionSources ?? []).map((s) => {
176
+ const joins = s.join?.length ? `[${s.join.map((j) => `${j.field}\u2192${j.as}`).join(";")}]` : "";
177
+ return `${s.collection}${joins}`;
178
+ }).join(",");
147
179
  const groupBy = Array.isArray(spec.groupBy) ? [...spec.groupBy].sort().join(",") : typeof spec.groupBy === "string" ? spec.groupBy : "";
148
180
  const aggKeys = spec.aggregate ? Object.keys(spec.aggregate).sort().join(",") : "";
149
- return `union(${arms})|groupBy(${groupBy})|aggregate(${aggKeys})`;
181
+ const moneyKeys = spec.moneyFields ? Object.keys(spec.moneyFields).sort().join(",") : "";
182
+ return `union(${arms})|groupBy(${groupBy})|aggregate(${aggKeys})|money(${moneyKeys})`;
150
183
  }
151
184
  var init_dependency_analyzer = __esm({
152
185
  "src/materialized-views/dependency-analyzer.ts"() {
@@ -280,6 +313,7 @@ var init_registry = __esm({
280
313
  let isQuery = false;
281
314
  if (spec.unionSources) {
282
315
  dependencies = new Set(spec.unionSources.map((s) => s.collection));
316
+ if (spec.sources) for (const s of spec.sources) dependencies.add(s);
283
317
  queryPlanSummary = summarizeUnionPlan(spec);
284
318
  } else {
285
319
  const q = spec.query(dbForQuery);
@@ -410,6 +444,189 @@ var init_registry = __esm({
410
444
  }
411
445
  });
412
446
 
447
+ // src/money/fixed-point.ts
448
+ function expandExponent(s) {
449
+ const m = /^([+-]?)(\d+)(?:\.(\d+))?[eE]([+-]?\d+)$/.exec(s);
450
+ if (!m) return s;
451
+ const sign = m[1] === "-" ? "-" : "";
452
+ const intp = m[2];
453
+ const frac = m[3] ?? "";
454
+ const exp = Number(m[4]);
455
+ const digits = intp + frac;
456
+ const pointPos = intp.length + exp;
457
+ let body;
458
+ if (pointPos <= 0) {
459
+ body = "0." + "0".repeat(-pointPos) + digits;
460
+ } else if (pointPos >= digits.length) {
461
+ body = digits + "0".repeat(pointPos - digits.length);
462
+ } else {
463
+ body = digits.slice(0, pointPos) + "." + digits.slice(pointPos);
464
+ }
465
+ return sign + body;
466
+ }
467
+ function toCanonicalDecimalString(input) {
468
+ let s;
469
+ if (typeof input === "number") {
470
+ if (!Number.isFinite(input)) return null;
471
+ s = String(input);
472
+ } else {
473
+ s = input.trim();
474
+ }
475
+ s = expandExponent(s);
476
+ if (s.startsWith("+")) s = s.slice(1);
477
+ if (!/^-?(\d+(\.\d*)?|\.\d+)$/.test(s)) return null;
478
+ return s;
479
+ }
480
+ function shouldRoundUp(negative, lastKeptDigit, firstDiscarded, hasMoreNonZeroAfterFirst, mode) {
481
+ switch (mode) {
482
+ case "up":
483
+ return true;
484
+ case "down":
485
+ return false;
486
+ case "ceil":
487
+ return !negative;
488
+ case "floor":
489
+ return negative;
490
+ case "half-up":
491
+ return firstDiscarded >= 5;
492
+ case "half-down":
493
+ return firstDiscarded > 5 || firstDiscarded === 5 && hasMoreNonZeroAfterFirst;
494
+ case "half-even":
495
+ if (firstDiscarded > 5) return true;
496
+ if (firstDiscarded < 5) return false;
497
+ return hasMoreNonZeroAfterFirst || lastKeptDigit % 2 === 1;
498
+ }
499
+ }
500
+ function parseToScaledInt(input, scale, rounding) {
501
+ const canonical = toCanonicalDecimalString(input);
502
+ if (canonical === null) return { ok: false, reason: "nonfinite" };
503
+ const negative = canonical.startsWith("-");
504
+ const unsigned = negative ? canonical.slice(1) : canonical;
505
+ const dot = unsigned.indexOf(".");
506
+ const intPart = dot === -1 ? unsigned : unsigned.slice(0, dot);
507
+ const fracPart = dot === -1 ? "" : unsigned.slice(dot + 1);
508
+ const intDigits = intPart === "" ? "0" : intPart;
509
+ if (fracPart.length <= scale) {
510
+ const keep2 = fracPart.padEnd(scale, "0");
511
+ const magnitude2 = BigInt(intDigits + keep2);
512
+ return { ok: true, value: negative && magnitude2 !== 0n ? -magnitude2 : magnitude2 };
513
+ }
514
+ const keep = fracPart.slice(0, scale);
515
+ const tail = fracPart.slice(scale);
516
+ const magnitudeDigits = intDigits + keep;
517
+ let magnitude = BigInt(magnitudeDigits);
518
+ if (/^0+$/.test(tail)) {
519
+ return { ok: true, value: negative && magnitude !== 0n ? -magnitude : magnitude };
520
+ }
521
+ if (rounding === void 0) return { ok: false, reason: "precision" };
522
+ const lastKeptDigit = Number(magnitudeDigits[magnitudeDigits.length - 1]);
523
+ const firstDiscarded = Number(tail[0]);
524
+ const hasMoreNonZeroAfterFirst = /[1-9]/.test(tail.slice(1));
525
+ if (shouldRoundUp(negative, lastKeptDigit, firstDiscarded, hasMoreNonZeroAfterFirst, rounding)) {
526
+ magnitude += 1n;
527
+ }
528
+ return { ok: true, value: negative && magnitude !== 0n ? -magnitude : magnitude };
529
+ }
530
+ function formatScaledInt(value, scale) {
531
+ const negative = value < 0n;
532
+ const abs = (negative ? -value : value).toString();
533
+ if (scale === 0) return (negative ? "-" : "") + abs;
534
+ const padded = abs.padStart(scale + 1, "0");
535
+ const cut = padded.length - scale;
536
+ const intPart = padded.slice(0, cut);
537
+ const fracPart = padded.slice(cut);
538
+ return (negative ? "-" : "") + intPart + "." + fracPart;
539
+ }
540
+ var init_fixed_point = __esm({
541
+ "src/money/fixed-point.ts"() {
542
+ "use strict";
543
+ }
544
+ });
545
+
546
+ // src/money/iso4217.ts
547
+ function scaleForCurrency(code) {
548
+ const v = MINOR_UNITS[code];
549
+ return v === void 0 ? null : v;
550
+ }
551
+ var MINOR_UNITS;
552
+ var init_iso4217 = __esm({
553
+ "src/money/iso4217.ts"() {
554
+ "use strict";
555
+ MINOR_UNITS = {
556
+ // 2-decimal majors
557
+ EUR: 2,
558
+ USD: 2,
559
+ GBP: 2,
560
+ CHF: 2,
561
+ CAD: 2,
562
+ AUD: 2,
563
+ NZD: 2,
564
+ SGD: 2,
565
+ HKD: 2,
566
+ CNY: 2,
567
+ INR: 2,
568
+ BRL: 2,
569
+ MXN: 2,
570
+ ZAR: 2,
571
+ RUB: 2,
572
+ TRY: 2,
573
+ PLN: 2,
574
+ SEK: 2,
575
+ NOK: 2,
576
+ DKK: 2,
577
+ CZK: 2,
578
+ HUF: 2,
579
+ RON: 2,
580
+ ILS: 2,
581
+ THB: 2,
582
+ PHP: 2,
583
+ MYR: 2,
584
+ IDR: 2,
585
+ AED: 2,
586
+ SAR: 2,
587
+ QAR: 2,
588
+ EGP: 2,
589
+ // 0-decimal
590
+ JPY: 0,
591
+ KRW: 0,
592
+ ISK: 0,
593
+ CLP: 0,
594
+ VND: 0,
595
+ XOF: 0,
596
+ XAF: 0,
597
+ PYG: 0,
598
+ // 3-decimal
599
+ BHD: 3,
600
+ KWD: 3,
601
+ OMR: 3,
602
+ TND: 3,
603
+ JOD: 3,
604
+ IQD: 3,
605
+ LYD: 3
606
+ };
607
+ }
608
+ });
609
+
610
+ // src/money/descriptor.ts
611
+ var MoneyUnsupportedError;
612
+ var init_descriptor = __esm({
613
+ "src/money/descriptor.ts"() {
614
+ "use strict";
615
+ init_errors();
616
+ MoneyUnsupportedError = class extends NoydbError {
617
+ constructor(field, message) {
618
+ super(
619
+ "MONEY_UNSUPPORTED",
620
+ message ?? `money: operation is not supported on field "${field}" \u2014 use sum() and count() and divide at the boundary`
621
+ );
622
+ this.field = field;
623
+ this.name = "MoneyUnsupportedError";
624
+ }
625
+ field;
626
+ };
627
+ }
628
+ });
629
+
413
630
  // src/query/predicate.ts
414
631
  function readPath(record, path) {
415
632
  if (record === null || record === void 0) return void 0;
@@ -447,6 +664,411 @@ var init_canonical_key = __esm({
447
664
  }
448
665
  });
449
666
 
667
+ // src/money/money-reducer.ts
668
+ function toScaledIntFromAny(v, scale) {
669
+ if (typeof v === "bigint") return v;
670
+ if (typeof v === "number") {
671
+ const r = parseToScaledInt(v, scale);
672
+ return r.ok ? r.value : null;
673
+ }
674
+ if (typeof v === "string") {
675
+ if (!v.includes(".")) {
676
+ try {
677
+ return BigInt(v);
678
+ } catch {
679
+ return null;
680
+ }
681
+ }
682
+ const r = parseToScaledInt(v, scale);
683
+ return r.ok ? r.value : null;
684
+ }
685
+ return null;
686
+ }
687
+ function readMoney(record, field, desc) {
688
+ const raw = readPath(record, field);
689
+ if (raw === null || raw === void 0) return null;
690
+ if (desc.mode === "fixed") {
691
+ const cur = desc.fixedCurrency;
692
+ const value2 = toScaledIntFromAny(raw, desc.scaleFor(cur));
693
+ return value2 === null ? null : { currency: cur, value: value2 };
694
+ }
695
+ if (typeof raw !== "object") return null;
696
+ const o = raw;
697
+ if (typeof o.currency !== "string") return null;
698
+ const scale = desc.allows(o.currency) ? desc.scaleFor(o.currency) : 0;
699
+ const value = toScaledIntFromAny(o.amount, scale);
700
+ return value === null ? null : { currency: o.currency, value };
701
+ }
702
+ function targetScaleFor(desc, currency) {
703
+ if (desc.allows(currency)) return desc.scaleFor(currency);
704
+ const s = scaleForCurrency(currency);
705
+ if (s === null) {
706
+ throw new Error(`money: cannot determine scale for conversion target "${currency}"`);
707
+ }
708
+ return s;
709
+ }
710
+ function parseRate(rate) {
711
+ const s = String(rate).trim();
712
+ const neg = s.startsWith("-");
713
+ const body = neg ? s.slice(1) : s;
714
+ const dot = body.indexOf(".");
715
+ const intPart = dot === -1 ? body : body.slice(0, dot);
716
+ const fracPart = dot === -1 ? "" : body.slice(dot + 1);
717
+ const int = BigInt((intPart === "" ? "0" : intPart) + fracPart);
718
+ return { int: neg ? -int : int, scale: fracPart.length };
719
+ }
720
+ function divRoundHalfEven(n, d) {
721
+ const q = n / d;
722
+ const r = n % d;
723
+ const twiceR = (r < 0n ? -r : r) * 2n;
724
+ if (twiceR < d) return q;
725
+ if (twiceR > d) return q + (n < 0n ? -1n : 1n);
726
+ return q % 2n === 0n ? q : q + (n < 0n ? -1n : 1n);
727
+ }
728
+ function convertScaled(value, srcScale, rate, targetScale) {
729
+ const { int: rateInt, scale: rateScale } = parseRate(rate);
730
+ const product = value * rateInt;
731
+ const curScale = srcScale + rateScale;
732
+ if (curScale === targetScale) return product;
733
+ if (curScale < targetScale) return product * 10n ** BigInt(targetScale - curScale);
734
+ return divRoundHalfEven(product, 10n ** BigInt(curScale - targetScale));
735
+ }
736
+ function finalizeSum(state, desc, convertTo, fx) {
737
+ if (convertTo !== void 0) {
738
+ if (fx === void 0) {
739
+ throw new Error(`money: sum convertTo "${convertTo}" requires an fx rate map`);
740
+ }
741
+ const targetScale = targetScaleFor(desc, convertTo);
742
+ let total = 0n;
743
+ for (const [cur, v] of state) {
744
+ if (cur === convertTo) {
745
+ total += convertScaled(v, desc.scaleFor(cur), 1, targetScale);
746
+ continue;
747
+ }
748
+ const rate = fx[`${cur}->${convertTo}`];
749
+ if (rate === void 0) {
750
+ throw new Error(`money: no fx rate for "${cur}->${convertTo}"`);
751
+ }
752
+ total += convertScaled(v, desc.scaleFor(cur), rate, targetScale);
753
+ }
754
+ return formatScaledInt(total, targetScale);
755
+ }
756
+ if (desc.mode === "fixed") {
757
+ const cur = desc.fixedCurrency;
758
+ return formatScaledInt(state.get(cur) ?? 0n, desc.scaleFor(cur));
759
+ }
760
+ const out = {};
761
+ for (const [cur, v] of state) out[cur] = formatScaledInt(v, desc.scaleFor(cur));
762
+ return out;
763
+ }
764
+ function moneySumReducer(field, desc, convertTo, fx) {
765
+ return {
766
+ op: "sum",
767
+ field,
768
+ init: () => /* @__PURE__ */ new Map(),
769
+ step: (state, record) => {
770
+ const m = readMoney(record, field, desc);
771
+ if (m) state.set(m.currency, (state.get(m.currency) ?? 0n) + m.value);
772
+ return state;
773
+ },
774
+ remove: (state, record) => {
775
+ const m = readMoney(record, field, desc);
776
+ if (m) state.set(m.currency, (state.get(m.currency) ?? 0n) - m.value);
777
+ return state;
778
+ },
779
+ finalize: (state) => finalizeSum(state, desc, convertTo, fx)
780
+ };
781
+ }
782
+ function extremum(values, op) {
783
+ let out = values[0];
784
+ for (let i = 1; i < values.length; i++) {
785
+ const v = values[i];
786
+ if (op === "min" ? v < out : v > out) out = v;
787
+ }
788
+ return out;
789
+ }
790
+ function moneyMinMaxReducer(op, field, desc) {
791
+ return {
792
+ op,
793
+ field,
794
+ init: () => /* @__PURE__ */ new Map(),
795
+ step: (state, record) => {
796
+ const m = readMoney(record, field, desc);
797
+ if (m) {
798
+ const arr = state.get(m.currency);
799
+ if (arr) arr.push(m.value);
800
+ else state.set(m.currency, [m.value]);
801
+ }
802
+ return state;
803
+ },
804
+ remove: (state, record) => {
805
+ const m = readMoney(record, field, desc);
806
+ if (m) {
807
+ const arr = state.get(m.currency);
808
+ if (arr) {
809
+ const idx = arr.indexOf(m.value);
810
+ if (idx >= 0) arr.splice(idx, 1);
811
+ }
812
+ }
813
+ return state;
814
+ },
815
+ finalize: (state) => {
816
+ if (desc.mode === "fixed") {
817
+ const cur = desc.fixedCurrency;
818
+ const arr = state.get(cur);
819
+ if (!arr || arr.length === 0) return null;
820
+ return formatScaledInt(extremum(arr, op), desc.scaleFor(cur));
821
+ }
822
+ const out = {};
823
+ for (const [cur, arr] of state) {
824
+ if (arr.length > 0) out[cur] = formatScaledInt(extremum(arr, op), desc.scaleFor(cur));
825
+ }
826
+ return out;
827
+ }
828
+ };
829
+ }
830
+ function wrapMoneyReducers(spec, moneyFields) {
831
+ let changed = false;
832
+ const out = {};
833
+ for (const [key, reducer] of Object.entries(spec)) {
834
+ const field = reducer.field;
835
+ const desc = field ? moneyFields[field] : void 0;
836
+ if (desc && reducer.op === "avg") {
837
+ throw new MoneyUnsupportedError(
838
+ field,
839
+ `avg() is not supported on money field "${field}" in v1 \u2014 use sum() and count() and divide at the boundary.`
840
+ );
841
+ }
842
+ if (desc && (reducer.op === "sum" || reducer.op === "min" || reducer.op === "max")) {
843
+ changed = true;
844
+ out[key] = reducer.op === "sum" ? moneySumReducer(field, desc, reducer.convertTo, reducer.fx) : moneyMinMaxReducer(reducer.op, field, desc);
845
+ } else {
846
+ out[key] = reducer;
847
+ }
848
+ }
849
+ return changed ? out : spec;
850
+ }
851
+ var init_money_reducer = __esm({
852
+ "src/money/money-reducer.ts"() {
853
+ "use strict";
854
+ init_predicate();
855
+ init_fixed_point();
856
+ init_iso4217();
857
+ init_descriptor();
858
+ }
859
+ });
860
+
861
+ // src/i18n/policy.ts
862
+ function resolvePolicy(onMissing, layer) {
863
+ const explicit = onMissing && typeof onMissing === "object" ? onMissing[layer] : void 0;
864
+ const scalar = typeof onMissing === "string" ? onMissing : void 0;
865
+ const layerDefault = layer === "guard" ? "substitute" : void 0;
866
+ return explicit ?? layerDefault ?? scalar ?? "throw";
867
+ }
868
+ var init_policy = __esm({
869
+ "src/i18n/policy.ts"() {
870
+ "use strict";
871
+ }
872
+ });
873
+
874
+ // src/i18n/script.ts
875
+ function inferScripts(locale) {
876
+ const parts = locale.split("-");
877
+ const subtag = parts.find((t) => /^[A-Z][a-z]{3}$/.test(t));
878
+ if (subtag && SUBTAG_SCRIPTS[subtag]) return SUBTAG_SCRIPTS[subtag];
879
+ const base = (parts[0] ?? "").toLowerCase();
880
+ if (LATIN_BASE.has(base)) return ["Latin"];
881
+ const primary = SCRIPT_TABLE[base];
882
+ if (primary) return [...primary, "Latin"];
883
+ return ["Latin"];
884
+ }
885
+ var LATIN_BASE, SCRIPT_TABLE, SUBTAG_SCRIPTS, BASELINE;
886
+ var init_script = __esm({
887
+ "src/i18n/script.ts"() {
888
+ "use strict";
889
+ LATIN_BASE = /* @__PURE__ */ new Set([
890
+ "en",
891
+ "fr",
892
+ "de",
893
+ "es",
894
+ "it",
895
+ "pt",
896
+ "nl",
897
+ "sv",
898
+ "no",
899
+ "da",
900
+ "fi",
901
+ "is",
902
+ "pl",
903
+ "cs",
904
+ "sk",
905
+ "hu",
906
+ "ro",
907
+ "hr",
908
+ "sl",
909
+ "et",
910
+ "lv",
911
+ "lt",
912
+ "tr",
913
+ "vi",
914
+ "id",
915
+ "ms",
916
+ "tl",
917
+ "sw",
918
+ "af",
919
+ "ca",
920
+ "gl",
921
+ "eu",
922
+ "cy",
923
+ "ga"
924
+ ]);
925
+ SCRIPT_TABLE = {
926
+ th: ["Thai"],
927
+ ko: ["Hangul", "Han"],
928
+ ja: ["Han", "Hiragana", "Katakana"],
929
+ zh: ["Han"],
930
+ ar: ["Arabic"],
931
+ fa: ["Arabic"],
932
+ ur: ["Arabic"],
933
+ ru: ["Cyrillic"],
934
+ uk: ["Cyrillic"],
935
+ bg: ["Cyrillic"],
936
+ sr: ["Cyrillic"],
937
+ he: ["Hebrew"],
938
+ el: ["Greek"],
939
+ hi: ["Devanagari"],
940
+ ta: ["Tamil"],
941
+ km: ["Khmer"],
942
+ lo: ["Lao"],
943
+ my: ["Myanmar"]
944
+ };
945
+ SUBTAG_SCRIPTS = {
946
+ Latn: ["Latin"],
947
+ Cyrl: ["Cyrillic", "Latin"],
948
+ Hans: ["Han", "Latin"],
949
+ Hant: ["Han", "Latin"],
950
+ Thai: ["Thai", "Latin"],
951
+ Arab: ["Arabic", "Latin"]
952
+ };
953
+ BASELINE = String.raw`\p{White_Space}\p{Script=Common}\p{Script=Inherited}\p{Mark}`;
954
+ }
955
+ });
956
+
957
+ // src/i18n/core.ts
958
+ function toChain(fallback) {
959
+ return Array.isArray(fallback) ? fallback : fallback ? [fallback] : [];
960
+ }
961
+ function pickFromChain(value, chain) {
962
+ for (const fb of chain) {
963
+ if (fb === "any") {
964
+ const any = Object.values(value).find((v) => v !== "");
965
+ if (any !== void 0) return any;
966
+ } else if (value[fb] !== void 0 && value[fb] !== "") {
967
+ return value[fb];
968
+ }
969
+ }
970
+ return void 0;
971
+ }
972
+ function resolveI18nText(value, locale, fallback, field, opts) {
973
+ if (locale === "raw") {
974
+ return value;
975
+ }
976
+ if (!locale) {
977
+ throw new LocaleNotSpecifiedError(field ?? "<unknown>");
978
+ }
979
+ if (value[locale] !== void 0 && value[locale] !== "") {
980
+ return value[locale];
981
+ }
982
+ const policy = opts?.policy ?? "throw";
983
+ const callerChain = toChain(fallback);
984
+ const callerHit = pickFromChain(value, callerChain);
985
+ if (callerHit !== void 0) return callerHit;
986
+ if (policy === "substitute") {
987
+ const subHit = pickFromChain(value, toChain(opts?.substitute));
988
+ if (subHit !== void 0) return subHit;
989
+ if (opts?.smartSubstitute) {
990
+ const smartHit = pickNearestScript(value, locale);
991
+ if (smartHit !== void 0) return smartHit;
992
+ }
993
+ }
994
+ if (policy === "throw") {
995
+ throw new LocaleNotSpecifiedError(
996
+ field ?? "<unknown>",
997
+ `No translation available for locale "${locale}"` + (callerChain.length > 0 ? ` or fallback chain [${callerChain.join(", ")}]` : "") + "."
998
+ );
999
+ }
1000
+ return null;
1001
+ }
1002
+ function pickNearestScript(value, target) {
1003
+ const targetScript = inferScripts(target)[0] ?? "Latin";
1004
+ let best;
1005
+ for (const [loc, v] of Object.entries(value)) {
1006
+ if (typeof v !== "string" || v === "") continue;
1007
+ const s = inferScripts(loc)[0] ?? "Latin";
1008
+ const score = s === targetScript ? 0 : s === "Latin" ? 1 : 2;
1009
+ if (best === void 0 || score < best.score) best = { score, v };
1010
+ if (score === 0) break;
1011
+ }
1012
+ return best?.v;
1013
+ }
1014
+ function applyAtPath(obj, path, locale, fallback, opts) {
1015
+ const arrayIdx = path.indexOf("[].");
1016
+ if (arrayIdx !== -1) {
1017
+ const arrayKey = path.slice(0, arrayIdx);
1018
+ const restPath = path.slice(arrayIdx + 3);
1019
+ const arr = obj[arrayKey];
1020
+ if (!Array.isArray(arr)) return obj;
1021
+ return {
1022
+ ...obj,
1023
+ [arrayKey]: arr.map((item) => {
1024
+ if (!item || typeof item !== "object" || Array.isArray(item)) return item;
1025
+ return applyAtPath(item, restPath, locale, fallback, opts);
1026
+ })
1027
+ };
1028
+ }
1029
+ const dotIdx = path.indexOf(".");
1030
+ if (dotIdx !== -1) {
1031
+ const head = path.slice(0, dotIdx);
1032
+ const rest = path.slice(dotIdx + 1);
1033
+ const nested = obj[head];
1034
+ if (!nested || typeof nested !== "object" || Array.isArray(nested)) return obj;
1035
+ return {
1036
+ ...obj,
1037
+ [head]: applyAtPath(nested, rest, locale, fallback, opts)
1038
+ };
1039
+ }
1040
+ const raw = obj[path];
1041
+ if (raw === void 0 || raw === null) return obj;
1042
+ if (typeof raw !== "object" || Array.isArray(raw)) return obj;
1043
+ return {
1044
+ ...obj,
1045
+ [path]: resolveI18nText(raw, locale, fallback, path, opts)
1046
+ };
1047
+ }
1048
+ function applyI18nLocale(record, i18nFields, locale, fallback, layer = "read") {
1049
+ const fieldNames = Object.keys(i18nFields);
1050
+ if (fieldNames.length === 0) return record;
1051
+ let result = record;
1052
+ for (const [field, descriptor] of Object.entries(i18nFields)) {
1053
+ const { onMissing, substitute, smartSubstitute } = descriptor.options;
1054
+ const opts = {
1055
+ policy: resolvePolicy(onMissing, layer),
1056
+ ...substitute !== void 0 ? { substitute } : {},
1057
+ ...smartSubstitute ? { smartSubstitute } : {}
1058
+ };
1059
+ result = applyAtPath(result, field, locale, fallback, opts);
1060
+ }
1061
+ return result;
1062
+ }
1063
+ var init_core = __esm({
1064
+ "src/i18n/core.ts"() {
1065
+ "use strict";
1066
+ init_errors();
1067
+ init_policy();
1068
+ init_script();
1069
+ }
1070
+ });
1071
+
450
1072
  // src/aggregate/groupby.ts
451
1073
  function warnCardinalityApproaching(fields, observed) {
452
1074
  const key = JSON.stringify([...fields].sort());
@@ -457,11 +1079,14 @@ function warnCardinalityApproaching(fields, observed) {
457
1079
  `[noy-db] .groupBy(${label}) produced ${observed} distinct groups, ${Math.round(observed / GROUPBY_MAX_CARDINALITY * 100)}% of the ${GROUPBY_MAX_CARDINALITY}-group ceiling. Narrow the query with .where() before grouping, or switch to a lower-cardinality field.`
458
1080
  );
459
1081
  }
460
- function groupAndReduce(records, fieldOrFields, spec) {
1082
+ function groupAndReduce(records, fieldOrFields, spec, moneyFields) {
461
1083
  const fields = typeof fieldOrFields === "string" ? [fieldOrFields] : fieldOrFields;
462
1084
  if (fields.length === 0) {
463
1085
  throw new Error(".groupBy() requires at least one field");
464
1086
  }
1087
+ if (moneyFields) {
1088
+ spec = wrapMoneyReducers(spec, moneyFields);
1089
+ }
465
1090
  const buckets = /* @__PURE__ */ new Map();
466
1091
  const fieldLabel = fields.length === 1 ? fields[0] : `[${fields.join(", ")}]`;
467
1092
  for (const record of records) {
@@ -517,6 +1142,7 @@ var init_groupby = __esm({
517
1142
  init_predicate();
518
1143
  init_canonical_key();
519
1144
  init_errors();
1145
+ init_money_reducer();
520
1146
  GROUPBY_WARN_CARDINALITY = 1e4;
521
1147
  GROUPBY_MAX_CARDINALITY = 1e5;
522
1148
  warnedCardinalityFields = /* @__PURE__ */ new Set();
@@ -528,12 +1154,13 @@ var executor_exports = {};
528
1154
  __export(executor_exports, {
529
1155
  MaterializedViewExecutor: () => MaterializedViewExecutor
530
1156
  });
531
- async function materializeQueryResult(q, mvName) {
1157
+ async function materializeQueryResult(q, mvName, i18nLocale, i18nFields) {
532
1158
  if (typeof q?.toArray === "function") {
533
1159
  return await q.toArray();
534
1160
  }
535
1161
  if (typeof q?.run === "function") {
536
- const result = await Promise.resolve(q.run());
1162
+ const runOpts = i18nLocale !== void 0 ? { locale: i18nLocale, i18nFields } : void 0;
1163
+ const result = await Promise.resolve(q.run(runOpts));
537
1164
  if (Array.isArray(result)) {
538
1165
  return result;
539
1166
  }
@@ -547,13 +1174,44 @@ async function materializeUnionResult(spec, db) {
547
1174
  const unified = [];
548
1175
  for (const arm of spec.unionSources) {
549
1176
  const coll = db.collection(arm.collection);
550
- const sourceRows = coll.query().toArray();
1177
+ let q = coll.query();
1178
+ if (arm.join?.length) {
1179
+ for (const leg of arm.join) {
1180
+ q = q.join(leg.field, { as: leg.as, maxRows: leg.maxRows, strategy: leg.strategy });
1181
+ }
1182
+ }
1183
+ const sourceRows = q.toArray();
551
1184
  for (const r of sourceRows) {
552
- unified.push(arm.map(r));
1185
+ const mapped = arm.map(r);
1186
+ if (mapped == null) continue;
1187
+ unified.push(mapped);
553
1188
  }
554
1189
  }
555
1190
  if (!spec.groupBy) return unified;
556
1191
  const groupFields = typeof spec.groupBy === "string" ? [spec.groupBy] : spec.groupBy;
1192
+ if (spec.i18nLocale !== void 0 && spec.i18nFields !== void 0) {
1193
+ const groupI18n = {};
1194
+ for (const f of groupFields) {
1195
+ const d = spec.i18nFields[f];
1196
+ if (d !== void 0) groupI18n[f] = d;
1197
+ }
1198
+ if (Object.keys(groupI18n).length > 0) {
1199
+ for (let i = 0; i < unified.length; i++) {
1200
+ unified[i] = applyI18nLocale(unified[i], groupI18n, spec.i18nLocale, void 0, "mv");
1201
+ }
1202
+ }
1203
+ }
1204
+ for (const f of groupFields) {
1205
+ for (const row of unified) {
1206
+ const v = row[f];
1207
+ if (v !== null && typeof v === "object") {
1208
+ throw new LocaleNotSpecifiedError(
1209
+ f,
1210
+ `Materialized view "${spec.name}" groups by "${f}", whose value is a raw i18n locale map \u2014 an unstable object group key. Declare { i18nLocale, i18nFields } on the MV to resolve it at the 'mv' layer, or group by a dictKey/staticDict code (the stable key) and resolve the label at read time.`
1211
+ );
1212
+ }
1213
+ }
1214
+ }
557
1215
  if (!spec.aggregate) {
558
1216
  const seen = /* @__PURE__ */ new Map();
559
1217
  for (const row of unified) {
@@ -562,7 +1220,7 @@ async function materializeUnionResult(spec, db) {
562
1220
  }
563
1221
  return [...seen.values()];
564
1222
  }
565
- return groupAndReduce(unified, groupFields, spec.aggregate);
1223
+ return groupAndReduce(unified, groupFields, spec.aggregate, spec.moneyFields);
566
1224
  }
567
1225
  async function listOutputIds(outputColl) {
568
1226
  const cAny = outputColl;
@@ -585,6 +1243,7 @@ var init_executor = __esm({
585
1243
  init_registry();
586
1244
  init_groupby();
587
1245
  init_canonical_key();
1246
+ init_core();
588
1247
  DEFAULT_MAX_ROWS = 1e5;
589
1248
  MaterializedViewExecutor = {
590
1249
  async refresh(reg, accessor) {
@@ -600,7 +1259,7 @@ var init_executor = __esm({
600
1259
  rows = await materializeUnionResult(spec, ctxForQuery);
601
1260
  } else {
602
1261
  const q = spec.query(ctxForQuery);
603
- rows = await materializeQueryResult(q, spec.name);
1262
+ rows = await materializeQueryResult(q, spec.name, spec.i18nLocale, spec.i18nFields);
604
1263
  }
605
1264
  if (rows.length > maxRows) {
606
1265
  throw new MaterializedViewTooLargeError(spec.name, rows.length, maxRows);
@@ -708,9 +1367,9 @@ function withMaterializedView(spec) {
708
1367
  throw new ValidationError("withMaterializedView: query must be a function returning a Query<T>");
709
1368
  }
710
1369
  if (spec.unionSources) {
711
- if (spec.unionSources.length < 2) {
1370
+ if (spec.unionSources.length < 1) {
712
1371
  throw new MaterializedViewConfigError(
713
- "unionSources requires at least 2 source collections"
1372
+ "unionSources requires at least 1 source collection"
714
1373
  );
715
1374
  }
716
1375
  const seen = /* @__PURE__ */ new Set();
@@ -742,12 +1401,27 @@ function withMaterializedView(spec) {
742
1401
  `withMaterializedView "${spec.name}": UNION strategy with aggregate requires groupBy \u2014 use groupBy to declare the bucketing keys, or remove aggregate for a pure dedup MV`
743
1402
  );
744
1403
  }
1404
+ if (spec.moneyFields && !spec.aggregate) {
1405
+ throw new MaterializedViewConfigError(
1406
+ `withMaterializedView "${spec.name}": moneyFields requires aggregate \u2014 moneyFields rewrites sum/min/max reducers over money output fields, so it is meaningless without an aggregate spec`
1407
+ );
1408
+ }
1409
+ if (spec.unionSources.some((s) => s.join && s.join.length > 0) && (!spec.sources || spec.sources.length === 0)) {
1410
+ throw new MaterializedViewConfigError(
1411
+ `withMaterializedView "${spec.name}": a unionSources arm declares join(s) but no \`sources\` are listed \u2014 declare sources: [...] with the right-side (join-target) collection names so writes to them trigger MV refresh`
1412
+ );
1413
+ }
745
1414
  if (spec.predicates) {
746
1415
  throw new MaterializedViewConfigError(
747
1416
  `withMaterializedView "${spec.name}": predicates are not supported on UNION strategies \u2014 UNION mode does not use a Query<T> chain, so .wherePredicate() cannot fire. Use the query() form, or open an issue if per-arm predicates are needed`
748
1417
  );
749
1418
  }
750
1419
  }
1420
+ if (spec.i18nLocale !== void 0 && spec.i18nFields === void 0) {
1421
+ throw new MaterializedViewConfigError(
1422
+ `withMaterializedView "${spec.name}": i18nLocale requires i18nFields \u2014 declare the i18nText descriptors of the group-key fields so they can be resolved at the mv layer before bucketing.`
1423
+ );
1424
+ }
751
1425
  if (typeof spec.rowKey !== "function") {
752
1426
  throw new ValidationError("withMaterializedView: rowKey is required (no default; see spec \xA7 Type surface)");
753
1427
  }