@noy-db/hub 0.2.0-pre.9 → 0.3.0-pre.1
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 +129 -3
- package/dist/adapter/index.d.ts +5 -0
- package/dist/adapter/index.js +15 -0
- package/dist/aggregate/index.d.ts +6 -2
- package/dist/aggregate/index.js +24 -16
- package/dist/aggregate/index.js.map +1 -1
- package/dist/api-RW3KP7WU.js +14 -0
- package/dist/as/index.d.ts +7 -0
- package/dist/as/index.js +24 -0
- package/dist/at/index.d.ts +5 -0
- package/dist/at/index.js +1 -0
- package/dist/attestation/index.d.ts +15 -47
- package/dist/attestation/index.js +54 -10
- package/dist/attestation/index.js.map +1 -1
- package/dist/backup-XV3IOEGB.js +217 -0
- package/dist/backup-XV3IOEGB.js.map +1 -0
- package/dist/blobs/index.d.ts +6 -8
- package/dist/blobs/index.js +19 -12
- package/dist/blobs/index.js.map +1 -1
- package/dist/bundle/index.d.ts +16 -70
- package/dist/bundle/index.js +39 -476
- package/dist/bundle/index.js.map +1 -1
- package/dist/{ulid-CJ8RzRrm.d.ts → bundle-CH-H06dp.d.ts} +31 -86
- package/dist/by/index.d.ts +1 -0
- package/dist/by/index.js +11 -0
- package/dist/cargo/index.d.ts +9 -0
- package/dist/cargo/index.js +89 -0
- package/dist/chunk-26LGBE4T.js +42 -0
- package/dist/chunk-26LGBE4T.js.map +1 -0
- package/dist/chunk-2P2HZEXU.js +233 -0
- package/dist/chunk-2P2HZEXU.js.map +1 -0
- package/dist/{chunk-K3DK3NU5.js → chunk-3YFXJ3ZP.js} +20 -5
- package/dist/chunk-3YFXJ3ZP.js.map +1 -0
- package/dist/chunk-4Q6HSHHL.js +90 -0
- package/dist/chunk-4Q6HSHHL.js.map +1 -0
- package/dist/chunk-5LUY7UTV.js +380 -0
- package/dist/chunk-5LUY7UTV.js.map +1 -0
- package/dist/chunk-5N6CZTCY.js +367 -0
- package/dist/chunk-5N6CZTCY.js.map +1 -0
- package/dist/chunk-5O3AOPDT.js +992 -0
- package/dist/chunk-5O3AOPDT.js.map +1 -0
- package/dist/chunk-5R3ERCDH.js +239 -0
- package/dist/chunk-5R3ERCDH.js.map +1 -0
- package/dist/{chunk-6CME4UEK.js → chunk-5R5JW2JT.js} +7000 -4827
- package/dist/chunk-5R5JW2JT.js.map +1 -0
- package/dist/chunk-5TDJ56JE.js +32 -0
- package/dist/chunk-5TDJ56JE.js.map +1 -0
- package/dist/{chunk-T7JEBOGN.js → chunk-62QYRORB.js} +18 -11
- package/dist/chunk-62QYRORB.js.map +1 -0
- package/dist/{chunk-J66GRPNH.js → chunk-6S7T6WC4.js} +2 -2
- package/dist/chunk-6S7T6WC4.js.map +1 -0
- package/dist/chunk-76722EBH.js +451 -0
- package/dist/chunk-76722EBH.js.map +1 -0
- package/dist/{chunk-Z6FNBOTC.js → chunk-AIWULCUO.js} +13 -17
- package/dist/chunk-AIWULCUO.js.map +1 -0
- package/dist/{chunk-O3VZPBZG.js → chunk-AQTBSL7R.js} +47 -11
- package/dist/chunk-AQTBSL7R.js.map +1 -0
- package/dist/chunk-AURFOK3D.js +35 -0
- package/dist/chunk-AURFOK3D.js.map +1 -0
- package/dist/{chunk-53XBRIRT.js → chunk-AXRXJTE2.js} +9 -9
- package/dist/chunk-AXRXJTE2.js.map +1 -0
- package/dist/chunk-AZAOEIKW.js +155 -0
- package/dist/chunk-AZAOEIKW.js.map +1 -0
- package/dist/{chunk-HNRHLRDC.js → chunk-BG3SPSR4.js} +3 -3
- package/dist/chunk-BG3SPSR4.js.map +1 -0
- package/dist/chunk-BGIZAFY7.js +1 -0
- package/dist/chunk-CHFZDSE4.js +1 -0
- package/dist/{chunk-DJHHA6XH.js → chunk-CMGR4ZEW.js} +50 -20
- package/dist/chunk-CMGR4ZEW.js.map +1 -0
- package/dist/chunk-CWPPNPOH.js +23 -0
- package/dist/chunk-CWPPNPOH.js.map +1 -0
- package/dist/{chunk-QODLLGQ7.js → chunk-DFEMTNPJ.js} +371 -38
- package/dist/chunk-DFEMTNPJ.js.map +1 -0
- package/dist/{chunk-ZYWZWG6G.js → chunk-DGDI2D4M.js} +10 -10
- package/dist/chunk-DGDI2D4M.js.map +1 -0
- package/dist/{chunk-SYMWGEET.js → chunk-EIZUR2XW.js} +3 -3
- package/dist/chunk-EIZUR2XW.js.map +1 -0
- package/dist/{chunk-BVRYKATC.js → chunk-FISN7WE4.js} +36 -33
- package/dist/chunk-FISN7WE4.js.map +1 -0
- package/dist/chunk-GHVIKOHT.js +1 -0
- package/dist/chunk-GYGWYIOZ.js +200 -0
- package/dist/chunk-GYGWYIOZ.js.map +1 -0
- package/dist/chunk-HCIPRAGS.js +45 -0
- package/dist/chunk-HCIPRAGS.js.map +1 -0
- package/dist/{chunk-PX35GA7L.js → chunk-I2NOIW44.js} +10 -10
- package/dist/chunk-I2NOIW44.js.map +1 -0
- package/dist/{chunk-OIF6LZUR.js → chunk-I3TIKTJO.js} +3 -3
- package/dist/chunk-I3TIKTJO.js.map +1 -0
- package/dist/chunk-I7FD46FF.js +9 -0
- package/dist/chunk-I7FD46FF.js.map +1 -0
- package/dist/chunk-IAGBDSCS.js +40 -0
- package/dist/chunk-IAGBDSCS.js.map +1 -0
- package/dist/{chunk-JWRVQKRZ.js → chunk-IELYAOGG.js} +6 -18
- package/dist/chunk-IELYAOGG.js.map +1 -0
- package/dist/chunk-IGUYVGGI.js +205 -0
- package/dist/chunk-IGUYVGGI.js.map +1 -0
- package/dist/{chunk-U26HQ6KJ.js → chunk-IO6GRPT6.js} +4 -4
- package/dist/chunk-IO6GRPT6.js.map +1 -0
- package/dist/chunk-IPB7FTQX.js +273 -0
- package/dist/chunk-IPB7FTQX.js.map +1 -0
- package/dist/chunk-ITNUCOXM.js +148 -0
- package/dist/chunk-ITNUCOXM.js.map +1 -0
- package/dist/{chunk-WPLVTJ5D.js → chunk-IUEN57TV.js} +10 -10
- package/dist/chunk-IUEN57TV.js.map +1 -0
- package/dist/{chunk-DL3HWOQ5.js → chunk-JNUWZ6D3.js} +9 -9
- package/dist/chunk-JNUWZ6D3.js.map +1 -0
- package/dist/chunk-K2WCO3NX.js +1 -0
- package/dist/chunk-KVOXU4T5.js +30 -0
- package/dist/chunk-KVOXU4T5.js.map +1 -0
- package/dist/chunk-KXGNJJXB.js +135 -0
- package/dist/chunk-KXGNJJXB.js.map +1 -0
- package/dist/chunk-LB7FD65R.js +163 -0
- package/dist/chunk-LB7FD65R.js.map +1 -0
- package/dist/{chunk-22DWZL57.js → chunk-LFLXAY2W.js} +43 -218
- package/dist/chunk-LFLXAY2W.js.map +1 -0
- package/dist/chunk-LMTH2RM6.js +129 -0
- package/dist/chunk-LMTH2RM6.js.map +1 -0
- package/dist/{aggregate/index.cjs → chunk-LV7M27WM.js} +390 -219
- package/dist/chunk-LV7M27WM.js.map +1 -0
- package/dist/{chunk-PE2FR4J3.js → chunk-LXQT4WMP.js} +16 -18
- package/dist/chunk-LXQT4WMP.js.map +1 -0
- package/dist/chunk-M2YKN37S.js +524 -0
- package/dist/chunk-M2YKN37S.js.map +1 -0
- package/dist/chunk-M6OST55S.js +14 -0
- package/dist/chunk-M6OST55S.js.map +1 -0
- package/dist/{chunk-F3GDRNUT.js → chunk-MD3Y6J3L.js} +35 -69
- package/dist/chunk-MD3Y6J3L.js.map +1 -0
- package/dist/{chunk-XJFLDA7A.js → chunk-MTMJVJ5W.js} +8 -7
- package/dist/chunk-MTMJVJ5W.js.map +1 -0
- package/dist/{chunk-DFMLEQZB.js → chunk-NF5JWERG.js} +5 -10
- package/dist/chunk-NF5JWERG.js.map +1 -0
- package/dist/{chunk-DO7C2TOG.js → chunk-PKHL44ER.js} +3 -3
- package/dist/{chunk-DO7C2TOG.js.map → chunk-PKHL44ER.js.map} +1 -1
- package/dist/chunk-PSMV73A5.js +117 -0
- package/dist/chunk-PSMV73A5.js.map +1 -0
- package/dist/chunk-PY4KJPYU.js +9 -0
- package/dist/chunk-PY4KJPYU.js.map +1 -0
- package/dist/chunk-PZ5AY32C.js +10 -0
- package/dist/{chunk-DE6GKS6G.js → chunk-Q7SS3IME.js} +50 -9
- package/dist/chunk-Q7SS3IME.js.map +1 -0
- package/dist/chunk-QHJW5EXU.js +54 -0
- package/dist/chunk-QHJW5EXU.js.map +1 -0
- package/dist/{chunk-NONAAENK.js → chunk-RUEKROOS.js} +11 -4
- package/dist/chunk-RUEKROOS.js.map +1 -0
- package/dist/chunk-RUIMKQTA.js +23 -0
- package/dist/chunk-RUIMKQTA.js.map +1 -0
- package/dist/{chunk-TFBP23BX.js → chunk-SKF73JOP.js} +66 -7
- package/dist/chunk-SKF73JOP.js.map +1 -0
- package/dist/chunk-SM3AVUHC.js +42 -0
- package/dist/chunk-SM3AVUHC.js.map +1 -0
- package/dist/{chunk-ML236QKC.js → chunk-SMXWYP24.js} +5 -5
- package/dist/chunk-SMXWYP24.js.map +1 -0
- package/dist/chunk-SRB2XEWB.js +148 -0
- package/dist/chunk-SRB2XEWB.js.map +1 -0
- package/dist/chunk-SVLR4POP.js +64 -0
- package/dist/chunk-SVLR4POP.js.map +1 -0
- package/dist/chunk-TA66UMI4.js +123 -0
- package/dist/chunk-TA66UMI4.js.map +1 -0
- package/dist/chunk-TEILUWOI.js +664 -0
- package/dist/chunk-TEILUWOI.js.map +1 -0
- package/dist/chunk-TJYQIGAP.js +82 -0
- package/dist/chunk-TJYQIGAP.js.map +1 -0
- package/dist/{chunk-H2X3ISXG.js → chunk-UAG5KWVA.js} +7 -7
- package/dist/chunk-UAG5KWVA.js.map +1 -0
- package/dist/chunk-UDRIWL7A.js +382 -0
- package/dist/chunk-UDRIWL7A.js.map +1 -0
- package/dist/{chunk-2GLDA55J.js → chunk-UIU2THRG.js} +498 -133
- package/dist/chunk-UIU2THRG.js.map +1 -0
- package/dist/{chunk-3YPCK6JX.js → chunk-UPJNJGGA.js} +165 -423
- package/dist/chunk-UPJNJGGA.js.map +1 -0
- package/dist/chunk-UV5MFVO3.js +21 -0
- package/dist/chunk-UV5MFVO3.js.map +1 -0
- package/dist/{chunk-2WUSG3IT.js → chunk-V7RWQRG7.js} +5 -5
- package/dist/chunk-V7RWQRG7.js.map +1 -0
- package/dist/{chunk-VTKGMEPP.js → chunk-VCTFO5CO.js} +13 -3
- package/dist/chunk-VCTFO5CO.js.map +1 -0
- package/dist/{chunk-5T22KDPN.js → chunk-VFQGRQIH.js} +8 -8
- package/dist/chunk-VFQGRQIH.js.map +1 -0
- package/dist/{chunk-2QR2PQTT.js → chunk-VQNJ7UZL.js} +5 -3
- package/dist/chunk-VQNJ7UZL.js.map +1 -0
- package/dist/{chunk-DONMZAD2.js → chunk-WWGT2MDV.js} +43 -165
- package/dist/chunk-WWGT2MDV.js.map +1 -0
- package/dist/{chunk-EMIGCR7X.js → chunk-WXSYDNBT.js} +2 -2
- package/dist/chunk-WXSYDNBT.js.map +1 -0
- package/dist/chunk-WYSO2NIH.js +30 -0
- package/dist/chunk-WYSO2NIH.js.map +1 -0
- package/dist/chunk-XXYIOFUB.js +164 -0
- package/dist/chunk-XXYIOFUB.js.map +1 -0
- package/dist/{chunk-3BFJOWSU.js → chunk-Y22T3KQE.js} +35 -7
- package/dist/chunk-Y22T3KQE.js.map +1 -0
- package/dist/{chunk-A3JMGXPG.js → chunk-YMUGBZN2.js} +2 -2
- package/dist/chunk-YMUGBZN2.js.map +1 -0
- package/dist/{chunk-I5FOWO4J.js → chunk-ZCGAHGUS.js} +52 -73
- package/dist/chunk-ZCGAHGUS.js.map +1 -0
- package/dist/{chunk-FZU343FL.js → chunk-ZJADGNYF.js} +2 -2
- package/dist/chunk-ZJADGNYF.js.map +1 -0
- package/dist/{chunk-B6PB7JLN.js → chunk-ZYUC53LT.js} +427 -6
- package/dist/chunk-ZYUC53LT.js.map +1 -0
- package/dist/collection-facade-GQAOGJP2.js +33 -0
- package/dist/consent/index.d.ts +5 -7
- package/dist/consent/index.js +7 -5
- package/dist/consent/index.js.map +1 -1
- package/dist/crdt/index.d.ts +6 -2
- package/dist/crdt/index.js +3 -2
- package/dist/crdt/index.js.map +1 -1
- package/dist/decrypt-partition-IHtxEnTi.d.ts +21 -0
- package/dist/delegation-UL5HKLER.js +19 -0
- package/dist/derivations/index.d.ts +7 -9
- package/dist/derivations/index.js +11 -6
- package/dist/describe/index.d.ts +1 -0
- package/dist/describe/index.js +1 -0
- package/dist/describe-aBkJR2sd.d.ts +131 -0
- package/dist/{dev-unlock-B4kDxep_.d.ts → dev-unlock-C9Ro3v_O.d.ts} +1 -1
- package/dist/discriminant-BN9REW3o.d.ts +60 -0
- package/dist/enclave-UL5LW66V.js +88 -0
- package/dist/executor-2FWQRLMG.js +15 -0
- package/dist/executor-QZ7BXICW.js +9 -0
- package/dist/executor-Z5ZLJVTV.js +9 -0
- package/dist/export-accessible-KRV5W4GH.js +17 -0
- package/dist/extract-partition-GLKBOXFQ.js +30 -0
- package/dist/{fanout-sidecar-OKPMMPLG.js → fanout-sidecar-GF3DJ6KR.js} +34 -14
- package/dist/fanout-sidecar-GF3DJ6KR.js.map +1 -0
- package/dist/forget/index.d.ts +36 -0
- package/dist/forget/index.js +19 -0
- package/dist/forget/index.js.map +1 -0
- package/dist/guards/index.d.ts +13 -9
- package/dist/guards/index.js +12 -5
- package/dist/{hash-DdpVypUp.d.cts → hash-Cp5uwiox.d.ts} +5 -1
- package/dist/history/index.d.ts +6 -8
- package/dist/history/index.js +19 -12
- package/dist/history/index.js.map +1 -1
- package/dist/i18n/index.d.ts +5 -7
- package/dist/i18n/index.js +104 -15
- package/dist/i18n/index.js.map +1 -1
- package/dist/in/index.d.ts +5 -0
- package/dist/in/index.js +1 -0
- package/dist/in/index.js.map +1 -0
- package/dist/index-B9QdHytu.d.ts +123 -0
- package/dist/index-BF9_96A5.d.ts +123 -0
- package/dist/{types-Df28QFKb.d.ts → index-BzUo1B6n.d.ts} +16270 -8358
- package/dist/index.d.ts +1088 -450
- package/dist/index.js +1165 -293
- package/dist/index.js.map +1 -1
- package/dist/indexing/index.d.ts +6 -3
- package/dist/indexing/index.js +6 -5
- package/dist/indexing/index.js.map +1 -1
- package/dist/issue-Y6UVIR43.js +13 -0
- package/dist/issue-Y6UVIR43.js.map +1 -0
- package/dist/kernel/index.d.ts +32 -0
- package/dist/kernel/index.js +53 -0
- package/dist/kernel/index.js.map +1 -0
- package/dist/{ledger-TMRZYNVJ.js → ledger-RYI35CDS.js} +12 -9
- package/dist/ledger-RYI35CDS.js.map +1 -0
- package/dist/liberate-CRPZEV7O.js +18 -0
- package/dist/liberate-CRPZEV7O.js.map +1 -0
- package/dist/materialized-views/index.d.ts +6 -19
- package/dist/materialized-views/index.js +16 -12
- package/dist/mime-magic-CGhw37_E.d.ts +103 -0
- package/dist/noydb-367AM4HT.js +50 -0
- package/dist/noydb-367AM4HT.js.map +1 -0
- package/dist/on/index.d.ts +5 -0
- package/dist/on/index.js +11 -0
- package/dist/on/index.js.map +1 -0
- package/dist/overlay-views/index.d.ts +27 -11
- package/dist/overlay-views/index.js +7 -6
- package/dist/periods/index.d.ts +5 -7
- package/dist/periods/index.js +13 -9
- package/dist/pod/index.d.ts +63 -0
- package/dist/pod/index.js +61 -0
- package/dist/pod/index.js.map +1 -0
- package/dist/policy-IXK4FVXP.js +41 -0
- package/dist/policy-IXK4FVXP.js.map +1 -0
- package/dist/portability/index.d.ts +20 -0
- package/dist/portability/index.js +43 -0
- package/dist/portability/index.js.map +1 -0
- package/dist/{public-envelope-BW6OXORV.js → public-envelope-JHDQCPSX.js} +6 -5
- package/dist/public-envelope-JHDQCPSX.js.map +1 -0
- package/dist/query/index.d.ts +5 -3
- package/dist/query/index.js +21 -13
- package/dist/read-only-facade-5ADRJVTM.js +8 -0
- package/dist/read-only-facade-5ADRJVTM.js.map +1 -0
- package/dist/registry-45RJNWGU.js +9 -0
- package/dist/registry-45RJNWGU.js.map +1 -0
- package/dist/registry-5GRV5VXI.js +13 -0
- package/dist/registry-5GRV5VXI.js.map +1 -0
- package/dist/registry-VW6P6A3J.js +8 -0
- package/dist/registry-VW6P6A3J.js.map +1 -0
- package/dist/registry-WEUCHBO4.js +11 -0
- package/dist/registry-WEUCHBO4.js.map +1 -0
- package/dist/request-withdrawal-GBPH2FDY.js +25 -0
- package/dist/request-withdrawal-GBPH2FDY.js.map +1 -0
- package/dist/revoke-TUFRGI6S.js +18 -0
- package/dist/revoke-TUFRGI6S.js.map +1 -0
- package/dist/sealed-record/index.d.ts +69 -0
- package/dist/sealed-record/index.js +65 -0
- package/dist/sealed-record/index.js.map +1 -0
- package/dist/session/index.d.ts +6 -8
- package/dist/session/index.js +7 -5
- package/dist/session/index.js.map +1 -1
- package/dist/shadow/index.d.ts +5 -7
- package/dist/shadow/index.js +4 -3
- package/dist/shadow/index.js.map +1 -1
- package/dist/{signer-72QAUSVW.js → signer-PNKTBVF7.js} +6 -5
- package/dist/signer-PNKTBVF7.js.map +1 -0
- package/dist/snapshots/index.d.ts +6 -8
- package/dist/snapshots/index.js +13 -11
- package/dist/snapshots/index.js.map +1 -1
- package/dist/{stale-6ZDBTQT7.js → stale-3JWHNDIY.js} +3 -2
- package/dist/stale-3JWHNDIY.js.map +1 -0
- package/dist/store-coordination-provider-3I7XWZZK.js +142 -0
- package/dist/store-coordination-provider-3I7XWZZK.js.map +1 -0
- package/dist/subject-index-O75wKshW.d.ts +362 -0
- package/dist/sync/index.d.ts +4 -6
- package/dist/sync/index.js +7 -6
- package/dist/sync/index.js.map +1 -1
- package/dist/team/index.d.ts +5 -7
- package/dist/team/index.js +20 -16
- package/dist/tiers/index.d.ts +5 -0
- package/dist/tiers/index.js +33 -0
- package/dist/tiers/index.js.map +1 -0
- package/dist/to/index.d.ts +5 -0
- package/dist/to/index.js +17 -0
- package/dist/to/index.js.map +1 -0
- package/dist/transition-guard-C7ol6oPw.d.ts +165 -0
- package/dist/tx/index.d.ts +23 -9
- package/dist/tx/index.js +13 -8
- package/dist/tx/index.js.map +1 -1
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.js +1 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ulid-DRH25k3y.d.ts +66 -0
- package/dist/ulid-PTAIMDG4.js +10 -0
- package/dist/ulid-PTAIMDG4.js.map +1 -0
- package/dist/util/index.d.ts +2 -0
- package/dist/util/index.js +7 -2
- package/dist/util/index.js.map +1 -1
- package/dist/vault-diff-B5fYNBL7.d.ts +147 -0
- package/dist/with/index.d.ts +38 -0
- package/dist/with/index.js +25 -0
- package/dist/with/index.js.map +1 -0
- package/dist/{with-materialized-view-BLkQxoQN.d.ts → with-materialized-view-6p0Fk8bL.d.ts} +1 -1
- package/dist/{with-overlayed-view-CRsSEwHR.d.ts → with-overlayed-view-BJ6mXGMd.d.ts} +2 -3
- package/dist/with-rollup-BvQo3ROo.d.ts +47 -0
- package/dist/withdraw-accessible-FFS46EOD.js +22 -0
- package/dist/withdraw-accessible-FFS46EOD.js.map +1 -0
- package/dist/zod-HAJM7LMS.js +14763 -0
- package/dist/zod-HAJM7LMS.js.map +1 -0
- package/package.json +121 -201
- package/dist/aggregate/index.cjs.map +0 -1
- package/dist/aggregate/index.d.cts +0 -38
- package/dist/attestation/index.cjs +0 -305
- package/dist/attestation/index.cjs.map +0 -1
- package/dist/attestation/index.d.cts +0 -52
- package/dist/blobs/index.cjs +0 -1480
- package/dist/blobs/index.cjs.map +0 -1
- package/dist/blobs/index.d.cts +0 -46
- package/dist/bundle/index.cjs +0 -19264
- package/dist/bundle/index.cjs.map +0 -1
- package/dist/bundle/index.d.cts +0 -176
- package/dist/chunk-22DWZL57.js.map +0 -1
- package/dist/chunk-2GLDA55J.js.map +0 -1
- package/dist/chunk-2QR2PQTT.js.map +0 -1
- package/dist/chunk-2WUSG3IT.js.map +0 -1
- package/dist/chunk-3BFJOWSU.js.map +0 -1
- package/dist/chunk-3YPCK6JX.js.map +0 -1
- package/dist/chunk-53XBRIRT.js.map +0 -1
- package/dist/chunk-5T22KDPN.js.map +0 -1
- package/dist/chunk-5XHKQ56N.js +0 -340
- package/dist/chunk-5XHKQ56N.js.map +0 -1
- package/dist/chunk-6CME4UEK.js.map +0 -1
- package/dist/chunk-6STK5TQP.js +0 -139
- package/dist/chunk-6STK5TQP.js.map +0 -1
- package/dist/chunk-A3JMGXPG.js.map +0 -1
- package/dist/chunk-B6PB7JLN.js.map +0 -1
- package/dist/chunk-BVRYKATC.js.map +0 -1
- package/dist/chunk-DE6GKS6G.js.map +0 -1
- package/dist/chunk-DFMLEQZB.js.map +0 -1
- package/dist/chunk-DJHHA6XH.js.map +0 -1
- package/dist/chunk-DL3HWOQ5.js.map +0 -1
- package/dist/chunk-DONMZAD2.js.map +0 -1
- package/dist/chunk-EMIGCR7X.js.map +0 -1
- package/dist/chunk-F3GDRNUT.js.map +0 -1
- package/dist/chunk-FZU343FL.js.map +0 -1
- package/dist/chunk-H2X3ISXG.js.map +0 -1
- package/dist/chunk-HNRHLRDC.js.map +0 -1
- package/dist/chunk-I5FOWO4J.js.map +0 -1
- package/dist/chunk-J66GRPNH.js.map +0 -1
- package/dist/chunk-JWRVQKRZ.js.map +0 -1
- package/dist/chunk-K3DK3NU5.js.map +0 -1
- package/dist/chunk-ML236QKC.js.map +0 -1
- package/dist/chunk-NONAAENK.js.map +0 -1
- package/dist/chunk-O3VZPBZG.js.map +0 -1
- package/dist/chunk-OIF6LZUR.js.map +0 -1
- package/dist/chunk-OQ6PIGHA.js +0 -19
- package/dist/chunk-OQ6PIGHA.js.map +0 -1
- package/dist/chunk-PE2FR4J3.js.map +0 -1
- package/dist/chunk-PP6W64Y3.js +0 -275
- package/dist/chunk-PP6W64Y3.js.map +0 -1
- package/dist/chunk-PX35GA7L.js.map +0 -1
- package/dist/chunk-QEILDE6R.js +0 -793
- package/dist/chunk-QEILDE6R.js.map +0 -1
- package/dist/chunk-QODLLGQ7.js.map +0 -1
- package/dist/chunk-RAZ4OVLL.js +0 -51
- package/dist/chunk-RAZ4OVLL.js.map +0 -1
- package/dist/chunk-SYMWGEET.js.map +0 -1
- package/dist/chunk-T7JEBOGN.js.map +0 -1
- package/dist/chunk-TFBP23BX.js.map +0 -1
- package/dist/chunk-TV3YZ35S.js +0 -90
- package/dist/chunk-TV3YZ35S.js.map +0 -1
- package/dist/chunk-U26HQ6KJ.js.map +0 -1
- package/dist/chunk-UF3BUNQZ.js +0 -1
- package/dist/chunk-UMLVJTYV.js +0 -20
- package/dist/chunk-UMLVJTYV.js.map +0 -1
- package/dist/chunk-VTKGMEPP.js.map +0 -1
- package/dist/chunk-W6EQLGMB.js +0 -100
- package/dist/chunk-W6EQLGMB.js.map +0 -1
- package/dist/chunk-WIRRPTFH.js +0 -17
- package/dist/chunk-WIRRPTFH.js.map +0 -1
- package/dist/chunk-WPLVTJ5D.js.map +0 -1
- package/dist/chunk-XJFLDA7A.js.map +0 -1
- package/dist/chunk-Z6FNBOTC.js.map +0 -1
- package/dist/chunk-ZYWZWG6G.js.map +0 -1
- package/dist/consent/index.cjs +0 -204
- package/dist/consent/index.cjs.map +0 -1
- package/dist/consent/index.d.cts +0 -25
- package/dist/crdt/index.cjs +0 -152
- package/dist/crdt/index.cjs.map +0 -1
- package/dist/crdt/index.d.cts +0 -30
- package/dist/crypto-HTZ4FJOP.js +0 -44
- package/dist/delegation-RI54P6I5.js +0 -17
- package/dist/derivations/index.cjs +0 -351
- package/dist/derivations/index.cjs.map +0 -1
- package/dist/derivations/index.d.cts +0 -72
- package/dist/dev-unlock-BIoEFbwm.d.cts +0 -263
- package/dist/executor-5PNY7LGW.js +0 -8
- package/dist/executor-B4QIYGZX.js +0 -8
- package/dist/executor-BWXXDQ7K.js +0 -11
- package/dist/fanout-sidecar-OKPMMPLG.js.map +0 -1
- package/dist/guards/index.cjs +0 -322
- package/dist/guards/index.cjs.map +0 -1
- package/dist/guards/index.d.cts +0 -31
- package/dist/hash-HJqD14vS.d.ts +0 -63
- package/dist/history/index.cjs +0 -1222
- package/dist/history/index.cjs.map +0 -1
- package/dist/history/index.d.cts +0 -63
- package/dist/i18n/index.cjs +0 -1100
- package/dist/i18n/index.cjs.map +0 -1
- package/dist/i18n/index.d.cts +0 -39
- package/dist/index-4fBVt8j9.d.cts +0 -2387
- package/dist/index-D8I_pyJD.d.ts +0 -2387
- package/dist/index.cjs +0 -24487
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -776
- package/dist/indexing/index.cjs +0 -742
- package/dist/indexing/index.cjs.map +0 -1
- package/dist/indexing/index.d.cts +0 -36
- package/dist/issue-VGDPP4B5.js +0 -12
- package/dist/lazy-builder-7tIpFyWN.d.ts +0 -304
- package/dist/lazy-builder-wY4pMCEe.d.cts +0 -304
- package/dist/materialized-views/index.cjs +0 -854
- package/dist/materialized-views/index.cjs.map +0 -1
- package/dist/materialized-views/index.d.cts +0 -186
- package/dist/mime-magic-CBBSOkjm.d.cts +0 -50
- package/dist/mime-magic-CBBSOkjm.d.ts +0 -50
- package/dist/noydb-G725ZSZG.js +0 -34
- package/dist/overlay-views/index.cjs +0 -359
- package/dist/overlay-views/index.cjs.map +0 -1
- package/dist/overlay-views/index.d.cts +0 -82
- package/dist/periods/index.cjs +0 -1041
- package/dist/periods/index.cjs.map +0 -1
- package/dist/periods/index.d.cts +0 -22
- package/dist/predicate-BSAGEyu5.d.cts +0 -209
- package/dist/predicate-BSAGEyu5.d.ts +0 -209
- package/dist/query/index.cjs +0 -2375
- package/dist/query/index.cjs.map +0 -1
- package/dist/query/index.d.cts +0 -3
- package/dist/read-only-facade-ITU6L7BL.js +0 -7
- package/dist/registry-3QP3YKQS.js +0 -8
- package/dist/registry-DKEXOJVO.js +0 -7
- package/dist/registry-OJIOSBV6.js +0 -10
- package/dist/registry-USRVT6YF.js +0 -8
- package/dist/revoke-JCC7N56X.js +0 -17
- package/dist/session/index.cjs +0 -495
- package/dist/session/index.cjs.map +0 -1
- package/dist/session/index.d.cts +0 -46
- package/dist/shadow/index.cjs +0 -133
- package/dist/shadow/index.cjs.map +0 -1
- package/dist/shadow/index.d.cts +0 -17
- package/dist/snapshots/index.cjs +0 -937
- package/dist/snapshots/index.cjs.map +0 -1
- package/dist/snapshots/index.d.cts +0 -28
- package/dist/store/index.cjs +0 -1083
- package/dist/store/index.cjs.map +0 -1
- package/dist/store/index.d.cts +0 -492
- package/dist/store/index.d.ts +0 -492
- package/dist/store/index.js +0 -37
- package/dist/strategy-BSxFXGzb.d.cts +0 -110
- package/dist/strategy-BSxFXGzb.d.ts +0 -110
- package/dist/strategy-DSTrsZ8t.d.cts +0 -601
- package/dist/strategy-DSTrsZ8t.d.ts +0 -601
- package/dist/sync/index.cjs +0 -1062
- package/dist/sync/index.cjs.map +0 -1
- package/dist/sync/index.d.cts +0 -43
- package/dist/team/index.cjs +0 -2798
- package/dist/team/index.cjs.map +0 -1
- package/dist/team/index.d.cts +0 -118
- package/dist/tx/index.cjs +0 -544
- package/dist/tx/index.cjs.map +0 -1
- package/dist/tx/index.d.cts +0 -21
- package/dist/types-DyXYr8rE.d.cts +0 -12818
- package/dist/ulid-COREQ2RQ.js +0 -9
- package/dist/ulid-Drr7ykr6.d.cts +0 -603
- package/dist/util/index.cjs +0 -230
- package/dist/util/index.cjs.map +0 -1
- package/dist/util/index.d.cts +0 -77
- package/dist/with-derivation-DFnFByiQ.d.ts +0 -13
- package/dist/with-derivation-DU3Sjazm.d.cts +0 -13
- package/dist/with-guard-ByyxmEe7.d.cts +0 -18
- package/dist/with-guard-qube6BMI.d.ts +0 -18
- package/dist/with-materialized-view-BmEToIR1.d.cts +0 -27
- package/dist/with-overlayed-view-BMsQQbWm.d.cts +0 -13
- /package/dist/{store → adapter}/index.js.map +0 -0
- /package/dist/{chunk-UF3BUNQZ.js.map → api-RW3KP7WU.js.map} +0 -0
- /package/dist/{crypto-HTZ4FJOP.js.map → as/index.js.map} +0 -0
- /package/dist/{delegation-RI54P6I5.js.map → at/index.js.map} +0 -0
- /package/dist/{executor-5PNY7LGW.js.map → by/index.js.map} +0 -0
- /package/dist/{executor-B4QIYGZX.js.map → cargo/index.js.map} +0 -0
- /package/dist/{executor-BWXXDQ7K.js.map → chunk-BGIZAFY7.js.map} +0 -0
- /package/dist/{issue-VGDPP4B5.js.map → chunk-CHFZDSE4.js.map} +0 -0
- /package/dist/{ledger-TMRZYNVJ.js.map → chunk-GHVIKOHT.js.map} +0 -0
- /package/dist/{noydb-G725ZSZG.js.map → chunk-K2WCO3NX.js.map} +0 -0
- /package/dist/{public-envelope-BW6OXORV.js.map → chunk-PZ5AY32C.js.map} +0 -0
- /package/dist/{read-only-facade-ITU6L7BL.js.map → collection-facade-GQAOGJP2.js.map} +0 -0
- /package/dist/{registry-3QP3YKQS.js.map → delegation-UL5HKLER.js.map} +0 -0
- /package/dist/{registry-DKEXOJVO.js.map → describe/index.js.map} +0 -0
- /package/dist/{registry-OJIOSBV6.js.map → enclave-UL5LW66V.js.map} +0 -0
- /package/dist/{registry-USRVT6YF.js.map → executor-2FWQRLMG.js.map} +0 -0
- /package/dist/{revoke-JCC7N56X.js.map → executor-QZ7BXICW.js.map} +0 -0
- /package/dist/{signer-72QAUSVW.js.map → executor-Z5ZLJVTV.js.map} +0 -0
- /package/dist/{stale-6ZDBTQT7.js.map → export-accessible-KRV5W4GH.js.map} +0 -0
- /package/dist/{ulid-COREQ2RQ.js.map → extract-partition-GLKBOXFQ.js.map} +0 -0
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
|
+
reducerBuilder,
|
|
3
|
+
wrapMoneyReducers
|
|
4
|
+
} from "./chunk-LV7M27WM.js";
|
|
5
|
+
import {
|
|
6
|
+
MoneyPrecisionError,
|
|
2
7
|
evaluateClause,
|
|
8
|
+
formatScaledInt,
|
|
9
|
+
hasFnClause,
|
|
10
|
+
moneyFieldClause,
|
|
11
|
+
parseToScaledInt,
|
|
3
12
|
readPath
|
|
4
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-M2YKN37S.js";
|
|
14
|
+
import {
|
|
15
|
+
applyI18nLocale
|
|
16
|
+
} from "./chunk-5LUY7UTV.js";
|
|
5
17
|
import {
|
|
6
18
|
CrossJoinSourceUnknownError,
|
|
7
19
|
CrossJoinTooLargeError,
|
|
8
20
|
DanglingReferenceError,
|
|
9
|
-
JoinTooLargeError
|
|
10
|
-
|
|
21
|
+
JoinTooLargeError,
|
|
22
|
+
ValidationError
|
|
23
|
+
} from "./chunk-ZYUC53LT.js";
|
|
11
24
|
|
|
12
|
-
// src/query/join.ts
|
|
25
|
+
// src/kernel/query/join.ts
|
|
13
26
|
var DEFAULT_JOIN_MAX_ROWS = 5e4;
|
|
14
27
|
var JOIN_WARN_FRACTION = 0.8;
|
|
15
28
|
function coerceRefKey(value) {
|
|
@@ -37,15 +50,15 @@ function warnCeilingApproaching(target, side, rows, maxRows) {
|
|
|
37
50
|
`[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.`
|
|
38
51
|
);
|
|
39
52
|
}
|
|
40
|
-
function applyJoins(rows, joins, context) {
|
|
53
|
+
function applyJoins(rows, joins, context, locale) {
|
|
41
54
|
if (joins.length === 0) return [...rows];
|
|
42
55
|
let result = [...rows];
|
|
43
56
|
for (const leg of joins) {
|
|
44
|
-
result = applyOneJoin(result, leg, context);
|
|
57
|
+
result = applyOneJoin(result, leg, context, locale);
|
|
45
58
|
}
|
|
46
59
|
return result;
|
|
47
60
|
}
|
|
48
|
-
function applyOneJoin(leftRows, leg, context) {
|
|
61
|
+
function applyOneJoin(leftRows, leg, context, locale) {
|
|
49
62
|
if (leg.isDictJoin) {
|
|
50
63
|
const dictSource = context.resolveDictSource?.(leg.field);
|
|
51
64
|
if (!dictSource) {
|
|
@@ -100,24 +113,27 @@ function applyOneJoin(leftRows, leg, context) {
|
|
|
100
113
|
if (rightSnapshot.length > maxRows * JOIN_WARN_FRACTION) {
|
|
101
114
|
warnCeilingApproaching(leg.target, "right", rightSnapshot.length, maxRows);
|
|
102
115
|
}
|
|
116
|
+
const effLocale = locale ?? context.defaultLocale;
|
|
117
|
+
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;
|
|
103
118
|
const strategy = leg.strategy ?? (source.lookupById ? "nested" : "hash");
|
|
104
119
|
if (strategy === "nested" && source.lookupById) {
|
|
105
120
|
const lookup = (id) => source.lookupById?.(id);
|
|
106
|
-
return nestedLoopJoin(leftRows, leg, lookup);
|
|
121
|
+
return nestedLoopJoin(leftRows, leg, lookup, i18nResolve);
|
|
107
122
|
}
|
|
108
|
-
return hashJoin(leftRows, leg, rightSnapshot);
|
|
123
|
+
return hashJoin(leftRows, leg, rightSnapshot, i18nResolve);
|
|
109
124
|
}
|
|
110
|
-
function nestedLoopJoin(leftRows, leg, lookupById) {
|
|
125
|
+
function nestedLoopJoin(leftRows, leg, lookupById, i18nResolve) {
|
|
111
126
|
const out = [];
|
|
112
127
|
for (const left of leftRows) {
|
|
113
128
|
const rawId = readPath(left, leg.field);
|
|
114
129
|
const key = coerceRefKey(rawId);
|
|
115
|
-
|
|
130
|
+
let right = key === null ? void 0 : lookupById(key);
|
|
131
|
+
if (i18nResolve && right !== void 0) right = i18nResolve(right);
|
|
116
132
|
out.push(attachJoin(left, leg, right, rawId));
|
|
117
133
|
}
|
|
118
134
|
return out;
|
|
119
135
|
}
|
|
120
|
-
function hashJoin(leftRows, leg, rightSnapshot) {
|
|
136
|
+
function hashJoin(leftRows, leg, rightSnapshot, i18nResolve) {
|
|
121
137
|
const rightMap = /* @__PURE__ */ new Map();
|
|
122
138
|
for (const record of rightSnapshot) {
|
|
123
139
|
const rawId = readPath(record, "id");
|
|
@@ -130,7 +146,8 @@ function hashJoin(leftRows, leg, rightSnapshot) {
|
|
|
130
146
|
for (const left of leftRows) {
|
|
131
147
|
const rawId = readPath(left, leg.field);
|
|
132
148
|
const key = coerceRefKey(rawId);
|
|
133
|
-
|
|
149
|
+
let right = key === null ? void 0 : rightMap.get(key);
|
|
150
|
+
if (i18nResolve && right !== void 0) right = i18nResolve(right);
|
|
134
151
|
out.push(attachJoin(left, leg, right, rawId));
|
|
135
152
|
}
|
|
136
153
|
return out;
|
|
@@ -164,7 +181,7 @@ function resetJoinWarnings() {
|
|
|
164
181
|
warnedCeilingKeys.clear();
|
|
165
182
|
}
|
|
166
183
|
|
|
167
|
-
// src/query/live.ts
|
|
184
|
+
// src/kernel/query/live.ts
|
|
168
185
|
function buildLiveQuery(recompute, upstreams) {
|
|
169
186
|
return new LiveQueryImpl(recompute, upstreams);
|
|
170
187
|
}
|
|
@@ -235,7 +252,7 @@ var LiveQueryImpl = class {
|
|
|
235
252
|
}
|
|
236
253
|
};
|
|
237
254
|
|
|
238
|
-
// src/aggregate/strategy.ts
|
|
255
|
+
// src/with-lookup/aggregate/strategy.ts
|
|
239
256
|
var NOT_ENABLED = new Error(
|
|
240
257
|
'Aggregate / groupBy is not enabled on this Noydb instance. Import `{ withAggregate }` from "@noy-db/hub/aggregate" and pass it to `createNoydb({ aggregateStrategy: withAggregate() })`.'
|
|
241
258
|
);
|
|
@@ -254,7 +271,278 @@ var NO_AGGREGATE = {
|
|
|
254
271
|
}
|
|
255
272
|
};
|
|
256
273
|
|
|
257
|
-
// src/
|
|
274
|
+
// src/with-shape/money/paths.ts
|
|
275
|
+
var SEGMENT_RE = /^(\*|[^.[\]*]+)(\[\])?$/;
|
|
276
|
+
var parseCache = /* @__PURE__ */ new Map();
|
|
277
|
+
function parseMoneyPath(path) {
|
|
278
|
+
const cached = parseCache.get(path);
|
|
279
|
+
if (cached) return cached;
|
|
280
|
+
if (typeof path !== "string" || path.length === 0) {
|
|
281
|
+
throw new ValidationError("moneyFields: path must be a non-empty string");
|
|
282
|
+
}
|
|
283
|
+
const segments = [];
|
|
284
|
+
for (const part of path.split(".")) {
|
|
285
|
+
const m = SEGMENT_RE.exec(part);
|
|
286
|
+
if (!m) {
|
|
287
|
+
throw new ValidationError(
|
|
288
|
+
`moneyFields: invalid path "${path}" \u2014 segment "${part}" must be a key, "key[]", "*", or "*[]"`
|
|
289
|
+
);
|
|
290
|
+
}
|
|
291
|
+
const array = m[2] === "[]";
|
|
292
|
+
segments.push(
|
|
293
|
+
m[1] === "*" ? { kind: "wildcard", array } : { kind: "key", key: m[1], array }
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
parseCache.set(path, segments);
|
|
297
|
+
return segments;
|
|
298
|
+
}
|
|
299
|
+
function isSimpleMoneyPath(path) {
|
|
300
|
+
return !path.includes(".") && !path.includes("[") && !path.includes("*");
|
|
301
|
+
}
|
|
302
|
+
function validateMoneyFieldPaths(moneyFields) {
|
|
303
|
+
for (const path of Object.keys(moneyFields)) parseMoneyPath(path);
|
|
304
|
+
}
|
|
305
|
+
function transformAtMoneyPath(node, path, segments, index, visit, lenient) {
|
|
306
|
+
if (node === null || node === void 0) return node;
|
|
307
|
+
const seg = segments[index];
|
|
308
|
+
const last = index === segments.length - 1;
|
|
309
|
+
if (seg.kind === "key") {
|
|
310
|
+
if (typeof node !== "object" || Array.isArray(node)) {
|
|
311
|
+
if (lenient) return node;
|
|
312
|
+
throw new ValidationError(
|
|
313
|
+
`moneyFields: path "${path}" expected an object at segment "${seg.key}", got ${Array.isArray(node) ? "an array" : typeof node}`
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
const obj2 = node;
|
|
317
|
+
if (!(seg.key in obj2) || obj2[seg.key] === null || obj2[seg.key] === void 0) return node;
|
|
318
|
+
if (seg.array) {
|
|
319
|
+
const arr = obj2[seg.key];
|
|
320
|
+
if (!Array.isArray(arr)) {
|
|
321
|
+
if (lenient) return node;
|
|
322
|
+
throw new ValidationError(
|
|
323
|
+
`moneyFields: path "${path}" declares "${seg.key}[]" but the value is not an array`
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
const cloned = [...arr];
|
|
327
|
+
if (last) {
|
|
328
|
+
for (let i = 0; i < cloned.length; i++) visit(cloned, i);
|
|
329
|
+
} else {
|
|
330
|
+
for (let i = 0; i < cloned.length; i++) {
|
|
331
|
+
cloned[i] = transformAtMoneyPath(cloned[i], path, segments, index + 1, visit, lenient);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
return { ...obj2, [seg.key]: cloned };
|
|
335
|
+
}
|
|
336
|
+
const clone2 = { ...obj2 };
|
|
337
|
+
if (last) {
|
|
338
|
+
visit(clone2, seg.key);
|
|
339
|
+
} else {
|
|
340
|
+
clone2[seg.key] = transformAtMoneyPath(clone2[seg.key], path, segments, index + 1, visit, lenient);
|
|
341
|
+
}
|
|
342
|
+
return clone2;
|
|
343
|
+
}
|
|
344
|
+
if (seg.array) {
|
|
345
|
+
if (!Array.isArray(node)) {
|
|
346
|
+
if (lenient) return node;
|
|
347
|
+
throw new ValidationError(`moneyFields: path "${path}" declares "*[]" but the value is not an array`);
|
|
348
|
+
}
|
|
349
|
+
const cloned = [...node];
|
|
350
|
+
if (last) {
|
|
351
|
+
for (let i = 0; i < cloned.length; i++) visit(cloned, i);
|
|
352
|
+
} else {
|
|
353
|
+
for (let i = 0; i < cloned.length; i++) {
|
|
354
|
+
cloned[i] = transformAtMoneyPath(cloned[i], path, segments, index + 1, visit, lenient);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return cloned;
|
|
358
|
+
}
|
|
359
|
+
if (typeof node !== "object" || Array.isArray(node)) {
|
|
360
|
+
if (lenient) return node;
|
|
361
|
+
throw new ValidationError(
|
|
362
|
+
`moneyFields: path "${path}" applies "*" to a non-object (${Array.isArray(node) ? 'array \u2014 use "*[]"' : typeof node})`
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
const obj = node;
|
|
366
|
+
const clone = { ...obj };
|
|
367
|
+
for (const key of Object.keys(obj)) {
|
|
368
|
+
const v = clone[key];
|
|
369
|
+
if (v === null || v === void 0) continue;
|
|
370
|
+
if (last) visit(clone, key);
|
|
371
|
+
else clone[key] = transformAtMoneyPath(v, path, segments, index + 1, visit, lenient);
|
|
372
|
+
}
|
|
373
|
+
return clone;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// src/with-shape/money/normalize.ts
|
|
377
|
+
function isMoneyValueObject(v) {
|
|
378
|
+
return typeof v === "object" && v !== null && "currency" in v;
|
|
379
|
+
}
|
|
380
|
+
function quantizeAmount(field, input, scale, rounding) {
|
|
381
|
+
const r = parseToScaledInt(input, scale, rounding);
|
|
382
|
+
if (!r.ok) {
|
|
383
|
+
if (r.reason === "precision") throw new MoneyPrecisionError(field, input, scale);
|
|
384
|
+
throw new TypeError(`money: field "${field}" value ${JSON.stringify(input)} is not a finite decimal`);
|
|
385
|
+
}
|
|
386
|
+
return r.value.toString();
|
|
387
|
+
}
|
|
388
|
+
function canonicalizeStoredMoney(record, moneyFields) {
|
|
389
|
+
if (record === null || record === void 0) return record;
|
|
390
|
+
if (!moneyFields || Object.keys(moneyFields).length === 0) return record;
|
|
391
|
+
return decodeMoneyFields(record, moneyFields, "raw");
|
|
392
|
+
}
|
|
393
|
+
function canonicalizeIncomingMoney(record, moneyFields) {
|
|
394
|
+
if (!moneyFields || Object.keys(moneyFields).length === 0) return record;
|
|
395
|
+
try {
|
|
396
|
+
return decodeMoneyFields(
|
|
397
|
+
quantizeMoneyFields(record, moneyFields),
|
|
398
|
+
moneyFields,
|
|
399
|
+
"raw"
|
|
400
|
+
);
|
|
401
|
+
} catch {
|
|
402
|
+
return record;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
function quantizeValue(field, raw, desc) {
|
|
406
|
+
if (desc.mode === "fixed") {
|
|
407
|
+
const currency2 = desc.fixedCurrency;
|
|
408
|
+
return quantizeAmount(field, raw, desc.scaleFor(currency2), desc.rounding);
|
|
409
|
+
}
|
|
410
|
+
let amount;
|
|
411
|
+
let currency;
|
|
412
|
+
if (isMoneyValueObject(raw)) {
|
|
413
|
+
currency = String(raw.currency);
|
|
414
|
+
amount = raw.amount;
|
|
415
|
+
} else {
|
|
416
|
+
const sole = desc.soleCurrency();
|
|
417
|
+
if (sole === void 0) {
|
|
418
|
+
throw new TypeError(
|
|
419
|
+
`money: field "${field}" is multi-currency \u2014 write { amount, currency }, not a bare amount`
|
|
420
|
+
);
|
|
421
|
+
}
|
|
422
|
+
currency = sole;
|
|
423
|
+
amount = raw;
|
|
424
|
+
}
|
|
425
|
+
const scale = desc.scaleFor(currency);
|
|
426
|
+
return { amount: quantizeAmount(field, amount, scale, desc.rounding), currency };
|
|
427
|
+
}
|
|
428
|
+
function quantizeMoneyFields(record, moneyFields) {
|
|
429
|
+
let out = { ...record };
|
|
430
|
+
for (const [path, desc] of Object.entries(moneyFields)) {
|
|
431
|
+
if (isSimpleMoneyPath(path)) {
|
|
432
|
+
const raw = out[path];
|
|
433
|
+
if (raw === null || raw === void 0) continue;
|
|
434
|
+
out[path] = quantizeValue(path, raw, desc);
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
437
|
+
out = transformAtMoneyPath(
|
|
438
|
+
out,
|
|
439
|
+
path,
|
|
440
|
+
parseMoneyPath(path),
|
|
441
|
+
0,
|
|
442
|
+
(container, key) => {
|
|
443
|
+
const raw = container[key];
|
|
444
|
+
if (raw === null || raw === void 0) return;
|
|
445
|
+
container[key] = quantizeValue(path, raw, desc);
|
|
446
|
+
},
|
|
447
|
+
/* lenient */
|
|
448
|
+
false
|
|
449
|
+
);
|
|
450
|
+
}
|
|
451
|
+
return out;
|
|
452
|
+
}
|
|
453
|
+
function formatCurrency(decimal, currency, scale, locale) {
|
|
454
|
+
const fmt = new Intl.NumberFormat(locale, {
|
|
455
|
+
style: "currency",
|
|
456
|
+
currency,
|
|
457
|
+
minimumFractionDigits: scale,
|
|
458
|
+
maximumFractionDigits: scale
|
|
459
|
+
});
|
|
460
|
+
return fmt.format(decimal);
|
|
461
|
+
}
|
|
462
|
+
function moneyScaledValue(stored, desc) {
|
|
463
|
+
let raw;
|
|
464
|
+
if (desc.mode === "fixed") {
|
|
465
|
+
raw = stored;
|
|
466
|
+
} else {
|
|
467
|
+
if (!isMoneyValueObject(stored)) return null;
|
|
468
|
+
raw = stored.amount;
|
|
469
|
+
}
|
|
470
|
+
if (typeof raw !== "string" && typeof raw !== "number") return null;
|
|
471
|
+
try {
|
|
472
|
+
return BigInt(String(raw));
|
|
473
|
+
} catch {
|
|
474
|
+
return null;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
function decodeValue(stored, desc) {
|
|
478
|
+
let currency;
|
|
479
|
+
let scaledIntString;
|
|
480
|
+
if (desc.mode === "fixed") {
|
|
481
|
+
if (typeof stored !== "string" && typeof stored !== "number") return null;
|
|
482
|
+
currency = desc.fixedCurrency;
|
|
483
|
+
scaledIntString = String(stored);
|
|
484
|
+
} else {
|
|
485
|
+
if (!isMoneyValueObject(stored)) return null;
|
|
486
|
+
const amount = stored.amount;
|
|
487
|
+
if (typeof stored.currency !== "string" || typeof amount !== "string" && typeof amount !== "number") return null;
|
|
488
|
+
currency = stored.currency;
|
|
489
|
+
scaledIntString = String(amount);
|
|
490
|
+
}
|
|
491
|
+
const scale = desc.scaleFor(currency);
|
|
492
|
+
let decimal;
|
|
493
|
+
try {
|
|
494
|
+
decimal = formatScaledInt(BigInt(scaledIntString), scale);
|
|
495
|
+
} catch {
|
|
496
|
+
return null;
|
|
497
|
+
}
|
|
498
|
+
return {
|
|
499
|
+
decoded: desc.mode === "fixed" ? decimal : { amount: decimal, currency },
|
|
500
|
+
decimal,
|
|
501
|
+
currency,
|
|
502
|
+
scale
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
function decodeMoneyFields(record, moneyFields, locale) {
|
|
506
|
+
let out = { ...record };
|
|
507
|
+
const format = locale !== "raw";
|
|
508
|
+
const fmtLocale = typeof locale === "string" && locale !== "raw" ? locale : "en-US";
|
|
509
|
+
for (const [path, desc] of Object.entries(moneyFields)) {
|
|
510
|
+
if (isSimpleMoneyPath(path)) {
|
|
511
|
+
const stored = out[path];
|
|
512
|
+
if (stored === null || stored === void 0) continue;
|
|
513
|
+
const r = decodeValue(stored, desc);
|
|
514
|
+
if (r === null) continue;
|
|
515
|
+
out[path] = r.decoded;
|
|
516
|
+
if (format) {
|
|
517
|
+
out[`${path}Formatted`] = formatCurrency(r.decimal, r.currency, r.scale, fmtLocale);
|
|
518
|
+
out[`${path}Number`] = Number(r.decimal);
|
|
519
|
+
}
|
|
520
|
+
continue;
|
|
521
|
+
}
|
|
522
|
+
out = transformAtMoneyPath(
|
|
523
|
+
out,
|
|
524
|
+
path,
|
|
525
|
+
parseMoneyPath(path),
|
|
526
|
+
0,
|
|
527
|
+
(container, key) => {
|
|
528
|
+
const stored = container[key];
|
|
529
|
+
if (stored === null || stored === void 0) return;
|
|
530
|
+
const r = decodeValue(stored, desc);
|
|
531
|
+
if (r === null) return;
|
|
532
|
+
container[key] = r.decoded;
|
|
533
|
+
if (format && typeof key === "string" && !Array.isArray(container)) {
|
|
534
|
+
container[`${key}Formatted`] = formatCurrency(r.decimal, r.currency, r.scale, fmtLocale);
|
|
535
|
+
container[`${key}Number`] = Number(r.decimal);
|
|
536
|
+
}
|
|
537
|
+
},
|
|
538
|
+
/* lenient */
|
|
539
|
+
true
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
return out;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// src/kernel/query/builder.ts
|
|
258
546
|
var EMPTY_PLAN = {
|
|
259
547
|
clauses: [],
|
|
260
548
|
orderBy: [],
|
|
@@ -307,6 +595,36 @@ var Query = class _Query {
|
|
|
307
595
|
predicates
|
|
308
596
|
);
|
|
309
597
|
}
|
|
598
|
+
/**
|
|
599
|
+
* @internal — the ids of records matching this query's plan,
|
|
600
|
+
* recovered by reference identity: `executePlanWithSource` returns the
|
|
601
|
+
* ORIGINAL snapshot record references (money-decode and joins are applied
|
|
602
|
+
* later, in `toArray`), so each matched record is found in the id-paired
|
|
603
|
+
* `snapshotEntries()` map. Used by `collection.retrieve({ within })`.
|
|
604
|
+
* Throws if the source is not collection-backed (no `snapshotEntries`).
|
|
605
|
+
*/
|
|
606
|
+
_idArray() {
|
|
607
|
+
const entries = this.source.snapshotEntries?.();
|
|
608
|
+
if (entries === void 0) {
|
|
609
|
+
throw new Error(
|
|
610
|
+
"Query._idArray(): the query source has no snapshotEntries(); retrieve({ within }) requires a collection-backed query (collection.query())."
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
if (this.plan.clauses.some((c) => c.type === "crossJoin")) {
|
|
614
|
+
throw new Error(
|
|
615
|
+
"Query._idArray(): retrieve({ within }) does not support crossJoin queries (cross-join produces new row objects, breaking id recovery). Use where/filter/and/or, or a projection .join()."
|
|
616
|
+
);
|
|
617
|
+
}
|
|
618
|
+
const refToId = /* @__PURE__ */ new Map();
|
|
619
|
+
for (const { id, record } of entries) refToId.set(record, id);
|
|
620
|
+
const matched = executePlanWithSource(this.source, this.plan, this.joinContext);
|
|
621
|
+
const ids = [];
|
|
622
|
+
for (const r of matched) {
|
|
623
|
+
const id = refToId.get(r);
|
|
624
|
+
if (id !== void 0) ids.push(id);
|
|
625
|
+
}
|
|
626
|
+
return ids;
|
|
627
|
+
}
|
|
310
628
|
/**
|
|
311
629
|
* Filter by a registered deterministic predicate. Requires
|
|
312
630
|
* the Query to have been augmented with a predicates map (typically
|
|
@@ -346,9 +664,18 @@ var Query = class _Query {
|
|
|
346
664
|
this.predicates
|
|
347
665
|
);
|
|
348
666
|
}
|
|
349
|
-
/**
|
|
667
|
+
/**
|
|
668
|
+
* Add a field comparison. Multiple where() calls are AND-combined.
|
|
669
|
+
*
|
|
670
|
+
* A declared money field compares in MAJOR units: the operand
|
|
671
|
+
* (`10000`, `'10000.00'`, or `{ amount, currency }` in multi mode) is
|
|
672
|
+
* quantized into stored scaled-int space at build time and evaluated
|
|
673
|
+
* BigInt-exact per record. A malformed operand or a string operator
|
|
674
|
+
* (`contains`/`startsWith`) throws here, at the call site.
|
|
675
|
+
*/
|
|
350
676
|
where(field, op, value) {
|
|
351
|
-
const
|
|
677
|
+
const desc = this.source.moneyFields?.[field];
|
|
678
|
+
const clause = desc ? moneyFieldClause(field, op, value, desc) : { type: "field", field, op, value };
|
|
352
679
|
return new _Query(
|
|
353
680
|
this.source,
|
|
354
681
|
{ ...this.plan, clauses: [...this.plan.clauses, clause] },
|
|
@@ -414,11 +741,16 @@ var Query = class _Query {
|
|
|
414
741
|
this.predicates
|
|
415
742
|
);
|
|
416
743
|
}
|
|
417
|
-
/**
|
|
418
|
-
|
|
744
|
+
/**
|
|
745
|
+
* Sort by a field. Subsequent calls are tie-breakers. Pass
|
|
746
|
+
* `{ by: 'label' }` to sort a `dictKey`/`staticDict` field by its resolved
|
|
747
|
+
* label at the query locale instead of the stored code.
|
|
748
|
+
*/
|
|
749
|
+
orderBy(field, direction = "asc", opts) {
|
|
750
|
+
const entry = opts?.by === "label" ? { field, direction, by: "label" } : { field, direction };
|
|
419
751
|
return new _Query(
|
|
420
752
|
this.source,
|
|
421
|
-
{ ...this.plan, orderBy: [...this.plan.orderBy,
|
|
753
|
+
{ ...this.plan, orderBy: [...this.plan.orderBy, entry] },
|
|
422
754
|
this.joinContext,
|
|
423
755
|
this.aggregateStrategy,
|
|
424
756
|
this.predicates
|
|
@@ -621,20 +953,42 @@ var Query = class _Query {
|
|
|
621
953
|
* carries any join legs, they are applied after `where` / `orderBy`
|
|
622
954
|
* / `limit` / `offset` narrow the left set. See the `.join()` doc
|
|
623
955
|
* for the ordering rationale.
|
|
956
|
+
*
|
|
957
|
+
* `opts.locale` resolves JOINED right-side i18n fields at the
|
|
958
|
+
* `join` layer to that locale; without it, the owning collection's default
|
|
959
|
+
* locale applies, and a locale-less query leaves joined i18n fields raw.
|
|
960
|
+
* (Left/base i18n fields are resolved by `get`/`list`, not here.)
|
|
624
961
|
*/
|
|
625
|
-
toArray() {
|
|
626
|
-
const base = executePlanWithSource(this.source, this.plan, this.joinContext);
|
|
962
|
+
toArray(opts) {
|
|
963
|
+
const base = this.decodeMoney(executePlanWithSource(this.source, this.plan, this.joinContext, opts?.locale));
|
|
627
964
|
if (this.plan.joins.length === 0) return base;
|
|
628
965
|
if (!this.joinContext) {
|
|
629
966
|
throw new Error(
|
|
630
967
|
`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.`
|
|
631
968
|
);
|
|
632
969
|
}
|
|
633
|
-
return applyJoins(base, this.plan.joins, this.joinContext);
|
|
970
|
+
return applyJoins(base, this.plan.joins, this.joinContext, opts?.locale);
|
|
634
971
|
}
|
|
635
|
-
/**
|
|
636
|
-
|
|
637
|
-
|
|
972
|
+
/**
|
|
973
|
+
* Decode this source's money fields on read (stored scaled-int → canonical
|
|
974
|
+
* decimal), so `query().toArray()` agrees with `get()`/`sum()` on the value.
|
|
975
|
+
* No-op when the source declares no money fields.
|
|
976
|
+
*
|
|
977
|
+
* The query layer carries no locale context, so we decode with `'raw'` —
|
|
978
|
+
* canonical decimal, WITHOUT fabricating locale-formatted `<field>Formatted`
|
|
979
|
+
* / `<field>Number` virtuals. Producing a guessed-locale string here would
|
|
980
|
+
* reintroduce a "two read paths disagree" failure on the virtual
|
|
981
|
+
* field (e.g. it-IT via `get()` vs en-US here). Consumers who need formatted
|
|
982
|
+
* money read through `get()`/`list()` with a locale.
|
|
983
|
+
*/
|
|
984
|
+
decodeMoney(records) {
|
|
985
|
+
const moneyFields = this.source.moneyFields;
|
|
986
|
+
if (!moneyFields || Object.keys(moneyFields).length === 0) return records;
|
|
987
|
+
return records.map((r) => decodeMoneyFields(r, moneyFields, "raw"));
|
|
988
|
+
}
|
|
989
|
+
/** Return the first matching record, or null. Joins are applied. `opts.locale` resolves joined i18n fields. */
|
|
990
|
+
first(opts) {
|
|
991
|
+
const arr = this.limit(1).toArray(opts);
|
|
638
992
|
return arr[0] ?? null;
|
|
639
993
|
}
|
|
640
994
|
/**
|
|
@@ -657,49 +1011,14 @@ var Query = class _Query {
|
|
|
657
1011
|
}
|
|
658
1012
|
const { candidates, remainingClauses } = candidateRecords(this.source, this.plan.clauses);
|
|
659
1013
|
if (remainingClauses.length === 0) return candidates.length;
|
|
660
|
-
return filterRecords(candidates, remainingClauses).length;
|
|
1014
|
+
return filterRecords(candidates, remainingClauses, fnViewDecoder(this.source)).length;
|
|
661
1015
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
* .where('status', '==', 'open')
|
|
669
|
-
* .aggregate({
|
|
670
|
-
* total: sum('amount'),
|
|
671
|
-
* n: count(),
|
|
672
|
-
* avgAmount: avg('amount'),
|
|
673
|
-
* })
|
|
674
|
-
* .run()
|
|
675
|
-
* ```
|
|
676
|
-
*
|
|
677
|
-
* Returns an `Aggregation<R>` wrapper with two terminals:
|
|
678
|
-
* - `.run(): R` — synchronous one-shot reduction
|
|
679
|
-
* - `.live(): LiveAggregation<R>` — reactive primitive that
|
|
680
|
-
* re-runs the reduction whenever the source notifies of a
|
|
681
|
-
* change. Always call `live.stop()` when finished.
|
|
682
|
-
*
|
|
683
|
-
* The reducer spec is bound here once and reused by both
|
|
684
|
-
* terminals — this is why `.aggregate()` returns a wrapper instead
|
|
685
|
-
* of being a direct terminal. Consumers who only need the static
|
|
686
|
-
* value read `.run()`; consumers wiring a reactive UI read
|
|
687
|
-
* `.live()`.
|
|
688
|
-
*
|
|
689
|
-
* Joins are intentionally NOT applied to aggregations in —
|
|
690
|
-
* the same logic as `.count()`. Joins in are projection-only
|
|
691
|
-
* (they attach an aliased field and never filter), so running
|
|
692
|
-
* them just to throw the aliases away would be wasteful. If you
|
|
693
|
-
* need a reducer that reads a joined field, open an issue —
|
|
694
|
-
* aggregations-across-joins is explicitly out of scope for v1.
|
|
695
|
-
*
|
|
696
|
-
* Every reducer factory accepts an optional `{ seed }` parameter
|
|
697
|
-
* that is plumbed through the protocol but unused by the
|
|
698
|
-
* executor — that's constraint #2. When partition-aware
|
|
699
|
-
* aggregation lands, the seed will carry running state across
|
|
700
|
-
* partition boundaries without an API break.
|
|
701
|
-
*/
|
|
702
|
-
aggregate(spec) {
|
|
1016
|
+
aggregate(specOrBuild) {
|
|
1017
|
+
let spec = typeof specOrBuild === "function" ? specOrBuild(reducerBuilder) : specOrBuild;
|
|
1018
|
+
const moneyFields = this.source.moneyFields;
|
|
1019
|
+
if (moneyFields) {
|
|
1020
|
+
spec = wrapMoneyReducers(spec, moneyFields);
|
|
1021
|
+
}
|
|
703
1022
|
const source = this.source;
|
|
704
1023
|
const clauses = this.plan.clauses;
|
|
705
1024
|
const joinCtx = this.joinContext;
|
|
@@ -710,7 +1029,7 @@ var Query = class _Query {
|
|
|
710
1029
|
return executeClausePipeline(source, clauses, joinCtx);
|
|
711
1030
|
}
|
|
712
1031
|
const { candidates, remainingClauses } = candidateRecords(source, clauses);
|
|
713
|
-
return remainingClauses.length === 0 ? candidates : filterRecords(candidates, remainingClauses);
|
|
1032
|
+
return remainingClauses.length === 0 ? candidates : filterRecords(candidates, remainingClauses, fnViewDecoder(source));
|
|
714
1033
|
};
|
|
715
1034
|
const upstreams = [];
|
|
716
1035
|
if (source.subscribe) {
|
|
@@ -733,7 +1052,7 @@ var Query = class _Query {
|
|
|
733
1052
|
return executeClausePipeline(source, clauses, joinCtx);
|
|
734
1053
|
}
|
|
735
1054
|
const { candidates, remainingClauses } = candidateRecords(source, clauses);
|
|
736
|
-
return remainingClauses.length === 0 ? candidates : filterRecords(candidates, remainingClauses);
|
|
1055
|
+
return remainingClauses.length === 0 ? candidates : filterRecords(candidates, remainingClauses, fnViewDecoder(source));
|
|
737
1056
|
};
|
|
738
1057
|
const upstreams = [];
|
|
739
1058
|
if (source.subscribe) {
|
|
@@ -747,13 +1066,15 @@ var Query = class _Query {
|
|
|
747
1066
|
executeRecords,
|
|
748
1067
|
field,
|
|
749
1068
|
upstreams,
|
|
750
|
-
dictLabelResolver
|
|
1069
|
+
dictLabelResolver,
|
|
1070
|
+
this.source.moneyFields
|
|
751
1071
|
);
|
|
752
1072
|
}
|
|
753
1073
|
return this.aggregateStrategy.groupByN(
|
|
754
1074
|
executeRecords,
|
|
755
1075
|
fields,
|
|
756
|
-
upstreams
|
|
1076
|
+
upstreams,
|
|
1077
|
+
this.source.moneyFields
|
|
757
1078
|
);
|
|
758
1079
|
}
|
|
759
1080
|
/**
|
|
@@ -871,7 +1192,7 @@ var Query = class _Query {
|
|
|
871
1192
|
return serializePlan(this.plan);
|
|
872
1193
|
}
|
|
873
1194
|
};
|
|
874
|
-
function executePlanWithSource(source, plan, joinContext) {
|
|
1195
|
+
function executePlanWithSource(source, plan, joinContext, locale) {
|
|
875
1196
|
const hasCrossJoins = plan.clauses.some((c) => c.type === "crossJoin");
|
|
876
1197
|
let result;
|
|
877
1198
|
if (hasCrossJoins) {
|
|
@@ -883,10 +1204,11 @@ function executePlanWithSource(source, plan, joinContext) {
|
|
|
883
1204
|
result = executeClausePipeline(source, plan.clauses, joinContext);
|
|
884
1205
|
} else {
|
|
885
1206
|
const { candidates, remainingClauses } = candidateRecords(source, plan.clauses);
|
|
886
|
-
result = remainingClauses.length === 0 ? [...candidates] : filterRecords(candidates, remainingClauses);
|
|
1207
|
+
result = remainingClauses.length === 0 ? [...candidates] : filterRecords(candidates, remainingClauses, fnViewDecoder(source));
|
|
887
1208
|
}
|
|
888
1209
|
if (plan.orderBy.length > 0) {
|
|
889
|
-
|
|
1210
|
+
const labelMaps = buildOrderLabelMaps(plan.orderBy, joinContext, locale);
|
|
1211
|
+
result = sortRecords(result, plan.orderBy, source.moneyFields, labelMaps);
|
|
890
1212
|
}
|
|
891
1213
|
if (plan.offset > 0) {
|
|
892
1214
|
result = result.slice(plan.offset);
|
|
@@ -906,6 +1228,7 @@ function candidateRecords(source, clauses) {
|
|
|
906
1228
|
const clause = clauses[i];
|
|
907
1229
|
if (clause.type !== "field") continue;
|
|
908
1230
|
if (!indexes.has(clause.field)) continue;
|
|
1231
|
+
if (clause.money?.mode === "multi") continue;
|
|
909
1232
|
let ids = null;
|
|
910
1233
|
if (clause.op === "==") {
|
|
911
1234
|
ids = indexes.lookupEqual(clause.field, clause.value);
|
|
@@ -951,13 +1274,20 @@ function executePlan(records, plan) {
|
|
|
951
1274
|
}
|
|
952
1275
|
return result;
|
|
953
1276
|
}
|
|
954
|
-
function
|
|
1277
|
+
function fnViewDecoder(source) {
|
|
1278
|
+
const mf = source.moneyFields;
|
|
1279
|
+
if (!mf || Object.keys(mf).length === 0) return void 0;
|
|
1280
|
+
return (r) => decodeMoneyFields(r, mf, "raw");
|
|
1281
|
+
}
|
|
1282
|
+
function filterRecords(records, clauses, decodeForFns) {
|
|
955
1283
|
if (clauses.length === 0) return [...records];
|
|
1284
|
+
const needsFnView = decodeForFns !== void 0 && hasFnClause(clauses);
|
|
956
1285
|
const out = [];
|
|
957
1286
|
for (const r of records) {
|
|
1287
|
+
const fnView = needsFnView ? decodeForFns(r) : void 0;
|
|
958
1288
|
let matches = true;
|
|
959
1289
|
for (const clause of clauses) {
|
|
960
|
-
if (!evaluateClause(r, clause)) {
|
|
1290
|
+
if (!evaluateClause(r, clause, fnView)) {
|
|
961
1291
|
matches = false;
|
|
962
1292
|
break;
|
|
963
1293
|
}
|
|
@@ -969,10 +1299,11 @@ function filterRecords(records, clauses) {
|
|
|
969
1299
|
function executeClausePipeline(source, clauses, joinContext) {
|
|
970
1300
|
let rel = [...source.snapshot()];
|
|
971
1301
|
let filterBatch = [];
|
|
1302
|
+
const decodeForFns = fnViewDecoder(source);
|
|
972
1303
|
for (const clause of clauses) {
|
|
973
1304
|
if (clause.type === "crossJoin") {
|
|
974
1305
|
if (filterBatch.length > 0) {
|
|
975
|
-
rel = filterRecords(rel, filterBatch);
|
|
1306
|
+
rel = filterRecords(rel, filterBatch, decodeForFns);
|
|
976
1307
|
filterBatch = [];
|
|
977
1308
|
}
|
|
978
1309
|
const rightSource = joinContext.resolveSource(clause.target);
|
|
@@ -985,7 +1316,7 @@ function executeClausePipeline(source, clauses, joinContext) {
|
|
|
985
1316
|
}
|
|
986
1317
|
}
|
|
987
1318
|
if (filterBatch.length > 0) {
|
|
988
|
-
rel = filterRecords(rel, filterBatch);
|
|
1319
|
+
rel = filterRecords(rel, filterBatch, decodeForFns);
|
|
989
1320
|
}
|
|
990
1321
|
return rel;
|
|
991
1322
|
}
|
|
@@ -1034,17 +1365,55 @@ function applyCrossJoin(leftRel, clause, rightSource) {
|
|
|
1034
1365
|
}
|
|
1035
1366
|
return expanded;
|
|
1036
1367
|
}
|
|
1037
|
-
function sortRecords(records, orderBy) {
|
|
1368
|
+
function sortRecords(records, orderBy, moneyFields, labelMaps) {
|
|
1038
1369
|
return [...records].sort((a, b) => {
|
|
1039
|
-
for (const { field, direction } of orderBy) {
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
const
|
|
1370
|
+
for (const { field, direction, by } of orderBy) {
|
|
1371
|
+
let av = readField(a, field);
|
|
1372
|
+
let bv = readField(b, field);
|
|
1373
|
+
const labelMap = by === "label" ? labelMaps?.get(field) : void 0;
|
|
1374
|
+
if (labelMap) {
|
|
1375
|
+
av = (typeof av === "string" ? labelMap.get(av) : void 0) ?? av;
|
|
1376
|
+
bv = (typeof bv === "string" ? labelMap.get(bv) : void 0) ?? bv;
|
|
1377
|
+
const cmp2 = compareValues(av, bv);
|
|
1378
|
+
if (cmp2 !== 0) return direction === "asc" ? cmp2 : -cmp2;
|
|
1379
|
+
continue;
|
|
1380
|
+
}
|
|
1381
|
+
const desc = moneyFields?.[field];
|
|
1382
|
+
const cmp = desc ? compareMoney(av, bv, desc) : compareValues(av, bv);
|
|
1043
1383
|
if (cmp !== 0) return direction === "asc" ? cmp : -cmp;
|
|
1044
1384
|
}
|
|
1045
1385
|
return 0;
|
|
1046
1386
|
});
|
|
1047
1387
|
}
|
|
1388
|
+
function buildOrderLabelMaps(orderBy, joinContext, locale) {
|
|
1389
|
+
if (!joinContext?.resolveDictSource) return void 0;
|
|
1390
|
+
const resolveDict = joinContext.resolveDictSource.bind(joinContext);
|
|
1391
|
+
let maps;
|
|
1392
|
+
for (const { field, by } of orderBy) {
|
|
1393
|
+
if (by !== "label") continue;
|
|
1394
|
+
const dictSource = resolveDict(field);
|
|
1395
|
+
if (!dictSource) continue;
|
|
1396
|
+
const loc = locale ?? dictSource.displayLocale;
|
|
1397
|
+
if (loc === void 0) continue;
|
|
1398
|
+
const codeToLabel = /* @__PURE__ */ new Map();
|
|
1399
|
+
for (const entry of dictSource.snapshot()) {
|
|
1400
|
+
const k = entry["key"];
|
|
1401
|
+
const labels = entry["labels"];
|
|
1402
|
+
const label = labels?.[loc];
|
|
1403
|
+
if (typeof k === "string" && typeof label === "string") codeToLabel.set(k, label);
|
|
1404
|
+
}
|
|
1405
|
+
;
|
|
1406
|
+
(maps ??= /* @__PURE__ */ new Map()).set(field, codeToLabel);
|
|
1407
|
+
}
|
|
1408
|
+
return maps;
|
|
1409
|
+
}
|
|
1410
|
+
function compareMoney(a, b, desc) {
|
|
1411
|
+
const av = moneyScaledValue(a, desc);
|
|
1412
|
+
const bv = moneyScaledValue(b, desc);
|
|
1413
|
+
if (av === null) return bv === null ? 0 : 1;
|
|
1414
|
+
if (bv === null) return -1;
|
|
1415
|
+
return av < bv ? -1 : av > bv ? 1 : 0;
|
|
1416
|
+
}
|
|
1048
1417
|
function readField(record, field) {
|
|
1049
1418
|
if (record === null || record === void 0) return void 0;
|
|
1050
1419
|
if (!field.includes(".")) {
|
|
@@ -1131,6 +1500,7 @@ function buildDictLabelResolver(joinCtx, field) {
|
|
|
1131
1500
|
const dictSource = joinCtx.resolveDictSource(field);
|
|
1132
1501
|
if (!dictSource) return void 0;
|
|
1133
1502
|
const snapshot = dictSource.snapshot();
|
|
1503
|
+
const displayLocale = dictSource.displayLocale;
|
|
1134
1504
|
const dictMap = /* @__PURE__ */ new Map();
|
|
1135
1505
|
for (const entry of snapshot) {
|
|
1136
1506
|
const k = entry["key"];
|
|
@@ -1140,9 +1510,11 @@ function buildDictLabelResolver(joinCtx, field) {
|
|
|
1140
1510
|
}
|
|
1141
1511
|
}
|
|
1142
1512
|
return async (key, locale, fallback) => {
|
|
1513
|
+
const effLocale = locale || displayLocale;
|
|
1514
|
+
if (!effLocale) return void 0;
|
|
1143
1515
|
const labels = dictMap.get(key);
|
|
1144
1516
|
if (!labels) return void 0;
|
|
1145
|
-
if (labels[
|
|
1517
|
+
if (labels[effLocale] !== void 0) return labels[effLocale];
|
|
1146
1518
|
const chain = Array.isArray(fallback) ? fallback : fallback ? [fallback] : [];
|
|
1147
1519
|
for (const fb of chain) {
|
|
1148
1520
|
if (fb === "any") {
|
|
@@ -1156,7 +1528,7 @@ function buildDictLabelResolver(joinCtx, field) {
|
|
|
1156
1528
|
};
|
|
1157
1529
|
}
|
|
1158
1530
|
|
|
1159
|
-
// src/query/scan-builder.ts
|
|
1531
|
+
// src/kernel/query/scan-builder.ts
|
|
1160
1532
|
var DEFAULT_SCAN_PAGE_SIZE = 100;
|
|
1161
1533
|
var ScanBuilder = class _ScanBuilder {
|
|
1162
1534
|
pageProvider;
|
|
@@ -1182,12 +1554,29 @@ var ScanBuilder = class _ScanBuilder {
|
|
|
1182
1554
|
* context throws with an actionable error.
|
|
1183
1555
|
*/
|
|
1184
1556
|
joinContext;
|
|
1185
|
-
|
|
1557
|
+
/**
|
|
1558
|
+
* Money field descriptors for the backing collection. When present, yielded
|
|
1559
|
+
* records are decoded (stored scaled-int → canonical decimal) so `scan()`
|
|
1560
|
+
* agrees with `get()`/`list()`/`query().toArray()`. Decoded with
|
|
1561
|
+
* `'raw'` (canonical decimal, no locale-formatted virtuals) since the scan
|
|
1562
|
+
* stream carries no locale context, mirroring `Query.toArray()`.
|
|
1563
|
+
*/
|
|
1564
|
+
moneyFields;
|
|
1565
|
+
constructor(pageProvider, pageSize = DEFAULT_SCAN_PAGE_SIZE, clauses = [], joins = [], joinContext, moneyFields) {
|
|
1186
1566
|
this.pageProvider = pageProvider;
|
|
1187
1567
|
this.pageSize = pageSize;
|
|
1188
1568
|
this.clauses = clauses;
|
|
1189
1569
|
this.joins = joins;
|
|
1190
1570
|
this.joinContext = joinContext;
|
|
1571
|
+
this.moneyFields = moneyFields;
|
|
1572
|
+
}
|
|
1573
|
+
/**
|
|
1574
|
+
* Decode this scan's money fields on a record (stored scaled-int → canonical
|
|
1575
|
+
* decimal). No-op when no money fields are declared. See {@link moneyFields}.
|
|
1576
|
+
*/
|
|
1577
|
+
decodeMoney(record) {
|
|
1578
|
+
if (!this.moneyFields || Object.keys(this.moneyFields).length === 0) return record;
|
|
1579
|
+
return decodeMoneyFields(record, this.moneyFields, "raw");
|
|
1191
1580
|
}
|
|
1192
1581
|
/**
|
|
1193
1582
|
* Add a field comparison. Runs per record as the scan stream
|
|
@@ -1203,13 +1592,15 @@ var ScanBuilder = class _ScanBuilder {
|
|
|
1203
1592
|
* evaluates clauses per record in O(1) per clause.
|
|
1204
1593
|
*/
|
|
1205
1594
|
where(field, op, value) {
|
|
1206
|
-
const
|
|
1595
|
+
const desc = this.moneyFields?.[field];
|
|
1596
|
+
const clause = desc ? moneyFieldClause(field, op, value, desc) : { type: "field", field, op, value };
|
|
1207
1597
|
return new _ScanBuilder(
|
|
1208
1598
|
this.pageProvider,
|
|
1209
1599
|
this.pageSize,
|
|
1210
1600
|
[...this.clauses, clause],
|
|
1211
1601
|
this.joins,
|
|
1212
|
-
this.joinContext
|
|
1602
|
+
this.joinContext,
|
|
1603
|
+
this.moneyFields
|
|
1213
1604
|
);
|
|
1214
1605
|
}
|
|
1215
1606
|
/**
|
|
@@ -1228,7 +1619,8 @@ var ScanBuilder = class _ScanBuilder {
|
|
|
1228
1619
|
this.pageSize,
|
|
1229
1620
|
[...this.clauses, clause],
|
|
1230
1621
|
this.joins,
|
|
1231
|
-
this.joinContext
|
|
1622
|
+
this.joinContext,
|
|
1623
|
+
this.moneyFields
|
|
1232
1624
|
);
|
|
1233
1625
|
}
|
|
1234
1626
|
/**
|
|
@@ -1339,7 +1731,8 @@ var ScanBuilder = class _ScanBuilder {
|
|
|
1339
1731
|
this.pageSize,
|
|
1340
1732
|
this.clauses,
|
|
1341
1733
|
[...this.joins, leg],
|
|
1342
|
-
this.joinContext
|
|
1734
|
+
this.joinContext,
|
|
1735
|
+
this.moneyFields
|
|
1343
1736
|
);
|
|
1344
1737
|
}
|
|
1345
1738
|
/**
|
|
@@ -1356,10 +1749,11 @@ var ScanBuilder = class _ScanBuilder {
|
|
|
1356
1749
|
while (true) {
|
|
1357
1750
|
for (const record of page.items) {
|
|
1358
1751
|
if (!this.recordMatches(record)) continue;
|
|
1752
|
+
const decoded = this.decodeMoney(record);
|
|
1359
1753
|
if (joinResolvers === null) {
|
|
1360
|
-
yield
|
|
1754
|
+
yield decoded;
|
|
1361
1755
|
} else {
|
|
1362
|
-
let attached =
|
|
1756
|
+
let attached = decoded;
|
|
1363
1757
|
for (const resolver of joinResolvers) {
|
|
1364
1758
|
attached = this.applyOneJoinStreaming(attached, resolver);
|
|
1365
1759
|
}
|
|
@@ -1483,43 +1877,8 @@ var ScanBuilder = class _ScanBuilder {
|
|
|
1483
1877
|
}
|
|
1484
1878
|
return merged;
|
|
1485
1879
|
}
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
* return the final aggregated shape.
|
|
1489
|
-
*
|
|
1490
|
-
* Memory is O(reducers): one mutable state slot per spec key.
|
|
1491
|
-
* Records flow through the pipeline one at a time via
|
|
1492
|
-
* `for await` and are discarded after their `step()` is applied
|
|
1493
|
-
* — never collected into an array. This is the distinguishing
|
|
1494
|
-
* property from `Query.aggregate()`, which materializes the full
|
|
1495
|
-
* match set first.
|
|
1496
|
-
*
|
|
1497
|
-
* Reuses the same reducer protocol as `Query.aggregate()`,
|
|
1498
|
-
* so `count()`, `sum(field)`, `avg(field)`, `min(field)`,
|
|
1499
|
-
* `max(field)` all work unchanged. The `{ seed }` parameter
|
|
1500
|
-
* plumbing from constraint #2 is honored transparently — the
|
|
1501
|
-
* factories ignore it in and the scan executor never
|
|
1502
|
-
* touches the per-reducer state construction.
|
|
1503
|
-
*
|
|
1504
|
-
* **Returns a Promise**, unlike `Query.aggregate().run()` which
|
|
1505
|
-
* is synchronous. The scan is inherently async because it walks
|
|
1506
|
-
* adapter pages, so the terminal has to be too. Consumers
|
|
1507
|
-
* destructure with await:
|
|
1508
|
-
*
|
|
1509
|
-
* ```ts
|
|
1510
|
-
* const { total, n } = await invoices.scan()
|
|
1511
|
-
* .where('year', '==', 2025)
|
|
1512
|
-
* .aggregate({ total: sum('amount'), n: count() })
|
|
1513
|
-
* ```
|
|
1514
|
-
*
|
|
1515
|
-
* **No `.live()` in.** `scan().aggregate().live()` would
|
|
1516
|
-
* require reconciling an unbounded streaming iteration with a
|
|
1517
|
-
* change-stream subscription — a design problem, not just a code
|
|
1518
|
-
* one. Consumers with huge collections and live needs should
|
|
1519
|
-
* narrow with `.where()` enough to fit in the 50k `query()`
|
|
1520
|
-
* limit and use `query().aggregate().live()` instead.
|
|
1521
|
-
*/
|
|
1522
|
-
async aggregate(spec) {
|
|
1880
|
+
async aggregate(specOrBuild) {
|
|
1881
|
+
const spec = typeof specOrBuild === "function" ? specOrBuild(reducerBuilder) : specOrBuild;
|
|
1523
1882
|
const keys = Object.keys(spec);
|
|
1524
1883
|
const state = {};
|
|
1525
1884
|
for (const key of keys) {
|
|
@@ -1545,8 +1904,9 @@ var ScanBuilder = class _ScanBuilder {
|
|
|
1545
1904
|
*/
|
|
1546
1905
|
recordMatches(record) {
|
|
1547
1906
|
if (this.clauses.length === 0) return true;
|
|
1907
|
+
const fnView = this.moneyFields && Object.keys(this.moneyFields).length > 0 && hasFnClause(this.clauses) ? this.decodeMoney(record) : void 0;
|
|
1548
1908
|
for (const clause of this.clauses) {
|
|
1549
|
-
if (!evaluateClause(record, clause)) return false;
|
|
1909
|
+
if (!evaluateClause(record, clause, fnView)) return false;
|
|
1550
1910
|
}
|
|
1551
1911
|
return true;
|
|
1552
1912
|
}
|
|
@@ -1559,6 +1919,11 @@ function coerceRefKey2(value) {
|
|
|
1559
1919
|
}
|
|
1560
1920
|
|
|
1561
1921
|
export {
|
|
1922
|
+
validateMoneyFieldPaths,
|
|
1923
|
+
canonicalizeStoredMoney,
|
|
1924
|
+
canonicalizeIncomingMoney,
|
|
1925
|
+
quantizeMoneyFields,
|
|
1926
|
+
decodeMoneyFields,
|
|
1562
1927
|
DEFAULT_JOIN_MAX_ROWS,
|
|
1563
1928
|
applyJoins,
|
|
1564
1929
|
resetJoinWarnings,
|
|
@@ -1569,4 +1934,4 @@ export {
|
|
|
1569
1934
|
executePlan,
|
|
1570
1935
|
ScanBuilder
|
|
1571
1936
|
};
|
|
1572
|
-
//# sourceMappingURL=chunk-
|
|
1937
|
+
//# sourceMappingURL=chunk-UIU2THRG.js.map
|