@noy-db/hub 0.8.0 → 0.9.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/CHANGELOG.md +49 -0
- package/README.md +8 -8
- package/codemods/0.4.0-pre.json +1 -1
- package/codemods/0.8.0-pre.json +1 -1
- package/dist/api-6EFD43KN.js +18 -0
- package/dist/as/index.js +33 -23
- package/dist/as/index.js.map +1 -1
- package/dist/at/index.js +8 -8
- package/dist/attestation/index.js +18 -18
- package/dist/{backup-YE2VQ26S.js → backup-RJBFQSHE.js} +92 -31
- package/dist/backup-RJBFQSHE.js.map +1 -0
- package/dist/blobs/index.js +12 -12
- package/dist/broker/index.js +19 -11
- package/dist/broker/index.js.map +1 -1
- package/dist/by/index.js +2 -2
- package/dist/capsule/contract.d.ts +1 -1
- package/dist/capsule/contract.js +6 -6
- package/dist/capsule/enclave-aes/broker/proof.d.ts +12 -3
- package/dist/capsule/enclave-aes/crypto.d.ts +18 -0
- package/dist/capsule/enclave-aes/index.d.ts +3 -3
- package/dist/capsule/enclave-aes/index.js +46 -14
- package/dist/capsule/enclave-aes/index.js.map +1 -1
- package/dist/capsule/index.d.ts +2 -2
- package/dist/capsule/plumbing/record-codec.d.ts +7 -0
- package/dist/{capsule-VOLX3QRQ.js → capsule-6LJAVQNM.js} +14 -8
- package/dist/cargo/index.js +35 -35
- package/dist/{chunk-GZT3NQRA.js → chunk-25FXU6WS.js} +8 -2
- package/dist/chunk-25FXU6WS.js.map +1 -0
- package/dist/{chunk-OYW3I5M4.js → chunk-2DOCDOPL.js} +6 -6
- package/dist/chunk-2DX4JCRI.js +1 -0
- package/dist/{chunk-FLPCETP6.js → chunk-2LBS62AC.js} +2 -2
- package/dist/{chunk-WXE4W2U6.js → chunk-2ST3WA3C.js} +4 -4
- package/dist/{chunk-DQESF6RP.js → chunk-3G3GOGZZ.js} +50 -40
- package/dist/chunk-3G3GOGZZ.js.map +1 -0
- package/dist/{chunk-O2IMQSNA.js → chunk-3YBIVLTC.js} +2 -2
- package/dist/{chunk-LGNDFRYC.js → chunk-4CFHL5RY.js} +1 -1
- package/dist/chunk-4CFHL5RY.js.map +1 -0
- package/dist/{chunk-DIZLQVAA.js → chunk-4CHM2TRS.js} +2 -2
- package/dist/{chunk-V7ADQF5O.js → chunk-4CUJLEOA.js} +4 -4
- package/dist/{chunk-3EWS67C7.js → chunk-4TG2ITRW.js} +2 -2
- package/dist/{chunk-HS554XAF.js → chunk-5HQFROZS.js} +2 -2
- package/dist/{chunk-IUBMZPHM.js → chunk-5ZVE3N5C.js} +5 -6
- package/dist/chunk-5ZVE3N5C.js.map +1 -0
- package/dist/{chunk-PP3K67AJ.js → chunk-654RE5YC.js} +3 -3
- package/dist/{chunk-FOEDQATO.js → chunk-66GD7XXU.js} +2 -2
- package/dist/{chunk-BNWA3WG5.js → chunk-72FQ46VW.js} +3 -3
- package/dist/{chunk-EYG2CY2X.js → chunk-7JPA3LIH.js} +11 -11
- package/dist/chunk-7JPA3LIH.js.map +1 -0
- package/dist/{chunk-JQYKPKG6.js → chunk-7K42TSCY.js} +4 -4
- package/dist/{chunk-BPWYQ25R.js → chunk-7Q6IU3R7.js} +4 -4
- package/dist/{chunk-BPWYQ25R.js.map → chunk-7Q6IU3R7.js.map} +1 -1
- package/dist/{chunk-T7IR4N2S.js → chunk-7UHLO4ZN.js} +37 -2
- package/dist/chunk-7UHLO4ZN.js.map +1 -0
- package/dist/{chunk-UEFOQH74.js → chunk-ADCXTW7L.js} +2 -2
- package/dist/{chunk-MBMTND6D.js → chunk-AGGPT4UE.js} +2 -2
- package/dist/{chunk-RB4DOPGZ.js → chunk-AKIEBFIJ.js} +10 -10
- package/dist/{chunk-VHBKYN2J.js → chunk-B3B6HV5S.js} +2 -2
- package/dist/{chunk-JWWYRR4Q.js → chunk-B6EWMGFX.js} +2 -2
- package/dist/{chunk-H7JBY4P7.js → chunk-B7Y2BRQA.js} +14 -14
- package/dist/chunk-B7Y2BRQA.js.map +1 -0
- package/dist/{chunk-4CIQDWRB.js → chunk-BFJE2GPP.js} +14 -8
- package/dist/{chunk-4CIQDWRB.js.map → chunk-BFJE2GPP.js.map} +1 -1
- package/dist/{chunk-WPOYWFSE.js → chunk-BJRKXNFP.js} +7 -7
- package/dist/{chunk-H427H63K.js → chunk-BPQ5CRJF.js} +2 -2
- package/dist/{chunk-VFHCKG5M.js → chunk-BVRJYMFZ.js} +3 -3
- package/dist/{chunk-244QBK7Z.js → chunk-C4XV3PSJ.js} +4 -4
- package/dist/{chunk-244QBK7Z.js.map → chunk-C4XV3PSJ.js.map} +1 -1
- package/dist/{chunk-SMV2HRDU.js → chunk-DFC4WTJW.js} +2 -2
- package/dist/{chunk-5A4345TG.js → chunk-DMIEKD24.js} +3 -3
- package/dist/{chunk-TKVUE4JF.js → chunk-DQAXA2GK.js} +9 -9
- package/dist/{chunk-AL6ML4LA.js → chunk-DWCFGF2K.js} +5 -5
- package/dist/{chunk-Y3LPTBG7.js → chunk-E2C6FFSI.js} +6 -9
- package/dist/chunk-E2C6FFSI.js.map +1 -0
- package/dist/{chunk-LNSVGRHO.js → chunk-EQ6C2ZPT.js} +17 -51
- package/dist/chunk-EQ6C2ZPT.js.map +1 -0
- package/dist/chunk-EZOFTI4K.js +60 -0
- package/dist/chunk-EZOFTI4K.js.map +1 -0
- package/dist/{chunk-PD64727P.js → chunk-FMINS2B6.js} +2 -2
- package/dist/chunk-FMINS2B6.js.map +1 -0
- package/dist/{chunk-QBLT6POL.js → chunk-FPF5HRBE.js} +2 -2
- package/dist/{chunk-UA372JHH.js → chunk-FZVCZEVI.js} +3 -3
- package/dist/chunk-FZVCZEVI.js.map +1 -0
- package/dist/{chunk-FFWI7UH7.js → chunk-GAGT3YZN.js} +1 -1
- package/dist/chunk-GAGT3YZN.js.map +1 -0
- package/dist/{chunk-5WWDGFOS.js → chunk-GIQJGXV7.js} +2 -2
- package/dist/{chunk-V3RWOOSO.js → chunk-GYZICGRU.js} +4 -4
- package/dist/chunk-GYZICGRU.js.map +1 -0
- package/dist/{chunk-BVCUTXE3.js → chunk-H334G6KU.js} +2 -2
- package/dist/{chunk-AEQGFRU4.js → chunk-HE7EAHGS.js} +3 -3
- package/dist/chunk-HKB4HZDU.js +74 -0
- package/dist/chunk-HKB4HZDU.js.map +1 -0
- package/dist/{chunk-4V3Q35WG.js → chunk-ICF3TIGY.js} +3 -3
- package/dist/{chunk-3L2NBKDR.js → chunk-IF2M43G4.js} +2 -2
- package/dist/{chunk-37EPTBBR.js → chunk-IKPQ2GGB.js} +46 -4
- package/dist/chunk-IKPQ2GGB.js.map +1 -0
- package/dist/{chunk-DHHGL42E.js → chunk-IKS2CPAG.js} +27 -11
- package/dist/chunk-IKS2CPAG.js.map +1 -0
- package/dist/{chunk-3A5DUZ56.js → chunk-IMIQAGR7.js} +6 -6
- package/dist/{chunk-3A5DUZ56.js.map → chunk-IMIQAGR7.js.map} +1 -1
- package/dist/{chunk-A4XMIZT3.js → chunk-IQAJ4OR6.js} +41 -6
- package/dist/chunk-IQAJ4OR6.js.map +1 -0
- package/dist/{chunk-IUT3GWP3.js → chunk-IUD7WU67.js} +17 -93
- package/dist/chunk-IUD7WU67.js.map +1 -0
- package/dist/{chunk-AUKKUPVB.js → chunk-IVLRPRXM.js} +2 -2
- package/dist/{chunk-GUZET4SG.js → chunk-JAQHWHUN.js} +4 -4
- package/dist/chunk-JAQHWHUN.js.map +1 -0
- package/dist/{chunk-Y2RKVFKR.js → chunk-K4JSTGXT.js} +2 -2
- package/dist/{chunk-EJLV62NI.js → chunk-KN4LUMH6.js} +2 -2
- package/dist/{chunk-23D6M6VM.js → chunk-KZA3DITX.js} +4 -4
- package/dist/{chunk-E2N2T5ZO.js → chunk-L2VM64HK.js} +2 -2
- package/dist/chunk-L4UL4IAR.js +55 -0
- package/dist/chunk-L4UL4IAR.js.map +1 -0
- package/dist/{chunk-UIYESRD6.js → chunk-LUCQY3OM.js} +10 -10
- package/dist/{chunk-UIYESRD6.js.map → chunk-LUCQY3OM.js.map} +1 -1
- package/dist/{chunk-O46CHQT7.js → chunk-MAQBYBUX.js} +4 -4
- package/dist/{chunk-EZOAKKTB.js → chunk-MBPZMZVB.js} +2 -2
- package/dist/{chunk-XQRFSKYM.js → chunk-MCNNZBG7.js} +2 -2
- package/dist/{chunk-YRXFFWG4.js → chunk-MLVPMDOZ.js} +2 -2
- package/dist/{chunk-5FE75J4S.js → chunk-MMCN7TLK.js} +5 -5
- package/dist/{chunk-MXOQ5JCG.js → chunk-MRCR7ZMC.js} +686 -202
- package/dist/chunk-MRCR7ZMC.js.map +1 -0
- package/dist/{chunk-SYNY3VB5.js → chunk-NCTN2FW4.js} +2 -2
- package/dist/{chunk-4T3SE27M.js → chunk-ND6S2DKC.js} +2 -2
- package/dist/{chunk-3XJQBBZD.js → chunk-NTVKHQ3L.js} +2 -2
- package/dist/{chunk-RHVMZSUU.js → chunk-NV4OESHC.js} +1 -1
- package/dist/chunk-NV4OESHC.js.map +1 -0
- package/dist/chunk-NXQEOC3X.js +40 -0
- package/dist/chunk-NXQEOC3X.js.map +1 -0
- package/dist/{chunk-Q4UHJ5SN.js → chunk-O2VQ3K36.js} +2 -2
- package/dist/{chunk-HW7CMKUG.js → chunk-OFD2HD6F.js} +1 -1
- package/dist/{chunk-HW7CMKUG.js.map → chunk-OFD2HD6F.js.map} +1 -1
- package/dist/{chunk-2GHDLTPE.js → chunk-OGKMRIIJ.js} +2 -2
- package/dist/{chunk-N7EVQD5S.js → chunk-ONZ3B5EW.js} +4 -4
- package/dist/{chunk-VKI2EB3N.js → chunk-OOPSMQX5.js} +3 -3
- package/dist/{chunk-VMV5SBE4.js → chunk-OYEBSWLE.js} +5 -5
- package/dist/{chunk-JDEYF3PJ.js → chunk-P6FATPXQ.js} +2 -2
- package/dist/chunk-P6FATPXQ.js.map +1 -0
- package/dist/{chunk-VVOLDVIR.js → chunk-PLTIJDQN.js} +2 -2
- package/dist/{chunk-OKSTSITU.js → chunk-PR7ILCIH.js} +3 -3
- package/dist/{chunk-7R2Q7CPL.js → chunk-QE3TLZ6Z.js} +7 -7
- package/dist/{chunk-G2MVBDFP.js → chunk-QFW4MYGN.js} +39 -9
- package/dist/chunk-QFW4MYGN.js.map +1 -0
- package/dist/{chunk-6QVKPHBF.js → chunk-QHG7GQKM.js} +2 -2
- package/dist/chunk-QJNAHPVT.js +91 -0
- package/dist/chunk-QJNAHPVT.js.map +1 -0
- package/dist/{chunk-LIOVX5TJ.js → chunk-QT5ITL25.js} +3 -3
- package/dist/{chunk-IMQKWR46.js → chunk-R2ZULFXU.js} +4 -5
- package/dist/chunk-R2ZULFXU.js.map +1 -0
- package/dist/{chunk-Q2XRFWOI.js → chunk-RRTQAQ3N.js} +2 -2
- package/dist/{chunk-H23XHRTT.js → chunk-RUE6TCES.js} +809 -101
- package/dist/chunk-RUE6TCES.js.map +1 -0
- package/dist/chunk-RWFQVNXR.js +24 -0
- package/dist/chunk-RWFQVNXR.js.map +1 -0
- package/dist/{chunk-2PVXF5CS.js → chunk-SALY3LIJ.js} +3 -3
- package/dist/{chunk-JOSPH3E5.js → chunk-SBAR5JQ6.js} +2 -2
- package/dist/{chunk-N7UDP5VU.js → chunk-SCH2F7R2.js} +7 -7
- package/dist/{chunk-MXKI4ABF.js → chunk-SOOAW6HK.js} +3 -3
- package/dist/{chunk-VQDZYB2B.js → chunk-T4VTRKCY.js} +3 -3
- package/dist/{chunk-VQDZYB2B.js.map → chunk-T4VTRKCY.js.map} +1 -1
- package/dist/{chunk-TEHHROZL.js → chunk-T5EXREMW.js} +5 -5
- package/dist/{chunk-M5B2W6YY.js → chunk-TDJVQTXD.js} +3 -3
- package/dist/{chunk-QMWY2FDS.js → chunk-THQ3BHLM.js} +2 -2
- package/dist/{chunk-VAORSCSU.js → chunk-TLIFNRU5.js} +2 -2
- package/dist/chunk-TLIFNRU5.js.map +1 -0
- package/dist/{chunk-FVH5QYY2.js → chunk-TRHUNPXP.js} +2 -2
- package/dist/{chunk-EGVJ7TM4.js → chunk-UL6MTRMJ.js} +8 -9
- package/dist/chunk-UL6MTRMJ.js.map +1 -0
- package/dist/chunk-UNL6YGL5.js +169 -0
- package/dist/chunk-UNL6YGL5.js.map +1 -0
- package/dist/{chunk-747G6CT3.js → chunk-UORWAG7K.js} +2 -2
- package/dist/{chunk-XSPFDUDG.js → chunk-V7AKGAXY.js} +314 -77
- package/dist/chunk-V7AKGAXY.js.map +1 -0
- package/dist/{chunk-TZZBXPZK.js → chunk-VLQ6KT7F.js} +2 -2
- package/dist/{chunk-NCO25JZO.js → chunk-VP37VUKQ.js} +4 -4
- package/dist/{chunk-52MGURXO.js → chunk-WBUHHMLN.js} +2 -2
- package/dist/{chunk-EZGV6F47.js → chunk-WRLWEYHY.js} +7 -1
- package/dist/chunk-WRLWEYHY.js.map +1 -0
- package/dist/{chunk-2MG3SW7Q.js → chunk-X6Z2SIRF.js} +2 -2
- package/dist/{chunk-U2FZNEWJ.js → chunk-XLKWF3L4.js} +8 -6
- package/dist/{chunk-U2FZNEWJ.js.map → chunk-XLKWF3L4.js.map} +1 -1
- package/dist/{chunk-5UMK7GRI.js → chunk-XPNJH7GN.js} +5 -5
- package/dist/{chunk-KZXDLBY6.js → chunk-XPW7T2GN.js} +5 -5
- package/dist/{chunk-SV2PM2OY.js → chunk-XX4R7TUB.js} +1 -1
- package/dist/chunk-XX4R7TUB.js.map +1 -0
- package/dist/{chunk-NBQ3KK6X.js → chunk-Y55XHMQB.js} +4 -4
- package/dist/chunk-Y55XHMQB.js.map +1 -0
- package/dist/{chunk-5KC7QYEC.js → chunk-YH4OUOSI.js} +33 -7
- package/dist/chunk-YH4OUOSI.js.map +1 -0
- package/dist/{chunk-FFJFE4T7.js → chunk-YJGKOSQD.js} +2 -2
- package/dist/{chunk-2AFX33YA.js → chunk-Z3STG43F.js} +3 -3
- package/dist/chunk-Z3STG43F.js.map +1 -0
- package/dist/{chunk-OIEO4WDL.js → chunk-ZD7WFMV2.js} +2 -2
- package/dist/chunk-ZD7WFMV2.js.map +1 -0
- package/dist/{chunk-42ALPZ2B.js → chunk-ZF6JECDT.js} +4 -4
- package/dist/{chunk-42ALPZ2B.js.map → chunk-ZF6JECDT.js.map} +1 -1
- package/dist/{chunk-4JPMZTJY.js → chunk-ZF7KNSLU.js} +2 -2
- package/dist/{chunk-2ODVB6LZ.js → chunk-ZGKODRGB.js} +2 -2
- package/dist/{chunk-JIBUPZHA.js → chunk-ZNEKQFGF.js} +4 -4
- package/dist/{chunk-DLD5LGDS.js → chunk-ZUTUNVFD.js} +3 -3
- package/dist/{chunk-JSMTXZR3.js → chunk-ZWMOHANW.js} +8 -6
- package/dist/chunk-ZWMOHANW.js.map +1 -0
- package/dist/{chunk-MILI22XQ.js → chunk-ZZZ4VCY2.js} +10 -10
- package/dist/chunk-ZZZ4VCY2.js.map +1 -0
- package/dist/classified/index.js +5 -5
- package/dist/{classified-marker-SIYKUU5L.js → classified-marker-WKP33U2R.js} +3 -3
- package/dist/collection-facade-COSGZKLC.js +41 -0
- package/dist/{computed-FAD7SED4.js → computed-WN6V53ZV.js} +3 -3
- package/dist/consent/index.js +8 -8
- package/dist/cover/index.js +8 -8
- package/dist/coverage/index.js +1 -1
- package/dist/custody/index.js +12 -11
- package/dist/{dead-filter-4F3LWYKH.js → dead-filter-43WL3Y5H.js} +10 -10
- package/dist/debug/index.js +7 -7
- package/dist/delegation-5UWT4JGT.js +26 -0
- package/dist/derivations/index.js +24 -23
- package/dist/derive-IL5JNLEE.js +20 -0
- package/dist/directory/index.js +9 -9
- package/dist/{dispatch-JDZNGEB3.js → dispatch-LOQQD5JK.js} +20 -20
- package/dist/{dispatch-H4HV32AM.js → dispatch-SHKTG57L.js} +5 -5
- package/dist/executor-6PQ7WAGV.js +35 -0
- package/dist/executor-6ZPQA6HS.js +8 -0
- package/dist/executor-OXRA64TY.js +8 -0
- package/dist/export-accessible-XG3FKJWW.js +22 -0
- package/dist/extract-partition-33747NY5.js +35 -0
- package/dist/{fanout-sidecar-L7NHPIOC.js → fanout-sidecar-NEB6IYV7.js} +8 -8
- package/dist/find-VW543G3J.js +10 -0
- package/dist/forget/index.js +25 -8
- package/dist/forget/index.js.map +1 -1
- package/dist/guards/index.js +4 -4
- package/dist/history/index.js +15 -13
- package/dist/history/index.js.map +1 -1
- package/dist/i18n/index.js +13 -13
- package/dist/index.d.ts +9 -6
- package/dist/index.js +126 -110
- package/dist/index.js.map +1 -1
- package/dist/indexing/index.js +6 -6
- package/dist/introspection/index.js +15 -11
- package/dist/issue-4ZPSY44M.js +19 -0
- package/dist/kernel/cache/index.d.ts +1 -1
- package/dist/kernel/collection.d.ts +86 -6
- package/dist/kernel/constants.d.ts +7 -0
- package/dist/kernel/errors.d.ts +42 -4
- package/dist/kernel/export-scope.d.ts +40 -0
- package/dist/kernel/merge-authority.d.ts +5 -1
- package/dist/kernel/noydb.d.ts +118 -21
- package/dist/kernel/put-many-atomic.d.ts +1 -1
- package/dist/kernel/query/live/live.d.ts +2 -1
- package/dist/kernel/query/sort-key.d.ts +0 -2
- package/dist/kernel/rejection-seal.d.ts +13 -0
- package/dist/kernel/sync-wiring.d.ts +55 -0
- package/dist/kernel/tx-write-gate.d.ts +2 -4
- package/dist/kernel/types.d.ts +463 -14
- package/dist/kernel/validation.d.ts +0 -10
- package/dist/kernel/vault.d.ts +42 -4
- package/dist/kernel/via/reconcile.d.ts +1 -42
- package/dist/{ledger-5ZMGE44K.js → ledger-MZ25UFT2.js} +10 -10
- package/dist/liberate-OJIP2ZFX.js +25 -0
- package/dist/{link-set-MFXC24VK.js → link-set-4FRRAVTH.js} +10 -10
- package/dist/{managed-secret-MFTFT22X.js → managed-secret-SQWO2EUR.js} +9 -9
- package/dist/materialized-views/index.js +26 -26
- package/dist/{migrate-cek-DZRFFOHW.js → migrate-cek-JWEM4RP6.js} +2 -2
- package/dist/money/index.js +5 -5
- package/dist/noydb-U62OVKXB.js +100 -0
- package/dist/on/index.js +25 -0
- package/dist/overlay-views/index.js +4 -4
- package/dist/periods/index.js +11 -11
- package/dist/pod/index.js +71 -67
- package/dist/{pod-handle-A3LET7NO.js → pod-handle-R6Y4MILX.js} +8 -8
- package/dist/policy/index.js +9 -9
- package/dist/port/as/active.d.ts +4 -0
- package/dist/port/as/index.d.ts +1 -0
- package/dist/port/by/index.d.ts +14 -5
- package/dist/port/on/index.d.ts +26 -0
- package/dist/port/to/index.d.ts +1 -1
- package/dist/port/with/admission-authority.d.ts +34 -0
- package/dist/port/with/broker-strategy.d.ts +24 -0
- package/dist/port/with/coverage-strategy.d.ts +17 -1
- package/dist/port/with/formats-strategy.d.ts +34 -1
- package/dist/port/with/lookup-strategy.d.ts +85 -4
- package/dist/port/with/rejection-courier.d.ts +37 -0
- package/dist/port/with/restore-host.d.ts +33 -0
- package/dist/port/with/service-bus.d.ts +20 -1
- package/dist/port/with/team-strategy.d.ts +2 -2
- package/dist/port/with/write-hooks.d.ts +2 -0
- package/dist/portability/index.js +8 -8
- package/dist/{post-register-7ND27CF2.js → post-register-GRVQHBOH.js} +6 -6
- package/dist/query/all/index.js +16 -16
- package/dist/query/index.js +8 -8
- package/dist/query/live/index.js +7 -7
- package/dist/query/reduce/index.js +10 -10
- package/dist/query/relate/index.js +10 -10
- package/dist/reduce/index.js +8 -8
- package/dist/register-YJ5YLQ36.js +30 -0
- package/dist/registry-ICOHBQFD.js +8 -0
- package/dist/registry-MJ7MWCSW.js +35 -0
- package/dist/registry-MVEKKGWL.js +23 -0
- package/dist/registry-XP744FAP.js +8 -0
- package/dist/request-withdrawal-LSU4G6W3.js +28 -0
- package/dist/restore-to-DVBHAQAA.js +66 -0
- package/dist/restore-to-DVBHAQAA.js.map +1 -0
- package/dist/{reveal-B2TLP4JQ.js → reveal-AIHOIK2N.js} +7 -7
- package/dist/revoke-QUT7WWG3.js +24 -0
- package/dist/satellites/index.js +1 -1
- package/dist/schema-update/index.js +2 -2
- package/dist/sealed-record/index.js +11 -11
- package/dist/search/index.js +4 -4
- package/dist/{seed-XNSE4U3S.js → seed-GFLA4FCK.js} +136 -27
- package/dist/seed-GFLA4FCK.js.map +1 -0
- package/dist/sequence/index.js +8 -8
- package/dist/session/index.js +8 -8
- package/dist/shadow/index.js +2 -2
- package/dist/signer-NYR4I3FO.js +23 -0
- package/dist/snapshots/index.js +9 -9
- package/dist/{stale-6GCFMOOR.js → stale-PIJPAL5T.js} +9 -9
- package/dist/storage-VH6SPXHC.js +21 -0
- package/dist/{store-coordination-provider-C4BPT5XF.js → store-coordination-provider-2KSHCOPU.js} +9 -9
- package/dist/sync/index.js +19 -13
- package/dist/sync/index.js.map +1 -1
- package/dist/team/index.js +17 -15
- package/dist/tiers/index.js +10 -10
- package/dist/to/index.js +2 -2
- package/dist/transactions/index.js +3 -3
- package/dist/util/index.js +1 -1
- package/dist/vault-head/index.js +8 -8
- package/dist/{verify-UKALW7C2.js → verify-PCFS4PNS.js} +7 -7
- package/dist/via/classified/presets.d.ts +29 -0
- package/dist/via/classified/resolve.d.ts +7 -0
- package/dist/via/geo/binding.d.ts +0 -4
- package/dist/via/lookup/index.d.ts +32 -0
- package/dist/via/money/binding.d.ts +0 -9
- package/dist/walk-OZCN6LJS.js +20 -0
- package/dist/with-audit/attestation/strategy.d.ts +2 -1
- package/dist/with-audit/attestation/vault-facade.d.ts +7 -0
- package/dist/with-audit/forget/completeness.d.ts +66 -0
- package/dist/with-audit/forget/index.d.ts +2 -0
- package/dist/with-audit/forget/strategy.d.ts +65 -0
- package/dist/with-audit/guards/types.d.ts +2 -0
- package/dist/with-audit/periods/periods.d.ts +0 -9
- package/dist/with-audit/periods/reserved-collections.d.ts +7 -0
- package/dist/with-audit/portability/request-withdrawal.d.ts +0 -1
- package/dist/with-audit/portability/withdraw-accessible.d.ts +0 -1
- package/dist/with-audit/tiers/index.d.ts +6 -6
- package/dist/with-audit/tiers/strategy.d.ts +19 -0
- package/dist/with-cargo/extract-partition.d.ts +0 -46
- package/dist/with-commit/history/history.d.ts +16 -0
- package/dist/with-commit/history/restore-to.d.ts +40 -0
- package/dist/with-commit/numbering/index.d.ts +0 -2
- package/dist/with-commit/tx/transaction.d.ts +2 -24
- package/dist/with-commit/vault-head/strategy.d.ts +7 -0
- package/dist/with-fork/snapshots/noydb-facade.d.ts +7 -0
- package/dist/with-formula/derivations/trigger-match.d.ts +8 -5
- package/dist/with-formula/materialized-views/emit-memo.d.ts +0 -2
- package/dist/with-lookup/embeddings/index.d.ts +1 -2
- package/dist/with-lookup/indexing/collection-facade.d.ts +1 -15
- package/dist/with-lookup/indexing/eager-indexes.d.ts +2 -1
- package/dist/with-lookup/search/collection-facade.d.ts +0 -12
- package/dist/with-party/broker/index.d.ts +2 -2
- package/dist/with-party/broker/seed.d.ts +29 -10
- package/dist/with-party/custody/strategy.d.ts +2 -2
- package/dist/with-party/policy/noydb-facade.d.ts +1 -31
- package/dist/with-party/team/delegation.d.ts +93 -7
- package/dist/with-party/team/echo-secret.d.ts +0 -2
- package/dist/with-party/team/index.d.ts +2 -0
- package/dist/with-party/team/keyring.d.ts +133 -24
- package/dist/with-party/team/magic-link-grant.d.ts +11 -1
- package/dist/with-party/team/noydb-facade.d.ts +19 -2
- package/dist/with-party/team/reserved-secret-collections.d.ts +10 -8
- package/dist/with-party/team/roster-tag.d.ts +42 -1
- package/dist/with-party/team/tiers.d.ts +36 -5
- package/dist/with-pod/backup.d.ts +9 -17
- package/dist/with-shape/blobs/blob-set.d.ts +23 -0
- package/dist/with-shape/blobs/legacy-sweep.d.ts +16 -0
- package/dist/with-shape/introspection/describe.d.ts +1 -2
- package/dist/with-shape/introspection/index.d.ts +1 -0
- package/dist/with-shape/introspection/types.d.ts +2 -1
- package/dist/with-shape/schema-update/fence.d.ts +7 -0
- package/dist/with-sync/active.d.ts +28 -1
- package/dist/with-sync/engine.d.ts +88 -2
- package/dist/with-sync/index.d.ts +1 -0
- package/dist/with-sync/reserved-mirror.d.ts +112 -0
- package/dist/with-sync/strategy.d.ts +9 -0
- package/dist/with-sync/tab-write-relay.d.ts +0 -10
- package/dist/withdraw-accessible-MTFP7OIB.js +25 -0
- package/dist/withdraw-accessible-MTFP7OIB.js.map +1 -0
- package/package.json +3 -3
- package/dist/api-OS747DS4.js +0 -18
- package/dist/backup-YE2VQ26S.js.map +0 -1
- package/dist/chunk-2AFX33YA.js.map +0 -1
- package/dist/chunk-2RH777HH.js +0 -126
- package/dist/chunk-2RH777HH.js.map +0 -1
- package/dist/chunk-37EPTBBR.js.map +0 -1
- package/dist/chunk-5KC7QYEC.js.map +0 -1
- package/dist/chunk-7XMHMVTS.js +0 -20
- package/dist/chunk-7XMHMVTS.js.map +0 -1
- package/dist/chunk-A4XMIZT3.js.map +0 -1
- package/dist/chunk-DHHGL42E.js.map +0 -1
- package/dist/chunk-DQESF6RP.js.map +0 -1
- package/dist/chunk-EGVJ7TM4.js.map +0 -1
- package/dist/chunk-EYG2CY2X.js.map +0 -1
- package/dist/chunk-EZGV6F47.js.map +0 -1
- package/dist/chunk-FFWI7UH7.js.map +0 -1
- package/dist/chunk-G2MVBDFP.js.map +0 -1
- package/dist/chunk-GUZET4SG.js.map +0 -1
- package/dist/chunk-GZT3NQRA.js.map +0 -1
- package/dist/chunk-H23XHRTT.js.map +0 -1
- package/dist/chunk-H7JBY4P7.js.map +0 -1
- package/dist/chunk-IMQKWR46.js.map +0 -1
- package/dist/chunk-IUBMZPHM.js.map +0 -1
- package/dist/chunk-IUT3GWP3.js.map +0 -1
- package/dist/chunk-JDEYF3PJ.js.map +0 -1
- package/dist/chunk-JSMTXZR3.js.map +0 -1
- package/dist/chunk-LGNDFRYC.js.map +0 -1
- package/dist/chunk-LNSVGRHO.js.map +0 -1
- package/dist/chunk-MILI22XQ.js.map +0 -1
- package/dist/chunk-MXOQ5JCG.js.map +0 -1
- package/dist/chunk-NBQ3KK6X.js.map +0 -1
- package/dist/chunk-OIEO4WDL.js.map +0 -1
- package/dist/chunk-PD64727P.js.map +0 -1
- package/dist/chunk-RHVMZSUU.js.map +0 -1
- package/dist/chunk-SV2PM2OY.js.map +0 -1
- package/dist/chunk-T7IR4N2S.js.map +0 -1
- package/dist/chunk-UA372JHH.js.map +0 -1
- package/dist/chunk-UBSFPGVJ.js +0 -1
- package/dist/chunk-V3RWOOSO.js.map +0 -1
- package/dist/chunk-VAORSCSU.js.map +0 -1
- package/dist/chunk-XSPFDUDG.js.map +0 -1
- package/dist/chunk-Y3LPTBG7.js.map +0 -1
- package/dist/collection-facade-CS7CA2XO.js +0 -47
- package/dist/delegation-NANZDG4N.js +0 -102
- package/dist/delegation-NANZDG4N.js.map +0 -1
- package/dist/derive-XLOJVXPU.js +0 -20
- package/dist/executor-FMPVN6DT.js +0 -35
- package/dist/executor-LBBBRTN5.js +0 -8
- package/dist/executor-OSRZST2U.js +0 -8
- package/dist/export-accessible-RAOJAAU5.js +0 -22
- package/dist/extract-partition-JD5CUSTG.js +0 -37
- package/dist/find-JRN4RNQ5.js +0 -10
- package/dist/issue-YIVBZUTH.js +0 -19
- package/dist/liberate-WZSZM2W6.js +0 -24
- package/dist/noydb-ITIGNKUF.js +0 -96
- package/dist/register-DT5HZ2LZ.js +0 -30
- package/dist/registry-BHRZGZHF.js +0 -8
- package/dist/registry-ET6ZFFWA.js +0 -34
- package/dist/registry-HXFGLGTG.js +0 -8
- package/dist/registry-THCPDEOD.js +0 -23
- package/dist/request-withdrawal-AV2MJJKY.js +0 -30
- package/dist/revoke-6DWIEOCV.js +0 -24
- package/dist/seed-XNSE4U3S.js.map +0 -1
- package/dist/signer-MHGW3OIL.js +0 -23
- package/dist/storage-BYN5LO6Z.js +0 -21
- package/dist/walk-4VPK7AS4.js +0 -20
- package/dist/withdraw-accessible-HL7GACUE.js +0 -27
- /package/dist/{api-OS747DS4.js.map → api-6EFD43KN.js.map} +0 -0
- /package/dist/{capsule-VOLX3QRQ.js.map → capsule-6LJAVQNM.js.map} +0 -0
- /package/dist/{chunk-OYW3I5M4.js.map → chunk-2DOCDOPL.js.map} +0 -0
- /package/dist/{chunk-UBSFPGVJ.js.map → chunk-2DX4JCRI.js.map} +0 -0
- /package/dist/{chunk-FLPCETP6.js.map → chunk-2LBS62AC.js.map} +0 -0
- /package/dist/{chunk-WXE4W2U6.js.map → chunk-2ST3WA3C.js.map} +0 -0
- /package/dist/{chunk-O2IMQSNA.js.map → chunk-3YBIVLTC.js.map} +0 -0
- /package/dist/{chunk-DIZLQVAA.js.map → chunk-4CHM2TRS.js.map} +0 -0
- /package/dist/{chunk-V7ADQF5O.js.map → chunk-4CUJLEOA.js.map} +0 -0
- /package/dist/{chunk-3EWS67C7.js.map → chunk-4TG2ITRW.js.map} +0 -0
- /package/dist/{chunk-HS554XAF.js.map → chunk-5HQFROZS.js.map} +0 -0
- /package/dist/{chunk-PP3K67AJ.js.map → chunk-654RE5YC.js.map} +0 -0
- /package/dist/{chunk-FOEDQATO.js.map → chunk-66GD7XXU.js.map} +0 -0
- /package/dist/{chunk-BNWA3WG5.js.map → chunk-72FQ46VW.js.map} +0 -0
- /package/dist/{chunk-JQYKPKG6.js.map → chunk-7K42TSCY.js.map} +0 -0
- /package/dist/{chunk-UEFOQH74.js.map → chunk-ADCXTW7L.js.map} +0 -0
- /package/dist/{chunk-MBMTND6D.js.map → chunk-AGGPT4UE.js.map} +0 -0
- /package/dist/{chunk-RB4DOPGZ.js.map → chunk-AKIEBFIJ.js.map} +0 -0
- /package/dist/{chunk-VHBKYN2J.js.map → chunk-B3B6HV5S.js.map} +0 -0
- /package/dist/{chunk-JWWYRR4Q.js.map → chunk-B6EWMGFX.js.map} +0 -0
- /package/dist/{chunk-WPOYWFSE.js.map → chunk-BJRKXNFP.js.map} +0 -0
- /package/dist/{chunk-H427H63K.js.map → chunk-BPQ5CRJF.js.map} +0 -0
- /package/dist/{chunk-VFHCKG5M.js.map → chunk-BVRJYMFZ.js.map} +0 -0
- /package/dist/{chunk-SMV2HRDU.js.map → chunk-DFC4WTJW.js.map} +0 -0
- /package/dist/{chunk-5A4345TG.js.map → chunk-DMIEKD24.js.map} +0 -0
- /package/dist/{chunk-TKVUE4JF.js.map → chunk-DQAXA2GK.js.map} +0 -0
- /package/dist/{chunk-AL6ML4LA.js.map → chunk-DWCFGF2K.js.map} +0 -0
- /package/dist/{chunk-QBLT6POL.js.map → chunk-FPF5HRBE.js.map} +0 -0
- /package/dist/{chunk-5WWDGFOS.js.map → chunk-GIQJGXV7.js.map} +0 -0
- /package/dist/{chunk-BVCUTXE3.js.map → chunk-H334G6KU.js.map} +0 -0
- /package/dist/{chunk-AEQGFRU4.js.map → chunk-HE7EAHGS.js.map} +0 -0
- /package/dist/{chunk-4V3Q35WG.js.map → chunk-ICF3TIGY.js.map} +0 -0
- /package/dist/{chunk-3L2NBKDR.js.map → chunk-IF2M43G4.js.map} +0 -0
- /package/dist/{chunk-AUKKUPVB.js.map → chunk-IVLRPRXM.js.map} +0 -0
- /package/dist/{chunk-Y2RKVFKR.js.map → chunk-K4JSTGXT.js.map} +0 -0
- /package/dist/{chunk-EJLV62NI.js.map → chunk-KN4LUMH6.js.map} +0 -0
- /package/dist/{chunk-23D6M6VM.js.map → chunk-KZA3DITX.js.map} +0 -0
- /package/dist/{chunk-E2N2T5ZO.js.map → chunk-L2VM64HK.js.map} +0 -0
- /package/dist/{chunk-O46CHQT7.js.map → chunk-MAQBYBUX.js.map} +0 -0
- /package/dist/{chunk-EZOAKKTB.js.map → chunk-MBPZMZVB.js.map} +0 -0
- /package/dist/{chunk-XQRFSKYM.js.map → chunk-MCNNZBG7.js.map} +0 -0
- /package/dist/{chunk-YRXFFWG4.js.map → chunk-MLVPMDOZ.js.map} +0 -0
- /package/dist/{chunk-5FE75J4S.js.map → chunk-MMCN7TLK.js.map} +0 -0
- /package/dist/{chunk-SYNY3VB5.js.map → chunk-NCTN2FW4.js.map} +0 -0
- /package/dist/{chunk-4T3SE27M.js.map → chunk-ND6S2DKC.js.map} +0 -0
- /package/dist/{chunk-3XJQBBZD.js.map → chunk-NTVKHQ3L.js.map} +0 -0
- /package/dist/{chunk-Q4UHJ5SN.js.map → chunk-O2VQ3K36.js.map} +0 -0
- /package/dist/{chunk-2GHDLTPE.js.map → chunk-OGKMRIIJ.js.map} +0 -0
- /package/dist/{chunk-N7EVQD5S.js.map → chunk-ONZ3B5EW.js.map} +0 -0
- /package/dist/{chunk-VKI2EB3N.js.map → chunk-OOPSMQX5.js.map} +0 -0
- /package/dist/{chunk-VMV5SBE4.js.map → chunk-OYEBSWLE.js.map} +0 -0
- /package/dist/{chunk-VVOLDVIR.js.map → chunk-PLTIJDQN.js.map} +0 -0
- /package/dist/{chunk-OKSTSITU.js.map → chunk-PR7ILCIH.js.map} +0 -0
- /package/dist/{chunk-7R2Q7CPL.js.map → chunk-QE3TLZ6Z.js.map} +0 -0
- /package/dist/{chunk-6QVKPHBF.js.map → chunk-QHG7GQKM.js.map} +0 -0
- /package/dist/{chunk-LIOVX5TJ.js.map → chunk-QT5ITL25.js.map} +0 -0
- /package/dist/{chunk-Q2XRFWOI.js.map → chunk-RRTQAQ3N.js.map} +0 -0
- /package/dist/{chunk-2PVXF5CS.js.map → chunk-SALY3LIJ.js.map} +0 -0
- /package/dist/{chunk-JOSPH3E5.js.map → chunk-SBAR5JQ6.js.map} +0 -0
- /package/dist/{chunk-N7UDP5VU.js.map → chunk-SCH2F7R2.js.map} +0 -0
- /package/dist/{chunk-MXKI4ABF.js.map → chunk-SOOAW6HK.js.map} +0 -0
- /package/dist/{chunk-TEHHROZL.js.map → chunk-T5EXREMW.js.map} +0 -0
- /package/dist/{chunk-M5B2W6YY.js.map → chunk-TDJVQTXD.js.map} +0 -0
- /package/dist/{chunk-QMWY2FDS.js.map → chunk-THQ3BHLM.js.map} +0 -0
- /package/dist/{chunk-FVH5QYY2.js.map → chunk-TRHUNPXP.js.map} +0 -0
- /package/dist/{chunk-747G6CT3.js.map → chunk-UORWAG7K.js.map} +0 -0
- /package/dist/{chunk-TZZBXPZK.js.map → chunk-VLQ6KT7F.js.map} +0 -0
- /package/dist/{chunk-NCO25JZO.js.map → chunk-VP37VUKQ.js.map} +0 -0
- /package/dist/{chunk-52MGURXO.js.map → chunk-WBUHHMLN.js.map} +0 -0
- /package/dist/{chunk-2MG3SW7Q.js.map → chunk-X6Z2SIRF.js.map} +0 -0
- /package/dist/{chunk-5UMK7GRI.js.map → chunk-XPNJH7GN.js.map} +0 -0
- /package/dist/{chunk-KZXDLBY6.js.map → chunk-XPW7T2GN.js.map} +0 -0
- /package/dist/{chunk-FFJFE4T7.js.map → chunk-YJGKOSQD.js.map} +0 -0
- /package/dist/{chunk-4JPMZTJY.js.map → chunk-ZF7KNSLU.js.map} +0 -0
- /package/dist/{chunk-2ODVB6LZ.js.map → chunk-ZGKODRGB.js.map} +0 -0
- /package/dist/{chunk-JIBUPZHA.js.map → chunk-ZNEKQFGF.js.map} +0 -0
- /package/dist/{chunk-DLD5LGDS.js.map → chunk-ZUTUNVFD.js.map} +0 -0
- /package/dist/{classified-marker-SIYKUU5L.js.map → classified-marker-WKP33U2R.js.map} +0 -0
- /package/dist/{collection-facade-CS7CA2XO.js.map → collection-facade-COSGZKLC.js.map} +0 -0
- /package/dist/{computed-FAD7SED4.js.map → computed-WN6V53ZV.js.map} +0 -0
- /package/dist/{dead-filter-4F3LWYKH.js.map → dead-filter-43WL3Y5H.js.map} +0 -0
- /package/dist/{derive-XLOJVXPU.js.map → delegation-5UWT4JGT.js.map} +0 -0
- /package/dist/{executor-FMPVN6DT.js.map → derive-IL5JNLEE.js.map} +0 -0
- /package/dist/{dispatch-JDZNGEB3.js.map → dispatch-LOQQD5JK.js.map} +0 -0
- /package/dist/{dispatch-H4HV32AM.js.map → dispatch-SHKTG57L.js.map} +0 -0
- /package/dist/{executor-LBBBRTN5.js.map → executor-6PQ7WAGV.js.map} +0 -0
- /package/dist/{executor-OSRZST2U.js.map → executor-6ZPQA6HS.js.map} +0 -0
- /package/dist/{export-accessible-RAOJAAU5.js.map → executor-OXRA64TY.js.map} +0 -0
- /package/dist/{extract-partition-JD5CUSTG.js.map → export-accessible-XG3FKJWW.js.map} +0 -0
- /package/dist/{find-JRN4RNQ5.js.map → extract-partition-33747NY5.js.map} +0 -0
- /package/dist/{fanout-sidecar-L7NHPIOC.js.map → fanout-sidecar-NEB6IYV7.js.map} +0 -0
- /package/dist/{issue-YIVBZUTH.js.map → find-VW543G3J.js.map} +0 -0
- /package/dist/{ledger-5ZMGE44K.js.map → issue-4ZPSY44M.js.map} +0 -0
- /package/dist/{liberate-WZSZM2W6.js.map → ledger-MZ25UFT2.js.map} +0 -0
- /package/dist/{link-set-MFXC24VK.js.map → liberate-OJIP2ZFX.js.map} +0 -0
- /package/dist/{managed-secret-MFTFT22X.js.map → link-set-4FRRAVTH.js.map} +0 -0
- /package/dist/{noydb-ITIGNKUF.js.map → managed-secret-SQWO2EUR.js.map} +0 -0
- /package/dist/{migrate-cek-DZRFFOHW.js.map → migrate-cek-JWEM4RP6.js.map} +0 -0
- /package/dist/{register-DT5HZ2LZ.js.map → noydb-U62OVKXB.js.map} +0 -0
- /package/dist/{pod-handle-A3LET7NO.js.map → pod-handle-R6Y4MILX.js.map} +0 -0
- /package/dist/{post-register-7ND27CF2.js.map → post-register-GRVQHBOH.js.map} +0 -0
- /package/dist/{registry-BHRZGZHF.js.map → register-YJ5YLQ36.js.map} +0 -0
- /package/dist/{registry-ET6ZFFWA.js.map → registry-ICOHBQFD.js.map} +0 -0
- /package/dist/{registry-HXFGLGTG.js.map → registry-MJ7MWCSW.js.map} +0 -0
- /package/dist/{registry-THCPDEOD.js.map → registry-MVEKKGWL.js.map} +0 -0
- /package/dist/{request-withdrawal-AV2MJJKY.js.map → registry-XP744FAP.js.map} +0 -0
- /package/dist/{revoke-6DWIEOCV.js.map → request-withdrawal-LSU4G6W3.js.map} +0 -0
- /package/dist/{reveal-B2TLP4JQ.js.map → reveal-AIHOIK2N.js.map} +0 -0
- /package/dist/{signer-MHGW3OIL.js.map → revoke-QUT7WWG3.js.map} +0 -0
- /package/dist/{stale-6GCFMOOR.js.map → signer-NYR4I3FO.js.map} +0 -0
- /package/dist/{storage-BYN5LO6Z.js.map → stale-PIJPAL5T.js.map} +0 -0
- /package/dist/{walk-4VPK7AS4.js.map → storage-VH6SPXHC.js.map} +0 -0
- /package/dist/{store-coordination-provider-C4BPT5XF.js.map → store-coordination-provider-2KSHCOPU.js.map} +0 -0
- /package/dist/{verify-UKALW7C2.js.map → verify-PCFS4PNS.js.map} +0 -0
- /package/dist/{withdraw-accessible-HL7GACUE.js.map → walk-OZCN6LJS.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/kernel/query/relate/join-reduce.ts","../src/kernel/query/reduce/methods.ts","../src/kernel/query/reduce/scan-methods.ts","../src/kernel/query/reduce/install.ts"],"sourcesContent":["/**\n * Reducing over a JOIN ALIAS (#1338).\n *\n * `aggregate()` and `groupBy()` used to refuse any field rooted at a join\n * alias. The refusal's own doc named the real blocker, and it was never \"the\n * legs do not run\" — running them is the easy half. It was that the Via\n * pipeline is LEFT-SCOPED: `Query.aggregate()` calls\n * `this.source.via.wrapReducers(spec)`, which resolves every reducer's field\n * against the LEFT collection's map. For `sum('client.balance')` that map has\n * no entry, so two things silently did not happen — money's exact-BigInt\n * rewrite was skipped (a generic sum over stored scaled-integer strings, which\n * `readNumber` coerces to 0), and `refuseUnqueryableReducers` never fired, so\n * the `queryable: 'none'` gate that would refuse a blob field never applied.\n *\n * This module supplies the missing half as a Via BINDING rather than as a\n * special case threaded through the reduce strategy. A binding composes: the\n * pipeline handed to `GroupedQuery`/`aggregate()` is the left one plus this,\n * so every existing call site keeps its exact behaviour and the alias case\n * arrives through the same `wrapReducers` door as everything else.\n *\n * Two properties make that safe:\n *\n * - **It delegates, it does not reimplement.** An aliased reducer is handed\n * to the RIGHT collection's OWN pipeline under its BARE field name — which\n * is how a pipeline is keyed (that is the whole shape of #1335) — so the\n * right side's rewrite AND its posture gate apply together, from one call.\n * - **`covers()` returns false**, so the binding is inert for `postureFor`,\n * `present`, `decodeResults` and every other phase. It exists for exactly\n * one hook.\n */\nimport type { NoydbVia } from '../../via/index.js'\nimport { ViaPipeline } from '../../via/pipeline.js'\n\n/**\n * The reducer shape this file needs, declared STRUCTURALLY rather than\n * imported from `with-lookup/reduce/`.\n *\n * Not a style choice: `check-architecture.mjs`'s port-layering guard refuses a\n * NEW static kernel→`with-*` import (its allowlist is a frozen per-file, per-\n * specifier baseline, and adding a row would be the thing the freeze exists to\n * stop). `NoydbVia.wrapReducers` is declared `(spec: unknown) => unknown`\n * precisely so a binding never has to name the service's types, and these\n * three members are all this file touches — every reducer that reaches it was\n * built by the reduce service and keeps every other member intact through the\n * spread below.\n */\ninterface AliasReducer {\n readonly field?: string\n init(): unknown\n step(state: unknown, record: unknown): unknown\n remove?(state: unknown, record: unknown): unknown\n finalize(state: unknown): unknown\n}\ntype AliasSpec = Readonly<Record<string, AliasReducer>>\n\n/**\n * Re-aim a reducer at the sub-record under `alias`.\n *\n * The right side's pipeline rewrote the reducer for the BARE field name, so\n * its `step`/`remove` read `credit` off whatever record they are handed. On a\n * joined row that value lives at `row.client.credit`, so the row is unwrapped\n * one level on the way in rather than the field path being rewritten — the\n * rewritten reducer closes over its field name internally, so re-pointing the\n * `.field` property afterwards would change the label and not the read.\n *\n * An unmatched left row carries `null` under the alias; every reducer's read\n * already treats a nullish record as \"no value here\", so it contributes\n * nothing — the same thing a missing left-side field does.\n */\nfunction liftToAlias(alias: string, path: string, inner: AliasReducer): AliasReducer {\n const under = (record: unknown): unknown =>\n record === null || typeof record !== 'object' ? undefined : (record as Record<string, unknown>)[alias]\n return {\n ...inner,\n // The dotted path, so anything reading `.field` for a label or a\n // dependency still sees the field the CALLER named.\n field: path,\n init: () => inner.init(),\n step: (state, record) => inner.step(state, under(record)),\n ...(inner.remove ? { remove: (state: unknown, record: unknown) => inner.remove!(state, under(record)) } : {}),\n finalize: (state) => inner.finalize(state),\n }\n}\n\n/**\n * The binding: rewrite every reducer whose field is rooted at a join alias\n * through that alias's own collection pipeline, and leave everything else\n * exactly as it arrived.\n *\n * A reducer the right side does NOT rewrite (a plain `avg('client.score')`)\n * is returned untouched and keeps reading the dotted path off the joined row,\n * which is already correct — only a REWRITTEN reducer needs lifting, because\n * only a rewritten one has swapped to the bare name.\n */\nfunction joinAliasBinding(aliasVia: ReadonlyMap<string, ViaPipeline>): NoydbVia {\n return {\n brand: 'join-alias',\n posture: { encryptedAtRest: 'envelope', queryable: 'full', exportable: true, forgettable: true },\n // Claims no field: this binding must never shadow a left-side posture.\n covers: () => false,\n wrapReducers: (spec) => {\n let changed = false\n const out: Record<string, AliasReducer> = {}\n for (const [key, reducer] of Object.entries(spec as AliasSpec)) {\n const field = reducer.field\n const dot = field === undefined ? -1 : field.indexOf('.')\n const via = dot > 0 ? aliasVia.get(field!.slice(0, dot)) : undefined\n if (!via) { out[key] = reducer; continue }\n const bare = field!.slice(dot + 1)\n // One call: the right side's rewrite and its `queryable: 'none'`\n // refusal, both keyed by the bare name it actually declares.\n const wrapped = via.wrapReducers({ [key]: { ...reducer, field: bare } } as AliasSpec)[key]!\n if (wrapped === reducer || wrapped.field !== bare) { out[key] = reducer; continue }\n changed = true\n out[key] = liftToAlias(field!.slice(0, dot), field!, wrapped)\n }\n return changed ? out : spec\n },\n }\n}\n\n/**\n * The pipeline `aggregate()` / `groupBy()` should reduce THIS plan with: the\n * source's own, plus the alias binding when the plan can produce an alias.\n *\n * Returns the left pipeline unchanged when there is no alias to serve, so a\n * query with no joins — every query written before #1338 — is handed exactly\n * the object it was handed before.\n */\nexport function reduceViaFor(\n leftVia: ViaPipeline | undefined,\n aliasVia: ReadonlyMap<string, ViaPipeline> | undefined,\n): ViaPipeline | undefined {\n if (aliasVia === undefined || aliasVia.size === 0) return leftVia\n return ViaPipeline.build([...(leftVia?.bindings ?? []), joinAliasBinding(aliasVia)], leftVia?.taint)\n}\n\n/**\n * The other half, and the reason this one is not merely a missing feature:\n * a binding that REFUSES an aliased reducer instead of rewriting it.\n *\n * It is installed on the path where the legs do NOT run —\n * `groupBy('status').aggregate({ x: sum('client.credit') })`, a group key over\n * a left field with a reducer over an alias. `Query.aggregate()`'s guard never\n * saw that spec (the grouped terminal is `GroupedQuery.aggregate`, one object\n * along the chain), so it reduced `undefined` for every row and returned a\n * confident `0`. Group by the alias — then the legs run and the reducer is\n * rewritten by the branch above — or drop the grouping.\n */\nfunction refuseAliasBinding(aliases: ReadonlySet<string>): NoydbVia {\n return {\n brand: 'join-alias-refuse',\n posture: { encryptedAtRest: 'envelope', queryable: 'full', exportable: true, forgettable: true },\n covers: () => false,\n wrapReducers: (spec) => {\n for (const reducer of Object.values(spec as AliasSpec)) {\n const field = reducer.field\n if (field === undefined) continue\n const head = field.split('.')[0]!\n if (!aliases.has(head)) continue\n throw new Error(\n `Query.groupBy().aggregate(): reducer field \"${field}\" addresses the join alias ` +\n `\"${head}\", but the GROUP KEY does not — so the join legs are not applied for ` +\n `this grouping and the reducer would fold undefined into every bucket. ` +\n `Group by a field on \"${head}\" (then the legs run), or aggregate without ` +\n `grouping, where an aliased reducer is applied directly.`,\n )\n }\n return spec\n },\n }\n}\n\n/**\n * The pipeline for a grouped plan whose GROUP KEY stays on the left: the\n * source's own, plus the refusal above so an aliased reducer is a loud error\n * rather than a confident zero. No aliases in the plan → unchanged.\n */\nexport function refuseAliasReduceVia(\n leftVia: ViaPipeline | undefined,\n aliases: ReadonlySet<string>,\n): ViaPipeline | undefined {\n if (aliases.size === 0) return leftVia\n return ViaPipeline.build([...(leftVia?.bindings ?? []), refuseAliasBinding(aliases)], leftVia?.taint)\n}\n","/**\n * #1458 — **Reduce**: a fold over a result set.\n *\n * `aggregate` · `groupBy` · `window` · `distinct`\n *\n * Bodies moved out of `kernel/query/builder.ts` unchanged; see\n * `../relate/methods.ts` for why `this.plan` still resolves.\n *\n * ⚠️ This group depends on TWO others, and both edges are real rather than\n * tidyable:\n * - **Live**, for `incrementalMaintainer` — a live reduction maintains its\n * state through Live's maintainer (see `../internal/maintenance.ts`);\n * - **Relate**, for `reduceViaFor` / `refuseAliasReduceVia` — a reducer over\n * a JOIN ALIAS has to resolve the right side's Via pipeline, and refusing\n * it correctly is #1338's whole subject.\n * Neither is a layering accident: both are what \"reduce over a joined, live\n * result\" means.\n */\nimport type { DeclaredPredicate, InternalSource, QueryPlan } from '../builder.js'\n// @internal Find helpers. A reduce terminal narrows its record set through the\n// SAME executor the projection terminals use — sharing the functions is what\n// keeps \"which records does this terminal see\" one definition (#1347).\nimport { buildDictLabelResolver, candidateRecords, executeClausePipeline, filterRecords, fnViewDecoder } from '../builder.js'\nimport { readPath } from '../predicate.js'\nimport type { SourceChange } from '../live/incremental.js'\nimport type { QueryField } from '../../types.js'\nimport type { ViaPipeline } from '../../via/pipeline.js'\nimport type { JoinContext, JoinLeg } from '../relate/join.js'\nimport { reduceViaFor, refuseAliasReduceVia } from '../relate/join-reduce.js'\nimport type { DateTruncKey, GroupKey } from './date-trunc.js'\nimport { groupKeyName, isDateTruncKey, projectDateTruncKeys } from './date-trunc.js'\nimport { distinctKeyOf } from '../distinct-key.js'\nimport type { LiveMaintainer, GroupMaintenanceSource } from '../live/incremental.js'\nimport type { ReduceSpec, ReduceResult, ReductionUpstream, Reduction } from '../../../with-lookup/reduce/reduction.js'\nimport type { ReducerBuilder } from '../../../with-lookup/reduce/reducers.js'\nimport { bindDistinctReducers, reducerBuilder } from '../../../with-lookup/reduce/reducers.js'\nimport type { GroupedQuery, GroupedQueryN } from '../../../with-lookup/reduce/groupby.js'\nimport type { ReduceStrategy, WindowSpec, WindowedQuery } from '../../../with-lookup/reduce/strategy.js'\nimport { FieldNotQueryableError } from '../../errors.js'\n\nfunction assertNoJoinAliasField(\n fields: readonly string[],\n joins: readonly JoinLeg[],\n terminal: string,\n): void {\n if (joins.length === 0) return\n const aliases = new Set(joins.map(leg => leg.as))\n for (const field of fields) {\n const head = field.split('.')[0]!\n if (!aliases.has(head)) continue\n throw new Error(\n `Query.${terminal}(): field \"${field}\" addresses the join alias \"${head}\", but ` +\n `${terminal}() does not apply join legs — it would silently group every row ` +\n `under undefined. Joined aggregation is not supported. Either aggregate over ` +\n `the left collection's own fields, or use .crossJoin(\"${head}\", { as: … }), ` +\n `whose expansion IS visible to ${terminal}().`,\n )\n }\n}\n\n/** @internal — the mixin whose prototype `./index.ts` copies onto `Query`. */\n /* eslint-disable @typescript-eslint/no-unused-vars -- #1458: the parameter\n list must match `Query`'s exactly (T, S, Q, M) because `declare module`\n merges this mixin's `Pick` into it, and TypeScript requires every\n declaration of an interface to carry identical type parameters. A group\n whose methods happen to use only `T` still declares all four. */\nexport class ReduceMethods<\n T,\n S extends keyof T = never,\n Q extends keyof T & string = never,\n M extends keyof T & string = never,\n /* eslint-enable @typescript-eslint/no-unused-vars */\n> {\n declare protected readonly source: InternalSource\n declare protected readonly plan: QueryPlan\n declare protected readonly joinContext: JoinContext | undefined\n declare protected readonly reduceStrategy: ReduceStrategy\n declare protected readonly predicates: ReadonlyMap<string, DeclaredPredicate> | undefined\n declare protected matchedRecords: (terminal: string, forceJoins?: boolean) => readonly unknown[]\n declare protected decodeVia: (records: readonly unknown[], locale?: string) => unknown[]\n declare protected aliasVia: () => ReadonlyMap<string, ViaPipeline> | undefined\n declare protected incrementalMaintainer: (mode: 'rows' | 'records') => LiveMaintainer | undefined\n declare protected groupMaintenance: (derived: readonly DateTruncKey[]) => GroupMaintenanceSource | undefined\n declare toArray: (opts?: { locale?: string }) => T[]\n\n /**\n * The right-side change streams a joined query has to merge (#1338), deduped\n * by target the way `live()` does — a chain joining the same collection\n * twice must not double-fire. Extracted so a joined REDUCTION and a joined\n * live query cannot disagree on what \"the sources of this result\" means.\n */\n private rightSideUpstreams(): ReductionUpstream[] {\n const ctx = this.joinContext\n if (!ctx) return []\n const out: ReductionUpstream[] = []\n const seen = new Set<string>()\n for (const leg of this.plan.joins) {\n if (seen.has(leg.target)) continue\n seen.add(leg.target)\n const right = ctx.resolveSource(leg.target)\n if (!right?.subscribe) continue\n const subscribe = right.subscribe.bind(right)\n out.push({ subscribe: (cb: () => void) => subscribe(cb) })\n }\n return out\n }\n\n /**\n * Every alias this plan can produce, pipeline or not (#1338).\n *\n * `aliasVia()` above holds only the aliases whose collection compiles a Via\n * pipeline; refusal has to know about ALL of them, or an aliased reducer\n * over a plain right-side collection stays silent.\n */\n private aliasNames(): ReadonlySet<string> {\n const out = new Set<string>()\n for (const clause of this.plan.clauses) {\n if (clause.type !== 'crossJoin') continue\n out.add(clause.as)\n if (clause.leftAs !== undefined) out.add(clause.leftAs)\n }\n for (const leg of this.plan.joins) out.add(leg.as)\n return out\n }\n\n /** Is `field` rooted at an alias this plan produces? */\n\n private addressesAlias(field: string, aliases: ReadonlySet<string>): boolean {\n const dot = field.indexOf('.')\n return dot > 0 && aliases.has(field.slice(0, dot))\n }\n\n /**\n * The distinct values of `field` across the match set (#1347) — the\n * declarative form of `new Set(q.toArray().map(r => r[field]))`, which is\n * what consumers write today and which is wrong in two ways this is not.\n *\n * **Distinctness is decided on the canonical index key, not on the value\n * you get back.** For a Via-covered field that is the difference between a\n * right answer and a plausible one: money stores a scaled integer, and a\n * row written before the field was declared can spell it non-canonically\n * (`'0100'` for `'100'`). Deduping the stored strings reports two values\n * where there is one; deduping the FORMATTED strings makes the answer\n * depend on a locale this layer does not have (`'10.00'` vs `'10,00'`).\n * See `distinct-key.ts`. The values RETURNED are the decoded ones, so they\n * match what `toArray()` hands back for the same field.\n *\n * **Nullish values are excluded** — `null`/`undefined`/missing is the\n * absence of a value, not a distinct one. That is also the only choice\n * under which the index-backed and scanned paths can agree, since the hash\n * index does not hold nullish keys; see `distinctKeyOf`.\n *\n * Same match set as `count()`: where/filter apply, orderBy/limit/offset do\n * not. Values come back in first-encountered order.\n *\n * ⭐ INDEX-BACKED when the field carries a hash index AND the plan narrows\n * nothing — the buckets ARE the distinct key set, so the answer costs\n * O(distinct values) instead of O(records) and never decrypts a snapshot.\n * The guard is deliberately all-or-nothing: with a where clause the whole\n * collection's buckets are not the answer, and intersecting a candidate id\n * set with every bucket would cost more than the scan it replaced.\n *\n * ⛔ THE RETURN TYPE IS `(T & Record<F, unknown>)[F][]`, NOT\n * `F extends keyof T ? T[F][] : unknown[]` — and it must stay that way. The\n * conditional form reads better and type-checks at every call site, but a\n * DEFERRED conditional over `T` makes TypeScript give up relating\n * `Query<T>` to `Query<unknown>`, which makes `Collection<T>` invariant in\n * `T`, which breaks `vault.ts`'s `Map<string, Collection<unknown>>` cache\n * with four errors that name neither this method nor this file. The\n * intersection form resolves to the same thing (`T[F]` for a literal key,\n * `unknown` for a `string`-typed one) and stays covariant.\n */\n distinct<F extends QueryField<T, S>>(field: F): (T & Record<F, unknown>)[F][] {\n const name = field as string\n assertNoJoinAliasField([name], this.plan.joins, 'distinct')\n const via = this.source.via\n // Same posture gate `.where()` / `.orderBy()` apply: a `queryable: 'none'`\n // field (a blob handle) must not have its value set enumerated either.\n if (via?.postureFor(name)?.queryable === 'none') throw new FieldNotQueryableError(name)\n const decode = via?.hasResultDecode ? (r: unknown) => via.decodeResults(r) : (r: unknown) => r\n\n const indexes =\n this.plan.clauses.length === 0 && this.plan.joins.length === 0\n ? this.source.getIndexes?.()\n : undefined\n if (indexes && this.source.lookupById) {\n const lookupById = (id: string): unknown => this.source.lookupById?.(id)\n const reps = indexes.bucketRepresentatives(name)\n if (reps) {\n const fromIndex: unknown[] = []\n for (const id of reps) {\n const record = lookupById(id)\n if (record === undefined) continue\n fromIndex.push(readPath(decode(record), name))\n }\n return fromIndex as (T & Record<F, unknown>)[F][]\n }\n }\n\n const seen = new Set<string>()\n const out: unknown[] = []\n for (const record of this.matchedRecords('distinct')) {\n const key = distinctKeyOf(name, readPath(record, name), via)\n if (key === undefined || seen.has(key)) continue\n seen.add(key)\n out.push(readPath(decode(record), name))\n }\n return out as (T & Record<F, unknown>)[F][]\n }\n\n /**\n * Reduce the matching records through a named set of reducers.\n * the aggregation terminal.\n *\n * ```ts\n * const { total, n, avgAmount } = invoices.query()\n * .where('status', '==', 'open')\n * .aggregate({\n * total: sum('amount'),\n * n: count(),\n * avgAmount: avg('amount'),\n * })\n * .run()\n * ```\n *\n * Returns an `Reduction<R>` wrapper with two terminals:\n * - `.run(): R` — synchronous one-shot reduction\n * - `.live(): LiveReduction<R>` — reactive primitive that\n * re-runs the reduction whenever the source notifies of a\n * change. Always call `live.stop()` when finished.\n *\n * The reducer spec is bound here once and reused by both\n * terminals — this is why `.aggregate()` returns a wrapper instead\n * of being a direct terminal. Consumers who only need the static\n * value read `.run()`; consumers wiring a reactive UI read\n * `.live()`.\n *\n * Joins are NOT applied by default — the same logic as `.count()`. A leg is\n * projection-only, so running one just to throw the alias away would be\n * wasteful. ⭐ **The exception is a reducer that ADDRESSES an alias**\n * (#1338): then the joined relation IS what is being reduced, so the legs\n * run and the reducer is rewritten by the right collection's own Via\n * pipeline — money stays exact, and the right side's `queryable: 'none'`\n * posture refuses a field it would refuse locally. A live joined\n * aggregation also merges every right-side change stream, so it does not\n * quietly stop updating when the right side moves.\n *\n * Every reducer factory accepts an optional `{ seed }` parameter\n * that is plumbed through the protocol but unused by the\n * executor — that's constraint #2. When partition-aware\n * aggregation lands, the seed will carry running state across\n * partition boundaries without an API break.\n *\n * KNOWN GAP (sealed fields, bare-spec form): `where`/`orderBy`/`groupBy`\n * refuse a `sensitive` field at compile time, but a reducer over a sensitive\n * field in the BARE-SPEC form (e.g. `aggregate({ x: sum('ssn') })`) is NOT\n * refused — the reducer factories (`sum`/`min`/`max`/…) are standalone\n * `(field: string)` functions with no collection-type context. This form is\n * preserved as-is for backward compatibility.\n *\n * The BUILDER form closes this gap: `aggregate(b => ({ x: b.sum('field') }))`\n * types the builder's field parameter as `QueryField<T, S>`, refusing any\n * `sensitive` field at compile time. Use the builder form for new code that\n * aggregates over a collection with sensitive fields.\n *\n */\n aggregate<Spec extends ReduceSpec>(spec: Spec): Reduction<ReduceResult<Spec>>\n aggregate<Spec extends ReduceSpec>(build: (b: ReducerBuilder<T, S, M>) => Spec): Reduction<ReduceResult<Spec>>\n aggregate<Spec extends ReduceSpec>(\n specOrBuild: Spec | ((b: ReducerBuilder<T, S, M>) => Spec),\n ): Reduction<ReduceResult<Spec>> {\n let spec = typeof specOrBuild === 'function'\n ? (specOrBuild as (b: ReducerBuilder<T, S, M>) => Spec)((reducerBuilder as unknown) as ReducerBuilder<T, S, M>)\n : specOrBuild\n // #1338 — a reducer over a joined alias used to be refused here. It now\n // routes: the legs run (so the reducer sees the joined relation) and the\n // spec is wrapped by a pipeline that delegates each aliased field to the\n // RIGHT collection's own — which carries money's exact-BigInt rewrite and\n // the `queryable: 'none'` posture gate together. Reducers without a field\n // (e.g. `count()`) address nothing and are unaffected.\n const aliases = this.aliasNames()\n const aliasedReducer =\n this.plan.joins.length > 0 &&\n Object.values(spec).some(r => {\n const f = (r as { field?: unknown }).field\n return typeof f === 'string' && this.addressesAlias(f, aliases)\n })\n // Rewrite sum/min/max over Via-covered fields (e.g. money) into exact\n // BigInt reducers before the strategy runs (covers static run() and\n // live/MV paths).\n spec = (aliasedReducer ? reduceViaFor(this.source.via, this.aliasVia()) : this.source.via)?.wrapReducers(spec) ?? spec\n // #1347 — `countDistinct` needs the SAME canonicalizer the hash index\n // buckets by, and only the source knows it. Bound here, beside the\n // money rewrite, so both spec-wrapping seams stay in one place.\n spec = bindDistinctReducers(spec, this.source.via)\n // Closure over the current query. Produces the record set that\n // the aggregation reduces — same pipeline as `count()`, skipping\n // limit/offset because aggregation is over the full match set,\n // not a paginated slice. (A paginated aggregation would be a\n // different operation; see docs for rationale.)\n const source = this.source\n const clauses = this.plan.clauses\n const joinCtx = this.joinContext\n const hasCrossJoins = clauses.some(c => c.type === 'crossJoin')\n const fullScan = aliasedReducer\n // The reduced relation IS the joined one — same pipeline `count()` uses,\n // with the legs forced on (#1338).\n ? (): readonly unknown[] => this.matchedRecords('aggregate', true)\n : (): readonly unknown[] => {\n if (hasCrossJoins) {\n if (!joinCtx) throw new Error('Query.aggregate(): crossJoin requires a join context')\n return executeClausePipeline(source, clauses, joinCtx)\n }\n const { candidates, remainingClauses } = candidateRecords(source, clauses)\n return remainingClauses.length === 0\n ? candidates\n : filterRecords(candidates, remainingClauses, fnViewDecoder(source))\n }\n\n // #1341 — when the plan admits it, the match set is MAINTAINED across\n // change events instead of re-scanned, so a live reduction folds over an\n // incrementally-patched array. The reducers themselves still run a full\n // fold: the array they see is byte-for-byte the one a re-scan would\n // produce (same records, same candidate order), so an incremental result\n // is not merely close to a re-run's — it is the identical computation.\n const maintainer = this.incrementalMaintainer('records')\n const executeRecords = maintainer ? (): readonly unknown[] => maintainer.rows() : fullScan\n\n // Upstream for live mode. The left source always subscribes; a joined\n // aggregation ALSO merges every right-side change stream (#1338) — the\n // refusal's own doc named a live joined aggregate that silently stops\n // updating as half the work, and it is this half.\n const upstreams: ReductionUpstream[] = []\n if (aliasedReducer) upstreams.push(...this.rightSideUpstreams())\n if (source.subscribe) {\n const subscribe = source.subscribe.bind(source)\n upstreams.push(\n maintainer\n ? {\n // The maintainer folds the delta in BEFORE the reduction reads,\n // which is why it is wrapped here rather than subscribed\n // separately — emitter callback order would otherwise decide\n // whether the reduction saw the new record.\n subscribe: (cb: () => void) => {\n maintainer.attach()\n const unsubscribe = subscribe(change => {\n // A predicate that throws must not escape into the emitter —\n // the maintainer drops its state and the reduction's own\n // re-run raises the same error where it can be caught.\n try {\n maintainer.apply(change)\n } catch {\n maintainer.invalidate()\n }\n cb()\n })\n // Detach on teardown: the Reduction survives its LiveReduction\n // (`.run()` reuses the same closure), and a maintainer with no\n // subscription feeding it would go quietly out of date.\n return () => {\n maintainer.detach()\n unsubscribe()\n }\n },\n }\n : { subscribe: (cb: () => void) => subscribe(cb) },\n )\n }\n\n // #1414 — the gate travels INTO the reduction rather than wrapping it.\n // `Reduction.run()` is the synchronous terminal, and `await …aggregate(\n // spec).run()` is what an async guard's Σ-over-siblings invariant writes;\n // gating the builder call instead would break that awaited form.\n return this.reduceStrategy.aggregate<Spec>(executeRecords, spec, upstreams, this.source.hydration)\n }\n\n /**\n * Partition matching records into buckets keyed by a field, then\n * terminate with `.aggregate(spec)` to compute per-bucket\n * reducers..\n *\n * ```ts\n * const byClient = invoices.query()\n * .where('status', '==', 'open')\n * .groupBy('clientId')\n * .aggregate({ total: sum('amount'), n: count() })\n * .run()\n * // → [ { clientId: 'c1', total: 5250, n: 3 }, … ]\n * ```\n *\n * Result rows carry the group key value under the grouping field\n * name plus every reducer output from the spec. Buckets are\n * emitted in first-seen order — consumers who want a specific\n * ordering should `.sort()` downstream.\n *\n * **Cardinality caps:** a one-shot warning fires at 10_000\n * distinct groups; `GroupCardinalityError` throws at 100_000.\n * Grouping on a high-uniqueness field like `id` or `createdAt` is\n * almost always a query mistake — the error message names the\n * field and observed cardinality and suggests narrowing with\n * `.where()` first.\n *\n * **Null / undefined keys:** records with a missing or explicitly\n * `null` group field get their own buckets. `Map`-based\n * partitioning distinguishes `undefined` from `null`, so the two\n * cases do NOT merge. Consumers who want them merged should\n * coalesce upstream with `.filter()`.\n *\n * **Joins are not applied unless the GROUP KEY addresses an alias** (#1338).\n * For a left-side key the old rationale still holds — a leg is\n * projection-only, so running one inside a grouping pipeline would be\n * wasteful and could trigger `DanglingReferenceError` in strict mode for a\n * call whose intent is purely to bucket-and-reduce. For an aliased key\n * (`groupBy('client.region')`, the accounting-report shape) the legs run and\n * the buckets are the joined relation's: the key is stamped under its DOTTED\n * path (`row['client.region']`), and a left row whose right side is absent\n * reads `undefined` and lands in the undefined bucket — the same bucket a\n * missing left-side key gets, and still distinct from an explicit `null`.\n *\n * ⚠️ The decision is taken from the KEY, because the reducer spec arrives a\n * call later. A reducer over an alias under a LEFT key is therefore REFUSED\n * rather than folded as `undefined` — group by the alias, or aggregate\n * without grouping.\n *\n * **Filter clauses (`.filter(fn)`):** grouped queries still\n * support filter clauses in the underlying plan — they run in\n * the same candidate/filter pipeline that `.aggregate()` uses.\n * The performance caveat is the same: filter clauses cost O(N)\n * per record and can't be index-accelerated.\n */\n // The `field` param is `QueryField<T, S>` so a sealed (`sensitive`) field is\n // refused — grouping BY a sensitive field leaks its value distribution as\n // group-key labels. With `S = never` this is exactly `string` (zero churn).\n\n groupBy<F extends QueryField<T, S>>(field: F): GroupedQuery<T, F, S, M>\n groupBy<F extends readonly [QueryField<T, S>, QueryField<T, S>, ...QueryField<T, S>[]]>(\n ...fields: F\n ): GroupedQueryN<T, F, S, M>\n // Derived calendar keys (#1350). Listed last so the two field-name overloads\n // above still win for plain string arguments — a `DateTruncKey` is an object\n // and matches neither, so nothing existing re-resolves onto these.\n groupBy(key: DateTruncKey): GroupedQuery<T, string, S, M>\n // The string members stay `QueryField<T, S>`, so the sealed-field refusal\n // still applies to every plain key in a mixed grouping.\n groupBy(\n ...keys: readonly [\n QueryField<T, S> | DateTruncKey,\n QueryField<T, S> | DateTruncKey,\n ...(QueryField<T, S> | DateTruncKey)[],\n ]\n ): GroupedQueryN<T, readonly string[], S, M>\n groupBy(...keys: readonly GroupKey[]): GroupedQuery<T, string, S, M> | GroupedQueryN<T, readonly string[], S, M> {\n if (keys.length === 0) {\n throw new Error('.groupBy() requires at least one field')\n }\n // A derived key is bucketed into an ordinary row field before the grouping\n // pipeline runs, so everything downstream — cardinality caps, null/undefined\n // bucket semantics, live re-grouping — keeps working unchanged.\n const derived = keys.filter(isDateTruncKey)\n const fields: readonly string[] = keys.map(groupKeyName)\n // #1338 — a group key addressing an alias used to be refused. It now\n // decides the shape of the whole grouped pipeline: the legs run, and the\n // reducers are wrapped through the right side's pipeline.\n //\n // ⚠️ The decision is made HERE, from the group KEY alone, because the\n // reducer spec does not exist yet — it arrives one call later, at\n // `.aggregate()`. That is exactly why the left-key case installs a\n // REFUSING binding rather than nothing: a reducer over an alias under a\n // left-side key would otherwise fold undefined into every bucket, and the\n // grouped terminal is not the one `Query.aggregate()`'s guard sees.\n const aliases = this.aliasNames()\n const keyIsAliased = this.plan.joins.length > 0 && fields.some(f => this.addressesAlias(f, aliases))\n // Same record-producing closure as .aggregate() — grouped and\n // non-grouped aggregations execute over the same candidate set.\n // We inline the closure here instead of sharing a helper so the\n // builder stays allocation-friendly for the hot path.\n const source = this.source\n const clauses = this.plan.clauses\n const joinCtx = this.joinContext\n const hasCrossJoins = clauses.some(c => c.type === 'crossJoin')\n const executeRecords = keyIsAliased\n ? (): readonly unknown[] => this.matchedRecords('groupBy', true)\n : (): readonly unknown[] => {\n if (hasCrossJoins) {\n if (!joinCtx) throw new Error('Query.groupBy(): crossJoin requires a join context')\n return executeClausePipeline(source, clauses, joinCtx)\n }\n const { candidates, remainingClauses } = candidateRecords(source, clauses)\n return remainingClauses.length === 0\n ? candidates\n : filterRecords(candidates, remainingClauses, fnViewDecoder(source))\n }\n const executeGroupRecords = derived.length === 0\n ? executeRecords\n : (): readonly unknown[] => projectDateTruncKeys(executeRecords(), derived)\n\n // #1341 (grouped half) — the upstream passes the DELTA through, not just a\n // \"something changed\" ping, so `GroupedReduction.live()` can patch the one\n // or two buckets a change touches instead of re-grouping everything. A cb\n // that ignores the argument (every pre-#1341 caller) is unaffected.\n const upstreams: ReductionUpstream[] = []\n if (source.subscribe) {\n const subscribe = source.subscribe.bind(source)\n upstreams.push({ subscribe: (cb: (change?: SourceChange) => void) => subscribe(cb) })\n }\n if (keyIsAliased) upstreams.push(...this.rightSideUpstreams())\n // Withheld for a plan the whitelist refuses, and for an aliased key (which\n // implies joins, which the whitelist refuses anyway) — `.live()` then\n // re-runs the whole grouping, exactly as it did before.\n const maintenance = keyIsAliased ? undefined : this.groupMaintenance(derived)\n\n // The pipeline the reducers are wrapped with: the right side's rewrite\n // when the legs run, the refusal when they do not (#1338).\n const reduceVia = keyIsAliased\n ? reduceViaFor(this.source.via, this.aliasVia())\n : refuseAliasReduceVia(this.source.via, aliases)\n\n // Dict-label resolution is single-field only — the <field>Label\n // projection has no meaningful shape for composite keys. A derived\n // calendar key is never a dictKey, so it skips the lookup entirely.\n if (fields.length === 1) {\n const field = fields[0]!\n const dictLabelResolver = derived.length > 0\n ? undefined\n : buildDictLabelResolver(this.joinContext, field)\n return this.reduceStrategy.groupBy<T, string, S, M>(\n executeGroupRecords,\n field,\n upstreams,\n dictLabelResolver,\n reduceVia,\n maintenance,\n )\n }\n return this.reduceStrategy.groupByN<T, readonly string[], S, M>(\n executeGroupRecords,\n fields,\n upstreams,\n reduceVia,\n maintenance,\n )\n }\n\n /**\n * SQL window functions over the query's result rows (#1349) — terminate with\n * `.select(spec)`.\n *\n * ```ts\n * invoices.query()\n * .where('status', '==', 'open')\n * .window({ partitionBy: 'clientId', orderBy: 'date' })\n * .select({ balance: runningSum('amount'), prev: lag('amount', 1), n: rowNumber() })\n * .run()\n * ```\n *\n * ⭐ Distinguished from `.groupBy()` by ARITY, not by capability: grouping\n * emits one row per bucket and drops the source rows; a window keeps EVERY\n * row and attaches per-row values computed over its partition.\n *\n * **The record set is `toArray()`'s** — the full pipeline, including joins,\n * `orderBy`, `offset`/`limit` and the Via decode. That differs deliberately\n * from `.groupBy()`, which reads the candidate/filter pipeline only: a\n * window returns ROWS, so the query's own ordering and paging are exactly\n * what decides which rows there are and how they are presented. `orderBy`\n * inside the window decides only how a partition is WALKED.\n *\n * **Frame:** `rows unbounded preceding → current row`, and only that in v1.\n *\n * `partitionBy` / `orderBy` accept a `dateTrunc()` key (#1350) alongside\n * plain field names; the derived bucket is used for partitioning and is not\n * stamped on the output row. A sealed (`sensitive`) field is refused at\n * compile time, same as `.groupBy()`.\n *\n * ⛔ **Not an `explain()` node.** `explain()` is a terminal on `Query`;\n * `.window()` leaves `Query` for `WindowedQuery`, so there is nothing past\n * here to add a node to — the same reason #1336's post-group ops are absent.\n */\n window(spec: WindowSpec<QueryField<T, S>>): WindowedQuery<T> {\n const upstreams: ReductionUpstream[] = []\n if (this.source.subscribe) {\n const subscribe = this.source.subscribe.bind(this.source)\n upstreams.push({ subscribe: (cb: () => void) => subscribe(cb) })\n }\n return this.reduceStrategy.window<T>(\n () => this.toArray() as readonly unknown[],\n spec as WindowSpec,\n upstreams,\n this.source.via,\n )\n }\n}\n\n/** The public Reduce surface — merged into `Query` by `./index.ts`. */\nexport type ReduceSurface<\n T,\n S extends keyof T = never,\n Q extends keyof T & string = never,\n M extends keyof T & string = never,\n> = Pick<ReduceMethods<T, S, Q, M>, 'aggregate' | 'groupBy' | 'window' | 'distinct'>\n\n","/**\n * #1458 — the **Reduce** half of `ScanBuilder`.\n *\n * `aggregate` · `groupBy` · the grouped-scan handle they return.\n *\n * See `../relate/scan-methods.ts` for why `ScanBuilder` is split at all.\n *\n * ⭐ **The streaming memory property travels with the code.**\n * `scan().aggregate()` is O(reducers), not O(records) — it steps every reducer\n * per record and never collects the stream — and `groupBy().aggregate()` is\n * O(groups). That is a code-level invariant visible in the bodies below, so\n * moving them wholesale is what preserves it; re-expressing them over the\n * eager reducers would have quietly turned an unbounded scan into an array.\n */\nimport type { MultiReduceResult, ScanPageProvider } from '../scan-builder.js'\nimport type { QueryField } from '../../types.js'\nimport type { Clause } from '../predicate.js'\nimport { readPath } from '../predicate.js'\nimport type { ViaPipeline } from '../../via/pipeline.js'\nimport type { JoinContext, JoinLeg } from '../relate/join.js'\nimport type { ReducerBuilder } from '../../../with-lookup/reduce/reducers.js'\nimport { bindDistinctReducers, reducerBuilder } from '../../../with-lookup/reduce/reducers.js'\nimport type { ReduceSpec, ReduceResult } from '../../../with-lookup/reduce/reduction.js'\nimport type { DateTruncKey } from './date-trunc.js'\nimport { groupKeyName, isDateTruncKey, projectDateTruncKeys } from './date-trunc.js'\nimport { GroupCardinalityError } from '../../errors.js'\n\n/** @internal — the mixin whose prototype `./index.ts` copies onto `ScanBuilder`. */\nexport class ScanReduceMethods<T, S extends keyof T = never, M extends keyof T & string = never> {\n declare protected readonly pageProvider: ScanPageProvider<T>\n declare protected readonly pageSize: number\n declare protected readonly clauses: readonly Clause[]\n declare protected readonly joins: readonly JoinLeg[]\n declare protected readonly joinContext: JoinContext | undefined\n declare protected readonly via: ViaPipeline | undefined\n declare protected decodeVia: (record: T) => T\n declare protected recordMatches: (record: T, clauses?: readonly Clause[]) => boolean\n declare [Symbol.asyncIterator]: () => AsyncIterator<T>\n\n async aggregate<const Specs extends readonly ReduceSpec[]>(specs: Specs): Promise<MultiReduceResult<Specs>>\n async aggregate<Spec extends ReduceSpec>(spec: Spec): Promise<ReduceResult<Spec>>\n async aggregate<Spec extends ReduceSpec>(build: (b: ReducerBuilder<T, S, M>) => Spec): Promise<ReduceResult<Spec>>\n async aggregate<Spec extends ReduceSpec>(\n specOrBuild: Spec | readonly ReduceSpec[] | ((b: ReducerBuilder<T, S, M>) => Spec),\n ): Promise<ReduceResult<Spec> | unknown[]> {\n // #1340 — the multi-spec form. N independent specs, ONE pass: the states\n // for every spec are stepped from the same yielded record, so the page\n // provider is walked exactly once no matter how many specs are passed.\n // (Calling `.aggregate(specA)` then `.aggregate(specB)` costs two full\n // scans — the immutable-builder docs above say so, and this is the fix.)\n if (Array.isArray(specOrBuild)) return this.aggregateMany(specOrBuild as readonly ReduceSpec[])\n // Opt-in builder form `aggregate(b => spec)`: `b`'s field args are\n // `QueryField<T, S>`, refusing sensitive fields (the standalone-spec form\n // stays unrefused for back-compat), and `sum`/`min`/`max` over a declared\n // `moneyFields` (`M`) member return a `MoneyString`. Mirrors `Query.aggregate`.\n const spec: Spec = typeof specOrBuild === 'function'\n ? (specOrBuild as (b: ReducerBuilder<T, S, M>) => Spec)(reducerBuilder as unknown as ReducerBuilder<T, S, M>)\n // `Array.isArray` above does not narrow a READONLY array out of the\n // union, so the array arm is already returned and this cast is the\n // remainder — a plain spec.\n : (specOrBuild as Spec)\n this.via?.refuseUnqueryableReducers(spec)\n const keys = Object.keys(spec)\n // Per-reducer state. Exactly |keys| entries, never grows with\n // the record count — that's the O(reducers) memory guarantee.\n const state: Record<string, unknown> = {}\n for (const key of keys) {\n state[key] = spec[key]!.init()\n }\n\n // Record-by-record streaming step. `for await (… of this)`\n // invokes the Symbol.asyncIterator above, which honors the\n // clause list, so filtered-out records never reach the step\n // loop — they're dropped at the iterator boundary.\n for await (const record of this) {\n for (const key of keys) {\n state[key] = spec[key]!.step(state[key], record)\n }\n }\n\n const result: Record<string, unknown> = {}\n for (const key of keys) {\n result[key] = spec[key]!.finalize(state[key])\n }\n return result as ReduceResult<Spec>\n }\n\n /**\n * The multi-spec `.aggregate([specA, specB, …])` executor (#1340).\n *\n * One iteration of the scan, `Σ|spec|` reducer states — memory stays\n * O(reducers) exactly as the single-spec terminal's does, with the sum taken\n * across specs instead of within one. Every spec's state is stepped from the\n * SAME yielded record, so the page provider is read once per page.\n *\n * Semantics per spec are identical to the single-spec form, deliberately:\n * the posture gate is `refuseUnqueryableReducers` (metadata only), NOT the\n * full `wrapReducers` — so `aggregate([a, b])` returns exactly what\n * `aggregate(a)` and `aggregate(b)` return, and the array form is a pure\n * cost optimisation with no behavioural delta to reason about. (The grouped\n * scan path DOES wrap — it has to agree with the eager grouped path, which\n * wraps. See `scan-groupby.ts`.)\n */\n private async aggregateMany(specs: readonly ReduceSpec[]): Promise<unknown[]> {\n for (const spec of specs) this.via?.refuseUnqueryableReducers(spec)\n const keysPerSpec = specs.map((spec) => Object.keys(spec))\n const states: Record<string, unknown>[] = specs.map((spec, i) => {\n const state: Record<string, unknown> = {}\n for (const key of keysPerSpec[i]!) state[key] = spec[key]!.init()\n return state\n })\n\n for await (const record of this) {\n for (let i = 0; i < specs.length; i++) {\n const spec = specs[i]!\n const state = states[i]!\n for (const key of keysPerSpec[i]!) state[key] = spec[key]!.step(state[key], record)\n }\n }\n\n return specs.map((spec, i) => {\n const result: Record<string, unknown> = {}\n for (const key of keysPerSpec[i]!) result[key] = spec[key]!.finalize(states[i]![key])\n return result\n })\n }\n\n /**\n * Group the scan stream and reduce each group — `#1340`.\n *\n * ```ts\n * const byClient = await invoices.scan()\n * .where('status', '==', 'open')\n * .groupBy('clientId', { maxGroups: 5_000 })\n * .aggregate({ total: sum('amount'), n: count() })\n * ```\n *\n * ⚠️ **This is the one scan terminal whose memory is NOT O(pageSize).** It\n * holds one reducer state per group, which is why the budget is explicit:\n * `maxGroups` defaults to the eager path's 100_000-group ceiling and is\n * REFUSED — never truncated — the moment a scan would exceed it. Price the\n * budget before raising it: an exact `median`/`percentile`, a `mode` or a\n * `countDistinct` holds O(values) per group, so an unbounded scan wants\n * `{ approx: true }` on the quantiles. Full rationale in `scan-groupby.ts`.\n *\n * The key may be a field name or a `dateTrunc()` derived calendar key (the\n * monthly-rollup shape); grouping BY a `sensitive` field is refused at\n * compile time, same as `Query.groupBy()`.\n */\n groupBy<F extends QueryField<T, S>>(field: F, opts?: { maxGroups?: number }): ScanGroupedScan<T, F, S, M>\n groupBy(key: DateTruncKey, opts?: { maxGroups?: number }): ScanGroupedScan<T, string, S, M>\n groupBy(key: QueryField<T, S> | DateTruncKey, opts?: { maxGroups?: number }): ScanGroupedScan<T, string, S, M> {\n return new ScanGroupedScan<T, string, S, M>(\n this,\n key as string | DateTruncKey,\n opts?.maxGroups ?? SCAN_GROUPBY_DEFAULT_MAX_GROUPS,\n this.via,\n )\n }\n}\n\n/** The public Reduce surface of `ScanBuilder` — merged by `./index.ts`. */\nexport type ScanReduceSurface<\n T,\n S extends keyof T = never,\n M extends keyof T & string = never,\n> = Pick<ScanReduceMethods<T, S, M>, 'aggregate' | 'groupBy'>\n\n/**\n * Default group ceiling — the same constant the eager `.groupBy()` enforces.\n * Duplicated as a literal rather than imported from\n * `with-lookup/reduce/groupby.ts` on purpose: that module carries the eager\n * `groupAndReduce` + `GroupedReduction` classes, and the always-on kernel must\n * not pull them in to read one number. The pairing is asserted by a test.\n */\nexport const SCAN_GROUPBY_DEFAULT_MAX_GROUPS = 100_000\n\n/**\n * Single-field spelling of `canonicalGroupKey` (`with-lookup/reduce/canonical-key.ts`).\n *\n * ⛔ Inlined, not imported, and not by preference: `check-architecture`'s\n * `port-layering` rule grandfathers this file for exactly two\n * `with-lookup/reduce/*` specifiers (`reducers.js`, `reduction.js`), and\n * `canonical-key.js` is not one of them — a new one may not be added\n * silently. The eager helper sorts its field list and serialises\n * each value — with exactly one field, that reduces to this line, including\n * the part that matters: `undefined` gets a sentinel so a MISSING key and an\n * explicit `null` land in different buckets, as they do under\n * `Query.groupBy()`. The agreement is held by test, not by comment\n * (`query-scan-groupby.test.ts` — null/undefined bucketing, and full equality\n * with the eager path).\n */\nfunction scanGroupKey(field: string, value: unknown): string {\n return `${field}=${value === undefined ? 'undefined' : JSON.stringify(value)}`\n}\n\n/** Group-key result-row shape: the key under its own name, plus the reducers. */\n\nexport type ScanGroupedRow<F extends string, R> = { [K in F]: unknown } & R\n\n/**\n * Chainable wrapper returned by `ScanBuilder.groupBy()`. The only operation on\n * it is `.aggregate()` — same minimal shape as `GroupedQuery`.\n */\nexport class ScanGroupedScan<\n T,\n F extends string,\n S extends keyof T = never,\n M extends keyof T & string = never,\n> {\n constructor(\n private readonly stream: AsyncIterable<T>,\n private readonly key: string | DateTruncKey,\n private readonly maxGroups: number,\n private readonly via: ViaPipeline | undefined,\n ) {\n if (!Number.isInteger(maxGroups) || maxGroups < 1) {\n throw new Error(\n `scan().groupBy(): { maxGroups: ${String(maxGroups)} } must be a positive integer — ` +\n `it is the declared ceiling on how many reducer states the grouped scan may hold.`,\n )\n }\n }\n\n /**\n * Fold the scan into one row per group. Resolves to `R[]`, ordered by each\n * group's FIRST-SEEN position in the stream (`Map` insertion order), which\n * is the same ordering rule the eager path documents.\n *\n * ```ts\n * const byMonth = await invoices.scan()\n * .where('status', '==', 'paid')\n * .groupBy(dateTrunc('closedAt', 'month', { as: 'month', timeZone: 'UTC' }), { maxGroups: 240 })\n * .aggregate({ total: sum('amount'), n: count() })\n * ```\n */\n async aggregate<Spec extends ReduceSpec>(spec: Spec): Promise<ScanGroupedRow<F, ReduceResult<Spec>>[]>\n async aggregate<Spec extends ReduceSpec>(\n build: (b: ReducerBuilder<T, S, M>) => Spec,\n ): Promise<ScanGroupedRow<F, ReduceResult<Spec>>[]>\n async aggregate<Spec extends ReduceSpec>(\n specOrBuild: Spec | ((b: ReducerBuilder<T, S, M>) => Spec),\n ): Promise<ScanGroupedRow<F, ReduceResult<Spec>>[]> {\n const raw: Spec =\n typeof specOrBuild === 'function'\n ? (specOrBuild as (b: ReducerBuilder<T, S, M>) => Spec)(reducerBuilder as unknown as ReducerBuilder<T, S, M>)\n : specOrBuild\n // Same reducer rewriting as the eager grouped path, and for the same\n // reason: a money `sum` must accumulate per-currency BigInt totals, and a\n // `countDistinct` must dedup on the canonical index key — otherwise a\n // grouped scan and a grouped query disagree on identical data.\n // `wrapReducers` runs the `queryable: 'none'` posture refusal itself.\n const spec: ReduceSpec = bindDistinctReducers(this.via ? this.via.wrapReducers(raw) : raw, this.via)\n const keys = Object.keys(spec)\n\n const field = groupKeyName(this.key)\n const derived: readonly DateTruncKey[] = isDateTruncKey(this.key) ? [this.key] : []\n const groups = new Map<string, { keyValue: unknown; state: Record<string, unknown> }>()\n\n for await (const record of this.stream) {\n // A derived calendar key is stamped onto a shallow copy before bucketing\n // — the reducers then see an ordinary row carrying an ordinary field,\n // exactly as they do under `Query.groupBy(dateTrunc(...))`.\n const row = derived.length === 0 ? record : projectDateTruncKeys([record], derived)[0]!\n const keyValue = readPath(row, field)\n const dedupKey = scanGroupKey(field, keyValue)\n let group = groups.get(dedupKey)\n if (group === undefined) {\n if (groups.size >= this.maxGroups) {\n // Loud and early: the state for this group is never allocated, so\n // the refusal fires at the budget, not after blowing through it.\n throw new GroupCardinalityError(field, groups.size + 1, this.maxGroups, 'scan')\n }\n const state: Record<string, unknown> = {}\n for (const k of keys) state[k] = spec[k]!.init()\n group = { keyValue, state }\n groups.set(dedupKey, group)\n }\n for (const k of keys) group.state[k] = spec[k]!.step(group.state[k], row)\n }\n\n const out: ScanGroupedRow<F, ReduceResult<Spec>>[] = []\n for (const group of groups.values()) {\n // Group key first, then the reducer outputs — same row shape as the\n // eager path, which tests assert by key order.\n const outRow: Record<string, unknown> = { [field]: group.keyValue }\n for (const k of keys) outRow[k] = spec[k]!.finalize(group.state[k])\n out.push(outRow as ScanGroupedRow<F, ReduceResult<Spec>>)\n }\n return out\n }\n}\n","/**\n * #1458 — the Reduce install. See `../relate/install.ts` for why this is a\n * function called from the entry rather than a module-level side effect.\n */\nimport { Query } from '../builder.js'\nimport { ScanBuilder } from '../scan-builder.js'\nimport { installMethods } from '../internal/core.js'\nimport { MaintenanceMethods } from '../internal/maintenance.js'\nimport { ReduceMethods } from './methods.js'\nimport { ScanReduceMethods } from './scan-methods.js'\n\nlet done = false\n\n/** Idempotent: the root barrel and the subpath entry both call it. */\nexport function installReduce(): void {\n if (done) return\n done = true\n installMethods(Query.prototype, MaintenanceMethods)\n installMethods(Query.prototype, ReduceMethods)\n installMethods(ScanBuilder.prototype, ScanReduceMethods)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqEA,SAAS,YAAY,OAAe,MAAc,OAAmC;AACnF,QAAM,QAAQ,CAAC,WACb,WAAW,QAAQ,OAAO,WAAW,WAAW,SAAa,OAAmC,KAAK;AACvG,SAAO;AAAA,IACL,GAAG;AAAA;AAAA;AAAA,IAGH,OAAO;AAAA,IACP,MAAM,MAAM,MAAM,KAAK;AAAA,IACvB,MAAM,CAAC,OAAO,WAAW,MAAM,KAAK,OAAO,MAAM,MAAM,CAAC;AAAA,IACxD,GAAI,MAAM,SAAS,EAAE,QAAQ,CAAC,OAAgB,WAAoB,MAAM,OAAQ,OAAO,MAAM,MAAM,CAAC,EAAE,IAAI,CAAC;AAAA,IAC3G,UAAU,CAAC,UAAU,MAAM,SAAS,KAAK;AAAA,EAC3C;AACF;AAYA,SAAS,iBAAiB,UAAsD;AAC9E,SAAO;AAAA,IACL,OAAO;AAAA,IACP,SAAS,EAAE,iBAAiB,YAAY,WAAW,QAAQ,YAAY,MAAM,aAAa,KAAK;AAAA;AAAA,IAE/F,QAAQ,MAAM;AAAA,IACd,cAAc,CAAC,SAAS;AACtB,UAAI,UAAU;AACd,YAAM,MAAoC,CAAC;AAC3C,iBAAW,CAAC,KAAK,OAAO,KAAK,OAAO,QAAQ,IAAiB,GAAG;AAC9D,cAAM,QAAQ,QAAQ;AACtB,cAAM,MAAM,UAAU,SAAY,KAAK,M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AC,GAAG,GAAG;AAAA,IAC1E;AAEA,UAAM,MAA+C,CAAC;AACtD,eAAW,SAAS,OAAO,OAAO,GAAG;AAGnC,YAAM,SAAkC,EAAE,CAAC,KAAK,GAAG,MAAM,SAAS;AAClE,iBAAW,KAAK,KAAM,QAAO,CAAC,IAAI,KAAK,CAAC,EAAG,SAAS,MAAM,MAAM,CAAC,CAAC;AAClE,UAAI,KAAK,MAA+C;AAAA,IAC1D;AACA,WAAO;AAAA,EACT;AACF;;;ACxRA,IAAI,OAAO;AAGJ,SAAS,gBAAsB;AACpC,MAAI,KAAM;AACV,SAAO;AACP,iBAAe,MAAM,WAAW,kBAAkB;AAClD,iBAAe,MAAM,WAAW,aAAa;AAC7C,iBAAe,YAAY,WAAW,iBAAiB;AACzD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/kernel/query/relate/join-reduce.ts","../src/kernel/query/reduce/methods.ts","../src/kernel/query/reduce/scan-methods.ts","../src/kernel/query/reduce/install.ts"],"sourcesContent":["/**\n * Reducing over a JOIN ALIAS (#1338).\n *\n * `aggregate()` and `groupBy()` used to refuse any field rooted at a join\n * alias. The refusal's own doc named the real blocker, and it was never \"the\n * legs do not run\" — running them is the easy half. It was that the Via\n * pipeline is LEFT-SCOPED: `Query.aggregate()` calls\n * `this.source.via.wrapReducers(spec)`, which resolves every reducer's field\n * against the LEFT collection's map. For `sum('client.balance')` that map has\n * no entry, so two things silently did not happen — money's exact-BigInt\n * rewrite was skipped (a generic sum over stored scaled-integer strings, which\n * `readNumber` coerces to 0), and `refuseUnqueryableReducers` never fired, so\n * the `queryable: 'none'` gate that would refuse a blob field never applied.\n *\n * This module supplies the missing half as a Via BINDING rather than as a\n * special case threaded through the reduce strategy. A binding composes: the\n * pipeline handed to `GroupedQuery`/`aggregate()` is the left one plus this,\n * so every existing call site keeps its exact behaviour and the alias case\n * arrives through the same `wrapReducers` door as everything else.\n *\n * Two properties make that safe:\n *\n * - **It delegates, it does not reimplement.** An aliased reducer is handed\n * to the RIGHT collection's OWN pipeline under its BARE field name — which\n * is how a pipeline is keyed (that is the whole shape of #1335) — so the\n * right side's rewrite AND its posture gate apply together, from one call.\n * - **`covers()` returns false**, so the binding is inert for `postureFor`,\n * `present`, `decodeResults` and every other phase. It exists for exactly\n * one hook.\n */\nimport type { NoydbVia } from '../../via/index.js'\nimport { ViaPipeline } from '../../via/pipeline.js'\n\n/**\n * The reducer shape this file needs, declared STRUCTURALLY rather than\n * imported from `with-lookup/reduce/`.\n *\n * Not a style choice: `check-architecture.mjs`'s port-layering guard refuses a\n * NEW static kernel→`with-*` import (its allowlist is a frozen per-file, per-\n * specifier baseline, and adding a row would be the thing the freeze exists to\n * stop). `NoydbVia.wrapReducers` is declared `(spec: unknown) => unknown`\n * precisely so a binding never has to name the service's types, and these\n * three members are all this file touches — every reducer that reaches it was\n * built by the reduce service and keeps every other member intact through the\n * spread below.\n */\ninterface AliasReducer {\n readonly field?: string\n init(): unknown\n step(state: unknown, record: unknown): unknown\n remove?(state: unknown, record: unknown): unknown\n finalize(state: unknown): unknown\n}\ntype AliasSpec = Readonly<Record<string, AliasReducer>>\n\n/**\n * Re-aim a reducer at the sub-record under `alias`.\n *\n * The right side's pipeline rewrote the reducer for the BARE field name, so\n * its `step`/`remove` read `credit` off whatever record they are handed. On a\n * joined row that value lives at `row.client.credit`, so the row is unwrapped\n * one level on the way in rather than the field path being rewritten — the\n * rewritten reducer closes over its field name internally, so re-pointing the\n * `.field` property afterwards would change the label and not the read.\n *\n * An unmatched left row carries `null` under the alias; every reducer's read\n * already treats a nullish record as \"no value here\", so it contributes\n * nothing — the same thing a missing left-side field does.\n */\nfunction liftToAlias(alias: string, path: string, inner: AliasReducer): AliasReducer {\n const under = (record: unknown): unknown =>\n record === null || typeof record !== 'object' ? undefined : (record as Record<string, unknown>)[alias]\n return {\n ...inner,\n // The dotted path, so anything reading `.field` for a label or a\n // dependency still sees the field the CALLER named.\n field: path,\n init: () => inner.init(),\n step: (state, record) => inner.step(state, under(record)),\n ...(inner.remove ? { remove: (state: unknown, record: unknown) => inner.remove!(state, under(record)) } : {}),\n finalize: (state) => inner.finalize(state),\n }\n}\n\n/**\n * The binding: rewrite every reducer whose field is rooted at a join alias\n * through that alias's own collection pipeline, and leave everything else\n * exactly as it arrived.\n *\n * A reducer the right side does NOT rewrite (a plain `avg('client.score')`)\n * is returned untouched and keeps reading the dotted path off the joined row,\n * which is already correct — only a REWRITTEN reducer needs lifting, because\n * only a rewritten one has swapped to the bare name.\n */\nfunction joinAliasBinding(aliasVia: ReadonlyMap<string, ViaPipeline>): NoydbVia {\n return {\n brand: 'join-alias',\n posture: { encryptedAtRest: 'envelope', queryable: 'full', exportable: true, forgettable: true },\n // Claims no field: this binding must never shadow a left-side posture.\n covers: () => false,\n wrapReducers: (spec) => {\n let changed = false\n const out: Record<string, AliasReducer> = {}\n for (const [key, reducer] of Object.entries(spec as AliasSpec)) {\n const field = reducer.field\n const dot = field === undefined ? -1 : field.indexOf('.')\n const via = dot > 0 ? aliasVia.get(field!.slice(0, dot)) : undefined\n if (!via) { out[key] = reducer; continue }\n const bare = field!.slice(dot + 1)\n // One call: the right side's rewrite and its `queryable: 'none'`\n // refusal, both keyed by the bare name it actually declares.\n const wrapped = via.wrapReducers({ [key]: { ...reducer, field: bare } } as AliasSpec)[key]!\n if (wrapped === reducer || wrapped.field !== bare) { out[key] = reducer; continue }\n changed = true\n out[key] = liftToAlias(field!.slice(0, dot), field!, wrapped)\n }\n return changed ? out : spec\n },\n }\n}\n\n/**\n * The pipeline `aggregate()` / `groupBy()` should reduce THIS plan with: the\n * source's own, plus the alias binding when the plan can produce an alias.\n *\n * Returns the left pipeline unchanged when there is no alias to serve, so a\n * query with no joins — every query written before #1338 — is handed exactly\n * the object it was handed before.\n */\nexport function reduceViaFor(\n leftVia: ViaPipeline | undefined,\n aliasVia: ReadonlyMap<string, ViaPipeline> | undefined,\n): ViaPipeline | undefined {\n if (aliasVia === undefined || aliasVia.size === 0) return leftVia\n return ViaPipeline.build([...(leftVia?.bindings ?? []), joinAliasBinding(aliasVia)], leftVia?.taint)\n}\n\n/**\n * The other half, and the reason this one is not merely a missing feature:\n * a binding that REFUSES an aliased reducer instead of rewriting it.\n *\n * It is installed on the path where the legs do NOT run —\n * `groupBy('status').aggregate({ x: sum('client.credit') })`, a group key over\n * a left field with a reducer over an alias. `Query.aggregate()`'s guard never\n * saw that spec (the grouped terminal is `GroupedQuery.aggregate`, one object\n * along the chain), so it reduced `undefined` for every row and returned a\n * confident `0`. Group by the alias — then the legs run and the reducer is\n * rewritten by the branch above — or drop the grouping.\n */\nfunction refuseAliasBinding(aliases: ReadonlySet<string>): NoydbVia {\n return {\n brand: 'join-alias-refuse',\n posture: { encryptedAtRest: 'envelope', queryable: 'full', exportable: true, forgettable: true },\n covers: () => false,\n wrapReducers: (spec) => {\n for (const reducer of Object.values(spec as AliasSpec)) {\n const field = reducer.field\n if (field === undefined) continue\n const head = field.split('.')[0]!\n if (!aliases.has(head)) continue\n throw new Error(\n `Query.groupBy().aggregate(): reducer field \"${field}\" addresses the join alias ` +\n `\"${head}\", but the GROUP KEY does not — so the join legs are not applied for ` +\n `this grouping and the reducer would fold undefined into every bucket. ` +\n `Group by a field on \"${head}\" (then the legs run), or aggregate without ` +\n `grouping, where an aliased reducer is applied directly.`,\n )\n }\n return spec\n },\n }\n}\n\n/**\n * The pipeline for a grouped plan whose GROUP KEY stays on the left: the\n * source's own, plus the refusal above so an aliased reducer is a loud error\n * rather than a confident zero. No aliases in the plan → unchanged.\n */\nexport function refuseAliasReduceVia(\n leftVia: ViaPipeline | undefined,\n aliases: ReadonlySet<string>,\n): ViaPipeline | undefined {\n if (aliases.size === 0) return leftVia\n return ViaPipeline.build([...(leftVia?.bindings ?? []), refuseAliasBinding(aliases)], leftVia?.taint)\n}\n","/**\n * #1458 — **Reduce**: a fold over a result set.\n *\n * `aggregate` · `groupBy` · `window` · `distinct`\n *\n * Bodies moved out of `kernel/query/builder.ts` unchanged; see\n * `../relate/methods.ts` for why `this.plan` still resolves.\n *\n * ⚠️ This group depends on TWO others, and both edges are real rather than\n * tidyable:\n * - **Live**, for `incrementalMaintainer` — a live reduction maintains its\n * state through Live's maintainer (see `../internal/maintenance.ts`);\n * - **Relate**, for `reduceViaFor` / `refuseAliasReduceVia` — a reducer over\n * a JOIN ALIAS has to resolve the right side's Via pipeline, and refusing\n * it correctly is #1338's whole subject.\n * Neither is a layering accident: both are what \"reduce over a joined, live\n * result\" means.\n */\nimport type { DeclaredPredicate, InternalSource, QueryPlan } from '../builder.js'\n// @internal Find helpers. A reduce terminal narrows its record set through the\n// SAME executor the projection terminals use — sharing the functions is what\n// keeps \"which records does this terminal see\" one definition (#1347).\nimport { buildDictLabelResolver, candidateRecords, executeClausePipeline, filterRecords, fnViewDecoder } from '../builder.js'\nimport { readPath } from '../predicate.js'\nimport type { SourceChange } from '../live/incremental.js'\nimport type { QueryField } from '../../types.js'\nimport type { ViaPipeline } from '../../via/pipeline.js'\nimport type { JoinContext, JoinLeg } from '../relate/join.js'\nimport { reduceViaFor, refuseAliasReduceVia } from '../relate/join-reduce.js'\nimport type { DateTruncKey, GroupKey } from './date-trunc.js'\nimport { groupKeyName, isDateTruncKey, projectDateTruncKeys } from './date-trunc.js'\nimport { distinctKeyOf } from '../distinct-key.js'\nimport type { LiveMaintainer, GroupMaintenanceSource } from '../live/incremental.js'\nimport type { ReduceSpec, ReduceResult, ReductionUpstream, Reduction } from '../../../with-lookup/reduce/reduction.js'\nimport type { ReducerBuilder } from '../../../with-lookup/reduce/reducers.js'\nimport { bindDistinctReducers, reducerBuilder } from '../../../with-lookup/reduce/reducers.js'\nimport type { GroupedQuery, GroupedQueryN } from '../../../with-lookup/reduce/groupby.js'\nimport type { ReduceStrategy, WindowSpec, WindowedQuery } from '../../../with-lookup/reduce/strategy.js'\nimport { FieldNotQueryableError } from '../../errors.js'\n\nfunction assertNoJoinAliasField(\n fields: readonly string[],\n joins: readonly JoinLeg[],\n terminal: string,\n): void {\n if (joins.length === 0) return\n const aliases = new Set(joins.map(leg => leg.as))\n for (const field of fields) {\n const head = field.split('.')[0]!\n if (!aliases.has(head)) continue\n throw new Error(\n `Query.${terminal}(): field \"${field}\" addresses the join alias \"${head}\", but ` +\n `${terminal}() does not apply join legs — it would silently group every row ` +\n `under undefined. Joined aggregation is not supported. Either aggregate over ` +\n `the left collection's own fields, or use .crossJoin(\"${head}\", { as: … }), ` +\n `whose expansion IS visible to ${terminal}().`,\n )\n }\n}\n\n/** @internal — the mixin whose prototype `./index.ts` copies onto `Query`. */\n /* eslint-disable @typescript-eslint/no-unused-vars -- #1458: the parameter\n list must match `Query`'s exactly (T, S, Q, M) because `declare module`\n merges this mixin's `Pick` into it, and TypeScript requires every\n declaration of an interface to carry identical type parameters. A group\n whose methods happen to use only `T` still declares all four. */\nexport class ReduceMethods<\n T,\n S extends keyof T = never,\n Q extends keyof T & string = never,\n M extends keyof T & string = never,\n /* eslint-enable @typescript-eslint/no-unused-vars */\n> {\n declare protected readonly source: InternalSource\n declare protected readonly plan: QueryPlan\n declare protected readonly joinContext: JoinContext | undefined\n declare protected readonly reduceStrategy: ReduceStrategy\n declare protected readonly predicates: ReadonlyMap<string, DeclaredPredicate> | undefined\n declare protected matchedRecords: (terminal: string, forceJoins?: boolean) => readonly unknown[]\n declare protected decodeVia: (records: readonly unknown[], locale?: string) => unknown[]\n declare protected aliasVia: () => ReadonlyMap<string, ViaPipeline> | undefined\n declare protected incrementalMaintainer: (mode: 'rows' | 'records') => LiveMaintainer | undefined\n declare protected groupMaintenance: (derived: readonly DateTruncKey[]) => GroupMaintenanceSource | undefined\n declare toArray: (opts?: { locale?: string }) => T[]\n\n /**\n * The right-side change streams a joined query has to merge (#1338), deduped\n * by target the way `live()` does — a chain joining the same collection\n * twice must not double-fire. Extracted so a joined REDUCTION and a joined\n * live query cannot disagree on what \"the sources of this result\" means.\n */\n private rightSideUpstreams(): ReductionUpstream[] {\n const ctx = this.joinContext\n if (!ctx) return []\n const out: ReductionUpstream[] = []\n const seen = new Set<string>()\n for (const leg of this.plan.joins) {\n if (seen.has(leg.target)) continue\n seen.add(leg.target)\n const right = ctx.resolveSource(leg.target)\n if (!right?.subscribe) continue\n const subscribe = right.subscribe.bind(right)\n out.push({ subscribe: (cb: () => void) => subscribe(cb) })\n }\n return out\n }\n\n /**\n * Every alias this plan can produce, pipeline or not (#1338).\n *\n * `aliasVia()` above holds only the aliases whose collection compiles a Via\n * pipeline; refusal has to know about ALL of them, or an aliased reducer\n * over a plain right-side collection stays silent.\n */\n private aliasNames(): ReadonlySet<string> {\n const out = new Set<string>()\n for (const clause of this.plan.clauses) {\n if (clause.type !== 'crossJoin') continue\n out.add(clause.as)\n if (clause.leftAs !== undefined) out.add(clause.leftAs)\n }\n for (const leg of this.plan.joins) out.add(leg.as)\n return out\n }\n\n /** Is `field` rooted at an alias this plan produces? */\n\n private addressesAlias(field: string, aliases: ReadonlySet<string>): boolean {\n const dot = field.indexOf('.')\n return dot > 0 && aliases.has(field.slice(0, dot))\n }\n\n /**\n * The distinct values of `field` across the match set (#1347) — the\n * declarative form of `new Set(q.toArray().map(r => r[field]))`, which is\n * what consumers write today and which is wrong in two ways this is not.\n *\n * **Distinctness is decided on the canonical index key, not on the value\n * you get back.** For a Via-covered field that is the difference between a\n * right answer and a plausible one: money stores a scaled integer, and a\n * row written before the field was declared can spell it non-canonically\n * (`'0100'` for `'100'`). Deduping the stored strings reports two values\n * where there is one; deduping the FORMATTED strings makes the answer\n * depend on a locale this layer does not have (`'10.00'` vs `'10,00'`).\n * See `distinct-key.ts`. The values RETURNED are the decoded ones, so they\n * match what `toArray()` hands back for the same field.\n *\n * **Nullish values are excluded** — `null`/`undefined`/missing is the\n * absence of a value, not a distinct one. That is also the only choice\n * under which the index-backed and scanned paths can agree, since the hash\n * index does not hold nullish keys; see `distinctKeyOf`.\n *\n * Same match set as `count()`: where/filter apply, orderBy/limit/offset do\n * not. Values come back in first-encountered order.\n *\n * ⭐ INDEX-BACKED when the field carries a hash index AND the plan narrows\n * nothing — the buckets ARE the distinct key set, so the answer costs\n * O(distinct values) instead of O(records) and never decrypts a snapshot.\n * The guard is deliberately all-or-nothing: with a where clause the whole\n * collection's buckets are not the answer, and intersecting a candidate id\n * set with every bucket would cost more than the scan it replaced.\n *\n * ⛔ THE RETURN TYPE IS `(T & Record<F, unknown>)[F][]`, NOT\n * `F extends keyof T ? T[F][] : unknown[]` — and it must stay that way. The\n * conditional form reads better and type-checks at every call site, but a\n * DEFERRED conditional over `T` makes TypeScript give up relating\n * `Query<T>` to `Query<unknown>`, which makes `Collection<T>` invariant in\n * `T`, which breaks `vault.ts`'s `Map<string, Collection<unknown>>` cache\n * with four errors that name neither this method nor this file. The\n * intersection form resolves to the same thing (`T[F]` for a literal key,\n * `unknown` for a `string`-typed one) and stays covariant.\n */\n distinct<F extends QueryField<T, S>>(field: F): (T & Record<F, unknown>)[F][] {\n const name = field as string\n assertNoJoinAliasField([name], this.plan.joins, 'distinct')\n const via = this.source.via\n // Same posture gate `.where()` / `.orderBy()` apply: a `queryable: 'none'`\n // field (a blob handle) must not have its value set enumerated either.\n if (via?.postureFor(name)?.queryable === 'none') throw new FieldNotQueryableError(name)\n const decode = via?.hasResultDecode ? (r: unknown) => via.decodeResults(r) : (r: unknown) => r\n\n const indexes =\n this.plan.clauses.length === 0 && this.plan.joins.length === 0\n ? this.source.getIndexes?.()\n : undefined\n if (indexes && this.source.lookupById) {\n const lookupById = (id: string): unknown => this.source.lookupById?.(id)\n const reps = indexes.bucketRepresentatives(name)\n if (reps) {\n const fromIndex: unknown[] = []\n for (const id of reps) {\n const record = lookupById(id)\n if (record === undefined) continue\n fromIndex.push(readPath(decode(record), name))\n }\n return fromIndex as (T & Record<F, unknown>)[F][]\n }\n }\n\n const seen = new Set<string>()\n const out: unknown[] = []\n for (const record of this.matchedRecords('distinct')) {\n const key = distinctKeyOf(name, readPath(record, name), via)\n if (key === undefined || seen.has(key)) continue\n seen.add(key)\n out.push(readPath(decode(record), name))\n }\n return out as (T & Record<F, unknown>)[F][]\n }\n\n /**\n * Reduce the matching records through a named set of reducers.\n * the aggregation terminal.\n *\n * ```ts\n * const { total, n, avgAmount } = invoices.query()\n * .where('status', '==', 'open')\n * .aggregate({\n * total: sum('amount'),\n * n: count(),\n * avgAmount: avg('amount'),\n * })\n * .run()\n * ```\n *\n * Returns an `Reduction<R>` wrapper with two terminals:\n * - `.run(): R` — synchronous one-shot reduction\n * - `.live(): LiveReduction<R>` — reactive primitive that\n * re-runs the reduction whenever the source notifies of a\n * change. Always call `live.stop()` when finished.\n *\n * The reducer spec is bound here once and reused by both\n * terminals — this is why `.aggregate()` returns a wrapper instead\n * of being a direct terminal. Consumers who only need the static\n * value read `.run()`; consumers wiring a reactive UI read\n * `.live()`.\n *\n * Joins are NOT applied by default — the same logic as `.count()`. A leg is\n * projection-only, so running one just to throw the alias away would be\n * wasteful. ⭐ **The exception is a reducer that ADDRESSES an alias**\n * (#1338): then the joined relation IS what is being reduced, so the legs\n * run and the reducer is rewritten by the right collection's own Via\n * pipeline — money stays exact, and the right side's `queryable: 'none'`\n * posture refuses a field it would refuse locally. A live joined\n * aggregation also merges every right-side change stream, so it does not\n * quietly stop updating when the right side moves.\n *\n * Every reducer factory accepts an optional `{ seed }` parameter\n * that is plumbed through the protocol but unused by the\n * executor — that's constraint #2. When partition-aware\n * aggregation lands, the seed will carry running state across\n * partition boundaries without an API break.\n *\n * KNOWN GAP (sealed fields, bare-spec form): `where`/`orderBy`/`groupBy`\n * refuse a `sensitive` field at compile time, but a reducer over a sensitive\n * field in the BARE-SPEC form (e.g. `aggregate({ x: sum('ssn') })`) is NOT\n * refused — the reducer factories (`sum`/`min`/`max`/…) are standalone\n * `(field: string)` functions with no collection-type context. This form is\n * preserved as-is for backward compatibility.\n *\n * The BUILDER form closes this gap: `aggregate(b => ({ x: b.sum('field') }))`\n * types the builder's field parameter as `QueryField<T, S>`, refusing any\n * `sensitive` field at compile time. Use the builder form for new code that\n * aggregates over a collection with sensitive fields.\n *\n */\n aggregate<Spec extends ReduceSpec>(spec: Spec): Reduction<ReduceResult<Spec>>\n aggregate<Spec extends ReduceSpec>(build: (b: ReducerBuilder<T, S, M>) => Spec): Reduction<ReduceResult<Spec>>\n aggregate<Spec extends ReduceSpec>(\n specOrBuild: Spec | ((b: ReducerBuilder<T, S, M>) => Spec),\n ): Reduction<ReduceResult<Spec>> {\n let spec = typeof specOrBuild === 'function'\n ? (specOrBuild as (b: ReducerBuilder<T, S, M>) => Spec)((reducerBuilder as unknown) as ReducerBuilder<T, S, M>)\n : specOrBuild\n // #1338 — a reducer over a joined alias used to be refused here. It now\n // routes: the legs run (so the reducer sees the joined relation) and the\n // spec is wrapped by a pipeline that delegates each aliased field to the\n // RIGHT collection's own — which carries money's exact-BigInt rewrite and\n // the `queryable: 'none'` posture gate together. Reducers without a field\n // (e.g. `count()`) address nothing and are unaffected.\n const aliases = this.aliasNames()\n const aliasedReducer =\n this.plan.joins.length > 0 &&\n Object.values(spec).some(r => {\n const f = (r as { field?: unknown }).field\n return typeof f === 'string' && this.addressesAlias(f, aliases)\n })\n // Rewrite sum/min/max over Via-covered fields (e.g. money) into exact\n // BigInt reducers before the strategy runs (covers static run() and\n // live/MV paths).\n spec = (aliasedReducer ? reduceViaFor(this.source.via, this.aliasVia()) : this.source.via)?.wrapReducers(spec) ?? spec\n // #1347 — `countDistinct` needs the SAME canonicalizer the hash index\n // buckets by, and only the source knows it. Bound here, beside the\n // money rewrite, so both spec-wrapping seams stay in one place.\n spec = bindDistinctReducers(spec, this.source.via)\n // Closure over the current query. Produces the record set that\n // the aggregation reduces — same pipeline as `count()`, skipping\n // limit/offset because aggregation is over the full match set,\n // not a paginated slice. (A paginated aggregation would be a\n // different operation; see docs for rationale.)\n const source = this.source\n const clauses = this.plan.clauses\n const joinCtx = this.joinContext\n const hasCrossJoins = clauses.some(c => c.type === 'crossJoin')\n const fullScan = aliasedReducer\n // The reduced relation IS the joined one — same pipeline `count()` uses,\n // with the legs forced on (#1338).\n ? (): readonly unknown[] => this.matchedRecords('aggregate', true)\n : (): readonly unknown[] => {\n if (hasCrossJoins) {\n if (!joinCtx) throw new Error('Query.aggregate(): crossJoin requires a join context')\n return executeClausePipeline(source, clauses, joinCtx)\n }\n const { candidates, remainingClauses } = candidateRecords(source, clauses)\n return remainingClauses.length === 0\n ? candidates\n : filterRecords(candidates, remainingClauses, fnViewDecoder(source))\n }\n\n // #1341 — when the plan admits it, the match set is MAINTAINED across\n // change events instead of re-scanned, so a live reduction folds over an\n // incrementally-patched array. The reducers themselves still run a full\n // fold: the array they see is byte-for-byte the one a re-scan would\n // produce (same records, same candidate order), so an incremental result\n // is not merely close to a re-run's — it is the identical computation.\n const maintainer = this.incrementalMaintainer('records')\n const executeRecords = maintainer ? (): readonly unknown[] => maintainer.rows() : fullScan\n\n // Upstream for live mode. The left source always subscribes; a joined\n // aggregation ALSO merges every right-side change stream (#1338) — the\n // refusal's own doc named a live joined aggregate that silently stops\n // updating as half the work, and it is this half.\n const upstreams: ReductionUpstream[] = []\n if (aliasedReducer) upstreams.push(...this.rightSideUpstreams())\n if (source.subscribe) {\n const subscribe = source.subscribe.bind(source)\n upstreams.push(\n maintainer\n ? {\n // The maintainer folds the delta in BEFORE the reduction reads,\n // which is why it is wrapped here rather than subscribed\n // separately — emitter callback order would otherwise decide\n // whether the reduction saw the new record.\n subscribe: (cb: () => void) => {\n maintainer.attach()\n const unsubscribe = subscribe(change => {\n // A predicate that throws must not escape into the emitter —\n // the maintainer drops its state and the reduction's own\n // re-run raises the same error where it can be caught.\n try {\n maintainer.apply(change)\n } catch {\n maintainer.invalidate()\n }\n cb()\n })\n // Detach on teardown: the Reduction survives its LiveReduction\n // (`.run()` reuses the same closure), and a maintainer with no\n // subscription feeding it would go quietly out of date.\n return () => {\n maintainer.detach()\n unsubscribe()\n }\n },\n }\n : { subscribe: (cb: () => void) => subscribe(cb) },\n )\n }\n\n // #1414 — the gate travels INTO the reduction rather than wrapping it.\n // `Reduction.run()` is the synchronous terminal, and `await …aggregate(\n // spec).run()` is what an async guard's Σ-over-siblings invariant writes;\n // gating the builder call instead would break that awaited form.\n return this.reduceStrategy.aggregate<Spec>(executeRecords, spec, upstreams, this.source.hydration)\n }\n\n /**\n * Partition matching records into buckets keyed by a field, then\n * terminate with `.aggregate(spec)` to compute per-bucket\n * reducers..\n *\n * ```ts\n * const byClient = invoices.query()\n * .where('status', '==', 'open')\n * .groupBy('clientId')\n * .aggregate({ total: sum('amount'), n: count() })\n * .run()\n * // → [ { clientId: 'c1', total: 5250, n: 3 }, … ]\n * ```\n *\n * Result rows carry the group key value under the grouping field\n * name plus every reducer output from the spec. Buckets are\n * emitted in first-seen order — consumers who want a specific\n * ordering should `.sort()` downstream.\n *\n * **Cardinality caps:** a one-shot warning fires at 10_000\n * distinct groups; `GroupCardinalityError` throws at 100_000.\n * Grouping on a high-uniqueness field like `id` or `createdAt` is\n * almost always a query mistake — the error message names the\n * field and observed cardinality and suggests narrowing with\n * `.where()` first.\n *\n * **Null / undefined keys:** records with a missing or explicitly\n * `null` group field get their own buckets. `Map`-based\n * partitioning distinguishes `undefined` from `null`, so the two\n * cases do NOT merge. Consumers who want them merged should\n * coalesce upstream with `.filter()`.\n *\n * **Joins are not applied unless the GROUP KEY addresses an alias** (#1338).\n * For a left-side key the old rationale still holds — a leg is\n * projection-only, so running one inside a grouping pipeline would be\n * wasteful and could trigger `DanglingReferenceError` in strict mode for a\n * call whose intent is purely to bucket-and-reduce. For an aliased key\n * (`groupBy('client.region')`, the accounting-report shape) the legs run and\n * the buckets are the joined relation's: the key is stamped under its DOTTED\n * path (`row['client.region']`), and a left row whose right side is absent\n * reads `undefined` and lands in the undefined bucket — the same bucket a\n * missing left-side key gets, and still distinct from an explicit `null`.\n *\n * ⚠️ The decision is taken from the KEY, because the reducer spec arrives a\n * call later. A reducer over an alias under a LEFT key is therefore REFUSED\n * rather than folded as `undefined` — group by the alias, or aggregate\n * without grouping.\n *\n * **Filter clauses (`.filter(fn)`):** grouped queries still\n * support filter clauses in the underlying plan — they run in\n * the same candidate/filter pipeline that `.aggregate()` uses.\n * The performance caveat is the same: filter clauses cost O(N)\n * per record and can't be index-accelerated.\n */\n // The `field` param is `QueryField<T, S>` so a sealed (`sensitive`) field is\n // refused — grouping BY a sensitive field leaks its value distribution as\n // group-key labels. With `S = never` this is exactly `string` (zero churn).\n\n groupBy<F extends QueryField<T, S>>(field: F): GroupedQuery<T, F, S, M>\n groupBy<F extends readonly [QueryField<T, S>, QueryField<T, S>, ...QueryField<T, S>[]]>(\n ...fields: F\n ): GroupedQueryN<T, F, S, M>\n // Derived calendar keys (#1350). Listed last so the two field-name overloads\n // above still win for plain string arguments — a `DateTruncKey` is an object\n // and matches neither, so nothing existing re-resolves onto these.\n groupBy(key: DateTruncKey): GroupedQuery<T, string, S, M>\n // The string members stay `QueryField<T, S>`, so the sealed-field refusal\n // still applies to every plain key in a mixed grouping.\n groupBy(\n ...keys: readonly [\n QueryField<T, S> | DateTruncKey,\n QueryField<T, S> | DateTruncKey,\n ...(QueryField<T, S> | DateTruncKey)[],\n ]\n ): GroupedQueryN<T, readonly string[], S, M>\n groupBy(...keys: readonly GroupKey[]): GroupedQuery<T, string, S, M> | GroupedQueryN<T, readonly string[], S, M> {\n if (keys.length === 0) {\n throw new Error('.groupBy() requires at least one field')\n }\n // A derived key is bucketed into an ordinary row field before the grouping\n // pipeline runs, so everything downstream — cardinality caps, null/undefined\n // bucket semantics, live re-grouping — keeps working unchanged.\n const derived = keys.filter(isDateTruncKey)\n const fields: readonly string[] = keys.map(groupKeyName)\n // #29 — the same posture gate `.where()` / `.orderBy()` / `.distinct()`\n // apply. A `queryable: 'none'` field (a virtual computed field, a blob\n // handle) is absent from the stored record the reducer walks, so grouping\n // on it keys every row on `undefined` and folds the whole collection into\n // one well-formed bucket with no error anywhere. Refusing here is what a\n // caller can catch; a silently-undefined key is not detectable downstream.\n //\n // ⚠️ Gated on the RESOLVED names, so a `dateTrunc` key over a virtual\n // field is refused too — `groupKeyName` returns the underlying field.\n const groupVia = this.source.via\n if (groupVia) {\n for (const f of fields) {\n if (groupVia.postureFor(f)?.queryable === 'none') throw new FieldNotQueryableError(f)\n }\n }\n // #1338 — a group key addressing an alias used to be refused. It now\n // decides the shape of the whole grouped pipeline: the legs run, and the\n // reducers are wrapped through the right side's pipeline.\n //\n // ⚠️ The decision is made HERE, from the group KEY alone, because the\n // reducer spec does not exist yet — it arrives one call later, at\n // `.aggregate()`. That is exactly why the left-key case installs a\n // REFUSING binding rather than nothing: a reducer over an alias under a\n // left-side key would otherwise fold undefined into every bucket, and the\n // grouped terminal is not the one `Query.aggregate()`'s guard sees.\n const aliases = this.aliasNames()\n const keyIsAliased = this.plan.joins.length > 0 && fields.some(f => this.addressesAlias(f, aliases))\n // Same record-producing closure as .aggregate() — grouped and\n // non-grouped aggregations execute over the same candidate set.\n // We inline the closure here instead of sharing a helper so the\n // builder stays allocation-friendly for the hot path.\n const source = this.source\n const clauses = this.plan.clauses\n const joinCtx = this.joinContext\n const hasCrossJoins = clauses.some(c => c.type === 'crossJoin')\n const executeRecords = keyIsAliased\n ? (): readonly unknown[] => this.matchedRecords('groupBy', true)\n : (): readonly unknown[] => {\n if (hasCrossJoins) {\n if (!joinCtx) throw new Error('Query.groupBy(): crossJoin requires a join context')\n return executeClausePipeline(source, clauses, joinCtx)\n }\n const { candidates, remainingClauses } = candidateRecords(source, clauses)\n return remainingClauses.length === 0\n ? candidates\n : filterRecords(candidates, remainingClauses, fnViewDecoder(source))\n }\n const executeGroupRecords = derived.length === 0\n ? executeRecords\n : (): readonly unknown[] => projectDateTruncKeys(executeRecords(), derived)\n\n // #1341 (grouped half) — the upstream passes the DELTA through, not just a\n // \"something changed\" ping, so `GroupedReduction.live()` can patch the one\n // or two buckets a change touches instead of re-grouping everything. A cb\n // that ignores the argument (every pre-#1341 caller) is unaffected.\n const upstreams: ReductionUpstream[] = []\n if (source.subscribe) {\n const subscribe = source.subscribe.bind(source)\n upstreams.push({ subscribe: (cb: (change?: SourceChange) => void) => subscribe(cb) })\n }\n if (keyIsAliased) upstreams.push(...this.rightSideUpstreams())\n // Withheld for a plan the whitelist refuses, and for an aliased key (which\n // implies joins, which the whitelist refuses anyway) — `.live()` then\n // re-runs the whole grouping, exactly as it did before.\n const maintenance = keyIsAliased ? undefined : this.groupMaintenance(derived)\n\n // The pipeline the reducers are wrapped with: the right side's rewrite\n // when the legs run, the refusal when they do not (#1338).\n const reduceVia = keyIsAliased\n ? reduceViaFor(this.source.via, this.aliasVia())\n : refuseAliasReduceVia(this.source.via, aliases)\n\n // Dict-label resolution is single-field only — the <field>Label\n // projection has no meaningful shape for composite keys. A derived\n // calendar key is never a dictKey, so it skips the lookup entirely.\n if (fields.length === 1) {\n const field = fields[0]!\n const dictLabelResolver = derived.length > 0\n ? undefined\n : buildDictLabelResolver(this.joinContext, field)\n return this.reduceStrategy.groupBy<T, string, S, M>(\n executeGroupRecords,\n field,\n upstreams,\n dictLabelResolver,\n reduceVia,\n maintenance,\n )\n }\n return this.reduceStrategy.groupByN<T, readonly string[], S, M>(\n executeGroupRecords,\n fields,\n upstreams,\n reduceVia,\n maintenance,\n )\n }\n\n /**\n * SQL window functions over the query's result rows (#1349) — terminate with\n * `.select(spec)`.\n *\n * ```ts\n * invoices.query()\n * .where('status', '==', 'open')\n * .window({ partitionBy: 'clientId', orderBy: 'date' })\n * .select({ balance: runningSum('amount'), prev: lag('amount', 1), n: rowNumber() })\n * .run()\n * ```\n *\n * ⭐ Distinguished from `.groupBy()` by ARITY, not by capability: grouping\n * emits one row per bucket and drops the source rows; a window keeps EVERY\n * row and attaches per-row values computed over its partition.\n *\n * **The record set is `toArray()`'s** — the full pipeline, including joins,\n * `orderBy`, `offset`/`limit` and the Via decode. That differs deliberately\n * from `.groupBy()`, which reads the candidate/filter pipeline only: a\n * window returns ROWS, so the query's own ordering and paging are exactly\n * what decides which rows there are and how they are presented. `orderBy`\n * inside the window decides only how a partition is WALKED.\n *\n * **Frame:** `rows unbounded preceding → current row`, and only that in v1.\n *\n * `partitionBy` / `orderBy` accept a `dateTrunc()` key (#1350) alongside\n * plain field names; the derived bucket is used for partitioning and is not\n * stamped on the output row. A sealed (`sensitive`) field is refused at\n * compile time, same as `.groupBy()`.\n *\n * ⛔ **Not an `explain()` node.** `explain()` is a terminal on `Query`;\n * `.window()` leaves `Query` for `WindowedQuery`, so there is nothing past\n * here to add a node to — the same reason #1336's post-group ops are absent.\n */\n window(spec: WindowSpec<QueryField<T, S>>): WindowedQuery<T> {\n const upstreams: ReductionUpstream[] = []\n if (this.source.subscribe) {\n const subscribe = this.source.subscribe.bind(this.source)\n upstreams.push({ subscribe: (cb: () => void) => subscribe(cb) })\n }\n return this.reduceStrategy.window<T>(\n () => this.toArray() as readonly unknown[],\n spec as WindowSpec,\n upstreams,\n this.source.via,\n )\n }\n}\n\n/** The public Reduce surface — merged into `Query` by `./index.ts`. */\nexport type ReduceSurface<\n T,\n S extends keyof T = never,\n Q extends keyof T & string = never,\n M extends keyof T & string = never,\n> = Pick<ReduceMethods<T, S, Q, M>, 'aggregate' | 'groupBy' | 'window' | 'distinct'>\n\n","/**\n * #1458 — the **Reduce** half of `ScanBuilder`.\n *\n * `aggregate` · `groupBy` · the grouped-scan handle they return.\n *\n * See `../relate/scan-methods.ts` for why `ScanBuilder` is split at all.\n *\n * ⭐ **The streaming memory property travels with the code.**\n * `scan().aggregate()` is O(reducers), not O(records) — it steps every reducer\n * per record and never collects the stream — and `groupBy().aggregate()` is\n * O(groups). That is a code-level invariant visible in the bodies below, so\n * moving them wholesale is what preserves it; re-expressing them over the\n * eager reducers would have quietly turned an unbounded scan into an array.\n */\nimport type { MultiReduceResult, ScanPageProvider } from '../scan-builder.js'\nimport type { QueryField } from '../../types.js'\nimport type { Clause } from '../predicate.js'\nimport { readPath } from '../predicate.js'\nimport type { ViaPipeline } from '../../via/pipeline.js'\nimport type { JoinContext, JoinLeg } from '../relate/join.js'\nimport type { ReducerBuilder } from '../../../with-lookup/reduce/reducers.js'\nimport { bindDistinctReducers, reducerBuilder } from '../../../with-lookup/reduce/reducers.js'\nimport type { ReduceSpec, ReduceResult } from '../../../with-lookup/reduce/reduction.js'\nimport type { DateTruncKey } from './date-trunc.js'\nimport { groupKeyName, isDateTruncKey, projectDateTruncKeys } from './date-trunc.js'\nimport { GroupCardinalityError } from '../../errors.js'\n\n/** @internal — the mixin whose prototype `./index.ts` copies onto `ScanBuilder`. */\nexport class ScanReduceMethods<T, S extends keyof T = never, M extends keyof T & string = never> {\n declare protected readonly pageProvider: ScanPageProvider<T>\n declare protected readonly pageSize: number\n declare protected readonly clauses: readonly Clause[]\n declare protected readonly joins: readonly JoinLeg[]\n declare protected readonly joinContext: JoinContext | undefined\n declare protected readonly via: ViaPipeline | undefined\n declare protected decodeVia: (record: T) => T\n declare protected recordMatches: (record: T, clauses?: readonly Clause[]) => boolean\n declare [Symbol.asyncIterator]: () => AsyncIterator<T>\n\n async aggregate<const Specs extends readonly ReduceSpec[]>(specs: Specs): Promise<MultiReduceResult<Specs>>\n async aggregate<Spec extends ReduceSpec>(spec: Spec): Promise<ReduceResult<Spec>>\n async aggregate<Spec extends ReduceSpec>(build: (b: ReducerBuilder<T, S, M>) => Spec): Promise<ReduceResult<Spec>>\n async aggregate<Spec extends ReduceSpec>(\n specOrBuild: Spec | readonly ReduceSpec[] | ((b: ReducerBuilder<T, S, M>) => Spec),\n ): Promise<ReduceResult<Spec> | unknown[]> {\n // #1340 — the multi-spec form. N independent specs, ONE pass: the states\n // for every spec are stepped from the same yielded record, so the page\n // provider is walked exactly once no matter how many specs are passed.\n // (Calling `.aggregate(specA)` then `.aggregate(specB)` costs two full\n // scans — the immutable-builder docs above say so, and this is the fix.)\n if (Array.isArray(specOrBuild)) return this.aggregateMany(specOrBuild as readonly ReduceSpec[])\n // Opt-in builder form `aggregate(b => spec)`: `b`'s field args are\n // `QueryField<T, S>`, refusing sensitive fields (the standalone-spec form\n // stays unrefused for back-compat), and `sum`/`min`/`max` over a declared\n // `moneyFields` (`M`) member return a `MoneyString`. Mirrors `Query.aggregate`.\n const spec: Spec = typeof specOrBuild === 'function'\n ? (specOrBuild as (b: ReducerBuilder<T, S, M>) => Spec)(reducerBuilder as unknown as ReducerBuilder<T, S, M>)\n // `Array.isArray` above does not narrow a READONLY array out of the\n // union, so the array arm is already returned and this cast is the\n // remainder — a plain spec.\n : (specOrBuild as Spec)\n this.via?.refuseUnqueryableReducers(spec)\n const keys = Object.keys(spec)\n // Per-reducer state. Exactly |keys| entries, never grows with\n // the record count — that's the O(reducers) memory guarantee.\n const state: Record<string, unknown> = {}\n for (const key of keys) {\n state[key] = spec[key]!.init()\n }\n\n // Record-by-record streaming step. `for await (… of this)`\n // invokes the Symbol.asyncIterator above, which honors the\n // clause list, so filtered-out records never reach the step\n // loop — they're dropped at the iterator boundary.\n for await (const record of this) {\n for (const key of keys) {\n state[key] = spec[key]!.step(state[key], record)\n }\n }\n\n const result: Record<string, unknown> = {}\n for (const key of keys) {\n result[key] = spec[key]!.finalize(state[key])\n }\n return result as ReduceResult<Spec>\n }\n\n /**\n * The multi-spec `.aggregate([specA, specB, …])` executor (#1340).\n *\n * One iteration of the scan, `Σ|spec|` reducer states — memory stays\n * O(reducers) exactly as the single-spec terminal's does, with the sum taken\n * across specs instead of within one. Every spec's state is stepped from the\n * SAME yielded record, so the page provider is read once per page.\n *\n * Semantics per spec are identical to the single-spec form, deliberately:\n * the posture gate is `refuseUnqueryableReducers` (metadata only), NOT the\n * full `wrapReducers` — so `aggregate([a, b])` returns exactly what\n * `aggregate(a)` and `aggregate(b)` return, and the array form is a pure\n * cost optimisation with no behavioural delta to reason about. (The grouped\n * scan path DOES wrap — it has to agree with the eager grouped path, which\n * wraps. See `scan-groupby.ts`.)\n */\n private async aggregateMany(specs: readonly ReduceSpec[]): Promise<unknown[]> {\n for (const spec of specs) this.via?.refuseUnqueryableReducers(spec)\n const keysPerSpec = specs.map((spec) => Object.keys(spec))\n const states: Record<string, unknown>[] = specs.map((spec, i) => {\n const state: Record<string, unknown> = {}\n for (const key of keysPerSpec[i]!) state[key] = spec[key]!.init()\n return state\n })\n\n for await (const record of this) {\n for (let i = 0; i < specs.length; i++) {\n const spec = specs[i]!\n const state = states[i]!\n for (const key of keysPerSpec[i]!) state[key] = spec[key]!.step(state[key], record)\n }\n }\n\n return specs.map((spec, i) => {\n const result: Record<string, unknown> = {}\n for (const key of keysPerSpec[i]!) result[key] = spec[key]!.finalize(states[i]![key])\n return result\n })\n }\n\n /**\n * Group the scan stream and reduce each group — `#1340`.\n *\n * ```ts\n * const byClient = await invoices.scan()\n * .where('status', '==', 'open')\n * .groupBy('clientId', { maxGroups: 5_000 })\n * .aggregate({ total: sum('amount'), n: count() })\n * ```\n *\n * ⚠️ **This is the one scan terminal whose memory is NOT O(pageSize).** It\n * holds one reducer state per group, which is why the budget is explicit:\n * `maxGroups` defaults to the eager path's 100_000-group ceiling and is\n * REFUSED — never truncated — the moment a scan would exceed it. Price the\n * budget before raising it: an exact `median`/`percentile`, a `mode` or a\n * `countDistinct` holds O(values) per group, so an unbounded scan wants\n * `{ approx: true }` on the quantiles. Full rationale in `scan-groupby.ts`.\n *\n * The key may be a field name or a `dateTrunc()` derived calendar key (the\n * monthly-rollup shape); grouping BY a `sensitive` field is refused at\n * compile time, same as `Query.groupBy()`.\n */\n groupBy<F extends QueryField<T, S>>(field: F, opts?: { maxGroups?: number }): ScanGroupedScan<T, F, S, M>\n groupBy(key: DateTruncKey, opts?: { maxGroups?: number }): ScanGroupedScan<T, string, S, M>\n groupBy(key: QueryField<T, S> | DateTruncKey, opts?: { maxGroups?: number }): ScanGroupedScan<T, string, S, M> {\n return new ScanGroupedScan<T, string, S, M>(\n this,\n key as string | DateTruncKey,\n opts?.maxGroups ?? SCAN_GROUPBY_DEFAULT_MAX_GROUPS,\n this.via,\n )\n }\n}\n\n/** The public Reduce surface of `ScanBuilder` — merged by `./index.ts`. */\nexport type ScanReduceSurface<\n T,\n S extends keyof T = never,\n M extends keyof T & string = never,\n> = Pick<ScanReduceMethods<T, S, M>, 'aggregate' | 'groupBy'>\n\n/**\n * Default group ceiling — the same constant the eager `.groupBy()` enforces.\n * Duplicated as a literal rather than imported from\n * `with-lookup/reduce/groupby.ts` on purpose: that module carries the eager\n * `groupAndReduce` + `GroupedReduction` classes, and the always-on kernel must\n * not pull them in to read one number. The pairing is asserted by a test.\n */\nexport const SCAN_GROUPBY_DEFAULT_MAX_GROUPS = 100_000\n\n/**\n * Single-field spelling of `canonicalGroupKey` (`with-lookup/reduce/canonical-key.ts`).\n *\n * ⛔ Inlined, not imported, and not by preference: `check-architecture`'s\n * `port-layering` rule grandfathers this file for exactly two\n * `with-lookup/reduce/*` specifiers (`reducers.js`, `reduction.js`), and\n * `canonical-key.js` is not one of them — a new one may not be added\n * silently. The eager helper sorts its field list and serialises\n * each value — with exactly one field, that reduces to this line, including\n * the part that matters: `undefined` gets a sentinel so a MISSING key and an\n * explicit `null` land in different buckets, as they do under\n * `Query.groupBy()`. The agreement is held by test, not by comment\n * (`query-scan-groupby.test.ts` — null/undefined bucketing, and full equality\n * with the eager path).\n */\nfunction scanGroupKey(field: string, value: unknown): string {\n return `${field}=${value === undefined ? 'undefined' : JSON.stringify(value)}`\n}\n\n/** Group-key result-row shape: the key under its own name, plus the reducers. */\n\nexport type ScanGroupedRow<F extends string, R> = { [K in F]: unknown } & R\n\n/**\n * Chainable wrapper returned by `ScanBuilder.groupBy()`. The only operation on\n * it is `.aggregate()` — same minimal shape as `GroupedQuery`.\n */\nexport class ScanGroupedScan<\n T,\n F extends string,\n S extends keyof T = never,\n M extends keyof T & string = never,\n> {\n constructor(\n private readonly stream: AsyncIterable<T>,\n private readonly key: string | DateTruncKey,\n private readonly maxGroups: number,\n private readonly via: ViaPipeline | undefined,\n ) {\n if (!Number.isInteger(maxGroups) || maxGroups < 1) {\n throw new Error(\n `scan().groupBy(): { maxGroups: ${String(maxGroups)} } must be a positive integer — ` +\n `it is the declared ceiling on how many reducer states the grouped scan may hold.`,\n )\n }\n }\n\n /**\n * Fold the scan into one row per group. Resolves to `R[]`, ordered by each\n * group's FIRST-SEEN position in the stream (`Map` insertion order), which\n * is the same ordering rule the eager path documents.\n *\n * ```ts\n * const byMonth = await invoices.scan()\n * .where('status', '==', 'paid')\n * .groupBy(dateTrunc('closedAt', 'month', { as: 'month', timeZone: 'UTC' }), { maxGroups: 240 })\n * .aggregate({ total: sum('amount'), n: count() })\n * ```\n */\n async aggregate<Spec extends ReduceSpec>(spec: Spec): Promise<ScanGroupedRow<F, ReduceResult<Spec>>[]>\n async aggregate<Spec extends ReduceSpec>(\n build: (b: ReducerBuilder<T, S, M>) => Spec,\n ): Promise<ScanGroupedRow<F, ReduceResult<Spec>>[]>\n async aggregate<Spec extends ReduceSpec>(\n specOrBuild: Spec | ((b: ReducerBuilder<T, S, M>) => Spec),\n ): Promise<ScanGroupedRow<F, ReduceResult<Spec>>[]> {\n const raw: Spec =\n typeof specOrBuild === 'function'\n ? (specOrBuild as (b: ReducerBuilder<T, S, M>) => Spec)(reducerBuilder as unknown as ReducerBuilder<T, S, M>)\n : specOrBuild\n // Same reducer rewriting as the eager grouped path, and for the same\n // reason: a money `sum` must accumulate per-currency BigInt totals, and a\n // `countDistinct` must dedup on the canonical index key — otherwise a\n // grouped scan and a grouped query disagree on identical data.\n // `wrapReducers` runs the `queryable: 'none'` posture refusal itself.\n const spec: ReduceSpec = bindDistinctReducers(this.via ? this.via.wrapReducers(raw) : raw, this.via)\n const keys = Object.keys(spec)\n\n const field = groupKeyName(this.key)\n const derived: readonly DateTruncKey[] = isDateTruncKey(this.key) ? [this.key] : []\n const groups = new Map<string, { keyValue: unknown; state: Record<string, unknown> }>()\n\n for await (const record of this.stream) {\n // A derived calendar key is stamped onto a shallow copy before bucketing\n // — the reducers then see an ordinary row carrying an ordinary field,\n // exactly as they do under `Query.groupBy(dateTrunc(...))`.\n const row = derived.length === 0 ? record : projectDateTruncKeys([record], derived)[0]!\n const keyValue = readPath(row, field)\n const dedupKey = scanGroupKey(field, keyValue)\n let group = groups.get(dedupKey)\n if (group === undefined) {\n if (groups.size >= this.maxGroups) {\n // Loud and early: the state for this group is never allocated, so\n // the refusal fires at the budget, not after blowing through it.\n throw new GroupCardinalityError(field, groups.size + 1, this.maxGroups, 'scan')\n }\n const state: Record<string, unknown> = {}\n for (const k of keys) state[k] = spec[k]!.init()\n group = { keyValue, state }\n groups.set(dedupKey, group)\n }\n for (const k of keys) group.state[k] = spec[k]!.step(group.state[k], row)\n }\n\n const out: ScanGroupedRow<F, ReduceResult<Spec>>[] = []\n for (const group of groups.values()) {\n // Group key first, then the reducer outputs — same row shape as the\n // eager path, which tests assert by key order.\n const outRow: Record<string, unknown> = { [field]: group.keyValue }\n for (const k of keys) outRow[k] = spec[k]!.finalize(group.state[k])\n out.push(outRow as ScanGroupedRow<F, ReduceResult<Spec>>)\n }\n return out\n }\n}\n","/**\n * #1458 — the Reduce install. See `../relate/install.ts` for why this is a\n * function called from the entry rather than a module-level side effect.\n */\nimport { Query } from '../builder.js'\nimport { ScanBuilder } from '../scan-builder.js'\nimport { installMethods } from '../internal/core.js'\nimport { MaintenanceMethods } from '../internal/maintenance.js'\nimport { ReduceMethods } from './methods.js'\nimport { ScanReduceMethods } from './scan-methods.js'\n\nlet done = false\n\n/** Idempotent: the root barrel and the subpath entry both call it. */\nexport function installReduce(): void {\n if (done) return\n done = true\n installMethods(Query.prototype, MaintenanceMethods)\n installMethods(Query.prototype, ReduceMethods)\n installMethods(ScanBuilder.prototype, ScanReduceMethods)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqEA,SAAS,YAAY,OAAe,MAAc,OAAmC;AACnF,QAAM,QAAQ,CAAC,WACb,WAAW,QAAQ,OAAO,WAAW,WAAW,SAAa,OAAmC,KAAK;AACvG,SAAO;AAAA,IACL,GAAG;AAAA;AAAA;AAAA,IAGH,OAAO;AAAA,IACP,MAAM,MAAM,MAAM,KAAK;AAAA,IACvB,MAAM,CAAC,O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Y,WAAW,iBAAiB;AACzD;","names":[]}
|
|
@@ -7,28 +7,28 @@ import {
|
|
|
7
7
|
deriveSchemaManifest,
|
|
8
8
|
loadSchemaManifestEntry,
|
|
9
9
|
saveSchemaManifest
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-T5EXREMW.js";
|
|
11
11
|
import {
|
|
12
12
|
MANIFEST_COLLECTION
|
|
13
13
|
} from "./chunk-EPFF7LOX.js";
|
|
14
14
|
import {
|
|
15
15
|
loadFence,
|
|
16
16
|
saveFence
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-TLIFNRU5.js";
|
|
18
18
|
import {
|
|
19
19
|
derivePersistedSchema
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-UORWAG7K.js";
|
|
21
21
|
import {
|
|
22
22
|
loadPersistedSchemaEntry,
|
|
23
23
|
savePersistedSchema
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-IF2M43G4.js";
|
|
25
25
|
import {
|
|
26
26
|
envelopePayloadHash
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-QHG7GQKM.js";
|
|
28
28
|
import {
|
|
29
29
|
ManifestConflictError,
|
|
30
30
|
isConflictError
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-IKPQ2GGB.js";
|
|
32
32
|
|
|
33
33
|
// src/with-shape/persisted-schemas/field-ids.ts
|
|
34
34
|
var BASE32URL_ALPHABET = "abcdefghijklmnopqrstuvwxyz234567";
|
|
@@ -257,4 +257,4 @@ export {
|
|
|
257
257
|
persistClassifiedMarker,
|
|
258
258
|
persistSatelliteMarker
|
|
259
259
|
};
|
|
260
|
-
//# sourceMappingURL=chunk-
|
|
260
|
+
//# sourceMappingURL=chunk-BJRKXNFP.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DerivationCapExceededError,
|
|
3
3
|
DerivationOutputShapeError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-IKPQ2GGB.js";
|
|
5
5
|
|
|
6
6
|
// src/with-formula/derivations/executor.ts
|
|
7
7
|
var DerivationExecutor = {
|
|
@@ -121,4 +121,4 @@ var DerivationExecutor = {
|
|
|
121
121
|
export {
|
|
122
122
|
DerivationExecutor
|
|
123
123
|
};
|
|
124
|
-
//# sourceMappingURL=chunk-
|
|
124
|
+
//# sourceMappingURL=chunk-BPQ5CRJF.js.map
|
|
@@ -3,14 +3,14 @@ import {
|
|
|
3
3
|
buildRecordEnvelope,
|
|
4
4
|
encrypt,
|
|
5
5
|
openEnvelopeJson
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-WRLWEYHY.js";
|
|
7
7
|
import {
|
|
8
8
|
SequenceContentionError,
|
|
9
9
|
SequenceNotEnabledError,
|
|
10
10
|
SequenceOfflineError,
|
|
11
11
|
ValidationError,
|
|
12
12
|
isConflictError
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-IKPQ2GGB.js";
|
|
14
14
|
|
|
15
15
|
// src/with-commit/sequence/active.ts
|
|
16
16
|
function withSequence() {
|
|
@@ -197,4 +197,4 @@ export {
|
|
|
197
197
|
resolveSequenceKey,
|
|
198
198
|
SequenceStore
|
|
199
199
|
};
|
|
200
|
-
//# sourceMappingURL=chunk-
|
|
200
|
+
//# sourceMappingURL=chunk-BVRJYMFZ.js.map
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
dictCollectionName
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-KZA3DITX.js";
|
|
4
4
|
import {
|
|
5
5
|
getAtPath,
|
|
6
6
|
presentI18nForJoin
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-PR7ILCIH.js";
|
|
8
8
|
import {
|
|
9
9
|
UnknownDictCodeError,
|
|
10
10
|
ValidationError
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-IKPQ2GGB.js";
|
|
12
12
|
|
|
13
13
|
// src/via/lookup/registry.ts
|
|
14
14
|
function enforceStaticDictOnPut(staticFields, record) {
|
|
@@ -320,4 +320,4 @@ export {
|
|
|
320
320
|
buildPresentForJoin,
|
|
321
321
|
isLookupDescriptor
|
|
322
322
|
};
|
|
323
|
-
//# sourceMappingURL=chunk-
|
|
323
|
+
//# sourceMappingURL=chunk-C4XV3PSJ.js.map
|