@nicia-ai/typegraph 0.40.0 → 0.42.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/dist/backend/drizzle/indexes.cjs +9 -9
- package/dist/backend/drizzle/indexes.d.cts +1 -2
- package/dist/backend/drizzle/indexes.d.ts +1 -2
- package/dist/backend/drizzle/indexes.js +5 -5
- package/dist/backend/index.cjs +50 -50
- package/dist/backend/index.d.cts +3 -4
- package/dist/backend/index.d.ts +3 -4
- package/dist/backend/index.js +11 -11
- package/dist/backend/postgres/index.cjs +26 -26
- package/dist/backend/postgres/index.d.cts +5 -6
- package/dist/backend/postgres/index.d.ts +5 -6
- package/dist/backend/postgres/index.js +13 -13
- package/dist/backend/postgres/pglite-store.cjs +34 -34
- package/dist/backend/postgres/pglite-store.d.cts +7 -8
- package/dist/backend/postgres/pglite-store.d.ts +7 -8
- package/dist/backend/postgres/pglite-store.js +30 -30
- package/dist/backend/postgres/pglite.cjs +15 -15
- package/dist/backend/postgres/pglite.d.cts +2 -3
- package/dist/backend/postgres/pglite.d.ts +2 -3
- package/dist/backend/postgres/pglite.js +14 -14
- package/dist/backend/sqlite/index.cjs +23 -23
- package/dist/backend/sqlite/index.d.cts +5 -6
- package/dist/backend/sqlite/index.d.ts +5 -6
- package/dist/backend/sqlite/index.js +11 -11
- package/dist/backend/sqlite/libsql.cjs +17 -17
- package/dist/backend/sqlite/libsql.d.cts +2 -3
- package/dist/backend/sqlite/libsql.d.ts +2 -3
- package/dist/backend/sqlite/libsql.js +13 -13
- package/dist/backend/sqlite/local-store.cjs +35 -35
- package/dist/backend/sqlite/local-store.d.cts +7 -8
- package/dist/backend/sqlite/local-store.d.ts +7 -8
- package/dist/backend/sqlite/local-store.js +31 -31
- package/dist/backend/sqlite/local.cjs +16 -16
- package/dist/backend/sqlite/local.d.cts +2 -3
- package/dist/backend/sqlite/local.d.ts +2 -3
- package/dist/backend/sqlite/local.js +14 -14
- package/dist/{chunk-H6I36MGT.cjs → chunk-277UZV7X.cjs} +1191 -1090
- package/dist/chunk-277UZV7X.cjs.map +1 -0
- package/dist/{chunk-2I3DNNBU.js → chunk-2G6ZEGYO.js} +4 -4
- package/dist/{chunk-2I3DNNBU.js.map → chunk-2G6ZEGYO.js.map} +1 -1
- package/dist/{chunk-76HE7DJP.js → chunk-2HKIID5K.js} +5 -5
- package/dist/{chunk-76HE7DJP.js.map → chunk-2HKIID5K.js.map} +1 -1
- package/dist/{chunk-QOHTVDHU.js → chunk-2OOY4OYT.js} +4 -4
- package/dist/{chunk-QOHTVDHU.js.map → chunk-2OOY4OYT.js.map} +1 -1
- package/dist/{chunk-UCHW2MGP.cjs → chunk-2SO5I5AI.cjs} +196 -196
- package/dist/{chunk-UCHW2MGP.cjs.map → chunk-2SO5I5AI.cjs.map} +1 -1
- package/dist/{chunk-LFFVD5ZR.cjs → chunk-33PAKPED.cjs} +41 -41
- package/dist/{chunk-LFFVD5ZR.cjs.map → chunk-33PAKPED.cjs.map} +1 -1
- package/dist/chunk-3RPQDGUE.cjs +83 -0
- package/dist/chunk-3RPQDGUE.cjs.map +1 -0
- package/dist/{chunk-PH4IJ3V5.js → chunk-3V6D5DEC.js} +3 -3
- package/dist/{chunk-PH4IJ3V5.js.map → chunk-3V6D5DEC.js.map} +1 -1
- package/dist/{chunk-Y5UC3IXF.js → chunk-42XYPKZU.js} +3 -3
- package/dist/{chunk-Y5UC3IXF.js.map → chunk-42XYPKZU.js.map} +1 -1
- package/dist/{chunk-XZA3Y4YH.js → chunk-4WYFRACU.js} +3 -3
- package/dist/{chunk-XZA3Y4YH.js.map → chunk-4WYFRACU.js.map} +1 -1
- package/dist/{chunk-AQVDAKXH.js → chunk-4XRP2N6B.js} +3 -3
- package/dist/{chunk-AQVDAKXH.js.map → chunk-4XRP2N6B.js.map} +1 -1
- package/dist/{chunk-PWXGB77L.cjs → chunk-5AERZSHC.cjs} +4 -4
- package/dist/{chunk-PWXGB77L.cjs.map → chunk-5AERZSHC.cjs.map} +1 -1
- package/dist/{chunk-K6CD6W5J.js → chunk-5C75HQYQ.js} +5 -5
- package/dist/{chunk-K6CD6W5J.js.map → chunk-5C75HQYQ.js.map} +1 -1
- package/dist/{chunk-2J5NMMVR.cjs → chunk-5GV4JQNA.cjs} +43 -43
- package/dist/{chunk-2J5NMMVR.cjs.map → chunk-5GV4JQNA.cjs.map} +1 -1
- package/dist/{chunk-KHNKYSGP.cjs → chunk-5P6IPIT6.cjs} +41 -41
- package/dist/{chunk-KHNKYSGP.cjs.map → chunk-5P6IPIT6.cjs.map} +1 -1
- package/dist/{chunk-53BSOG3O.js → chunk-6NB73BXV.js} +11 -11
- package/dist/{chunk-53BSOG3O.js.map → chunk-6NB73BXV.js.map} +1 -1
- package/dist/{chunk-SE422RES.cjs → chunk-6TJ6PKPS.cjs} +27 -27
- package/dist/{chunk-SE422RES.cjs.map → chunk-6TJ6PKPS.cjs.map} +1 -1
- package/dist/{chunk-QXKVUJLI.cjs → chunk-7TOT7RKY.cjs} +120 -120
- package/dist/{chunk-QXKVUJLI.cjs.map → chunk-7TOT7RKY.cjs.map} +1 -1
- package/dist/{chunk-7WLEQIHA.cjs → chunk-7Y6BV3TK.cjs} +100 -100
- package/dist/{chunk-7WLEQIHA.cjs.map → chunk-7Y6BV3TK.cjs.map} +1 -1
- package/dist/{chunk-HP6LWBLB.cjs → chunk-AO2WPYFZ.cjs} +4 -4
- package/dist/{chunk-HP6LWBLB.cjs.map → chunk-AO2WPYFZ.cjs.map} +1 -1
- package/dist/{chunk-7UTUKH4E.cjs → chunk-AQR6BHB3.cjs} +10 -10
- package/dist/{chunk-7UTUKH4E.cjs.map → chunk-AQR6BHB3.cjs.map} +1 -1
- package/dist/{chunk-X4PVHAZ6.cjs → chunk-ARN3ZODS.cjs} +6 -6
- package/dist/{chunk-X4PVHAZ6.cjs.map → chunk-ARN3ZODS.cjs.map} +1 -1
- package/dist/{chunk-EFZ4S22A.js → chunk-BGXKXGDI.js} +12 -12
- package/dist/{chunk-EFZ4S22A.js.map → chunk-BGXKXGDI.js.map} +1 -1
- package/dist/{chunk-YYLMXERH.js → chunk-CDYRPI5U.js} +4 -4
- package/dist/{chunk-YYLMXERH.js.map → chunk-CDYRPI5U.js.map} +1 -1
- package/dist/{chunk-3LKL3S6X.js → chunk-CI5NPLXX.js} +3 -3
- package/dist/{chunk-3LKL3S6X.js.map → chunk-CI5NPLXX.js.map} +1 -1
- package/dist/{chunk-UUIBACKJ.js → chunk-CUPJL6TS.js} +3 -3
- package/dist/{chunk-UUIBACKJ.js.map → chunk-CUPJL6TS.js.map} +1 -1
- package/dist/{chunk-JZYMOHHM.cjs → chunk-CVK4T34X.cjs} +22 -22
- package/dist/{chunk-JZYMOHHM.cjs.map → chunk-CVK4T34X.cjs.map} +1 -1
- package/dist/{chunk-L3DDZUZP.js → chunk-CVNGKTHO.js} +4 -4
- package/dist/{chunk-L3DDZUZP.js.map → chunk-CVNGKTHO.js.map} +1 -1
- package/dist/{chunk-RW24SAHI.cjs → chunk-DMZEVJGL.cjs} +13 -13
- package/dist/{chunk-RW24SAHI.cjs.map → chunk-DMZEVJGL.cjs.map} +1 -1
- package/dist/{chunk-3BL3JFHL.js → chunk-DP7KC6CL.js} +126 -25
- package/dist/{chunk-3BL3JFHL.js.map → chunk-DP7KC6CL.js.map} +1 -1
- package/dist/{chunk-QYDUCWD2.cjs → chunk-ECU53PMN.cjs} +4 -4
- package/dist/{chunk-QYDUCWD2.cjs.map → chunk-ECU53PMN.cjs.map} +1 -1
- package/dist/{chunk-SCTZRFW5.js → chunk-EQOQOT55.js} +5 -5
- package/dist/{chunk-SCTZRFW5.js.map → chunk-EQOQOT55.js.map} +1 -1
- package/dist/{chunk-JHK6NPFV.js → chunk-EVFL2ZY5.js} +9 -9
- package/dist/{chunk-JHK6NPFV.js.map → chunk-EVFL2ZY5.js.map} +1 -1
- package/dist/{chunk-SAMJLDGG.cjs → chunk-F2KVJ6FF.cjs} +112 -112
- package/dist/{chunk-SAMJLDGG.cjs.map → chunk-F2KVJ6FF.cjs.map} +1 -1
- package/dist/{chunk-NMQ6C6TS.cjs → chunk-F7TDKSVB.cjs} +4 -4
- package/dist/{chunk-NMQ6C6TS.cjs.map → chunk-F7TDKSVB.cjs.map} +1 -1
- package/dist/{chunk-HQRZEYYB.cjs → chunk-FFQGI67R.cjs} +44 -44
- package/dist/{chunk-HQRZEYYB.cjs.map → chunk-FFQGI67R.cjs.map} +1 -1
- package/dist/{chunk-YIRLBUNN.js → chunk-FMPZPOUD.js} +3 -3
- package/dist/{chunk-YIRLBUNN.js.map → chunk-FMPZPOUD.js.map} +1 -1
- package/dist/{chunk-LL5D5T5W.cjs → chunk-FSCJOTHF.cjs} +10 -10
- package/dist/{chunk-LL5D5T5W.cjs.map → chunk-FSCJOTHF.cjs.map} +1 -1
- package/dist/{chunk-2X73QTIC.cjs → chunk-FY4VY5EV.cjs} +20 -20
- package/dist/{chunk-2X73QTIC.cjs.map → chunk-FY4VY5EV.cjs.map} +1 -1
- package/dist/{chunk-3SHAUJRB.js → chunk-GT7NEXSU.js} +3 -3
- package/dist/{chunk-3SHAUJRB.js.map → chunk-GT7NEXSU.js.map} +1 -1
- package/dist/{chunk-W66YCXWT.js → chunk-HHBKGPEI.js} +11 -10
- package/dist/chunk-HHBKGPEI.js.map +1 -0
- package/dist/{chunk-CKFBZ4LV.cjs → chunk-I73ATSAH.cjs} +4 -4
- package/dist/{chunk-CKFBZ4LV.cjs.map → chunk-I73ATSAH.cjs.map} +1 -1
- package/dist/{chunk-ELA3V6UN.js → chunk-JOYPNY33.js} +9 -9
- package/dist/{chunk-ELA3V6UN.js.map → chunk-JOYPNY33.js.map} +1 -1
- package/dist/{chunk-YIX3BEBR.cjs → chunk-K2HHCWZO.cjs} +108 -108
- package/dist/{chunk-YIX3BEBR.cjs.map → chunk-K2HHCWZO.cjs.map} +1 -1
- package/dist/{chunk-SAFZ6JTI.cjs → chunk-KTBTSHU6.cjs} +19 -2
- package/dist/chunk-KTBTSHU6.cjs.map +1 -0
- package/dist/chunk-LDCWO5B6.js +81 -0
- package/dist/chunk-LDCWO5B6.js.map +1 -0
- package/dist/{chunk-I5CRUPKO.js → chunk-LQLVJWUH.js} +7 -7
- package/dist/{chunk-I5CRUPKO.js.map → chunk-LQLVJWUH.js.map} +1 -1
- package/dist/{chunk-ZE7E46IZ.js → chunk-LTVBD56M.js} +6 -6
- package/dist/{chunk-ZE7E46IZ.js.map → chunk-LTVBD56M.js.map} +1 -1
- package/dist/{chunk-6N7QBIWN.js → chunk-M4GYQF2H.js} +3 -3
- package/dist/{chunk-6N7QBIWN.js.map → chunk-M4GYQF2H.js.map} +1 -1
- package/dist/{chunk-XRU7V7FF.cjs → chunk-O2GZM7UK.cjs} +7 -7
- package/dist/{chunk-XRU7V7FF.cjs.map → chunk-O2GZM7UK.cjs.map} +1 -1
- package/dist/{chunk-ZE6NVENI.js → chunk-O3USVVWS.js} +3 -3
- package/dist/{chunk-ZE6NVENI.js.map → chunk-O3USVVWS.js.map} +1 -1
- package/dist/{chunk-UDS5DZNY.cjs → chunk-O7XVCLXW.cjs} +68 -67
- package/dist/chunk-O7XVCLXW.cjs.map +1 -0
- package/dist/{chunk-KLR77R5A.cjs → chunk-OM6RIOA5.cjs} +13 -13
- package/dist/{chunk-KLR77R5A.cjs.map → chunk-OM6RIOA5.cjs.map} +1 -1
- package/dist/{chunk-LLHMAHG4.cjs → chunk-OMQ2NBOR.cjs} +27 -27
- package/dist/{chunk-LLHMAHG4.cjs.map → chunk-OMQ2NBOR.cjs.map} +1 -1
- package/dist/{chunk-DPNA466P.js → chunk-OYJSYDIH.js} +19 -3
- package/dist/chunk-OYJSYDIH.js.map +1 -0
- package/dist/{chunk-CU3LPYNB.js → chunk-RAWG2FEU.js} +138 -22
- package/dist/chunk-RAWG2FEU.js.map +1 -0
- package/dist/{chunk-M2RPZS7J.cjs → chunk-RTUCOEIO.cjs} +12 -12
- package/dist/{chunk-M2RPZS7J.cjs.map → chunk-RTUCOEIO.cjs.map} +1 -1
- package/dist/{chunk-TAUGGLNQ.js → chunk-RXOAXO3R.js} +3 -3
- package/dist/{chunk-TAUGGLNQ.js.map → chunk-RXOAXO3R.js.map} +1 -1
- package/dist/{chunk-LLE25NRD.cjs → chunk-TRC646QQ.cjs} +7 -7
- package/dist/{chunk-LLE25NRD.cjs.map → chunk-TRC646QQ.cjs.map} +1 -1
- package/dist/chunk-U3YRCZ5L.cjs +12 -0
- package/dist/{chunk-IMQKXL4E.cjs.map → chunk-U3YRCZ5L.cjs.map} +1 -1
- package/dist/{chunk-ZVME6OSV.js → chunk-UJRWOV5B.js} +5 -5
- package/dist/{chunk-ZVME6OSV.js.map → chunk-UJRWOV5B.js.map} +1 -1
- package/dist/{chunk-HAQVISUF.cjs → chunk-UTTW2Q3M.cjs} +133 -133
- package/dist/{chunk-HAQVISUF.cjs.map → chunk-UTTW2Q3M.cjs.map} +1 -1
- package/dist/{chunk-L5ET7FYQ.js → chunk-UZLEQFTV.js} +3 -3
- package/dist/{chunk-L5ET7FYQ.js.map → chunk-UZLEQFTV.js.map} +1 -1
- package/dist/{chunk-K4FB2RMO.cjs → chunk-V2GZBPY2.cjs} +184 -65
- package/dist/chunk-V2GZBPY2.cjs.map +1 -0
- package/dist/{chunk-BUZWMDNL.js → chunk-VC26BUNP.js} +5 -5
- package/dist/{chunk-BUZWMDNL.js.map → chunk-VC26BUNP.js.map} +1 -1
- package/dist/chunk-VGMNGWBR.cjs +12 -0
- package/dist/{chunk-5YBDB7UG.cjs.map → chunk-VGMNGWBR.cjs.map} +1 -1
- package/dist/{chunk-XMEYZYGE.js → chunk-WYQILW5V.js} +8 -8
- package/dist/{chunk-XMEYZYGE.js.map → chunk-WYQILW5V.js.map} +1 -1
- package/dist/{chunk-YX3H63VV.cjs → chunk-X2XOQZT3.cjs} +9 -9
- package/dist/{chunk-YX3H63VV.cjs.map → chunk-X2XOQZT3.cjs.map} +1 -1
- package/dist/{chunk-N2V3HJFV.cjs → chunk-XDMPDUKL.cjs} +9 -9
- package/dist/{chunk-N2V3HJFV.cjs.map → chunk-XDMPDUKL.cjs.map} +1 -1
- package/dist/{chunk-5J4VNCUD.js → chunk-Z3WIL6S3.js} +5 -5
- package/dist/{chunk-5J4VNCUD.js.map → chunk-Z3WIL6S3.js.map} +1 -1
- package/dist/{chunk-MNURF4RF.cjs → chunk-ZBV4LQD2.cjs} +4 -4
- package/dist/{chunk-MNURF4RF.cjs.map → chunk-ZBV4LQD2.cjs.map} +1 -1
- package/dist/{chunk-YGX4PMG6.js → chunk-ZGOUVMVS.js} +5 -5
- package/dist/{chunk-YGX4PMG6.js.map → chunk-ZGOUVMVS.js.map} +1 -1
- package/dist/{chunk-QZYGZVUI.js → chunk-ZIRC2U6G.js} +11 -11
- package/dist/{chunk-QZYGZVUI.js.map → chunk-ZIRC2U6G.js.map} +1 -1
- package/dist/{chunk-6QP4QXBR.js → chunk-ZOHCFYXE.js} +3 -3
- package/dist/{chunk-6QP4QXBR.js.map → chunk-ZOHCFYXE.js.map} +1 -1
- package/dist/{chunk-VWEFXG73.js → chunk-ZP2KPDNN.js} +3 -3
- package/dist/{chunk-VWEFXG73.js.map → chunk-ZP2KPDNN.js.map} +1 -1
- package/dist/{chunk-NT6ILURI.cjs → chunk-ZPCKPLMX.cjs} +8 -8
- package/dist/{chunk-NT6ILURI.cjs.map → chunk-ZPCKPLMX.cjs.map} +1 -1
- package/dist/core/index.cjs +28 -28
- package/dist/core/index.d.cts +5 -6
- package/dist/core/index.d.ts +5 -6
- package/dist/core/index.js +8 -8
- package/dist/{ddl-KnCdF_le.d.cts → ddl-3unqC-kg.d.cts} +3 -3
- package/dist/{ddl-BLEzHw6j.d.ts → ddl-Bc4Dl8fu.d.ts} +3 -3
- package/dist/{define-graph-DQnj3fNH.d.ts → define-graph-Byslw2OO.d.cts} +1 -2
- package/dist/{define-graph-Cv3CFwKm.d.cts → define-graph-DBFnc7u_.d.ts} +1 -2
- package/dist/graph-extension/index.cjs +20 -20
- package/dist/graph-extension/index.d.cts +4 -4
- package/dist/graph-extension/index.d.ts +4 -4
- package/dist/graph-extension/index.js +5 -5
- package/dist/graph-merge/index.cjs +105 -105
- package/dist/graph-merge/index.d.cts +8 -9
- package/dist/graph-merge/index.d.ts +8 -9
- package/dist/graph-merge/index.js +25 -25
- package/dist/{index-BD_3TCgh.d.ts → index-DHXw7QAl.d.cts} +19 -4
- package/dist/{index-BihFPsPu.d.cts → index-DQzVJBHa.d.ts} +19 -4
- package/dist/index.cjs +209 -200
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -15
- package/dist/index.d.ts +13 -15
- package/dist/index.js +35 -34
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +13 -13
- package/dist/indexes/index.d.cts +4 -5
- package/dist/indexes/index.d.ts +4 -5
- package/dist/indexes/index.js +6 -6
- package/dist/interchange/index.cjs +40 -40
- package/dist/interchange/index.d.cts +9 -10
- package/dist/interchange/index.d.ts +9 -10
- package/dist/interchange/index.js +14 -14
- package/dist/{manager-DjE6Mhag.d.ts → manager-Dl0-er1G.d.ts} +45 -156
- package/dist/{manager-mqee5MVB.d.cts → manager-U9_zopqr.d.cts} +45 -156
- package/dist/materialize-indexes-BM3u0aXE.d.ts +258 -0
- package/dist/materialize-indexes-DzMCetZe.d.cts +258 -0
- package/dist/{postgres-Bm4DyFQU.d.cts → postgres-C5-WMKFA.d.ts} +1 -1
- package/dist/{postgres-DtaVALOZ.d.ts → postgres-DpJqtbSX.d.cts} +1 -1
- package/dist/profiler/index.d.cts +9 -10
- package/dist/profiler/index.d.ts +9 -10
- package/dist/provenance/index.cjs +39 -39
- package/dist/provenance/index.d.cts +7 -8
- package/dist/provenance/index.d.ts +7 -8
- package/dist/provenance/index.js +9 -9
- package/dist/schema/index.cjs +55 -112
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +57 -58
- package/dist/schema/index.d.ts +57 -58
- package/dist/schema/index.js +15 -92
- package/dist/schema/index.js.map +1 -1
- package/dist/{searchable-BxlJQVFw.d.cts → searchable-B4mUXZT6.d.cts} +2 -2
- package/dist/{searchable-ChJ29MCd.d.ts → searchable-C7jmPNLT.d.ts} +2 -2
- package/dist/{sqlite-m9Izphk_.d.ts → sqlite-Ch5tSYQY.d.ts} +1 -1
- package/dist/{sqlite-DT6tTHOG.d.cts → sqlite-Da7jiYu9.d.cts} +1 -1
- package/dist/{store-view-CagdeyNn.d.ts → store-view-6C2vTWqf.d.ts} +68 -16
- package/dist/{store-view-C-buB8Q8.d.cts → store-view-CNcOG8bQ.d.cts} +68 -16
- package/dist/{temporal-CyFsSPe8.d.ts → temporal-BtrTYTiB.d.ts} +1 -1
- package/dist/{temporal-Dn_JADWY.d.cts → temporal-CMpigMCW.d.cts} +1 -1
- package/dist/{types-CYdXzZef.d.ts → types-D2rU5Taq.d.ts} +1 -2
- package/dist/{types-D8szWDUo.d.ts → types-Dh-EgT-w.d.cts} +569 -2
- package/dist/{types-C5pZeKTl.d.cts → types-Dh-EgT-w.d.ts} +569 -2
- package/dist/{types-CqSfMRW3.d.cts → types-G4sVM-76.d.cts} +1 -2
- package/dist/{where-sQL4u5h-.d.ts → where-B8Y21kig.d.ts} +1 -2
- package/dist/{where-C3-HRgUq.d.cts → where-DbZ9XDOI.d.cts} +1 -2
- package/package.json +1 -1
- package/dist/chunk-5YBDB7UG.cjs +0 -12
- package/dist/chunk-CU3LPYNB.js.map +0 -1
- package/dist/chunk-DPNA466P.js.map +0 -1
- package/dist/chunk-H6I36MGT.cjs.map +0 -1
- package/dist/chunk-IMQKXL4E.cjs +0 -12
- package/dist/chunk-K4FB2RMO.cjs.map +0 -1
- package/dist/chunk-SAFZ6JTI.cjs.map +0 -1
- package/dist/chunk-UDS5DZNY.cjs.map +0 -1
- package/dist/chunk-W66YCXWT.js.map +0 -1
- package/dist/extension-types-BLEVH4SG.d.cts +0 -571
- package/dist/extension-types-BLEVH4SG.d.ts +0 -571
- package/dist/materialize-indexes-D4iei4Kp.d.ts +0 -90
- package/dist/materialize-indexes-ExQ6OrAh.d.cts +0 -90
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
3
|
+
var chunk7TOT7RKY_cjs = require('./chunk-7TOT7RKY.cjs');
|
|
4
|
+
var chunkOMQ2NBOR_cjs = require('./chunk-OMQ2NBOR.cjs');
|
|
5
|
+
var chunkECU53PMN_cjs = require('./chunk-ECU53PMN.cjs');
|
|
6
|
+
var chunkKTBTSHU6_cjs = require('./chunk-KTBTSHU6.cjs');
|
|
7
7
|
var pglite = require('@electric-sql/pglite');
|
|
8
8
|
var pglite$1 = require('drizzle-orm/pglite');
|
|
9
9
|
|
|
@@ -12,7 +12,7 @@ async function loadDefaultPgvectorExtension() {
|
|
|
12
12
|
const module_ = await import('@electric-sql/pglite-pgvector');
|
|
13
13
|
return module_.vector;
|
|
14
14
|
} catch (error) {
|
|
15
|
-
throw new
|
|
15
|
+
throw new chunkKTBTSHU6_cjs.ConfigurationError(
|
|
16
16
|
"createLocalPgliteBackend needs the pgvector extension but `@electric-sql/pglite-pgvector` could not be loaded. Install it (`pnpm add @electric-sql/pglite-pgvector`), pass your own `vector` extension, or set `vector: false` to disable vector support.",
|
|
17
17
|
{ backend: "pglite", dependency: "@electric-sql/pglite-pgvector" },
|
|
18
18
|
{ cause: error }
|
|
@@ -20,7 +20,7 @@ async function loadDefaultPgvectorExtension() {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
async function createLocalPgliteBackend(options = {}) {
|
|
23
|
-
const tables2 = options.tables ??
|
|
23
|
+
const tables2 = options.tables ?? chunkOMQ2NBOR_cjs.tables;
|
|
24
24
|
const vectorExtension = options.vector === false ? void 0 : options.vector ?? await loadDefaultPgvectorExtension();
|
|
25
25
|
const vectorEnabled = vectorExtension !== void 0;
|
|
26
26
|
const client = await pglite.PGlite.create({
|
|
@@ -28,22 +28,22 @@ async function createLocalPgliteBackend(options = {}) {
|
|
|
28
28
|
...vectorExtension === void 0 ? {} : { extensions: { vector: vectorExtension } }
|
|
29
29
|
});
|
|
30
30
|
try {
|
|
31
|
-
const migrationSql = vectorEnabled ?
|
|
31
|
+
const migrationSql = vectorEnabled ? chunkOMQ2NBOR_cjs.generatePostgresMigrationSQL(tables2) : chunkOMQ2NBOR_cjs.generatePostgresDDL(tables2).join("\n\n");
|
|
32
32
|
await client.exec(migrationSql);
|
|
33
33
|
const db = pglite$1.drizzle(client);
|
|
34
|
-
const backend =
|
|
34
|
+
const backend = chunk7TOT7RKY_cjs.createPostgresBackend(db, {
|
|
35
35
|
tables: tables2,
|
|
36
36
|
...vectorEnabled ? {} : { vector: false }
|
|
37
37
|
});
|
|
38
|
-
const managedBackend =
|
|
38
|
+
const managedBackend = chunkECU53PMN_cjs.wrapWithManagedClose(backend, async () => {
|
|
39
39
|
await client.close();
|
|
40
40
|
});
|
|
41
41
|
return { backend: managedBackend, db, client };
|
|
42
42
|
} catch (error) {
|
|
43
|
-
return
|
|
43
|
+
return chunkECU53PMN_cjs.closeAfterFailure(client, error);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
exports.createLocalPgliteBackend = createLocalPgliteBackend;
|
|
48
|
-
//# sourceMappingURL=chunk-
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
48
|
+
//# sourceMappingURL=chunk-RTUCOEIO.cjs.map
|
|
49
|
+
//# sourceMappingURL=chunk-RTUCOEIO.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/backend/postgres/pglite.ts"],"names":["ConfigurationError","tables","PGlite","generatePostgresMigrationSQL","generatePostgresDDL","drizzle","createPostgresBackend","wrapWithManagedClose","closeAfterFailure"],"mappings":";;;;;;;;;AAiIA,eAAe,4BAAA,GAAmD;AAChE,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,GAAU,MAAM,OAAO,+BAA+B,CAAA;AAC5D,IAAA,OAA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CAAA,CAAqB,OAAA,EAAS,YAAY;AAC/D,MAAA,MAAM,OAAO,KAAA,EAAM;AAAA,IACrB,CAAC,CAAA;AAED,IAAA,OAAO,EAAE,OAAA,EAAS,cAAA,EAAgB,EAAA,EAAI,MAAA,EAAO;AAAA,EAC/C,SAAS,KAAA,EAAO;AACd,IAAA,OAAOC,mCAAA,CAAkB,QAAQ,KAAK,CAAA;AAAA,EACxC;AACF","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/backend/postgres/pglite.ts"],"names":["ConfigurationError","tables","PGlite","generatePostgresMigrationSQL","generatePostgresDDL","drizzle","createPostgresBackend","wrapWithManagedClose","closeAfterFailure"],"mappings":";;;;;;;;;AAiIA,eAAe,4BAAA,GAAmD;AAChE,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,GAAU,MAAM,OAAO,+BAA+B,CAAA;AAC5D,IAAA,OAAO,OAAA,CAAQ,MAAA;AAAA,EACjB,SAAS,KAAA,EAAO;AACd,IAAA,MAAM,IAAIA,oCAAA;AAAA,MACR,2PAAA;AAAA,MAIA,EAAE,OAAA,EAAS,QAAA,EAAU,UAAA,EAAY,+BAAA,EAAgC;AAAA,MACjE,EAAE,OAAO,KAAA;AAAM,KACjB;AAAA,EACF;AACF;AAoBA,eAAsB,wBAAA,CACpB,OAAA,GAAqC,EAAC,EACH;AACnC,EAAA,MAAMC,OAAAA,GAAS,QAAQ,MAAA,IAAUA,wBAAA;AAMjC,EAAA,MAAM,eAAA,GACJ,QAAQ,MAAA,KAAW,KAAA,GACjB,SACC,OAAA,CAAQ,MAAA,IAAW,MAAM,4BAAA,EAA6B;AAC3D,EAAA,MAAM,gBAAgB,eAAA,KAAoB,MAAA;AAO1C,EAAA,MAAM,MAAA,GAAS,MAAMC,aAAA,CAAO,MAAA,CAAO;AAAA,IACjC,GAAI,QAAQ,OAAA,KAAY,MAAA,GAAY,EAAC,GAAI,EAAE,OAAA,EAAS,OAAA,CAAQ,OAAA,EAAQ;AAAA,IACpE,GAAI,eAAA,KAAoB,MAAA,GACtB,EAAC,GACD,EAAE,UAAA,EAAY,EAAE,MAAA,EAAQ,eAAA,EAAgB;AAAE,GAC7C,CAAA;AAED,EAAA,IAAI;AAGF,IAAA,MAAM,YAAA,GACJ,gBACEC,8CAAA,CAA6BF,OAAM,IACnCG,qCAAA,CAAoBH,OAAM,CAAA,CAAE,IAAA,CAAK,MAAM,CAAA;AAC3C,IAAA,MAAM,MAAA,CAAO,KAAK,YAAY,CAAA;AAE9B,IAAA,MAAM,EAAA,GAAKI,iBAAQ,MAAM,CAAA;AACzB,IAAA,MAAM,OAAA,GAAUC,wCAAsB,EAAA,EAAI;AAAA,MACxC,MAAA,EAAAL,OAAAA;AAAA,MACA,GAAI,aAAA,GAAgB,EAAC,GAAI,EAAE,QAAQ,KAAA;AAAM,KAC1C,CAAA;AACD,IAAA,MAAM,cAAA,GAAiBM,sCAAA,CAAqB,OAAA,EAAS,YAAY;AAC/D,MAAA,MAAM,OAAO,KAAA,EAAM;AAAA,IACrB,CAAC,CAAA;AAED,IAAA,OAAO,EAAE,OAAA,EAAS,cAAA,EAAgB,EAAA,EAAI,MAAA,EAAO;AAAA,EAC/C,SAAS,KAAA,EAAO;AACd,IAAA,OAAOC,mCAAA,CAAkB,QAAQ,KAAK,CAAA;AAAA,EACxC;AACF","file":"chunk-RTUCOEIO.cjs","sourcesContent":["/**\n * Local PGlite backend — Postgres-in-WASM, running in-process.\n *\n * [PGlite](https://pglite.dev/) is a full Postgres compiled to WebAssembly\n * that runs inside the Node/Bun/Deno/browser process with no server and no\n * native addon. This is the batteries-included Postgres analog of\n * `createLocalSqliteBackend`: it constructs a PGlite instance, loads the\n * pgvector extension, runs the schema DDL, and returns a ready\n * `{ backend, db }` pair whose `close()` disposes the engine.\n *\n * `@electric-sql/pglite` is an optional peer dependency. Vector support\n * additionally needs `@electric-sql/pglite-pgvector` (PGlite ≥ 0.5 ships\n * pgvector as a separate package). Install what you need:\n *\n * ```bash\n * pnpm add @electric-sql/pglite @electric-sql/pglite-pgvector\n * ```\n *\n * @example In-memory database (default, vector enabled)\n * ```typescript\n * import { createLocalPgliteBackend } from \"@nicia-ai/typegraph/adapters/drizzle/postgres/pglite\";\n *\n * const { backend } = await createLocalPgliteBackend();\n * const store = createStore(graph, backend);\n * ```\n *\n * @example Persistent on-disk database\n * ```typescript\n * const { backend, db } = await createLocalPgliteBackend({ dataDir: \"./pgdata\" });\n * ```\n *\n * @example No vector support (skip the pgvector extension)\n * ```typescript\n * const { backend } = await createLocalPgliteBackend({ vector: false });\n * ```\n *\n * PGlite is single-connection and serial: there is no pooling, so concurrent\n * `store.transaction()` calls queue rather than run in parallel.\n */\nimport { type Extension, PGlite } from \"@electric-sql/pglite\";\nimport { drizzle, type PgliteDatabase } from \"drizzle-orm/pglite\";\n\nimport { ConfigurationError } from \"../../errors\";\nimport {\n generatePostgresDDL,\n generatePostgresMigrationSQL,\n} from \"../drizzle/ddl\";\nimport { type AnyPgTransaction } from \"../drizzle/execution\";\nexport type { AnyPgDatabase, AnyPgTransaction } from \"../drizzle/execution\";\nimport {\n createPostgresBackend,\n type PostgresTables,\n tables as defaultTables,\n} from \"../drizzle/postgres\";\nimport {\n type AdapterBackend,\n closeAfterFailure,\n wrapWithManagedClose,\n} from \"../types\";\n\n// ============================================================\n// Types\n// ============================================================\n\n/**\n * Options for creating a local PGlite backend.\n */\nexport type LocalPgliteBackendOptions = Readonly<{\n /**\n * PGlite data directory. Omit for an in-memory database (the default).\n * Accepts any PGlite data-dir spec: a filesystem path (`\"./pgdata\"`),\n * `\"memory://\"`, or a browser/runtime-specific scheme such as\n * `\"idb://my-db\"`.\n */\n dataDir?: string;\n\n /**\n * Custom table definitions. Defaults to standard TypeGraph table names.\n */\n tables?: PostgresTables;\n\n /**\n * Controls the pgvector stack:\n *\n * - **omitted (default)** — load pgvector from `@electric-sql/pglite-pgvector`\n * and run `CREATE EXTENSION vector`, so embedding fields work out of the\n * box. Throws a {@link ConfigurationError} if the package isn't installed.\n * - **`false`** — skip the extension entirely; the backend advertises no\n * vector capability (mirroring a SQLite connection without sqlite-vec).\n * Use when a graph carries no embeddings, or to avoid the extension dep.\n * - **a PGlite `Extension`** — bring your own pgvector build or custom\n * extension packaging. Decouples this helper from a specific pgvector\n * package version.\n */\n vector?: false | Extension;\n}>;\n\n/**\n * Result of creating a local PGlite backend.\n */\nexport type LocalPgliteBackendResult = Readonly<{\n /**\n * The GraphBackend instance for use with createStore. Its `close()`\n * disposes the underlying PGlite engine.\n */\n backend: AdapterBackend<AnyPgTransaction>;\n\n /**\n * The underlying Drizzle database instance. Useful for direct SQL access.\n */\n db: PgliteDatabase;\n\n /**\n * The raw PGlite instance, for engine-specific operations such as\n * `dumpDataDir()` / `clone()` not surfaced through Drizzle.\n */\n client: PGlite;\n}>;\n\n// ============================================================\n// Vector extension loading\n// ============================================================\n\n/**\n * Dynamically loads the default pgvector extension from\n * `@electric-sql/pglite-pgvector`. Kept as a runtime import so the package\n * stays an optional peer dependency — callers using `vector: false` or\n * supplying their own extension never need it installed.\n */\nasync function loadDefaultPgvectorExtension(): Promise<Extension> {\n try {\n const module_ = await import(\"@electric-sql/pglite-pgvector\");\n return module_.vector;\n } catch (error) {\n throw new ConfigurationError(\n \"createLocalPgliteBackend needs the pgvector extension but \" +\n \"`@electric-sql/pglite-pgvector` could not be loaded. Install it \" +\n \"(`pnpm add @electric-sql/pglite-pgvector`), pass your own `vector` \" +\n \"extension, or set `vector: false` to disable vector support.\",\n { backend: \"pglite\", dependency: \"@electric-sql/pglite-pgvector\" },\n { cause: error },\n );\n }\n}\n\n// ============================================================\n// Factory Function\n// ============================================================\n\n/**\n * Creates a TypeGraph backend backed by an in-process PGlite database.\n *\n * Constructs the PGlite engine (loading pgvector unless disabled), executes\n * the schema DDL, and wires the standard Postgres backend. The returned\n * backend owns the engine: call `backend.close()` to dispose it.\n *\n * For production Postgres, or a PGlite instance you construct yourself,\n * use `createPostgresBackend` directly with your own Drizzle database — the\n * execution fast path detects PGlite and routes it correctly.\n *\n * @param options - Configuration options\n * @returns Backend, Drizzle database, and raw PGlite client\n */\nexport async function createLocalPgliteBackend(\n options: LocalPgliteBackendOptions = {},\n): Promise<LocalPgliteBackendResult> {\n const tables = options.tables ?? defaultTables;\n\n // pgvector lives in the WASM instance, so the extension must be passed at\n // construction — `CREATE EXTENSION vector` alone can't pull it in. An\n // explicitly supplied extension wins; `false` disables; otherwise load the\n // default package.\n const vectorExtension =\n options.vector === false ?\n undefined\n : (options.vector ?? (await loadDefaultPgvectorExtension()));\n const vectorEnabled = vectorExtension !== undefined;\n\n // Construct via the single options-object form (passing `dataDir` as a\n // field), not the positional `create(dataDir, options)` overload: with a\n // leading `undefined` dataDir, that overload silently drops `extensions`\n // (\"extension vector is not available\"). The options form loads them for\n // both the in-memory and on-disk cases.\n const client = await PGlite.create({\n ...(options.dataDir === undefined ? {} : { dataDir: options.dataDir }),\n ...(vectorExtension === undefined ?\n {}\n : { extensions: { vector: vectorExtension } }),\n });\n\n try {\n // `exec` runs a multi-statement batch (DDL + the pgvector `CREATE\n // EXTENSION` when enabled) in one round trip.\n const migrationSql =\n vectorEnabled ?\n generatePostgresMigrationSQL(tables)\n : generatePostgresDDL(tables).join(\"\\n\\n\");\n await client.exec(migrationSql);\n\n const db = drizzle(client);\n const backend = createPostgresBackend(db, {\n tables,\n ...(vectorEnabled ? {} : { vector: false }),\n });\n const managedBackend = wrapWithManagedClose(backend, async () => {\n await client.close();\n });\n\n return { backend: managedBackend, db, client };\n } catch (error) {\n return closeAfterFailure(client, error);\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isPlainObject } from './chunk-ITE4IXAK.js';
|
|
2
|
-
import { ConfigurationError } from './chunk-
|
|
2
|
+
import { ConfigurationError } from './chunk-OYJSYDIH.js';
|
|
3
3
|
|
|
4
4
|
// src/core/json-value.ts
|
|
5
5
|
function assertJsonValue(value, rootLabel, ownerKind) {
|
|
@@ -55,5 +55,5 @@ function throwInvalid(path, kind, ownerKind) {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
export { assertJsonValue };
|
|
58
|
-
//# sourceMappingURL=chunk-
|
|
59
|
-
//# sourceMappingURL=chunk-
|
|
58
|
+
//# sourceMappingURL=chunk-RXOAXO3R.js.map
|
|
59
|
+
//# sourceMappingURL=chunk-RXOAXO3R.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/json-value.ts"],"names":[],"mappings":";;;;AAyBO,SAAS,eAAA,CACd,KAAA,EACA,SAAA,EACA,SAAA,EACM;AACN,EAAA,IAAA,CAAK,KAAA,EAAO,WAAW,SAAS,CAAA;AAClC;AAEA,SAAS,IAAA,CAAK,KAAA,EAAgB,IAAA,EAAc,SAAA,EAAyB;AACnE,EAAA,IAAI,UAAU,IAAA,EAAM;AACpB,EAAA,MAAM,YAAY,OAAO,KAAA;AACzB,EAAA,IAAI,cAAc,QAAA,EAAU;AAI1B,IAAA,IAAI,CAAC,MAAA,CAAO,QAAA,CAAS,KAAK,CAAA,EAAG;AAC3B,MAAA,YAAA,CAAa,IAAA,EAAM,iBAAA,CAAkB,KAAe,CAAA,EAAG,SAAS,CAAA;AAAA,IAClE;AACA,IAAA;AAAA,EACF;AACA,EAAA,IAAI,SAAA,KAAc,QAAA,IAAY,SAAA,KAAc,SAAA,EAAW;AACvD,EAAA,IACE,cAAc,QAAA,IACd,SAAA,KAAc,cACd,SAAA,KAAc,QAAA,IACd,cAAc,WAAA,EACd;AACA,IAAA,YAAA,CAAa,IAAA,EAAM,WAAW,SAAS,CAAA;AAAA,EACzC;AACA,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxB,IAAA,KAAA,MAAW,CAAC,KAAA,EAAO,OAAO,CAAA,IAAK,KAAA,CAAM,SAAQ,EAAG;AAC9C,MAAA,IAAA,CAAK,SAAS,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,KAAK,KAAK,SAAS,CAAA;AAAA,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CAAA,EAAG;AACjD,IAAA,IAAA,CAAK,QAAQ,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,GAAG,IAAI,SAAS,CAAA;AAAA,EAC1C;AACF;AAEA,SAAS,kBAAkB,KAAA,EAAuB;AAChD,EAAA,IAAI,MAAA,CAAO,KAAA,CAAM,KAAK,CAAA,EAAG,OAAO,KAAA;AAChC,EAAA,IAAI,KAAA,KAAU,MAAA,CAAO,iBAAA,EAAmB,OAAO,UAAA;AAC/C,EAAA,IAAI,KAAA,KAAU,MAAA,CAAO,iBAAA,EAAmB,OAAO,WAAA;AAC/C,EAAA,OAAO,mBAAA;AACT;AAEA,SAAS,iBAAiB,KAAA,EAAwB;AAChD,EAAA,MAAM,eAAA,GAAmB,OACrB,WAAA,EAAa,IAAA;AACjB,EAAA,IAAI,OAAO,eAAA,KAAoB,QAAA,IAAY,eAAA,CAAgB,SAAS,CAAA,EAAG;AACrE,IAAA,OAAO,GAAG,eAAe,CAAA,SAAA,CAAA;AAAA,EAC3B;AACA,EAAA,OAAO,kBAAA;AACT;AAEA,SAAS,YAAA,CAAa,IAAA,EAAc,IAAA,EAAc,SAAA,EAA0B;AAC1E,EAAA,MAAM,IAAI,kBAAA;AAAA,IACR,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,IAAI,+BAA+B,IAAI,CAAA,yCAAA,CAAA;AAAA,IACvD,EAAE,IAAA,EAAM,SAAA,EAAW,IAAA,EAAK;AAAA,IACxB;AAAA,MACE,UAAA,EACE;AAAA;AACJ,GACF;AACF","file":"chunk-RXOAXO3R.js","sourcesContent":["/**\n * Runtime validation for JSON-serializable values.\n *\n * Used at definition-time boundaries (e.g., `defineNode`/`defineEdge` annotations)\n * to reject values that would silently break `JSON.stringify` round-trips or\n * throw at hash time. Catches accidental violations from untyped JS callers\n * and `as any` escape hatches that bypass the `JsonValue` type.\n */\nimport { ConfigurationError } from \"../errors\";\nimport { isPlainObject } from \"../utils/object\";\n\n/**\n * Asserts that `value` is JSON-serializable.\n *\n * Throws `ConfigurationError` with a dotted path identifying the offending\n * field. Rejects `bigint`, `function`, `symbol`, `undefined`, and class\n * instances such as `Date`, `Map`, `Set`, regex literals, and Buffers — all\n * of which either throw or silently coerce under `JSON.stringify`.\n *\n * @param value - The value to validate\n * @param rootLabel - Label for the root of the value (e.g., `\"annotations\"`)\n * used as the prefix of the error path\n * @param ownerKind - Human-readable owner identifier for the error message\n * (e.g., `'Node \"Person\"'`)\n */\nexport function assertJsonValue(\n value: unknown,\n rootLabel: string,\n ownerKind: string,\n): void {\n walk(value, rootLabel, ownerKind);\n}\n\nfunction walk(value: unknown, path: string, ownerKind: string): void {\n if (value === null) return;\n const valueType = typeof value;\n if (valueType === \"number\") {\n // NaN/Infinity/-Infinity are not JSON values; JSON.stringify silently\n // coerces them to `null`, which would change the canonical hash input\n // without the consumer noticing.\n if (!Number.isFinite(value)) {\n throwInvalid(path, describeNonFinite(value as number), ownerKind);\n }\n return;\n }\n if (valueType === \"string\" || valueType === \"boolean\") return;\n if (\n valueType === \"bigint\" ||\n valueType === \"function\" ||\n valueType === \"symbol\" ||\n valueType === \"undefined\"\n ) {\n throwInvalid(path, valueType, ownerKind);\n }\n if (Array.isArray(value)) {\n for (const [index, element] of value.entries()) {\n walk(element, `${path}[${index}]`, ownerKind);\n }\n return;\n }\n if (!isPlainObject(value)) {\n throwInvalid(path, describeNonPlain(value), ownerKind);\n }\n for (const [key, nested] of Object.entries(value)) {\n walk(nested, `${path}.${key}`, ownerKind);\n }\n}\n\nfunction describeNonFinite(value: number): string {\n if (Number.isNaN(value)) return \"NaN\";\n if (value === Number.POSITIVE_INFINITY) return \"Infinity\";\n if (value === Number.NEGATIVE_INFINITY) return \"-Infinity\";\n return \"non-finite number\";\n}\n\nfunction describeNonPlain(value: unknown): string {\n const constructorName = (value as { constructor?: { name?: unknown } } | null)\n ?.constructor?.name;\n if (typeof constructorName === \"string\" && constructorName.length > 0) {\n return `${constructorName} instance`;\n }\n return \"non-plain object\";\n}\n\nfunction throwInvalid(path: string, kind: string, ownerKind: string): never {\n throw new ConfigurationError(\n `${ownerKind} ${path} contains a non-JSON value (${kind}). Annotations must be JSON-serializable.`,\n { path, valueKind: kind },\n {\n suggestion:\n \"Use only strings, numbers, booleans, null, arrays, and plain objects in annotations.\",\n },\n );\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkUTTW2Q3M_cjs = require('./chunk-UTTW2Q3M.cjs');
|
|
4
4
|
|
|
5
5
|
// src/indexes/system.ts
|
|
6
6
|
var SYSTEM_INDEX_DECLARATIONS = [
|
|
@@ -175,7 +175,7 @@ var MAX_SQL_IDENTIFIER_LENGTH = 63;
|
|
|
175
175
|
function systemIndexName(physicalTableName, suffix) {
|
|
176
176
|
const full = `${physicalTableName}_${suffix}`;
|
|
177
177
|
if (full.length <= MAX_SQL_IDENTIFIER_LENGTH) return full;
|
|
178
|
-
const hash =
|
|
178
|
+
const hash = chunkUTTW2Q3M_cjs.shortHash(JSON.stringify([physicalTableName, suffix]));
|
|
179
179
|
return `${full.slice(0, MAX_SQL_IDENTIFIER_LENGTH - 1 - hash.length)}_${hash}`;
|
|
180
180
|
}
|
|
181
181
|
function resolveSystemIndexNames(overrides) {
|
|
@@ -200,11 +200,11 @@ function assertNoSystemIndexNameCollision(indexes, overrides) {
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
function generateSystemIndexDDL(declaration, physicalTableName, options) {
|
|
203
|
-
const name =
|
|
203
|
+
const name = chunkUTTW2Q3M_cjs.quoteIdentifier(
|
|
204
204
|
systemIndexName(physicalTableName, declaration.suffix)
|
|
205
205
|
);
|
|
206
|
-
const table =
|
|
207
|
-
const columns = declaration.columns.map((column) =>
|
|
206
|
+
const table = chunkUTTW2Q3M_cjs.quoteIdentifier(physicalTableName);
|
|
207
|
+
const columns = declaration.columns.map((column) => chunkUTTW2Q3M_cjs.quoteIdentifier(column)).join(", ");
|
|
208
208
|
const concurrently = options.concurrent ? "CONCURRENTLY " : "";
|
|
209
209
|
return `CREATE INDEX ${concurrently}IF NOT EXISTS ${name} ON ${table} (${columns});`;
|
|
210
210
|
}
|
|
@@ -215,5 +215,5 @@ exports.generateSystemIndexDDL = generateSystemIndexDDL;
|
|
|
215
215
|
exports.resolveSystemIndexNames = resolveSystemIndexNames;
|
|
216
216
|
exports.resolveSystemIndexTableName = resolveSystemIndexTableName;
|
|
217
217
|
exports.systemIndexName = systemIndexName;
|
|
218
|
-
//# sourceMappingURL=chunk-
|
|
219
|
-
//# sourceMappingURL=chunk-
|
|
218
|
+
//# sourceMappingURL=chunk-TRC646QQ.cjs.map
|
|
219
|
+
//# sourceMappingURL=chunk-TRC646QQ.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/indexes/system.ts"],"names":["shortHash","quoteIdentifier"],"mappings":";;;;;AA6EO,IAAM,yBAAA,GAA+D;AAAA;AAAA,EAE1E,EAAE,OAAO,OAAA,EAAS,MAAA,EAAQ,YAAY,OAAA,EAAS,CAAC,UAAA,EAAY,MAAM,CAAA,EAAE;AAAA;AAAA;AAAA;AAAA,EAIpE;AAAA,IACE,KAAA,EAAO,OAAA;AAAA,IACP,MAAA,EAAQ,kBAAA;AAAA,IACR,OAAA,EAAS,CAAC,UAAA,EAAY,MAAA,EAAQ,cAAc,YAAY;AAAA,GAC1D;AAAA,EACA;AAAA,IACE,KAAA,EAAO,OAAA;AAAA,IACP,MAAA,EAAQ,aAAA;AAAA,IACR,OAAA,EAAS,CAAC,UAAA,EAAY,YAAY;AAAA,GACpC;AAAA,EACA;AAAA,IACE,KAAA,EAAO,OAAA;AAAA,IACP,MAAA,EAAQ,WAAA;AAAA,IACR,OAAA,EAAS,CAAC,UAAA,EAAY,YAAA,EAAc,UAAU;AAAA,GAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,EAAE,OAAO,OAAA,EAAS,MA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4B,WAAA,CAAY,KAAA,EAAO,SAAS,CAAA;AAAA,QACxD,WAAA,CAAY;AAAA;AACd;AACF,GACF;AACF;AAUO,SAAS,gCAAA,CACd,SACA,SAAA,EAEM;AACN,EAAA,IAAI,OAAA,CAAQ,WAAW,CAAA,EAAG;AAC1B,EAAA,MAAM,QAAA,GAAW,wBAAwB,SAAS,CAAA;AAClD,EAAA,KAAA,MAAW,SAAS,OAAA,EAAS;AAC3B,IAAA,IAAI,QAAA,CAAS,GAAA,CAAI,KAAA,CAAM,IAAI,CAAA,EAAG;AAC5B,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,YAAA,EAAe,MAAM,IAAI,CAAA,yOAAA;AAAA,OAK3B;AAAA,IACF;AAAA,EACF;AACF;AAQO,SAAS,sBAAA,CACd,WAAA,EACA,iBAAA,EACA,OAAA,EACQ;AACR,EAAA,MAAM,IAAA,GAAOC,iCAAA;AAAA,IACX,eAAA,CAAgB,iBAAA,EAAmB,WAAA,CAAY,MAAM;AAAA,GACvD;AACA,EAAA,MAAM,KAAA,GAAQA,kCAAgB,iBAAiB,CAAA;AAC/C,EAAA,MAAM,OAAA,GAAU,WAAA,CAAY,OAAA,CACzB,GAAA,CAAI,CAAC,MAAA,KAAWA,iCAAA,CAAgB,MAAM,CAAC,CAAA,CACvC,IAAA,CAAK,IAAI,CAAA;AACZ,EAAA,MAAM,YAAA,GAAe,OAAA,CAAQ,UAAA,GAAa,eAAA,GAAkB,EAAA;AAC5D,EAAA,OAAO,gBAAgB,YAAY,CAAA,cAAA,EAAiB,IAAI,CAAA,IAAA,EAAO,KAAK,KAAK,OAAO,CAAA,EAAA,CAAA;AAClF","file":"chunk-LLE25NRD.cjs","sourcesContent":["/**\n * System-index declarations — the single source of truth for the plain\n * btree indexes TypeGraph ships on its own relations.\n *\n * Both dialect schema factories (`createSqliteTables` /\n * `createPostgresTables`) derive their Drizzle index builders from this\n * list, so the two dialects cannot drift, and\n * `materializeSystemIndexes()` derives the same indexes as runtime DDL so\n * an index added in a new library version reaches already-initialized\n * databases (bootstrap DDL only runs on first boot — see\n * `loadActiveSchemaWithBootstrap`).\n *\n * Scope: non-unique btree column indexes on the four graph relations,\n * where performance iteration actually happens. Primary keys, unique /\n * partial-unique constraints, and status-table indexes are structural —\n * they are created with their table and never retrofitted — and stay in\n * the schema files.\n *\n * Changing a declaration's shape under the same suffix is a signature\n * drift: `materializeSystemIndexes` reports `failed` for it until the\n * operator drops the old physical index. Rename (new suffix) instead,\n * exactly like graph-declared indexes. Two acknowledged limits of that\n * contract: on databases whose indexes were bootstrap-created (no status\n * rows) an in-place reshape is undetectable at runtime — the rename rule\n * is enforced by review and the parity tests; and a renamed suffix\n * strands the old physical index (the runner only adds). When the first\n * rename actually happens, add a retired-suffixes list + drop path here.\n */\nimport { quoteIdentifier, shortHash } from \"../query/dialect/vector-strategy\";\n\n/** The TypeGraph relations that carry system indexes. */\nexport type SystemIndexTable =\n \"nodes\" | \"edges\" | \"recordedNodes\" | \"recordedEdges\";\n\ntype LiveColumn =\n | \"graph_id\"\n | \"kind\"\n | \"id\"\n | \"deleted_at\"\n | \"valid_from\"\n | \"valid_to\"\n | \"created_at\";\n\ntype LiveEdgeColumn =\n LiveColumn | \"from_kind\" | \"from_id\" | \"to_kind\" | \"to_id\";\n\ntype RecordedColumn =\n | \"graph_id\"\n | \"kind\"\n | \"id\"\n | \"valid_from\"\n | \"valid_to\"\n | \"recorded_from\"\n | \"recorded_to\";\n\ntype RecordedEdgeColumn =\n RecordedColumn | \"from_kind\" | \"from_id\" | \"to_kind\" | \"to_id\";\n\ntype SystemIndexColumnsFor<T extends SystemIndexTable> =\n T extends \"nodes\" ? LiveColumn\n : T extends \"edges\" ? LiveEdgeColumn\n : T extends \"recordedNodes\" ? RecordedColumn\n : RecordedEdgeColumn;\n\ntype SystemIndexDeclarationFor<T extends SystemIndexTable> = Readonly<{\n table: T;\n /** Physical index name is `${physicalTableName}_${suffix}`. */\n suffix: string;\n columns: readonly [SystemIndexColumnsFor<T>, ...SystemIndexColumnsFor<T>[]];\n}>;\n\nexport type SystemIndexDeclaration =\n | SystemIndexDeclarationFor<\"nodes\">\n | SystemIndexDeclarationFor<\"edges\">\n | SystemIndexDeclarationFor<\"recordedNodes\">\n | SystemIndexDeclarationFor<\"recordedEdges\">;\n\nexport const SYSTEM_INDEX_DECLARATIONS: readonly SystemIndexDeclaration[] = [\n // ---------------------------------------------------------- nodes\n { table: \"nodes\", suffix: \"kind_idx\", columns: [\"graph_id\", \"kind\"] },\n // Listing shape: kind partition ordered by creation with the\n // soft-delete column ahead of it so `deleted_at IS NULL` list queries\n // stay index-served.\n {\n table: \"nodes\",\n suffix: \"kind_created_idx\",\n columns: [\"graph_id\", \"kind\", \"deleted_at\", \"created_at\"],\n },\n {\n table: \"nodes\",\n suffix: \"deleted_idx\",\n columns: [\"graph_id\", \"deleted_at\"],\n },\n {\n table: \"nodes\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n // Bare-id lookup: the primary key leads with `kind` (graph_id, kind,\n // id), so a `WHERE graph_id = ? AND id = ?` probe that doesn't know the\n // kind can't seek it — SQLite falls back to a graph_id-only scan of\n // every node in the graph (~3M at LDBC SF1).\n // `store.algorithms.degree`'s node-kind subquery does exactly that\n // lookup (it resolves the seed's kind by id), so without this index\n // degree is a full nodes scan (~95ms at SF1). See typegraph#280.\n { table: \"nodes\", suffix: \"id_idx\", columns: [\"graph_id\", \"id\"] },\n\n // ---------------------------------------------------------- edges\n { table: \"edges\", suffix: \"kind_idx\", columns: [\"graph_id\", \"kind\"] },\n // Directional traversal index (outgoing): supports endpoint lookups\n // and extra filtering by edge kind / target kind. Includes every\n // system column the compiled query's soft-delete/temporal-validity\n // predicate touches (deleted_at, valid_from, valid_to), trailed by\n // to_id — the compiled traversal join reads `n.id = e.to_id` for an\n // outgoing traversal (standard-builders.ts), so without to_id here\n // the join still fetches the edge's heap row for that one column\n // even with the seek/predicate columns covered.\n {\n table: \"edges\",\n suffix: \"from_idx\",\n columns: [\n \"graph_id\",\n \"from_kind\",\n \"from_id\",\n \"kind\",\n \"to_kind\",\n \"deleted_at\",\n \"valid_from\",\n \"valid_to\",\n \"to_id\",\n ],\n },\n // Directional traversal index (incoming): mirrors from_idx for\n // reverse traversals, trailed by from_id for the same reason\n // (`n.id = e.from_id` for an incoming traversal).\n {\n table: \"edges\",\n suffix: \"to_idx\",\n columns: [\n \"graph_id\",\n \"to_kind\",\n \"to_id\",\n \"kind\",\n \"from_kind\",\n \"deleted_at\",\n \"valid_from\",\n \"valid_to\",\n \"from_id\",\n ],\n },\n {\n table: \"edges\",\n suffix: \"kind_created_idx\",\n columns: [\"graph_id\", \"kind\", \"deleted_at\", \"created_at\"],\n },\n {\n table: \"edges\",\n suffix: \"deleted_idx\",\n columns: [\"graph_id\", \"deleted_at\"],\n },\n {\n table: \"edges\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n // Cardinality enforcement: the one-per-endpoint check probes for a\n // currently-valid edge of a kind from a specific endpoint.\n {\n table: \"edges\",\n suffix: \"cardinality_idx\",\n columns: [\"graph_id\", \"kind\", \"from_kind\", \"from_id\", \"valid_to\"],\n },\n\n // ---------------------------------------------------------- recordedNodes\n {\n table: \"recordedNodes\",\n suffix: \"entity_idx\",\n columns: [\"graph_id\", \"kind\", \"id\", \"recorded_from\", \"recorded_to\"],\n },\n {\n table: \"recordedNodes\",\n suffix: \"open_idx\",\n columns: [\"graph_id\", \"recorded_to\"],\n },\n {\n table: \"recordedNodes\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n // Bare-id lookup parity with the live nodes table: recorded-pinned\n // reads swap this relation in as the node source, and `entity_idx`\n // leads with `kind`, so the same kind-by-bare-id probe (e.g.\n // `degree()` at a recorded coordinate) would otherwise scan every\n // historical version in the graph. See typegraph#280.\n { table: \"recordedNodes\", suffix: \"id_idx\", columns: [\"graph_id\", \"id\"] },\n\n // ---------------------------------------------------------- recordedEdges\n {\n table: \"recordedEdges\",\n suffix: \"entity_idx\",\n columns: [\"graph_id\", \"kind\", \"id\", \"recorded_from\", \"recorded_to\"],\n },\n {\n table: \"recordedEdges\",\n suffix: \"open_idx\",\n columns: [\"graph_id\", \"recorded_to\"],\n },\n {\n table: \"recordedEdges\",\n suffix: \"from_idx\",\n columns: [\n \"graph_id\",\n \"from_kind\",\n \"from_id\",\n \"kind\",\n \"to_kind\",\n \"recorded_from\",\n \"recorded_to\",\n ],\n },\n {\n table: \"recordedEdges\",\n suffix: \"to_idx\",\n columns: [\n \"graph_id\",\n \"to_kind\",\n \"to_id\",\n \"kind\",\n \"from_kind\",\n \"recorded_from\",\n \"recorded_to\",\n ],\n },\n {\n table: \"recordedEdges\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n];\n\n/** Default physical table names for the system-index relations. */\nconst DEFAULT_SYSTEM_INDEX_TABLE_NAMES: Readonly<\n Record<SystemIndexTable, string>\n> = {\n nodes: \"typegraph_nodes\",\n edges: \"typegraph_edges\",\n recordedNodes: \"typegraph_recorded_nodes\",\n recordedEdges: \"typegraph_recorded_edges\",\n};\n\n/**\n * Resolves the physical table name for a system-index relation, honoring\n * a backend's table-name overrides.\n */\nexport function resolveSystemIndexTableName(\n table: SystemIndexTable,\n overrides:\n Readonly<Partial<Record<SystemIndexTable, string | undefined>>> | undefined,\n): string {\n return overrides?.[table] ?? DEFAULT_SYSTEM_INDEX_TABLE_NAMES[table];\n}\n\n/**\n * PostgreSQL truncates identifiers to NAMEDATALEN-1 = 63 bytes SILENTLY —\n * two suffixes of one long custom table name would collide after\n * truncation, and the catalog probes (which compare by exact name) would\n * never match the stored name, re-attempting the build on every boot.\n * SQLite has no such limit but uses the same bound so the two dialects'\n * index sets stay in byte-for-byte parity. (Char-based like the vector\n * identifier bound — multibyte table names are out of scope.)\n */\nconst MAX_SQL_IDENTIFIER_LENGTH = 63;\n\n/**\n * Physical index name: `${physicalTableName}_${suffix}`, deterministically\n * truncated + hash-suffixed past the 63-char identifier bound so distinct\n * indexes stay distinct. Single choke point — the Drizzle builders, the\n * runtime DDL, the catalog probes, and the status keys all derive the\n * name here, so they can never disagree.\n */\nexport function systemIndexName(\n physicalTableName: string,\n suffix: string,\n): string {\n const full = `${physicalTableName}_${suffix}`;\n if (full.length <= MAX_SQL_IDENTIFIER_LENGTH) return full;\n const hash = shortHash(JSON.stringify([physicalTableName, suffix]));\n return `${full.slice(0, MAX_SQL_IDENTIFIER_LENGTH - 1 - hash.length)}_${hash}`;\n}\n\n/**\n * Every system index name for a deployment's (possibly overridden) table\n * names. Graph-declared index names must not collide with these: a\n * colliding `CREATE INDEX IF NOT EXISTS` would silently no-op against the\n * system index (wrong shape) while recording a false success — see the\n * guards in the schema factories and `materializeIndexes`.\n */\nexport function resolveSystemIndexNames(\n overrides:\n Readonly<Partial<Record<SystemIndexTable, string | undefined>>> | undefined,\n): ReadonlySet<string> {\n return new Set(\n SYSTEM_INDEX_DECLARATIONS.map((declaration) =>\n systemIndexName(\n resolveSystemIndexTableName(declaration.table, overrides),\n declaration.suffix,\n ),\n ),\n );\n}\n\n/**\n * Rejects graph-declared indexes whose names collide with this\n * deployment's system index names. Called by both dialect schema\n * factories so a colliding declaration fails at table-definition time\n * instead of silently no-opping against the (differently shaped) system\n * index at CREATE INDEX IF NOT EXISTS time. `materializeIndexes` applies\n * the same check per-declaration on its runtime path.\n */\nexport function assertNoSystemIndexNameCollision(\n indexes: readonly Readonly<{ name: string }>[],\n overrides:\n Readonly<Partial<Record<SystemIndexTable, string | undefined>>> | undefined,\n): void {\n if (indexes.length === 0) return;\n const reserved = resolveSystemIndexNames(overrides);\n for (const index of indexes) {\n if (reserved.has(index.name)) {\n throw new Error(\n `Index name \"${index.name}\" collides with a TypeGraph system ` +\n `index. Choose a different name — system index names are ` +\n `reserved, and a same-named CREATE INDEX IF NOT EXISTS would ` +\n `silently no-op against the system index instead of creating ` +\n `the declared one.`,\n );\n }\n }\n}\n\n/**\n * Runtime DDL for one system index — byte-compatible with the index the\n * bootstrap path creates from the Drizzle schema (same name, same\n * columns), plus `CONCURRENTLY` where the dialect supports building\n * without blocking writes.\n */\nexport function generateSystemIndexDDL(\n declaration: SystemIndexDeclaration,\n physicalTableName: string,\n options: Readonly<{ concurrent: boolean }>,\n): string {\n const name = quoteIdentifier(\n systemIndexName(physicalTableName, declaration.suffix),\n );\n const table = quoteIdentifier(physicalTableName);\n const columns = declaration.columns\n .map((column) => quoteIdentifier(column))\n .join(\", \");\n const concurrently = options.concurrent ? \"CONCURRENTLY \" : \"\";\n return `CREATE INDEX ${concurrently}IF NOT EXISTS ${name} ON ${table} (${columns});`;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/indexes/system.ts"],"names":["shortHash","quoteIdentifier"],"mappings":";;;;;AA6EO,IAAM,yBAAA,GAA+D;AAAA;AAAA,EAE1E,EAAE,OAAO,OAAA,EAAS,MAAA,EAAQ,YAAY,OAAA,EAAS,CAAC,UAAA,EAAY,MAAM,CAAA,EAAE;AAAA;AAAA;AAAA;AAAA,EAIpE;AAAA,IACE,KAAA,EAAO,OAAA;AAAA,IACP,MAAA,EAAQ,kBAAA;AAAA,IACR,OAAA,EAAS,CAAC,UAAA,EAAY,MAAA,EAAQ,cAAc,YAAY;AAAA,GAC1D;AAAA,EACA;AAAA,IACE,KAAA,EAAO,OAAA;AAAA,IACP,MAAA,EAAQ,aAAA;AAAA,IACR,OAAA,EAAS,CAAC,UAAA,EAAY,YAAY;AAAA,GACpC;AAAA,EACA;AAAA,IACE,KAAA,EAAO,OAAA;AAAA,IACP,MAAA,EAAQ,WAAA;AAAA,IACR,OAAA,EAAS,CAAC,UAAA,EAAY,YAAA,EAAc,UAAU;AAAA,GAChD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,EAAE,OAAO,OAAA,EAAS,MAAA,EAAQ,UAAU,OAAA,EAAS,CAAC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CAAA;AAAA,QACxD,WAAA,CAAY;AAAA;AACd;AACF,GACF;AACF;AAUO,SAAS,gCAAA,CACd,SACA,SAAA,EAEM;AACN,EAAA,IAAI,OAAA,CAAQ,WAAW,CAAA,EAAG;AAC1B,EAAA,MAAM,QAAA,GAAW,wBAAwB,SAAS,CAAA;AAClD,EAAA,KAAA,MAAW,SAAS,OAAA,EAAS;AAC3B,IAAA,IAAI,QAAA,CAAS,GAAA,CAAI,KAAA,CAAM,IAAI,CAAA,EAAG;AAC5B,MAAA,MAAM,IAAI,KAAA;AAAA,QACR,CAAA,YAAA,EAAe,MAAM,IAAI,CAAA,yOAAA;AAAA,OAK3B;AAAA,IACF;AAAA,EACF;AACF;AAQO,SAAS,sBAAA,CACd,WAAA,EACA,iBAAA,EACA,OAAA,EACQ;AACR,EAAA,MAAM,IAAA,GAAOC,iCAAA;AAAA,IACX,eAAA,CAAgB,iBAAA,EAAmB,WAAA,CAAY,MAAM;AAAA,GACvD;AACA,EAAA,MAAM,KAAA,GAAQA,kCAAgB,iBAAiB,CAAA;AAC/C,EAAA,MAAM,OAAA,GAAU,WAAA,CAAY,OAAA,CACzB,GAAA,CAAI,CAAC,MAAA,KAAWA,iCAAA,CAAgB,MAAM,CAAC,CAAA,CACvC,IAAA,CAAK,IAAI,CAAA;AACZ,EAAA,MAAM,YAAA,GAAe,OAAA,CAAQ,UAAA,GAAa,eAAA,GAAkB,EAAA;AAC5D,EAAA,OAAO,gBAAgB,YAAY,CAAA,cAAA,EAAiB,IAAI,CAAA,IAAA,EAAO,KAAK,KAAK,OAAO,CAAA,EAAA,CAAA;AAClF","file":"chunk-TRC646QQ.cjs","sourcesContent":["/**\n * System-index declarations — the single source of truth for the plain\n * btree indexes TypeGraph ships on its own relations.\n *\n * Both dialect schema factories (`createSqliteTables` /\n * `createPostgresTables`) derive their Drizzle index builders from this\n * list, so the two dialects cannot drift, and\n * `materializeSystemIndexes()` derives the same indexes as runtime DDL so\n * an index added in a new library version reaches already-initialized\n * databases (bootstrap DDL only runs on first boot — see\n * `loadActiveSchemaWithBootstrap`).\n *\n * Scope: non-unique btree column indexes on the four graph relations,\n * where performance iteration actually happens. Primary keys, unique /\n * partial-unique constraints, and status-table indexes are structural —\n * they are created with their table and never retrofitted — and stay in\n * the schema files.\n *\n * Changing a declaration's shape under the same suffix is a signature\n * drift: `materializeSystemIndexes` reports `failed` for it until the\n * operator drops the old physical index. Rename (new suffix) instead,\n * exactly like graph-declared indexes. Two acknowledged limits of that\n * contract: on databases whose indexes were bootstrap-created (no status\n * rows) an in-place reshape is undetectable at runtime — the rename rule\n * is enforced by review and the parity tests; and a renamed suffix\n * strands the old physical index (the runner only adds). When the first\n * rename actually happens, add a retired-suffixes list + drop path here.\n */\nimport { quoteIdentifier, shortHash } from \"../query/dialect/vector-strategy\";\n\n/** The TypeGraph relations that carry system indexes. */\nexport type SystemIndexTable =\n \"nodes\" | \"edges\" | \"recordedNodes\" | \"recordedEdges\";\n\ntype LiveColumn =\n | \"graph_id\"\n | \"kind\"\n | \"id\"\n | \"deleted_at\"\n | \"valid_from\"\n | \"valid_to\"\n | \"created_at\";\n\ntype LiveEdgeColumn =\n LiveColumn | \"from_kind\" | \"from_id\" | \"to_kind\" | \"to_id\";\n\ntype RecordedColumn =\n | \"graph_id\"\n | \"kind\"\n | \"id\"\n | \"valid_from\"\n | \"valid_to\"\n | \"recorded_from\"\n | \"recorded_to\";\n\ntype RecordedEdgeColumn =\n RecordedColumn | \"from_kind\" | \"from_id\" | \"to_kind\" | \"to_id\";\n\ntype SystemIndexColumnsFor<T extends SystemIndexTable> =\n T extends \"nodes\" ? LiveColumn\n : T extends \"edges\" ? LiveEdgeColumn\n : T extends \"recordedNodes\" ? RecordedColumn\n : RecordedEdgeColumn;\n\ntype SystemIndexDeclarationFor<T extends SystemIndexTable> = Readonly<{\n table: T;\n /** Physical index name is `${physicalTableName}_${suffix}`. */\n suffix: string;\n columns: readonly [SystemIndexColumnsFor<T>, ...SystemIndexColumnsFor<T>[]];\n}>;\n\nexport type SystemIndexDeclaration =\n | SystemIndexDeclarationFor<\"nodes\">\n | SystemIndexDeclarationFor<\"edges\">\n | SystemIndexDeclarationFor<\"recordedNodes\">\n | SystemIndexDeclarationFor<\"recordedEdges\">;\n\nexport const SYSTEM_INDEX_DECLARATIONS: readonly SystemIndexDeclaration[] = [\n // ---------------------------------------------------------- nodes\n { table: \"nodes\", suffix: \"kind_idx\", columns: [\"graph_id\", \"kind\"] },\n // Listing shape: kind partition ordered by creation with the\n // soft-delete column ahead of it so `deleted_at IS NULL` list queries\n // stay index-served.\n {\n table: \"nodes\",\n suffix: \"kind_created_idx\",\n columns: [\"graph_id\", \"kind\", \"deleted_at\", \"created_at\"],\n },\n {\n table: \"nodes\",\n suffix: \"deleted_idx\",\n columns: [\"graph_id\", \"deleted_at\"],\n },\n {\n table: \"nodes\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n // Bare-id lookup: the primary key leads with `kind` (graph_id, kind,\n // id), so a `WHERE graph_id = ? AND id = ?` probe that doesn't know the\n // kind can't seek it — SQLite falls back to a graph_id-only scan of\n // every node in the graph (~3M at LDBC SF1).\n // `store.algorithms.degree`'s node-kind subquery does exactly that\n // lookup (it resolves the seed's kind by id), so without this index\n // degree is a full nodes scan (~95ms at SF1). See typegraph#280.\n { table: \"nodes\", suffix: \"id_idx\", columns: [\"graph_id\", \"id\"] },\n\n // ---------------------------------------------------------- edges\n { table: \"edges\", suffix: \"kind_idx\", columns: [\"graph_id\", \"kind\"] },\n // Directional traversal index (outgoing): supports endpoint lookups\n // and extra filtering by edge kind / target kind. Includes every\n // system column the compiled query's soft-delete/temporal-validity\n // predicate touches (deleted_at, valid_from, valid_to), trailed by\n // to_id — the compiled traversal join reads `n.id = e.to_id` for an\n // outgoing traversal (standard-builders.ts), so without to_id here\n // the join still fetches the edge's heap row for that one column\n // even with the seek/predicate columns covered.\n {\n table: \"edges\",\n suffix: \"from_idx\",\n columns: [\n \"graph_id\",\n \"from_kind\",\n \"from_id\",\n \"kind\",\n \"to_kind\",\n \"deleted_at\",\n \"valid_from\",\n \"valid_to\",\n \"to_id\",\n ],\n },\n // Directional traversal index (incoming): mirrors from_idx for\n // reverse traversals, trailed by from_id for the same reason\n // (`n.id = e.from_id` for an incoming traversal).\n {\n table: \"edges\",\n suffix: \"to_idx\",\n columns: [\n \"graph_id\",\n \"to_kind\",\n \"to_id\",\n \"kind\",\n \"from_kind\",\n \"deleted_at\",\n \"valid_from\",\n \"valid_to\",\n \"from_id\",\n ],\n },\n {\n table: \"edges\",\n suffix: \"kind_created_idx\",\n columns: [\"graph_id\", \"kind\", \"deleted_at\", \"created_at\"],\n },\n {\n table: \"edges\",\n suffix: \"deleted_idx\",\n columns: [\"graph_id\", \"deleted_at\"],\n },\n {\n table: \"edges\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n // Cardinality enforcement: the one-per-endpoint check probes for a\n // currently-valid edge of a kind from a specific endpoint.\n {\n table: \"edges\",\n suffix: \"cardinality_idx\",\n columns: [\"graph_id\", \"kind\", \"from_kind\", \"from_id\", \"valid_to\"],\n },\n\n // ---------------------------------------------------------- recordedNodes\n {\n table: \"recordedNodes\",\n suffix: \"entity_idx\",\n columns: [\"graph_id\", \"kind\", \"id\", \"recorded_from\", \"recorded_to\"],\n },\n {\n table: \"recordedNodes\",\n suffix: \"open_idx\",\n columns: [\"graph_id\", \"recorded_to\"],\n },\n {\n table: \"recordedNodes\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n // Bare-id lookup parity with the live nodes table: recorded-pinned\n // reads swap this relation in as the node source, and `entity_idx`\n // leads with `kind`, so the same kind-by-bare-id probe (e.g.\n // `degree()` at a recorded coordinate) would otherwise scan every\n // historical version in the graph. See typegraph#280.\n { table: \"recordedNodes\", suffix: \"id_idx\", columns: [\"graph_id\", \"id\"] },\n\n // ---------------------------------------------------------- recordedEdges\n {\n table: \"recordedEdges\",\n suffix: \"entity_idx\",\n columns: [\"graph_id\", \"kind\", \"id\", \"recorded_from\", \"recorded_to\"],\n },\n {\n table: \"recordedEdges\",\n suffix: \"open_idx\",\n columns: [\"graph_id\", \"recorded_to\"],\n },\n {\n table: \"recordedEdges\",\n suffix: \"from_idx\",\n columns: [\n \"graph_id\",\n \"from_kind\",\n \"from_id\",\n \"kind\",\n \"to_kind\",\n \"recorded_from\",\n \"recorded_to\",\n ],\n },\n {\n table: \"recordedEdges\",\n suffix: \"to_idx\",\n columns: [\n \"graph_id\",\n \"to_kind\",\n \"to_id\",\n \"kind\",\n \"from_kind\",\n \"recorded_from\",\n \"recorded_to\",\n ],\n },\n {\n table: \"recordedEdges\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n];\n\n/** Default physical table names for the system-index relations. */\nconst DEFAULT_SYSTEM_INDEX_TABLE_NAMES: Readonly<\n Record<SystemIndexTable, string>\n> = {\n nodes: \"typegraph_nodes\",\n edges: \"typegraph_edges\",\n recordedNodes: \"typegraph_recorded_nodes\",\n recordedEdges: \"typegraph_recorded_edges\",\n};\n\n/**\n * Resolves the physical table name for a system-index relation, honoring\n * a backend's table-name overrides.\n */\nexport function resolveSystemIndexTableName(\n table: SystemIndexTable,\n overrides:\n Readonly<Partial<Record<SystemIndexTable, string | undefined>>> | undefined,\n): string {\n return overrides?.[table] ?? DEFAULT_SYSTEM_INDEX_TABLE_NAMES[table];\n}\n\n/**\n * PostgreSQL truncates identifiers to NAMEDATALEN-1 = 63 bytes SILENTLY —\n * two suffixes of one long custom table name would collide after\n * truncation, and the catalog probes (which compare by exact name) would\n * never match the stored name, re-attempting the build on every boot.\n * SQLite has no such limit but uses the same bound so the two dialects'\n * index sets stay in byte-for-byte parity. (Char-based like the vector\n * identifier bound — multibyte table names are out of scope.)\n */\nconst MAX_SQL_IDENTIFIER_LENGTH = 63;\n\n/**\n * Physical index name: `${physicalTableName}_${suffix}`, deterministically\n * truncated + hash-suffixed past the 63-char identifier bound so distinct\n * indexes stay distinct. Single choke point — the Drizzle builders, the\n * runtime DDL, the catalog probes, and the status keys all derive the\n * name here, so they can never disagree.\n */\nexport function systemIndexName(\n physicalTableName: string,\n suffix: string,\n): string {\n const full = `${physicalTableName}_${suffix}`;\n if (full.length <= MAX_SQL_IDENTIFIER_LENGTH) return full;\n const hash = shortHash(JSON.stringify([physicalTableName, suffix]));\n return `${full.slice(0, MAX_SQL_IDENTIFIER_LENGTH - 1 - hash.length)}_${hash}`;\n}\n\n/**\n * Every system index name for a deployment's (possibly overridden) table\n * names. Graph-declared index names must not collide with these: a\n * colliding `CREATE INDEX IF NOT EXISTS` would silently no-op against the\n * system index (wrong shape) while recording a false success — see the\n * guards in the schema factories and `materializeIndexes`.\n */\nexport function resolveSystemIndexNames(\n overrides:\n Readonly<Partial<Record<SystemIndexTable, string | undefined>>> | undefined,\n): ReadonlySet<string> {\n return new Set(\n SYSTEM_INDEX_DECLARATIONS.map((declaration) =>\n systemIndexName(\n resolveSystemIndexTableName(declaration.table, overrides),\n declaration.suffix,\n ),\n ),\n );\n}\n\n/**\n * Rejects graph-declared indexes whose names collide with this\n * deployment's system index names. Called by both dialect schema\n * factories so a colliding declaration fails at table-definition time\n * instead of silently no-opping against the (differently shaped) system\n * index at CREATE INDEX IF NOT EXISTS time. `materializeIndexes` applies\n * the same check per-declaration on its runtime path.\n */\nexport function assertNoSystemIndexNameCollision(\n indexes: readonly Readonly<{ name: string }>[],\n overrides:\n Readonly<Partial<Record<SystemIndexTable, string | undefined>>> | undefined,\n): void {\n if (indexes.length === 0) return;\n const reserved = resolveSystemIndexNames(overrides);\n for (const index of indexes) {\n if (reserved.has(index.name)) {\n throw new Error(\n `Index name \"${index.name}\" collides with a TypeGraph system ` +\n `index. Choose a different name — system index names are ` +\n `reserved, and a same-named CREATE INDEX IF NOT EXISTS would ` +\n `silently no-op against the system index instead of creating ` +\n `the declared one.`,\n );\n }\n }\n}\n\n/**\n * Runtime DDL for one system index — byte-compatible with the index the\n * bootstrap path creates from the Drizzle schema (same name, same\n * columns), plus `CONCURRENTLY` where the dialect supports building\n * without blocking writes.\n */\nexport function generateSystemIndexDDL(\n declaration: SystemIndexDeclaration,\n physicalTableName: string,\n options: Readonly<{ concurrent: boolean }>,\n): string {\n const name = quoteIdentifier(\n systemIndexName(physicalTableName, declaration.suffix),\n );\n const table = quoteIdentifier(physicalTableName);\n const columns = declaration.columns\n .map((column) => quoteIdentifier(column))\n .join(\", \");\n const concurrently = options.concurrent ? \"CONCURRENTLY \" : \"\";\n return `CREATE INDEX ${concurrently}IF NOT EXISTS ${name} ON ${table} (${columns});`;\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkXDMPDUKL_cjs = require('./chunk-XDMPDUKL.cjs');
|
|
4
|
+
|
|
5
|
+
// src/graph-extension/define-graph-extension.ts
|
|
6
|
+
function defineGraphExtension(input) {
|
|
7
|
+
return chunkXDMPDUKL_cjs.unwrap(chunkXDMPDUKL_cjs.validateGraphExtension(input, { strict: true }));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
exports.defineGraphExtension = defineGraphExtension;
|
|
11
|
+
//# sourceMappingURL=chunk-U3YRCZ5L.cjs.map
|
|
12
|
+
//# sourceMappingURL=chunk-U3YRCZ5L.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graph-extension/define-graph-extension.ts"],"names":["unwrap","validateGraphExtension"],"mappings":";;;;;AAyDO,SAAS,qBAAqB,KAAA,EAAuC;AAC1E,EAAA,OAAOA,yBAAOC,wCAAA,CAAuB,KAAA,EAAO,EAAE,MAAA,EAAQ,IAAA,EAAM,CAAC,CAAA;AAC/D","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/graph-extension/define-graph-extension.ts"],"names":["unwrap","validateGraphExtension"],"mappings":";;;;;AAyDO,SAAS,qBAAqB,KAAA,EAAuC;AAC1E,EAAA,OAAOA,yBAAOC,wCAAA,CAAuB,KAAA,EAAO,EAAE,MAAA,EAAQ,IAAA,EAAM,CAAC,CAAA;AAC/D","file":"chunk-U3YRCZ5L.cjs","sourcesContent":["/**\n * Public entry for declaring a graph extension.\n *\n * Pure value: validates the input, deeply freezes the result, and returns\n * a `GraphExtension`. Invalid documents throw\n * `GraphExtensionValidationError` carrying every issue with a\n * JSON-pointer `path` to the offending field.\n */\nimport { unwrap } from \"../utils/result\";\nimport { type GraphExtension } from \"./extension-types\";\nimport { validateGraphExtension } from \"./validation\";\n\n/**\n * Validates and freezes a graph-extension document.\n *\n * Authoring entry point — runs validation in **strict** mode: unknown\n * top-level keys (e.g. `node` instead of `nodes`) and unsupported\n * string formats (e.g. `\"date-time\"` with a hyphen instead of\n * `\"datetime\"`) fail loudly with `UNKNOWN_DOCUMENT_KEY` /\n * `UNSUPPORTED_STRING_FORMAT`. The persistence-load path leaves both\n * checks off so a document committed by a future v1.x writer with\n * additive fields still parses on an older v1 reader. Callers\n * accepting raw JSON from an untyped source (e.g. an LLM proposal)\n * should validate first via `validateGraphExtension` and surface\n * the structured issues, then pass the validated document here.\n *\n * @param input - Document describing additional node kinds, edge\n * kinds, and ontology relations. Must satisfy the v1 property-type\n * subset documented in `ExtensionPropertyType`.\n *\n * @returns The same document, deeply frozen and shape-checked.\n *\n * @throws {GraphExtensionValidationError} when the document violates\n * the v1 property-type subset, references undeclared kinds, contains\n * ontology cycles, etc. The thrown error's `details.issues` array\n * carries every failure with a JSON-pointer path.\n * @throws {GraphExtensionVersionUnsupportedError} when the document\n * declares a future major version this library cannot safely decode.\n *\n * @example\n * ```typescript\n * const extension = defineGraphExtension({\n * nodes: {\n * Paper: {\n * properties: {\n * doi: { type: \"string\" },\n * title: { type: \"string\", searchable: { language: \"english\" } },\n * },\n * unique: [{ name: \"paper_doi\", fields: [\"doi\"] }],\n * },\n * },\n * });\n *\n * const evolved = await store.evolve(extension);\n * const papers = evolved.getNodeCollectionOrThrow(\"Paper\");\n * ```\n */\nexport function defineGraphExtension(input: GraphExtension): GraphExtension {\n return unwrap(validateGraphExtension(input, { strict: true }));\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SYSTEM_INDEX_DECLARATIONS, systemIndexName } from './chunk-
|
|
2
|
-
import { compileNodeIndexKeys, compileIndexWhere, compileEdgeIndexKeys } from './chunk-
|
|
3
|
-
import { isSqlFragment, renderSql, throwUnsupportedSqlChunk, bindSqlValue, sql as sql$1 } from './chunk-
|
|
1
|
+
import { SYSTEM_INDEX_DECLARATIONS, systemIndexName } from './chunk-4XRP2N6B.js';
|
|
2
|
+
import { compileNodeIndexKeys, compileIndexWhere, compileEdgeIndexKeys } from './chunk-42XYPKZU.js';
|
|
3
|
+
import { isSqlFragment, renderSql, throwUnsupportedSqlChunk, bindSqlValue, sql as sql$1 } from './chunk-M4GYQF2H.js';
|
|
4
4
|
import { uniqueIndex, index } from 'drizzle-orm/pg-core';
|
|
5
5
|
import { uniqueIndex as uniqueIndex$1, index as index$1 } from 'drizzle-orm/sqlite-core';
|
|
6
6
|
import { sql } from 'drizzle-orm';
|
|
@@ -379,5 +379,5 @@ function assertNonEmpty(values, label) {
|
|
|
379
379
|
}
|
|
380
380
|
|
|
381
381
|
export { buildPostgresEdgeIndexBuilders, buildPostgresNodeIndexBuilders, buildPostgresSystemIndexBuilders, buildSqliteEdgeIndexBuilders, buildSqliteNodeIndexBuilders, buildSqliteSystemIndexBuilders, compileQueryWithDialect, toDrizzleSql };
|
|
382
|
-
//# sourceMappingURL=chunk-
|
|
383
|
-
//# sourceMappingURL=chunk-
|
|
382
|
+
//# sourceMappingURL=chunk-UJRWOV5B.js.map
|
|
383
|
+
//# sourceMappingURL=chunk-UJRWOV5B.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/backend/drizzle/execution/types.ts","../src/indexes/drizzle.ts"],"names":["drizzleSql","index","sql","pgUniqueIndex","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mBAAmB,WAAA,CAAY,MAAM,CAAC,CAAA,CAAE,EAAA;AAAA,MACnE,GAAG,yBAAA,CAA0B,WAAA,EAAa,OAAO;AAAA;AACnD,GACF;AACF;AAEO,SAAS,8BAAA,CACd,QAAA,EACA,iBAAA,EACA,OAAA,EAC+B;AAC/B,EAAA,OAAO,wBAAA;AAAA,IACL,QAAA;AAAA,IACA,iBAAA;AAAA,IACA,OAAA;AAAA,IACA,CAAC,IAAA,KAASA,OAAA,CAAY,IAAI;AAAA,GAC5B;AACF;AAEO,SAAS,gCAAA,CACd,QAAA,EACA,iBAAA,EACA,OAAA,EAC2B;AAC3B,EAAA,OAAO,wBAAA;AAAA,IACL,QAAA;AAAA,IACA,iBAAA;AAAA,IACA,OAAA;AAAA,IACA,CAAC,IAAA,KAASF,KAAA,CAAQ,IAAI;AAAA,GACxB;AACF;AAqCA,SAAS,cAAA,CACP,QACA,KAAA,EACwC;AACxC,EAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACvB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kCAAA,EAAqC,KAAK,CAAA,CAAA,CAAG,CAAA;AAAA,EAC/D;AACF","file":"chunk-ZVME6OSV.js","sourcesContent":["import { type SQL as DrizzleSql, sql as drizzleSql } from \"drizzle-orm\";\n\nimport { bindSqlValue } from \"../../../query/dialect/profile\";\nimport { type SqlDialect } from \"../../../query/dialect/types\";\nimport {\n isSqlFragment,\n renderSql,\n type SqlFragment,\n throwUnsupportedSqlChunk,\n} from \"../../../query/sql-fragment\";\n\nexport type ExecutableSql = DrizzleSql | SqlFragment;\n\nexport type CompiledSqlQuery = Readonly<{\n params: readonly unknown[];\n sql: string;\n}>;\n\nexport type PreparedSqlStatement = Readonly<{\n execute: <TRow>(params: readonly unknown[]) => Promise<readonly TRow[]>;\n}>;\n\nexport type SqlExecutionAdapter = Readonly<{\n compile: (query: ExecutableSql) => CompiledSqlQuery;\n execute: <TRow>(query: ExecutableSql) => Promise<readonly TRow[]>;\n executeCompiled?: <TRow>(\n compiledQuery: CompiledSqlQuery,\n ) => Promise<readonly TRow[]>;\n prepare?: (sqlText: string) => PreparedSqlStatement;\n /**\n * Runs `critical` with exclusive use of the connection: no statement from\n * anywhere else can interleave with the ones it issues.\n *\n * Statement-at-a-time serialization is not enough for a *sequence* that must\n * be atomic. `SET LOCAL` around a query is the motivating case — snapshot,\n * set, select, restore. Two searches whose statements merely take turns can\n * still interleave as `A snapshot → B snapshot → A set → B set → A select`,\n * and `A` then runs under `B`'s settings.\n *\n * `critical` is handed the unqueued adapter, so it must not attempt to\n * re-enter the queue. Present only on transaction-scoped (serialized)\n * adapters; a pooled adapter needs no exclusion because every statement gets\n * its own connection.\n */\n runExclusive?: <T>(\n critical: (connection: SqlExecutionAdapter) => Promise<T>,\n ) => Promise<T>;\n}>;\n\ntype SqlCompiler = Readonly<{\n sqlToQuery: (query: DrizzleSql) => CompiledSqlQuery;\n}>;\n\ntype DatabaseWithCompiler = Readonly<{\n dialect?: SqlCompiler;\n}>;\n\ntype BackendName = \"PostgreSQL\" | \"SQLite\";\n\nconst DIALECT_BY_BACKEND_NAME = {\n PostgreSQL: \"postgres\",\n SQLite: \"sqlite\",\n} as const satisfies Record<BackendName, SqlDialect>;\n\nexport function compileQueryWithDialect(\n db: unknown,\n query: ExecutableSql,\n backendName: BackendName,\n): CompiledSqlQuery {\n if (isSqlFragment(query)) {\n return renderSql(query, DIALECT_BY_BACKEND_NAME[backendName]);\n }\n const databaseWithCompiler = db as DatabaseWithCompiler;\n const compiler = databaseWithCompiler.dialect;\n if (compiler === undefined) {\n throw new Error(`${backendName} backend is missing a SQL compiler`);\n }\n return compiler.sqlToQuery(query);\n}\n\n/**\n * Translates TypeGraph's fragment IR into Drizzle's adapter-native SQL object.\n *\n * Most execution paths render directly to text and parameters. Async SQLite\n * drivers expose only Drizzle's execution method, so that adapter needs this\n * lossless bridge at its final boundary.\n */\nexport function toDrizzleSql(\n fragment: SqlFragment,\n dialect: SqlDialect,\n): DrizzleSql {\n const chunks = fragment.chunks.map((chunk) => {\n switch (chunk.kind) {\n case \"text\": {\n return drizzleSql.raw(chunk.value);\n }\n case \"identifier\": {\n // Drizzle's schema builders treat Name chunks as bare index-column\n // references and omit dialect quoting. Preserve the portable IR's\n // identifier semantics by handing the adapter an already-quoted,\n // trusted SQL token instead.\n return drizzleSql.raw(`\"${chunk.value.replaceAll('\"', '\"\"')}\"`);\n }\n case \"parameter\": {\n return drizzleSql.param(bindSqlValue(chunk.value, dialect));\n }\n case \"placeholder\": {\n return drizzleSql.placeholder(chunk.value.name);\n }\n default: {\n return throwUnsupportedSqlChunk(chunk);\n }\n }\n });\n return drizzleSql.join(chunks);\n}\n","import { type SQLWrapper } from \"drizzle-orm\";\nimport {\n index as pgIndex,\n type IndexBuilder as PgIndexBuilder,\n type PgColumn,\n uniqueIndex as pgUniqueIndex,\n} from \"drizzle-orm/pg-core\";\nimport {\n index as sqliteIndex,\n type IndexBuilder as SqliteIndexBuilder,\n type SQLiteColumn,\n uniqueIndex as sqliteUniqueIndex,\n} from \"drizzle-orm/sqlite-core\";\n\nimport { toDrizzleSql } from \"../backend/drizzle/execution/types\";\nimport { sql as portableSql, type SqlFragment } from \"../query/sql-fragment\";\nimport {\n compileEdgeIndexKeys,\n compileIndexWhere,\n compileNodeIndexKeys,\n type IndexCompilationContext,\n} from \"./compiler\";\nimport {\n SYSTEM_INDEX_DECLARATIONS,\n type SystemIndexDeclaration,\n systemIndexName,\n type SystemIndexTable,\n} from \"./system\";\nimport {\n type EdgeIndexDeclaration,\n type IndexDeclaration,\n type NodeIndexDeclaration,\n type SystemColumnName,\n} from \"./types\";\n\n// ============================================================\n// PostgreSQL (Drizzle Schema)\n// ============================================================\n\nexport function buildPostgresNodeIndexBuilders(\n table: NodeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly PgIndexBuilder[] {\n // GIN-family declarations (method: \"gin\" / \"trigram\") are\n // materialize-only — like pgvector ANN indexes, they are a pure\n // materialization concern and never ride the Drizzle table extras.\n const nodeIndexes = indexes.filter(\n (index): index is NodeIndexDeclaration =>\n index.entity === \"node\" && index.method === undefined,\n );\n\n return nodeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getPostgresNodeSystemColumn(table, column).name);\n\n const { keys } = compileNodeIndexKeys(\n index,\n \"postgres\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `node index \"${index.name}\"`);\n\n const base = index.unique ? pgUniqueIndex(index.name) : pgIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"postgres\"));\n assertNonEmpty(drizzleKeys, `node index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"postgres\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"postgres\"),\n );\n }\n\n return builder;\n });\n}\n\nexport function buildPostgresEdgeIndexBuilders(\n table: EdgeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly PgIndexBuilder[] {\n const edgeIndexes = indexes.filter(\n (index): index is EdgeIndexDeclaration =>\n index.entity === \"edge\" && index.method === undefined,\n );\n\n return edgeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getPostgresEdgeSystemColumn(table, column).name);\n\n const { keys } = compileEdgeIndexKeys(\n index,\n \"postgres\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `edge index \"${index.name}\"`);\n\n const base = index.unique ? pgUniqueIndex(index.name) : pgIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"postgres\"));\n assertNonEmpty(drizzleKeys, `edge index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"postgres\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"postgres\"),\n );\n }\n\n return builder;\n });\n}\n\nfunction getPostgresNodeSystemColumn(\n table: NodeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\":\n case \"from_id\":\n case \"to_kind\":\n case \"to_id\": {\n throw new Error(`Unsupported node system column for indexes: ${column}`);\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n return table.version;\n }\n }\n}\n\nfunction getPostgresEdgeSystemColumn(\n table: EdgeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\": {\n return table.fromKind;\n }\n case \"from_id\": {\n return table.fromId;\n }\n case \"to_kind\": {\n return table.toKind;\n }\n case \"to_id\": {\n return table.toId;\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n throw new Error(`Unsupported edge system column for indexes: ${column}`);\n }\n }\n}\n\n// ============================================================\n// SQLite (Drizzle Schema)\n// ============================================================\n\nexport function buildSqliteNodeIndexBuilders(\n table: NodeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly SqliteIndexBuilder[] {\n // GIN-family declarations (method: \"gin\" / \"trigram\") are\n // materialize-only — like pgvector ANN indexes, they are a pure\n // materialization concern and never ride the Drizzle table extras.\n const nodeIndexes = indexes.filter(\n (index): index is NodeIndexDeclaration =>\n index.entity === \"node\" && index.method === undefined,\n );\n\n return nodeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getSqliteNodeSystemColumn(table, column).name);\n\n const { keys } = compileNodeIndexKeys(\n index,\n \"sqlite\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `node index \"${index.name}\"`);\n\n const base =\n index.unique ? sqliteUniqueIndex(index.name) : sqliteIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"sqlite\"));\n assertNonEmpty(drizzleKeys, `node index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"sqlite\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"sqlite\"),\n );\n }\n\n return builder;\n });\n}\n\nexport function buildSqliteEdgeIndexBuilders(\n table: EdgeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly SqliteIndexBuilder[] {\n const edgeIndexes = indexes.filter(\n (index): index is EdgeIndexDeclaration =>\n index.entity === \"edge\" && index.method === undefined,\n );\n\n return edgeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getSqliteEdgeSystemColumn(table, column).name);\n\n const { keys } = compileEdgeIndexKeys(\n index,\n \"sqlite\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `edge index \"${index.name}\"`);\n\n const base =\n index.unique ? sqliteUniqueIndex(index.name) : sqliteIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"sqlite\"));\n assertNonEmpty(drizzleKeys, `edge index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"sqlite\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"sqlite\"),\n );\n }\n\n return builder;\n });\n}\n\nfunction getSqliteNodeSystemColumn(\n table: NodeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\":\n case \"from_id\":\n case \"to_kind\":\n case \"to_id\": {\n throw new Error(`Unsupported node system column for indexes: ${column}`);\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n return table.version;\n }\n }\n}\n\nfunction getSqliteEdgeSystemColumn(\n table: EdgeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\": {\n return table.fromKind;\n }\n case \"from_id\": {\n return table.fromId;\n }\n case \"to_kind\": {\n return table.toKind;\n }\n case \"to_id\": {\n return table.toId;\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n throw new Error(`Unsupported edge system column for indexes: ${column}`);\n }\n }\n}\n\n// ============================================================\n// System indexes (both dialects)\n// ============================================================\n//\n// The schema factories derive their system-index Drizzle builders from\n// `SYSTEM_INDEX_DECLARATIONS` so both dialects emit the same index set by\n// construction. The builders receive the table's real column objects (not\n// SQL wrappers) so the DDL generator renders plain quoted column names —\n// byte-identical to the runtime DDL `materializeSystemIndexes` emits.\n\ntype SystemIndexColumns<C extends { name: string }> = Readonly<\n Record<string, C>\n>;\n\n/**\n * Resolves a declaration's physical column names against the table's own\n * column objects by each column's `.name` — the SQL name Drizzle carries on\n * the column itself — so no naming convention sits between the declaration\n * and the schema. A column the table doesn't define throws at\n * table-construction time (exercised by the system-index parity tests).\n */\nfunction resolveSystemIndexColumns<C extends { name: string }>(\n declaration: SystemIndexDeclaration,\n columns: SystemIndexColumns<C>,\n): readonly [C, ...C[]] {\n const byPhysicalName = new Map(\n Object.values(columns).map((column) => [column.name, column]),\n );\n const resolved = declaration.columns.map((column) => {\n const value = byPhysicalName.get(column);\n if (value === undefined) {\n throw new Error(\n `System index \"${declaration.table}_${declaration.suffix}\" references ` +\n `a column \"${column}\" the ${declaration.table} table does not define`,\n );\n }\n return value;\n });\n // `declaration.columns` is non-empty by type, so `resolved` is too.\n return resolved as [C, ...C[]];\n}\n\n/**\n * The two dialect variants do no dialect-specific work (no unique, no\n * where, no expression compilation — unlike the node/edge builder pairs\n * above), so they share one body parameterized by the dialect's index\n * factory.\n */\nfunction buildSystemIndexBuilders<C extends { name: string }, B>(\n tableKey: SystemIndexTable,\n physicalTableName: string,\n columns: SystemIndexColumns<C>,\n indexFactory: (name: string) => { on: (...cols: [C, ...C[]]) => B },\n): readonly B[] {\n return SYSTEM_INDEX_DECLARATIONS.filter(\n (declaration) => declaration.table === tableKey,\n ).map((declaration) =>\n indexFactory(systemIndexName(physicalTableName, declaration.suffix)).on(\n ...resolveSystemIndexColumns(declaration, columns),\n ),\n );\n}\n\nexport function buildSqliteSystemIndexBuilders(\n tableKey: SystemIndexTable,\n physicalTableName: string,\n columns: SystemIndexColumns<SQLiteColumn>,\n): readonly SqliteIndexBuilder[] {\n return buildSystemIndexBuilders(\n tableKey,\n physicalTableName,\n columns,\n (name) => sqliteIndex(name),\n );\n}\n\nexport function buildPostgresSystemIndexBuilders(\n tableKey: SystemIndexTable,\n physicalTableName: string,\n columns: SystemIndexColumns<PgColumn>,\n): readonly PgIndexBuilder[] {\n return buildSystemIndexBuilders(\n tableKey,\n physicalTableName,\n columns,\n (name) => pgIndex(name),\n );\n}\n\n// ============================================================\n// Minimal table shapes (shared between dialect schemas)\n// ============================================================\n\ntype NamedSqlWrapper = SQLWrapper & Readonly<{ name: string }>;\n\ntype NodeIndexTable = Readonly<{\n graphId: NamedSqlWrapper;\n kind: NamedSqlWrapper;\n id: NamedSqlWrapper;\n props: NamedSqlWrapper;\n version: NamedSqlWrapper;\n validFrom: NamedSqlWrapper;\n validTo: NamedSqlWrapper;\n createdAt: NamedSqlWrapper;\n updatedAt: NamedSqlWrapper;\n deletedAt: NamedSqlWrapper;\n}>;\n\ntype EdgeIndexTable = Readonly<{\n graphId: NamedSqlWrapper;\n id: NamedSqlWrapper;\n kind: NamedSqlWrapper;\n fromKind: NamedSqlWrapper;\n fromId: NamedSqlWrapper;\n toKind: NamedSqlWrapper;\n toId: NamedSqlWrapper;\n props: NamedSqlWrapper;\n validFrom: NamedSqlWrapper;\n validTo: NamedSqlWrapper;\n createdAt: NamedSqlWrapper;\n updatedAt: NamedSqlWrapper;\n deletedAt: NamedSqlWrapper;\n}>;\n\nfunction assertNonEmpty<T>(\n values: readonly T[],\n label: string,\n): asserts values is readonly [T, ...T[]] {\n if (values.length === 0) {\n throw new Error(`Index must have at least one key (${label})`);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/backend/drizzle/execution/types.ts","../src/indexes/drizzle.ts"],"names":["drizzleSql","index","sql","pgUniqueIndex","pgIndex","sqliteUniqueIndex","sqliteIndex"],"mappings":";;;;;;;AA2DA,IAAM,uBAAA,GAA0B;AAAA,EAC9B,UAAA,EAAY,UAAA;AAAA,EACZ,MAAA,EAAQ;AACV,CAAA;AAEO,SAAS,uBAAA,CAC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,EACA,OAAA,EAC+B;AAC/B,EAAA,OAAO,wBAAA;AAAA,IACL,QAAA;AAAA,IACA,iBAAA;AAAA,IACA,OAAA;AAAA,IACA,CAAC,IAAA,KAASA,OAAA,CAAY,IAAI;AAAA,GAC5B;AACF;AAEO,SAAS,gCAAA,CACd,QAAA,EACA,iBAAA,EACA,OAAA,EAC2B;AAC3B,EAAA,OAAO,wBAAA;AAAA,IACL,QAAA;AAAA,IACA,iBAAA;AAAA,IACA,OAAA;AAAA,IACA,CAAC,IAAA,KAASF,KAAA,CAAQ,IAAI;AAAA,GACxB;AACF;AAqCA,SAAS,cAAA,CACP,QACA,KAAA,EACwC;AACxC,EAAA,IAAI,MAAA,CAAO,WAAW,CAAA,EAAG;AACvB,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,kCAAA,EAAqC,KAAK,CAAA,CAAA,CAAG,CAAA;AAAA,EAC/D;AACF","file":"chunk-UJRWOV5B.js","sourcesContent":["import { type SQL as DrizzleSql, sql as drizzleSql } from \"drizzle-orm\";\n\nimport { bindSqlValue } from \"../../../query/dialect/profile\";\nimport { type SqlDialect } from \"../../../query/dialect/types\";\nimport {\n isSqlFragment,\n renderSql,\n type SqlFragment,\n throwUnsupportedSqlChunk,\n} from \"../../../query/sql-fragment\";\n\nexport type ExecutableSql = DrizzleSql | SqlFragment;\n\nexport type CompiledSqlQuery = Readonly<{\n params: readonly unknown[];\n sql: string;\n}>;\n\nexport type PreparedSqlStatement = Readonly<{\n execute: <TRow>(params: readonly unknown[]) => Promise<readonly TRow[]>;\n}>;\n\nexport type SqlExecutionAdapter = Readonly<{\n compile: (query: ExecutableSql) => CompiledSqlQuery;\n execute: <TRow>(query: ExecutableSql) => Promise<readonly TRow[]>;\n executeCompiled?: <TRow>(\n compiledQuery: CompiledSqlQuery,\n ) => Promise<readonly TRow[]>;\n prepare?: (sqlText: string) => PreparedSqlStatement;\n /**\n * Runs `critical` with exclusive use of the connection: no statement from\n * anywhere else can interleave with the ones it issues.\n *\n * Statement-at-a-time serialization is not enough for a *sequence* that must\n * be atomic. `SET LOCAL` around a query is the motivating case — snapshot,\n * set, select, restore. Two searches whose statements merely take turns can\n * still interleave as `A snapshot → B snapshot → A set → B set → A select`,\n * and `A` then runs under `B`'s settings.\n *\n * `critical` is handed the unqueued adapter, so it must not attempt to\n * re-enter the queue. Present only on transaction-scoped (serialized)\n * adapters; a pooled adapter needs no exclusion because every statement gets\n * its own connection.\n */\n runExclusive?: <T>(\n critical: (connection: SqlExecutionAdapter) => Promise<T>,\n ) => Promise<T>;\n}>;\n\ntype SqlCompiler = Readonly<{\n sqlToQuery: (query: DrizzleSql) => CompiledSqlQuery;\n}>;\n\ntype DatabaseWithCompiler = Readonly<{\n dialect?: SqlCompiler;\n}>;\n\ntype BackendName = \"PostgreSQL\" | \"SQLite\";\n\nconst DIALECT_BY_BACKEND_NAME = {\n PostgreSQL: \"postgres\",\n SQLite: \"sqlite\",\n} as const satisfies Record<BackendName, SqlDialect>;\n\nexport function compileQueryWithDialect(\n db: unknown,\n query: ExecutableSql,\n backendName: BackendName,\n): CompiledSqlQuery {\n if (isSqlFragment(query)) {\n return renderSql(query, DIALECT_BY_BACKEND_NAME[backendName]);\n }\n const databaseWithCompiler = db as DatabaseWithCompiler;\n const compiler = databaseWithCompiler.dialect;\n if (compiler === undefined) {\n throw new Error(`${backendName} backend is missing a SQL compiler`);\n }\n return compiler.sqlToQuery(query);\n}\n\n/**\n * Translates TypeGraph's fragment IR into Drizzle's adapter-native SQL object.\n *\n * Most execution paths render directly to text and parameters. Async SQLite\n * drivers expose only Drizzle's execution method, so that adapter needs this\n * lossless bridge at its final boundary.\n */\nexport function toDrizzleSql(\n fragment: SqlFragment,\n dialect: SqlDialect,\n): DrizzleSql {\n const chunks = fragment.chunks.map((chunk) => {\n switch (chunk.kind) {\n case \"text\": {\n return drizzleSql.raw(chunk.value);\n }\n case \"identifier\": {\n // Drizzle's schema builders treat Name chunks as bare index-column\n // references and omit dialect quoting. Preserve the portable IR's\n // identifier semantics by handing the adapter an already-quoted,\n // trusted SQL token instead.\n return drizzleSql.raw(`\"${chunk.value.replaceAll('\"', '\"\"')}\"`);\n }\n case \"parameter\": {\n return drizzleSql.param(bindSqlValue(chunk.value, dialect));\n }\n case \"placeholder\": {\n return drizzleSql.placeholder(chunk.value.name);\n }\n default: {\n return throwUnsupportedSqlChunk(chunk);\n }\n }\n });\n return drizzleSql.join(chunks);\n}\n","import { type SQLWrapper } from \"drizzle-orm\";\nimport {\n index as pgIndex,\n type IndexBuilder as PgIndexBuilder,\n type PgColumn,\n uniqueIndex as pgUniqueIndex,\n} from \"drizzle-orm/pg-core\";\nimport {\n index as sqliteIndex,\n type IndexBuilder as SqliteIndexBuilder,\n type SQLiteColumn,\n uniqueIndex as sqliteUniqueIndex,\n} from \"drizzle-orm/sqlite-core\";\n\nimport { toDrizzleSql } from \"../backend/drizzle/execution/types\";\nimport { sql as portableSql, type SqlFragment } from \"../query/sql-fragment\";\nimport {\n compileEdgeIndexKeys,\n compileIndexWhere,\n compileNodeIndexKeys,\n type IndexCompilationContext,\n} from \"./compiler\";\nimport {\n SYSTEM_INDEX_DECLARATIONS,\n type SystemIndexDeclaration,\n systemIndexName,\n type SystemIndexTable,\n} from \"./system\";\nimport {\n type EdgeIndexDeclaration,\n type IndexDeclaration,\n type NodeIndexDeclaration,\n type SystemColumnName,\n} from \"./types\";\n\n// ============================================================\n// PostgreSQL (Drizzle Schema)\n// ============================================================\n\nexport function buildPostgresNodeIndexBuilders(\n table: NodeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly PgIndexBuilder[] {\n // GIN-family declarations (method: \"gin\" / \"trigram\") are\n // materialize-only — like pgvector ANN indexes, they are a pure\n // materialization concern and never ride the Drizzle table extras.\n const nodeIndexes = indexes.filter(\n (index): index is NodeIndexDeclaration =>\n index.entity === \"node\" && index.method === undefined,\n );\n\n return nodeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getPostgresNodeSystemColumn(table, column).name);\n\n const { keys } = compileNodeIndexKeys(\n index,\n \"postgres\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `node index \"${index.name}\"`);\n\n const base = index.unique ? pgUniqueIndex(index.name) : pgIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"postgres\"));\n assertNonEmpty(drizzleKeys, `node index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"postgres\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"postgres\"),\n );\n }\n\n return builder;\n });\n}\n\nexport function buildPostgresEdgeIndexBuilders(\n table: EdgeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly PgIndexBuilder[] {\n const edgeIndexes = indexes.filter(\n (index): index is EdgeIndexDeclaration =>\n index.entity === \"edge\" && index.method === undefined,\n );\n\n return edgeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getPostgresEdgeSystemColumn(table, column).name);\n\n const { keys } = compileEdgeIndexKeys(\n index,\n \"postgres\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `edge index \"${index.name}\"`);\n\n const base = index.unique ? pgUniqueIndex(index.name) : pgIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"postgres\"));\n assertNonEmpty(drizzleKeys, `edge index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"postgres\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"postgres\"),\n );\n }\n\n return builder;\n });\n}\n\nfunction getPostgresNodeSystemColumn(\n table: NodeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\":\n case \"from_id\":\n case \"to_kind\":\n case \"to_id\": {\n throw new Error(`Unsupported node system column for indexes: ${column}`);\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n return table.version;\n }\n }\n}\n\nfunction getPostgresEdgeSystemColumn(\n table: EdgeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\": {\n return table.fromKind;\n }\n case \"from_id\": {\n return table.fromId;\n }\n case \"to_kind\": {\n return table.toKind;\n }\n case \"to_id\": {\n return table.toId;\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n throw new Error(`Unsupported edge system column for indexes: ${column}`);\n }\n }\n}\n\n// ============================================================\n// SQLite (Drizzle Schema)\n// ============================================================\n\nexport function buildSqliteNodeIndexBuilders(\n table: NodeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly SqliteIndexBuilder[] {\n // GIN-family declarations (method: \"gin\" / \"trigram\") are\n // materialize-only — like pgvector ANN indexes, they are a pure\n // materialization concern and never ride the Drizzle table extras.\n const nodeIndexes = indexes.filter(\n (index): index is NodeIndexDeclaration =>\n index.entity === \"node\" && index.method === undefined,\n );\n\n return nodeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getSqliteNodeSystemColumn(table, column).name);\n\n const { keys } = compileNodeIndexKeys(\n index,\n \"sqlite\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `node index \"${index.name}\"`);\n\n const base =\n index.unique ? sqliteUniqueIndex(index.name) : sqliteIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"sqlite\"));\n assertNonEmpty(drizzleKeys, `node index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"sqlite\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"sqlite\"),\n );\n }\n\n return builder;\n });\n}\n\nexport function buildSqliteEdgeIndexBuilders(\n table: EdgeIndexTable,\n indexes: readonly IndexDeclaration[],\n): readonly SqliteIndexBuilder[] {\n const edgeIndexes = indexes.filter(\n (index): index is EdgeIndexDeclaration =>\n index.entity === \"edge\" && index.method === undefined,\n );\n\n return edgeIndexes.map((index) => {\n const propsColumn = portableSql.identifier(table.props.name);\n const systemColumn = (column: SystemColumnName): SqlFragment =>\n portableSql.identifier(getSqliteEdgeSystemColumn(table, column).name);\n\n const { keys } = compileEdgeIndexKeys(\n index,\n \"sqlite\",\n propsColumn,\n systemColumn,\n );\n assertNonEmpty(keys, `edge index \"${index.name}\"`);\n\n const base =\n index.unique ? sqliteUniqueIndex(index.name) : sqliteIndex(index.name);\n\n const drizzleKeys = keys.map((key) => toDrizzleSql(key, \"sqlite\"));\n assertNonEmpty(drizzleKeys, `edge index \"${index.name}\"`);\n const [firstKey, ...remainingKeys] = drizzleKeys;\n const builder = base.on(firstKey, ...remainingKeys);\n\n if (index.where) {\n const ctx: IndexCompilationContext = {\n dialect: \"sqlite\",\n propsColumn,\n systemColumn,\n };\n builder.where(\n toDrizzleSql(compileIndexWhere(ctx, index.where), \"sqlite\"),\n );\n }\n\n return builder;\n });\n}\n\nfunction getSqliteNodeSystemColumn(\n table: NodeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\":\n case \"from_id\":\n case \"to_kind\":\n case \"to_id\": {\n throw new Error(`Unsupported node system column for indexes: ${column}`);\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n return table.version;\n }\n }\n}\n\nfunction getSqliteEdgeSystemColumn(\n table: EdgeIndexTable,\n column: SystemColumnName,\n): NamedSqlWrapper {\n switch (column) {\n case \"graph_id\": {\n return table.graphId;\n }\n case \"kind\": {\n return table.kind;\n }\n case \"id\": {\n return table.id;\n }\n case \"from_kind\": {\n return table.fromKind;\n }\n case \"from_id\": {\n return table.fromId;\n }\n case \"to_kind\": {\n return table.toKind;\n }\n case \"to_id\": {\n return table.toId;\n }\n case \"deleted_at\": {\n return table.deletedAt;\n }\n case \"valid_from\": {\n return table.validFrom;\n }\n case \"valid_to\": {\n return table.validTo;\n }\n case \"created_at\": {\n return table.createdAt;\n }\n case \"updated_at\": {\n return table.updatedAt;\n }\n case \"version\": {\n throw new Error(`Unsupported edge system column for indexes: ${column}`);\n }\n }\n}\n\n// ============================================================\n// System indexes (both dialects)\n// ============================================================\n//\n// The schema factories derive their system-index Drizzle builders from\n// `SYSTEM_INDEX_DECLARATIONS` so both dialects emit the same index set by\n// construction. The builders receive the table's real column objects (not\n// SQL wrappers) so the DDL generator renders plain quoted column names —\n// byte-identical to the runtime DDL `materializeSystemIndexes` emits.\n\ntype SystemIndexColumns<C extends { name: string }> = Readonly<\n Record<string, C>\n>;\n\n/**\n * Resolves a declaration's physical column names against the table's own\n * column objects by each column's `.name` — the SQL name Drizzle carries on\n * the column itself — so no naming convention sits between the declaration\n * and the schema. A column the table doesn't define throws at\n * table-construction time (exercised by the system-index parity tests).\n */\nfunction resolveSystemIndexColumns<C extends { name: string }>(\n declaration: SystemIndexDeclaration,\n columns: SystemIndexColumns<C>,\n): readonly [C, ...C[]] {\n const byPhysicalName = new Map(\n Object.values(columns).map((column) => [column.name, column]),\n );\n const resolved = declaration.columns.map((column) => {\n const value = byPhysicalName.get(column);\n if (value === undefined) {\n throw new Error(\n `System index \"${declaration.table}_${declaration.suffix}\" references ` +\n `a column \"${column}\" the ${declaration.table} table does not define`,\n );\n }\n return value;\n });\n // `declaration.columns` is non-empty by type, so `resolved` is too.\n return resolved as [C, ...C[]];\n}\n\n/**\n * The two dialect variants do no dialect-specific work (no unique, no\n * where, no expression compilation — unlike the node/edge builder pairs\n * above), so they share one body parameterized by the dialect's index\n * factory.\n */\nfunction buildSystemIndexBuilders<C extends { name: string }, B>(\n tableKey: SystemIndexTable,\n physicalTableName: string,\n columns: SystemIndexColumns<C>,\n indexFactory: (name: string) => { on: (...cols: [C, ...C[]]) => B },\n): readonly B[] {\n return SYSTEM_INDEX_DECLARATIONS.filter(\n (declaration) => declaration.table === tableKey,\n ).map((declaration) =>\n indexFactory(systemIndexName(physicalTableName, declaration.suffix)).on(\n ...resolveSystemIndexColumns(declaration, columns),\n ),\n );\n}\n\nexport function buildSqliteSystemIndexBuilders(\n tableKey: SystemIndexTable,\n physicalTableName: string,\n columns: SystemIndexColumns<SQLiteColumn>,\n): readonly SqliteIndexBuilder[] {\n return buildSystemIndexBuilders(\n tableKey,\n physicalTableName,\n columns,\n (name) => sqliteIndex(name),\n );\n}\n\nexport function buildPostgresSystemIndexBuilders(\n tableKey: SystemIndexTable,\n physicalTableName: string,\n columns: SystemIndexColumns<PgColumn>,\n): readonly PgIndexBuilder[] {\n return buildSystemIndexBuilders(\n tableKey,\n physicalTableName,\n columns,\n (name) => pgIndex(name),\n );\n}\n\n// ============================================================\n// Minimal table shapes (shared between dialect schemas)\n// ============================================================\n\ntype NamedSqlWrapper = SQLWrapper & Readonly<{ name: string }>;\n\ntype NodeIndexTable = Readonly<{\n graphId: NamedSqlWrapper;\n kind: NamedSqlWrapper;\n id: NamedSqlWrapper;\n props: NamedSqlWrapper;\n version: NamedSqlWrapper;\n validFrom: NamedSqlWrapper;\n validTo: NamedSqlWrapper;\n createdAt: NamedSqlWrapper;\n updatedAt: NamedSqlWrapper;\n deletedAt: NamedSqlWrapper;\n}>;\n\ntype EdgeIndexTable = Readonly<{\n graphId: NamedSqlWrapper;\n id: NamedSqlWrapper;\n kind: NamedSqlWrapper;\n fromKind: NamedSqlWrapper;\n fromId: NamedSqlWrapper;\n toKind: NamedSqlWrapper;\n toId: NamedSqlWrapper;\n props: NamedSqlWrapper;\n validFrom: NamedSqlWrapper;\n validTo: NamedSqlWrapper;\n createdAt: NamedSqlWrapper;\n updatedAt: NamedSqlWrapper;\n deletedAt: NamedSqlWrapper;\n}>;\n\nfunction assertNonEmpty<T>(\n values: readonly T[],\n label: string,\n): asserts values is readonly [T, ...T[]] {\n if (values.length === 0) {\n throw new Error(`Index must have at least one key (${label})`);\n }\n}\n"]}
|