@noy-db/hub 0.2.0-pre.13 → 0.2.0-pre.15
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/dist/aggregate/index.cjs +56 -56
- package/dist/aggregate/index.cjs.map +1 -1
- package/dist/aggregate/index.d.cts +2 -2
- package/dist/aggregate/index.d.ts +2 -2
- package/dist/aggregate/index.js +4 -4
- package/dist/attestation/index.cjs.map +1 -1
- package/dist/attestation/index.d.cts +5 -5
- package/dist/attestation/index.d.ts +5 -5
- package/dist/attestation/index.js +5 -5
- package/dist/blobs/index.cjs.map +1 -1
- package/dist/blobs/index.d.cts +6 -6
- package/dist/blobs/index.d.ts +6 -6
- package/dist/blobs/index.js +4 -4
- package/dist/bundle/index.cjs +559 -76
- package/dist/bundle/index.cjs.map +1 -1
- package/dist/bundle/index.d.cts +7 -7
- package/dist/bundle/index.d.ts +7 -7
- package/dist/bundle/index.js +8 -8
- package/dist/{chunk-YWBHS25M.js → chunk-3EWXMOK3.js} +8 -267
- package/dist/chunk-3EWXMOK3.js.map +1 -0
- package/dist/{chunk-SJ24GHID.js → chunk-4TBBMHVC.js} +2 -2
- package/dist/{chunk-NKGY3C53.js → chunk-535SSHBS.js} +8 -1
- package/dist/{chunk-NKGY3C53.js.map → chunk-535SSHBS.js.map} +1 -1
- package/dist/{chunk-HQXOEWLZ.js → chunk-56DJ7JVK.js} +3 -3
- package/dist/{chunk-KKB42D3Q.js → chunk-5LQG6ZO2.js} +2 -2
- package/dist/{chunk-TDECYU4Y.js → chunk-6AJBSQU4.js} +2 -2
- package/dist/{chunk-O2JW656W.js → chunk-6RR3MNMG.js} +3 -3
- package/dist/{chunk-P5MW7BG2.js → chunk-7EFFHEN5.js} +57 -50
- package/dist/chunk-7EFFHEN5.js.map +1 -0
- package/dist/{chunk-7TEI2K2A.js → chunk-7HT2MEZ5.js} +4 -4
- package/dist/{chunk-WQKZIQIL.js → chunk-7PS7EOCF.js} +3 -3
- package/dist/{chunk-C3WRKABE.js → chunk-A5ZOOZFB.js} +3 -3
- package/dist/{chunk-5NISHSBO.js → chunk-AAVWKNZW.js} +2 -2
- package/dist/{chunk-SOU42FGB.js → chunk-BIYRQQV6.js} +4 -4
- package/dist/{chunk-ILWQGTNH.js → chunk-BQ65SS5A.js} +2 -2
- package/dist/{chunk-CWFQTAD4.js → chunk-C5T5AFWN.js} +4 -4
- package/dist/chunk-CJORTUJ2.js +524 -0
- package/dist/chunk-CJORTUJ2.js.map +1 -0
- package/dist/{chunk-SYSKC237.js → chunk-COFPAMX6.js} +5 -5
- package/dist/{chunk-D5Y3HIC6.js → chunk-CZI2A4MQ.js} +3 -3
- package/dist/{chunk-KJF7EPUE.js → chunk-DKO2QFSA.js} +2 -2
- package/dist/{chunk-QFYVGJLI.js → chunk-DQU36Q7I.js} +2 -2
- package/dist/{chunk-NIUXQDWD.js → chunk-EGD5DXFT.js} +2 -2
- package/dist/{chunk-NJMKHRQI.js → chunk-EYVQHAGH.js} +267 -67
- package/dist/chunk-EYVQHAGH.js.map +1 -0
- package/dist/{chunk-KHQ3N5AB.js → chunk-F4OJZIWQ.js} +4 -4
- package/dist/{chunk-3OUCWHV6.js → chunk-FWPKCXTN.js} +2 -2
- package/dist/{chunk-QIVFGU2M.js → chunk-HOR4R722.js} +3 -3
- package/dist/{chunk-NP6EZT44.js → chunk-IQLVUT37.js} +2 -2
- package/dist/{chunk-4VCQH32J.js → chunk-JD3OZAI4.js} +2 -2
- package/dist/{chunk-J67BP5EP.js → chunk-KI6HAJWL.js} +3 -3
- package/dist/{chunk-AYNF7PVX.js → chunk-KIP6JLTF.js} +2 -2
- package/dist/{chunk-PW26DAXS.js → chunk-L2FE64BU.js} +3 -3
- package/dist/{chunk-QAWCVWCX.js → chunk-LX3CB26H.js} +4 -4
- package/dist/{chunk-VAK6NQAK.js → chunk-NSCVNK5K.js} +4 -4
- package/dist/{chunk-4YDZ7JPZ.js → chunk-NU6Q3FOR.js} +4 -4
- package/dist/chunk-NU6Q3FOR.js.map +1 -0
- package/dist/{chunk-3XZRRBFW.js → chunk-OHVFWCJP.js} +2 -2
- package/dist/{chunk-TEQGXA7L.js → chunk-PE4AQGFH.js} +4 -4
- package/dist/{chunk-UNQEWORI.js → chunk-TS26M2SB.js} +2 -2
- package/dist/{chunk-FNVFT4HZ.js → chunk-VU7SWWT5.js} +2 -2
- package/dist/{chunk-GZJ5JBED.js → chunk-WBAYSNUQ.js} +3 -3
- package/dist/{chunk-HHZ77DHM.js → chunk-WGHU7BLI.js} +2 -2
- package/dist/{chunk-GL3Z7LH7.js → chunk-X73VS74Y.js} +2 -2
- package/dist/{chunk-WIBHRONM.js → chunk-XWH4MXIU.js} +2 -2
- package/dist/{chunk-M6KXHRIA.js → chunk-YHPM5D7Y.js} +3 -3
- package/dist/{chunk-E3DIBDKA.js → chunk-YULZKK4F.js} +2 -2
- package/dist/{chunk-JWFNOD2T.js → chunk-Z4DO7YSI.js} +2 -2
- package/dist/{chunk-JPOQMXGT.js → chunk-ZNQYHJXX.js} +2 -2
- package/dist/consent/index.cjs.map +1 -1
- package/dist/consent/index.d.cts +6 -6
- package/dist/consent/index.d.ts +6 -6
- package/dist/consent/index.js +3 -3
- package/dist/{crypto-YXH6SAOW.js → crypto-QXQOHMHF.js} +3 -3
- package/dist/{delegation-K5ERUH6A.js → delegation-NIQ43IPU.js} +5 -5
- package/dist/derivations/index.cjs.map +1 -1
- package/dist/derivations/index.d.cts +7 -7
- package/dist/derivations/index.d.ts +7 -7
- package/dist/derivations/index.js +4 -4
- package/dist/{dev-unlock-BW0GNBEV.d.ts → dev-unlock-iAS8z9jc.d.ts} +1 -1
- package/dist/{dev-unlock-a7SOtaV0.d.cts → dev-unlock-nVkuRLLe.d.cts} +1 -1
- package/dist/executor-6ZDSDZ6V.js +8 -0
- package/dist/executor-HSSRXDOB.js +11 -0
- package/dist/executor-IDZDAFNH.js +8 -0
- package/dist/guards/index.cjs.map +1 -1
- package/dist/guards/index.d.cts +7 -7
- package/dist/guards/index.d.ts +7 -7
- package/dist/guards/index.js +3 -3
- package/dist/{hash-B0cLQcq_.d.cts → hash-Cv6byZs7.d.cts} +1 -1
- package/dist/{hash-uMNIAAW8.d.ts → hash-DHOnRarj.d.ts} +1 -1
- package/dist/history/index.cjs.map +1 -1
- package/dist/history/index.d.cts +7 -7
- package/dist/history/index.d.ts +7 -7
- package/dist/history/index.js +4 -4
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/i18n/index.d.cts +6 -6
- package/dist/i18n/index.d.ts +6 -6
- package/dist/i18n/index.js +5 -5
- package/dist/{immutable-guard-B0h-ipLz.d.ts → immutable-guard-BehB1YGB.d.ts} +1 -1
- package/dist/{immutable-guard-BZIcYhYX.d.cts → immutable-guard-yBEOYmif.d.cts} +1 -1
- package/dist/{index-CUVOMtgg.d.cts → index-D95VK1Qy.d.cts} +11 -3
- package/dist/{index-Cqzp4tt9.d.ts → index-XNB2r6bX.d.ts} +11 -3
- package/dist/index.cjs +700 -78
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +145 -15
- package/dist/index.d.ts +145 -15
- package/dist/index.js +164 -48
- package/dist/index.js.map +1 -1
- package/dist/indexing/index.cjs +92 -31
- 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-ADVS4OVP.js +12 -0
- package/dist/{lazy-builder-D5GU14TS.d.ts → lazy-builder-ChSqcF5t.d.ts} +1 -1
- package/dist/{lazy-builder-Ci5_YG73.d.cts → lazy-builder-eYZzLEL1.d.cts} +1 -1
- package/dist/{ledger-64TTQMRS.js → ledger-CWSE3BLF.js} +4 -4
- package/dist/materialized-views/index.cjs +2 -2
- package/dist/materialized-views/index.cjs.map +1 -1
- package/dist/materialized-views/index.d.cts +7 -7
- package/dist/materialized-views/index.d.ts +7 -7
- package/dist/materialized-views/index.js +7 -7
- package/dist/noydb-GZGFBA4E.js +35 -0
- package/dist/overlay-views/index.cjs.map +1 -1
- package/dist/overlay-views/index.d.cts +7 -7
- package/dist/overlay-views/index.d.ts +7 -7
- package/dist/overlay-views/index.js +4 -4
- package/dist/periods/index.cjs.map +1 -1
- package/dist/periods/index.d.cts +6 -6
- package/dist/periods/index.d.ts +6 -6
- package/dist/periods/index.js +4 -4
- package/dist/{predicate-Bt5ft-9c.d.cts → predicate-BmhBSPCH.d.cts} +59 -2
- package/dist/{predicate-Bt5ft-9c.d.ts → predicate-BmhBSPCH.d.ts} +59 -2
- package/dist/{public-envelope-MHG6YVXW.js → public-envelope-SYHEYQ3X.js} +3 -3
- package/dist/query/index.cjs +580 -195
- package/dist/query/index.cjs.map +1 -1
- package/dist/query/index.d.cts +3 -3
- package/dist/query/index.d.ts +3 -3
- package/dist/query/index.js +6 -6
- package/dist/{registry-PV4G3OPA.js → registry-DK5YWAAA.js} +3 -3
- package/dist/registry-IUZQVVBB.js +8 -0
- package/dist/registry-XGLNADIE.js +8 -0
- package/dist/{revoke-5BOLVJ3N.js → revoke-ZDFKMR5E.js} +5 -5
- package/dist/session/index.cjs.map +1 -1
- package/dist/session/index.d.cts +7 -7
- package/dist/session/index.d.ts +7 -7
- package/dist/session/index.js +3 -3
- package/dist/shadow/index.cjs.map +1 -1
- package/dist/shadow/index.d.cts +6 -6
- package/dist/shadow/index.d.ts +6 -6
- package/dist/shadow/index.js +2 -2
- package/dist/{signer-GRIYBA22.js → signer-P5D7Y72U.js} +4 -4
- package/dist/snapshots/index.cjs.map +1 -1
- package/dist/snapshots/index.d.cts +6 -6
- package/dist/snapshots/index.d.ts +6 -6
- package/dist/snapshots/index.js +3 -3
- package/dist/{stale-LZYMMDDS.js → stale-JH67FU57.js} +2 -2
- package/dist/{state-vault-QFJWU23A.js → state-vault-TMXZRTY5.js} +3 -3
- package/dist/store/index.cjs.map +1 -1
- package/dist/store/index.d.cts +6 -6
- package/dist/store/index.d.ts +6 -6
- package/dist/store/index.js +2 -2
- package/dist/{strategy-CrS7PnbE.d.ts → strategy-CbneC7bS.d.cts} +1 -1
- package/dist/{strategy-CrS7PnbE.d.cts → strategy-CbneC7bS.d.ts} +1 -1
- package/dist/sync/index.cjs.map +1 -1
- package/dist/sync/index.d.cts +5 -5
- package/dist/sync/index.d.ts +5 -5
- package/dist/sync/index.js +3 -3
- package/dist/team/index.cjs.map +1 -1
- package/dist/team/index.d.cts +6 -6
- package/dist/team/index.d.ts +6 -6
- package/dist/team/index.js +7 -7
- package/dist/tx/index.cjs.map +1 -1
- package/dist/tx/index.d.cts +6 -6
- package/dist/tx/index.d.ts +6 -6
- package/dist/tx/index.js +3 -3
- package/dist/{types-pax34sec.d.ts → types-4t1-tWS4.d.ts} +77 -9
- package/dist/{types-CDwSSXiI.d.cts → types-BpPV5uyy.d.cts} +77 -9
- package/dist/{ulid-7bCSgIgb.d.cts → ulid-CiPrpGqm.d.cts} +1 -1
- package/dist/{ulid-C_t4hL3d.d.ts → ulid-DAfenvFd.d.ts} +1 -1
- package/dist/util/index.cjs.map +1 -1
- package/dist/util/index.js +1 -1
- package/dist/{vault-group-UO4YUZOG.js → vault-group-KOM7QRJG.js} +125 -11
- package/dist/vault-group-KOM7QRJG.js.map +1 -0
- package/dist/{with-derivation-D8wFlb6V.d.cts → with-derivation-DBqJB3dQ.d.cts} +1 -1
- package/dist/{with-derivation-BjdOxUBn.d.ts → with-derivation-OK9M2sJE.d.ts} +1 -1
- package/dist/{with-materialized-view-DJb-HO65.d.ts → with-materialized-view-Dt-ufPWQ.d.ts} +1 -1
- package/dist/{with-materialized-view-5QMF1rS_.d.cts → with-materialized-view-NzuxYPDF.d.cts} +1 -1
- package/dist/{with-overlayed-view-DDNflPvC.d.cts → with-overlayed-view-CC0_ocy-.d.cts} +1 -1
- package/dist/{with-overlayed-view-CkqTefbz.d.ts → with-overlayed-view-eDvMs6LO.d.ts} +1 -1
- package/package.json +3 -3
- package/dist/chunk-4YDZ7JPZ.js.map +0 -1
- package/dist/chunk-NJMKHRQI.js.map +0 -1
- package/dist/chunk-P5MW7BG2.js.map +0 -1
- package/dist/chunk-TV3YZ35S.js +0 -90
- package/dist/chunk-TV3YZ35S.js.map +0 -1
- package/dist/chunk-YWBHS25M.js.map +0 -1
- package/dist/executor-AVJ7UEWA.js +0 -8
- package/dist/executor-IQO3KGXQ.js +0 -11
- package/dist/executor-VT7TKGE4.js +0 -8
- package/dist/issue-ZH27C23Y.js +0 -12
- package/dist/noydb-O76SKBST.js +0 -35
- package/dist/registry-2PKBQDCH.js +0 -8
- package/dist/registry-4VXFKCBJ.js +0 -8
- package/dist/vault-group-UO4YUZOG.js.map +0 -1
- /package/dist/{chunk-SJ24GHID.js.map → chunk-4TBBMHVC.js.map} +0 -0
- /package/dist/{chunk-HQXOEWLZ.js.map → chunk-56DJ7JVK.js.map} +0 -0
- /package/dist/{chunk-KKB42D3Q.js.map → chunk-5LQG6ZO2.js.map} +0 -0
- /package/dist/{chunk-TDECYU4Y.js.map → chunk-6AJBSQU4.js.map} +0 -0
- /package/dist/{chunk-O2JW656W.js.map → chunk-6RR3MNMG.js.map} +0 -0
- /package/dist/{chunk-7TEI2K2A.js.map → chunk-7HT2MEZ5.js.map} +0 -0
- /package/dist/{chunk-WQKZIQIL.js.map → chunk-7PS7EOCF.js.map} +0 -0
- /package/dist/{chunk-C3WRKABE.js.map → chunk-A5ZOOZFB.js.map} +0 -0
- /package/dist/{chunk-5NISHSBO.js.map → chunk-AAVWKNZW.js.map} +0 -0
- /package/dist/{chunk-SOU42FGB.js.map → chunk-BIYRQQV6.js.map} +0 -0
- /package/dist/{chunk-ILWQGTNH.js.map → chunk-BQ65SS5A.js.map} +0 -0
- /package/dist/{chunk-CWFQTAD4.js.map → chunk-C5T5AFWN.js.map} +0 -0
- /package/dist/{chunk-SYSKC237.js.map → chunk-COFPAMX6.js.map} +0 -0
- /package/dist/{chunk-D5Y3HIC6.js.map → chunk-CZI2A4MQ.js.map} +0 -0
- /package/dist/{chunk-KJF7EPUE.js.map → chunk-DKO2QFSA.js.map} +0 -0
- /package/dist/{chunk-QFYVGJLI.js.map → chunk-DQU36Q7I.js.map} +0 -0
- /package/dist/{chunk-NIUXQDWD.js.map → chunk-EGD5DXFT.js.map} +0 -0
- /package/dist/{chunk-KHQ3N5AB.js.map → chunk-F4OJZIWQ.js.map} +0 -0
- /package/dist/{chunk-3OUCWHV6.js.map → chunk-FWPKCXTN.js.map} +0 -0
- /package/dist/{chunk-QIVFGU2M.js.map → chunk-HOR4R722.js.map} +0 -0
- /package/dist/{chunk-NP6EZT44.js.map → chunk-IQLVUT37.js.map} +0 -0
- /package/dist/{chunk-4VCQH32J.js.map → chunk-JD3OZAI4.js.map} +0 -0
- /package/dist/{chunk-J67BP5EP.js.map → chunk-KI6HAJWL.js.map} +0 -0
- /package/dist/{chunk-AYNF7PVX.js.map → chunk-KIP6JLTF.js.map} +0 -0
- /package/dist/{chunk-PW26DAXS.js.map → chunk-L2FE64BU.js.map} +0 -0
- /package/dist/{chunk-QAWCVWCX.js.map → chunk-LX3CB26H.js.map} +0 -0
- /package/dist/{chunk-VAK6NQAK.js.map → chunk-NSCVNK5K.js.map} +0 -0
- /package/dist/{chunk-3XZRRBFW.js.map → chunk-OHVFWCJP.js.map} +0 -0
- /package/dist/{chunk-TEQGXA7L.js.map → chunk-PE4AQGFH.js.map} +0 -0
- /package/dist/{chunk-UNQEWORI.js.map → chunk-TS26M2SB.js.map} +0 -0
- /package/dist/{chunk-FNVFT4HZ.js.map → chunk-VU7SWWT5.js.map} +0 -0
- /package/dist/{chunk-GZJ5JBED.js.map → chunk-WBAYSNUQ.js.map} +0 -0
- /package/dist/{chunk-HHZ77DHM.js.map → chunk-WGHU7BLI.js.map} +0 -0
- /package/dist/{chunk-GL3Z7LH7.js.map → chunk-X73VS74Y.js.map} +0 -0
- /package/dist/{chunk-WIBHRONM.js.map → chunk-XWH4MXIU.js.map} +0 -0
- /package/dist/{chunk-M6KXHRIA.js.map → chunk-YHPM5D7Y.js.map} +0 -0
- /package/dist/{chunk-E3DIBDKA.js.map → chunk-YULZKK4F.js.map} +0 -0
- /package/dist/{chunk-JWFNOD2T.js.map → chunk-Z4DO7YSI.js.map} +0 -0
- /package/dist/{chunk-JPOQMXGT.js.map → chunk-ZNQYHJXX.js.map} +0 -0
- /package/dist/{crypto-YXH6SAOW.js.map → crypto-QXQOHMHF.js.map} +0 -0
- /package/dist/{delegation-K5ERUH6A.js.map → delegation-NIQ43IPU.js.map} +0 -0
- /package/dist/{executor-AVJ7UEWA.js.map → executor-6ZDSDZ6V.js.map} +0 -0
- /package/dist/{executor-IQO3KGXQ.js.map → executor-HSSRXDOB.js.map} +0 -0
- /package/dist/{executor-VT7TKGE4.js.map → executor-IDZDAFNH.js.map} +0 -0
- /package/dist/{issue-ZH27C23Y.js.map → issue-ADVS4OVP.js.map} +0 -0
- /package/dist/{ledger-64TTQMRS.js.map → ledger-CWSE3BLF.js.map} +0 -0
- /package/dist/{noydb-O76SKBST.js.map → noydb-GZGFBA4E.js.map} +0 -0
- /package/dist/{public-envelope-MHG6YVXW.js.map → public-envelope-SYHEYQ3X.js.map} +0 -0
- /package/dist/{registry-2PKBQDCH.js.map → registry-DK5YWAAA.js.map} +0 -0
- /package/dist/{registry-4VXFKCBJ.js.map → registry-IUZQVVBB.js.map} +0 -0
- /package/dist/{registry-PV4G3OPA.js.map → registry-XGLNADIE.js.map} +0 -0
- /package/dist/{revoke-5BOLVJ3N.js.map → revoke-ZDFKMR5E.js.map} +0 -0
- /package/dist/{signer-GRIYBA22.js.map → signer-P5D7Y72U.js.map} +0 -0
- /package/dist/{stale-LZYMMDDS.js.map → stale-JH67FU57.js.map} +0 -0
- /package/dist/{state-vault-QFJWU23A.js.map → state-vault-TMXZRTY5.js.map} +0 -0
package/dist/bundle/index.cjs
CHANGED
|
@@ -31,7 +31,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
32
|
|
|
33
33
|
// src/errors.ts
|
|
34
|
-
var NoydbError, DecryptionError, TamperedError, InvalidKeyError, KeyringCorruptError, NoAccessError, ReadOnlyError, PermissionDeniedError, ExportCapabilityError, KeyringExpiredError, ImportCapabilityError, StoreCapabilityError, PrivilegeEscalationError, ReservedVaultNameError, FieldFrozenError, InvariantError, AmendmentForbiddenError, TierNotGrantedError, ElevationExpiredError, AlreadyElevatedError, TierDemoteDeniedError, DelegationTargetMissingError, ConflictError, LedgerContentionError, SequenceContentionError, SequenceOfflineError, NumberingUncertaintyError, BundleVersionConflictError, ValidationError, SchemaValidationError, SchemaUpdateError, SchemaFenceError, MigrationRequiredError, QuiesceTimeoutError, GroupCardinalityError, IndexRequiredError, UniqueConstraintError, UnsupportedIndexOptionError, IndexWriteFailureError, BundleIntegrityError, BundleSealMismatchError, ReservedCollectionNameError, LocaleNotSpecifiedError, TranslatorNotConfiguredError, BackupLedgerError, BackupCorruptedError, PartitionExtractionError, TransferSealError, AdoptionStateError, AttestationError, JoinTooLargeError, CrossJoinTooLargeError, CrossJoinSourceUnknownError, DanglingReferenceError, DerivationCycleError, DerivationOutputShapeError, DerivationCapExceededError, MaterializedViewCycleError, MaterializedViewSourceUnknownError, MaterializedViewTooLargeError, OverlayBaseIsVirtualError, OverlayCollectionUnavailableError, OverlayNameCollisionError, OverlayIdMismatchError, UnknownShardError, ShardProvisioningError, VaultTemplateNotFoundError;
|
|
34
|
+
var NoydbError, DecryptionError, TamperedError, InvalidKeyError, KeyringCorruptError, NoAccessError, ReadOnlyError, PermissionDeniedError, ExportCapabilityError, KeyringExpiredError, ImportCapabilityError, StoreCapabilityError, PrivilegeEscalationError, ReservedVaultNameError, FieldFrozenError, InvariantError, AmendmentForbiddenError, TierNotGrantedError, ElevationExpiredError, AlreadyElevatedError, TierDemoteDeniedError, DelegationTargetMissingError, ConflictError, LedgerContentionError, SequenceContentionError, SequenceOfflineError, NumberingUncertaintyError, BundleVersionConflictError, ValidationError, SchemaValidationError, SchemaUpdateError, SchemaFenceError, MigrationRequiredError, QuiesceTimeoutError, GroupCardinalityError, IndexRequiredError, UniqueConstraintError, UnsupportedIndexOptionError, IndexWriteFailureError, BundleIntegrityError, BundleSealMismatchError, ReservedCollectionNameError, LocaleNotSpecifiedError, TranslatorNotConfiguredError, BackupLedgerError, BackupCorruptedError, PartitionExtractionError, TransferSealError, AdoptionStateError, AttestationError, JoinTooLargeError, CrossJoinTooLargeError, CrossJoinSourceUnknownError, DanglingReferenceError, DerivationCycleError, DerivationOutputShapeError, DerivationCapExceededError, MaterializedViewCycleError, MaterializedViewSourceUnknownError, MaterializedViewTooLargeError, OverlayBaseIsVirtualError, OverlayCollectionUnavailableError, OverlayNameCollisionError, OverlayIdMismatchError, UnknownShardError, ShardProvisioningError, CrossShardJoinError, VaultTemplateNotFoundError;
|
|
35
35
|
var init_errors = __esm({
|
|
36
36
|
"src/errors.ts"() {
|
|
37
37
|
"use strict";
|
|
@@ -746,6 +746,12 @@ Resolutions:
|
|
|
746
746
|
this.vaultId = vaultId;
|
|
747
747
|
}
|
|
748
748
|
};
|
|
749
|
+
CrossShardJoinError = class extends NoydbError {
|
|
750
|
+
constructor(message) {
|
|
751
|
+
super("CROSS_SHARD_JOIN", message);
|
|
752
|
+
this.name = "CrossShardJoinError";
|
|
753
|
+
}
|
|
754
|
+
};
|
|
749
755
|
VaultTemplateNotFoundError = class extends NoydbError {
|
|
750
756
|
templateName;
|
|
751
757
|
constructor(templateName) {
|
|
@@ -3888,6 +3894,115 @@ var init_descriptor = __esm({
|
|
|
3888
3894
|
}
|
|
3889
3895
|
});
|
|
3890
3896
|
|
|
3897
|
+
// src/money/paths.ts
|
|
3898
|
+
function parseMoneyPath(path) {
|
|
3899
|
+
const cached = parseCache.get(path);
|
|
3900
|
+
if (cached) return cached;
|
|
3901
|
+
if (typeof path !== "string" || path.length === 0) {
|
|
3902
|
+
throw new ValidationError("moneyFields: path must be a non-empty string");
|
|
3903
|
+
}
|
|
3904
|
+
const segments = [];
|
|
3905
|
+
for (const part of path.split(".")) {
|
|
3906
|
+
const m = SEGMENT_RE.exec(part);
|
|
3907
|
+
if (!m) {
|
|
3908
|
+
throw new ValidationError(
|
|
3909
|
+
`moneyFields: invalid path "${path}" \u2014 segment "${part}" must be a key, "key[]", "*", or "*[]"`
|
|
3910
|
+
);
|
|
3911
|
+
}
|
|
3912
|
+
const array = m[2] === "[]";
|
|
3913
|
+
segments.push(
|
|
3914
|
+
m[1] === "*" ? { kind: "wildcard", array } : { kind: "key", key: m[1], array }
|
|
3915
|
+
);
|
|
3916
|
+
}
|
|
3917
|
+
parseCache.set(path, segments);
|
|
3918
|
+
return segments;
|
|
3919
|
+
}
|
|
3920
|
+
function isSimpleMoneyPath(path) {
|
|
3921
|
+
return !path.includes(".") && !path.includes("[") && !path.includes("*");
|
|
3922
|
+
}
|
|
3923
|
+
function validateMoneyFieldPaths(moneyFields) {
|
|
3924
|
+
for (const path of Object.keys(moneyFields)) parseMoneyPath(path);
|
|
3925
|
+
}
|
|
3926
|
+
function transformAtMoneyPath(node, path, segments, index, visit, lenient) {
|
|
3927
|
+
if (node === null || node === void 0) return node;
|
|
3928
|
+
const seg = segments[index];
|
|
3929
|
+
const last = index === segments.length - 1;
|
|
3930
|
+
if (seg.kind === "key") {
|
|
3931
|
+
if (typeof node !== "object" || Array.isArray(node)) {
|
|
3932
|
+
if (lenient) return node;
|
|
3933
|
+
throw new ValidationError(
|
|
3934
|
+
`moneyFields: path "${path}" expected an object at segment "${seg.key}", got ${Array.isArray(node) ? "an array" : typeof node}`
|
|
3935
|
+
);
|
|
3936
|
+
}
|
|
3937
|
+
const obj2 = node;
|
|
3938
|
+
if (!(seg.key in obj2) || obj2[seg.key] === null || obj2[seg.key] === void 0) return node;
|
|
3939
|
+
if (seg.array) {
|
|
3940
|
+
const arr = obj2[seg.key];
|
|
3941
|
+
if (!Array.isArray(arr)) {
|
|
3942
|
+
if (lenient) return node;
|
|
3943
|
+
throw new ValidationError(
|
|
3944
|
+
`moneyFields: path "${path}" declares "${seg.key}[]" but the value is not an array`
|
|
3945
|
+
);
|
|
3946
|
+
}
|
|
3947
|
+
const cloned = [...arr];
|
|
3948
|
+
if (last) {
|
|
3949
|
+
for (let i = 0; i < cloned.length; i++) visit(cloned, i);
|
|
3950
|
+
} else {
|
|
3951
|
+
for (let i = 0; i < cloned.length; i++) {
|
|
3952
|
+
cloned[i] = transformAtMoneyPath(cloned[i], path, segments, index + 1, visit, lenient);
|
|
3953
|
+
}
|
|
3954
|
+
}
|
|
3955
|
+
return { ...obj2, [seg.key]: cloned };
|
|
3956
|
+
}
|
|
3957
|
+
const clone3 = { ...obj2 };
|
|
3958
|
+
if (last) {
|
|
3959
|
+
visit(clone3, seg.key);
|
|
3960
|
+
} else {
|
|
3961
|
+
clone3[seg.key] = transformAtMoneyPath(clone3[seg.key], path, segments, index + 1, visit, lenient);
|
|
3962
|
+
}
|
|
3963
|
+
return clone3;
|
|
3964
|
+
}
|
|
3965
|
+
if (seg.array) {
|
|
3966
|
+
if (!Array.isArray(node)) {
|
|
3967
|
+
if (lenient) return node;
|
|
3968
|
+
throw new ValidationError(`moneyFields: path "${path}" declares "*[]" but the value is not an array`);
|
|
3969
|
+
}
|
|
3970
|
+
const cloned = [...node];
|
|
3971
|
+
if (last) {
|
|
3972
|
+
for (let i = 0; i < cloned.length; i++) visit(cloned, i);
|
|
3973
|
+
} else {
|
|
3974
|
+
for (let i = 0; i < cloned.length; i++) {
|
|
3975
|
+
cloned[i] = transformAtMoneyPath(cloned[i], path, segments, index + 1, visit, lenient);
|
|
3976
|
+
}
|
|
3977
|
+
}
|
|
3978
|
+
return cloned;
|
|
3979
|
+
}
|
|
3980
|
+
if (typeof node !== "object" || Array.isArray(node)) {
|
|
3981
|
+
if (lenient) return node;
|
|
3982
|
+
throw new ValidationError(
|
|
3983
|
+
`moneyFields: path "${path}" applies "*" to a non-object (${Array.isArray(node) ? 'array \u2014 use "*[]"' : typeof node})`
|
|
3984
|
+
);
|
|
3985
|
+
}
|
|
3986
|
+
const obj = node;
|
|
3987
|
+
const clone2 = { ...obj };
|
|
3988
|
+
for (const key of Object.keys(obj)) {
|
|
3989
|
+
const v = clone2[key];
|
|
3990
|
+
if (v === null || v === void 0) continue;
|
|
3991
|
+
if (last) visit(clone2, key);
|
|
3992
|
+
else clone2[key] = transformAtMoneyPath(v, path, segments, index + 1, visit, lenient);
|
|
3993
|
+
}
|
|
3994
|
+
return clone2;
|
|
3995
|
+
}
|
|
3996
|
+
var SEGMENT_RE, parseCache;
|
|
3997
|
+
var init_paths = __esm({
|
|
3998
|
+
"src/money/paths.ts"() {
|
|
3999
|
+
"use strict";
|
|
4000
|
+
init_errors();
|
|
4001
|
+
SEGMENT_RE = /^(\*|[^.[\]*]+)(\[\])?$/;
|
|
4002
|
+
parseCache = /* @__PURE__ */ new Map();
|
|
4003
|
+
}
|
|
4004
|
+
});
|
|
4005
|
+
|
|
3891
4006
|
// src/money/normalize.ts
|
|
3892
4007
|
function isMoneyValueObject(v) {
|
|
3893
4008
|
return typeof v === "object" && v !== null && "currency" in v;
|
|
@@ -3900,33 +4015,68 @@ function quantizeAmount(field, input, scale, rounding) {
|
|
|
3900
4015
|
}
|
|
3901
4016
|
return r.value.toString();
|
|
3902
4017
|
}
|
|
4018
|
+
function canonicalizeStoredMoney(record, moneyFields) {
|
|
4019
|
+
if (record === null || record === void 0) return record;
|
|
4020
|
+
if (!moneyFields || Object.keys(moneyFields).length === 0) return record;
|
|
4021
|
+
return decodeMoneyFields(record, moneyFields, "raw");
|
|
4022
|
+
}
|
|
4023
|
+
function canonicalizeIncomingMoney(record, moneyFields) {
|
|
4024
|
+
if (!moneyFields || Object.keys(moneyFields).length === 0) return record;
|
|
4025
|
+
try {
|
|
4026
|
+
return decodeMoneyFields(
|
|
4027
|
+
quantizeMoneyFields(record, moneyFields),
|
|
4028
|
+
moneyFields,
|
|
4029
|
+
"raw"
|
|
4030
|
+
);
|
|
4031
|
+
} catch {
|
|
4032
|
+
return record;
|
|
4033
|
+
}
|
|
4034
|
+
}
|
|
4035
|
+
function quantizeValue(field, raw, desc) {
|
|
4036
|
+
if (desc.mode === "fixed") {
|
|
4037
|
+
const currency2 = desc.fixedCurrency;
|
|
4038
|
+
return quantizeAmount(field, raw, desc.scaleFor(currency2), desc.rounding);
|
|
4039
|
+
}
|
|
4040
|
+
let amount;
|
|
4041
|
+
let currency;
|
|
4042
|
+
if (isMoneyValueObject(raw)) {
|
|
4043
|
+
currency = String(raw.currency);
|
|
4044
|
+
amount = raw.amount;
|
|
4045
|
+
} else {
|
|
4046
|
+
const sole = desc.soleCurrency();
|
|
4047
|
+
if (sole === void 0) {
|
|
4048
|
+
throw new TypeError(
|
|
4049
|
+
`money: field "${field}" is multi-currency \u2014 write { amount, currency }, not a bare amount`
|
|
4050
|
+
);
|
|
4051
|
+
}
|
|
4052
|
+
currency = sole;
|
|
4053
|
+
amount = raw;
|
|
4054
|
+
}
|
|
4055
|
+
const scale = desc.scaleFor(currency);
|
|
4056
|
+
return { amount: quantizeAmount(field, amount, scale, desc.rounding), currency };
|
|
4057
|
+
}
|
|
3903
4058
|
function quantizeMoneyFields(record, moneyFields) {
|
|
3904
|
-
|
|
3905
|
-
for (const [
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
out[field] = quantizeAmount(field, raw, desc.scaleFor(currency2), desc.rounding);
|
|
4059
|
+
let out = { ...record };
|
|
4060
|
+
for (const [path, desc] of Object.entries(moneyFields)) {
|
|
4061
|
+
if (isSimpleMoneyPath(path)) {
|
|
4062
|
+
const raw = out[path];
|
|
4063
|
+
if (raw === null || raw === void 0) continue;
|
|
4064
|
+
out[path] = quantizeValue(path, raw, desc);
|
|
3911
4065
|
continue;
|
|
3912
4066
|
}
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
amount = raw;
|
|
3927
|
-
}
|
|
3928
|
-
const scale = desc.scaleFor(currency);
|
|
3929
|
-
out[field] = { amount: quantizeAmount(field, amount, scale, desc.rounding), currency };
|
|
4067
|
+
out = transformAtMoneyPath(
|
|
4068
|
+
out,
|
|
4069
|
+
path,
|
|
4070
|
+
parseMoneyPath(path),
|
|
4071
|
+
0,
|
|
4072
|
+
(container, key) => {
|
|
4073
|
+
const raw = container[key];
|
|
4074
|
+
if (raw === null || raw === void 0) return;
|
|
4075
|
+
container[key] = quantizeValue(path, raw, desc);
|
|
4076
|
+
},
|
|
4077
|
+
/* lenient */
|
|
4078
|
+
false
|
|
4079
|
+
);
|
|
3930
4080
|
}
|
|
3931
4081
|
return out;
|
|
3932
4082
|
}
|
|
@@ -3939,33 +4089,70 @@ function formatCurrency(decimal, currency, scale, locale) {
|
|
|
3939
4089
|
});
|
|
3940
4090
|
return fmt.format(decimal);
|
|
3941
4091
|
}
|
|
4092
|
+
function decodeValue(stored, desc) {
|
|
4093
|
+
let currency;
|
|
4094
|
+
let scaledIntString;
|
|
4095
|
+
if (desc.mode === "fixed") {
|
|
4096
|
+
if (typeof stored !== "string" && typeof stored !== "number") return null;
|
|
4097
|
+
currency = desc.fixedCurrency;
|
|
4098
|
+
scaledIntString = String(stored);
|
|
4099
|
+
} else {
|
|
4100
|
+
if (!isMoneyValueObject(stored)) return null;
|
|
4101
|
+
const amount = stored.amount;
|
|
4102
|
+
if (typeof stored.currency !== "string" || typeof amount !== "string" && typeof amount !== "number") return null;
|
|
4103
|
+
currency = stored.currency;
|
|
4104
|
+
scaledIntString = String(amount);
|
|
4105
|
+
}
|
|
4106
|
+
const scale = desc.scaleFor(currency);
|
|
4107
|
+
let decimal;
|
|
4108
|
+
try {
|
|
4109
|
+
decimal = formatScaledInt(BigInt(scaledIntString), scale);
|
|
4110
|
+
} catch {
|
|
4111
|
+
return null;
|
|
4112
|
+
}
|
|
4113
|
+
return {
|
|
4114
|
+
decoded: desc.mode === "fixed" ? decimal : { amount: decimal, currency },
|
|
4115
|
+
decimal,
|
|
4116
|
+
currency,
|
|
4117
|
+
scale
|
|
4118
|
+
};
|
|
4119
|
+
}
|
|
3942
4120
|
function decodeMoneyFields(record, moneyFields, locale) {
|
|
3943
|
-
|
|
4121
|
+
let out = { ...record };
|
|
3944
4122
|
const format = locale !== "raw";
|
|
3945
4123
|
const fmtLocale = typeof locale === "string" && locale !== "raw" ? locale : "en-US";
|
|
3946
|
-
for (const [
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
if (typeof stored.currency !== "string" || typeof amount !== "string" && typeof amount !== "number") continue;
|
|
3959
|
-
currency = stored.currency;
|
|
3960
|
-
scaledIntString = String(amount);
|
|
3961
|
-
}
|
|
3962
|
-
const scale = desc.scaleFor(currency);
|
|
3963
|
-
const decimal = formatScaledInt(BigInt(scaledIntString), scale);
|
|
3964
|
-
out[field] = desc.mode === "fixed" ? decimal : { amount: decimal, currency };
|
|
3965
|
-
if (format) {
|
|
3966
|
-
out[`${field}Formatted`] = formatCurrency(decimal, currency, scale, fmtLocale);
|
|
3967
|
-
out[`${field}Number`] = Number(decimal);
|
|
4124
|
+
for (const [path, desc] of Object.entries(moneyFields)) {
|
|
4125
|
+
if (isSimpleMoneyPath(path)) {
|
|
4126
|
+
const stored = out[path];
|
|
4127
|
+
if (stored === null || stored === void 0) continue;
|
|
4128
|
+
const r = decodeValue(stored, desc);
|
|
4129
|
+
if (r === null) continue;
|
|
4130
|
+
out[path] = r.decoded;
|
|
4131
|
+
if (format) {
|
|
4132
|
+
out[`${path}Formatted`] = formatCurrency(r.decimal, r.currency, r.scale, fmtLocale);
|
|
4133
|
+
out[`${path}Number`] = Number(r.decimal);
|
|
4134
|
+
}
|
|
4135
|
+
continue;
|
|
3968
4136
|
}
|
|
4137
|
+
out = transformAtMoneyPath(
|
|
4138
|
+
out,
|
|
4139
|
+
path,
|
|
4140
|
+
parseMoneyPath(path),
|
|
4141
|
+
0,
|
|
4142
|
+
(container, key) => {
|
|
4143
|
+
const stored = container[key];
|
|
4144
|
+
if (stored === null || stored === void 0) return;
|
|
4145
|
+
const r = decodeValue(stored, desc);
|
|
4146
|
+
if (r === null) return;
|
|
4147
|
+
container[key] = r.decoded;
|
|
4148
|
+
if (format && typeof key === "string" && !Array.isArray(container)) {
|
|
4149
|
+
container[`${key}Formatted`] = formatCurrency(r.decimal, r.currency, r.scale, fmtLocale);
|
|
4150
|
+
container[`${key}Number`] = Number(r.decimal);
|
|
4151
|
+
}
|
|
4152
|
+
},
|
|
4153
|
+
/* lenient */
|
|
4154
|
+
true
|
|
4155
|
+
);
|
|
3969
4156
|
}
|
|
3970
4157
|
return out;
|
|
3971
4158
|
}
|
|
@@ -3974,6 +4161,7 @@ var init_normalize = __esm({
|
|
|
3974
4161
|
"use strict";
|
|
3975
4162
|
init_fixed_point();
|
|
3976
4163
|
init_descriptor();
|
|
4164
|
+
init_paths();
|
|
3977
4165
|
}
|
|
3978
4166
|
});
|
|
3979
4167
|
|
|
@@ -4146,6 +4334,146 @@ var init_strategy3 = __esm({
|
|
|
4146
4334
|
}
|
|
4147
4335
|
});
|
|
4148
4336
|
|
|
4337
|
+
// src/money/where.ts
|
|
4338
|
+
function isMoneyValueObject2(v) {
|
|
4339
|
+
return typeof v === "object" && v !== null && "currency" in v;
|
|
4340
|
+
}
|
|
4341
|
+
function parseOperand(field, raw, desc) {
|
|
4342
|
+
let amount;
|
|
4343
|
+
let currency;
|
|
4344
|
+
if (desc.mode === "fixed") {
|
|
4345
|
+
currency = desc.fixedCurrency;
|
|
4346
|
+
amount = raw;
|
|
4347
|
+
} else if (isMoneyValueObject2(raw)) {
|
|
4348
|
+
currency = String(raw.currency);
|
|
4349
|
+
amount = raw.amount;
|
|
4350
|
+
} else {
|
|
4351
|
+
const sole = desc.soleCurrency();
|
|
4352
|
+
if (sole === void 0) {
|
|
4353
|
+
throw new MoneyUnsupportedError(
|
|
4354
|
+
`where("${field}"): field is multi-currency \u2014 compare against { amount, currency }, not a bare amount`
|
|
4355
|
+
);
|
|
4356
|
+
}
|
|
4357
|
+
currency = sole;
|
|
4358
|
+
amount = raw;
|
|
4359
|
+
}
|
|
4360
|
+
if (typeof amount !== "number" && typeof amount !== "string") {
|
|
4361
|
+
throw new MoneyUnsupportedError(
|
|
4362
|
+
`where("${field}"): operand ${JSON.stringify(raw)} is not a money amount`
|
|
4363
|
+
);
|
|
4364
|
+
}
|
|
4365
|
+
const r = parseToScaledInt(amount, desc.scaleFor(currency), desc.rounding);
|
|
4366
|
+
if (!r.ok) {
|
|
4367
|
+
throw new MoneyUnsupportedError(
|
|
4368
|
+
`where("${field}"): operand ${JSON.stringify(amount)} is not a finite decimal`
|
|
4369
|
+
);
|
|
4370
|
+
}
|
|
4371
|
+
return { scaled: r.value.toString(), currency };
|
|
4372
|
+
}
|
|
4373
|
+
function moneyFieldClause(field, op, value, desc) {
|
|
4374
|
+
switch (op) {
|
|
4375
|
+
case "==":
|
|
4376
|
+
case "!=":
|
|
4377
|
+
case "<":
|
|
4378
|
+
case "<=":
|
|
4379
|
+
case ">":
|
|
4380
|
+
case ">=": {
|
|
4381
|
+
const e = parseOperand(field, value, desc);
|
|
4382
|
+
return withMoney(field, op, value, desc, [e]);
|
|
4383
|
+
}
|
|
4384
|
+
case "between": {
|
|
4385
|
+
if (!Array.isArray(value) || value.length !== 2) {
|
|
4386
|
+
throw new MoneyUnsupportedError(`where("${field}"): 'between' needs a [lo, hi] tuple`);
|
|
4387
|
+
}
|
|
4388
|
+
const lo = parseOperand(field, value[0], desc);
|
|
4389
|
+
const hi = parseOperand(field, value[1], desc);
|
|
4390
|
+
if (lo.currency !== hi.currency) {
|
|
4391
|
+
throw new MoneyUnsupportedError(
|
|
4392
|
+
`where("${field}"): 'between' bounds mix currencies (${lo.currency} vs ${hi.currency})`
|
|
4393
|
+
);
|
|
4394
|
+
}
|
|
4395
|
+
return withMoney(field, op, value, desc, [lo, hi]);
|
|
4396
|
+
}
|
|
4397
|
+
case "in": {
|
|
4398
|
+
if (!Array.isArray(value)) {
|
|
4399
|
+
throw new MoneyUnsupportedError(`where("${field}"): 'in' needs an array of amounts`);
|
|
4400
|
+
}
|
|
4401
|
+
return withMoney(field, op, value, desc, value.map((v) => parseOperand(field, v, desc)));
|
|
4402
|
+
}
|
|
4403
|
+
default:
|
|
4404
|
+
throw new MoneyUnsupportedError(
|
|
4405
|
+
`where("${field}"): operator '${op}' is not supported on a money field`
|
|
4406
|
+
);
|
|
4407
|
+
}
|
|
4408
|
+
}
|
|
4409
|
+
function withMoney(field, op, originalValue, desc, entries) {
|
|
4410
|
+
const money = { mode: desc.mode, entries };
|
|
4411
|
+
const value = desc.mode !== "fixed" ? originalValue : entries.length === 1 && op !== "in" && op !== "between" ? entries[0].scaled : entries.map((e) => e.scaled);
|
|
4412
|
+
return { type: "field", field, op, value, money };
|
|
4413
|
+
}
|
|
4414
|
+
function readStored(actual, operand) {
|
|
4415
|
+
let amount;
|
|
4416
|
+
let currency;
|
|
4417
|
+
if (operand.mode === "fixed") {
|
|
4418
|
+
if (typeof actual !== "string" && typeof actual !== "number") return null;
|
|
4419
|
+
amount = actual;
|
|
4420
|
+
currency = operand.entries[0]?.currency ?? "";
|
|
4421
|
+
} else {
|
|
4422
|
+
if (!isMoneyValueObject2(actual)) return null;
|
|
4423
|
+
if (typeof actual.currency !== "string") return null;
|
|
4424
|
+
amount = actual.amount;
|
|
4425
|
+
currency = actual.currency;
|
|
4426
|
+
}
|
|
4427
|
+
if (typeof amount !== "string" && typeof amount !== "number") return null;
|
|
4428
|
+
try {
|
|
4429
|
+
return { scaled: BigInt(amount).toString(), currency };
|
|
4430
|
+
} catch {
|
|
4431
|
+
return null;
|
|
4432
|
+
}
|
|
4433
|
+
}
|
|
4434
|
+
function evaluateMoneyClause(actual, op, operand) {
|
|
4435
|
+
const stored = readStored(actual, operand);
|
|
4436
|
+
if (stored === null) return op === "!=";
|
|
4437
|
+
const a = BigInt(stored.scaled);
|
|
4438
|
+
if (op === "in") {
|
|
4439
|
+
return operand.entries.some(
|
|
4440
|
+
(e2) => e2.currency === stored.currency && BigInt(e2.scaled) === a
|
|
4441
|
+
);
|
|
4442
|
+
}
|
|
4443
|
+
if (op === "between") {
|
|
4444
|
+
const [lo, hi] = operand.entries;
|
|
4445
|
+
if (!lo || !hi || lo.currency !== stored.currency) return false;
|
|
4446
|
+
return a >= BigInt(lo.scaled) && a <= BigInt(hi.scaled);
|
|
4447
|
+
}
|
|
4448
|
+
const e = operand.entries[0];
|
|
4449
|
+
if (!e) return false;
|
|
4450
|
+
if (e.currency !== stored.currency) return op === "!=";
|
|
4451
|
+
const b = BigInt(e.scaled);
|
|
4452
|
+
switch (op) {
|
|
4453
|
+
case "==":
|
|
4454
|
+
return a === b;
|
|
4455
|
+
case "!=":
|
|
4456
|
+
return a !== b;
|
|
4457
|
+
case "<":
|
|
4458
|
+
return a < b;
|
|
4459
|
+
case "<=":
|
|
4460
|
+
return a <= b;
|
|
4461
|
+
case ">":
|
|
4462
|
+
return a > b;
|
|
4463
|
+
case ">=":
|
|
4464
|
+
return a >= b;
|
|
4465
|
+
default:
|
|
4466
|
+
return false;
|
|
4467
|
+
}
|
|
4468
|
+
}
|
|
4469
|
+
var init_where = __esm({
|
|
4470
|
+
"src/money/where.ts"() {
|
|
4471
|
+
"use strict";
|
|
4472
|
+
init_fixed_point();
|
|
4473
|
+
init_descriptor();
|
|
4474
|
+
}
|
|
4475
|
+
});
|
|
4476
|
+
|
|
4149
4477
|
// src/query/predicate.ts
|
|
4150
4478
|
function readPath(record, path) {
|
|
4151
4479
|
if (record === null || record === void 0) return void 0;
|
|
@@ -4163,6 +4491,7 @@ function readPath(record, path) {
|
|
|
4163
4491
|
function evaluateFieldClause(record, clause) {
|
|
4164
4492
|
const actual = readPath(record, clause.field);
|
|
4165
4493
|
const { op, value } = clause;
|
|
4494
|
+
if (clause.money) return evaluateMoneyClause(actual, op, clause.money);
|
|
4166
4495
|
switch (op) {
|
|
4167
4496
|
case "==":
|
|
4168
4497
|
return actual === value;
|
|
@@ -4203,14 +4532,14 @@ function isComparable(a, b) {
|
|
|
4203
4532
|
if (a instanceof Date && b instanceof Date) return true;
|
|
4204
4533
|
return false;
|
|
4205
4534
|
}
|
|
4206
|
-
function evaluateClause(record, clause) {
|
|
4535
|
+
function evaluateClause(record, clause, fnRecord) {
|
|
4207
4536
|
switch (clause.type) {
|
|
4208
4537
|
case "field":
|
|
4209
4538
|
return evaluateFieldClause(record, clause);
|
|
4210
4539
|
case "filter":
|
|
4211
|
-
return clause.fn(record);
|
|
4540
|
+
return clause.fn(fnRecord !== void 0 ? fnRecord : record);
|
|
4212
4541
|
case "wherePredicate":
|
|
4213
|
-
return clause.fn(record, clause.ctx);
|
|
4542
|
+
return clause.fn(fnRecord !== void 0 ? fnRecord : record, clause.ctx);
|
|
4214
4543
|
case "crossJoin":
|
|
4215
4544
|
throw new Error(
|
|
4216
4545
|
`evaluateClause: 'crossJoin' clauses are expansion primitives and are not evaluated per-record. This is a query planner routing error \u2014 crossJoin clauses must be extracted from the clause list before calling evaluateClause or filterRecords.`
|
|
@@ -4218,20 +4547,28 @@ function evaluateClause(record, clause) {
|
|
|
4218
4547
|
case "group":
|
|
4219
4548
|
if (clause.op === "and") {
|
|
4220
4549
|
for (const child of clause.clauses) {
|
|
4221
|
-
if (!evaluateClause(record, child)) return false;
|
|
4550
|
+
if (!evaluateClause(record, child, fnRecord)) return false;
|
|
4222
4551
|
}
|
|
4223
4552
|
return true;
|
|
4224
4553
|
} else {
|
|
4225
4554
|
for (const child of clause.clauses) {
|
|
4226
|
-
if (evaluateClause(record, child)) return true;
|
|
4555
|
+
if (evaluateClause(record, child, fnRecord)) return true;
|
|
4227
4556
|
}
|
|
4228
4557
|
return false;
|
|
4229
4558
|
}
|
|
4230
4559
|
}
|
|
4231
4560
|
}
|
|
4561
|
+
function hasFnClause(clauses) {
|
|
4562
|
+
for (const c of clauses) {
|
|
4563
|
+
if (c.type === "filter" || c.type === "wherePredicate") return true;
|
|
4564
|
+
if (c.type === "group" && hasFnClause(c.clauses)) return true;
|
|
4565
|
+
}
|
|
4566
|
+
return false;
|
|
4567
|
+
}
|
|
4232
4568
|
var init_predicate = __esm({
|
|
4233
4569
|
"src/query/predicate.ts"() {
|
|
4234
4570
|
"use strict";
|
|
4571
|
+
init_where();
|
|
4235
4572
|
}
|
|
4236
4573
|
});
|
|
4237
4574
|
|
|
@@ -4692,7 +5029,7 @@ function executePlanWithSource(source, plan, joinContext) {
|
|
|
4692
5029
|
result = executeClausePipeline(source, plan.clauses, joinContext);
|
|
4693
5030
|
} else {
|
|
4694
5031
|
const { candidates, remainingClauses } = candidateRecords(source, plan.clauses);
|
|
4695
|
-
result = remainingClauses.length === 0 ? [...candidates] : filterRecords(candidates, remainingClauses);
|
|
5032
|
+
result = remainingClauses.length === 0 ? [...candidates] : filterRecords(candidates, remainingClauses, fnViewDecoder(source));
|
|
4696
5033
|
}
|
|
4697
5034
|
if (plan.orderBy.length > 0) {
|
|
4698
5035
|
result = sortRecords(result, plan.orderBy);
|
|
@@ -4715,6 +5052,7 @@ function candidateRecords(source, clauses) {
|
|
|
4715
5052
|
const clause = clauses[i];
|
|
4716
5053
|
if (clause.type !== "field") continue;
|
|
4717
5054
|
if (!indexes.has(clause.field)) continue;
|
|
5055
|
+
if (clause.money?.mode === "multi") continue;
|
|
4718
5056
|
let ids = null;
|
|
4719
5057
|
if (clause.op === "==") {
|
|
4720
5058
|
ids = indexes.lookupEqual(clause.field, clause.value);
|
|
@@ -4742,13 +5080,20 @@ function materializeIds(ids, lookupById) {
|
|
|
4742
5080
|
}
|
|
4743
5081
|
return out;
|
|
4744
5082
|
}
|
|
4745
|
-
function
|
|
5083
|
+
function fnViewDecoder(source) {
|
|
5084
|
+
const mf = source.moneyFields;
|
|
5085
|
+
if (!mf || Object.keys(mf).length === 0) return void 0;
|
|
5086
|
+
return (r) => decodeMoneyFields(r, mf, "raw");
|
|
5087
|
+
}
|
|
5088
|
+
function filterRecords(records, clauses, decodeForFns) {
|
|
4746
5089
|
if (clauses.length === 0) return [...records];
|
|
5090
|
+
const needsFnView = decodeForFns !== void 0 && hasFnClause(clauses);
|
|
4747
5091
|
const out = [];
|
|
4748
5092
|
for (const r of records) {
|
|
5093
|
+
const fnView = needsFnView ? decodeForFns(r) : void 0;
|
|
4749
5094
|
let matches = true;
|
|
4750
5095
|
for (const clause of clauses) {
|
|
4751
|
-
if (!evaluateClause(r, clause)) {
|
|
5096
|
+
if (!evaluateClause(r, clause, fnView)) {
|
|
4752
5097
|
matches = false;
|
|
4753
5098
|
break;
|
|
4754
5099
|
}
|
|
@@ -4760,10 +5105,11 @@ function filterRecords(records, clauses) {
|
|
|
4760
5105
|
function executeClausePipeline(source, clauses, joinContext) {
|
|
4761
5106
|
let rel = [...source.snapshot()];
|
|
4762
5107
|
let filterBatch = [];
|
|
5108
|
+
const decodeForFns = fnViewDecoder(source);
|
|
4763
5109
|
for (const clause of clauses) {
|
|
4764
5110
|
if (clause.type === "crossJoin") {
|
|
4765
5111
|
if (filterBatch.length > 0) {
|
|
4766
|
-
rel = filterRecords(rel, filterBatch);
|
|
5112
|
+
rel = filterRecords(rel, filterBatch, decodeForFns);
|
|
4767
5113
|
filterBatch = [];
|
|
4768
5114
|
}
|
|
4769
5115
|
const rightSource = joinContext.resolveSource(clause.target);
|
|
@@ -4776,7 +5122,7 @@ function executeClausePipeline(source, clauses, joinContext) {
|
|
|
4776
5122
|
}
|
|
4777
5123
|
}
|
|
4778
5124
|
if (filterBatch.length > 0) {
|
|
4779
|
-
rel = filterRecords(rel, filterBatch);
|
|
5125
|
+
rel = filterRecords(rel, filterBatch, decodeForFns);
|
|
4780
5126
|
}
|
|
4781
5127
|
return rel;
|
|
4782
5128
|
}
|
|
@@ -4957,6 +5303,7 @@ var init_builder = __esm({
|
|
|
4957
5303
|
init_strategy4();
|
|
4958
5304
|
init_money_reducer();
|
|
4959
5305
|
init_normalize();
|
|
5306
|
+
init_where();
|
|
4960
5307
|
EMPTY_PLAN = {
|
|
4961
5308
|
clauses: [],
|
|
4962
5309
|
orderBy: [],
|
|
@@ -5048,9 +5395,18 @@ var init_builder = __esm({
|
|
|
5048
5395
|
this.predicates
|
|
5049
5396
|
);
|
|
5050
5397
|
}
|
|
5051
|
-
/**
|
|
5398
|
+
/**
|
|
5399
|
+
* Add a field comparison. Multiple where() calls are AND-combined.
|
|
5400
|
+
*
|
|
5401
|
+
* A declared money field compares in MAJOR units (#336): the operand
|
|
5402
|
+
* (`10000`, `'10000.00'`, or `{ amount, currency }` in multi mode) is
|
|
5403
|
+
* quantized into stored scaled-int space at build time and evaluated
|
|
5404
|
+
* BigInt-exact per record. A malformed operand or a string operator
|
|
5405
|
+
* (`contains`/`startsWith`) throws here, at the call site.
|
|
5406
|
+
*/
|
|
5052
5407
|
where(field, op, value) {
|
|
5053
|
-
const
|
|
5408
|
+
const desc = this.source.moneyFields?.[field];
|
|
5409
|
+
const clause = desc ? moneyFieldClause(field, op, value, desc) : { type: "field", field, op, value };
|
|
5054
5410
|
return new _Query(
|
|
5055
5411
|
this.source,
|
|
5056
5412
|
{ ...this.plan, clauses: [...this.plan.clauses, clause] },
|
|
@@ -5376,7 +5732,7 @@ var init_builder = __esm({
|
|
|
5376
5732
|
}
|
|
5377
5733
|
const { candidates, remainingClauses } = candidateRecords(this.source, this.plan.clauses);
|
|
5378
5734
|
if (remainingClauses.length === 0) return candidates.length;
|
|
5379
|
-
return filterRecords(candidates, remainingClauses).length;
|
|
5735
|
+
return filterRecords(candidates, remainingClauses, fnViewDecoder(this.source)).length;
|
|
5380
5736
|
}
|
|
5381
5737
|
/**
|
|
5382
5738
|
* Reduce the matching records through a named set of reducers.
|
|
@@ -5433,7 +5789,7 @@ var init_builder = __esm({
|
|
|
5433
5789
|
return executeClausePipeline(source, clauses, joinCtx);
|
|
5434
5790
|
}
|
|
5435
5791
|
const { candidates, remainingClauses } = candidateRecords(source, clauses);
|
|
5436
|
-
return remainingClauses.length === 0 ? candidates : filterRecords(candidates, remainingClauses);
|
|
5792
|
+
return remainingClauses.length === 0 ? candidates : filterRecords(candidates, remainingClauses, fnViewDecoder(source));
|
|
5437
5793
|
};
|
|
5438
5794
|
const upstreams = [];
|
|
5439
5795
|
if (source.subscribe) {
|
|
@@ -5456,7 +5812,7 @@ var init_builder = __esm({
|
|
|
5456
5812
|
return executeClausePipeline(source, clauses, joinCtx);
|
|
5457
5813
|
}
|
|
5458
5814
|
const { candidates, remainingClauses } = candidateRecords(source, clauses);
|
|
5459
|
-
return remainingClauses.length === 0 ? candidates : filterRecords(candidates, remainingClauses);
|
|
5815
|
+
return remainingClauses.length === 0 ? candidates : filterRecords(candidates, remainingClauses, fnViewDecoder(source));
|
|
5460
5816
|
};
|
|
5461
5817
|
const upstreams = [];
|
|
5462
5818
|
if (source.subscribe) {
|
|
@@ -5729,6 +6085,7 @@ var init_scan_builder = __esm({
|
|
|
5729
6085
|
init_predicate();
|
|
5730
6086
|
init_errors();
|
|
5731
6087
|
init_normalize();
|
|
6088
|
+
init_where();
|
|
5732
6089
|
DEFAULT_SCAN_PAGE_SIZE = 100;
|
|
5733
6090
|
ScanBuilder = class _ScanBuilder {
|
|
5734
6091
|
pageProvider;
|
|
@@ -5792,7 +6149,8 @@ var init_scan_builder = __esm({
|
|
|
5792
6149
|
* evaluates clauses per record in O(1) per clause.
|
|
5793
6150
|
*/
|
|
5794
6151
|
where(field, op, value) {
|
|
5795
|
-
const
|
|
6152
|
+
const desc = this.moneyFields?.[field];
|
|
6153
|
+
const clause = desc ? moneyFieldClause(field, op, value, desc) : { type: "field", field, op, value };
|
|
5796
6154
|
return new _ScanBuilder(
|
|
5797
6155
|
this.pageProvider,
|
|
5798
6156
|
this.pageSize,
|
|
@@ -6138,8 +6496,9 @@ var init_scan_builder = __esm({
|
|
|
6138
6496
|
*/
|
|
6139
6497
|
recordMatches(record) {
|
|
6140
6498
|
if (this.clauses.length === 0) return true;
|
|
6499
|
+
const fnView = this.moneyFields && Object.keys(this.moneyFields).length > 0 && hasFnClause(this.clauses) ? this.decodeMoney(record) : void 0;
|
|
6141
6500
|
for (const clause of this.clauses) {
|
|
6142
|
-
if (!evaluateClause(record, clause)) return false;
|
|
6501
|
+
if (!evaluateClause(record, clause, fnView)) return false;
|
|
6143
6502
|
}
|
|
6144
6503
|
return true;
|
|
6145
6504
|
}
|
|
@@ -7680,6 +8039,7 @@ var init_collection = __esm({
|
|
|
7680
8039
|
init_strategy();
|
|
7681
8040
|
init_core();
|
|
7682
8041
|
init_normalize();
|
|
8042
|
+
init_paths();
|
|
7683
8043
|
init_computed();
|
|
7684
8044
|
init_strategy2();
|
|
7685
8045
|
init_policy();
|
|
@@ -8002,6 +8362,7 @@ var init_collection = __esm({
|
|
|
8002
8362
|
this.joinResolver = opts.joinResolver;
|
|
8003
8363
|
this.i18nFields = opts.i18nFields;
|
|
8004
8364
|
this.dictKeyFields = opts.dictKeyFields;
|
|
8365
|
+
if (opts.moneyFields) validateMoneyFieldPaths(opts.moneyFields);
|
|
8005
8366
|
this.moneyFields = opts.moneyFields;
|
|
8006
8367
|
this.computed = opts.computed;
|
|
8007
8368
|
this.dictLabelResolver = opts.dictLabelResolver;
|
|
@@ -8135,7 +8496,9 @@ var init_collection = __esm({
|
|
|
8135
8496
|
* declaration; this reconciles that ordering. First-wins. Not public.
|
|
8136
8497
|
*/
|
|
8137
8498
|
_applyMoneyFields(moneyFields) {
|
|
8138
|
-
if (this.moneyFields
|
|
8499
|
+
if (this.moneyFields !== void 0) return;
|
|
8500
|
+
validateMoneyFieldPaths(moneyFields);
|
|
8501
|
+
this.moneyFields = moneyFields;
|
|
8139
8502
|
}
|
|
8140
8503
|
/** @internal — attach computed fields post-construction. See {@link _applyMoneyFields}. */
|
|
8141
8504
|
_applyComputed(computed) {
|
|
@@ -8302,6 +8665,7 @@ var init_collection = __esm({
|
|
|
8302
8665
|
if (!hasWritePermission(this.keyring, this.name)) {
|
|
8303
8666
|
throw new ReadOnlyError();
|
|
8304
8667
|
}
|
|
8668
|
+
record = canonicalizeIncomingMoney(record, this.moneyFields);
|
|
8305
8669
|
if (this.subsystemBus?.hasGateHandlers("beforePut")) {
|
|
8306
8670
|
const existingEnv = await this.adapter.get(this.vault, this.name, id);
|
|
8307
8671
|
let existingRecord = null;
|
|
@@ -8318,7 +8682,7 @@ var init_collection = __esm({
|
|
|
8318
8682
|
collection: this.name,
|
|
8319
8683
|
docId: id,
|
|
8320
8684
|
incoming: record,
|
|
8321
|
-
existing: existingRecord,
|
|
8685
|
+
existing: canonicalizeStoredMoney(existingRecord, this.moneyFields),
|
|
8322
8686
|
existingVersion: existingEnv?._v ?? 0,
|
|
8323
8687
|
existingTs: existingEnv?._ts,
|
|
8324
8688
|
userId: this.keyring.userId,
|
|
@@ -8587,7 +8951,7 @@ var init_collection = __esm({
|
|
|
8587
8951
|
*/
|
|
8588
8952
|
async dispatchDerivations(id, record, version) {
|
|
8589
8953
|
if (this.derivationSource === void 0) return;
|
|
8590
|
-
const incoming = record;
|
|
8954
|
+
const incoming = canonicalizeStoredMoney(record, this.moneyFields);
|
|
8591
8955
|
if (incoming && typeof incoming === "object" && "_derivedFrom" in incoming) return;
|
|
8592
8956
|
const registry = this.derivationSource.registry();
|
|
8593
8957
|
const strategies = registry.strategiesForSource(this.name);
|
|
@@ -8820,7 +9184,7 @@ var init_collection = __esm({
|
|
|
8820
9184
|
vault: this.vault,
|
|
8821
9185
|
collection: this.name,
|
|
8822
9186
|
docId: id,
|
|
8823
|
-
existing: existingRecord,
|
|
9187
|
+
existing: canonicalizeStoredMoney(existingRecord, this.moneyFields),
|
|
8824
9188
|
existingVersion: existingEnv._v,
|
|
8825
9189
|
existingTs: existingEnv._ts,
|
|
8826
9190
|
internal,
|
|
@@ -17203,6 +17567,54 @@ var init_classify_skip = __esm({
|
|
|
17203
17567
|
}
|
|
17204
17568
|
});
|
|
17205
17569
|
|
|
17570
|
+
// src/federation/cross-shard-join.ts
|
|
17571
|
+
function coerceKey(value) {
|
|
17572
|
+
if (value === null || value === void 0) return null;
|
|
17573
|
+
if (typeof value === "string") return value;
|
|
17574
|
+
if (typeof value === "number" || typeof value === "bigint") return String(value);
|
|
17575
|
+
return null;
|
|
17576
|
+
}
|
|
17577
|
+
function warnOnceBroadcastMiss(field, as, key) {
|
|
17578
|
+
const dedup = `${field}\u2192${as}:${key}`;
|
|
17579
|
+
if (warnedBroadcastKeys.has(dedup)) return;
|
|
17580
|
+
warnedBroadcastKeys.add(dedup);
|
|
17581
|
+
console.warn(
|
|
17582
|
+
`[noy-db] broadcastJoin: no "${as}" dimension row for ${field}="${key}". Attaching null. Use mode: 'cascade' to silence.`
|
|
17583
|
+
);
|
|
17584
|
+
}
|
|
17585
|
+
async function applyBroadcastLegs(rows, legs) {
|
|
17586
|
+
if (legs.length === 0) return [...rows];
|
|
17587
|
+
const indexes = [];
|
|
17588
|
+
for (const leg of legs) {
|
|
17589
|
+
const map = /* @__PURE__ */ new Map();
|
|
17590
|
+
for (const rec of await leg.from.list()) {
|
|
17591
|
+
const k = coerceKey(readPath(rec, leg.on));
|
|
17592
|
+
if (k !== null && !map.has(k)) map.set(k, rec);
|
|
17593
|
+
}
|
|
17594
|
+
indexes.push({ leg, map });
|
|
17595
|
+
}
|
|
17596
|
+
return rows.map((row) => {
|
|
17597
|
+
const out = { ...row };
|
|
17598
|
+
for (const { leg, map } of indexes) {
|
|
17599
|
+
const key = coerceKey(readPath(row, leg.field));
|
|
17600
|
+
const match = key === null ? null : map.get(key) ?? null;
|
|
17601
|
+
if (match === null && leg.mode === "warn") {
|
|
17602
|
+
warnOnceBroadcastMiss(leg.field, leg.as, key ?? "<null>");
|
|
17603
|
+
}
|
|
17604
|
+
out[leg.as] = match;
|
|
17605
|
+
}
|
|
17606
|
+
return out;
|
|
17607
|
+
});
|
|
17608
|
+
}
|
|
17609
|
+
var warnedBroadcastKeys;
|
|
17610
|
+
var init_cross_shard_join = __esm({
|
|
17611
|
+
"src/federation/cross-shard-join.ts"() {
|
|
17612
|
+
"use strict";
|
|
17613
|
+
init_predicate();
|
|
17614
|
+
warnedBroadcastKeys = /* @__PURE__ */ new Set();
|
|
17615
|
+
}
|
|
17616
|
+
});
|
|
17617
|
+
|
|
17206
17618
|
// src/federation/cross-vault-live.ts
|
|
17207
17619
|
var CrossVaultLive;
|
|
17208
17620
|
var init_cross_vault_live = __esm({
|
|
@@ -17431,6 +17843,7 @@ var init_vault_group = __esm({
|
|
|
17431
17843
|
init_errors();
|
|
17432
17844
|
init_constants2();
|
|
17433
17845
|
init_classify_skip();
|
|
17846
|
+
init_cross_shard_join();
|
|
17434
17847
|
init_cross_vault_live();
|
|
17435
17848
|
init_aggregate_across();
|
|
17436
17849
|
SHARD_SEPARATOR = "--";
|
|
@@ -17594,31 +18007,89 @@ var init_vault_group = __esm({
|
|
|
17594
18007
|
}
|
|
17595
18008
|
};
|
|
17596
18009
|
ShardedQuery = class _ShardedQuery {
|
|
17597
|
-
constructor(group, collectionName, clauses) {
|
|
18010
|
+
constructor(group, collectionName, clauses, coPartitionedLegs = [], broadcastLegs = []) {
|
|
17598
18011
|
this.group = group;
|
|
17599
18012
|
this.collectionName = collectionName;
|
|
17600
18013
|
this.clauses = clauses;
|
|
18014
|
+
this.coPartitionedLegs = coPartitionedLegs;
|
|
18015
|
+
this.broadcastLegs = broadcastLegs;
|
|
17601
18016
|
}
|
|
17602
18017
|
group;
|
|
17603
18018
|
collectionName;
|
|
17604
18019
|
clauses;
|
|
18020
|
+
coPartitionedLegs;
|
|
18021
|
+
broadcastLegs;
|
|
17605
18022
|
where(field, op, value) {
|
|
17606
|
-
return new _ShardedQuery(
|
|
17607
|
-
|
|
17608
|
-
|
|
17609
|
-
|
|
18023
|
+
return new _ShardedQuery(
|
|
18024
|
+
this.group,
|
|
18025
|
+
this.collectionName,
|
|
18026
|
+
[...this.clauses, { field, op, value }],
|
|
18027
|
+
this.coPartitionedLegs,
|
|
18028
|
+
this.broadcastLegs
|
|
18029
|
+
);
|
|
18030
|
+
}
|
|
18031
|
+
/** Co-partitioned join: each shard joins its own same-vault right collection (resolved via ref()), then union. */
|
|
18032
|
+
crossShardJoin(field, opts) {
|
|
18033
|
+
const leg = { field, as: opts.as, maxRows: opts.maxRows, strategy: opts.strategy };
|
|
18034
|
+
return new _ShardedQuery(
|
|
18035
|
+
this.group,
|
|
18036
|
+
this.collectionName,
|
|
18037
|
+
this.clauses,
|
|
18038
|
+
[...this.coPartitionedLegs, leg],
|
|
18039
|
+
this.broadcastLegs
|
|
18040
|
+
);
|
|
18041
|
+
}
|
|
18042
|
+
/** Broadcast dimension join: enrich every merged row from a single shared collection. */
|
|
18043
|
+
broadcastJoin(field, opts) {
|
|
18044
|
+
const leg = {
|
|
18045
|
+
field,
|
|
18046
|
+
as: opts.as,
|
|
18047
|
+
from: opts.from,
|
|
18048
|
+
on: opts.on ?? "id",
|
|
18049
|
+
mode: opts.mode ?? "warn"
|
|
18050
|
+
};
|
|
18051
|
+
return new _ShardedQuery(
|
|
18052
|
+
this.group,
|
|
18053
|
+
this.collectionName,
|
|
18054
|
+
this.clauses,
|
|
18055
|
+
this.coPartitionedLegs,
|
|
18056
|
+
[...this.broadcastLegs, leg]
|
|
18057
|
+
);
|
|
17610
18058
|
}
|
|
17611
18059
|
/** @internal — fan out the where-filtered records across eligible shards. */
|
|
17612
18060
|
async fanoutRecords(options = {}) {
|
|
17613
18061
|
const { eligible, skipped } = await this.group.resolveEligible(options);
|
|
18062
|
+
const probeRow = eligible[0];
|
|
18063
|
+
if (this.coPartitionedLegs.length > 0 && probeRow) {
|
|
18064
|
+
const probe = await this.group.openShard(probeRow.partitionKey);
|
|
18065
|
+
this.group.template.configure(probe);
|
|
18066
|
+
for (const leg of this.coPartitionedLegs) {
|
|
18067
|
+
if (!probe.resolveRef(this.collectionName, leg.field)) {
|
|
18068
|
+
throw new CrossShardJoinError(
|
|
18069
|
+
`crossShardJoin("${leg.field}"): no ref() declared for "${leg.field}" on collection "${this.collectionName}" in template "${this.group.sharding.vaultTemplate}". Add refs: { ${leg.field}: ref('<target>') } to the template's collection options.`
|
|
18070
|
+
);
|
|
18071
|
+
}
|
|
18072
|
+
}
|
|
18073
|
+
}
|
|
17614
18074
|
const across = await this.group.db.queryAcross(
|
|
17615
18075
|
eligible.map((r) => r.vaultId),
|
|
17616
18076
|
async (vault) => {
|
|
17617
18077
|
this.group.template.configure(vault);
|
|
17618
18078
|
const coll = vault.collection(this.collectionName);
|
|
17619
18079
|
await coll.list();
|
|
18080
|
+
for (const leg of this.coPartitionedLegs) {
|
|
18081
|
+
const desc = vault.resolveRef(this.collectionName, leg.field);
|
|
18082
|
+
if (desc) await vault.collection(desc.target).list();
|
|
18083
|
+
}
|
|
17620
18084
|
let q = coll.query();
|
|
17621
18085
|
for (const c of this.clauses) q = q.where(c.field, c.op, c.value);
|
|
18086
|
+
for (const leg of this.coPartitionedLegs) {
|
|
18087
|
+
q = q.join(leg.field, {
|
|
18088
|
+
as: leg.as,
|
|
18089
|
+
...leg.maxRows !== void 0 ? { maxRows: leg.maxRows } : {},
|
|
18090
|
+
...leg.strategy ? { strategy: leg.strategy } : {}
|
|
18091
|
+
});
|
|
18092
|
+
}
|
|
17622
18093
|
return q.toArray();
|
|
17623
18094
|
},
|
|
17624
18095
|
{ concurrency: options.concurrency ?? 1, create: false }
|
|
@@ -17630,10 +18101,11 @@ var init_vault_group = __esm({
|
|
|
17630
18101
|
}
|
|
17631
18102
|
return { records: results, skippedVaults: skipped };
|
|
17632
18103
|
}
|
|
17633
|
-
/** Fan out across eligible shards
|
|
18104
|
+
/** Fan out across eligible shards, merge, then apply any broadcast dimension legs. */
|
|
17634
18105
|
async toArray(options = {}) {
|
|
17635
18106
|
const { records, skippedVaults } = await this.fanoutRecords(options);
|
|
17636
|
-
|
|
18107
|
+
const results = await applyBroadcastLegs(records, this.broadcastLegs);
|
|
18108
|
+
return { results, skippedVaults };
|
|
17637
18109
|
}
|
|
17638
18110
|
/** @internal — build the change-subscription + relevance binding for this query's group+collection. */
|
|
17639
18111
|
liveBinding() {
|
|
@@ -17647,8 +18119,17 @@ var init_vault_group = __esm({
|
|
|
17647
18119
|
isRelevant: (e) => e.collection === collectionName && e.vault.startsWith(`${group.name}--`)
|
|
17648
18120
|
};
|
|
17649
18121
|
}
|
|
18122
|
+
/** @internal — joined queries don't support reactive/aggregate surfaces in v1. */
|
|
18123
|
+
assertNoJoinLegs(surface) {
|
|
18124
|
+
if (this.coPartitionedLegs.length || this.broadcastLegs.length) {
|
|
18125
|
+
throw new CrossShardJoinError(
|
|
18126
|
+
`${surface}() is not supported on a ShardedQuery with crossShardJoin/broadcastJoin legs in v1. Use toArray() for joined cross-shard queries.`
|
|
18127
|
+
);
|
|
18128
|
+
}
|
|
18129
|
+
}
|
|
17650
18130
|
/** Returns a reactive cross-shard live query — a facade over CrossVaultLive. */
|
|
17651
18131
|
live(options = {}) {
|
|
18132
|
+
this.assertNoJoinLegs("live");
|
|
17652
18133
|
const bind = this.liveBinding();
|
|
17653
18134
|
const core = new CrossVaultLive({
|
|
17654
18135
|
...bind,
|
|
@@ -17676,10 +18157,12 @@ var init_vault_group = __esm({
|
|
|
17676
18157
|
}
|
|
17677
18158
|
/** One-shot distributed aggregate — central reduce over all shard records. */
|
|
17678
18159
|
aggregate(spec) {
|
|
18160
|
+
this.assertNoJoinLegs("aggregate");
|
|
17679
18161
|
return new CrossVaultAggregation(this, spec, this.liveBinding());
|
|
17680
18162
|
}
|
|
17681
18163
|
/** Begin a grouped cross-shard aggregate. */
|
|
17682
18164
|
groupBy(field) {
|
|
18165
|
+
this.assertNoJoinLegs("groupBy");
|
|
17683
18166
|
return new ShardedGroupedQuery(this, field);
|
|
17684
18167
|
}
|
|
17685
18168
|
};
|