@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.
- package/README.md +126 -0
- package/dist/aggregate/index.cjs +643 -37
- package/dist/aggregate/index.cjs.map +1 -1
- package/dist/aggregate/index.d.cts +3 -2
- package/dist/aggregate/index.d.ts +3 -2
- package/dist/aggregate/index.js +9 -8
- package/dist/aggregate/index.js.map +1 -1
- package/dist/attestation/index.cjs.map +1 -1
- package/dist/attestation/index.d.cts +7 -5
- package/dist/attestation/index.d.ts +7 -5
- package/dist/attestation/index.js +6 -6
- package/dist/blobs/index.cjs +509 -22
- package/dist/blobs/index.cjs.map +1 -1
- package/dist/blobs/index.d.cts +9 -7
- package/dist/blobs/index.d.ts +9 -7
- package/dist/blobs/index.js +11 -6
- package/dist/blobs/index.js.map +1 -1
- package/dist/bundle/index.cjs +7886 -841
- package/dist/bundle/index.cjs.map +1 -1
- package/dist/bundle/index.d.cts +20 -18
- package/dist/bundle/index.d.ts +20 -18
- package/dist/bundle/index.js +24 -13
- package/dist/bundle/index.js.map +1 -1
- package/dist/{chunk-PFSNOPBQ.js → chunk-2XA2ZML4.js} +31 -3
- package/dist/chunk-2XA2ZML4.js.map +1 -0
- package/dist/{chunk-2PAQNPE3.js → chunk-37VGJM3T.js} +37 -2
- package/dist/chunk-37VGJM3T.js.map +1 -0
- package/dist/{chunk-7BRE6EUA.js → chunk-3HNKR65T.js} +4 -4
- package/dist/chunk-3HNKR65T.js.map +1 -0
- package/dist/{chunk-Y2RKOPNC.js → chunk-5YTXYPES.js} +46 -10
- package/dist/chunk-5YTXYPES.js.map +1 -0
- package/dist/{chunk-OVZDFEOR.js → chunk-6QAZ5O6X.js} +2 -2
- package/dist/chunk-6QAZ5O6X.js.map +1 -0
- package/dist/{chunk-RTZVQAJ7.js → chunk-6QE4DUYC.js} +19 -4
- package/dist/chunk-6QE4DUYC.js.map +1 -0
- package/dist/{chunk-7Q5PLD5C.js → chunk-7MRT7EPB.js} +3 -3
- package/dist/{chunk-E535SAN4.js → chunk-7PH4OPBZ.js} +4258 -520
- package/dist/chunk-7PH4OPBZ.js.map +1 -0
- package/dist/{chunk-PEULZC6M.js → chunk-A3JMGXPG.js} +8 -1
- package/dist/chunk-A3JMGXPG.js.map +1 -0
- package/dist/{chunk-UMLVJTYV.js → chunk-ADB7GPM3.js} +7 -4
- package/dist/chunk-ADB7GPM3.js.map +1 -0
- package/dist/{chunk-G6FRSBKK.js → chunk-AI4USDRI.js} +4 -4
- package/dist/chunk-BZW5IL43.js +151 -0
- package/dist/chunk-BZW5IL43.js.map +1 -0
- package/dist/chunk-C2RJVZZL.js +123 -0
- package/dist/chunk-C2RJVZZL.js.map +1 -0
- package/dist/{chunk-UND4XIB6.js → chunk-C6W5KVDV.js} +52 -38
- package/dist/chunk-C6W5KVDV.js.map +1 -0
- package/dist/chunk-CQYEDODS.js +125 -0
- package/dist/chunk-CQYEDODS.js.map +1 -0
- package/dist/{chunk-NWZ3I6R6.js → chunk-EYK72OTL.js} +5 -5
- package/dist/{chunk-7BUTTVMR.js → chunk-F5GWNSE2.js} +2 -2
- package/dist/{chunk-AHPFONIL.js → chunk-F5ILTHMU.js} +5 -5
- package/dist/{chunk-Q6W2CMEJ.js → chunk-FRRJIUSI.js} +18 -5
- package/dist/chunk-FRRJIUSI.js.map +1 -0
- package/dist/{chunk-YMYK7US4.js → chunk-GJTKMME7.js} +2 -2
- package/dist/chunk-GJTKMME7.js.map +1 -0
- package/dist/{chunk-EUYOGYGV.js → chunk-HYJMAV53.js} +6 -6
- package/dist/chunk-HYJMAV53.js.map +1 -0
- package/dist/{chunk-QPEXPHJR.js → chunk-I3IYTUUI.js} +4 -4
- package/dist/{chunk-3QAKZ37R.js → chunk-IVZWHIEK.js} +5 -5
- package/dist/{chunk-PLI5TV7N.js → chunk-IW4L4X65.js} +2 -2
- package/dist/chunk-IW4L4X65.js.map +1 -0
- package/dist/{chunk-3Z2TPHC4.js → chunk-IY24WS2P.js} +69 -5
- package/dist/chunk-IY24WS2P.js.map +1 -0
- package/dist/{chunk-HXJXPZRE.js → chunk-J6RGRZOY.js} +10 -3
- package/dist/chunk-J6RGRZOY.js.map +1 -0
- package/dist/{chunk-3S4BJX25.js → chunk-JBBWALNI.js} +2 -2
- package/dist/chunk-JBBWALNI.js.map +1 -0
- package/dist/{chunk-7Z23ZFLV.js → chunk-JDCPRJVS.js} +5 -5
- package/dist/chunk-JDCPRJVS.js.map +1 -0
- package/dist/{chunk-243PNUA6.js → chunk-JOK73NDT.js} +3 -3
- package/dist/chunk-JTI57WRT.js +164 -0
- package/dist/chunk-JTI57WRT.js.map +1 -0
- package/dist/{chunk-VRBCTEKQ.js → chunk-JYNH4FIM.js} +233 -11
- package/dist/chunk-JYNH4FIM.js.map +1 -0
- package/dist/{chunk-TBKOGSYR.js → chunk-KOAJ3TZM.js} +27 -5
- package/dist/chunk-KOAJ3TZM.js.map +1 -0
- package/dist/{chunk-YTXSFG3C.js → chunk-MBXKRHSS.js} +50 -20
- package/dist/chunk-MBXKRHSS.js.map +1 -0
- package/dist/{chunk-MUWOSVEP.js → chunk-NSXNXLYM.js} +10 -2
- package/dist/chunk-NSXNXLYM.js.map +1 -0
- package/dist/{chunk-J4KLMEUL.js → chunk-NV4IHBZS.js} +664 -51
- package/dist/chunk-NV4IHBZS.js.map +1 -0
- package/dist/{chunk-LRAZDV5X.js → chunk-O5XKZCUD.js} +31 -8
- package/dist/chunk-O5XKZCUD.js.map +1 -0
- package/dist/{chunk-W3XXT26A.js → chunk-OTWT6BAJ.js} +358 -3
- package/dist/chunk-OTWT6BAJ.js.map +1 -0
- package/dist/{chunk-XG3PTSCD.js → chunk-PDVP3C2I.js} +1 -1
- package/dist/chunk-PDVP3C2I.js.map +1 -0
- package/dist/{chunk-GIV6DWBG.js → chunk-S45MDEEF.js} +44 -5
- package/dist/chunk-S45MDEEF.js.map +1 -0
- package/dist/{chunk-VK5EER6C.js → chunk-SQKAECUL.js} +2 -2
- package/dist/{chunk-FAQVNJD4.js → chunk-SQOK5UM6.js} +12 -2
- package/dist/{chunk-FAQVNJD4.js.map → chunk-SQOK5UM6.js.map} +1 -1
- package/dist/chunk-STNPB3UM.js +9 -0
- package/dist/chunk-STNPB3UM.js.map +1 -0
- package/dist/{chunk-YS3POABP.js → chunk-TA6HPKWQ.js} +1 -1
- package/dist/chunk-TA6HPKWQ.js.map +1 -0
- package/dist/{chunk-4HIL6AHQ.js → chunk-TAMRU7A2.js} +4 -4
- package/dist/{chunk-QXQRKXCU.js → chunk-TGIJTNM3.js} +2 -2
- package/dist/chunk-TNH5SLCD.js +361 -0
- package/dist/chunk-TNH5SLCD.js.map +1 -0
- package/dist/{chunk-VPSUZLOJ.js → chunk-TYMDCIQM.js} +31 -5
- package/dist/chunk-TYMDCIQM.js.map +1 -0
- package/dist/chunk-U2XSUCDF.js +524 -0
- package/dist/chunk-U2XSUCDF.js.map +1 -0
- package/dist/{chunk-3Y53S2SA.js → chunk-UU6M64HI.js} +4 -4
- package/dist/{chunk-VCGTOS2A.js → chunk-WE2BUQD2.js} +3 -3
- package/dist/chunk-WE2BUQD2.js.map +1 -0
- package/dist/{chunk-JYQTXEIO.js → chunk-WWVJXBOT.js} +449 -29
- package/dist/chunk-WWVJXBOT.js.map +1 -0
- package/dist/chunk-YPIOFSN3.js +129 -0
- package/dist/chunk-YPIOFSN3.js.map +1 -0
- package/dist/chunk-ZC7J6ZYV.js +7 -0
- package/dist/chunk-ZC7J6ZYV.js.map +1 -0
- package/dist/{chunk-5ZGZ6HIZ.js → chunk-ZONKSLF2.js} +30 -7
- package/dist/chunk-ZONKSLF2.js.map +1 -0
- package/dist/consent/index.cjs.map +1 -1
- package/dist/consent/index.d.cts +8 -6
- package/dist/consent/index.d.ts +8 -6
- package/dist/consent/index.js +3 -3
- package/dist/{crypto-5ZDIY3NG.js → crypto-456N7UVX.js} +7 -3
- package/dist/{delegation-QYXZW25W.js → delegation-DP4COTXB.js} +5 -5
- package/dist/derivations/index.cjs +124 -6
- package/dist/derivations/index.cjs.map +1 -1
- package/dist/derivations/index.d.cts +11 -9
- package/dist/derivations/index.d.ts +11 -9
- package/dist/derivations/index.js +8 -6
- package/dist/{dev-unlock-DQCNDfFp.d.cts → dev-unlock-CY0HIZA0.d.cts} +1 -1
- package/dist/{dev-unlock-utkybTKb.d.ts → dev-unlock-CpKSkl2c.d.ts} +1 -1
- package/dist/discriminant-BN9REW3o.d.cts +60 -0
- package/dist/discriminant-BN9REW3o.d.ts +60 -0
- package/dist/errors-Dkc_fi-S.d.cts +1467 -0
- package/dist/errors-Dkc_fi-S.d.ts +1467 -0
- package/dist/executor-4IEW4KG5.js +8 -0
- package/dist/executor-KYJCJCIN.js +12 -0
- package/dist/executor-W7VIBOBZ.js +8 -0
- package/dist/{fanout-sidecar-VJ52RIEY.js → fanout-sidecar-YXNAEZ33.js} +2 -2
- package/dist/fanout-sidecar-YXNAEZ33.js.map +1 -0
- package/dist/forget/index.cjs +43 -0
- package/dist/forget/index.cjs.map +1 -0
- package/dist/forget/index.d.cts +1 -0
- package/dist/forget/index.d.ts +1 -0
- package/dist/forget/index.js +14 -0
- package/dist/guards/index.cjs +144 -4
- package/dist/guards/index.cjs.map +1 -1
- package/dist/guards/index.d.cts +16 -8
- package/dist/guards/index.d.ts +16 -8
- package/dist/guards/index.js +13 -7
- package/dist/{hash-jDowCrK2.d.cts → hash-BSd0-_L8.d.cts} +1 -1
- package/dist/{hash-DcoYWfJ_.d.ts → hash-BnBQx39y.d.ts} +1 -1
- package/dist/history/index.cjs +28 -5
- package/dist/history/index.cjs.map +1 -1
- package/dist/history/index.d.cts +9 -7
- package/dist/history/index.d.ts +9 -7
- package/dist/history/index.js +9 -7
- package/dist/history/index.js.map +1 -1
- package/dist/i18n/index.cjs +356 -26
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/i18n/index.d.cts +8 -6
- package/dist/i18n/index.d.ts +8 -6
- package/dist/i18n/index.js +36 -15
- package/dist/i18n/index.js.map +1 -1
- package/dist/index-BMmajblo.d.cts +362 -0
- package/dist/index-BMmajblo.d.ts +362 -0
- package/dist/{index-BCKdioeh.d.ts → index-Bm9hIY7t.d.ts} +169 -1127
- package/dist/{index-BMjrzNZr.d.cts → index-tZqVB9g5.d.cts} +169 -1127
- package/dist/index.cjs +10286 -2168
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +258 -23
- package/dist/index.d.ts +258 -23
- package/dist/index.js +443 -110
- package/dist/index.js.map +1 -1
- package/dist/indexing/index.cjs +97 -32
- package/dist/indexing/index.cjs.map +1 -1
- package/dist/indexing/index.d.cts +3 -3
- package/dist/indexing/index.d.ts +3 -3
- package/dist/indexing/index.js +4 -4
- package/dist/issue-JXC6T2QR.js +12 -0
- package/dist/{lazy-builder-Rpd-V3jP.d.ts → lazy-builder-ChSqcF5t.d.ts} +2 -2
- package/dist/{lazy-builder-C-rPfWG0.d.cts → lazy-builder-eYZzLEL1.d.cts} +2 -2
- package/dist/{ledger-3IU5GMXA.js → ledger-I7JUYP4L.js} +6 -6
- package/dist/materialized-views/index.cjs +687 -13
- package/dist/materialized-views/index.cjs.map +1 -1
- package/dist/materialized-views/index.d.cts +23 -20
- package/dist/materialized-views/index.d.ts +23 -20
- package/dist/materialized-views/index.js +8 -7
- package/dist/mime-magic-BnJCGJzB.d.cts +103 -0
- package/dist/mime-magic-CjSyakO4.d.ts +103 -0
- package/dist/noydb-ZZCRF6TE.js +38 -0
- package/dist/overlay-views/index.cjs +58 -18
- package/dist/overlay-views/index.cjs.map +1 -1
- package/dist/overlay-views/index.d.cts +32 -12
- package/dist/overlay-views/index.d.ts +32 -12
- package/dist/overlay-views/index.js +6 -6
- package/dist/periods/index.cjs.map +1 -1
- package/dist/periods/index.d.cts +8 -6
- package/dist/periods/index.d.ts +8 -6
- package/dist/periods/index.js +6 -6
- package/dist/{predicate-Dnu81tsS.d.cts → predicate-BmhBSPCH.d.cts} +87 -5
- package/dist/{predicate-Dnu81tsS.d.ts → predicate-BmhBSPCH.d.ts} +87 -5
- package/dist/{public-envelope-U3CMEOMV.js → public-envelope-5XRTUNKF.js} +4 -4
- package/dist/query/index.cjs +1438 -130
- package/dist/query/index.cjs.map +1 -1
- package/dist/query/index.d.cts +4 -3
- package/dist/query/index.d.ts +4 -3
- package/dist/query/index.js +13 -6
- package/dist/read-only-facade-EX6WZZBP.js +7 -0
- package/dist/registry-ATRHOG5B.js +8 -0
- package/dist/registry-DKEXOJVO.js +7 -0
- package/dist/registry-LEHB26TY.js +8 -0
- package/dist/{registry-3ALP62P6.js → registry-NWHOLD5M.js} +3 -3
- package/dist/{revoke-KY2GB4KP.js → revoke-5IEK22KT.js} +6 -6
- package/dist/sealed-record/index.cjs +139 -0
- package/dist/sealed-record/index.cjs.map +1 -0
- package/dist/sealed-record/index.d.cts +123 -0
- package/dist/sealed-record/index.d.ts +123 -0
- package/dist/sealed-record/index.js +42 -0
- package/dist/sealed-record/index.js.map +1 -0
- package/dist/session/index.cjs.map +1 -1
- package/dist/session/index.d.cts +9 -7
- package/dist/session/index.d.ts +9 -7
- package/dist/session/index.js +3 -3
- package/dist/shadow/index.cjs.map +1 -1
- package/dist/shadow/index.d.cts +8 -6
- package/dist/shadow/index.d.ts +8 -6
- package/dist/shadow/index.js +2 -2
- package/dist/{signer-GRI5TZKH.js → signer-I6YARZQA.js} +5 -5
- package/dist/snapshots/index.cjs +937 -0
- package/dist/snapshots/index.cjs.map +1 -0
- package/dist/snapshots/index.d.cts +30 -0
- package/dist/snapshots/index.d.ts +30 -0
- package/dist/snapshots/index.js +152 -0
- package/dist/snapshots/index.js.map +1 -0
- package/dist/{stale-OTOF3FH7.js → stale-CPESGAPL.js} +2 -2
- package/dist/stale-CPESGAPL.js.map +1 -0
- package/dist/state-vault-JR3CFGNP.js +14 -0
- package/dist/state-vault-JR3CFGNP.js.map +1 -0
- package/dist/store/index.cjs +8 -0
- package/dist/store/index.cjs.map +1 -1
- package/dist/store/index.d.cts +15 -6
- package/dist/store/index.d.ts +15 -6
- package/dist/store/index.js +2 -2
- package/dist/{strategy-DSTrsZ8t.d.ts → strategy-54eIwox5.d.ts} +456 -7
- package/dist/{strategy-DSTrsZ8t.d.cts → strategy-WtB-jXYv.d.cts} +456 -7
- package/dist/sync/index.cjs.map +1 -1
- package/dist/sync/index.d.cts +7 -5
- package/dist/sync/index.d.ts +7 -5
- package/dist/sync/index.js +4 -4
- package/dist/team/index.cjs +1 -1
- package/dist/team/index.cjs.map +1 -1
- package/dist/team/index.d.cts +8 -6
- package/dist/team/index.d.ts +8 -6
- package/dist/team/index.js +8 -8
- package/dist/transition-guard-D4bfIAiW.d.ts +165 -0
- package/dist/transition-guard-Dmpqzg-_.d.cts +165 -0
- package/dist/tx/index.cjs +155 -5
- package/dist/tx/index.cjs.map +1 -1
- package/dist/tx/index.d.cts +27 -9
- package/dist/tx/index.d.ts +27 -9
- package/dist/tx/index.js +61 -4
- package/dist/tx/index.js.map +1 -1
- package/dist/{types-BoFFiskX.d.ts → types-DLfWFr6U.d.ts} +3997 -1262
- package/dist/{types-DJG8HG6F.d.cts → types-DyOI6XZ_.d.cts} +3997 -1262
- package/dist/{ulid-BmBgooGm.d.ts → ulid-B2L_aqVA.d.ts} +19 -19
- package/dist/{ulid-C7ms9oli.d.cts → ulid-LaxfH2tK.d.cts} +19 -19
- package/dist/util/index.cjs +7 -0
- package/dist/util/index.cjs.map +1 -1
- package/dist/util/index.d.cts +2 -0
- package/dist/util/index.d.ts +2 -0
- package/dist/util/index.js +5 -1
- package/dist/util/index.js.map +1 -1
- package/dist/vault-group-BB246VIM.js +804 -0
- package/dist/vault-group-BB246VIM.js.map +1 -0
- package/dist/{with-materialized-view-CqnRwI2S.d.ts → with-materialized-view-CeZYGJVf.d.cts} +2 -2
- package/dist/{with-materialized-view-BbEPFIIJ.d.cts → with-materialized-view-DNULSxoP.d.ts} +2 -2
- package/dist/{with-overlayed-view-Ct1fSJt-.d.ts → with-overlayed-view-C9joG7UZ.d.ts} +2 -2
- package/dist/{with-overlayed-view-bwlmmFjx.d.cts → with-overlayed-view-kdcPGHih.d.cts} +2 -2
- package/dist/with-rollup-DJDbrxjf.d.ts +47 -0
- package/dist/with-rollup-s58XAeWO.d.cts +47 -0
- package/package.json +35 -4
- package/dist/chunk-2PAQNPE3.js.map +0 -1
- package/dist/chunk-3S4BJX25.js.map +0 -1
- package/dist/chunk-3XHOCQK4.js +0 -118
- package/dist/chunk-3XHOCQK4.js.map +0 -1
- package/dist/chunk-3Z2TPHC4.js.map +0 -1
- package/dist/chunk-5ZGZ6HIZ.js.map +0 -1
- package/dist/chunk-7BRE6EUA.js.map +0 -1
- package/dist/chunk-7Z23ZFLV.js.map +0 -1
- package/dist/chunk-CXSCDO5T.js +0 -51
- package/dist/chunk-CXSCDO5T.js.map +0 -1
- package/dist/chunk-E535SAN4.js.map +0 -1
- package/dist/chunk-EUYOGYGV.js.map +0 -1
- package/dist/chunk-GIV6DWBG.js.map +0 -1
- package/dist/chunk-HXJXPZRE.js.map +0 -1
- package/dist/chunk-J4KLMEUL.js.map +0 -1
- package/dist/chunk-JYQTXEIO.js.map +0 -1
- package/dist/chunk-LRAZDV5X.js.map +0 -1
- package/dist/chunk-MRIBLZL3.js +0 -86
- package/dist/chunk-MRIBLZL3.js.map +0 -1
- package/dist/chunk-MUWOSVEP.js.map +0 -1
- package/dist/chunk-OVZDFEOR.js.map +0 -1
- package/dist/chunk-PEULZC6M.js.map +0 -1
- package/dist/chunk-PFSNOPBQ.js.map +0 -1
- package/dist/chunk-PLI5TV7N.js.map +0 -1
- package/dist/chunk-Q6W2CMEJ.js.map +0 -1
- package/dist/chunk-RTZVQAJ7.js.map +0 -1
- package/dist/chunk-TBKOGSYR.js.map +0 -1
- package/dist/chunk-UMLVJTYV.js.map +0 -1
- package/dist/chunk-UND4XIB6.js.map +0 -1
- package/dist/chunk-VCGTOS2A.js.map +0 -1
- package/dist/chunk-VE6YVP32.js +0 -19
- package/dist/chunk-VE6YVP32.js.map +0 -1
- package/dist/chunk-VPSUZLOJ.js.map +0 -1
- package/dist/chunk-VRBCTEKQ.js.map +0 -1
- package/dist/chunk-W3XXT26A.js.map +0 -1
- package/dist/chunk-XG3PTSCD.js.map +0 -1
- package/dist/chunk-Y2RKOPNC.js.map +0 -1
- package/dist/chunk-YMYK7US4.js.map +0 -1
- package/dist/chunk-YS3POABP.js.map +0 -1
- package/dist/chunk-YTXSFG3C.js.map +0 -1
- package/dist/executor-AS2IDHKZ.js +0 -11
- package/dist/executor-HLXFXNFM.js +0 -8
- package/dist/executor-HN6YBHZ5.js +0 -8
- package/dist/fanout-sidecar-VJ52RIEY.js.map +0 -1
- package/dist/issue-ORP37MVW.js +0 -12
- package/dist/mime-magic-CBBSOkjm.d.cts +0 -50
- package/dist/mime-magic-CBBSOkjm.d.ts +0 -50
- package/dist/noydb-5H3C24GG.js +0 -34
- package/dist/read-only-facade-ITU6L7BL.js +0 -7
- package/dist/registry-7HE6VJGC.js +0 -8
- package/dist/registry-PSIPG2QR.js +0 -8
- package/dist/registry-RFGGMVNJ.js +0 -7
- package/dist/with-derivation-BKXXa8Vt.d.ts +0 -13
- package/dist/with-derivation-BjQ7q4NE.d.cts +0 -13
- package/dist/with-guard-C25yNjzd.d.ts +0 -18
- package/dist/with-guard-DQme5DKE.d.cts +0 -18
- /package/dist/{chunk-7Q5PLD5C.js.map → chunk-7MRT7EPB.js.map} +0 -0
- /package/dist/{chunk-G6FRSBKK.js.map → chunk-AI4USDRI.js.map} +0 -0
- /package/dist/{chunk-NWZ3I6R6.js.map → chunk-EYK72OTL.js.map} +0 -0
- /package/dist/{chunk-7BUTTVMR.js.map → chunk-F5GWNSE2.js.map} +0 -0
- /package/dist/{chunk-AHPFONIL.js.map → chunk-F5ILTHMU.js.map} +0 -0
- /package/dist/{chunk-QPEXPHJR.js.map → chunk-I3IYTUUI.js.map} +0 -0
- /package/dist/{chunk-3QAKZ37R.js.map → chunk-IVZWHIEK.js.map} +0 -0
- /package/dist/{chunk-243PNUA6.js.map → chunk-JOK73NDT.js.map} +0 -0
- /package/dist/{chunk-VK5EER6C.js.map → chunk-SQKAECUL.js.map} +0 -0
- /package/dist/{chunk-4HIL6AHQ.js.map → chunk-TAMRU7A2.js.map} +0 -0
- /package/dist/{chunk-QXQRKXCU.js.map → chunk-TGIJTNM3.js.map} +0 -0
- /package/dist/{chunk-3Y53S2SA.js.map → chunk-UU6M64HI.js.map} +0 -0
- /package/dist/{crypto-5ZDIY3NG.js.map → crypto-456N7UVX.js.map} +0 -0
- /package/dist/{delegation-QYXZW25W.js.map → delegation-DP4COTXB.js.map} +0 -0
- /package/dist/{executor-AS2IDHKZ.js.map → executor-4IEW4KG5.js.map} +0 -0
- /package/dist/{executor-HLXFXNFM.js.map → executor-KYJCJCIN.js.map} +0 -0
- /package/dist/{executor-HN6YBHZ5.js.map → executor-W7VIBOBZ.js.map} +0 -0
- /package/dist/{issue-ORP37MVW.js.map → forget/index.js.map} +0 -0
- /package/dist/{ledger-3IU5GMXA.js.map → issue-JXC6T2QR.js.map} +0 -0
- /package/dist/{noydb-5H3C24GG.js.map → ledger-I7JUYP4L.js.map} +0 -0
- /package/dist/{public-envelope-U3CMEOMV.js.map → noydb-ZZCRF6TE.js.map} +0 -0
- /package/dist/{read-only-facade-ITU6L7BL.js.map → public-envelope-5XRTUNKF.js.map} +0 -0
- /package/dist/{registry-3ALP62P6.js.map → read-only-facade-EX6WZZBP.js.map} +0 -0
- /package/dist/{registry-7HE6VJGC.js.map → registry-ATRHOG5B.js.map} +0 -0
- /package/dist/{registry-PSIPG2QR.js.map → registry-DKEXOJVO.js.map} +0 -0
- /package/dist/{registry-RFGGMVNJ.js.map → registry-LEHB26TY.js.map} +0 -0
- /package/dist/{revoke-KY2GB4KP.js.map → registry-NWHOLD5M.js.map} +0 -0
- /package/dist/{signer-GRI5TZKH.js.map → revoke-5IEK22KT.js.map} +0 -0
- /package/dist/{stale-OTOF3FH7.js.map → signer-I6YARZQA.js.map} +0 -0
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
|
+
wrapMoneyReducers
|
|
3
|
+
} from "./chunk-JYNH4FIM.js";
|
|
4
|
+
import {
|
|
5
|
+
MoneyPrecisionError,
|
|
2
6
|
evaluateClause,
|
|
7
|
+
formatScaledInt,
|
|
8
|
+
hasFnClause,
|
|
9
|
+
moneyFieldClause,
|
|
10
|
+
parseToScaledInt,
|
|
3
11
|
readPath
|
|
4
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-U2XSUCDF.js";
|
|
13
|
+
import {
|
|
14
|
+
applyI18nLocale
|
|
15
|
+
} from "./chunk-TNH5SLCD.js";
|
|
5
16
|
import {
|
|
17
|
+
CrossJoinSourceUnknownError,
|
|
18
|
+
CrossJoinTooLargeError,
|
|
6
19
|
DanglingReferenceError,
|
|
7
|
-
JoinTooLargeError
|
|
8
|
-
|
|
20
|
+
JoinTooLargeError,
|
|
21
|
+
ValidationError
|
|
22
|
+
} from "./chunk-OTWT6BAJ.js";
|
|
9
23
|
|
|
10
24
|
// src/query/join.ts
|
|
11
25
|
var DEFAULT_JOIN_MAX_ROWS = 5e4;
|
|
@@ -35,15 +49,15 @@ function warnCeilingApproaching(target, side, rows, maxRows) {
|
|
|
35
49
|
`[noy-db] .join() ${side} side is at ${pct}% of the ${maxRows}-row ceiling for target "${target}" (${rows} rows). Streaming joins over scan() are not yet supported for collections that need to exceed this.`
|
|
36
50
|
);
|
|
37
51
|
}
|
|
38
|
-
function applyJoins(rows, joins, context) {
|
|
52
|
+
function applyJoins(rows, joins, context, locale) {
|
|
39
53
|
if (joins.length === 0) return [...rows];
|
|
40
54
|
let result = [...rows];
|
|
41
55
|
for (const leg of joins) {
|
|
42
|
-
result = applyOneJoin(result, leg, context);
|
|
56
|
+
result = applyOneJoin(result, leg, context, locale);
|
|
43
57
|
}
|
|
44
58
|
return result;
|
|
45
59
|
}
|
|
46
|
-
function applyOneJoin(leftRows, leg, context) {
|
|
60
|
+
function applyOneJoin(leftRows, leg, context, locale) {
|
|
47
61
|
if (leg.isDictJoin) {
|
|
48
62
|
const dictSource = context.resolveDictSource?.(leg.field);
|
|
49
63
|
if (!dictSource) {
|
|
@@ -98,24 +112,27 @@ function applyOneJoin(leftRows, leg, context) {
|
|
|
98
112
|
if (rightSnapshot.length > maxRows * JOIN_WARN_FRACTION) {
|
|
99
113
|
warnCeilingApproaching(leg.target, "right", rightSnapshot.length, maxRows);
|
|
100
114
|
}
|
|
115
|
+
const effLocale = locale ?? context.defaultLocale;
|
|
116
|
+
const i18nResolve = effLocale !== void 0 && source.i18nFields !== void 0 ? (right) => right !== null && typeof right === "object" ? applyI18nLocale(right, source.i18nFields, effLocale, void 0, "join") : right : void 0;
|
|
101
117
|
const strategy = leg.strategy ?? (source.lookupById ? "nested" : "hash");
|
|
102
118
|
if (strategy === "nested" && source.lookupById) {
|
|
103
119
|
const lookup = (id) => source.lookupById?.(id);
|
|
104
|
-
return nestedLoopJoin(leftRows, leg, lookup);
|
|
120
|
+
return nestedLoopJoin(leftRows, leg, lookup, i18nResolve);
|
|
105
121
|
}
|
|
106
|
-
return hashJoin(leftRows, leg, rightSnapshot);
|
|
122
|
+
return hashJoin(leftRows, leg, rightSnapshot, i18nResolve);
|
|
107
123
|
}
|
|
108
|
-
function nestedLoopJoin(leftRows, leg, lookupById) {
|
|
124
|
+
function nestedLoopJoin(leftRows, leg, lookupById, i18nResolve) {
|
|
109
125
|
const out = [];
|
|
110
126
|
for (const left of leftRows) {
|
|
111
127
|
const rawId = readPath(left, leg.field);
|
|
112
128
|
const key = coerceRefKey(rawId);
|
|
113
|
-
|
|
129
|
+
let right = key === null ? void 0 : lookupById(key);
|
|
130
|
+
if (i18nResolve && right !== void 0) right = i18nResolve(right);
|
|
114
131
|
out.push(attachJoin(left, leg, right, rawId));
|
|
115
132
|
}
|
|
116
133
|
return out;
|
|
117
134
|
}
|
|
118
|
-
function hashJoin(leftRows, leg, rightSnapshot) {
|
|
135
|
+
function hashJoin(leftRows, leg, rightSnapshot, i18nResolve) {
|
|
119
136
|
const rightMap = /* @__PURE__ */ new Map();
|
|
120
137
|
for (const record of rightSnapshot) {
|
|
121
138
|
const rawId = readPath(record, "id");
|
|
@@ -128,7 +145,8 @@ function hashJoin(leftRows, leg, rightSnapshot) {
|
|
|
128
145
|
for (const left of leftRows) {
|
|
129
146
|
const rawId = readPath(left, leg.field);
|
|
130
147
|
const key = coerceRefKey(rawId);
|
|
131
|
-
|
|
148
|
+
let right = key === null ? void 0 : rightMap.get(key);
|
|
149
|
+
if (i18nResolve && right !== void 0) right = i18nResolve(right);
|
|
132
150
|
out.push(attachJoin(left, leg, right, rawId));
|
|
133
151
|
}
|
|
134
152
|
return out;
|
|
@@ -252,6 +270,277 @@ var NO_AGGREGATE = {
|
|
|
252
270
|
}
|
|
253
271
|
};
|
|
254
272
|
|
|
273
|
+
// src/money/paths.ts
|
|
274
|
+
var SEGMENT_RE = /^(\*|[^.[\]*]+)(\[\])?$/;
|
|
275
|
+
var parseCache = /* @__PURE__ */ new Map();
|
|
276
|
+
function parseMoneyPath(path) {
|
|
277
|
+
const cached = parseCache.get(path);
|
|
278
|
+
if (cached) return cached;
|
|
279
|
+
if (typeof path !== "string" || path.length === 0) {
|
|
280
|
+
throw new ValidationError("moneyFields: path must be a non-empty string");
|
|
281
|
+
}
|
|
282
|
+
const segments = [];
|
|
283
|
+
for (const part of path.split(".")) {
|
|
284
|
+
const m = SEGMENT_RE.exec(part);
|
|
285
|
+
if (!m) {
|
|
286
|
+
throw new ValidationError(
|
|
287
|
+
`moneyFields: invalid path "${path}" \u2014 segment "${part}" must be a key, "key[]", "*", or "*[]"`
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
const array = m[2] === "[]";
|
|
291
|
+
segments.push(
|
|
292
|
+
m[1] === "*" ? { kind: "wildcard", array } : { kind: "key", key: m[1], array }
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
parseCache.set(path, segments);
|
|
296
|
+
return segments;
|
|
297
|
+
}
|
|
298
|
+
function isSimpleMoneyPath(path) {
|
|
299
|
+
return !path.includes(".") && !path.includes("[") && !path.includes("*");
|
|
300
|
+
}
|
|
301
|
+
function validateMoneyFieldPaths(moneyFields) {
|
|
302
|
+
for (const path of Object.keys(moneyFields)) parseMoneyPath(path);
|
|
303
|
+
}
|
|
304
|
+
function transformAtMoneyPath(node, path, segments, index, visit, lenient) {
|
|
305
|
+
if (node === null || node === void 0) return node;
|
|
306
|
+
const seg = segments[index];
|
|
307
|
+
const last = index === segments.length - 1;
|
|
308
|
+
if (seg.kind === "key") {
|
|
309
|
+
if (typeof node !== "object" || Array.isArray(node)) {
|
|
310
|
+
if (lenient) return node;
|
|
311
|
+
throw new ValidationError(
|
|
312
|
+
`moneyFields: path "${path}" expected an object at segment "${seg.key}", got ${Array.isArray(node) ? "an array" : typeof node}`
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
const obj2 = node;
|
|
316
|
+
if (!(seg.key in obj2) || obj2[seg.key] === null || obj2[seg.key] === void 0) return node;
|
|
317
|
+
if (seg.array) {
|
|
318
|
+
const arr = obj2[seg.key];
|
|
319
|
+
if (!Array.isArray(arr)) {
|
|
320
|
+
if (lenient) return node;
|
|
321
|
+
throw new ValidationError(
|
|
322
|
+
`moneyFields: path "${path}" declares "${seg.key}[]" but the value is not an array`
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
const cloned = [...arr];
|
|
326
|
+
if (last) {
|
|
327
|
+
for (let i = 0; i < cloned.length; i++) visit(cloned, i);
|
|
328
|
+
} else {
|
|
329
|
+
for (let i = 0; i < cloned.length; i++) {
|
|
330
|
+
cloned[i] = transformAtMoneyPath(cloned[i], path, segments, index + 1, visit, lenient);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return { ...obj2, [seg.key]: cloned };
|
|
334
|
+
}
|
|
335
|
+
const clone2 = { ...obj2 };
|
|
336
|
+
if (last) {
|
|
337
|
+
visit(clone2, seg.key);
|
|
338
|
+
} else {
|
|
339
|
+
clone2[seg.key] = transformAtMoneyPath(clone2[seg.key], path, segments, index + 1, visit, lenient);
|
|
340
|
+
}
|
|
341
|
+
return clone2;
|
|
342
|
+
}
|
|
343
|
+
if (seg.array) {
|
|
344
|
+
if (!Array.isArray(node)) {
|
|
345
|
+
if (lenient) return node;
|
|
346
|
+
throw new ValidationError(`moneyFields: path "${path}" declares "*[]" but the value is not an array`);
|
|
347
|
+
}
|
|
348
|
+
const cloned = [...node];
|
|
349
|
+
if (last) {
|
|
350
|
+
for (let i = 0; i < cloned.length; i++) visit(cloned, i);
|
|
351
|
+
} else {
|
|
352
|
+
for (let i = 0; i < cloned.length; i++) {
|
|
353
|
+
cloned[i] = transformAtMoneyPath(cloned[i], path, segments, index + 1, visit, lenient);
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
return cloned;
|
|
357
|
+
}
|
|
358
|
+
if (typeof node !== "object" || Array.isArray(node)) {
|
|
359
|
+
if (lenient) return node;
|
|
360
|
+
throw new ValidationError(
|
|
361
|
+
`moneyFields: path "${path}" applies "*" to a non-object (${Array.isArray(node) ? 'array \u2014 use "*[]"' : typeof node})`
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
const obj = node;
|
|
365
|
+
const clone = { ...obj };
|
|
366
|
+
for (const key of Object.keys(obj)) {
|
|
367
|
+
const v = clone[key];
|
|
368
|
+
if (v === null || v === void 0) continue;
|
|
369
|
+
if (last) visit(clone, key);
|
|
370
|
+
else clone[key] = transformAtMoneyPath(v, path, segments, index + 1, visit, lenient);
|
|
371
|
+
}
|
|
372
|
+
return clone;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// src/money/normalize.ts
|
|
376
|
+
function isMoneyValueObject(v) {
|
|
377
|
+
return typeof v === "object" && v !== null && "currency" in v;
|
|
378
|
+
}
|
|
379
|
+
function quantizeAmount(field, input, scale, rounding) {
|
|
380
|
+
const r = parseToScaledInt(input, scale, rounding);
|
|
381
|
+
if (!r.ok) {
|
|
382
|
+
if (r.reason === "precision") throw new MoneyPrecisionError(field, input, scale);
|
|
383
|
+
throw new TypeError(`money: field "${field}" value ${JSON.stringify(input)} is not a finite decimal`);
|
|
384
|
+
}
|
|
385
|
+
return r.value.toString();
|
|
386
|
+
}
|
|
387
|
+
function canonicalizeStoredMoney(record, moneyFields) {
|
|
388
|
+
if (record === null || record === void 0) return record;
|
|
389
|
+
if (!moneyFields || Object.keys(moneyFields).length === 0) return record;
|
|
390
|
+
return decodeMoneyFields(record, moneyFields, "raw");
|
|
391
|
+
}
|
|
392
|
+
function canonicalizeIncomingMoney(record, moneyFields) {
|
|
393
|
+
if (!moneyFields || Object.keys(moneyFields).length === 0) return record;
|
|
394
|
+
try {
|
|
395
|
+
return decodeMoneyFields(
|
|
396
|
+
quantizeMoneyFields(record, moneyFields),
|
|
397
|
+
moneyFields,
|
|
398
|
+
"raw"
|
|
399
|
+
);
|
|
400
|
+
} catch {
|
|
401
|
+
return record;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
function quantizeValue(field, raw, desc) {
|
|
405
|
+
if (desc.mode === "fixed") {
|
|
406
|
+
const currency2 = desc.fixedCurrency;
|
|
407
|
+
return quantizeAmount(field, raw, desc.scaleFor(currency2), desc.rounding);
|
|
408
|
+
}
|
|
409
|
+
let amount;
|
|
410
|
+
let currency;
|
|
411
|
+
if (isMoneyValueObject(raw)) {
|
|
412
|
+
currency = String(raw.currency);
|
|
413
|
+
amount = raw.amount;
|
|
414
|
+
} else {
|
|
415
|
+
const sole = desc.soleCurrency();
|
|
416
|
+
if (sole === void 0) {
|
|
417
|
+
throw new TypeError(
|
|
418
|
+
`money: field "${field}" is multi-currency \u2014 write { amount, currency }, not a bare amount`
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
currency = sole;
|
|
422
|
+
amount = raw;
|
|
423
|
+
}
|
|
424
|
+
const scale = desc.scaleFor(currency);
|
|
425
|
+
return { amount: quantizeAmount(field, amount, scale, desc.rounding), currency };
|
|
426
|
+
}
|
|
427
|
+
function quantizeMoneyFields(record, moneyFields) {
|
|
428
|
+
let out = { ...record };
|
|
429
|
+
for (const [path, desc] of Object.entries(moneyFields)) {
|
|
430
|
+
if (isSimpleMoneyPath(path)) {
|
|
431
|
+
const raw = out[path];
|
|
432
|
+
if (raw === null || raw === void 0) continue;
|
|
433
|
+
out[path] = quantizeValue(path, raw, desc);
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
out = transformAtMoneyPath(
|
|
437
|
+
out,
|
|
438
|
+
path,
|
|
439
|
+
parseMoneyPath(path),
|
|
440
|
+
0,
|
|
441
|
+
(container, key) => {
|
|
442
|
+
const raw = container[key];
|
|
443
|
+
if (raw === null || raw === void 0) return;
|
|
444
|
+
container[key] = quantizeValue(path, raw, desc);
|
|
445
|
+
},
|
|
446
|
+
/* lenient */
|
|
447
|
+
false
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
return out;
|
|
451
|
+
}
|
|
452
|
+
function formatCurrency(decimal, currency, scale, locale) {
|
|
453
|
+
const fmt = new Intl.NumberFormat(locale, {
|
|
454
|
+
style: "currency",
|
|
455
|
+
currency,
|
|
456
|
+
minimumFractionDigits: scale,
|
|
457
|
+
maximumFractionDigits: scale
|
|
458
|
+
});
|
|
459
|
+
return fmt.format(decimal);
|
|
460
|
+
}
|
|
461
|
+
function moneyScaledValue(stored, desc) {
|
|
462
|
+
let raw;
|
|
463
|
+
if (desc.mode === "fixed") {
|
|
464
|
+
raw = stored;
|
|
465
|
+
} else {
|
|
466
|
+
if (!isMoneyValueObject(stored)) return null;
|
|
467
|
+
raw = stored.amount;
|
|
468
|
+
}
|
|
469
|
+
if (typeof raw !== "string" && typeof raw !== "number") return null;
|
|
470
|
+
try {
|
|
471
|
+
return BigInt(String(raw));
|
|
472
|
+
} catch {
|
|
473
|
+
return null;
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
function decodeValue(stored, desc) {
|
|
477
|
+
let currency;
|
|
478
|
+
let scaledIntString;
|
|
479
|
+
if (desc.mode === "fixed") {
|
|
480
|
+
if (typeof stored !== "string" && typeof stored !== "number") return null;
|
|
481
|
+
currency = desc.fixedCurrency;
|
|
482
|
+
scaledIntString = String(stored);
|
|
483
|
+
} else {
|
|
484
|
+
if (!isMoneyValueObject(stored)) return null;
|
|
485
|
+
const amount = stored.amount;
|
|
486
|
+
if (typeof stored.currency !== "string" || typeof amount !== "string" && typeof amount !== "number") return null;
|
|
487
|
+
currency = stored.currency;
|
|
488
|
+
scaledIntString = String(amount);
|
|
489
|
+
}
|
|
490
|
+
const scale = desc.scaleFor(currency);
|
|
491
|
+
let decimal;
|
|
492
|
+
try {
|
|
493
|
+
decimal = formatScaledInt(BigInt(scaledIntString), scale);
|
|
494
|
+
} catch {
|
|
495
|
+
return null;
|
|
496
|
+
}
|
|
497
|
+
return {
|
|
498
|
+
decoded: desc.mode === "fixed" ? decimal : { amount: decimal, currency },
|
|
499
|
+
decimal,
|
|
500
|
+
currency,
|
|
501
|
+
scale
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
function decodeMoneyFields(record, moneyFields, locale) {
|
|
505
|
+
let out = { ...record };
|
|
506
|
+
const format = locale !== "raw";
|
|
507
|
+
const fmtLocale = typeof locale === "string" && locale !== "raw" ? locale : "en-US";
|
|
508
|
+
for (const [path, desc] of Object.entries(moneyFields)) {
|
|
509
|
+
if (isSimpleMoneyPath(path)) {
|
|
510
|
+
const stored = out[path];
|
|
511
|
+
if (stored === null || stored === void 0) continue;
|
|
512
|
+
const r = decodeValue(stored, desc);
|
|
513
|
+
if (r === null) continue;
|
|
514
|
+
out[path] = r.decoded;
|
|
515
|
+
if (format) {
|
|
516
|
+
out[`${path}Formatted`] = formatCurrency(r.decimal, r.currency, r.scale, fmtLocale);
|
|
517
|
+
out[`${path}Number`] = Number(r.decimal);
|
|
518
|
+
}
|
|
519
|
+
continue;
|
|
520
|
+
}
|
|
521
|
+
out = transformAtMoneyPath(
|
|
522
|
+
out,
|
|
523
|
+
path,
|
|
524
|
+
parseMoneyPath(path),
|
|
525
|
+
0,
|
|
526
|
+
(container, key) => {
|
|
527
|
+
const stored = container[key];
|
|
528
|
+
if (stored === null || stored === void 0) return;
|
|
529
|
+
const r = decodeValue(stored, desc);
|
|
530
|
+
if (r === null) return;
|
|
531
|
+
container[key] = r.decoded;
|
|
532
|
+
if (format && typeof key === "string" && !Array.isArray(container)) {
|
|
533
|
+
container[`${key}Formatted`] = formatCurrency(r.decimal, r.currency, r.scale, fmtLocale);
|
|
534
|
+
container[`${key}Number`] = Number(r.decimal);
|
|
535
|
+
}
|
|
536
|
+
},
|
|
537
|
+
/* lenient */
|
|
538
|
+
true
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
return out;
|
|
542
|
+
}
|
|
543
|
+
|
|
255
544
|
// src/query/builder.ts
|
|
256
545
|
var EMPTY_PLAN = {
|
|
257
546
|
clauses: [],
|
|
@@ -260,6 +549,7 @@ var EMPTY_PLAN = {
|
|
|
260
549
|
offset: 0,
|
|
261
550
|
joins: []
|
|
262
551
|
};
|
|
552
|
+
var DEFAULT_CROSS_JOIN_MAX_ROWS = 5e4;
|
|
263
553
|
var Query = class _Query {
|
|
264
554
|
source;
|
|
265
555
|
plan;
|
|
@@ -292,7 +582,7 @@ var Query = class _Query {
|
|
|
292
582
|
/**
|
|
293
583
|
* @internal — clone this Query with a declared-predicate map
|
|
294
584
|
* attached. Used by the materialized-view registry to enable
|
|
295
|
-
* `.wherePredicate(name, ctx?)` for the MV's query callback
|
|
585
|
+
* `.wherePredicate(name, ctx?)` for the MV's query callback.
|
|
296
586
|
* Consumers don't call this directly.
|
|
297
587
|
*/
|
|
298
588
|
_withPredicates(predicates) {
|
|
@@ -305,7 +595,7 @@ var Query = class _Query {
|
|
|
305
595
|
);
|
|
306
596
|
}
|
|
307
597
|
/**
|
|
308
|
-
* Filter by a registered deterministic predicate
|
|
598
|
+
* Filter by a registered deterministic predicate. Requires
|
|
309
599
|
* the Query to have been augmented with a predicates map (typically
|
|
310
600
|
* via the materialized-view registry — bare Queries constructed
|
|
311
601
|
* outside an MV throw on `.wherePredicate()`).
|
|
@@ -343,9 +633,18 @@ var Query = class _Query {
|
|
|
343
633
|
this.predicates
|
|
344
634
|
);
|
|
345
635
|
}
|
|
346
|
-
/**
|
|
636
|
+
/**
|
|
637
|
+
* Add a field comparison. Multiple where() calls are AND-combined.
|
|
638
|
+
*
|
|
639
|
+
* A declared money field compares in MAJOR units (#336): the operand
|
|
640
|
+
* (`10000`, `'10000.00'`, or `{ amount, currency }` in multi mode) is
|
|
641
|
+
* quantized into stored scaled-int space at build time and evaluated
|
|
642
|
+
* BigInt-exact per record. A malformed operand or a string operator
|
|
643
|
+
* (`contains`/`startsWith`) throws here, at the call site.
|
|
644
|
+
*/
|
|
347
645
|
where(field, op, value) {
|
|
348
|
-
const
|
|
646
|
+
const desc = this.source.moneyFields?.[field];
|
|
647
|
+
const clause = desc ? moneyFieldClause(field, op, value, desc) : { type: "field", field, op, value };
|
|
349
648
|
return new _Query(
|
|
350
649
|
this.source,
|
|
351
650
|
{ ...this.plan, clauses: [...this.plan.clauses, clause] },
|
|
@@ -411,11 +710,16 @@ var Query = class _Query {
|
|
|
411
710
|
this.predicates
|
|
412
711
|
);
|
|
413
712
|
}
|
|
414
|
-
/**
|
|
415
|
-
|
|
713
|
+
/**
|
|
714
|
+
* Sort by a field. Subsequent calls are tie-breakers. Pass
|
|
715
|
+
* `{ by: 'label' }` to sort a `dictKey`/`staticDict` field by its resolved
|
|
716
|
+
* label at the query locale instead of the stored code (#285).
|
|
717
|
+
*/
|
|
718
|
+
orderBy(field, direction = "asc", opts) {
|
|
719
|
+
const entry = opts?.by === "label" ? { field, direction, by: "label" } : { field, direction };
|
|
416
720
|
return new _Query(
|
|
417
721
|
this.source,
|
|
418
|
-
{ ...this.plan, orderBy: [...this.plan.orderBy,
|
|
722
|
+
{ ...this.plan, orderBy: [...this.plan.orderBy, entry] },
|
|
419
723
|
this.joinContext,
|
|
420
724
|
this.aggregateStrategy,
|
|
421
725
|
this.predicates
|
|
@@ -541,25 +845,119 @@ var Query = class _Query {
|
|
|
541
845
|
this.predicates
|
|
542
846
|
);
|
|
543
847
|
}
|
|
848
|
+
/**
|
|
849
|
+
* Cartesian-product cross-join against `target` collection. Each result row
|
|
850
|
+
* carries the original `T` fields plus `result[as]` populated from every
|
|
851
|
+
* right-side row (or the filtered subset when `on:` is supplied).
|
|
852
|
+
*
|
|
853
|
+
* **Order matters:** `.where().crossJoin()` filters BEFORE expanding (cheaper);
|
|
854
|
+
* `.crossJoin().where('alias.field', ...)` filters AFTER (required when the
|
|
855
|
+
* where clause references the aliased fields).
|
|
856
|
+
*
|
|
857
|
+
* **Cost ceiling:** `CrossJoinTooLargeError` fires before allocation when
|
|
858
|
+
* `leftRows × rightRows` (or the cumulative lateral count) exceeds the limit.
|
|
859
|
+
* Default: 50,000 rows. Override per-clause with `{ maxRows: N }`.
|
|
860
|
+
*
|
|
861
|
+
* **`on:` shapes:**
|
|
862
|
+
* - `on: (left) => TTarget[]` — subset form (most efficient)
|
|
863
|
+
* - `on: (left) => (right) => boolean` — predicate form
|
|
864
|
+
* - `on: { predicate: 'name' }` — MV-safe, hash-tracked form
|
|
865
|
+
* (requires the Query to have been augmented via `_withPredicates`)
|
|
866
|
+
*
|
|
867
|
+
* Requires a JoinContext (constructed via `collection.query()`).
|
|
868
|
+
*/
|
|
869
|
+
crossJoin(target, opts) {
|
|
870
|
+
if (!this.joinContext) {
|
|
871
|
+
throw new Error(
|
|
872
|
+
`Query.crossJoin("${target}"): requires a join context. Use collection.query() to construct a cross-join-capable Query instead of the Query constructor directly.`
|
|
873
|
+
);
|
|
874
|
+
}
|
|
875
|
+
let onFn;
|
|
876
|
+
let onPredicateName;
|
|
877
|
+
if (opts.on !== void 0) {
|
|
878
|
+
if (typeof opts.on === "function") {
|
|
879
|
+
onFn = opts.on;
|
|
880
|
+
if (this.predicates) {
|
|
881
|
+
console.warn(
|
|
882
|
+
`Query.crossJoin("${target}", { on: callback }): inline on: callback inside a withMaterializedView query() disables queryHash drift detection for this cross-join. Use on: { predicate: '<name>' } to enable it.`
|
|
883
|
+
);
|
|
884
|
+
}
|
|
885
|
+
} else {
|
|
886
|
+
const predName = opts.on.predicate;
|
|
887
|
+
if (!this.predicates) {
|
|
888
|
+
throw new Error(
|
|
889
|
+
`Query.crossJoin("${target}", { on: { predicate: "${predName}" } }): the { predicate } form requires a predicates map. Use this form inside a withMaterializedView query() callback that declares predicates: { ${predName}: { hash, fn } }.`
|
|
890
|
+
);
|
|
891
|
+
}
|
|
892
|
+
const decl = this.predicates.get(predName);
|
|
893
|
+
if (!decl) {
|
|
894
|
+
throw new Error(
|
|
895
|
+
`Query.crossJoin("${target}"): predicate "${predName}" not registered. Available: ${[...this.predicates.keys()].join(", ") || "(none)"}.`
|
|
896
|
+
);
|
|
897
|
+
}
|
|
898
|
+
const as = opts.as;
|
|
899
|
+
const predicateFn = decl.fn;
|
|
900
|
+
onFn = (_left) => (right) => predicateFn({ ..._left, [as]: right });
|
|
901
|
+
onPredicateName = predName;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
const clause = {
|
|
905
|
+
type: "crossJoin",
|
|
906
|
+
target,
|
|
907
|
+
as: opts.as,
|
|
908
|
+
...onFn !== void 0 && { on: onFn },
|
|
909
|
+
...onPredicateName !== void 0 && { onPredicateName },
|
|
910
|
+
...opts.maxRows !== void 0 && { maxRows: opts.maxRows }
|
|
911
|
+
};
|
|
912
|
+
return new _Query(
|
|
913
|
+
this.source,
|
|
914
|
+
{ ...this.plan, clauses: [...this.plan.clauses, clause] },
|
|
915
|
+
this.joinContext,
|
|
916
|
+
this.aggregateStrategy,
|
|
917
|
+
this.predicates
|
|
918
|
+
);
|
|
919
|
+
}
|
|
544
920
|
/**
|
|
545
921
|
* Execute the plan and return the matching records. When the plan
|
|
546
922
|
* carries any join legs, they are applied after `where` / `orderBy`
|
|
547
923
|
* / `limit` / `offset` narrow the left set. See the `.join()` doc
|
|
548
924
|
* for the ordering rationale.
|
|
925
|
+
*
|
|
926
|
+
* `opts.locale` (#285 §3) resolves JOINED right-side i18n fields at the
|
|
927
|
+
* `join` layer to that locale; without it, the owning collection's default
|
|
928
|
+
* locale applies, and a locale-less query leaves joined i18n fields raw.
|
|
929
|
+
* (Left/base i18n fields are resolved by `get`/`list`, not here.)
|
|
549
930
|
*/
|
|
550
|
-
toArray() {
|
|
551
|
-
const base = executePlanWithSource(this.source, this.plan);
|
|
931
|
+
toArray(opts) {
|
|
932
|
+
const base = this.decodeMoney(executePlanWithSource(this.source, this.plan, this.joinContext, opts?.locale));
|
|
552
933
|
if (this.plan.joins.length === 0) return base;
|
|
553
934
|
if (!this.joinContext) {
|
|
554
935
|
throw new Error(
|
|
555
936
|
`Query.toArray(): plan carries ${this.plan.joins.length} join leg(s) but no JoinContext is attached. This usually means the Query was constructed via the raw Query constructor with a plan that had joins pre-populated. Use collection.query().join(...) instead.`
|
|
556
937
|
);
|
|
557
938
|
}
|
|
558
|
-
return applyJoins(base, this.plan.joins, this.joinContext);
|
|
939
|
+
return applyJoins(base, this.plan.joins, this.joinContext, opts?.locale);
|
|
559
940
|
}
|
|
560
|
-
/**
|
|
561
|
-
|
|
562
|
-
|
|
941
|
+
/**
|
|
942
|
+
* Decode this source's money fields on read (stored scaled-int → canonical
|
|
943
|
+
* decimal), so `query().toArray()` agrees with `get()`/`sum()` on the value.
|
|
944
|
+
* No-op when the source declares no money fields.
|
|
945
|
+
*
|
|
946
|
+
* The query layer carries no locale context, so we decode with `'raw'` —
|
|
947
|
+
* canonical decimal, WITHOUT fabricating locale-formatted `<field>Formatted`
|
|
948
|
+
* / `<field>Number` virtuals. Producing a guessed-locale string here would
|
|
949
|
+
* just reintroduce #322's "two read paths disagree" failure on the virtual
|
|
950
|
+
* field (e.g. it-IT via `get()` vs en-US here). Consumers who need formatted
|
|
951
|
+
* money read through `get()`/`list()` with a locale.
|
|
952
|
+
*/
|
|
953
|
+
decodeMoney(records) {
|
|
954
|
+
const moneyFields = this.source.moneyFields;
|
|
955
|
+
if (!moneyFields || Object.keys(moneyFields).length === 0) return records;
|
|
956
|
+
return records.map((r) => decodeMoneyFields(r, moneyFields, "raw"));
|
|
957
|
+
}
|
|
958
|
+
/** Return the first matching record, or null. Joins are applied. `opts.locale` resolves joined i18n fields (#285 §3). */
|
|
959
|
+
first(opts) {
|
|
960
|
+
const arr = this.limit(1).toArray(opts);
|
|
563
961
|
return arr[0] ?? null;
|
|
564
962
|
}
|
|
565
963
|
/**
|
|
@@ -572,9 +970,17 @@ var Query = class _Query {
|
|
|
572
970
|
* intent is purely to count.
|
|
573
971
|
*/
|
|
574
972
|
count() {
|
|
973
|
+
if (this.plan.clauses.some((c) => c.type === "crossJoin")) {
|
|
974
|
+
if (!this.joinContext) {
|
|
975
|
+
throw new Error(
|
|
976
|
+
`Query.count(): plan contains crossJoin clauses but no JoinContext is attached.`
|
|
977
|
+
);
|
|
978
|
+
}
|
|
979
|
+
return executeClausePipeline(this.source, this.plan.clauses, this.joinContext).length;
|
|
980
|
+
}
|
|
575
981
|
const { candidates, remainingClauses } = candidateRecords(this.source, this.plan.clauses);
|
|
576
982
|
if (remainingClauses.length === 0) return candidates.length;
|
|
577
|
-
return filterRecords(candidates, remainingClauses).length;
|
|
983
|
+
return filterRecords(candidates, remainingClauses, fnViewDecoder(this.source)).length;
|
|
578
984
|
}
|
|
579
985
|
/**
|
|
580
986
|
* Reduce the matching records through a named set of reducers.
|
|
@@ -617,11 +1023,21 @@ var Query = class _Query {
|
|
|
617
1023
|
* partition boundaries without an API break.
|
|
618
1024
|
*/
|
|
619
1025
|
aggregate(spec) {
|
|
1026
|
+
const moneyFields = this.source.moneyFields;
|
|
1027
|
+
if (moneyFields) {
|
|
1028
|
+
spec = wrapMoneyReducers(spec, moneyFields);
|
|
1029
|
+
}
|
|
620
1030
|
const source = this.source;
|
|
621
1031
|
const clauses = this.plan.clauses;
|
|
1032
|
+
const joinCtx = this.joinContext;
|
|
1033
|
+
const hasCrossJoins = clauses.some((c) => c.type === "crossJoin");
|
|
622
1034
|
const executeRecords = () => {
|
|
1035
|
+
if (hasCrossJoins) {
|
|
1036
|
+
if (!joinCtx) throw new Error("Query.aggregate(): crossJoin requires a join context");
|
|
1037
|
+
return executeClausePipeline(source, clauses, joinCtx);
|
|
1038
|
+
}
|
|
623
1039
|
const { candidates, remainingClauses } = candidateRecords(source, clauses);
|
|
624
|
-
return remainingClauses.length === 0 ? candidates : filterRecords(candidates, remainingClauses);
|
|
1040
|
+
return remainingClauses.length === 0 ? candidates : filterRecords(candidates, remainingClauses, fnViewDecoder(source));
|
|
625
1041
|
};
|
|
626
1042
|
const upstreams = [];
|
|
627
1043
|
if (source.subscribe) {
|
|
@@ -636,9 +1052,15 @@ var Query = class _Query {
|
|
|
636
1052
|
}
|
|
637
1053
|
const source = this.source;
|
|
638
1054
|
const clauses = this.plan.clauses;
|
|
1055
|
+
const joinCtx = this.joinContext;
|
|
1056
|
+
const hasCrossJoins = clauses.some((c) => c.type === "crossJoin");
|
|
639
1057
|
const executeRecords = () => {
|
|
1058
|
+
if (hasCrossJoins) {
|
|
1059
|
+
if (!joinCtx) throw new Error("Query.groupBy(): crossJoin requires a join context");
|
|
1060
|
+
return executeClausePipeline(source, clauses, joinCtx);
|
|
1061
|
+
}
|
|
640
1062
|
const { candidates, remainingClauses } = candidateRecords(source, clauses);
|
|
641
|
-
return remainingClauses.length === 0 ? candidates : filterRecords(candidates, remainingClauses);
|
|
1063
|
+
return remainingClauses.length === 0 ? candidates : filterRecords(candidates, remainingClauses, fnViewDecoder(source));
|
|
642
1064
|
};
|
|
643
1065
|
const upstreams = [];
|
|
644
1066
|
if (source.subscribe) {
|
|
@@ -652,13 +1074,15 @@ var Query = class _Query {
|
|
|
652
1074
|
executeRecords,
|
|
653
1075
|
field,
|
|
654
1076
|
upstreams,
|
|
655
|
-
dictLabelResolver
|
|
1077
|
+
dictLabelResolver,
|
|
1078
|
+
this.source.moneyFields
|
|
656
1079
|
);
|
|
657
1080
|
}
|
|
658
1081
|
return this.aggregateStrategy.groupByN(
|
|
659
1082
|
executeRecords,
|
|
660
1083
|
fields,
|
|
661
|
-
upstreams
|
|
1084
|
+
upstreams,
|
|
1085
|
+
this.source.moneyFields
|
|
662
1086
|
);
|
|
663
1087
|
}
|
|
664
1088
|
/**
|
|
@@ -750,6 +1174,21 @@ var Query = class _Query {
|
|
|
750
1174
|
}
|
|
751
1175
|
}
|
|
752
1176
|
}
|
|
1177
|
+
if (this.joinContext) {
|
|
1178
|
+
const subscribedCross = /* @__PURE__ */ new Set();
|
|
1179
|
+
for (const clause of this.plan.clauses) {
|
|
1180
|
+
if (clause.type !== "crossJoin") continue;
|
|
1181
|
+
if (subscribedCross.has(clause.target)) continue;
|
|
1182
|
+
subscribedCross.add(clause.target);
|
|
1183
|
+
const rightSource = this.joinContext.resolveSource(clause.target);
|
|
1184
|
+
if (rightSource?.subscribe) {
|
|
1185
|
+
const rightSubscribe = rightSource.subscribe.bind(rightSource);
|
|
1186
|
+
upstreams.push({
|
|
1187
|
+
subscribe: (cb) => rightSubscribe(cb)
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
753
1192
|
return buildLiveQuery(() => this.toArray(), upstreams);
|
|
754
1193
|
}
|
|
755
1194
|
/**
|
|
@@ -761,11 +1200,23 @@ var Query = class _Query {
|
|
|
761
1200
|
return serializePlan(this.plan);
|
|
762
1201
|
}
|
|
763
1202
|
};
|
|
764
|
-
function executePlanWithSource(source, plan) {
|
|
765
|
-
const
|
|
766
|
-
let result
|
|
1203
|
+
function executePlanWithSource(source, plan, joinContext, locale) {
|
|
1204
|
+
const hasCrossJoins = plan.clauses.some((c) => c.type === "crossJoin");
|
|
1205
|
+
let result;
|
|
1206
|
+
if (hasCrossJoins) {
|
|
1207
|
+
if (!joinContext) {
|
|
1208
|
+
throw new Error(
|
|
1209
|
+
`Query.toArray(): plan contains crossJoin clauses but no JoinContext is attached. Use collection.query() instead of new Query() for cross-join support.`
|
|
1210
|
+
);
|
|
1211
|
+
}
|
|
1212
|
+
result = executeClausePipeline(source, plan.clauses, joinContext);
|
|
1213
|
+
} else {
|
|
1214
|
+
const { candidates, remainingClauses } = candidateRecords(source, plan.clauses);
|
|
1215
|
+
result = remainingClauses.length === 0 ? [...candidates] : filterRecords(candidates, remainingClauses, fnViewDecoder(source));
|
|
1216
|
+
}
|
|
767
1217
|
if (plan.orderBy.length > 0) {
|
|
768
|
-
|
|
1218
|
+
const labelMaps = buildOrderLabelMaps(plan.orderBy, joinContext, locale);
|
|
1219
|
+
result = sortRecords(result, plan.orderBy, source.moneyFields, labelMaps);
|
|
769
1220
|
}
|
|
770
1221
|
if (plan.offset > 0) {
|
|
771
1222
|
result = result.slice(plan.offset);
|
|
@@ -785,6 +1236,7 @@ function candidateRecords(source, clauses) {
|
|
|
785
1236
|
const clause = clauses[i];
|
|
786
1237
|
if (clause.type !== "field") continue;
|
|
787
1238
|
if (!indexes.has(clause.field)) continue;
|
|
1239
|
+
if (clause.money?.mode === "multi") continue;
|
|
788
1240
|
let ids = null;
|
|
789
1241
|
if (clause.op === "==") {
|
|
790
1242
|
ids = indexes.lookupEqual(clause.field, clause.value);
|
|
@@ -813,6 +1265,11 @@ function materializeIds(ids, lookupById) {
|
|
|
813
1265
|
return out;
|
|
814
1266
|
}
|
|
815
1267
|
function executePlan(records, plan) {
|
|
1268
|
+
if (plan.clauses.some((c) => c.type === "crossJoin")) {
|
|
1269
|
+
throw new Error(
|
|
1270
|
+
`executePlan(): does not support crossJoin clauses. executePlan is a stateless pure function \u2014 it cannot resolve cross-join right-side collections. Use Query.toArray() (via collection.query()) instead.`
|
|
1271
|
+
);
|
|
1272
|
+
}
|
|
816
1273
|
let result = filterRecords(records, plan.clauses);
|
|
817
1274
|
if (plan.orderBy.length > 0) {
|
|
818
1275
|
result = sortRecords(result, plan.orderBy);
|
|
@@ -825,13 +1282,20 @@ function executePlan(records, plan) {
|
|
|
825
1282
|
}
|
|
826
1283
|
return result;
|
|
827
1284
|
}
|
|
828
|
-
function
|
|
1285
|
+
function fnViewDecoder(source) {
|
|
1286
|
+
const mf = source.moneyFields;
|
|
1287
|
+
if (!mf || Object.keys(mf).length === 0) return void 0;
|
|
1288
|
+
return (r) => decodeMoneyFields(r, mf, "raw");
|
|
1289
|
+
}
|
|
1290
|
+
function filterRecords(records, clauses, decodeForFns) {
|
|
829
1291
|
if (clauses.length === 0) return [...records];
|
|
1292
|
+
const needsFnView = decodeForFns !== void 0 && hasFnClause(clauses);
|
|
830
1293
|
const out = [];
|
|
831
1294
|
for (const r of records) {
|
|
1295
|
+
const fnView = needsFnView ? decodeForFns(r) : void 0;
|
|
832
1296
|
let matches = true;
|
|
833
1297
|
for (const clause of clauses) {
|
|
834
|
-
if (!evaluateClause(r, clause)) {
|
|
1298
|
+
if (!evaluateClause(r, clause, fnView)) {
|
|
835
1299
|
matches = false;
|
|
836
1300
|
break;
|
|
837
1301
|
}
|
|
@@ -840,17 +1304,124 @@ function filterRecords(records, clauses) {
|
|
|
840
1304
|
}
|
|
841
1305
|
return out;
|
|
842
1306
|
}
|
|
843
|
-
function
|
|
1307
|
+
function executeClausePipeline(source, clauses, joinContext) {
|
|
1308
|
+
let rel = [...source.snapshot()];
|
|
1309
|
+
let filterBatch = [];
|
|
1310
|
+
const decodeForFns = fnViewDecoder(source);
|
|
1311
|
+
for (const clause of clauses) {
|
|
1312
|
+
if (clause.type === "crossJoin") {
|
|
1313
|
+
if (filterBatch.length > 0) {
|
|
1314
|
+
rel = filterRecords(rel, filterBatch, decodeForFns);
|
|
1315
|
+
filterBatch = [];
|
|
1316
|
+
}
|
|
1317
|
+
const rightSource = joinContext.resolveSource(clause.target);
|
|
1318
|
+
if (!rightSource) {
|
|
1319
|
+
throw new CrossJoinSourceUnknownError(clause.target, joinContext.leftCollection);
|
|
1320
|
+
}
|
|
1321
|
+
rel = applyCrossJoin(rel, clause, rightSource);
|
|
1322
|
+
} else {
|
|
1323
|
+
filterBatch.push(clause);
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
if (filterBatch.length > 0) {
|
|
1327
|
+
rel = filterRecords(rel, filterBatch, decodeForFns);
|
|
1328
|
+
}
|
|
1329
|
+
return rel;
|
|
1330
|
+
}
|
|
1331
|
+
function applyCrossJoin(leftRel, clause, rightSource) {
|
|
1332
|
+
const rightRows = rightSource.snapshot();
|
|
1333
|
+
const maxRows = clause.maxRows ?? DEFAULT_CROSS_JOIN_MAX_ROWS;
|
|
1334
|
+
const { as } = clause;
|
|
1335
|
+
if (!clause.on) {
|
|
1336
|
+
const product = leftRel.length * rightRows.length;
|
|
1337
|
+
if (product > maxRows) {
|
|
1338
|
+
throw new CrossJoinTooLargeError({ target: clause.target, expected: product, limit: maxRows });
|
|
1339
|
+
}
|
|
1340
|
+
const expanded2 = [];
|
|
1341
|
+
for (const left of leftRel) {
|
|
1342
|
+
const leftObj = left;
|
|
1343
|
+
for (const right of rightRows) {
|
|
1344
|
+
expanded2.push({ ...leftObj, [as]: right });
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
return expanded2;
|
|
1348
|
+
}
|
|
1349
|
+
const expanded = [];
|
|
1350
|
+
let cumulative = 0;
|
|
1351
|
+
for (const left of leftRel) {
|
|
1352
|
+
const callbackResult = clause.on(left);
|
|
1353
|
+
let filteredRight;
|
|
1354
|
+
if (Array.isArray(callbackResult)) {
|
|
1355
|
+
filteredRight = callbackResult;
|
|
1356
|
+
} else {
|
|
1357
|
+
filteredRight = rightRows.filter(
|
|
1358
|
+
callbackResult
|
|
1359
|
+
);
|
|
1360
|
+
}
|
|
1361
|
+
cumulative += filteredRight.length;
|
|
1362
|
+
if (cumulative > maxRows) {
|
|
1363
|
+
throw new CrossJoinTooLargeError({
|
|
1364
|
+
target: clause.target,
|
|
1365
|
+
expected: cumulative,
|
|
1366
|
+
limit: maxRows
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1369
|
+
const leftObj = left;
|
|
1370
|
+
for (const right of filteredRight) {
|
|
1371
|
+
expanded.push({ ...leftObj, [as]: right });
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
return expanded;
|
|
1375
|
+
}
|
|
1376
|
+
function sortRecords(records, orderBy, moneyFields, labelMaps) {
|
|
844
1377
|
return [...records].sort((a, b) => {
|
|
845
|
-
for (const { field, direction } of orderBy) {
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
const
|
|
1378
|
+
for (const { field, direction, by } of orderBy) {
|
|
1379
|
+
let av = readField(a, field);
|
|
1380
|
+
let bv = readField(b, field);
|
|
1381
|
+
const labelMap = by === "label" ? labelMaps?.get(field) : void 0;
|
|
1382
|
+
if (labelMap) {
|
|
1383
|
+
av = (typeof av === "string" ? labelMap.get(av) : void 0) ?? av;
|
|
1384
|
+
bv = (typeof bv === "string" ? labelMap.get(bv) : void 0) ?? bv;
|
|
1385
|
+
const cmp2 = compareValues(av, bv);
|
|
1386
|
+
if (cmp2 !== 0) return direction === "asc" ? cmp2 : -cmp2;
|
|
1387
|
+
continue;
|
|
1388
|
+
}
|
|
1389
|
+
const desc = moneyFields?.[field];
|
|
1390
|
+
const cmp = desc ? compareMoney(av, bv, desc) : compareValues(av, bv);
|
|
849
1391
|
if (cmp !== 0) return direction === "asc" ? cmp : -cmp;
|
|
850
1392
|
}
|
|
851
1393
|
return 0;
|
|
852
1394
|
});
|
|
853
1395
|
}
|
|
1396
|
+
function buildOrderLabelMaps(orderBy, joinContext, locale) {
|
|
1397
|
+
if (!joinContext?.resolveDictSource) return void 0;
|
|
1398
|
+
const resolveDict = joinContext.resolveDictSource.bind(joinContext);
|
|
1399
|
+
let maps;
|
|
1400
|
+
for (const { field, by } of orderBy) {
|
|
1401
|
+
if (by !== "label") continue;
|
|
1402
|
+
const dictSource = resolveDict(field);
|
|
1403
|
+
if (!dictSource) continue;
|
|
1404
|
+
const loc = locale ?? dictSource.displayLocale;
|
|
1405
|
+
if (loc === void 0) continue;
|
|
1406
|
+
const codeToLabel = /* @__PURE__ */ new Map();
|
|
1407
|
+
for (const entry of dictSource.snapshot()) {
|
|
1408
|
+
const k = entry["key"];
|
|
1409
|
+
const labels = entry["labels"];
|
|
1410
|
+
const label = labels?.[loc];
|
|
1411
|
+
if (typeof k === "string" && typeof label === "string") codeToLabel.set(k, label);
|
|
1412
|
+
}
|
|
1413
|
+
;
|
|
1414
|
+
(maps ??= /* @__PURE__ */ new Map()).set(field, codeToLabel);
|
|
1415
|
+
}
|
|
1416
|
+
return maps;
|
|
1417
|
+
}
|
|
1418
|
+
function compareMoney(a, b, desc) {
|
|
1419
|
+
const av = moneyScaledValue(a, desc);
|
|
1420
|
+
const bv = moneyScaledValue(b, desc);
|
|
1421
|
+
if (av === null) return bv === null ? 0 : 1;
|
|
1422
|
+
if (bv === null) return -1;
|
|
1423
|
+
return av < bv ? -1 : av > bv ? 1 : 0;
|
|
1424
|
+
}
|
|
854
1425
|
function readField(record, field) {
|
|
855
1426
|
if (record === null || record === void 0) return void 0;
|
|
856
1427
|
if (!field.includes(".")) {
|
|
@@ -902,6 +1473,16 @@ function serializeClause(clause) {
|
|
|
902
1473
|
clauses: clause.clauses.map(serializeClause)
|
|
903
1474
|
};
|
|
904
1475
|
}
|
|
1476
|
+
if (clause.type === "crossJoin") {
|
|
1477
|
+
return {
|
|
1478
|
+
type: "crossJoin",
|
|
1479
|
+
target: clause.target,
|
|
1480
|
+
as: clause.as,
|
|
1481
|
+
on: clause.on ? "[function]" : void 0,
|
|
1482
|
+
onPredicateName: clause.onPredicateName,
|
|
1483
|
+
maxRows: clause.maxRows
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
905
1486
|
return clause;
|
|
906
1487
|
}
|
|
907
1488
|
function canonicalCtxHash(ctx) {
|
|
@@ -927,6 +1508,7 @@ function buildDictLabelResolver(joinCtx, field) {
|
|
|
927
1508
|
const dictSource = joinCtx.resolveDictSource(field);
|
|
928
1509
|
if (!dictSource) return void 0;
|
|
929
1510
|
const snapshot = dictSource.snapshot();
|
|
1511
|
+
const displayLocale = dictSource.displayLocale;
|
|
930
1512
|
const dictMap = /* @__PURE__ */ new Map();
|
|
931
1513
|
for (const entry of snapshot) {
|
|
932
1514
|
const k = entry["key"];
|
|
@@ -936,9 +1518,11 @@ function buildDictLabelResolver(joinCtx, field) {
|
|
|
936
1518
|
}
|
|
937
1519
|
}
|
|
938
1520
|
return async (key, locale, fallback) => {
|
|
1521
|
+
const effLocale = locale || displayLocale;
|
|
1522
|
+
if (!effLocale) return void 0;
|
|
939
1523
|
const labels = dictMap.get(key);
|
|
940
1524
|
if (!labels) return void 0;
|
|
941
|
-
if (labels[
|
|
1525
|
+
if (labels[effLocale] !== void 0) return labels[effLocale];
|
|
942
1526
|
const chain = Array.isArray(fallback) ? fallback : fallback ? [fallback] : [];
|
|
943
1527
|
for (const fb of chain) {
|
|
944
1528
|
if (fb === "any") {
|
|
@@ -978,12 +1562,29 @@ var ScanBuilder = class _ScanBuilder {
|
|
|
978
1562
|
* context throws with an actionable error.
|
|
979
1563
|
*/
|
|
980
1564
|
joinContext;
|
|
981
|
-
|
|
1565
|
+
/**
|
|
1566
|
+
* Money field descriptors for the backing collection. When present, yielded
|
|
1567
|
+
* records are decoded (stored scaled-int → canonical decimal) so `scan()`
|
|
1568
|
+
* agrees with `get()`/`list()`/`query().toArray()` — #322. Decoded with
|
|
1569
|
+
* `'raw'` (canonical decimal, no locale-formatted virtuals) since the scan
|
|
1570
|
+
* stream carries no locale context, mirroring `Query.toArray()`.
|
|
1571
|
+
*/
|
|
1572
|
+
moneyFields;
|
|
1573
|
+
constructor(pageProvider, pageSize = DEFAULT_SCAN_PAGE_SIZE, clauses = [], joins = [], joinContext, moneyFields) {
|
|
982
1574
|
this.pageProvider = pageProvider;
|
|
983
1575
|
this.pageSize = pageSize;
|
|
984
1576
|
this.clauses = clauses;
|
|
985
1577
|
this.joins = joins;
|
|
986
1578
|
this.joinContext = joinContext;
|
|
1579
|
+
this.moneyFields = moneyFields;
|
|
1580
|
+
}
|
|
1581
|
+
/**
|
|
1582
|
+
* Decode this scan's money fields on a record (stored scaled-int → canonical
|
|
1583
|
+
* decimal). No-op when no money fields are declared. See {@link moneyFields}.
|
|
1584
|
+
*/
|
|
1585
|
+
decodeMoney(record) {
|
|
1586
|
+
if (!this.moneyFields || Object.keys(this.moneyFields).length === 0) return record;
|
|
1587
|
+
return decodeMoneyFields(record, this.moneyFields, "raw");
|
|
987
1588
|
}
|
|
988
1589
|
/**
|
|
989
1590
|
* Add a field comparison. Runs per record as the scan stream
|
|
@@ -999,13 +1600,15 @@ var ScanBuilder = class _ScanBuilder {
|
|
|
999
1600
|
* evaluates clauses per record in O(1) per clause.
|
|
1000
1601
|
*/
|
|
1001
1602
|
where(field, op, value) {
|
|
1002
|
-
const
|
|
1603
|
+
const desc = this.moneyFields?.[field];
|
|
1604
|
+
const clause = desc ? moneyFieldClause(field, op, value, desc) : { type: "field", field, op, value };
|
|
1003
1605
|
return new _ScanBuilder(
|
|
1004
1606
|
this.pageProvider,
|
|
1005
1607
|
this.pageSize,
|
|
1006
1608
|
[...this.clauses, clause],
|
|
1007
1609
|
this.joins,
|
|
1008
|
-
this.joinContext
|
|
1610
|
+
this.joinContext,
|
|
1611
|
+
this.moneyFields
|
|
1009
1612
|
);
|
|
1010
1613
|
}
|
|
1011
1614
|
/**
|
|
@@ -1024,7 +1627,8 @@ var ScanBuilder = class _ScanBuilder {
|
|
|
1024
1627
|
this.pageSize,
|
|
1025
1628
|
[...this.clauses, clause],
|
|
1026
1629
|
this.joins,
|
|
1027
|
-
this.joinContext
|
|
1630
|
+
this.joinContext,
|
|
1631
|
+
this.moneyFields
|
|
1028
1632
|
);
|
|
1029
1633
|
}
|
|
1030
1634
|
/**
|
|
@@ -1135,7 +1739,8 @@ var ScanBuilder = class _ScanBuilder {
|
|
|
1135
1739
|
this.pageSize,
|
|
1136
1740
|
this.clauses,
|
|
1137
1741
|
[...this.joins, leg],
|
|
1138
|
-
this.joinContext
|
|
1742
|
+
this.joinContext,
|
|
1743
|
+
this.moneyFields
|
|
1139
1744
|
);
|
|
1140
1745
|
}
|
|
1141
1746
|
/**
|
|
@@ -1152,10 +1757,11 @@ var ScanBuilder = class _ScanBuilder {
|
|
|
1152
1757
|
while (true) {
|
|
1153
1758
|
for (const record of page.items) {
|
|
1154
1759
|
if (!this.recordMatches(record)) continue;
|
|
1760
|
+
const decoded = this.decodeMoney(record);
|
|
1155
1761
|
if (joinResolvers === null) {
|
|
1156
|
-
yield
|
|
1762
|
+
yield decoded;
|
|
1157
1763
|
} else {
|
|
1158
|
-
let attached =
|
|
1764
|
+
let attached = decoded;
|
|
1159
1765
|
for (const resolver of joinResolvers) {
|
|
1160
1766
|
attached = this.applyOneJoinStreaming(attached, resolver);
|
|
1161
1767
|
}
|
|
@@ -1341,8 +1947,9 @@ var ScanBuilder = class _ScanBuilder {
|
|
|
1341
1947
|
*/
|
|
1342
1948
|
recordMatches(record) {
|
|
1343
1949
|
if (this.clauses.length === 0) return true;
|
|
1950
|
+
const fnView = this.moneyFields && Object.keys(this.moneyFields).length > 0 && hasFnClause(this.clauses) ? this.decodeMoney(record) : void 0;
|
|
1344
1951
|
for (const clause of this.clauses) {
|
|
1345
|
-
if (!evaluateClause(record, clause)) return false;
|
|
1952
|
+
if (!evaluateClause(record, clause, fnView)) return false;
|
|
1346
1953
|
}
|
|
1347
1954
|
return true;
|
|
1348
1955
|
}
|
|
@@ -1355,13 +1962,19 @@ function coerceRefKey2(value) {
|
|
|
1355
1962
|
}
|
|
1356
1963
|
|
|
1357
1964
|
export {
|
|
1965
|
+
validateMoneyFieldPaths,
|
|
1966
|
+
canonicalizeStoredMoney,
|
|
1967
|
+
canonicalizeIncomingMoney,
|
|
1968
|
+
quantizeMoneyFields,
|
|
1969
|
+
decodeMoneyFields,
|
|
1358
1970
|
DEFAULT_JOIN_MAX_ROWS,
|
|
1359
1971
|
applyJoins,
|
|
1360
1972
|
resetJoinWarnings,
|
|
1361
1973
|
buildLiveQuery,
|
|
1362
1974
|
NO_AGGREGATE,
|
|
1975
|
+
DEFAULT_CROSS_JOIN_MAX_ROWS,
|
|
1363
1976
|
Query,
|
|
1364
1977
|
executePlan,
|
|
1365
1978
|
ScanBuilder
|
|
1366
1979
|
};
|
|
1367
|
-
//# sourceMappingURL=chunk-
|
|
1980
|
+
//# sourceMappingURL=chunk-NV4IHBZS.js.map
|