@noy-db/hub 0.7.1-pre.0 → 0.8.0
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 +147 -14
- package/LICENSE +202 -21
- package/NOTICE +1 -0
- package/README.md +5 -5
- package/codemods/0.8.0-pre.json +61 -0
- package/dist/api-OS747DS4.js +18 -0
- package/dist/as/index.js +11 -12
- package/dist/as/index.js.map +1 -1
- package/dist/at/index.js +9 -10
- package/dist/attestation/index.js +37 -26
- package/dist/attestation/index.js.map +1 -1
- package/dist/{backup-XKCXVKV3.js → backup-YE2VQ26S.js} +15 -16
- package/dist/backup-YE2VQ26S.js.map +1 -0
- package/dist/blobs/index.js +13 -14
- package/dist/blobs/index.js.map +1 -1
- package/dist/broker/index.js +12 -13
- package/dist/broker/index.js.map +1 -1
- package/dist/by/index.js +2 -2
- package/dist/capsule/contract.d.ts +159 -0
- package/dist/capsule/contract.js +95 -0
- package/dist/capsule/enclave-aes/bound.d.ts +52 -0
- package/dist/capsule/enclave-aes/capabilities.d.ts +2 -0
- package/dist/capsule/enclave-aes/classify/compare.d.ts +20 -0
- package/dist/{kernel/enclave → capsule/enclave-aes}/classify/find.d.ts +1 -1
- package/dist/{kernel/enclave → capsule/enclave-aes}/classify/reveal.d.ts +1 -1
- package/dist/{kernel/enclave → capsule/enclave-aes}/classify/verify.d.ts +2 -2
- package/dist/{kernel/enclave → capsule/enclave-aes}/classify/write.d.ts +1 -1
- package/dist/{kernel/enclave → capsule/enclave-aes}/crypto.d.ts +33 -129
- package/dist/capsule/enclave-aes/index.d.ts +113 -0
- package/dist/capsule/enclave-aes/index.js +335 -0
- package/dist/capsule/enclave-aes/index.js.map +1 -0
- package/dist/capsule/enclave-aes/primitives.d.ts +29 -0
- package/dist/capsule/index.d.ts +27 -0
- package/dist/capsule/plumbing/ct-equal.d.ts +11 -0
- package/dist/{kernel/enclave/record-keys → capsule/plumbing}/deterministic.d.ts +8 -21
- package/dist/capsule/plumbing/digest.d.ts +122 -0
- package/dist/{kernel/enclave/record-keys → capsule/plumbing}/envelope-body.d.ts +44 -48
- package/dist/capsule/plumbing/index.d.ts +100 -0
- package/dist/capsule/plumbing/lifecycle.d.ts +50 -0
- package/dist/{kernel/enclave/record-keys → capsule/plumbing}/record-codec.d.ts +80 -20
- package/dist/{kernel/enclave → capsule/plumbing}/record-envelope.d.ts +1 -1
- package/dist/capsule/plumbing/rekey-blob.d.ts +33 -0
- package/dist/capsule/plumbing/rekey.d.ts +44 -0
- package/dist/capsule/plumbing/sealed-slot.d.ts +22 -0
- package/dist/capsule/plumbing/sealed-slots.d.ts +37 -0
- package/dist/capsule/plumbing/sealing.d.ts +29 -0
- package/dist/capsule/plumbing/sign.d.ts +9 -0
- package/dist/{kernel/enclave/record-keys → capsule/plumbing}/tombstone.d.ts +2 -2
- package/dist/capsule-VOLX3QRQ.js +209 -0
- package/dist/cargo/index.js +39 -36
- package/dist/{chunk-Q2MPFCQ7.js → chunk-23D6M6VM.js} +5 -5
- package/dist/chunk-23D6M6VM.js.map +1 -0
- package/dist/{chunk-R7BX2NB3.js → chunk-244QBK7Z.js} +4 -4
- package/dist/chunk-244QBK7Z.js.map +1 -0
- package/dist/chunk-2AFX33YA.js +936 -0
- package/dist/chunk-2AFX33YA.js.map +1 -0
- package/dist/{chunk-MVMXZYXT.js → chunk-2GHDLTPE.js} +2 -2
- package/dist/{chunk-GYGLAVCX.js → chunk-2MG3SW7Q.js} +6 -2
- package/dist/chunk-2MG3SW7Q.js.map +1 -0
- package/dist/{chunk-XLMEZIAJ.js → chunk-2ODVB6LZ.js} +2 -2
- package/dist/{chunk-HJUWN7JN.js → chunk-2PVXF5CS.js} +33 -8
- package/dist/chunk-2PVXF5CS.js.map +1 -0
- package/dist/{chunk-YJRT5UQM.js → chunk-2RH777HH.js} +21 -20
- package/dist/{chunk-YJRT5UQM.js.map → chunk-2RH777HH.js.map} +1 -1
- package/dist/{chunk-7O3Y4PPD.js → chunk-37EPTBBR.js} +153 -16
- package/dist/chunk-37EPTBBR.js.map +1 -0
- package/dist/{chunk-2ENE6445.js → chunk-3A5DUZ56.js} +102 -16
- package/dist/chunk-3A5DUZ56.js.map +1 -0
- package/dist/chunk-3EWS67C7.js +461 -0
- package/dist/chunk-3EWS67C7.js.map +1 -0
- package/dist/{chunk-SGZAIJCV.js → chunk-3L2NBKDR.js} +4 -8
- package/dist/chunk-3L2NBKDR.js.map +1 -0
- package/dist/{chunk-YMUFFJCO.js → chunk-3TDUWVWB.js} +5 -2
- package/dist/chunk-3TDUWVWB.js.map +1 -0
- package/dist/{chunk-4GVM6QZA.js → chunk-3XJQBBZD.js} +26 -28
- package/dist/chunk-3XJQBBZD.js.map +1 -0
- package/dist/{chunk-4ZS56W5S.js → chunk-42ALPZ2B.js} +672 -664
- package/dist/chunk-42ALPZ2B.js.map +1 -0
- package/dist/chunk-4CIQDWRB.js +524 -0
- package/dist/chunk-4CIQDWRB.js.map +1 -0
- package/dist/{chunk-RMS3NEA3.js → chunk-4JPMZTJY.js} +2 -2
- package/dist/{chunk-P3MG6QCN.js → chunk-4T3SE27M.js} +5 -9
- package/dist/chunk-4T3SE27M.js.map +1 -0
- package/dist/chunk-4V3Q35WG.js +204 -0
- package/dist/chunk-4V3Q35WG.js.map +1 -0
- package/dist/{chunk-NQKIUNW5.js → chunk-52MGURXO.js} +2 -2
- package/dist/{chunk-EQEYOJBM.js → chunk-5A4345TG.js} +4 -4
- package/dist/chunk-5A4345TG.js.map +1 -0
- package/dist/{chunk-334WSVOW.js → chunk-5FE75J4S.js} +6 -6
- package/dist/chunk-5FE75J4S.js.map +1 -0
- package/dist/chunk-5KC7QYEC.js +565 -0
- package/dist/chunk-5KC7QYEC.js.map +1 -0
- package/dist/{chunk-RSGLUIO6.js → chunk-5UMK7GRI.js} +13 -12
- package/dist/chunk-5UMK7GRI.js.map +1 -0
- package/dist/chunk-5WWDGFOS.js +275 -0
- package/dist/chunk-5WWDGFOS.js.map +1 -0
- package/dist/{chunk-QPQUVOZ2.js → chunk-6QVKPHBF.js} +3 -5
- package/dist/chunk-6QVKPHBF.js.map +1 -0
- package/dist/{chunk-ACAQ2DSG.js → chunk-747G6CT3.js} +2 -2
- package/dist/chunk-747G6CT3.js.map +1 -0
- package/dist/{chunk-QTQUH4DS.js → chunk-7R2Q7CPL.js} +16 -16
- package/dist/chunk-7R2Q7CPL.js.map +1 -0
- package/dist/{chunk-UGTBXF5U.js → chunk-7XMHMVTS.js} +3 -3
- package/dist/{chunk-YJX7EOJD.js → chunk-A4XMIZT3.js} +6 -6
- package/dist/{chunk-YJX7EOJD.js.map → chunk-A4XMIZT3.js.map} +1 -1
- package/dist/{chunk-A66I4JOA.js → chunk-AEQGFRU4.js} +4 -4
- package/dist/chunk-AEQGFRU4.js.map +1 -0
- package/dist/chunk-AL6ML4LA.js +1558 -0
- package/dist/chunk-AL6ML4LA.js.map +1 -0
- package/dist/{chunk-BZ3534YM.js → chunk-AUKKUPVB.js} +2 -2
- package/dist/{chunk-CUZLNGD5.js → chunk-B2YY6WDD.js} +1 -1
- package/dist/chunk-B2YY6WDD.js.map +1 -0
- package/dist/chunk-BKT776R5.js +1 -0
- package/dist/chunk-BNWA3WG5.js +22 -0
- package/dist/chunk-BNWA3WG5.js.map +1 -0
- package/dist/{chunk-VXANTWBJ.js → chunk-BPWYQ25R.js} +92 -6
- package/dist/{chunk-VXANTWBJ.js.map → chunk-BPWYQ25R.js.map} +1 -1
- package/dist/{chunk-6LKOJBV6.js → chunk-BVCUTXE3.js} +2 -2
- package/dist/chunk-CY2CYVWZ.js +41 -0
- package/dist/chunk-CY2CYVWZ.js.map +1 -0
- package/dist/{chunk-M4YPHYEH.js → chunk-DHHGL42E.js} +70 -25
- package/dist/chunk-DHHGL42E.js.map +1 -0
- package/dist/{chunk-VTFVLCUH.js → chunk-DIZLQVAA.js} +2 -2
- package/dist/{chunk-G73UVHCA.js → chunk-DLD5LGDS.js} +11 -12
- package/dist/chunk-DLD5LGDS.js.map +1 -0
- package/dist/{chunk-WQBG4SZS.js → chunk-DQESF6RP.js} +60 -49
- package/dist/chunk-DQESF6RP.js.map +1 -0
- package/dist/{chunk-LWBCUYZW.js → chunk-E2N2T5ZO.js} +2 -2
- package/dist/{chunk-3PGS7TYR.js → chunk-EGVJ7TM4.js} +29 -32
- package/dist/chunk-EGVJ7TM4.js.map +1 -0
- package/dist/{chunk-JVIBCBC7.js → chunk-EJLV62NI.js} +2 -2
- package/dist/{chunk-KKEESNPE.js → chunk-EYG2CY2X.js} +126 -19
- package/dist/chunk-EYG2CY2X.js.map +1 -0
- package/dist/{enclave-55PAM4YO.js → chunk-EZGV6F47.js} +83 -56
- package/dist/chunk-EZGV6F47.js.map +1 -0
- package/dist/{chunk-CHQCZZWC.js → chunk-EZOAKKTB.js} +36 -27
- package/dist/chunk-EZOAKKTB.js.map +1 -0
- package/dist/chunk-F6NCB7KT.js +13 -0
- package/dist/chunk-F6NCB7KT.js.map +1 -0
- package/dist/chunk-FFJFE4T7.js +100 -0
- package/dist/chunk-FFJFE4T7.js.map +1 -0
- package/dist/{chunk-JMGDHKQF.js → chunk-FLPCETP6.js} +2 -2
- package/dist/chunk-FOEDQATO.js +53 -0
- package/dist/chunk-FOEDQATO.js.map +1 -0
- package/dist/{chunk-DGOZ4UZD.js → chunk-FVH5QYY2.js} +2 -2
- package/dist/{chunk-HIWCKBEY.js → chunk-G2MVBDFP.js} +54 -28
- package/dist/chunk-G2MVBDFP.js.map +1 -0
- package/dist/chunk-GMKGGY7V.js +234 -0
- package/dist/chunk-GMKGGY7V.js.map +1 -0
- package/dist/{chunk-EIPVYUEP.js → chunk-GQ4MF3CM.js} +3 -3
- package/dist/chunk-GQ4MF3CM.js.map +1 -0
- package/dist/{chunk-PEOZ34EM.js → chunk-GSAK56VF.js} +1 -1
- package/dist/chunk-GSAK56VF.js.map +1 -0
- package/dist/{chunk-5VCRVKOZ.js → chunk-GUZET4SG.js} +12 -4
- package/dist/chunk-GUZET4SG.js.map +1 -0
- package/dist/{chunk-JBDFMYKQ.js → chunk-GZT3NQRA.js} +2 -2
- package/dist/{chunk-K23VKTN4.js → chunk-H23XHRTT.js} +19 -34
- package/dist/chunk-H23XHRTT.js.map +1 -0
- package/dist/{chunk-TFR7DSOV.js → chunk-H427H63K.js} +2 -2
- package/dist/{chunk-DFMWUOU5.js → chunk-H7JBY4P7.js} +23 -32
- package/dist/chunk-H7JBY4P7.js.map +1 -0
- package/dist/{chunk-SKGMN35F.js → chunk-HS554XAF.js} +3 -3
- package/dist/chunk-HS554XAF.js.map +1 -0
- package/dist/{chunk-HK67PX4J.js → chunk-HW7CMKUG.js} +1 -1
- package/dist/chunk-HW7CMKUG.js.map +1 -0
- package/dist/{chunk-3BVH633C.js → chunk-IMQKWR46.js} +5 -7
- package/dist/chunk-IMQKWR46.js.map +1 -0
- package/dist/{chunk-R42NSZI6.js → chunk-IUBMZPHM.js} +7 -7
- package/dist/chunk-IUBMZPHM.js.map +1 -0
- package/dist/{chunk-CUQPWYRX.js → chunk-IUT3GWP3.js} +75 -386
- package/dist/chunk-IUT3GWP3.js.map +1 -0
- package/dist/{chunk-RF6D3Y5E.js → chunk-JDEYF3PJ.js} +4 -8
- package/dist/{chunk-RF6D3Y5E.js.map → chunk-JDEYF3PJ.js.map} +1 -1
- package/dist/{chunk-PPTHY5QO.js → chunk-JIBUPZHA.js} +99 -8
- package/dist/chunk-JIBUPZHA.js.map +1 -0
- package/dist/{chunk-SMH6SRX7.js → chunk-JOSPH3E5.js} +2 -2
- package/dist/chunk-JQYKPKG6.js +193 -0
- package/dist/chunk-JQYKPKG6.js.map +1 -0
- package/dist/{chunk-7APJ6CO6.js → chunk-JSMTXZR3.js} +45 -13
- package/dist/chunk-JSMTXZR3.js.map +1 -0
- package/dist/chunk-JWWYRR4Q.js +12 -0
- package/dist/chunk-JWWYRR4Q.js.map +1 -0
- package/dist/{chunk-BVN6KXL2.js → chunk-KZXDLBY6.js} +14 -9
- package/dist/chunk-KZXDLBY6.js.map +1 -0
- package/dist/chunk-LGNDFRYC.js +23 -0
- package/dist/chunk-LGNDFRYC.js.map +1 -0
- package/dist/{chunk-XKWGNJ26.js → chunk-LIOVX5TJ.js} +7 -11
- package/dist/chunk-LIOVX5TJ.js.map +1 -0
- package/dist/{chunk-AYX7AINO.js → chunk-LNSVGRHO.js} +5 -7
- package/dist/chunk-LNSVGRHO.js.map +1 -0
- package/dist/chunk-M5B2W6YY.js +293 -0
- package/dist/chunk-M5B2W6YY.js.map +1 -0
- package/dist/chunk-MBMTND6D.js +456 -0
- package/dist/chunk-MBMTND6D.js.map +1 -0
- package/dist/{chunk-3BZZJJMQ.js → chunk-MILI22XQ.js} +3 -3
- package/dist/{chunk-A2HKRLPV.js → chunk-MXKI4ABF.js} +18 -59
- package/dist/chunk-MXKI4ABF.js.map +1 -0
- package/dist/{chunk-ZYIYHJ5R.js → chunk-MXOQ5JCG.js} +869 -238
- package/dist/chunk-MXOQ5JCG.js.map +1 -0
- package/dist/{chunk-V7ZRRCRJ.js → chunk-N7EVQD5S.js} +9 -13
- package/dist/chunk-N7EVQD5S.js.map +1 -0
- package/dist/chunk-N7UDP5VU.js +757 -0
- package/dist/chunk-N7UDP5VU.js.map +1 -0
- package/dist/chunk-NBQ3KK6X.js +270 -0
- package/dist/chunk-NBQ3KK6X.js.map +1 -0
- package/dist/{chunk-ZORTV6NH.js → chunk-NCO25JZO.js} +88 -4
- package/dist/chunk-NCO25JZO.js.map +1 -0
- package/dist/chunk-NH2UOV3B.js +18 -0
- package/dist/chunk-NH2UOV3B.js.map +1 -0
- package/dist/chunk-NYMLINRP.js +28 -0
- package/dist/chunk-NYMLINRP.js.map +1 -0
- package/dist/{chunk-YYP7WSEB.js → chunk-O2IMQSNA.js} +2 -2
- package/dist/chunk-O46CHQT7.js +215 -0
- package/dist/chunk-O46CHQT7.js.map +1 -0
- package/dist/chunk-OIEO4WDL.js +27 -0
- package/dist/chunk-OIEO4WDL.js.map +1 -0
- package/dist/{chunk-TRGTKX5E.js → chunk-OKSTSITU.js} +27 -4
- package/dist/chunk-OKSTSITU.js.map +1 -0
- package/dist/chunk-OYW3I5M4.js +31 -0
- package/dist/chunk-OYW3I5M4.js.map +1 -0
- package/dist/{chunk-Q7HZX3IF.js → chunk-PD64727P.js} +2 -2
- package/dist/chunk-PD64727P.js.map +1 -0
- package/dist/{chunk-FET5XCAT.js → chunk-PP3K67AJ.js} +34 -6
- package/dist/chunk-PP3K67AJ.js.map +1 -0
- package/dist/chunk-Q2XRFWOI.js +40 -0
- package/dist/chunk-Q2XRFWOI.js.map +1 -0
- package/dist/{chunk-QIZPZMUI.js → chunk-Q4UHJ5SN.js} +2 -2
- package/dist/{chunk-FAHMLERK.js → chunk-QBLT6POL.js} +2 -2
- package/dist/chunk-QMWY2FDS.js +157 -0
- package/dist/chunk-QMWY2FDS.js.map +1 -0
- package/dist/{chunk-LH5A3ZPG.js → chunk-RB4DOPGZ.js} +150 -22
- package/dist/chunk-RB4DOPGZ.js.map +1 -0
- package/dist/chunk-RHVMZSUU.js +7 -0
- package/dist/chunk-RHVMZSUU.js.map +1 -0
- package/dist/{chunk-BUE2D7PX.js → chunk-SMV2HRDU.js} +2 -2
- package/dist/chunk-SUZKW6UR.js +25 -0
- package/dist/chunk-SUZKW6UR.js.map +1 -0
- package/dist/{chunk-7MG7SJT7.js → chunk-SV2PM2OY.js} +1 -1
- package/dist/chunk-SV2PM2OY.js.map +1 -0
- package/dist/{chunk-UXVWEX5L.js → chunk-SYNY3VB5.js} +6 -2
- package/dist/chunk-SYNY3VB5.js.map +1 -0
- package/dist/{chunk-4GFX6MPA.js → chunk-TEHHROZL.js} +6 -8
- package/dist/chunk-TEHHROZL.js.map +1 -0
- package/dist/chunk-TKVUE4JF.js +1289 -0
- package/dist/chunk-TKVUE4JF.js.map +1 -0
- package/dist/{chunk-SFAWCTEM.js → chunk-TZZBXPZK.js} +2 -2
- package/dist/{chunk-F3W6YMDC.js → chunk-U2FZNEWJ.js} +4 -4
- package/dist/chunk-U2FZNEWJ.js.map +1 -0
- package/dist/{chunk-BLN54W3L.js → chunk-UA372JHH.js} +56 -3
- package/dist/chunk-UA372JHH.js.map +1 -0
- package/dist/{chunk-6YXCPL4T.js → chunk-UEFOQH74.js} +2 -2
- package/dist/chunk-UEFOQH74.js.map +1 -0
- package/dist/{chunk-2N5ML6HT.js → chunk-UIYESRD6.js} +9 -11
- package/dist/chunk-UIYESRD6.js.map +1 -0
- package/dist/{chunk-UHHPLO3I.js → chunk-V3RWOOSO.js} +4 -4
- package/dist/{chunk-KTFRCC5C.js → chunk-V7ADQF5O.js} +82 -8
- package/dist/chunk-V7ADQF5O.js.map +1 -0
- package/dist/{chunk-453F654R.js → chunk-VAORSCSU.js} +3 -3
- package/dist/chunk-VAORSCSU.js.map +1 -0
- package/dist/{chunk-GPNTB4Y7.js → chunk-VFHCKG5M.js} +6 -10
- package/dist/chunk-VFHCKG5M.js.map +1 -0
- package/dist/{chunk-2577DKXB.js → chunk-VHBKYN2J.js} +3 -3
- package/dist/chunk-VHBKYN2J.js.map +1 -0
- package/dist/chunk-VHM7HCKB.js +220 -0
- package/dist/chunk-VHM7HCKB.js.map +1 -0
- package/dist/{chunk-ZHKOPKE3.js → chunk-VKI2EB3N.js} +3 -3
- package/dist/chunk-VKI2EB3N.js.map +1 -0
- package/dist/{chunk-UDHWDSRL.js → chunk-VMV5SBE4.js} +16 -17
- package/dist/chunk-VMV5SBE4.js.map +1 -0
- package/dist/{chunk-SPYWXKJN.js → chunk-VQDZYB2B.js} +3 -3
- package/dist/chunk-VQDZYB2B.js.map +1 -0
- package/dist/{chunk-Q2PU57HC.js → chunk-VVOLDVIR.js} +2 -2
- package/dist/{chunk-3VF3WQ4F.js → chunk-WPOYWFSE.js} +7 -7
- package/dist/{chunk-3VF3WQ4F.js.map → chunk-WPOYWFSE.js.map} +1 -1
- package/dist/{chunk-OTQZ7ZWU.js → chunk-WXE4W2U6.js} +7 -11
- package/dist/chunk-WXE4W2U6.js.map +1 -0
- package/dist/chunk-XBKH4FOC.js +195 -0
- package/dist/chunk-XBKH4FOC.js.map +1 -0
- package/dist/{chunk-TUFM4UZP.js → chunk-XQRFSKYM.js} +2 -2
- package/dist/{chunk-3V4KWFX7.js → chunk-XSPFDUDG.js} +58 -53
- package/dist/chunk-XSPFDUDG.js.map +1 -0
- package/dist/{chunk-GY4WYNNG.js → chunk-Y2RKVFKR.js} +2 -2
- package/dist/{chunk-UP4BECPY.js → chunk-Y3LPTBG7.js} +89 -27
- package/dist/chunk-Y3LPTBG7.js.map +1 -0
- package/dist/{chunk-4OZNXTO4.js → chunk-YRXFFWG4.js} +2 -2
- package/dist/classified/index.js +5 -5
- package/dist/{classified-marker-BWOFVYAC.js → classified-marker-SIYKUU5L.js} +3 -3
- package/dist/classified-marker-SIYKUU5L.js.map +1 -0
- package/dist/collection-facade-CS7CA2XO.js +47 -0
- package/dist/{computed-VPOKQK4N.js → computed-FAD7SED4.js} +3 -3
- package/dist/consent/index.js +10 -11
- package/dist/consent/index.js.map +1 -1
- package/dist/cover/index.js +10 -11
- package/dist/coverage/index.js +306 -0
- package/dist/coverage/index.js.map +1 -0
- package/dist/custody/index.js +12 -13
- package/dist/{dead-filter-PKQDLOT4.js → dead-filter-4F3LWYKH.js} +11 -3
- package/dist/dead-filter-4F3LWYKH.js.map +1 -0
- package/dist/debug/index.js +11 -2
- package/dist/debug/index.js.map +1 -1
- package/dist/{delegation-DS5NRILW.js → delegation-NANZDG4N.js} +13 -16
- package/dist/delegation-NANZDG4N.js.map +1 -0
- package/dist/derivations/index.js +25 -23
- package/dist/derive-XLOJVXPU.js +20 -0
- package/dist/directory/index.js +10 -11
- package/dist/{dispatch-IEPAVQUM.js → dispatch-H4HV32AM.js} +5 -5
- package/dist/{dispatch-Q6MWLOJY.js → dispatch-JDZNGEB3.js} +20 -21
- package/dist/dispatch-JDZNGEB3.js.map +1 -0
- package/dist/executor-FMPVN6DT.js +35 -0
- package/dist/executor-LBBBRTN5.js +8 -0
- package/dist/executor-OSRZST2U.js +8 -0
- package/dist/export-accessible-RAOJAAU5.js +22 -0
- package/dist/extract-partition-JD5CUSTG.js +37 -0
- package/dist/{fanout-sidecar-S3QL53YX.js → fanout-sidecar-L7NHPIOC.js} +13 -15
- package/dist/fanout-sidecar-L7NHPIOC.js.map +1 -0
- package/dist/find-JRN4RNQ5.js +10 -0
- package/dist/forget/index.js +9 -10
- package/dist/forget/index.js.map +1 -1
- package/dist/guards/index.js +4 -4
- package/dist/history/index.js +13 -14
- package/dist/history/index.js.map +1 -1
- package/dist/i18n/index.js +14 -15
- package/dist/i18n/index.js.map +1 -1
- package/dist/index.d.ts +36 -14
- package/dist/index.js +970 -163
- package/dist/index.js.map +1 -1
- package/dist/indexing/index.js +13 -5
- package/dist/indexing/index.js.map +1 -1
- package/dist/introspection/index.js +11 -12
- package/dist/issue-YIVBZUTH.js +19 -0
- package/dist/ivf-flat-UZ6DQDLS.js +314 -0
- package/dist/ivf-flat-UZ6DQDLS.js.map +1 -0
- package/dist/{json-schema-V3M5MUCM.js → json-schema-3SHX72CC.js} +2 -1
- package/dist/json-schema-3SHX72CC.js.map +1 -0
- package/dist/kernel/attestation-types.d.ts +62 -0
- package/dist/kernel/collection-config.d.ts +5 -68
- package/dist/kernel/collection.d.ts +30 -9
- package/dist/kernel/cutover-transform.d.ts +1 -1
- package/dist/kernel/errors.d.ts +257 -38
- package/dist/kernel/generation-map.d.ts +48 -0
- package/dist/kernel/merge-authority.d.ts +1 -1
- package/dist/kernel/noydb.d.ts +6 -1
- package/dist/kernel/paths.d.ts +29 -5
- package/dist/kernel/prepared-write.d.ts +1 -1
- package/dist/kernel/present-cache.d.ts +58 -0
- package/dist/kernel/query/all.d.ts +7 -0
- package/dist/kernel/query/builder.d.ts +601 -270
- package/dist/kernel/query/civil-date.d.ts +64 -0
- package/dist/kernel/query/cursor.d.ts +40 -0
- package/dist/kernel/query/distinct-key.d.ts +98 -0
- package/dist/kernel/query/hydration.d.ts +76 -0
- package/dist/kernel/query/index.d.ts +31 -15
- package/dist/kernel/query/internal/core.d.ts +30 -0
- package/dist/kernel/query/internal/hooks.d.ts +22 -0
- package/dist/kernel/query/internal/maintenance.d.ts +43 -0
- package/dist/kernel/query/live/incremental.d.ts +314 -0
- package/dist/kernel/query/live/index.d.ts +22 -0
- package/dist/kernel/query/live/install.d.ts +2 -0
- package/dist/kernel/query/{live.d.ts → live/live.d.ts} +39 -9
- package/dist/kernel/query/live/methods.d.ts +107 -0
- package/dist/kernel/query/predicate.d.ts +119 -1
- package/dist/kernel/query/reduce/date-trunc.d.ts +75 -0
- package/dist/kernel/query/reduce/index.d.ts +36 -0
- package/dist/kernel/query/reduce/install.d.ts +2 -0
- package/dist/kernel/query/reduce/methods.d.ts +259 -0
- package/dist/kernel/query/reduce/scan-methods.d.ts +121 -0
- package/dist/kernel/query/relate/explain.d.ts +199 -0
- package/dist/kernel/query/relate/index.d.ts +48 -0
- package/dist/kernel/query/relate/install.d.ts +2 -0
- package/dist/kernel/query/relate/join-on.d.ts +126 -0
- package/dist/kernel/query/relate/join-reduce.d.ts +16 -0
- package/dist/kernel/query/relate/join.d.ts +452 -0
- package/dist/kernel/query/relate/methods.d.ts +426 -0
- package/dist/kernel/query/relate/partition.d.ts +87 -0
- package/dist/kernel/query/relate/scan-methods.d.ts +163 -0
- package/dist/kernel/query/relate/traverse.d.ts +109 -0
- package/dist/kernel/query/scan-builder.d.ts +79 -176
- package/dist/kernel/query/sort-key.d.ts +52 -0
- package/dist/kernel/secret-mode.d.ts +1 -1
- package/dist/kernel/tx-write-gate.d.ts +77 -0
- package/dist/kernel/types.d.ts +113 -8
- package/dist/kernel/validation.d.ts +27 -10
- package/dist/kernel/vault.d.ts +11 -6
- package/dist/kernel/via/compose.d.ts +3 -0
- package/dist/kernel/via/index.d.ts +56 -0
- package/dist/kernel/via/pipeline.d.ts +48 -0
- package/dist/kernel/write-queue.d.ts +17 -0
- package/dist/{ledger-EDXFFZQL.js → ledger-5ZMGE44K.js} +11 -12
- package/dist/liberate-WZSZM2W6.js +24 -0
- package/dist/link-set-MFXC24VK.js +29 -0
- package/dist/{managed-secret-NCWEMPUQ.js → managed-secret-MFTFT22X.js} +10 -11
- package/dist/materialized-views/index.js +30 -24
- package/dist/{migrate-cek-5ENH64AA.js → migrate-cek-DZRFFOHW.js} +2 -2
- package/dist/money/index.js +5 -5
- package/dist/noydb-ITIGNKUF.js +96 -0
- package/dist/overlay-views/index.js +4 -4
- package/dist/periods/index.js +12 -13
- package/dist/pod/index.js +74 -67
- package/dist/{pod-handle-ECVCDIXW.js → pod-handle-A3LET7NO.js} +10 -11
- package/dist/pod-handle-A3LET7NO.js.map +1 -0
- package/dist/policy/index.js +10 -11
- package/dist/port/on/index.d.ts +1 -1
- package/dist/port/to/index.d.ts +1 -1
- package/dist/port/with/blob-strategy.d.ts +10 -1
- package/dist/port/with/classified-strategy.d.ts +1 -1
- package/dist/port/with/collection-options.d.ts +6 -1
- package/dist/port/with/collection-registries.d.ts +1 -1
- package/dist/port/with/coverage-strategy.d.ts +83 -0
- package/dist/port/with/lookup-strategy.d.ts +2 -2
- package/dist/port/with/service-bus.d.ts +46 -0
- package/dist/port/with/strategies.d.ts +2 -0
- package/dist/portability/index.js +8 -8
- package/dist/{post-register-3IPCSG6Q.js → post-register-7ND27CF2.js} +6 -6
- package/dist/post-register-7ND27CF2.js.map +1 -0
- package/dist/query/all/index.js +31 -0
- package/dist/query/index.js +20 -32
- package/dist/query/live/index.js +21 -0
- package/dist/query/live/index.js.map +1 -0
- package/dist/query/reduce/index.js +33 -0
- package/dist/query/reduce/index.js.map +1 -0
- package/dist/query/relate/index.js +56 -0
- package/dist/query/relate/index.js.map +1 -0
- package/dist/reduce/index.js +72 -18
- package/dist/reduce/index.js.map +1 -1
- package/dist/register-DT5HZ2LZ.js +30 -0
- package/dist/registry-BHRZGZHF.js +8 -0
- package/dist/registry-ET6ZFFWA.js +34 -0
- package/dist/registry-HXFGLGTG.js +8 -0
- package/dist/registry-THCPDEOD.js +23 -0
- package/dist/request-withdrawal-AV2MJJKY.js +30 -0
- package/dist/{reveal-QZDHSGD4.js → reveal-B2TLP4JQ.js} +10 -9
- package/dist/reveal-B2TLP4JQ.js.map +1 -0
- package/dist/revoke-6DWIEOCV.js +24 -0
- package/dist/satellites/index.js +1 -1
- package/dist/schema-update/index.js +2 -2
- package/dist/sealed-record/index.js +16 -18
- package/dist/sealed-record/index.js.map +1 -1
- package/dist/search/index.js +11 -5
- package/dist/{seed-X5CC22CQ.js → seed-XNSE4U3S.js} +15 -18
- package/dist/seed-XNSE4U3S.js.map +1 -0
- package/dist/sequence/index.js +9 -10
- package/dist/session/index.js +9 -10
- package/dist/session/index.js.map +1 -1
- package/dist/shadow/index.js +2 -2
- package/dist/signer-MHGW3OIL.js +23 -0
- package/dist/snapshots/index.js +11 -11
- package/dist/stale-6GCFMOOR.js +28 -0
- package/dist/storage-BYN5LO6Z.js +21 -0
- package/dist/storage-BYN5LO6Z.js.map +1 -0
- package/dist/store/index.js +1 -1
- package/dist/{store-coordination-provider-4WZAIRHC.js → store-coordination-provider-C4BPT5XF.js} +11 -12
- package/dist/store-coordination-provider-C4BPT5XF.js.map +1 -0
- package/dist/sync/index.js +10 -11
- package/dist/sync/index.js.map +1 -1
- package/dist/team/index.js +17 -16
- package/dist/tiers/index.js +13 -12
- 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 +11 -14
- package/dist/vault-head/index.js.map +1 -1
- package/dist/{verify-6MDTIUEV.js → verify-UKALW7C2.js} +14 -12
- package/dist/verify-UKALW7C2.js.map +1 -0
- package/dist/via/blob/index.d.ts +1 -0
- package/dist/via/classified/binding.d.ts +2 -2
- package/dist/via/classified/config-drift.d.ts +2 -2
- package/dist/via/classified/errors.d.ts +1 -1
- package/dist/via/geo/binding.d.ts +31 -0
- package/dist/via/geo/descriptor.d.ts +54 -0
- package/dist/via/geo/geohash.d.ts +95 -0
- package/dist/via/geo/index.d.ts +13 -0
- package/dist/via/geo/where.d.ts +50 -0
- package/dist/via/i18n/core.d.ts +1 -1
- package/dist/via/lookup/handle.d.ts +4 -4
- package/dist/via/lookup/registry.d.ts +1 -1
- package/dist/via/lookup/snapshot.d.ts +3 -3
- package/dist/walk-4VPK7AS4.js +20 -0
- package/dist/walk-4VPK7AS4.js.map +1 -0
- package/dist/with-audit/attestation/index.d.ts +2 -1
- package/dist/with-audit/attestation/issue.d.ts +2 -2
- package/dist/with-audit/attestation/revoke.d.ts +2 -2
- package/dist/with-audit/attestation/scheme.d.ts +7 -0
- package/dist/with-audit/attestation/signer.d.ts +1 -1
- package/dist/with-audit/attestation/strategy.d.ts +2 -2
- package/dist/with-audit/attestation/types.d.ts +10 -0
- package/dist/with-audit/attestation/vault-facade.d.ts +2 -2
- package/dist/with-audit/attestation/verifier.d.ts +6 -0
- package/dist/with-audit/consent/consent.d.ts +1 -1
- package/dist/with-audit/consent/strategy.d.ts +1 -1
- package/dist/with-audit/coverage/accounting.d.ts +112 -0
- package/dist/with-audit/coverage/active.d.ts +29 -0
- package/dist/with-audit/coverage/index.d.ts +61 -0
- package/dist/with-audit/coverage/sketch.d.ts +75 -0
- package/dist/with-audit/forget/subject-index.d.ts +1 -1
- package/dist/with-audit/periods/periods.d.ts +55 -7
- package/dist/with-audit/periods/reserved-collections.d.ts +3 -0
- package/dist/with-audit/periods/vault-facade.d.ts +18 -1
- package/dist/with-audit/sealed-record/index.d.ts +2 -2
- package/dist/with-audit/sealed-record/strategy.d.ts +1 -1
- package/dist/with-audit/tiers/index.d.ts +53 -2
- package/dist/with-audit/tiers/strategy.d.ts +8 -0
- package/dist/with-cargo/adopt-partition.d.ts +1 -1
- package/dist/with-cargo/extract-partition.d.ts +1 -1
- package/dist/with-cargo/floor.d.ts +3 -3
- package/dist/with-commit/history/history.d.ts +2 -2
- package/dist/with-commit/history/index.d.ts +1 -1
- package/dist/with-commit/history/ledger/store.d.ts +1 -1
- package/dist/with-commit/history/strategy.d.ts +1 -1
- package/dist/with-commit/history/time-machine.d.ts +1 -1
- package/dist/with-commit/numbering/index.d.ts +1 -1
- package/dist/with-commit/sequence/index.d.ts +1 -1
- package/dist/with-commit/tx/invariants.d.ts +1 -1
- package/dist/with-commit/tx/transaction.d.ts +13 -3
- package/dist/with-commit/vault-head/head.d.ts +1 -1
- package/dist/with-commit/vault-head/index.d.ts +1 -1
- package/dist/with-commit/vault-head/strategy.d.ts +1 -1
- package/dist/with-commit/vault-head/verify.d.ts +1 -1
- package/dist/with-formula/derivations/dispatch.d.ts +1 -1
- package/dist/with-formula/derivations/fanout-sidecar.d.ts +1 -1
- package/dist/with-formula/materialized-views/dependency-analyzer.d.ts +4 -3
- package/dist/with-formula/materialized-views/emit-memo.d.ts +40 -0
- package/dist/with-formula/materialized-views/executor.d.ts +8 -0
- package/dist/with-formula/materialized-views/index.d.ts +1 -1
- package/dist/with-formula/materialized-views/registry.d.ts +15 -0
- package/dist/with-formula/materialized-views/types.d.ts +106 -14
- package/dist/with-formula/materialized-views/window-stage.d.ts +11 -0
- package/dist/with-formula/overlay-views/types.d.ts +1 -1
- package/dist/with-formula/overlay-views/virtual-collection.d.ts +13 -4
- package/dist/with-lookup/embeddings/chunks.d.ts +79 -0
- package/dist/with-lookup/embeddings/descriptor.d.ts +21 -0
- package/dist/with-lookup/embeddings/index.d.ts +3 -0
- package/dist/with-lookup/embeddings/ivf-flat.d.ts +93 -0
- package/dist/with-lookup/embeddings/vector-index.d.ts +73 -0
- package/dist/with-lookup/embeddings/vector-set.d.ts +94 -1
- package/dist/with-lookup/embeddings/with-vector-index.d.ts +67 -0
- package/dist/with-lookup/indexing/collection-facade.d.ts +86 -3
- package/dist/with-lookup/indexing/compound-indexes.d.ts +129 -0
- package/dist/with-lookup/indexing/eager-indexes.d.ts +170 -1
- package/dist/with-lookup/indexing/index-snapshot.d.ts +62 -0
- package/dist/with-lookup/indexing/lazy-builder.d.ts +33 -0
- package/dist/with-lookup/indexing/persisted-field-indexes.d.ts +104 -0
- package/dist/with-lookup/indexing/persisted-indexes.d.ts +12 -0
- package/dist/with-lookup/indexing/sorted-indexes.d.ts +117 -0
- package/dist/with-lookup/indexing/unique-constraints.d.ts +106 -23
- package/dist/with-lookup/reduce/active.d.ts +2 -24
- package/dist/with-lookup/reduce/group-core.d.ts +43 -0
- package/dist/with-lookup/reduce/groupby.d.ts +195 -36
- package/dist/with-lookup/reduce/incremental-group.d.ts +153 -0
- package/dist/with-lookup/reduce/index.d.ts +26 -5
- package/dist/with-lookup/reduce/reducers.d.ts +255 -1
- package/dist/with-lookup/reduce/reduction.d.ts +44 -13
- package/dist/with-lookup/reduce/strategy.d.ts +43 -3
- package/dist/with-lookup/reduce/window.d.ts +262 -0
- package/dist/with-lookup/search/collection-facade.d.ts +45 -9
- package/dist/with-lookup/search/index-store.d.ts +5 -3
- package/dist/with-lookup/search/index.d.ts +4 -2
- package/dist/with-lookup/search/inverted-index.d.ts +38 -2
- package/dist/with-lookup/search/persisted-index-store.d.ts +5 -2
- package/dist/with-lookup/search/phrase.d.ts +28 -0
- package/dist/with-lookup/search/retrieve-types.d.ts +57 -1
- package/dist/with-lookup/search/serialize.d.ts +29 -3
- package/dist/with-lookup/search/strategy.d.ts +2 -6
- package/dist/with-party/broker/index.d.ts +3 -3
- package/dist/with-party/directory/cover/index.d.ts +1 -1
- package/dist/with-party/directory/cover/storage.d.ts +1 -1
- package/dist/with-party/directory/cover/types.d.ts +1 -1
- package/dist/with-party/directory/index.d.ts +1 -1
- package/dist/with-party/directory/types.d.ts +1 -1
- package/dist/with-party/directory/user-envelope/api.d.ts +1 -1
- package/dist/with-party/directory/user-envelope/storage.d.ts +1 -1
- package/dist/with-party/policy/engine.d.ts +1 -1
- package/dist/with-party/policy/index.d.ts +1 -1
- package/dist/with-party/policy/presets.d.ts +1 -1
- package/dist/with-party/team/authenticators.d.ts +91 -1
- package/dist/with-party/team/delegation.d.ts +1 -1
- package/dist/with-party/team/echo-secret.d.ts +2 -2
- package/dist/with-party/team/index.d.ts +4 -3
- package/dist/with-party/team/keyring.d.ts +2 -2
- package/dist/with-party/team/magic-link-grant.d.ts +1 -1
- package/dist/with-party/team/managed-secret.d.ts +1 -1
- package/dist/with-party/team/noydb-facade.d.ts +12 -3
- package/dist/with-party/team/recovery.d.ts +1 -1
- package/dist/with-party/team/roster-tag.d.ts +1 -1
- package/dist/with-party/team/rotate-recover.d.ts +1 -1
- package/dist/with-party/team/wrapped-deks.d.ts +1 -1
- package/dist/with-pod/format.d.ts +1 -1
- package/dist/with-pod/index.d.ts +1 -1
- package/dist/with-pod/pod.d.ts +1 -1
- package/dist/with-shape/blobs/blob-compaction.d.ts +17 -1
- package/dist/with-shape/blobs/blob-intent.d.ts +1 -1
- package/dist/with-shape/blobs/blob-set.d.ts +23 -4
- package/dist/with-shape/blobs/legacy-sweep.d.ts +35 -0
- package/dist/with-shape/introspection/describe.d.ts +7 -1
- package/dist/with-shape/introspection/field-meta.d.ts +18 -0
- package/dist/with-shape/introspection/types.d.ts +57 -1
- package/dist/with-shape/introspection/walk.d.ts +1 -1
- package/dist/with-shape/links/lazy-handle.d.ts +1 -1
- package/dist/with-shape/links/link-set.d.ts +1 -1
- package/dist/with-shape/links/vault-facade.d.ts +1 -1
- package/dist/with-shape/manifest/derive.d.ts +1 -1
- package/dist/with-shape/manifest/storage.d.ts +1 -1
- package/dist/with-shape/persisted-schemas/register.d.ts +1 -1
- package/dist/with-shape/persisted-schemas/storage.d.ts +1 -1
- package/dist/with-shape/satellites/dead-filter.d.ts +1 -1
- package/dist/with-shape/satellites/declare.d.ts +1 -1
- package/dist/with-shape/satellites/marker.d.ts +1 -1
- package/dist/with-shape/satellites/post-register.d.ts +1 -1
- package/dist/with-store/partitioned/index.d.ts +337 -0
- package/dist/with-sync/change-broadcast.d.ts +153 -0
- package/dist/with-sync/presence.d.ts +5 -10
- package/dist/withdraw-accessible-HL7GACUE.js +27 -0
- package/dist/withdraw-accessible-HL7GACUE.js.map +1 -0
- package/package.json +48 -12
- package/dist/api-WYW4YEQG.js +0 -19
- package/dist/backup-XKCXVKV3.js.map +0 -1
- package/dist/chunk-2577DKXB.js.map +0 -1
- package/dist/chunk-2ENE6445.js.map +0 -1
- package/dist/chunk-2N5ML6HT.js.map +0 -1
- package/dist/chunk-334WSVOW.js.map +0 -1
- package/dist/chunk-3BVH633C.js.map +0 -1
- package/dist/chunk-3PGS7TYR.js.map +0 -1
- package/dist/chunk-3V4KWFX7.js.map +0 -1
- package/dist/chunk-453F654R.js.map +0 -1
- package/dist/chunk-4GFX6MPA.js.map +0 -1
- package/dist/chunk-4GVM6QZA.js.map +0 -1
- package/dist/chunk-4ZS56W5S.js.map +0 -1
- package/dist/chunk-5VCRVKOZ.js.map +0 -1
- package/dist/chunk-6YXCPL4T.js.map +0 -1
- package/dist/chunk-7APJ6CO6.js.map +0 -1
- package/dist/chunk-7MG2LHO5.js +0 -1616
- package/dist/chunk-7MG2LHO5.js.map +0 -1
- package/dist/chunk-7MG7SJT7.js.map +0 -1
- package/dist/chunk-7O3Y4PPD.js.map +0 -1
- package/dist/chunk-A2HKRLPV.js.map +0 -1
- package/dist/chunk-A66I4JOA.js.map +0 -1
- package/dist/chunk-ACAQ2DSG.js.map +0 -1
- package/dist/chunk-ATL3ZVXT.js +0 -151
- package/dist/chunk-ATL3ZVXT.js.map +0 -1
- package/dist/chunk-AYX7AINO.js.map +0 -1
- package/dist/chunk-BLN54W3L.js.map +0 -1
- package/dist/chunk-BRLKZUBT.js +0 -95
- package/dist/chunk-BRLKZUBT.js.map +0 -1
- package/dist/chunk-BTDR2PXY.js +0 -29
- package/dist/chunk-BTDR2PXY.js.map +0 -1
- package/dist/chunk-BVN6KXL2.js.map +0 -1
- package/dist/chunk-CHQCZZWC.js.map +0 -1
- package/dist/chunk-CUQPWYRX.js.map +0 -1
- package/dist/chunk-CUZLNGD5.js.map +0 -1
- package/dist/chunk-DFMWUOU5.js.map +0 -1
- package/dist/chunk-EIPVYUEP.js.map +0 -1
- package/dist/chunk-EQEYOJBM.js.map +0 -1
- package/dist/chunk-F3W6YMDC.js.map +0 -1
- package/dist/chunk-FET5XCAT.js.map +0 -1
- package/dist/chunk-G73UVHCA.js.map +0 -1
- package/dist/chunk-GPNTB4Y7.js.map +0 -1
- package/dist/chunk-GYGLAVCX.js.map +0 -1
- package/dist/chunk-HIWCKBEY.js.map +0 -1
- package/dist/chunk-HJUWN7JN.js.map +0 -1
- package/dist/chunk-HK67PX4J.js.map +0 -1
- package/dist/chunk-HPVZCW43.js +0 -479
- package/dist/chunk-HPVZCW43.js.map +0 -1
- package/dist/chunk-I3ISCYT7.js +0 -159
- package/dist/chunk-I3ISCYT7.js.map +0 -1
- package/dist/chunk-K23VKTN4.js.map +0 -1
- package/dist/chunk-KKEESNPE.js.map +0 -1
- package/dist/chunk-KTFRCC5C.js.map +0 -1
- package/dist/chunk-LH5A3ZPG.js.map +0 -1
- package/dist/chunk-LP7BEXCT.js +0 -32
- package/dist/chunk-LP7BEXCT.js.map +0 -1
- package/dist/chunk-M4YPHYEH.js.map +0 -1
- package/dist/chunk-NSITFOCJ.js +0 -99
- package/dist/chunk-NSITFOCJ.js.map +0 -1
- package/dist/chunk-OTQZ7ZWU.js.map +0 -1
- package/dist/chunk-P3MG6QCN.js.map +0 -1
- package/dist/chunk-PEOZ34EM.js.map +0 -1
- package/dist/chunk-PPTHY5QO.js.map +0 -1
- package/dist/chunk-Q2MPFCQ7.js.map +0 -1
- package/dist/chunk-Q7HZX3IF.js.map +0 -1
- package/dist/chunk-QPQUVOZ2.js.map +0 -1
- package/dist/chunk-QTQUH4DS.js.map +0 -1
- package/dist/chunk-R42NSZI6.js.map +0 -1
- package/dist/chunk-R7BX2NB3.js.map +0 -1
- package/dist/chunk-RSGLUIO6.js.map +0 -1
- package/dist/chunk-RTBJ5IOO.js +0 -87
- package/dist/chunk-RTBJ5IOO.js.map +0 -1
- package/dist/chunk-SGZAIJCV.js.map +0 -1
- package/dist/chunk-SKGMN35F.js.map +0 -1
- package/dist/chunk-SPYWXKJN.js.map +0 -1
- package/dist/chunk-SZJ3DLZA.js +0 -66
- package/dist/chunk-SZJ3DLZA.js.map +0 -1
- package/dist/chunk-TRGTKX5E.js.map +0 -1
- package/dist/chunk-UDHWDSRL.js.map +0 -1
- package/dist/chunk-UP4BECPY.js.map +0 -1
- package/dist/chunk-UXVWEX5L.js.map +0 -1
- package/dist/chunk-V7ZRRCRJ.js.map +0 -1
- package/dist/chunk-WQBG4SZS.js.map +0 -1
- package/dist/chunk-XKWGNJ26.js.map +0 -1
- package/dist/chunk-YMUFFJCO.js.map +0 -1
- package/dist/chunk-ZHKOPKE3.js.map +0 -1
- package/dist/chunk-ZN4FD4PE.js +0 -364
- package/dist/chunk-ZN4FD4PE.js.map +0 -1
- package/dist/chunk-ZORTV6NH.js.map +0 -1
- package/dist/chunk-ZYIYHJ5R.js.map +0 -1
- package/dist/classified-marker-BWOFVYAC.js.map +0 -1
- package/dist/collection-facade-JSJYIKS4.js +0 -45
- package/dist/dead-filter-PKQDLOT4.js.map +0 -1
- package/dist/delegation-DS5NRILW.js.map +0 -1
- package/dist/derive-E642AOUB.js +0 -21
- package/dist/dispatch-Q6MWLOJY.js.map +0 -1
- package/dist/executor-5NIMLSKZ.js +0 -8
- package/dist/executor-7UQ3BZ4F.js +0 -29
- package/dist/executor-AQVXV5GZ.js +0 -8
- package/dist/export-accessible-ORMKLA3E.js +0 -22
- package/dist/extract-partition-NKYO3WNG.js +0 -37
- package/dist/fanout-sidecar-S3QL53YX.js.map +0 -1
- package/dist/find-NOGJ25VX.js +0 -10
- package/dist/issue-3DTQ7VJJ.js +0 -18
- package/dist/json-schema-V3M5MUCM.js.map +0 -1
- package/dist/kernel/enclave/classify/compare.d.ts +0 -10
- package/dist/kernel/enclave/index.d.ts +0 -87
- package/dist/kernel/enclave/record-keys/lifecycle.d.ts +0 -124
- package/dist/kernel/enclave/record-keys/rekey-blob.d.ts +0 -88
- package/dist/kernel/enclave/record-keys/rekey.d.ts +0 -91
- package/dist/kernel/enclave/record-keys/sealed-slot.d.ts +0 -14
- package/dist/kernel/enclave/record-keys/sealed-slots.d.ts +0 -123
- package/dist/kernel/enclave/record-keys/sealing.d.ts +0 -70
- package/dist/kernel/query/join.d.ts +0 -232
- package/dist/liberate-V35QUHJP.js +0 -24
- package/dist/link-set-2TTM3IZC.js +0 -30
- package/dist/noydb-62MX4QUG.js +0 -90
- package/dist/pod-handle-ECVCDIXW.js.map +0 -1
- package/dist/post-register-3IPCSG6Q.js.map +0 -1
- package/dist/register-HHLXEQDN.js +0 -31
- package/dist/registry-23WF3TGH.js +0 -8
- package/dist/registry-4AYVUNXK.js +0 -8
- package/dist/registry-JS3YFQQM.js +0 -18
- package/dist/registry-XX2Z7B46.js +0 -32
- package/dist/request-withdrawal-CHPATE4G.js +0 -30
- package/dist/reveal-QZDHSGD4.js.map +0 -1
- package/dist/revoke-7M2VW4ON.js +0 -23
- package/dist/seed-X5CC22CQ.js.map +0 -1
- package/dist/signer-SJQJVSM6.js +0 -24
- package/dist/stale-BZS6H2RY.js +0 -29
- package/dist/storage-RW4QBS23.js +0 -22
- package/dist/store-coordination-provider-4WZAIRHC.js.map +0 -1
- package/dist/verify-6MDTIUEV.js.map +0 -1
- package/dist/walk-ZURCH6RZ.js +0 -21
- package/dist/withdraw-accessible-PXR4IXDX.js +0 -27
- /package/dist/{api-WYW4YEQG.js.map → api-OS747DS4.js.map} +0 -0
- /package/dist/{computed-VPOKQK4N.js.map → capsule/contract.js.map} +0 -0
- /package/dist/{kernel/enclave → capsule/enclave-aes}/broker/proof.d.ts +0 -0
- /package/dist/{kernel/enclave → capsule/enclave-aes}/classify/bidx.d.ts +0 -0
- /package/dist/{kernel/enclave → capsule/enclave-aes}/classify/digest.d.ts +0 -0
- /package/dist/{kernel/enclave → capsule/enclave-aes}/classify/vdig.d.ts +0 -0
- /package/dist/{kernel/enclave/classify → capsule/plumbing}/kofn.d.ts +0 -0
- /package/dist/{kernel/enclave/classify → capsule/plumbing}/normalize.d.ts +0 -0
- /package/dist/{kernel/enclave → capsule/plumbing}/record-aad.d.ts +0 -0
- /package/dist/{collection-facade-JSJYIKS4.js.map → capsule-VOLX3QRQ.js.map} +0 -0
- /package/dist/{chunk-MVMXZYXT.js.map → chunk-2GHDLTPE.js.map} +0 -0
- /package/dist/{chunk-XLMEZIAJ.js.map → chunk-2ODVB6LZ.js.map} +0 -0
- /package/dist/{chunk-RMS3NEA3.js.map → chunk-4JPMZTJY.js.map} +0 -0
- /package/dist/{chunk-NQKIUNW5.js.map → chunk-52MGURXO.js.map} +0 -0
- /package/dist/{chunk-UGTBXF5U.js.map → chunk-7XMHMVTS.js.map} +0 -0
- /package/dist/{chunk-BZ3534YM.js.map → chunk-AUKKUPVB.js.map} +0 -0
- /package/dist/{derive-E642AOUB.js.map → chunk-BKT776R5.js.map} +0 -0
- /package/dist/{chunk-6LKOJBV6.js.map → chunk-BVCUTXE3.js.map} +0 -0
- /package/dist/{chunk-VTFVLCUH.js.map → chunk-DIZLQVAA.js.map} +0 -0
- /package/dist/{chunk-LWBCUYZW.js.map → chunk-E2N2T5ZO.js.map} +0 -0
- /package/dist/{chunk-JVIBCBC7.js.map → chunk-EJLV62NI.js.map} +0 -0
- /package/dist/{chunk-JMGDHKQF.js.map → chunk-FLPCETP6.js.map} +0 -0
- /package/dist/{chunk-DGOZ4UZD.js.map → chunk-FVH5QYY2.js.map} +0 -0
- /package/dist/{chunk-JBDFMYKQ.js.map → chunk-GZT3NQRA.js.map} +0 -0
- /package/dist/{chunk-TFR7DSOV.js.map → chunk-H427H63K.js.map} +0 -0
- /package/dist/{chunk-SMH6SRX7.js.map → chunk-JOSPH3E5.js.map} +0 -0
- /package/dist/{chunk-3BZZJJMQ.js.map → chunk-MILI22XQ.js.map} +0 -0
- /package/dist/{chunk-YYP7WSEB.js.map → chunk-O2IMQSNA.js.map} +0 -0
- /package/dist/{chunk-QIZPZMUI.js.map → chunk-Q4UHJ5SN.js.map} +0 -0
- /package/dist/{chunk-FAHMLERK.js.map → chunk-QBLT6POL.js.map} +0 -0
- /package/dist/{chunk-BUE2D7PX.js.map → chunk-SMV2HRDU.js.map} +0 -0
- /package/dist/{chunk-SFAWCTEM.js.map → chunk-TZZBXPZK.js.map} +0 -0
- /package/dist/{chunk-UHHPLO3I.js.map → chunk-V3RWOOSO.js.map} +0 -0
- /package/dist/{chunk-Q2PU57HC.js.map → chunk-VVOLDVIR.js.map} +0 -0
- /package/dist/{chunk-TUFM4UZP.js.map → chunk-XQRFSKYM.js.map} +0 -0
- /package/dist/{chunk-GY4WYNNG.js.map → chunk-Y2RKVFKR.js.map} +0 -0
- /package/dist/{chunk-4OZNXTO4.js.map → chunk-YRXFFWG4.js.map} +0 -0
- /package/dist/{enclave-55PAM4YO.js.map → collection-facade-CS7CA2XO.js.map} +0 -0
- /package/dist/{executor-5NIMLSKZ.js.map → computed-FAD7SED4.js.map} +0 -0
- /package/dist/{executor-7UQ3BZ4F.js.map → derive-XLOJVXPU.js.map} +0 -0
- /package/dist/{dispatch-IEPAVQUM.js.map → dispatch-H4HV32AM.js.map} +0 -0
- /package/dist/{executor-AQVXV5GZ.js.map → executor-FMPVN6DT.js.map} +0 -0
- /package/dist/{export-accessible-ORMKLA3E.js.map → executor-LBBBRTN5.js.map} +0 -0
- /package/dist/{extract-partition-NKYO3WNG.js.map → executor-OSRZST2U.js.map} +0 -0
- /package/dist/{find-NOGJ25VX.js.map → export-accessible-RAOJAAU5.js.map} +0 -0
- /package/dist/{issue-3DTQ7VJJ.js.map → extract-partition-JD5CUSTG.js.map} +0 -0
- /package/dist/{ledger-EDXFFZQL.js.map → find-JRN4RNQ5.js.map} +0 -0
- /package/dist/{liberate-V35QUHJP.js.map → issue-YIVBZUTH.js.map} +0 -0
- /package/dist/{link-set-2TTM3IZC.js.map → ledger-5ZMGE44K.js.map} +0 -0
- /package/dist/{managed-secret-NCWEMPUQ.js.map → liberate-WZSZM2W6.js.map} +0 -0
- /package/dist/{noydb-62MX4QUG.js.map → link-set-MFXC24VK.js.map} +0 -0
- /package/dist/{register-HHLXEQDN.js.map → managed-secret-MFTFT22X.js.map} +0 -0
- /package/dist/{migrate-cek-5ENH64AA.js.map → migrate-cek-DZRFFOHW.js.map} +0 -0
- /package/dist/{registry-23WF3TGH.js.map → noydb-ITIGNKUF.js.map} +0 -0
- /package/dist/{registry-4AYVUNXK.js.map → query/all/index.js.map} +0 -0
- /package/dist/{registry-JS3YFQQM.js.map → register-DT5HZ2LZ.js.map} +0 -0
- /package/dist/{registry-XX2Z7B46.js.map → registry-BHRZGZHF.js.map} +0 -0
- /package/dist/{request-withdrawal-CHPATE4G.js.map → registry-ET6ZFFWA.js.map} +0 -0
- /package/dist/{revoke-7M2VW4ON.js.map → registry-HXFGLGTG.js.map} +0 -0
- /package/dist/{signer-SJQJVSM6.js.map → registry-THCPDEOD.js.map} +0 -0
- /package/dist/{stale-BZS6H2RY.js.map → request-withdrawal-AV2MJJKY.js.map} +0 -0
- /package/dist/{storage-RW4QBS23.js.map → revoke-6DWIEOCV.js.map} +0 -0
- /package/dist/{walk-ZURCH6RZ.js.map → signer-MHGW3OIL.js.map} +0 -0
- /package/dist/{withdraw-accessible-PXR4IXDX.js.map → stale-6GCFMOOR.js.map} +0 -0
|
@@ -0,0 +1,1558 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NO_REDUCE
|
|
3
|
+
} from "./chunk-3TDUWVWB.js";
|
|
4
|
+
import {
|
|
5
|
+
gateTerminal
|
|
6
|
+
} from "./chunk-FOEDQATO.js";
|
|
7
|
+
import {
|
|
8
|
+
evaluateClause,
|
|
9
|
+
hasFnClause,
|
|
10
|
+
normalizeMatches,
|
|
11
|
+
normalizeSubqueryOperand
|
|
12
|
+
} from "./chunk-5WWDGFOS.js";
|
|
13
|
+
import {
|
|
14
|
+
isViaPrefixProbe
|
|
15
|
+
} from "./chunk-SYNY3VB5.js";
|
|
16
|
+
import {
|
|
17
|
+
CrossJoinSourceUnknownError,
|
|
18
|
+
FieldNotQueryableError,
|
|
19
|
+
QueryExtensionMissingError
|
|
20
|
+
} from "./chunk-37EPTBBR.js";
|
|
21
|
+
|
|
22
|
+
// src/kernel/query/internal/hooks.ts
|
|
23
|
+
var installed;
|
|
24
|
+
function installRelateHooks(hooks) {
|
|
25
|
+
installed = hooks;
|
|
26
|
+
}
|
|
27
|
+
function relateHooks() {
|
|
28
|
+
if (installed === void 0) {
|
|
29
|
+
throw new QueryExtensionMissingError("join", "@noy-db/hub/query/relate");
|
|
30
|
+
}
|
|
31
|
+
return installed;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// src/kernel/query/cursor.ts
|
|
35
|
+
var CURSOR_VERSION = 1;
|
|
36
|
+
function keysetShape(identity, orderBy) {
|
|
37
|
+
const spec = orderBy.map((o) => `${o.field}:${o.direction}:${o.by ?? "value"}`).join(",");
|
|
38
|
+
return `${identity ?? "(anonymous source)"}::${spec}`;
|
|
39
|
+
}
|
|
40
|
+
function encodeValue(v) {
|
|
41
|
+
if (v instanceof Date) return { $d: v.toISOString() };
|
|
42
|
+
if (typeof v === "number" || typeof v === "string" || typeof v === "boolean") return v;
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
function decodeValue(v) {
|
|
46
|
+
if (v !== null && typeof v === "object" && "$d" in v) {
|
|
47
|
+
return new Date(v.$d);
|
|
48
|
+
}
|
|
49
|
+
return v;
|
|
50
|
+
}
|
|
51
|
+
function toBase64(text) {
|
|
52
|
+
const bytes = new TextEncoder().encode(text);
|
|
53
|
+
let binary = "";
|
|
54
|
+
for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i]);
|
|
55
|
+
return btoa(binary);
|
|
56
|
+
}
|
|
57
|
+
function fromBase64(b64) {
|
|
58
|
+
const binary = atob(b64);
|
|
59
|
+
const bytes = new Uint8Array(binary.length);
|
|
60
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
61
|
+
return new TextDecoder().decode(bytes);
|
|
62
|
+
}
|
|
63
|
+
function encodeCursor(cursor) {
|
|
64
|
+
return toBase64(
|
|
65
|
+
JSON.stringify({
|
|
66
|
+
v: CURSOR_VERSION,
|
|
67
|
+
k: cursor.shape,
|
|
68
|
+
s: cursor.values.map(encodeValue),
|
|
69
|
+
i: cursor.id
|
|
70
|
+
})
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
function decodeCursor(raw, expectedShape) {
|
|
74
|
+
let payload;
|
|
75
|
+
try {
|
|
76
|
+
payload = JSON.parse(fromBase64(raw));
|
|
77
|
+
} catch {
|
|
78
|
+
throw new Error(
|
|
79
|
+
`Query.after(): the value passed is not a valid keyset cursor. Pass back the \`nextCursor\` from a previous .page() call, verbatim.`
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
if (payload === null || typeof payload !== "object" || payload.v !== CURSOR_VERSION || typeof payload.k !== "string" || !Array.isArray(payload.s) || typeof payload.i !== "string") {
|
|
83
|
+
throw new Error(
|
|
84
|
+
`Query.after(): the value passed is not a valid keyset cursor (or was minted by an incompatible version). Pass back the \`nextCursor\` from a previous .page() call, verbatim.`
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
if (payload.k !== expectedShape) {
|
|
88
|
+
throw new Error(
|
|
89
|
+
`Query.after(): this cursor was minted for a different query shape. Cursor: "${payload.k}"; this query: "${expectedShape}". A keyset cursor is only valid for the same collection and the same orderBy(...) spec that produced it.`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
return { shape: payload.k, values: payload.s.map(decodeValue), id: payload.i };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// src/kernel/query/builder.ts
|
|
96
|
+
function splitAroundJoins(clauses, joins) {
|
|
97
|
+
if (joins.length === 0 || clauses.length === 0) return { preJoin: clauses, postJoin: [] };
|
|
98
|
+
return relateHooks().splitAroundJoins(clauses, joins);
|
|
99
|
+
}
|
|
100
|
+
function orderReferencesJoinAlias(orderBy, joins) {
|
|
101
|
+
if (joins.length === 0 || orderBy.length === 0) return false;
|
|
102
|
+
return relateHooks().orderReferencesJoinAlias(orderBy, joins);
|
|
103
|
+
}
|
|
104
|
+
function joinsDropLeftRows(joins) {
|
|
105
|
+
if (joins.length === 0) return false;
|
|
106
|
+
return relateHooks().joinsDropLeftRows(joins);
|
|
107
|
+
}
|
|
108
|
+
function applyJoins(rows, joins, context, locale) {
|
|
109
|
+
if (joins.length === 0) return [...rows];
|
|
110
|
+
return relateHooks().applyJoins(rows, joins, context, locale);
|
|
111
|
+
}
|
|
112
|
+
function applyCrossJoin(leftRel, clause, rightSource) {
|
|
113
|
+
return relateHooks().applyCrossJoin(leftRel, clause, rightSource);
|
|
114
|
+
}
|
|
115
|
+
var EMPTY_PLAN = {
|
|
116
|
+
clauses: [],
|
|
117
|
+
orderBy: [],
|
|
118
|
+
limit: void 0,
|
|
119
|
+
offset: 0,
|
|
120
|
+
after: void 0,
|
|
121
|
+
joins: []
|
|
122
|
+
};
|
|
123
|
+
var Query = class _Query {
|
|
124
|
+
source;
|
|
125
|
+
plan;
|
|
126
|
+
joinContext;
|
|
127
|
+
reduceStrategy;
|
|
128
|
+
predicates;
|
|
129
|
+
constructor(source, plan = EMPTY_PLAN, joinContext, reduceStrategy = NO_REDUCE, predicates) {
|
|
130
|
+
this.source = source;
|
|
131
|
+
this.plan = plan;
|
|
132
|
+
this.joinContext = joinContext;
|
|
133
|
+
this.reduceStrategy = reduceStrategy;
|
|
134
|
+
this.predicates = predicates;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* @internal — accessor for the materialized-view dependency
|
|
138
|
+
* analyzer. Not part of the public API; consumers should use the
|
|
139
|
+
* builder methods, not inspect the plan directly.
|
|
140
|
+
*/
|
|
141
|
+
_plan() {
|
|
142
|
+
return this.plan;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* @internal — accessor for the materialized-view dependency
|
|
146
|
+
* analyzer. Returns the join resolution context (or `undefined` for
|
|
147
|
+
* queries constructed without a Collection backing).
|
|
148
|
+
*/
|
|
149
|
+
_joinContext() {
|
|
150
|
+
return this.joinContext;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* @internal #1414 — clone this Query with the cold-collection gate REMOVED.
|
|
154
|
+
*
|
|
155
|
+
* For engine-internal readers only. The materialized-view engine reads its
|
|
156
|
+
* source collections through the public `collection.query()` on paths that
|
|
157
|
+
* are synchronous by construction (registration inspects the plan; the
|
|
158
|
+
* executor's row scan is called from inside a write commit), and it has
|
|
159
|
+
* always read whatever the in-memory cache held. Gating those would turn a
|
|
160
|
+
* pre-existing read into a throw for consumers who never asked a question —
|
|
161
|
+
* so this preserves that behaviour EXACTLY, and confines #1414's change to
|
|
162
|
+
* the surface a consumer or a guard actually calls.
|
|
163
|
+
*
|
|
164
|
+
* ⚠️ It does not make an unhydrated read correct — an MV computed over a
|
|
165
|
+
* cold source is the same defect wearing a different hat. That is tracked
|
|
166
|
+
* separately; do not reach for this to silence the gate in new code.
|
|
167
|
+
*/
|
|
168
|
+
_ungated() {
|
|
169
|
+
if (this.source.hydration === void 0) return this;
|
|
170
|
+
const rest = { ...this.source };
|
|
171
|
+
delete rest.hydration;
|
|
172
|
+
return new _Query(rest, this.plan, this.joinContext, this.reduceStrategy, this.predicates);
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* @internal — clone this Query with a declared-predicate map
|
|
176
|
+
* attached. Used by the materialized-view registry to enable
|
|
177
|
+
* `.wherePredicate(name, ctx?)` for the MV's query callback.
|
|
178
|
+
* Consumers don't call this directly.
|
|
179
|
+
*/
|
|
180
|
+
_withPredicates(predicates) {
|
|
181
|
+
return new _Query(
|
|
182
|
+
this.source,
|
|
183
|
+
this.plan,
|
|
184
|
+
this.joinContext,
|
|
185
|
+
this.reduceStrategy,
|
|
186
|
+
predicates
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* @internal — the ids of records matching this query's plan,
|
|
191
|
+
* recovered by reference identity: `executePlanWithSource` returns the
|
|
192
|
+
* ORIGINAL snapshot record references (money-decode and joins are applied
|
|
193
|
+
* later, in `toArray`), so each matched record is found in the id-paired
|
|
194
|
+
* `snapshotEntries()` map. Used by `collection.retrieve({ within })`.
|
|
195
|
+
* Throws if the source is not collection-backed (no `snapshotEntries`).
|
|
196
|
+
*/
|
|
197
|
+
_idArray() {
|
|
198
|
+
const entries = this.source.snapshotEntries?.();
|
|
199
|
+
if (entries === void 0) {
|
|
200
|
+
throw new Error(
|
|
201
|
+
"Query._idArray(): the query source has no snapshotEntries(); retrieve({ within }) requires a collection-backed query (collection.query())."
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
if (this.plan.clauses.some((c) => c.type === "crossJoin")) {
|
|
205
|
+
throw new Error(
|
|
206
|
+
"Query._idArray(): retrieve({ within }) does not support crossJoin queries (cross-join produces new row objects, breaking id recovery). Use where/filter/and/or, or a projection .join()."
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
const refToId = /* @__PURE__ */ new Map();
|
|
210
|
+
for (const { id, record } of entries) refToId.set(record, id);
|
|
211
|
+
const matched = executePlanWithSource(this.source, this.plan, this.joinContext);
|
|
212
|
+
const ids = [];
|
|
213
|
+
for (const r of matched) {
|
|
214
|
+
const id = refToId.get(r);
|
|
215
|
+
if (id !== void 0) ids.push(id);
|
|
216
|
+
}
|
|
217
|
+
return ids;
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* The ids of the records this query matches (#1351) — the public spelling
|
|
221
|
+
* of {@link _idArray}, and the eager half of the subquery operand:
|
|
222
|
+
* `where(f, 'in', inner.ids())` and `where(f, 'in', inner)` build the SAME
|
|
223
|
+
* clause. Reach for the explicit form when you want to reuse the id set, or
|
|
224
|
+
* to see it.
|
|
225
|
+
*
|
|
226
|
+
* Requires a collection-backed query (`collection.query()`); a `crossJoin`
|
|
227
|
+
* plan is refused, because it produces new row objects and there is no id
|
|
228
|
+
* to recover.
|
|
229
|
+
*
|
|
230
|
+
* **Synchronous** (#1413) — returns `string[]`, not a promise; the cache it reads is
|
|
231
|
+
* already decrypted. `await` is safe and is REQUIRED on an unhydrated collection
|
|
232
|
+
* (#1414); `.catch()` is not available. See the {@link Query} class doc.
|
|
233
|
+
*/
|
|
234
|
+
ids() {
|
|
235
|
+
const _h = this.source.hydration;
|
|
236
|
+
if (_h !== void 0 && !_h.isHydrated()) return gateTerminal(_h, "ids", () => this.ids());
|
|
237
|
+
return this._idArray();
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* @internal — the id-operand contract `normalizeSubqueryOperand()`
|
|
241
|
+
* (`predicate.ts`) duck-types when this Query is passed as the operand of
|
|
242
|
+
* `in`/`!in`. Separate from {@link ids} so the failure a subquery hits is
|
|
243
|
+
* phrased as a subquery failure rather than as a `retrieve({ within })` one.
|
|
244
|
+
*/
|
|
245
|
+
_asIdOperand() {
|
|
246
|
+
if (this.source.snapshotEntries === void 0) {
|
|
247
|
+
throw new Error(
|
|
248
|
+
"where(..., 'in', <subquery>): the inner query's source is not collection-backed (no snapshotEntries()). Pass a query obtained from collection.query(), or pass a literal array of values."
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
return { ids: this._idArray(), from: this.source.identity ?? "(unnamed)" };
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Filter by a registered deterministic predicate. Requires
|
|
255
|
+
* the Query to have been augmented with a predicates map (typically
|
|
256
|
+
* via the materialized-view registry — bare Queries constructed
|
|
257
|
+
* outside an MV throw on `.wherePredicate()`).
|
|
258
|
+
*
|
|
259
|
+
* `ctx` is an optional opaque value passed verbatim to the predicate
|
|
260
|
+
* function. Both `predicateHash` (from the registration) and a
|
|
261
|
+
* canonical-JSON hash of `ctx` fold into the MV's `queryHash`, so
|
|
262
|
+
* either changing forces refresh on next visit.
|
|
263
|
+
*/
|
|
264
|
+
wherePredicate(name, ctx) {
|
|
265
|
+
if (!this.predicates) {
|
|
266
|
+
throw new Error(
|
|
267
|
+
`.wherePredicate("${name}"): no predicates registered on this Query. Function-based predicates require the Query to be obtained from inside a materialized-view query() callback whose strategy declares \`predicates: { ${name}: { hash, fn } }\`.`
|
|
268
|
+
);
|
|
269
|
+
}
|
|
270
|
+
const decl = this.predicates.get(name);
|
|
271
|
+
if (!decl) {
|
|
272
|
+
throw new Error(
|
|
273
|
+
`.wherePredicate("${name}"): predicate not registered. Available: ${[...this.predicates.keys()].join(", ") || "(none)"}.`
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
const clause = {
|
|
277
|
+
type: "wherePredicate",
|
|
278
|
+
name,
|
|
279
|
+
ctx,
|
|
280
|
+
predicateHash: decl.hash,
|
|
281
|
+
ctxHash: canonicalCtxHash(ctx),
|
|
282
|
+
fn: decl.fn
|
|
283
|
+
};
|
|
284
|
+
return new _Query(
|
|
285
|
+
this.source,
|
|
286
|
+
{ ...this.plan, clauses: [...this.plan.clauses, clause] },
|
|
287
|
+
this.joinContext,
|
|
288
|
+
this.reduceStrategy,
|
|
289
|
+
this.predicates
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Add a field comparison. Multiple where() calls are AND-combined.
|
|
294
|
+
*
|
|
295
|
+
* A declared money field compares in MAJOR units: the operand
|
|
296
|
+
* (`10000`, `'10000.00'`, or `{ amount, currency }` in multi mode) is
|
|
297
|
+
* quantized into stored scaled-int space at build time and evaluated
|
|
298
|
+
* BigInt-exact per record. A malformed operand or a string operator
|
|
299
|
+
* (`contains`/`startsWith`) throws here, at the call site.
|
|
300
|
+
*
|
|
301
|
+
* Consults the Via pipeline's posture before building a clause (#629
|
|
302
|
+
* Task 8): a field whose posture is `queryable: 'none'` (e.g. a
|
|
303
|
+
* `blobFields` slot) throws `FieldNotQueryableError` here, at the call
|
|
304
|
+
* site. Every other posture is unaffected — the existing per-binding
|
|
305
|
+
* `buildClause` machinery runs exactly as before.
|
|
306
|
+
*/
|
|
307
|
+
where(field, op, value) {
|
|
308
|
+
const via = this.source.via;
|
|
309
|
+
if (via?.postureFor(field)?.queryable === "none") throw new FieldNotQueryableError(field);
|
|
310
|
+
const { op: sop, value: sval, subquery } = normalizeSubqueryOperand(op, value);
|
|
311
|
+
const { op: mop, value: mval } = normalizeMatches(sop, sval);
|
|
312
|
+
const viaClause = via?.buildClause(field, mop, mval);
|
|
313
|
+
const clause = viaClause ? {
|
|
314
|
+
type: "field",
|
|
315
|
+
field,
|
|
316
|
+
op: mop,
|
|
317
|
+
value: mval,
|
|
318
|
+
...subquery ? { subquery } : {},
|
|
319
|
+
via: {
|
|
320
|
+
brand: viaClause.brand,
|
|
321
|
+
payload: viaClause.payload,
|
|
322
|
+
evaluate: (actual, evalOp) => via.evaluateClause(viaClause, actual, evalOp),
|
|
323
|
+
indexValue: via.indexProbe(viaClause, mop)
|
|
324
|
+
}
|
|
325
|
+
} : { type: "field", field, op: mop, value: mval, ...subquery ? { subquery } : {} };
|
|
326
|
+
return new _Query(
|
|
327
|
+
this.source,
|
|
328
|
+
{ ...this.plan, clauses: [...this.plan.clauses, clause] },
|
|
329
|
+
this.joinContext,
|
|
330
|
+
this.reduceStrategy,
|
|
331
|
+
this.predicates
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Logical OR group. Pass a callback that builds a sub-query.
|
|
336
|
+
* Each clause inside the callback is OR-combined; the group itself
|
|
337
|
+
* joins the parent plan with AND.
|
|
338
|
+
*/
|
|
339
|
+
or(builder) {
|
|
340
|
+
const sub = builder(
|
|
341
|
+
new _Query(this.source, EMPTY_PLAN, this.joinContext, this.reduceStrategy, this.predicates)
|
|
342
|
+
);
|
|
343
|
+
const group = {
|
|
344
|
+
type: "group",
|
|
345
|
+
op: "or",
|
|
346
|
+
clauses: sub.plan.clauses
|
|
347
|
+
};
|
|
348
|
+
return new _Query(
|
|
349
|
+
this.source,
|
|
350
|
+
{ ...this.plan, clauses: [...this.plan.clauses, group] },
|
|
351
|
+
this.joinContext,
|
|
352
|
+
this.reduceStrategy,
|
|
353
|
+
this.predicates
|
|
354
|
+
);
|
|
355
|
+
}
|
|
356
|
+
/**
|
|
357
|
+
* Logical AND group. Same shape as `or()` but every clause inside the group
|
|
358
|
+
* must match. Useful for explicit grouping inside a larger OR.
|
|
359
|
+
*/
|
|
360
|
+
and(builder) {
|
|
361
|
+
const sub = builder(
|
|
362
|
+
new _Query(this.source, EMPTY_PLAN, this.joinContext, this.reduceStrategy, this.predicates)
|
|
363
|
+
);
|
|
364
|
+
const group = {
|
|
365
|
+
type: "group",
|
|
366
|
+
op: "and",
|
|
367
|
+
clauses: sub.plan.clauses
|
|
368
|
+
};
|
|
369
|
+
return new _Query(
|
|
370
|
+
this.source,
|
|
371
|
+
{ ...this.plan, clauses: [...this.plan.clauses, group] },
|
|
372
|
+
this.joinContext,
|
|
373
|
+
this.reduceStrategy,
|
|
374
|
+
this.predicates
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
/** Escape hatch: add an arbitrary predicate function. Not serializable. */
|
|
378
|
+
filter(fn) {
|
|
379
|
+
const clause = {
|
|
380
|
+
type: "filter",
|
|
381
|
+
fn
|
|
382
|
+
};
|
|
383
|
+
return new _Query(
|
|
384
|
+
this.source,
|
|
385
|
+
{ ...this.plan, clauses: [...this.plan.clauses, clause] },
|
|
386
|
+
this.joinContext,
|
|
387
|
+
this.reduceStrategy,
|
|
388
|
+
this.predicates
|
|
389
|
+
);
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Sort by a field. Subsequent calls are tie-breakers. Pass
|
|
393
|
+
* `{ by: 'label' }` to sort a `dictKey`/`staticDict` field by its resolved
|
|
394
|
+
* label at the query locale instead of the stored code.
|
|
395
|
+
*
|
|
396
|
+
* Consults the Via pipeline's posture (#629 Task 8): a field whose posture
|
|
397
|
+
* is `queryable: 'none'` throws `FieldNotQueryableError` here, at the call
|
|
398
|
+
* site — same gate as `where()`.
|
|
399
|
+
*/
|
|
400
|
+
orderBy(field, direction = "asc", opts) {
|
|
401
|
+
if (this.source.via?.postureFor(field)?.queryable === "none") throw new FieldNotQueryableError(field);
|
|
402
|
+
const entry = opts?.by === "label" ? { field, direction, by: "label" } : { field, direction };
|
|
403
|
+
return new _Query(
|
|
404
|
+
this.source,
|
|
405
|
+
{ ...this.plan, orderBy: [...this.plan.orderBy, entry] },
|
|
406
|
+
this.joinContext,
|
|
407
|
+
this.reduceStrategy,
|
|
408
|
+
this.predicates
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
/** Cap the result size. */
|
|
412
|
+
limit(n) {
|
|
413
|
+
return new _Query(
|
|
414
|
+
this.source,
|
|
415
|
+
{ ...this.plan, limit: n },
|
|
416
|
+
this.joinContext,
|
|
417
|
+
this.reduceStrategy,
|
|
418
|
+
this.predicates
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Resume strictly after the row an opaque keyset cursor names (#1346).
|
|
423
|
+
*
|
|
424
|
+
* ```ts
|
|
425
|
+
* const first = people.query().orderBy('name').limit(20).page()
|
|
426
|
+
* const next = people.query().orderBy('name').limit(20).after(first.nextCursor!).page()
|
|
427
|
+
* ```
|
|
428
|
+
*
|
|
429
|
+
* Unlike `offset(n)`, the window is anchored to a `(sortKey, id)` position,
|
|
430
|
+
* so a record inserted or deleted before it — including the cursor's own
|
|
431
|
+
* row — cannot re-serve or skip a record.
|
|
432
|
+
*
|
|
433
|
+
* The cursor is OPAQUE: pass back a `nextCursor` from `.page()` verbatim
|
|
434
|
+
* and do not parse it. It is validated when the query executes (not here —
|
|
435
|
+
* the sort spec it is bound to may still be added to the chain), and a
|
|
436
|
+
* cursor from a different collection or a different `orderBy(...)` spec is
|
|
437
|
+
* REFUSED rather than mis-paged.
|
|
438
|
+
*
|
|
439
|
+
* Requires at least one `orderBy(...)`, an id-paired (collection-backed)
|
|
440
|
+
* source, no join legs and no `offset()`; each is a loud error at execution.
|
|
441
|
+
*/
|
|
442
|
+
after(cursor) {
|
|
443
|
+
if (typeof cursor !== "string" || cursor.length === 0) {
|
|
444
|
+
throw new Error("Query.after(): a cursor must be a non-empty string \u2014 pass back the `nextCursor` from .page().");
|
|
445
|
+
}
|
|
446
|
+
return new _Query(
|
|
447
|
+
this.source,
|
|
448
|
+
{ ...this.plan, after: cursor },
|
|
449
|
+
this.joinContext,
|
|
450
|
+
this.reduceStrategy,
|
|
451
|
+
this.predicates
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
/** Skip the first N matching records (after ordering). */
|
|
455
|
+
offset(n) {
|
|
456
|
+
return new _Query(
|
|
457
|
+
this.source,
|
|
458
|
+
{ ...this.plan, offset: n },
|
|
459
|
+
this.joinContext,
|
|
460
|
+
this.reduceStrategy,
|
|
461
|
+
this.predicates
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Resolve a `ref()`-declared foreign key and attach the right-side
|
|
466
|
+
* record under `opts.as`. — eager, single-FK, intra-
|
|
467
|
+
* vault joins.
|
|
468
|
+
*
|
|
469
|
+
* ```ts
|
|
470
|
+
* const rows = invoices.query()
|
|
471
|
+
* .where('status', '==', 'open')
|
|
472
|
+
* .join('clientId', { as: 'client' })
|
|
473
|
+
* .toArray()
|
|
474
|
+
* // → [{ id, amount, client: { id, name, ... } }, ...]
|
|
475
|
+
* ```
|
|
476
|
+
*
|
|
477
|
+
* Preconditions:
|
|
478
|
+
* - The Query must have a `joinContext` (constructed via
|
|
479
|
+
* `Collection.query()`, not `new Query`).
|
|
480
|
+
* - `field` must have a matching `refs: { [field]: ref('<target>') }`
|
|
481
|
+
* declaration on the left collection.
|
|
482
|
+
* - The target collection must be reachable via the vault
|
|
483
|
+
* (either currently open or openable on demand).
|
|
484
|
+
*
|
|
485
|
+
* Strategy:
|
|
486
|
+
* - Nested-loop against `lookupById` when the target source
|
|
487
|
+
* provides it (the common path for Collection targets).
|
|
488
|
+
* - Hash join otherwise, or when `{ strategy: 'hash' }` is
|
|
489
|
+
* explicitly passed for test purposes.
|
|
490
|
+
*
|
|
491
|
+
* Ref-mode semantics on dangling refs (left record has a non-null
|
|
492
|
+
* FK value pointing at a right-side id that doesn't exist):
|
|
493
|
+
* - `strict` → throws `DanglingReferenceError` with the full
|
|
494
|
+
* field / target / refId context.
|
|
495
|
+
* - `warn` → attaches `null` and emits a one-shot warning per
|
|
496
|
+
* unique dangling pair.
|
|
497
|
+
* - `cascade` → attaches `null` silently. Cascade is a
|
|
498
|
+
* delete-time mode; dangling refs visible at read time are
|
|
499
|
+
* either mid-flight cascades or pre-existing orphans, not a
|
|
500
|
+
* DSL-level error.
|
|
501
|
+
*
|
|
502
|
+
* A left-side record whose FK field is `null` / `undefined` is NOT
|
|
503
|
+
* a dangling ref — it's "no reference at all", always allowed
|
|
504
|
+
* regardless of mode.
|
|
505
|
+
*
|
|
506
|
+
* The return type widens `T` with `Record<As, R | null>`. The `R`
|
|
507
|
+
* parameter is optional — supply it explicitly for type-checked
|
|
508
|
+
* access to the joined fields:
|
|
509
|
+
*
|
|
510
|
+
* ```ts
|
|
511
|
+
* invoices.query().join<'client', Client>('clientId', { as: 'client' })
|
|
512
|
+
* // ^^^^^^^^^^^^^^^^^^^ alias literal + right-side type
|
|
513
|
+
* ```
|
|
514
|
+
*
|
|
515
|
+
* Without the generic, the joined field is typed as `unknown`, which
|
|
516
|
+
* still works but requires a cast to access its properties.
|
|
517
|
+
*
|
|
518
|
+
* Joins stay intra-vault by construction — cross-vault
|
|
519
|
+
* correlation goes through `Noydb.queryAcross`, not
|
|
520
|
+
* `.join()`.
|
|
521
|
+
*/
|
|
522
|
+
/**
|
|
523
|
+
* Execute the plan and return the matching records. When the plan
|
|
524
|
+
* carries any join legs, they are applied after `where` / `orderBy`
|
|
525
|
+
* / `limit` / `offset` narrow the left set — UNLESS a clause (#1030) or
|
|
526
|
+
* the ordering (#1337) addresses a join alias, in which case the legs run
|
|
527
|
+
* first and the sort/page observe the joined relation. See the `.join()`
|
|
528
|
+
* doc for the ordering rationale, and `.explain()` for which one a given
|
|
529
|
+
* plan gets.
|
|
530
|
+
*
|
|
531
|
+
* `opts.locale` resolves JOINED right-side i18n fields at the
|
|
532
|
+
* `join` layer to that locale; without it, the owning collection's default
|
|
533
|
+
* locale applies, and a locale-less query leaves joined i18n fields raw.
|
|
534
|
+
* (Left/base i18n fields are resolved by `get`/`list`, not here.)
|
|
535
|
+
*
|
|
536
|
+
* **Synchronous** (#1413) — returns `T[]`, not a promise; the cache it reads is
|
|
537
|
+
* already decrypted. `await` is safe and is REQUIRED on an unhydrated collection
|
|
538
|
+
* (#1414); `.catch()` is not available. See the {@link Query} class doc.
|
|
539
|
+
*/
|
|
540
|
+
toArray(opts) {
|
|
541
|
+
const _h = this.source.hydration;
|
|
542
|
+
if (_h !== void 0 && !_h.isHydrated()) return gateTerminal(_h, "toArray", () => this.toArray(opts));
|
|
543
|
+
if (this.plan.after !== void 0) return this.executeKeyset(opts).rows;
|
|
544
|
+
const { preJoin, postJoin } = splitAroundJoins(this.plan.clauses, this.plan.joins);
|
|
545
|
+
const orderPostJoin = orderReferencesJoinAlias(this.plan.orderBy, this.plan.joins);
|
|
546
|
+
const innerDrops = joinsDropLeftRows(this.plan.joins);
|
|
547
|
+
if (postJoin.length === 0 && !orderPostJoin) {
|
|
548
|
+
const pagePlan = innerDrops ? { ...this.plan, offset: 0, limit: void 0 } : this.plan;
|
|
549
|
+
const base = this.decodeVia(
|
|
550
|
+
executePlanWithSource(this.source, pagePlan, this.joinContext, opts?.locale, this.aliasVia()),
|
|
551
|
+
opts?.locale
|
|
552
|
+
);
|
|
553
|
+
if (this.plan.joins.length === 0) return this.dressAliases(base);
|
|
554
|
+
const joined2 = applyJoins(base, this.plan.joins, this.requireJoinContext("toArray"), opts?.locale);
|
|
555
|
+
if (!innerDrops) return this.dressAliases(joined2);
|
|
556
|
+
const from = this.plan.offset;
|
|
557
|
+
return this.dressAliases(
|
|
558
|
+
this.plan.limit === void 0 ? joined2.slice(from) : joined2.slice(from, from + this.plan.limit)
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
const joinContext = this.requireJoinContext("toArray");
|
|
562
|
+
const narrowed = executePlanWithSource(
|
|
563
|
+
this.source,
|
|
564
|
+
{ ...this.plan, clauses: preJoin, orderBy: [], limit: void 0, offset: 0 },
|
|
565
|
+
joinContext,
|
|
566
|
+
opts?.locale
|
|
567
|
+
);
|
|
568
|
+
const joined = applyJoins(narrowed, this.plan.joins, joinContext, opts?.locale);
|
|
569
|
+
const filtered = filterRecords(joined, postJoin, fnViewDecoder(this.source));
|
|
570
|
+
const paged = applyOrderAndPage(filtered, this.plan, this.source, joinContext, opts?.locale, this.aliasVia());
|
|
571
|
+
return this.dressAliases(this.decodeVia(paged, opts?.locale));
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* Apply each aliased side's OWN Via result decode, in place of the
|
|
575
|
+
* top-level decode that cannot reach it (#1289, and the fix for #1335).
|
|
576
|
+
*
|
|
577
|
+
* `decodeVia` keys by bare field name, so it dresses exactly the fields
|
|
578
|
+
* sitting at the top of the row. Everything a join puts under an alias —
|
|
579
|
+
* a `.join()`/`.rightJoin()` right record, a `.crossJoin()` right record,
|
|
580
|
+
* and BOTH sides of a `.crossJoinWith()` pair — is therefore invisible to
|
|
581
|
+
* it, and was served raw: a self cross-join returned `"10.00"` on the left
|
|
582
|
+
* and `"1000"` on the right of the same field (#1335).
|
|
583
|
+
*
|
|
584
|
+
* Runs LAST, after every filter, sort and page. That is deliberate: a
|
|
585
|
+
* `where()` operand is built in raw stored space, so dressing earlier would
|
|
586
|
+
* make a post-join predicate compare a decoded string against a raw one.
|
|
587
|
+
* Dressing is presentation; it belongs after the plan has finished.
|
|
588
|
+
*
|
|
589
|
+
* Each alias is decoded by the Via pipeline of the collection the record
|
|
590
|
+
* came FROM — money on the right side is the right side's declaration, not
|
|
591
|
+
* this collection's. A source that declares no result decode returns the
|
|
592
|
+
* record unchanged, so the whole pass is a no-op for the common query and
|
|
593
|
+
* is skipped entirely when the plan has no aliases.
|
|
594
|
+
*/
|
|
595
|
+
dressAliases(rows) {
|
|
596
|
+
if (rows.length === 0) return rows;
|
|
597
|
+
const ctx = this.joinContext;
|
|
598
|
+
if (!ctx) return rows;
|
|
599
|
+
const targets = [];
|
|
600
|
+
const push = (path, collection) => {
|
|
601
|
+
const decode = ctx.resolveSource(collection)?.decodeResults;
|
|
602
|
+
if (decode) targets.push({ path, decode });
|
|
603
|
+
};
|
|
604
|
+
for (const clause of this.plan.clauses) {
|
|
605
|
+
if (clause.type !== "crossJoin") continue;
|
|
606
|
+
push(clause.as, clause.target);
|
|
607
|
+
if (clause.leftAs !== void 0) push(clause.leftAs, ctx.leftCollection);
|
|
608
|
+
}
|
|
609
|
+
for (const leg of this.plan.joins) {
|
|
610
|
+
if (leg.isDictJoin === true) continue;
|
|
611
|
+
push(leg.as, leg.target);
|
|
612
|
+
}
|
|
613
|
+
if (targets.length === 0) return rows;
|
|
614
|
+
return rows.map((row) => {
|
|
615
|
+
if (row === null || typeof row !== "object") return row;
|
|
616
|
+
let out;
|
|
617
|
+
for (const { path, decode } of targets) {
|
|
618
|
+
const value = row[path];
|
|
619
|
+
if (value === null || value === void 0 || typeof value !== "object") continue;
|
|
620
|
+
const dressed = decode(value);
|
|
621
|
+
if (dressed === value) continue;
|
|
622
|
+
out ??= { ...row };
|
|
623
|
+
out[path] = dressed;
|
|
624
|
+
}
|
|
625
|
+
return out ?? row;
|
|
626
|
+
});
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Alias → the Via pipeline of the collection whose records sit under it
|
|
630
|
+
* (#1337). Every alias this plan can produce: a `.join()`/`.rightJoin()`
|
|
631
|
+
* leg, a `.crossJoin()` right side, and both sides of `.crossJoinWith()`.
|
|
632
|
+
*
|
|
633
|
+
* ⭐ **Ordering compares in RAW STORED SPACE, never in dressed space, and
|
|
634
|
+
* that is what forces this map to exist.** `dressAliases` runs LAST — after
|
|
635
|
+
* every filter, sort and page — because a `where` operand is built raw. So
|
|
636
|
+
* the sort sees money as its stored scaled integer, where a generic compare
|
|
637
|
+
* is lexical and gets `'9882'` vs `'10004'` backwards. The left side has
|
|
638
|
+
* always avoided that by asking `source.via.compareForOrder`; an aliased
|
|
639
|
+
* field needs the same question asked of the RIGHT side's pipeline, keyed
|
|
640
|
+
* by the field name WITHOUT the alias prefix (a pipeline covers bare field
|
|
641
|
+
* names — that is the whole of #1335's shape).
|
|
642
|
+
*
|
|
643
|
+
* Empty when no alias resolves a pipeline, in which case the comparator
|
|
644
|
+
* falls back to exactly what it did before.
|
|
645
|
+
*/
|
|
646
|
+
aliasVia() {
|
|
647
|
+
const ctx = this.joinContext;
|
|
648
|
+
if (!ctx) return void 0;
|
|
649
|
+
const out = /* @__PURE__ */ new Map();
|
|
650
|
+
const push = (alias, collection) => {
|
|
651
|
+
const via = ctx.resolveSource(collection)?.via?.();
|
|
652
|
+
if (via) out.set(alias, via);
|
|
653
|
+
};
|
|
654
|
+
for (const clause of this.plan.clauses) {
|
|
655
|
+
if (clause.type !== "crossJoin") continue;
|
|
656
|
+
push(clause.as, clause.target);
|
|
657
|
+
if (clause.leftAs !== void 0) push(clause.leftAs, ctx.leftCollection);
|
|
658
|
+
}
|
|
659
|
+
for (const leg of this.plan.joins) {
|
|
660
|
+
if (leg.isDictJoin === true) continue;
|
|
661
|
+
push(leg.as, leg.target);
|
|
662
|
+
}
|
|
663
|
+
return out.size > 0 ? out : void 0;
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
666
|
+
* Joins need a `JoinContext`. Unreachable in practice — `.join()` throws
|
|
667
|
+
* when one is missing — but belt-and-braces for a plan built through the
|
|
668
|
+
* raw `Query` constructor with joins pre-populated.
|
|
669
|
+
*/
|
|
670
|
+
requireJoinContext(terminal) {
|
|
671
|
+
if (!this.joinContext) {
|
|
672
|
+
throw new Error(
|
|
673
|
+
`Query.${terminal}(): plan carries ${this.plan.joins.length} join leg(s) but no JoinContext is attached. This usually means the Query was constructed via the raw Query constructor with a plan that had joins pre-populated. Use collection.query().join(...) instead.`
|
|
674
|
+
);
|
|
675
|
+
}
|
|
676
|
+
return this.joinContext;
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Present this source's Via-covered fields on read, so `query().toArray()`
|
|
680
|
+
* agrees with `get()`/`list()` about what a record contains (#1416).
|
|
681
|
+
*
|
|
682
|
+
* ⛔ THIS USED TO RUN `decodeResults`, WHICH IS NOT THE SAME QUESTION. That
|
|
683
|
+
* hook is money's stored→canonical decode and nothing else, so a
|
|
684
|
+
* `computed({ mode: 'virtual' })` field read `undefined` on a query row while
|
|
685
|
+
* `get()` returned it — the same record with two shapes depending on which
|
|
686
|
+
* verb produced it, and a caller summing that field over a query result got
|
|
687
|
+
* `NaN` with no error. Reported at `receiptAmount get=84715.00 query=undefined`.
|
|
688
|
+
*
|
|
689
|
+
* The old doc comment defended the omission of money's `<field>Formatted` /
|
|
690
|
+
* `<field>Number` virtuals on the grounds that "the query layer carries no
|
|
691
|
+
* locale context", and that reasoning was right: fabricating a guessed-locale
|
|
692
|
+
* string here would make it-IT via `get()` disagree with en-US here. ⚠️ But
|
|
693
|
+
* the premise had gone stale — `toArray({ locale })` exists and threads its
|
|
694
|
+
* locale into `executePlanWithSource`, `applyJoins` and `applyOrderAndPage`.
|
|
695
|
+
* This was the one call site that never received it, which is also why joined
|
|
696
|
+
* ALIASES were dressed while the base row was not.
|
|
697
|
+
*
|
|
698
|
+
* So this presents at `'raw'`: values — money's canonical decode and every
|
|
699
|
+
* virtual computed field — while money's binding gates the locale-formatted
|
|
700
|
+
* virtuals on `locale !== 'raw'`, so nothing is guessed.
|
|
701
|
+
*
|
|
702
|
+
* ⛔ HONOURING `toArray({ locale })` HERE IS A SEPARATE CHANGE, and the
|
|
703
|
+
* obvious implementation is measurably wrong. Presenting twice — once raw for
|
|
704
|
+
* the plan, once at the locale for output — silently yields the RAW result:
|
|
705
|
+
*
|
|
706
|
+
* presentSync(stored, raw) -> { amount: "84715.00" }
|
|
707
|
+
* presentSync(that, 'en-US') -> { amount: "84715.00" } <-- no siblings
|
|
708
|
+
* presentSync(stored, 'en-US') -> { amount: "84715.00",
|
|
709
|
+
* amountFormatted: "THB 84,715.00", ... }
|
|
710
|
+
*
|
|
711
|
+
* because the second pass sees an already-decoded value and re-emits no
|
|
712
|
+
* siblings. So formatting has to happen in ONE pass at the final locale —
|
|
713
|
+
* and one of this method's call sites runs BEFORE the post-join filter,
|
|
714
|
+
* where a formatted value would change what a `where()` predicate compares
|
|
715
|
+
* against. That is the same rule `dressAliases` states: dressing is
|
|
716
|
+
* presentation and belongs after the plan has finished. Deciding it needs
|
|
717
|
+
* its own change; leaving `toArray({ locale })` inert for base rows is the
|
|
718
|
+
* status quo, not a new hole.
|
|
719
|
+
*
|
|
720
|
+
* ⚠️ SYNCHRONOUS, so it folds only the bindings that declared
|
|
721
|
+
* `presentIsSync` — money and computed. A collection also using i18n or
|
|
722
|
+
* lookup keeps those fields undressed here, exactly as today; `presentSync`
|
|
723
|
+
* reports them and `explain()` says so rather than leaving a silent hole.
|
|
724
|
+
* Making this complete would mean making `toArray()` async, which is the
|
|
725
|
+
* contract #1413 deliberately established.
|
|
726
|
+
*/
|
|
727
|
+
decodeVia(records, locale) {
|
|
728
|
+
const via = this.source.via;
|
|
729
|
+
if (!via) return records;
|
|
730
|
+
const ctx = { locale: locale ?? "raw", layer: "read" };
|
|
731
|
+
return records.map((r) => via.presentSync(r, ctx).record);
|
|
732
|
+
}
|
|
733
|
+
/**
|
|
734
|
+
* Terminal sibling of `toArray()` that also returns the cursor for the next
|
|
735
|
+
* page (#1346): `{ rows, nextCursor }`, where `nextCursor` is `null` once
|
|
736
|
+
* the last page has been served.
|
|
737
|
+
*
|
|
738
|
+
* ```ts
|
|
739
|
+
* const { rows, nextCursor } = people.query().orderBy('name').limit(20).page()
|
|
740
|
+
* ```
|
|
741
|
+
*
|
|
742
|
+
* Without a sorted index this is still a scan with a keyset filter — stable,
|
|
743
|
+
* not fast. The fast path is a separate concern (#1344).
|
|
744
|
+
*
|
|
745
|
+
* Same requirements as `.after()`: at least one `orderBy(...)`, an id-paired
|
|
746
|
+
* (collection-backed) source, no join legs, no `offset()`.
|
|
747
|
+
*
|
|
748
|
+
* **Synchronous** (#1413) — returns `{ rows, nextCursor }`, not a promise; the cache it reads is
|
|
749
|
+
* already decrypted. `await` is safe and is REQUIRED on an unhydrated collection
|
|
750
|
+
* (#1414); `.catch()` is not available. See the {@link Query} class doc.
|
|
751
|
+
*/
|
|
752
|
+
page(opts) {
|
|
753
|
+
const _h = this.source.hydration;
|
|
754
|
+
if (_h !== void 0 && !_h.isHydrated()) return gateTerminal(_h, "page", () => this.page(opts));
|
|
755
|
+
return this.executeKeyset(opts);
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* The keyset engine behind `page()` / `after()`.
|
|
759
|
+
*
|
|
760
|
+
* It deliberately does NOT reuse `applyOrderAndPage`: paging by keyset needs
|
|
761
|
+
* a TOTAL order (the id breaks ties that the ordinary sort leaves to input
|
|
762
|
+
* order) and needs the id alongside each row to mint the cursor. Both are
|
|
763
|
+
* properties of this path only, so the ordinary read path is untouched.
|
|
764
|
+
*/
|
|
765
|
+
executeKeyset(opts) {
|
|
766
|
+
const plan = this.plan;
|
|
767
|
+
if (plan.orderBy.length === 0) {
|
|
768
|
+
throw new Error(
|
|
769
|
+
"Query.page()/after(): keyset pagination requires at least one orderBy(...) \u2014 a cursor names a position in a sort order, so there must be one to name."
|
|
770
|
+
);
|
|
771
|
+
}
|
|
772
|
+
if (plan.offset > 0) {
|
|
773
|
+
throw new Error(
|
|
774
|
+
"Query.page()/after(): offset() cannot be combined with a keyset cursor. They are two different pagination strategies \u2014 drop offset() and page with after(nextCursor)."
|
|
775
|
+
);
|
|
776
|
+
}
|
|
777
|
+
if (plan.joins.length > 0 || plan.clauses.some((c) => c.type === "crossJoin")) {
|
|
778
|
+
throw new Error(
|
|
779
|
+
"Query.page()/after(): keyset pagination does not support join legs or crossJoin (joined rows are new objects, so the record id the cursor needs is not recoverable). Page the left side, then join per page."
|
|
780
|
+
);
|
|
781
|
+
}
|
|
782
|
+
const source = this.source;
|
|
783
|
+
const snapshotEntries = source.snapshotEntries === void 0 ? void 0 : () => source.snapshotEntries();
|
|
784
|
+
if (snapshotEntries === void 0) {
|
|
785
|
+
throw new Error(
|
|
786
|
+
"Query.page()/after(): the query source has no snapshotEntries(); keyset pagination requires a collection-backed query (collection.query())."
|
|
787
|
+
);
|
|
788
|
+
}
|
|
789
|
+
const memoKey = keysetMemoKey(this.source, plan, opts?.locale);
|
|
790
|
+
const cached = memoKey === null ? void 0 : readKeysetMemo(memoKey);
|
|
791
|
+
let sorted;
|
|
792
|
+
let keyPlan;
|
|
793
|
+
if (cached) {
|
|
794
|
+
sorted = cached.sorted;
|
|
795
|
+
keyPlan = cached.keyPlan;
|
|
796
|
+
} else {
|
|
797
|
+
const refToId = /* @__PURE__ */ new Map();
|
|
798
|
+
for (const { id, record } of snapshotEntries()) refToId.set(record, id);
|
|
799
|
+
const matched = executePlanWithSource(
|
|
800
|
+
this.source,
|
|
801
|
+
{ ...plan, orderBy: [], limit: void 0, offset: 0, after: void 0 },
|
|
802
|
+
this.joinContext,
|
|
803
|
+
opts?.locale
|
|
804
|
+
);
|
|
805
|
+
const labelMaps = buildOrderLabelMaps(plan.orderBy, this.joinContext, opts?.locale, this.source.via);
|
|
806
|
+
keyPlan = buildOrderKeyPlan(plan.orderBy, this.source.via, labelMaps);
|
|
807
|
+
sorted = matched.map((record) => ({ record, id: refToId.get(record) ?? "", key: orderKeyOf(keyPlan, record) })).sort((a, b) => compareOrderKeys(keyPlan, a.key, b.key) || compareIds(a.id, b.id));
|
|
808
|
+
if (memoKey !== null) writeKeysetMemo(memoKey, { sorted, keyPlan });
|
|
809
|
+
}
|
|
810
|
+
const shape = keysetShape(this.source.identity, plan.orderBy);
|
|
811
|
+
let start = 0;
|
|
812
|
+
if (plan.after !== void 0) {
|
|
813
|
+
const cursor = decodeCursor(plan.after, shape);
|
|
814
|
+
start = lowerBound(
|
|
815
|
+
sorted,
|
|
816
|
+
(r) => (compareOrderKeys(keyPlan, r.key, cursor.values) || compareIds(r.id, cursor.id)) > 0
|
|
817
|
+
);
|
|
818
|
+
}
|
|
819
|
+
const end = plan.limit === void 0 ? sorted.length : start + plan.limit;
|
|
820
|
+
const window = sorted.slice(start, end);
|
|
821
|
+
const last = window[window.length - 1];
|
|
822
|
+
const nextCursor = last !== void 0 && end < sorted.length ? encodeCursor({ shape, values: last.key, id: last.id }) : null;
|
|
823
|
+
return { rows: this.decodeVia(window.map((r) => r.record)), nextCursor };
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* Return the first matching record, or null. Joins are applied. `opts.locale`
|
|
827
|
+
* resolves joined i18n fields.
|
|
828
|
+
*
|
|
829
|
+
* **Synchronous** (#1413) — returns `T | null`, not a promise; the cache it reads is
|
|
830
|
+
* already decrypted. `await` is safe and is REQUIRED on an unhydrated collection
|
|
831
|
+
* (#1414); `.catch()` is not available. See the {@link Query} class doc.
|
|
832
|
+
*/
|
|
833
|
+
first(opts) {
|
|
834
|
+
const _h = this.source.hydration;
|
|
835
|
+
if (_h !== void 0 && !_h.isHydrated()) return gateTerminal(_h, "first", () => this.first(opts));
|
|
836
|
+
const arr = this.limit(1).toArray(opts);
|
|
837
|
+
return arr[0] ?? null;
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* Return the number of matching records (after where/filter,
|
|
841
|
+
* before limit). **Joins are normally NOT applied** — count() reports the
|
|
842
|
+
* left-side cardinality, because joins are projection-only
|
|
843
|
+
* (they attach an aliased field; they never filter). Running joins
|
|
844
|
+
* here just to discard the aliases would be wasteful, and in strict
|
|
845
|
+
* mode it could throw `DanglingReferenceError` for a call whose
|
|
846
|
+
* intent is purely to count.
|
|
847
|
+
*
|
|
848
|
+
* The exception (#1030) is a `where` clause addressing a join alias. Then
|
|
849
|
+
* the legs must run, because the predicate is part of what is being
|
|
850
|
+
* counted — skipping them would report the unfiltered left cardinality.
|
|
851
|
+
* A strict-mode `DanglingReferenceError` becomes reachable from `count()`
|
|
852
|
+
* in exactly that case, which is acceptable: the caller asked to filter on
|
|
853
|
+
* the joined side, so they asked for the join.
|
|
854
|
+
*
|
|
855
|
+
* **Synchronous** (#1413) — returns `number`, not a promise; the cache it reads is
|
|
856
|
+
* already decrypted. `await` is safe and is REQUIRED on an unhydrated collection
|
|
857
|
+
* (#1414); `.catch()` is not available. See the {@link Query} class doc.
|
|
858
|
+
*/
|
|
859
|
+
count() {
|
|
860
|
+
const _h = this.source.hydration;
|
|
861
|
+
if (_h !== void 0 && !_h.isHydrated()) return gateTerminal(_h, "count", () => this.count());
|
|
862
|
+
return this.matchedRecords("count").length;
|
|
863
|
+
}
|
|
864
|
+
/**
|
|
865
|
+
* The match set every reduce-shaped terminal reports over: `count()`,
|
|
866
|
+
* `distinct()`, and `exists()`'s non-short-circuit fallbacks.
|
|
867
|
+
*
|
|
868
|
+
* Extracted (#1347) rather than copied a third time, because "which records
|
|
869
|
+
* does this terminal see" is an INVARIANT across them — `distinct()`
|
|
870
|
+
* returning values `count()` never counted would be a bug nobody would look
|
|
871
|
+
* for. It is deliberately the `count()` pipeline: where/filter apply, joins
|
|
872
|
+
* apply only when a predicate addresses one (#1030), and orderBy/limit/offset
|
|
873
|
+
* do NOT — those describe a page, and a reduction is not paginated.
|
|
874
|
+
*/
|
|
875
|
+
matchedRecords(terminal, forceJoins = false) {
|
|
876
|
+
if (this.plan.clauses.some((c) => c.type === "crossJoin")) {
|
|
877
|
+
if (!this.joinContext) {
|
|
878
|
+
throw new Error(
|
|
879
|
+
`Query.${terminal}(): plan contains crossJoin clauses but no JoinContext is attached.`
|
|
880
|
+
);
|
|
881
|
+
}
|
|
882
|
+
return executeClausePipeline(this.source, this.plan.clauses, this.joinContext);
|
|
883
|
+
}
|
|
884
|
+
const { preJoin, postJoin } = splitAroundJoins(this.plan.clauses, this.plan.joins);
|
|
885
|
+
const { candidates, remainingClauses } = candidateRecords(this.source, preJoin);
|
|
886
|
+
const narrowed = remainingClauses.length === 0 ? candidates : filterRecords(candidates, remainingClauses, fnViewDecoder(this.source));
|
|
887
|
+
const reshapes = this.plan.joins.some((leg) => leg.direction !== void 0 && leg.direction !== "left") || joinsDropLeftRows(this.plan.joins);
|
|
888
|
+
if (postJoin.length === 0 && !reshapes && !forceJoins) return narrowed;
|
|
889
|
+
const joined = applyJoins(narrowed, this.plan.joins, this.requireJoinContext(terminal));
|
|
890
|
+
return filterRecords(joined, postJoin, fnViewDecoder(this.source));
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* Whether ANY record matches (#1347) — `count() > 0` without paying for the
|
|
894
|
+
* records after the first.
|
|
895
|
+
*
|
|
896
|
+
* The saving is real rather than cosmetic: `count()` evaluates every
|
|
897
|
+
* remaining clause against every candidate, so a `.filter(fn)` over 10_000
|
|
898
|
+
* records calls `fn` 10_000 times to answer a yes/no question. This returns
|
|
899
|
+
* at the first hit, and `__tests__/query-distinct-exists.test.ts` witnesses
|
|
900
|
+
* that by COUNTING the predicate's invocations — a boolean assertion cannot
|
|
901
|
+
* tell a short-circuit from a full scan.
|
|
902
|
+
*
|
|
903
|
+
* Same match set as `count()`. Two shapes do NOT short-circuit and fall
|
|
904
|
+
* back to it, because both must materialize the relation before anything
|
|
905
|
+
* can be tested: a `crossJoin` expansion, and a `where` clause addressing a
|
|
906
|
+
* join alias (#1030). Both still answer correctly.
|
|
907
|
+
*
|
|
908
|
+
* **Synchronous** (#1413) — returns `boolean`, not a promise; the cache it reads is
|
|
909
|
+
* already decrypted. `await` is safe and is REQUIRED on an unhydrated collection
|
|
910
|
+
* (#1414); `.catch()` is not available. See the {@link Query} class doc.
|
|
911
|
+
*/
|
|
912
|
+
exists() {
|
|
913
|
+
const _h = this.source.hydration;
|
|
914
|
+
if (_h !== void 0 && !_h.isHydrated()) return gateTerminal(_h, "exists", () => this.exists());
|
|
915
|
+
if (this.plan.clauses.some((c) => c.type === "crossJoin")) {
|
|
916
|
+
return this.matchedRecords("exists").length > 0;
|
|
917
|
+
}
|
|
918
|
+
const { preJoin, postJoin } = splitAroundJoins(this.plan.clauses, this.plan.joins);
|
|
919
|
+
if (postJoin.length > 0 || joinsDropLeftRows(this.plan.joins)) {
|
|
920
|
+
return this.matchedRecords("exists").length > 0;
|
|
921
|
+
}
|
|
922
|
+
const { candidates, remainingClauses } = candidateRecords(this.source, preJoin);
|
|
923
|
+
if (remainingClauses.length === 0) return candidates.length > 0;
|
|
924
|
+
return anyMatches(candidates, remainingClauses, fnViewDecoder(this.source));
|
|
925
|
+
}
|
|
926
|
+
/**
|
|
927
|
+
* Return the plan as a JSON-friendly object. FilterClause entries are
|
|
928
|
+
* stripped (their `fn` cannot be serialized) and replaced with
|
|
929
|
+
* { type: 'filter', fn: '[function]' } so devtools can still see them.
|
|
930
|
+
*/
|
|
931
|
+
toPlan() {
|
|
932
|
+
return serializePlan(this.plan);
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
var EXTENSION_METHODS = [
|
|
936
|
+
["subscribe", "@noy-db/hub/query/live"],
|
|
937
|
+
["live", "@noy-db/hub/query/live"],
|
|
938
|
+
["aggregate", "@noy-db/hub/query/reduce"],
|
|
939
|
+
["groupBy", "@noy-db/hub/query/reduce"],
|
|
940
|
+
["window", "@noy-db/hub/query/reduce"],
|
|
941
|
+
["distinct", "@noy-db/hub/query/reduce"],
|
|
942
|
+
["join", "@noy-db/hub/query/relate"],
|
|
943
|
+
["joinOn", "@noy-db/hub/query/relate"],
|
|
944
|
+
["rightJoin", "@noy-db/hub/query/relate"],
|
|
945
|
+
["fullOuterJoin", "@noy-db/hub/query/relate"],
|
|
946
|
+
["crossJoin", "@noy-db/hub/query/relate"],
|
|
947
|
+
["crossJoinWith", "@noy-db/hub/query/relate"],
|
|
948
|
+
["traverse", "@noy-db/hub/query/relate"],
|
|
949
|
+
["ancestorsOf", "@noy-db/hub/query/relate"],
|
|
950
|
+
["descendantsOf", "@noy-db/hub/query/relate"],
|
|
951
|
+
["explain", "@noy-db/hub/query/relate"]
|
|
952
|
+
];
|
|
953
|
+
for (const [method, subpath] of EXTENSION_METHODS) {
|
|
954
|
+
Object.defineProperty(Query.prototype, method, {
|
|
955
|
+
value: function extensionMissing() {
|
|
956
|
+
throw new QueryExtensionMissingError(method, subpath);
|
|
957
|
+
},
|
|
958
|
+
writable: true,
|
|
959
|
+
enumerable: false,
|
|
960
|
+
configurable: true
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
function executePlanWithSource(source, plan, joinContext, locale, aliasVia) {
|
|
964
|
+
const hasCrossJoins = plan.clauses.some((c) => c.type === "crossJoin");
|
|
965
|
+
let result;
|
|
966
|
+
if (hasCrossJoins) {
|
|
967
|
+
if (!joinContext) {
|
|
968
|
+
throw new Error(
|
|
969
|
+
`Query.toArray(): plan contains crossJoin clauses but no JoinContext is attached. Use collection.query() instead of new Query() for cross-join support.`
|
|
970
|
+
);
|
|
971
|
+
}
|
|
972
|
+
result = executeClausePipeline(source, plan.clauses, joinContext);
|
|
973
|
+
} else {
|
|
974
|
+
const ordered = orderedIndexRows(source, plan) ?? compoundOrderedRows(source, plan);
|
|
975
|
+
if (ordered) return ordered;
|
|
976
|
+
const { candidates, remainingClauses } = candidateRecords(source, plan.clauses);
|
|
977
|
+
result = remainingClauses.length === 0 ? [...candidates] : filterRecords(candidates, remainingClauses, fnViewDecoder(source));
|
|
978
|
+
}
|
|
979
|
+
return applyOrderAndPage(result, plan, source, joinContext, locale, aliasVia);
|
|
980
|
+
}
|
|
981
|
+
function applyOrderAndPage(rows, plan, source, joinContext, locale, aliasVia) {
|
|
982
|
+
let result = rows;
|
|
983
|
+
if (plan.orderBy.length > 0) {
|
|
984
|
+
const labelMaps = buildOrderLabelMaps(plan.orderBy, joinContext, locale, source.via);
|
|
985
|
+
result = sortRecords(result, plan.orderBy, source.via, labelMaps, aliasVia);
|
|
986
|
+
}
|
|
987
|
+
if (plan.offset > 0) {
|
|
988
|
+
result = result.slice(plan.offset);
|
|
989
|
+
}
|
|
990
|
+
if (plan.limit !== void 0) {
|
|
991
|
+
result = result.slice(0, plan.limit);
|
|
992
|
+
}
|
|
993
|
+
return result;
|
|
994
|
+
}
|
|
995
|
+
var RANGE_OPERATORS = /* @__PURE__ */ new Set(["<", "<=", ">", ">=", "between", "startsWith"]);
|
|
996
|
+
function isRangeOperator(op) {
|
|
997
|
+
return RANGE_OPERATORS.has(op);
|
|
998
|
+
}
|
|
999
|
+
function orderedIndexRows(source, plan) {
|
|
1000
|
+
const limit = plan.limit;
|
|
1001
|
+
if (limit === void 0 || plan.clauses.length > 0 || plan.orderBy.length !== 1) return null;
|
|
1002
|
+
const [order] = plan.orderBy;
|
|
1003
|
+
if (!order || order.by === "label") return null;
|
|
1004
|
+
const indexes = source.getIndexes?.();
|
|
1005
|
+
if (!indexes || !source.lookupById || !indexes.hasSorted(order.field)) return null;
|
|
1006
|
+
const lookupById = (id) => source.lookupById?.(id);
|
|
1007
|
+
if (viaOrdersField(source.via, order.field)) return null;
|
|
1008
|
+
const snapshot = source.snapshot();
|
|
1009
|
+
if (indexes.sortedSize(order.field) !== snapshot.length) return null;
|
|
1010
|
+
const ids = indexes.orderedIds(order.field, order.direction);
|
|
1011
|
+
if (!ids) return null;
|
|
1012
|
+
const out = [];
|
|
1013
|
+
for (let i = plan.offset; i < ids.length && out.length < limit; i++) {
|
|
1014
|
+
const record = lookupById(ids[i]);
|
|
1015
|
+
if (record !== void 0) out.push(record);
|
|
1016
|
+
}
|
|
1017
|
+
return out;
|
|
1018
|
+
}
|
|
1019
|
+
function viaOrdersField(via, field) {
|
|
1020
|
+
return via !== void 0 && via.compareForOrder(field, "", "") !== void 0;
|
|
1021
|
+
}
|
|
1022
|
+
function indexableClauses(clauses) {
|
|
1023
|
+
const eq = /* @__PURE__ */ new Map();
|
|
1024
|
+
const ranges = /* @__PURE__ */ new Map();
|
|
1025
|
+
for (let i = 0; i < clauses.length; i++) {
|
|
1026
|
+
const clause = clauses[i];
|
|
1027
|
+
if (clause.type !== "field" || clause.via !== void 0) continue;
|
|
1028
|
+
if (clause.op === "==") {
|
|
1029
|
+
if (!eq.has(clause.field)) eq.set(clause.field, { value: clause.value, at: i });
|
|
1030
|
+
} else if (isRangeOperator(clause.op)) {
|
|
1031
|
+
if (!ranges.has(clause.field)) ranges.set(clause.field, { op: clause.op, value: clause.value, at: i });
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
return { eq, ranges };
|
|
1035
|
+
}
|
|
1036
|
+
function pickCompound(indexes, clauses) {
|
|
1037
|
+
const { eq, ranges } = indexableClauses(clauses);
|
|
1038
|
+
if (eq.size === 0) return null;
|
|
1039
|
+
let best = null;
|
|
1040
|
+
for (const fields of indexes.compoundTuples()) {
|
|
1041
|
+
const values = [];
|
|
1042
|
+
const consumed = /* @__PURE__ */ new Set();
|
|
1043
|
+
let depth = 0;
|
|
1044
|
+
while (depth < fields.length) {
|
|
1045
|
+
const hit = eq.get(fields[depth]);
|
|
1046
|
+
if (!hit) break;
|
|
1047
|
+
values.push(hit.value);
|
|
1048
|
+
consumed.add(hit.at);
|
|
1049
|
+
depth++;
|
|
1050
|
+
}
|
|
1051
|
+
if (depth === 0) continue;
|
|
1052
|
+
let range;
|
|
1053
|
+
if (depth < fields.length) {
|
|
1054
|
+
const hit = ranges.get(fields[depth]);
|
|
1055
|
+
if (hit) {
|
|
1056
|
+
range = { op: hit.op, value: hit.value };
|
|
1057
|
+
consumed.add(hit.at);
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
if (consumed.size < 2) continue;
|
|
1061
|
+
if (!best || consumed.size > best.consumed.size) {
|
|
1062
|
+
best = { fields, values, consumed, ...range ? { range } : {} };
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
return best;
|
|
1066
|
+
}
|
|
1067
|
+
function compoundCandidates(source, indexes, lookupById, clauses) {
|
|
1068
|
+
const pick = pickCompound(indexes, clauses);
|
|
1069
|
+
if (!pick) return null;
|
|
1070
|
+
if (indexes.compoundSize(pick.fields) !== source.snapshot().length) return null;
|
|
1071
|
+
const ids = indexes.lookupCompound(pick.fields, pick.values, pick.range);
|
|
1072
|
+
if (!ids) return null;
|
|
1073
|
+
return { candidates: materializeIds(ids, lookupById), remainingClauses: clauses };
|
|
1074
|
+
}
|
|
1075
|
+
function compoundOrderedRows(source, plan) {
|
|
1076
|
+
const limit = plan.limit;
|
|
1077
|
+
if (limit === void 0 || plan.clauses.length === 0 || plan.orderBy.length !== 1) return null;
|
|
1078
|
+
const [order] = plan.orderBy;
|
|
1079
|
+
if (!order || order.by === "label") return null;
|
|
1080
|
+
const indexes = source.getIndexes?.();
|
|
1081
|
+
if (!indexes || !source.lookupById) return null;
|
|
1082
|
+
if (viaOrdersField(source.via, order.field)) return null;
|
|
1083
|
+
const { eq } = indexableClauses(plan.clauses);
|
|
1084
|
+
if (eq.size !== plan.clauses.length) return null;
|
|
1085
|
+
const match = pickCompoundOrder(indexes, eq, order.field);
|
|
1086
|
+
if (!match) return null;
|
|
1087
|
+
const snapshot = source.snapshot();
|
|
1088
|
+
if (indexes.compoundSize(match.fields) !== snapshot.length) return null;
|
|
1089
|
+
const ids = indexes.compoundOrderedIds(match.fields, match.values, order.direction);
|
|
1090
|
+
if (!ids) return null;
|
|
1091
|
+
const lookupById = (id) => source.lookupById?.(id);
|
|
1092
|
+
const out = [];
|
|
1093
|
+
let matched = 0;
|
|
1094
|
+
for (let i = 0; i < ids.length && out.length < limit; i++) {
|
|
1095
|
+
const record = lookupById(ids[i]);
|
|
1096
|
+
if (record === void 0) continue;
|
|
1097
|
+
let hit = true;
|
|
1098
|
+
for (const clause of plan.clauses) {
|
|
1099
|
+
if (!evaluateClause(record, clause)) {
|
|
1100
|
+
hit = false;
|
|
1101
|
+
break;
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
if (!hit) continue;
|
|
1105
|
+
if (matched++ < plan.offset) continue;
|
|
1106
|
+
out.push(record);
|
|
1107
|
+
}
|
|
1108
|
+
return out;
|
|
1109
|
+
}
|
|
1110
|
+
function pickCompoundOrder(indexes, eq, orderField) {
|
|
1111
|
+
for (const fields of indexes.compoundTuples()) {
|
|
1112
|
+
if (fields.length !== eq.size + 1) continue;
|
|
1113
|
+
if (fields[fields.length - 1] !== orderField) continue;
|
|
1114
|
+
const values = [];
|
|
1115
|
+
for (let i = 0; i < fields.length - 1; i++) {
|
|
1116
|
+
const hit = eq.get(fields[i]);
|
|
1117
|
+
if (!hit) break;
|
|
1118
|
+
values.push(hit.value);
|
|
1119
|
+
}
|
|
1120
|
+
if (values.length === fields.length - 1) return { fields, values };
|
|
1121
|
+
}
|
|
1122
|
+
return null;
|
|
1123
|
+
}
|
|
1124
|
+
function candidateRecords(source, clauses) {
|
|
1125
|
+
const indexes = source.getIndexes?.();
|
|
1126
|
+
if (!indexes || !source.lookupById || clauses.length === 0) {
|
|
1127
|
+
return { candidates: source.snapshot(), remainingClauses: clauses };
|
|
1128
|
+
}
|
|
1129
|
+
const lookupById = (id) => source.lookupById?.(id);
|
|
1130
|
+
const compound = compoundCandidates(source, indexes, lookupById, clauses);
|
|
1131
|
+
if (compound) return compound;
|
|
1132
|
+
const prefixed = prefixCandidates(indexes, lookupById, clauses);
|
|
1133
|
+
if (prefixed) return prefixed;
|
|
1134
|
+
for (let i = 0; i < clauses.length; i++) {
|
|
1135
|
+
const clause = clauses[i];
|
|
1136
|
+
if (clause.type !== "field") continue;
|
|
1137
|
+
if (!indexes.has(clause.field) && !indexes.hasSorted(clause.field)) continue;
|
|
1138
|
+
if (clause.via && clause.via.indexValue === void 0) continue;
|
|
1139
|
+
const probeValue = clause.via ? clause.via.indexValue : clause.value;
|
|
1140
|
+
let ids = null;
|
|
1141
|
+
let exact = true;
|
|
1142
|
+
if (clause.op === "==") {
|
|
1143
|
+
ids = indexes.lookupEqual(clause.field, probeValue);
|
|
1144
|
+
exact = false;
|
|
1145
|
+
} else if (clause.op === "in" && Array.isArray(probeValue)) {
|
|
1146
|
+
ids = indexes.lookupIn(clause.field, probeValue);
|
|
1147
|
+
exact = false;
|
|
1148
|
+
} else if (clause.via === void 0 && isRangeOperator(clause.op)) {
|
|
1149
|
+
ids = indexes.lookupRange(clause.field, clause.op, clause.value);
|
|
1150
|
+
}
|
|
1151
|
+
if (ids !== null) {
|
|
1152
|
+
const remaining = [];
|
|
1153
|
+
for (let j = 0; j < clauses.length; j++) {
|
|
1154
|
+
if (j !== i || !exact) remaining.push(clauses[j]);
|
|
1155
|
+
}
|
|
1156
|
+
return {
|
|
1157
|
+
candidates: materializeIds(ids, lookupById),
|
|
1158
|
+
remainingClauses: remaining
|
|
1159
|
+
};
|
|
1160
|
+
}
|
|
1161
|
+
}
|
|
1162
|
+
return { candidates: source.snapshot(), remainingClauses: clauses };
|
|
1163
|
+
}
|
|
1164
|
+
function prefixCandidates(indexes, lookupById, clauses) {
|
|
1165
|
+
for (const clause of clauses) {
|
|
1166
|
+
if (clause.type !== "field" || clause.via === void 0) continue;
|
|
1167
|
+
const probe = clause.via.indexValue;
|
|
1168
|
+
if (!isViaPrefixProbe(probe)) continue;
|
|
1169
|
+
if (!indexes.hasSorted(clause.field)) continue;
|
|
1170
|
+
const ids = /* @__PURE__ */ new Set();
|
|
1171
|
+
for (const prefix of probe.prefixes) {
|
|
1172
|
+
const hit = indexes.lookupRange(clause.field, "startsWith", prefix);
|
|
1173
|
+
if (hit === null) return null;
|
|
1174
|
+
for (const id of hit) ids.add(id);
|
|
1175
|
+
}
|
|
1176
|
+
return { candidates: materializeIds(ids, lookupById), remainingClauses: clauses };
|
|
1177
|
+
}
|
|
1178
|
+
return null;
|
|
1179
|
+
}
|
|
1180
|
+
function materializeIds(ids, lookupById) {
|
|
1181
|
+
const out = [];
|
|
1182
|
+
for (const id of ids) {
|
|
1183
|
+
const record = lookupById(id);
|
|
1184
|
+
if (record !== void 0) out.push(record);
|
|
1185
|
+
}
|
|
1186
|
+
return out;
|
|
1187
|
+
}
|
|
1188
|
+
function executePlan(records, plan) {
|
|
1189
|
+
if (plan.clauses.some((c) => c.type === "crossJoin")) {
|
|
1190
|
+
throw new Error(
|
|
1191
|
+
`executePlan(): does not support crossJoin clauses. executePlan is a stateless pure function \u2014 it cannot resolve cross-join right-side collections. Use Query.toArray() (via collection.query()) instead.`
|
|
1192
|
+
);
|
|
1193
|
+
}
|
|
1194
|
+
let result = filterRecords(records, plan.clauses);
|
|
1195
|
+
if (plan.orderBy.length > 0) {
|
|
1196
|
+
result = sortRecords(result, plan.orderBy);
|
|
1197
|
+
}
|
|
1198
|
+
if (plan.offset > 0) {
|
|
1199
|
+
result = result.slice(plan.offset);
|
|
1200
|
+
}
|
|
1201
|
+
if (plan.limit !== void 0) {
|
|
1202
|
+
result = result.slice(0, plan.limit);
|
|
1203
|
+
}
|
|
1204
|
+
return result;
|
|
1205
|
+
}
|
|
1206
|
+
function fnViewDecoder(source) {
|
|
1207
|
+
const via = source.via;
|
|
1208
|
+
if (!via || !via.hasResultDecode) return void 0;
|
|
1209
|
+
return (r) => via.decodeResults(r);
|
|
1210
|
+
}
|
|
1211
|
+
function compileClause(clause) {
|
|
1212
|
+
if (clause.type === "field" && clause.via === void 0 && !clause.field.includes(".")) {
|
|
1213
|
+
const field = clause.field;
|
|
1214
|
+
const value = clause.value;
|
|
1215
|
+
if (clause.op === "==") {
|
|
1216
|
+
return (r) => (r === null || r === void 0 ? void 0 : r[field]) === value;
|
|
1217
|
+
}
|
|
1218
|
+
if (clause.op === "in") {
|
|
1219
|
+
const set = Array.isArray(value) ? new Set(value) : null;
|
|
1220
|
+
if (set !== null) {
|
|
1221
|
+
return (r) => set.has(r === null || r === void 0 ? void 0 : r[field]);
|
|
1222
|
+
}
|
|
1223
|
+
return () => false;
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
return (r, fnView) => evaluateClause(r, clause, fnView);
|
|
1227
|
+
}
|
|
1228
|
+
function filterRecords(records, clauses, decodeForFns) {
|
|
1229
|
+
if (clauses.length === 0) return [...records];
|
|
1230
|
+
const needsFnView = decodeForFns !== void 0 && hasFnClause(clauses);
|
|
1231
|
+
const compiled = clauses.map(compileClause);
|
|
1232
|
+
const out = [];
|
|
1233
|
+
for (const r of records) {
|
|
1234
|
+
const fnView = needsFnView ? decodeForFns(r) : void 0;
|
|
1235
|
+
let matches = true;
|
|
1236
|
+
for (const test of compiled) {
|
|
1237
|
+
if (!test(r, fnView)) {
|
|
1238
|
+
matches = false;
|
|
1239
|
+
break;
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
if (matches) out.push(r);
|
|
1243
|
+
}
|
|
1244
|
+
return out;
|
|
1245
|
+
}
|
|
1246
|
+
function anyMatches(records, clauses, decodeForFns) {
|
|
1247
|
+
if (clauses.length === 0) return records.length > 0;
|
|
1248
|
+
const needsFnView = decodeForFns !== void 0 && hasFnClause(clauses);
|
|
1249
|
+
for (const r of records) {
|
|
1250
|
+
const fnView = needsFnView ? decodeForFns(r) : void 0;
|
|
1251
|
+
let matches = true;
|
|
1252
|
+
for (const clause of clauses) {
|
|
1253
|
+
if (!evaluateClause(r, clause, fnView)) {
|
|
1254
|
+
matches = false;
|
|
1255
|
+
break;
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
if (matches) return true;
|
|
1259
|
+
}
|
|
1260
|
+
return false;
|
|
1261
|
+
}
|
|
1262
|
+
function executeClausePipeline(source, clauses, joinContext) {
|
|
1263
|
+
let rel = [...source.snapshot()];
|
|
1264
|
+
let filterBatch = [];
|
|
1265
|
+
const decodeForFns = fnViewDecoder(source);
|
|
1266
|
+
for (const clause of clauses) {
|
|
1267
|
+
if (clause.type === "crossJoin") {
|
|
1268
|
+
if (filterBatch.length > 0) {
|
|
1269
|
+
rel = filterRecords(rel, filterBatch, decodeForFns);
|
|
1270
|
+
filterBatch = [];
|
|
1271
|
+
}
|
|
1272
|
+
const rightSource = joinContext.resolveSource(clause.target);
|
|
1273
|
+
if (!rightSource) {
|
|
1274
|
+
throw new CrossJoinSourceUnknownError(clause.target, joinContext.leftCollection);
|
|
1275
|
+
}
|
|
1276
|
+
rel = applyCrossJoin(rel, clause, rightSource);
|
|
1277
|
+
} else {
|
|
1278
|
+
filterBatch.push(clause);
|
|
1279
|
+
}
|
|
1280
|
+
}
|
|
1281
|
+
if (filterBatch.length > 0) {
|
|
1282
|
+
rel = filterRecords(rel, filterBatch, decodeForFns);
|
|
1283
|
+
}
|
|
1284
|
+
return rel;
|
|
1285
|
+
}
|
|
1286
|
+
var KEYSET_MEMO_LIMIT = 8;
|
|
1287
|
+
var keysetMemo = /* @__PURE__ */ new Map();
|
|
1288
|
+
function readKeysetMemo(key) {
|
|
1289
|
+
const hit = keysetMemo.get(key);
|
|
1290
|
+
if (hit) {
|
|
1291
|
+
keysetMemo.delete(key);
|
|
1292
|
+
keysetMemo.set(key, hit);
|
|
1293
|
+
}
|
|
1294
|
+
return hit;
|
|
1295
|
+
}
|
|
1296
|
+
function writeKeysetMemo(key, entry) {
|
|
1297
|
+
keysetMemo.set(key, entry);
|
|
1298
|
+
while (keysetMemo.size > KEYSET_MEMO_LIMIT) {
|
|
1299
|
+
const oldest = keysetMemo.keys().next();
|
|
1300
|
+
if (oldest.done === true) break;
|
|
1301
|
+
keysetMemo.delete(oldest.value);
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
function keysetMemoKey(source, plan, locale) {
|
|
1305
|
+
const identity = source.identity;
|
|
1306
|
+
const version = source.snapshotVersion?.();
|
|
1307
|
+
if (identity === void 0 || version === void 0) return null;
|
|
1308
|
+
const parts = [identity, String(version), locale ?? ""];
|
|
1309
|
+
for (const clause of plan.clauses) {
|
|
1310
|
+
if (clause.type !== "field") return null;
|
|
1311
|
+
const value = fingerprintOperand(clause.value);
|
|
1312
|
+
if (value === null) return null;
|
|
1313
|
+
parts.push(`w:${clause.field}:${clause.op}:${value}`);
|
|
1314
|
+
}
|
|
1315
|
+
for (const o of plan.orderBy) parts.push(`o:${o.field}:${o.direction}:${o.by ?? "value"}`);
|
|
1316
|
+
return parts.join("\0");
|
|
1317
|
+
}
|
|
1318
|
+
function fingerprintOperand(value) {
|
|
1319
|
+
if (value === null) return "null";
|
|
1320
|
+
if (value === void 0) return "undefined";
|
|
1321
|
+
if (value instanceof Date) return `D${value.getTime()}`;
|
|
1322
|
+
if (typeof value === "string") return `s${value}`;
|
|
1323
|
+
if (typeof value === "number") return `n${value}`;
|
|
1324
|
+
if (typeof value === "bigint") return `g${value}`;
|
|
1325
|
+
if (typeof value === "boolean") return `b${value}`;
|
|
1326
|
+
if (Array.isArray(value)) {
|
|
1327
|
+
const each = value.map(fingerprintOperand);
|
|
1328
|
+
if (each.some((e) => e === null)) return null;
|
|
1329
|
+
return `[${each.join(",")}]`;
|
|
1330
|
+
}
|
|
1331
|
+
return null;
|
|
1332
|
+
}
|
|
1333
|
+
function lowerBound(arr, pred) {
|
|
1334
|
+
let lo = 0;
|
|
1335
|
+
let hi = arr.length;
|
|
1336
|
+
while (lo < hi) {
|
|
1337
|
+
const mid = lo + hi >>> 1;
|
|
1338
|
+
if (pred(arr[mid])) hi = mid;
|
|
1339
|
+
else lo = mid + 1;
|
|
1340
|
+
}
|
|
1341
|
+
return lo;
|
|
1342
|
+
}
|
|
1343
|
+
function buildOrderKeyPlan(orderBy, via, labelMaps, aliasVia) {
|
|
1344
|
+
return {
|
|
1345
|
+
entries: orderBy.map(({ field, direction, by }) => {
|
|
1346
|
+
const dot = field.indexOf(".");
|
|
1347
|
+
const aliased = dot > 0 ? aliasVia?.get(field.slice(0, dot)) : void 0;
|
|
1348
|
+
return {
|
|
1349
|
+
field,
|
|
1350
|
+
direction,
|
|
1351
|
+
labelResolver: by === "label" ? labelMaps?.get(field) : void 0,
|
|
1352
|
+
via: aliased ?? via,
|
|
1353
|
+
viaField: aliased ? field.slice(dot + 1) : field
|
|
1354
|
+
};
|
|
1355
|
+
})
|
|
1356
|
+
};
|
|
1357
|
+
}
|
|
1358
|
+
function orderKeyOf(plan, record) {
|
|
1359
|
+
return plan.entries.map(({ field, labelResolver }) => {
|
|
1360
|
+
const v = readField(record, field);
|
|
1361
|
+
if (labelResolver) return (typeof v === "string" ? labelResolver(v) : void 0) ?? v;
|
|
1362
|
+
return v;
|
|
1363
|
+
});
|
|
1364
|
+
}
|
|
1365
|
+
function compareOrderKeys(plan, a, b) {
|
|
1366
|
+
for (let i = 0; i < plan.entries.length; i++) {
|
|
1367
|
+
const { direction, labelResolver, via, viaField } = plan.entries[i];
|
|
1368
|
+
const av = a[i];
|
|
1369
|
+
const bv = b[i];
|
|
1370
|
+
const viaCmp = labelResolver ? void 0 : via?.compareForOrder(viaField, av, bv);
|
|
1371
|
+
const cmp = viaCmp !== void 0 ? viaCmp : compareValues(av, bv);
|
|
1372
|
+
if (cmp !== 0) return direction === "asc" ? cmp : -cmp;
|
|
1373
|
+
}
|
|
1374
|
+
return 0;
|
|
1375
|
+
}
|
|
1376
|
+
function compareIds(a, b) {
|
|
1377
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
1378
|
+
}
|
|
1379
|
+
function sortRecords(records, orderBy, via, labelMaps, aliasVia) {
|
|
1380
|
+
const plan = buildOrderKeyPlan(orderBy, via, labelMaps, aliasVia);
|
|
1381
|
+
return [...records].sort(
|
|
1382
|
+
(a, b) => compareOrderKeys(plan, orderKeyOf(plan, a), orderKeyOf(plan, b))
|
|
1383
|
+
);
|
|
1384
|
+
}
|
|
1385
|
+
function buildOrderLabelMaps(orderBy, joinContext, locale, via) {
|
|
1386
|
+
let maps;
|
|
1387
|
+
for (const { field, by } of orderBy) {
|
|
1388
|
+
if (by !== "label") continue;
|
|
1389
|
+
const dictSource = joinContext?.resolveDictSource?.(field);
|
|
1390
|
+
if (dictSource) {
|
|
1391
|
+
const loc = locale ?? dictSource.displayLocale;
|
|
1392
|
+
if (loc === void 0) continue;
|
|
1393
|
+
const codeToLabel = /* @__PURE__ */ new Map();
|
|
1394
|
+
for (const entry of dictSource.snapshot()) {
|
|
1395
|
+
const k = entry["key"];
|
|
1396
|
+
const labels = entry["labels"];
|
|
1397
|
+
const label = labels?.[loc];
|
|
1398
|
+
if (typeof k === "string" && typeof label === "string") codeToLabel.set(k, label);
|
|
1399
|
+
}
|
|
1400
|
+
;
|
|
1401
|
+
(maps ??= /* @__PURE__ */ new Map()).set(field, (code) => codeToLabel.get(code));
|
|
1402
|
+
continue;
|
|
1403
|
+
}
|
|
1404
|
+
if (via) {
|
|
1405
|
+
const cache = /* @__PURE__ */ new Map();
|
|
1406
|
+
(maps ??= /* @__PURE__ */ new Map()).set(field, (code) => {
|
|
1407
|
+
if (!cache.has(code)) cache.set(code, via.resolveOrderLabel(field, code, locale));
|
|
1408
|
+
return cache.get(code);
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
return maps;
|
|
1413
|
+
}
|
|
1414
|
+
function readField(record, field) {
|
|
1415
|
+
if (record === null || record === void 0) return void 0;
|
|
1416
|
+
if (!field.includes(".")) {
|
|
1417
|
+
return record[field];
|
|
1418
|
+
}
|
|
1419
|
+
const segments = field.split(".");
|
|
1420
|
+
let cursor = record;
|
|
1421
|
+
for (const segment of segments) {
|
|
1422
|
+
if (cursor === null || cursor === void 0) return void 0;
|
|
1423
|
+
cursor = cursor[segment];
|
|
1424
|
+
}
|
|
1425
|
+
return cursor;
|
|
1426
|
+
}
|
|
1427
|
+
function compareValues(a, b) {
|
|
1428
|
+
if (a === void 0 || a === null) return b === void 0 || b === null ? 0 : 1;
|
|
1429
|
+
if (b === void 0 || b === null) return -1;
|
|
1430
|
+
if (typeof a === "number" && typeof b === "number") return a - b;
|
|
1431
|
+
if (typeof a === "string" && typeof b === "string") return a < b ? -1 : a > b ? 1 : 0;
|
|
1432
|
+
if (a instanceof Date && b instanceof Date) return a.getTime() - b.getTime();
|
|
1433
|
+
return 0;
|
|
1434
|
+
}
|
|
1435
|
+
function serializePlan(plan) {
|
|
1436
|
+
return {
|
|
1437
|
+
clauses: plan.clauses.map(serializeClause),
|
|
1438
|
+
orderBy: plan.orderBy,
|
|
1439
|
+
limit: plan.limit,
|
|
1440
|
+
offset: plan.offset,
|
|
1441
|
+
after: plan.after,
|
|
1442
|
+
joins: plan.joins
|
|
1443
|
+
};
|
|
1444
|
+
}
|
|
1445
|
+
function serializeClause(clause) {
|
|
1446
|
+
if (clause.type === "filter") {
|
|
1447
|
+
return { type: "filter", fn: "[function]" };
|
|
1448
|
+
}
|
|
1449
|
+
if (clause.type === "wherePredicate") {
|
|
1450
|
+
return {
|
|
1451
|
+
type: "wherePredicate",
|
|
1452
|
+
name: clause.name,
|
|
1453
|
+
ctx: clause.ctx,
|
|
1454
|
+
predicateHash: clause.predicateHash,
|
|
1455
|
+
ctxHash: clause.ctxHash,
|
|
1456
|
+
fn: "[function]"
|
|
1457
|
+
};
|
|
1458
|
+
}
|
|
1459
|
+
if (clause.type === "group") {
|
|
1460
|
+
return {
|
|
1461
|
+
type: "group",
|
|
1462
|
+
op: clause.op,
|
|
1463
|
+
clauses: clause.clauses.map(serializeClause)
|
|
1464
|
+
};
|
|
1465
|
+
}
|
|
1466
|
+
if (clause.type === "crossJoin") {
|
|
1467
|
+
return {
|
|
1468
|
+
type: "crossJoin",
|
|
1469
|
+
target: clause.target,
|
|
1470
|
+
as: clause.as,
|
|
1471
|
+
// Identity, not decoration: `leftAs` changes the SHAPE of every row
|
|
1472
|
+
// (#1289), so two plans differing only in it are different queries.
|
|
1473
|
+
// Omitted when unset so a `.crossJoin()` plan serializes exactly as it
|
|
1474
|
+
// did before #1289 and no stored queryHash moves.
|
|
1475
|
+
...clause.leftAs !== void 0 && { leftAs: clause.leftAs },
|
|
1476
|
+
on: clause.on ? "[function]" : void 0,
|
|
1477
|
+
onPredicateName: clause.onPredicateName,
|
|
1478
|
+
maxRows: clause.maxRows,
|
|
1479
|
+
// Part of the identity, not decoration: `outer` changes which rows come
|
|
1480
|
+
// back, so omitting it here would let an inner-mode plan be reused for an
|
|
1481
|
+
// outer-mode query under the same hash (#1130).
|
|
1482
|
+
outer: clause.outer
|
|
1483
|
+
};
|
|
1484
|
+
}
|
|
1485
|
+
return clause;
|
|
1486
|
+
}
|
|
1487
|
+
function canonicalCtxHash(ctx) {
|
|
1488
|
+
if (ctx === void 0) return "";
|
|
1489
|
+
const canonical = JSON.stringify(ctx, (_key, value) => {
|
|
1490
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
1491
|
+
const sorted = {};
|
|
1492
|
+
for (const k of Object.keys(value).sort()) {
|
|
1493
|
+
sorted[k] = value[k];
|
|
1494
|
+
}
|
|
1495
|
+
return sorted;
|
|
1496
|
+
}
|
|
1497
|
+
return value;
|
|
1498
|
+
});
|
|
1499
|
+
let h = 5381;
|
|
1500
|
+
for (let i = 0; i < canonical.length; i++) {
|
|
1501
|
+
h = (h << 5) + h ^ canonical.charCodeAt(i);
|
|
1502
|
+
}
|
|
1503
|
+
return (h >>> 0).toString(16).padStart(8, "0");
|
|
1504
|
+
}
|
|
1505
|
+
function buildDictLabelResolver(joinCtx, field) {
|
|
1506
|
+
if (!joinCtx?.resolveDictSource) return void 0;
|
|
1507
|
+
const dictSource = joinCtx.resolveDictSource(field);
|
|
1508
|
+
if (!dictSource) return void 0;
|
|
1509
|
+
const snapshot = dictSource.snapshot();
|
|
1510
|
+
const displayLocale = dictSource.displayLocale;
|
|
1511
|
+
const dictMap = /* @__PURE__ */ new Map();
|
|
1512
|
+
for (const entry of snapshot) {
|
|
1513
|
+
const k = entry["key"];
|
|
1514
|
+
const labels = entry["labels"];
|
|
1515
|
+
if (typeof k === "string" && labels && typeof labels === "object") {
|
|
1516
|
+
dictMap.set(k, labels);
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
return async (key, locale, fallback) => {
|
|
1520
|
+
const effLocale = locale || displayLocale;
|
|
1521
|
+
if (!effLocale) return void 0;
|
|
1522
|
+
const labels = dictMap.get(key);
|
|
1523
|
+
if (!labels) return void 0;
|
|
1524
|
+
if (labels[effLocale] !== void 0) return labels[effLocale];
|
|
1525
|
+
const chain = Array.isArray(fallback) ? fallback : fallback ? [fallback] : [];
|
|
1526
|
+
for (const fb of chain) {
|
|
1527
|
+
if (fb === "any") {
|
|
1528
|
+
const any = Object.values(labels)[0];
|
|
1529
|
+
if (any !== void 0) return any;
|
|
1530
|
+
} else if (labels[fb] !== void 0) {
|
|
1531
|
+
return labels[fb];
|
|
1532
|
+
}
|
|
1533
|
+
}
|
|
1534
|
+
return void 0;
|
|
1535
|
+
};
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
export {
|
|
1539
|
+
installRelateHooks,
|
|
1540
|
+
splitAroundJoins,
|
|
1541
|
+
Query,
|
|
1542
|
+
isRangeOperator,
|
|
1543
|
+
viaOrdersField,
|
|
1544
|
+
indexableClauses,
|
|
1545
|
+
pickCompound,
|
|
1546
|
+
pickCompoundOrder,
|
|
1547
|
+
candidateRecords,
|
|
1548
|
+
executePlan,
|
|
1549
|
+
fnViewDecoder,
|
|
1550
|
+
filterRecords,
|
|
1551
|
+
executeClausePipeline,
|
|
1552
|
+
buildOrderKeyPlan,
|
|
1553
|
+
orderKeyOf,
|
|
1554
|
+
compareOrderKeys,
|
|
1555
|
+
sortRecords,
|
|
1556
|
+
buildDictLabelResolver
|
|
1557
|
+
};
|
|
1558
|
+
//# sourceMappingURL=chunk-AL6ML4LA.js.map
|