@nicia-ai/typegraph 0.41.0 → 0.42.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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-LOKG3KQV.cjs → chunk-277UZV7X.cjs} +1113 -1089
- 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-QCKD3RCI.cjs → chunk-3RPQDGUE.cjs} +5 -5
- package/dist/{chunk-QCKD3RCI.cjs.map → chunk-3RPQDGUE.cjs.map} +1 -1
- 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-M2RPZS7J.cjs → chunk-5Q3P6OIC.cjs} +12 -12
- package/dist/{chunk-M2RPZS7J.cjs.map → chunk-5Q3P6OIC.cjs.map} +1 -1
- package/dist/{chunk-QXKVUJLI.cjs → chunk-5ZPRE4CV.cjs} +206 -166
- package/dist/chunk-5ZPRE4CV.cjs.map +1 -0
- 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-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-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-MQBF3XGY.js → chunk-DP7KC6CL.js} +47 -23
- package/dist/chunk-DP7KC6CL.js.map +1 -0
- 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-KOI7UEI5.js → chunk-LDCWO5B6.js} +3 -3
- package/dist/{chunk-KOI7UEI5.js.map → chunk-LDCWO5B6.js.map} +1 -1
- 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-6N7QBIWN.js → chunk-M4GYQF2H.js} +3 -3
- package/dist/{chunk-6N7QBIWN.js.map → chunk-M4GYQF2H.js.map} +1 -1
- package/dist/{chunk-ZE7E46IZ.js → chunk-NXIZL7ZZ.js} +6 -6
- package/dist/{chunk-ZE7E46IZ.js.map → chunk-NXIZL7ZZ.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-V3S74J44.js → chunk-RAWG2FEU.js} +134 -22
- package/dist/chunk-RAWG2FEU.js.map +1 -0
- 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-JP5EICR6.cjs → chunk-V2GZBPY2.cjs} +179 -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-EFZ4S22A.js → chunk-YPVQYM3L.js} +107 -67
- package/dist/chunk-YPVQYM3L.js.map +1 -0
- 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-BCXFRLWg.d.cts → ddl-3unqC-kg.d.cts} +3 -3
- package/dist/{ddl-ByLmGgn9.d.ts → ddl-Bc4Dl8fu.d.ts} +3 -3
- package/dist/{define-graph-BSviZubs.d.ts → define-graph-Byslw2OO.d.cts} +1 -2
- package/dist/{define-graph-XyJheaFm.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 +206 -202
- package/dist/index.d.cts +13 -15
- package/dist/index.d.ts +13 -15
- package/dist/index.js +35 -35
- 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-C7iC5bk_.d.ts → manager-Dl0-er1G.d.ts} +21 -156
- package/dist/{manager-Dm6MCYO7.d.cts → manager-U9_zopqr.d.cts} +21 -156
- package/dist/materialize-indexes-BM3u0aXE.d.ts +258 -0
- package/dist/materialize-indexes-DzMCetZe.d.cts +258 -0
- package/dist/{postgres-DZxwzCQ8.d.cts → postgres-C5-WMKFA.d.ts} +1 -1
- package/dist/{postgres-Cb6ceh4-.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 +48 -39
- package/dist/schema/index.d.cts +7 -8
- package/dist/schema/index.d.ts +7 -8
- package/dist/schema/index.js +15 -14
- package/dist/{searchable-aUaKh3_r.d.cts → searchable-B4mUXZT6.d.cts} +2 -2
- package/dist/{searchable-Cet4Oztt.d.ts → searchable-C7jmPNLT.d.ts} +2 -2
- package/dist/{sqlite-Cb3Ilj9_.d.ts → sqlite-Ch5tSYQY.d.ts} +1 -1
- package/dist/{sqlite-Dxklpizv.d.cts → sqlite-Da7jiYu9.d.cts} +1 -1
- package/dist/{store-view-PCT7vTKH.d.cts → store-view-6C2vTWqf.d.ts} +8 -7
- package/dist/{store-view-BDjGFjpN.d.ts → store-view-CNcOG8bQ.d.cts} +8 -7
- 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-CFZiEEPh.d.ts → types-D2rU5Taq.d.ts} +1 -2
- package/dist/{types-D-vOo_pM.d.ts → types-Dh-EgT-w.d.cts} +569 -2
- package/dist/{types-ho4DJJb_.d.cts → types-Dh-EgT-w.d.ts} +569 -2
- package/dist/{types-CsaG00wS.d.cts → types-G4sVM-76.d.cts} +1 -2
- package/dist/{where-DLYaXa4L.d.ts → where-B8Y21kig.d.ts} +1 -2
- package/dist/{where-udes1WRA.d.cts → where-DbZ9XDOI.d.cts} +1 -2
- package/package.json +1 -1
- package/dist/chunk-5YBDB7UG.cjs +0 -12
- package/dist/chunk-DPNA466P.js.map +0 -1
- package/dist/chunk-EFZ4S22A.js.map +0 -1
- package/dist/chunk-IMQKXL4E.cjs +0 -12
- package/dist/chunk-JP5EICR6.cjs.map +0 -1
- package/dist/chunk-LOKG3KQV.cjs.map +0 -1
- package/dist/chunk-MQBF3XGY.js.map +0 -1
- package/dist/chunk-QXKVUJLI.cjs.map +0 -1
- package/dist/chunk-SAFZ6JTI.cjs.map +0 -1
- package/dist/chunk-UDS5DZNY.cjs.map +0 -1
- package/dist/chunk-V3S74J44.js.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,4 +1,4 @@
|
|
|
1
|
-
import { sql } from './chunk-
|
|
1
|
+
import { sql } from './chunk-M4GYQF2H.js';
|
|
2
2
|
|
|
3
3
|
// src/query/dialect/vector/pagination.ts
|
|
4
4
|
function vectorPageClause(limit, offset) {
|
|
@@ -6,5 +6,5 @@ function vectorPageClause(limit, offset) {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export { vectorPageClause };
|
|
9
|
-
//# sourceMappingURL=chunk-
|
|
10
|
-
//# sourceMappingURL=chunk-
|
|
9
|
+
//# sourceMappingURL=chunk-ZOHCFYXE.js.map
|
|
10
|
+
//# sourceMappingURL=chunk-ZOHCFYXE.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/query/dialect/vector/pagination.ts"],"names":[],"mappings":";;;AAcO,SAAS,gBAAA,CAAiB,OAAe,MAAA,EAA8B;AAC5E,EAAA,OAAO,MAAA,KAAW,MAAA,IAAa,MAAA,KAAW,CAAA,GACtC,GAAA,CAAA,MAAA,EAAY,KAAK,CAAA,CAAA,GACjB,GAAA,CAAA,MAAA,EAAY,KAAK,CAAA,QAAA,EAAW,MAAM,CAAA,CAAA;AACxC","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/query/dialect/vector/pagination.ts"],"names":[],"mappings":";;;AAcO,SAAS,gBAAA,CAAiB,OAAe,MAAA,EAA8B;AAC5E,EAAA,OAAO,MAAA,KAAW,MAAA,IAAa,MAAA,KAAW,CAAA,GACtC,GAAA,CAAA,MAAA,EAAY,KAAK,CAAA,CAAA,GACjB,GAAA,CAAA,MAAA,EAAY,KAAK,CAAA,QAAA,EAAW,MAAM,CAAA,CAAA;AACxC","file":"chunk-ZOHCFYXE.js","sourcesContent":["/**\n * Shared vector-search pagination clause.\n *\n * Every vector strategy pages its ordered relevance scan the same way: emit a\n * bare `LIMIT` for the first page (`offset` unset or `0`), and `LIMIT … OFFSET`\n * only when a non-zero offset must discard the leading rows. The three engines'\n * `buildSearch` methods each repeated this ternary verbatim; it lives here once\n * so the emitted clause can never drift between dialects.\n *\n * `limit` and `offset` ride as bound parameters (never interpolated), so the\n * clause — string and bound values alike — is identical across engines.\n */\nimport { sql, type SqlFragment } from \"../../sql-fragment\";\n\nexport function vectorPageClause(limit: number, offset?: number): SqlFragment {\n return offset === undefined || offset === 0 ?\n sql`LIMIT ${limit}`\n : sql`LIMIT ${limit} OFFSET ${offset}`;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fnv1aBase36 } from './chunk-K34OPSJK.js';
|
|
2
2
|
import { MAX_PG_IDENTIFIER_LENGTH, TRUNCATED_IDENTIFIER_MAX_LENGTH, IDENTIFIER_COMPONENT_MAX_LENGTH } from './chunk-2EBMPJBO.js';
|
|
3
|
-
import { getNodeScopeColumns } from './chunk-
|
|
3
|
+
import { getNodeScopeColumns } from './chunk-42XYPKZU.js';
|
|
4
4
|
import { createSchemaIntrospector } from './chunk-D7PG5D5K.js';
|
|
5
5
|
import { resolveFieldTypeInfoAtJsonPointer } from './chunk-SNXVDZAJ.js';
|
|
6
6
|
import { jsonPointer, normalizeJsonPointer, parseJsonPointer } from './chunk-G6Q5UM7U.js';
|
|
@@ -609,5 +609,5 @@ function sanitizeIdentifierComponent(value) {
|
|
|
609
609
|
}
|
|
610
610
|
|
|
611
611
|
export { EDGE_META_KEYS, NODE_META_KEYS, defineEdgeIndex, defineNodeIndex };
|
|
612
|
-
//# sourceMappingURL=chunk-
|
|
613
|
-
//# sourceMappingURL=chunk-
|
|
612
|
+
//# sourceMappingURL=chunk-ZP2KPDNN.js.map
|
|
613
|
+
//# sourceMappingURL=chunk-ZP2KPDNN.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/system-fields.ts","../src/indexes/define-index.ts"],"names":[],"mappings":";;;;;;;;AAAO,IAAM,cAA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C,CAAA,GAClD,MAAA;AAAA,IACF,KAAA,CAAM,cAAA,CAAe,MAAA,GAAS,CAAA,GAC5B,CAAA,IAAA,EAAO,2BAAA,CAA4B,KAAA,CAAM,cAAA,CAAe,IAAA,CAAK,GAAG,CAAC,CAAC,CAAA,CAAA,GAClE,MAAA;AAAA,IACF,gBAAA,CAAiB,MAAA,GAAS,CAAA,GACxB,CAAA,IAAA,EAAO,2BAAA,CAA4B,iBAAiB,IAAA,CAAK,GAAG,CAAC,CAAC,CAAA,CAAA,GAC9D,MAAA;AAAA,IACF,KAAA,CAAM,SAAA,KAAc,MAAA,GAAS,MAAA,GAAY,KAAA,CAAM,SAAA;AAAA,IAC/C,KAAA,CAAM,SAAS,MAAA,GAAS,MAAA;AAAA,IACxB,MAAM,KAAA,KAAU,cAAA,GACd,MAAA,GACA,2BAAA,CAA4B,MAAM,KAAK,CAAA;AAAA,IACzC;AAAA,GACF,CAAE,MAAA,CAAO,CAAC,IAAA,KAAS,SAAS,MAAS,CAAA;AAErC,EAAA,MAAM,MAAA,GAAS,SAAA,CAAU,IAAA,CAAK,GAAG,CAAA;AACjC,EAAA,OAAO,MAAA,CAAO,MAAA,IAAU,wBAAA,GACpB,MAAA,GACA,CAAA,EAAG,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,+BAA+B,CAAC,CAAA,CAAA,EAAI,IAAI,CAAA,CAAA;AACjE;AAEA,SAAS,4BAA4B,KAAA,EAAuB;AAC1D,EAAA,OAAO,KAAA,CACJ,WAAA,EAAY,CACZ,UAAA,CAAW,cAAA,EAAgB,GAAG,CAAA,CAC9B,UAAA,CAAW,UAAA,EAAY,EAAE,CAAA,CACzB,KAAA,CAAM,GAAG,+BAA+B,CAAA;AAC7C","file":"chunk-VWEFXG73.js","sourcesContent":["export const NODE_META_KEYS = [\n \"version\",\n \"validFrom\",\n \"validTo\",\n \"createdAt\",\n \"updatedAt\",\n \"deletedAt\",\n] as const;\n\nexport const EDGE_META_KEYS = [\n \"validFrom\",\n \"validTo\",\n \"createdAt\",\n \"updatedAt\",\n \"deletedAt\",\n] as const;\n","import { type z } from \"zod\";\n\nimport {\n IDENTIFIER_COMPONENT_MAX_LENGTH,\n MAX_PG_IDENTIFIER_LENGTH,\n TRUNCATED_IDENTIFIER_MAX_LENGTH,\n} from \"../constants\";\nimport {\n type AnyEdgeType,\n type KindEntity,\n type NodeType,\n} from \"../core/types\";\nimport { type ValueType } from \"../query/ast\";\nimport { resolveFieldTypeInfoAtJsonPointer } from \"../query/field-type-info\";\nimport {\n type JsonPointer,\n jsonPointer,\n type JsonPointerInput,\n type JsonPointerSegment,\n normalizeJsonPointer,\n parseJsonPointer,\n} from \"../query/json-pointer\";\nimport {\n createSchemaIntrospector,\n type FieldTypeInfo,\n} from \"../query/schema-introspector\";\nimport { EDGE_META_KEYS, NODE_META_KEYS } from \"../system-fields\";\nimport { fnv1aBase36 } from \"../utils/hash\";\nimport { getNodeScopeColumns } from \"./compiler\";\nimport {\n type EdgeIndexConfig,\n type EdgeIndexDeclaration,\n type EdgeIndexDirection,\n type EdgeIndexWhereBuilder,\n type IndexFieldInput,\n type IndexScope,\n type IndexWhereExpression,\n type IndexWhereFieldBuilder,\n type IndexWhereLiteral,\n type IndexWhereOp,\n type IndexWhereOperand,\n type NodeIndexConfig,\n type NodeIndexDeclaration,\n type NodeIndexWhereBuilder,\n type RelationalIndexMethod,\n type SystemColumnName,\n} from \"./types\";\n\n// `keySystemColumns` on a node index must fail closed: reject anything that\n// isn't a known node-valid column, not just the known edge-only ones. A\n// caller whose array escapes TypeScript's literal-union checking (`any`-typed\n// data, a value round-tripped through JSON) could otherwise pass a typo'd or\n// otherwise-invalid column that silently reaches SQL DDL generation instead\n// of failing here with a clear error. Derived from the single source of\n// truth (`createSystemColumnMapForNode`, hoisted — see below) rather than a\n// second hand-maintained list, so it can't drift from it.\nconst NODE_KEY_SYSTEM_COLUMNS: ReadonlySet<SystemColumnName> = new Set(\n [...createSystemColumnMapForNode().values()].map((entry) => entry.column),\n);\n\n// ============================================================\n// Public API\n// ============================================================\n\nexport function defineNodeIndex<N extends NodeType>(\n node: N,\n config: NodeIndexConfig<N>,\n): NodeIndexDeclaration {\n const scope = config.scope ?? \"graphAndKind\";\n const unique = config.unique ?? false;\n const keySystemColumns = normalizeKeySystemColumnsOrThrow(\n config.keySystemColumns ?? [],\n scope,\n unique,\n );\n\n const schemaIntrospector = createSchemaIntrospector(\n new Map([[node.kind, { schema: node.schema }]]),\n );\n\n const { pointers: fields, valueTypes: fieldValueTypes } =\n normalizeNodeIndexFieldsOrThrow(\n node,\n config.fields ?? [],\n schemaIntrospector,\n \"fields\",\n // GIN containment indexes exist precisely for array/object fields,\n // which the btree guard otherwise rejects.\n { allowJsonFields: config.method === \"gin\" },\n );\n\n const { pointers: coveringFields, valueTypes: coveringFieldValueTypes } =\n normalizeNodeIndexFieldsOrThrow(\n node,\n config.coveringFields ?? [],\n schemaIntrospector,\n \"coveringFields\",\n {},\n );\n assertNoOverlap(fields, coveringFields, \"fields\", \"coveringFields\");\n\n if (\n fields.length === 0 &&\n coveringFields.length === 0 &&\n keySystemColumns.length === 0\n ) {\n throw new Error(\n \"Index must declare at least one of fields, coveringFields, or keySystemColumns\",\n );\n }\n\n const where = normalizeWhereInput(config.where, () =>\n createNodeWhereBuilder(node, schemaIntrospector),\n );\n\n const method = resolveAdvancedIndexMethod(config.method, {\n fieldCount: fields.length,\n fieldValueType: fieldValueTypes[0],\n coveringFieldCount: coveringFields.length,\n keySystemColumnCount: keySystemColumns.length,\n unique,\n hasWhere: where !== undefined,\n });\n\n const defaultName = generateDefaultIndexName({\n kind: \"node\",\n kindName: node.kind,\n unique,\n scope,\n direction: \"none\",\n fields,\n coveringFields,\n keySystemColumns,\n });\n const name =\n config.name ??\n (method === undefined ? defaultName : `${defaultName}_${method}`);\n\n // `origin` is intentionally omitted: `\"compile-time\"` is the default\n // and is canonicalized by absence so the serialized form stays\n // byte-identical for legacy graphs. `method` and `keySystemColumns`\n // follow the same rule (absence == \"btree\" / no system key columns).\n return {\n entity: \"node\",\n kind: node.kind,\n name,\n fields,\n fieldValueTypes,\n coveringFields,\n coveringFieldValueTypes,\n unique,\n scope,\n where,\n ...(method === undefined ? {} : { method }),\n ...(keySystemColumns.length === 0 ? {} : { keySystemColumns }),\n };\n}\n\n/**\n * Validates `keySystemColumns`: must be node system columns (not\n * edge-only `from_kind`/`from_id`/`to_kind`/`to_id`), must not repeat\n * each other, must not repeat a column `scope` already prefixes the key\n * with, and must not combine `\"id\"` with `unique` (every node's `id` is\n * already unique per row, so that combination can never enforce a\n * meaningful constraint across the index's other key columns).\n */\nfunction normalizeKeySystemColumnsOrThrow(\n columns: readonly SystemColumnName[],\n scope: IndexScope,\n unique: boolean,\n): readonly SystemColumnName[] {\n if (columns.length === 0) return [];\n\n for (const column of columns) {\n if (!NODE_KEY_SYSTEM_COLUMNS.has(column)) {\n throw new Error(\n `Node index keySystemColumns does not support \"${column}\" (edge-only system column)`,\n );\n }\n }\n assertUnique(columns, \"keySystemColumns\");\n\n const scopeColumns = new Set(getNodeScopeColumns(scope));\n for (const column of columns) {\n if (scopeColumns.has(column)) {\n throw new Error(\n `Node index keySystemColumns must not repeat a column already implied by scope \"${scope}\": \"${column}\"`,\n );\n }\n }\n\n if (unique && columns.includes(\"id\")) {\n throw new Error(\n `unique node indexes cannot include keySystemColumns: [\"id\"]; id is already unique per node, so including it defeats uniqueness across the prop fields`,\n );\n }\n\n // Return a fresh array: the declaration must own an immutable snapshot, not\n // a reference to the caller's array. Otherwise a post-call mutation of the\n // original `config.keySystemColumns` bypasses these checks and desyncs the\n // already-computed name/hash from the compiled index keys.\n return [...columns];\n}\n\nexport function defineEdgeIndex<E extends AnyEdgeType>(\n edge: E,\n config: EdgeIndexConfig<E>,\n): EdgeIndexDeclaration {\n const scope = config.scope ?? \"graphAndKind\";\n const unique = config.unique ?? false;\n const direction = config.direction ?? \"none\";\n\n const schemaIntrospector = createSchemaIntrospector(\n new Map(),\n new Map([[edge.kind, { schema: edge.schema }]]),\n );\n\n const { pointers: fields, valueTypes: fieldValueTypes } =\n normalizeEdgeIndexFieldsOrThrow(\n edge,\n config.fields,\n schemaIntrospector,\n \"fields\",\n { allowEmpty: false, allowJsonFields: config.method === \"gin\" },\n );\n\n const { pointers: coveringFields, valueTypes: coveringFieldValueTypes } =\n normalizeEdgeIndexFieldsOrThrow(\n edge,\n config.coveringFields ?? [],\n schemaIntrospector,\n \"coveringFields\",\n { allowEmpty: true },\n );\n assertNoOverlap(fields, coveringFields, \"fields\", \"coveringFields\");\n\n const where = normalizeWhereInput(config.where, () =>\n createEdgeWhereBuilder(edge, schemaIntrospector),\n );\n\n const method = resolveAdvancedIndexMethod(config.method, {\n fieldCount: fields.length,\n fieldValueType: fieldValueTypes[0],\n coveringFieldCount: coveringFields.length,\n keySystemColumnCount: 0,\n unique,\n hasWhere: where !== undefined,\n });\n\n const defaultName = generateDefaultIndexName({\n kind: \"edge\",\n kindName: edge.kind,\n unique,\n scope,\n direction,\n fields,\n coveringFields,\n });\n const name =\n config.name ??\n (method === undefined ? defaultName : `${defaultName}_${method}`);\n\n return {\n entity: \"edge\",\n kind: edge.kind,\n name,\n fields,\n fieldValueTypes,\n coveringFields,\n coveringFieldValueTypes,\n unique,\n scope,\n direction,\n where,\n ...(method === undefined ? {} : { method }),\n };\n}\n\n/**\n * Validates and canonicalizes a declaration's index method. `\"btree\"` (or\n * absent) canonicalizes to `undefined` so serialized declarations and\n * materialization signatures from before `method` existed stay\n * byte-identical. GIN-family methods index one expression and have no\n * ordered key columns, so multi-field, covering, unique, and partial\n * variants are rejected at declaration time rather than failing as\n * confusing DDL errors at materialization time.\n */\nfunction resolveAdvancedIndexMethod(\n method: RelationalIndexMethod | undefined,\n details: Readonly<{\n fieldCount: number;\n fieldValueType: ValueType | undefined;\n coveringFieldCount: number;\n keySystemColumnCount: number;\n unique: boolean;\n hasWhere: boolean;\n }>,\n): Exclude<RelationalIndexMethod, \"btree\"> | undefined {\n const resolved = method ?? \"btree\";\n if (resolved === \"btree\") return undefined;\n if (details.fieldCount !== 1) {\n throw new Error(\n `Index method \"${resolved}\" requires exactly one field (a GIN indexes one expression), got ${details.fieldCount}`,\n );\n }\n // Enforce the field-type contract the methods advertise: gin serves the\n // array containment predicates, trigram serves the string substring /\n // case-insensitive predicates. Anything else (including unresolvable\n // field types) would materialize an index no documented predicate can\n // ever use, so it is rejected here rather than silently costing write\n // amplification for nothing.\n if (resolved === \"gin\" && details.fieldValueType !== \"array\") {\n throw new Error(\n details.fieldValueType === \"string\" ?\n 'Index method \"gin\" serves array containment; for substring or case-insensitive matching on a string field use method: \"trigram\"'\n : `Index method \"gin\" requires an array field (it serves the array containment predicates), got field type \"${details.fieldValueType ?? \"unresolved\"}\"`,\n );\n }\n if (resolved === \"trigram\" && details.fieldValueType !== \"string\") {\n throw new Error(\n details.fieldValueType === \"array\" ?\n 'Index method \"trigram\" serves substring matching on string fields; for array containment use method: \"gin\"'\n : `Index method \"trigram\" requires a string field (it serves substring and case-insensitive matches), got field type \"${details.fieldValueType ?? \"unresolved\"}\"`,\n );\n }\n const extraKeyColumns: readonly [string, number][] = [\n [\"coveringFields\", details.coveringFieldCount],\n [\"keySystemColumns\", details.keySystemColumnCount],\n ];\n for (const [label, count] of extraKeyColumns) {\n if (count > 0) {\n throw new Error(\n `Index method \"${resolved}\" does not support ${label} (GIN indexes cannot serve index-only scans over extra columns)`,\n );\n }\n }\n if (details.unique) {\n throw new Error(\n `Index method \"${resolved}\" does not support unique (GIN indexes cannot enforce uniqueness)`,\n );\n }\n if (details.hasWhere) {\n throw new Error(\n `Index method \"${resolved}\" does not support a partial where clause`,\n );\n }\n return resolved;\n}\n\n// ============================================================\n// WHERE Builder\n// ============================================================\n\n/**\n * The WHERE builder currently only supports top-level fields.\n * Nested field access (e.g., `where.metadata.priority.gt(5)`) is not supported.\n * Use top-level field predicates like `where.status.eq(\"active\")`.\n *\n * For complex nested predicates, use `andWhere()`, `orWhere()`, and `notWhere()`\n * to compose multiple top-level conditions.\n */\n\nfunction normalizeWhereInput<Builder>(\n input:\n | ((where: Builder) => IndexWhereExpression)\n | IndexWhereExpression\n | undefined,\n createBuilder: () => Builder,\n): IndexWhereExpression | undefined {\n if (input === undefined) {\n return undefined;\n }\n\n if (typeof input === \"function\") {\n return input(createBuilder());\n }\n\n return input;\n}\n\ntype NodeShape = Readonly<Record<string, z.ZodType>>;\ntype EdgeShape = Readonly<Record<string, z.ZodType>>;\n\nfunction createNodeWhereBuilder<N extends NodeType>(\n node: N,\n schemaIntrospector: ReturnType<typeof createSchemaIntrospector>,\n): NodeIndexWhereBuilder<N> {\n const shape = getSchemaShape(node.schema);\n const system = createSystemColumnMapForNode();\n\n function getOperand(key: string): IndexWhereOperand {\n const systemColumn = system.get(key);\n if (systemColumn) {\n return {\n __type: \"index_operand_system\",\n column: systemColumn.column,\n valueType: systemColumn.valueType,\n };\n }\n\n if (!(key in shape)) {\n throw new Error(\n `Unknown field \"${key}\" in node index WHERE clause for \"${node.kind}\"`,\n );\n }\n\n const info = schemaIntrospector.getFieldTypeInfo(node.kind, key);\n const valueType = info?.valueType;\n\n return {\n __type: \"index_operand_prop\",\n field: key,\n valueType,\n };\n }\n\n return createWhereProxy<NodeIndexWhereBuilder<N>>((key) => getOperand(key));\n}\n\nfunction createEdgeWhereBuilder<E extends AnyEdgeType>(\n edge: E,\n schemaIntrospector: ReturnType<typeof createSchemaIntrospector>,\n): EdgeIndexWhereBuilder<E> {\n const shape = getSchemaShape(edge.schema);\n const system = createSystemColumnMapForEdge();\n\n function getOperand(key: string): IndexWhereOperand {\n const systemColumn = system.get(key);\n if (systemColumn) {\n return {\n __type: \"index_operand_system\",\n column: systemColumn.column,\n valueType: systemColumn.valueType,\n };\n }\n\n if (!(key in shape)) {\n throw new Error(\n `Unknown field \"${key}\" in edge index WHERE clause for \"${edge.kind}\"`,\n );\n }\n\n const info = schemaIntrospector.getEdgeFieldTypeInfo(edge.kind, key);\n const valueType = info?.valueType;\n\n return {\n __type: \"index_operand_prop\",\n field: key,\n valueType,\n };\n }\n\n return createWhereProxy<EdgeIndexWhereBuilder<E>>((key) => getOperand(key));\n}\n\nfunction createWhereProxy<TBuilder extends object>(\n getOperand: (key: string) => IndexWhereOperand,\n): TBuilder {\n return new Proxy(Object.create(null) as TBuilder, {\n get: (_target, property: string | symbol) => {\n if (typeof property !== \"string\") return;\n if (property === \"then\") return;\n if (property === \"toJSON\") return;\n\n const operand = getOperand(property);\n return createIndexWhereFieldBuilder(operand);\n },\n });\n}\n\nfunction createIndexWhereFieldBuilder<T>(\n operand: IndexWhereOperand,\n): IndexWhereFieldBuilder<T> {\n function isNull(): IndexWhereExpression {\n return { __type: \"index_where_null_check\", operand, op: \"isNull\" };\n }\n\n function isNotNull(): IndexWhereExpression {\n return { __type: \"index_where_null_check\", operand, op: \"isNotNull\" };\n }\n\n function comparison(op: IndexWhereOp, value: unknown): IndexWhereExpression {\n return {\n __type: \"index_where_comparison\",\n left: operand,\n op,\n right: toLiteralOrThrow(value, operand.valueType),\n };\n }\n\n function listComparison(\n op: IndexWhereOp,\n values: readonly unknown[],\n ): IndexWhereExpression {\n const literals = values.map((value) =>\n toLiteralOrThrow(value, operand.valueType),\n );\n return {\n __type: \"index_where_comparison\",\n left: operand,\n op,\n right: literals,\n };\n }\n\n return {\n eq: (value) => comparison(\"eq\", value),\n neq: (value) => comparison(\"neq\", value),\n gt: (value) => comparison(\"gt\", value),\n gte: (value) => comparison(\"gte\", value),\n lt: (value) => comparison(\"lt\", value),\n lte: (value) => comparison(\"lte\", value),\n in: (values) => listComparison(\"in\", values),\n notIn: (values) => listComparison(\"notIn\", values),\n isNull,\n isNotNull,\n };\n}\n\nfunction toLiteralOrThrow(\n value: unknown,\n preferredType: ValueType | undefined,\n): IndexWhereLiteral {\n if (value instanceof Date) {\n return {\n __type: \"index_where_literal\",\n value: value.toISOString(),\n valueType: \"date\",\n };\n }\n\n if (\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"boolean\"\n ) {\n const valueType = inferValueType(value, preferredType);\n return { __type: \"index_where_literal\", value, valueType };\n }\n\n throw new Error(\n `Unsupported literal value type in index WHERE clause: ${String(value)}`,\n );\n}\n\nfunction inferValueType(\n value: string | number | boolean,\n preferredType: ValueType | undefined,\n): ValueType {\n if (preferredType === \"date\" && typeof value === \"string\") {\n return \"date\";\n }\n if (preferredType === \"number\" && typeof value === \"string\") {\n return \"number\";\n }\n if (preferredType === \"boolean\" && typeof value === \"string\") {\n return \"boolean\";\n }\n\n if (typeof value === \"string\") return \"string\";\n if (typeof value === \"number\") return \"number\";\n return \"boolean\";\n}\n\nfunction toSystemColumnName(metaKey: string): SystemColumnName {\n const snake = metaKey.replaceAll(/([A-Z])/g, \"_$1\").toLowerCase();\n\n switch (snake) {\n case \"deleted_at\":\n case \"valid_from\":\n case \"valid_to\":\n case \"created_at\":\n case \"updated_at\": {\n return snake;\n }\n default: {\n throw new Error(`Unsupported system meta key: ${metaKey}`);\n }\n }\n}\n\nfunction createSystemColumnMapForNode(): Map<\n string,\n Readonly<{ column: SystemColumnName; valueType: ValueType | undefined }>\n> {\n const entries: (readonly [\n string,\n Readonly<{ column: SystemColumnName; valueType: ValueType | undefined }>,\n ])[] = [\n [\"graphId\", { column: \"graph_id\", valueType: \"string\" }],\n [\"kind\", { column: \"kind\", valueType: \"string\" }],\n [\"id\", { column: \"id\", valueType: \"string\" }],\n ];\n\n for (const key of NODE_META_KEYS) {\n if (key === \"version\") {\n entries.push([key, { column: \"version\", valueType: \"number\" }]);\n continue;\n }\n entries.push([key, { column: toSystemColumnName(key), valueType: \"date\" }]);\n }\n\n return new Map(entries);\n}\n\nfunction createSystemColumnMapForEdge(): Map<\n string,\n Readonly<{ column: SystemColumnName; valueType: ValueType | undefined }>\n> {\n const entries: (readonly [\n string,\n Readonly<{ column: SystemColumnName; valueType: ValueType | undefined }>,\n ])[] = [\n [\"graphId\", { column: \"graph_id\", valueType: \"string\" }],\n [\"kind\", { column: \"kind\", valueType: \"string\" }],\n [\"id\", { column: \"id\", valueType: \"string\" }],\n [\"fromKind\", { column: \"from_kind\", valueType: \"string\" }],\n [\"fromId\", { column: \"from_id\", valueType: \"string\" }],\n [\"toKind\", { column: \"to_kind\", valueType: \"string\" }],\n [\"toId\", { column: \"to_id\", valueType: \"string\" }],\n ];\n\n for (const key of EDGE_META_KEYS) {\n entries.push([key, { column: toSystemColumnName(key), valueType: \"date\" }]);\n }\n\n return new Map(entries);\n}\n\nfunction getSchemaShape(schema: z.ZodType): NodeShape | EdgeShape {\n if (schema.type !== \"object\") {\n throw new Error(\"Index definitions require an object schema\");\n }\n\n const def = schema.def as { shape?: Record<string, z.ZodType> };\n const shape = def.shape;\n if (!shape) {\n throw new Error(\"Index definitions require a resolvable object shape\");\n }\n\n return shape;\n}\n\n// ============================================================\n// Validation\n// ============================================================\n\nfunction assertNonEmpty(values: readonly unknown[], label: string): void {\n if (values.length === 0) {\n throw new Error(`Index ${label} must not be empty`);\n }\n}\n\nfunction assertUnique(values: readonly string[], label: string): void {\n const set = new Set<string>();\n for (const value of values) {\n if (set.has(value)) {\n throw new Error(`Index ${label} contains duplicate value: ${value}`);\n }\n set.add(value);\n }\n}\n\nfunction assertNoOverlap(\n a: readonly string[],\n b: readonly string[],\n aLabel: string,\n bLabel: string,\n): void {\n const set = new Set(a);\n for (const value of b) {\n if (set.has(value)) {\n throw new Error(`Index ${bLabel} must not overlap ${aLabel}: ${value}`);\n }\n }\n}\n\nfunction assertIndexableValueType(\n valueType: ValueType,\n context: string,\n options: Readonly<{ allowJsonFields: boolean }>,\n): void {\n if (valueType === \"embedding\") {\n throw new Error(\n `Cannot create props index for embedding field (${context}); embedding() fields are indexed automatically in the vector strategy's per-(kind, field) storage`,\n );\n }\n\n if (\n (valueType === \"array\" || valueType === \"object\") &&\n !options.allowJsonFields\n ) {\n throw new Error(\n `Cannot create btree props index for ${valueType} field (${context}); use method: \"gin\" instead`,\n );\n }\n}\n\ntype NormalizedIndexFields = Readonly<{\n pointers: readonly JsonPointer[];\n valueTypes: readonly (ValueType | undefined)[];\n}>;\n\nfunction normalizeNodeIndexFieldsOrThrow<N extends NodeType>(\n node: N,\n inputs: readonly IndexFieldInput<z.infer<N[\"schema\"]>>[],\n schemaIntrospector: ReturnType<typeof createSchemaIntrospector>,\n label: string,\n options: Readonly<{ allowJsonFields?: boolean }>,\n): NormalizedIndexFields {\n // Node `fields`/`coveringFields` are both optional (an index can be keyed\n // by `keySystemColumns` alone), so unlike the edge equivalent below, an\n // empty input is always valid here — `defineNodeIndex` enforces that at\n // least one of `fields`/`coveringFields`/`keySystemColumns` is non-empty.\n if (inputs.length === 0) {\n return { pointers: [], valueTypes: [] };\n }\n\n const pointers: JsonPointer[] = [];\n const valueTypes: (ValueType | undefined)[] = [];\n\n for (const input of inputs) {\n const pointer = normalizeIndexFieldPointer(input);\n const info = resolveNodeFieldTypeInfoOrThrow(\n node.kind,\n pointer,\n schemaIntrospector,\n );\n assertIndexableValueType(info.valueType, `node \"${node.kind}\" ${pointer}`, {\n allowJsonFields: options.allowJsonFields ?? false,\n });\n pointers.push(pointer);\n valueTypes.push(info.valueType);\n }\n\n assertUnique(pointers, label);\n\n return { pointers, valueTypes };\n}\n\nfunction normalizeEdgeIndexFieldsOrThrow<E extends AnyEdgeType>(\n edge: E,\n inputs: readonly IndexFieldInput<z.infer<E[\"schema\"]>>[],\n schemaIntrospector: ReturnType<typeof createSchemaIntrospector>,\n label: string,\n options: Readonly<{ allowEmpty: boolean; allowJsonFields?: boolean }>,\n): NormalizedIndexFields {\n if (inputs.length === 0 && options.allowEmpty) {\n return { pointers: [], valueTypes: [] };\n }\n assertNonEmpty(inputs, label);\n\n const pointers: JsonPointer[] = [];\n const valueTypes: (ValueType | undefined)[] = [];\n\n for (const input of inputs) {\n const pointer = normalizeIndexFieldPointer(input);\n const info = resolveEdgeFieldTypeInfoOrThrow(\n edge.kind,\n pointer,\n schemaIntrospector,\n );\n assertIndexableValueType(info.valueType, `edge \"${edge.kind}\" ${pointer}`, {\n allowJsonFields: options.allowJsonFields ?? false,\n });\n pointers.push(pointer);\n valueTypes.push(info.valueType);\n }\n\n assertUnique(pointers, label);\n\n return { pointers, valueTypes };\n}\n\nfunction normalizeIndexFieldPointer<T>(input: IndexFieldInput<T>): JsonPointer {\n if (Array.isArray(input)) {\n if (input.length === 0) {\n throw new Error(\"Index field JSON pointer must not be empty\");\n }\n return jsonPointer(input as readonly JsonPointerSegment[]);\n }\n\n if (typeof input === \"string\") {\n if (input.startsWith(\"/\")) {\n const pointer = normalizeJsonPointer(\n input as JsonPointerInput<Record<string, unknown>>,\n );\n if (pointer === \"\") {\n throw new Error(\"Index field JSON pointer must not be empty\");\n }\n return pointer;\n }\n return jsonPointer([input]);\n }\n\n throw new Error(`Unsupported index field input: ${String(input)}`);\n}\n\nfunction resolveNodeFieldTypeInfoOrThrow(\n nodeKind: string,\n pointer: JsonPointer,\n schemaIntrospector: ReturnType<typeof createSchemaIntrospector>,\n): FieldTypeInfo {\n const segments = parseJsonPointer(pointer);\n const [first, ...rest] = segments;\n if (!first) {\n throw new Error(\"Index field JSON pointer must not be empty\");\n }\n\n const rootInfo = schemaIntrospector.getFieldTypeInfo(nodeKind, first);\n if (!rootInfo) {\n throw new Error(\n `Unknown field \"${first}\" for node \"${nodeKind}\" in index definition`,\n );\n }\n\n if (rest.length === 0) {\n return rootInfo;\n }\n\n const resolved = resolveFieldTypeInfoAtJsonPointer(\n rootInfo,\n jsonPointer(rest),\n );\n if (!resolved) {\n throw new Error(\n `Unknown JSON pointer \"${pointer}\" for node \"${nodeKind}\" in index definition`,\n );\n }\n\n return resolved;\n}\n\nfunction resolveEdgeFieldTypeInfoOrThrow(\n edgeKind: string,\n pointer: JsonPointer,\n schemaIntrospector: ReturnType<typeof createSchemaIntrospector>,\n): FieldTypeInfo {\n const segments = parseJsonPointer(pointer);\n const [first, ...rest] = segments;\n if (!first) {\n throw new Error(\"Index field JSON pointer must not be empty\");\n }\n\n const rootInfo = schemaIntrospector.getEdgeFieldTypeInfo(edgeKind, first);\n if (!rootInfo) {\n throw new Error(\n `Unknown field \"${first}\" for edge \"${edgeKind}\" in index definition`,\n );\n }\n\n if (rest.length === 0) {\n return rootInfo;\n }\n\n const resolved = resolveFieldTypeInfoAtJsonPointer(\n rootInfo,\n jsonPointer(rest),\n );\n if (!resolved) {\n throw new Error(\n `Unknown JSON pointer \"${pointer}\" for edge \"${edgeKind}\" in index definition`,\n );\n }\n\n return resolved;\n}\n\n// ============================================================\n// Default Name Generation\n// ============================================================\n\ntype DefaultNameParts = Readonly<{\n kind: KindEntity;\n kindName: string;\n unique: boolean;\n scope: IndexScope;\n direction: EdgeIndexDirection;\n fields: readonly string[];\n coveringFields: readonly string[];\n /**\n * Node-only, defaults to `[]` for edges. Folded into the hash/name only\n * when non-empty so indexes that don't use it keep byte-identical\n * default names to before this field existed.\n */\n keySystemColumns?: readonly string[];\n}>;\n\nfunction generateDefaultIndexName(parts: DefaultNameParts): string {\n const keySystemColumns = parts.keySystemColumns ?? [];\n const hash = fnv1aBase36(\n JSON.stringify({\n kind: parts.kind,\n kindName: parts.kindName,\n unique: parts.unique,\n scope: parts.scope,\n direction: parts.direction,\n fields: parts.fields,\n covering: parts.coveringFields,\n ...(keySystemColumns.length > 0 ? { keySystemColumns } : {}),\n }),\n );\n\n const nameParts = [\n \"idx\",\n \"tg\",\n parts.kind,\n sanitizeIdentifierComponent(parts.kindName),\n parts.fields.length > 0 ?\n sanitizeIdentifierComponent(parts.fields.join(\"_\"))\n : undefined,\n parts.coveringFields.length > 0 ?\n `cov_${sanitizeIdentifierComponent(parts.coveringFields.join(\"_\"))}`\n : undefined,\n keySystemColumns.length > 0 ?\n `sys_${sanitizeIdentifierComponent(keySystemColumns.join(\"_\"))}`\n : undefined,\n parts.direction === \"none\" ? undefined : parts.direction,\n parts.unique ? \"uniq\" : undefined,\n parts.scope === \"graphAndKind\" ?\n undefined\n : sanitizeIdentifierComponent(parts.scope),\n hash,\n ].filter((part) => part !== undefined);\n\n const joined = nameParts.join(\"_\");\n return joined.length <= MAX_PG_IDENTIFIER_LENGTH ?\n joined\n : `${joined.slice(0, TRUNCATED_IDENTIFIER_MAX_LENGTH)}_${hash}`;\n}\n\nfunction sanitizeIdentifierComponent(value: string): string {\n return value\n .toLowerCase()\n .replaceAll(/[^a-z0-9_]+/g, \"_\")\n .replaceAll(/^_+|_+$/g, \"\")\n .slice(0, IDENTIFIER_COMPONENT_MAX_LENGTH);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/system-fields.ts","../src/indexes/define-index.ts"],"names":[],"mappings":";;;;;;;;AAAO,IAAM,cAAA,GAAiB;AAAA,EAC5B,SAAA;AAAA,EACA,WAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF;AAEO,IAAM,cAAA,GAAiB;AAAA,EAC5B,WAAA;AAAA,EACA,SAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF;;;ACyCA,IAAM,0BAAyD,IAAI,GAAA;AAAA,EACjE,CAAC,GAAG,4BAAA,EAA6B,CAAE,MAAA,EAAQ,CAAA,CAAE,GAAA,CAAI,CAAC,KAAA,KAAU,KAAA,CAAM,MAAM;AAC1E,CAAA;AAMO,SAAS,eAAA,CACd,MACA,MAAA,EACsB;AACtB,EAAA,MAAM,KAAA,GAAQ,OAAO,KAAA,IAAS,cAAA;AAC9B,EAAA,MAAM,MAAA,GAAS,OAAO,MAAA,IAAU,KAAA;AAChC,EAAA,MAAM,gBAAA,GAAmB,gCAAA;AAAA,IACvB,MAAA,CAAO,oBAAoB,EAAC;AAAA,IAC5B,KAAA;AAAA,IACA;AAAA,GACF;AAEA,EAAA,MAAM,kBAAA,GAAqB,wBAAA;AAAA,oBACzB,IAAI,GAAA,CAAI,CAAC,CAAC,IAAA,CAAK,IAAA,EAAM,EAAE,MAAA,EAAQ,IAAA,CAAK,MAAA,EAAQ,CAAC,CAAC;AAAA,GAChD;AAEA,EAAA,MAA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AAA;AACjE;AAEA,SAAS,4BAA4B,KAAA,EAAuB;AAC1D,EAAA,OAAO,KAAA,CACJ,WAAA,EAAY,CACZ,UAAA,CAAW,cAAA,EAAgB,GAAG,CAAA,CAC9B,UAAA,CAAW,UAAA,EAAY,EAAE,CAAA,CACzB,KAAA,CAAM,GAAG,+BAA+B,CAAA;AAC7C","file":"chunk-ZP2KPDNN.js","sourcesContent":["export const NODE_META_KEYS = [\n \"version\",\n \"validFrom\",\n \"validTo\",\n \"createdAt\",\n \"updatedAt\",\n \"deletedAt\",\n] as const;\n\nexport const EDGE_META_KEYS = [\n \"validFrom\",\n \"validTo\",\n \"createdAt\",\n \"updatedAt\",\n \"deletedAt\",\n] as const;\n","import { type z } from \"zod\";\n\nimport {\n IDENTIFIER_COMPONENT_MAX_LENGTH,\n MAX_PG_IDENTIFIER_LENGTH,\n TRUNCATED_IDENTIFIER_MAX_LENGTH,\n} from \"../constants\";\nimport {\n type AnyEdgeType,\n type KindEntity,\n type NodeType,\n} from \"../core/types\";\nimport { type ValueType } from \"../query/ast\";\nimport { resolveFieldTypeInfoAtJsonPointer } from \"../query/field-type-info\";\nimport {\n type JsonPointer,\n jsonPointer,\n type JsonPointerInput,\n type JsonPointerSegment,\n normalizeJsonPointer,\n parseJsonPointer,\n} from \"../query/json-pointer\";\nimport {\n createSchemaIntrospector,\n type FieldTypeInfo,\n} from \"../query/schema-introspector\";\nimport { EDGE_META_KEYS, NODE_META_KEYS } from \"../system-fields\";\nimport { fnv1aBase36 } from \"../utils/hash\";\nimport { getNodeScopeColumns } from \"./compiler\";\nimport {\n type EdgeIndexConfig,\n type EdgeIndexDeclaration,\n type EdgeIndexDirection,\n type EdgeIndexWhereBuilder,\n type IndexFieldInput,\n type IndexScope,\n type IndexWhereExpression,\n type IndexWhereFieldBuilder,\n type IndexWhereLiteral,\n type IndexWhereOp,\n type IndexWhereOperand,\n type NodeIndexConfig,\n type NodeIndexDeclaration,\n type NodeIndexWhereBuilder,\n type RelationalIndexMethod,\n type SystemColumnName,\n} from \"./types\";\n\n// `keySystemColumns` on a node index must fail closed: reject anything that\n// isn't a known node-valid column, not just the known edge-only ones. A\n// caller whose array escapes TypeScript's literal-union checking (`any`-typed\n// data, a value round-tripped through JSON) could otherwise pass a typo'd or\n// otherwise-invalid column that silently reaches SQL DDL generation instead\n// of failing here with a clear error. Derived from the single source of\n// truth (`createSystemColumnMapForNode`, hoisted — see below) rather than a\n// second hand-maintained list, so it can't drift from it.\nconst NODE_KEY_SYSTEM_COLUMNS: ReadonlySet<SystemColumnName> = new Set(\n [...createSystemColumnMapForNode().values()].map((entry) => entry.column),\n);\n\n// ============================================================\n// Public API\n// ============================================================\n\nexport function defineNodeIndex<N extends NodeType>(\n node: N,\n config: NodeIndexConfig<N>,\n): NodeIndexDeclaration {\n const scope = config.scope ?? \"graphAndKind\";\n const unique = config.unique ?? false;\n const keySystemColumns = normalizeKeySystemColumnsOrThrow(\n config.keySystemColumns ?? [],\n scope,\n unique,\n );\n\n const schemaIntrospector = createSchemaIntrospector(\n new Map([[node.kind, { schema: node.schema }]]),\n );\n\n const { pointers: fields, valueTypes: fieldValueTypes } =\n normalizeNodeIndexFieldsOrThrow(\n node,\n config.fields ?? [],\n schemaIntrospector,\n \"fields\",\n // GIN containment indexes exist precisely for array/object fields,\n // which the btree guard otherwise rejects.\n { allowJsonFields: config.method === \"gin\" },\n );\n\n const { pointers: coveringFields, valueTypes: coveringFieldValueTypes } =\n normalizeNodeIndexFieldsOrThrow(\n node,\n config.coveringFields ?? [],\n schemaIntrospector,\n \"coveringFields\",\n {},\n );\n assertNoOverlap(fields, coveringFields, \"fields\", \"coveringFields\");\n\n if (\n fields.length === 0 &&\n coveringFields.length === 0 &&\n keySystemColumns.length === 0\n ) {\n throw new Error(\n \"Index must declare at least one of fields, coveringFields, or keySystemColumns\",\n );\n }\n\n const where = normalizeWhereInput(config.where, () =>\n createNodeWhereBuilder(node, schemaIntrospector),\n );\n\n const method = resolveAdvancedIndexMethod(config.method, {\n fieldCount: fields.length,\n fieldValueType: fieldValueTypes[0],\n coveringFieldCount: coveringFields.length,\n keySystemColumnCount: keySystemColumns.length,\n unique,\n hasWhere: where !== undefined,\n });\n\n const defaultName = generateDefaultIndexName({\n kind: \"node\",\n kindName: node.kind,\n unique,\n scope,\n direction: \"none\",\n fields,\n coveringFields,\n keySystemColumns,\n });\n const name =\n config.name ??\n (method === undefined ? defaultName : `${defaultName}_${method}`);\n\n // `origin` is intentionally omitted: `\"compile-time\"` is the default\n // and is canonicalized by absence so the serialized form stays\n // byte-identical for legacy graphs. `method` and `keySystemColumns`\n // follow the same rule (absence == \"btree\" / no system key columns).\n return {\n entity: \"node\",\n kind: node.kind,\n name,\n fields,\n fieldValueTypes,\n coveringFields,\n coveringFieldValueTypes,\n unique,\n scope,\n where,\n ...(method === undefined ? {} : { method }),\n ...(keySystemColumns.length === 0 ? {} : { keySystemColumns }),\n };\n}\n\n/**\n * Validates `keySystemColumns`: must be node system columns (not\n * edge-only `from_kind`/`from_id`/`to_kind`/`to_id`), must not repeat\n * each other, must not repeat a column `scope` already prefixes the key\n * with, and must not combine `\"id\"` with `unique` (every node's `id` is\n * already unique per row, so that combination can never enforce a\n * meaningful constraint across the index's other key columns).\n */\nfunction normalizeKeySystemColumnsOrThrow(\n columns: readonly SystemColumnName[],\n scope: IndexScope,\n unique: boolean,\n): readonly SystemColumnName[] {\n if (columns.length === 0) return [];\n\n for (const column of columns) {\n if (!NODE_KEY_SYSTEM_COLUMNS.has(column)) {\n throw new Error(\n `Node index keySystemColumns does not support \"${column}\" (edge-only system column)`,\n );\n }\n }\n assertUnique(columns, \"keySystemColumns\");\n\n const scopeColumns = new Set(getNodeScopeColumns(scope));\n for (const column of columns) {\n if (scopeColumns.has(column)) {\n throw new Error(\n `Node index keySystemColumns must not repeat a column already implied by scope \"${scope}\": \"${column}\"`,\n );\n }\n }\n\n if (unique && columns.includes(\"id\")) {\n throw new Error(\n `unique node indexes cannot include keySystemColumns: [\"id\"]; id is already unique per node, so including it defeats uniqueness across the prop fields`,\n );\n }\n\n // Return a fresh array: the declaration must own an immutable snapshot, not\n // a reference to the caller's array. Otherwise a post-call mutation of the\n // original `config.keySystemColumns` bypasses these checks and desyncs the\n // already-computed name/hash from the compiled index keys.\n return [...columns];\n}\n\nexport function defineEdgeIndex<E extends AnyEdgeType>(\n edge: E,\n config: EdgeIndexConfig<E>,\n): EdgeIndexDeclaration {\n const scope = config.scope ?? \"graphAndKind\";\n const unique = config.unique ?? false;\n const direction = config.direction ?? \"none\";\n\n const schemaIntrospector = createSchemaIntrospector(\n new Map(),\n new Map([[edge.kind, { schema: edge.schema }]]),\n );\n\n const { pointers: fields, valueTypes: fieldValueTypes } =\n normalizeEdgeIndexFieldsOrThrow(\n edge,\n config.fields,\n schemaIntrospector,\n \"fields\",\n { allowEmpty: false, allowJsonFields: config.method === \"gin\" },\n );\n\n const { pointers: coveringFields, valueTypes: coveringFieldValueTypes } =\n normalizeEdgeIndexFieldsOrThrow(\n edge,\n config.coveringFields ?? [],\n schemaIntrospector,\n \"coveringFields\",\n { allowEmpty: true },\n );\n assertNoOverlap(fields, coveringFields, \"fields\", \"coveringFields\");\n\n const where = normalizeWhereInput(config.where, () =>\n createEdgeWhereBuilder(edge, schemaIntrospector),\n );\n\n const method = resolveAdvancedIndexMethod(config.method, {\n fieldCount: fields.length,\n fieldValueType: fieldValueTypes[0],\n coveringFieldCount: coveringFields.length,\n keySystemColumnCount: 0,\n unique,\n hasWhere: where !== undefined,\n });\n\n const defaultName = generateDefaultIndexName({\n kind: \"edge\",\n kindName: edge.kind,\n unique,\n scope,\n direction,\n fields,\n coveringFields,\n });\n const name =\n config.name ??\n (method === undefined ? defaultName : `${defaultName}_${method}`);\n\n return {\n entity: \"edge\",\n kind: edge.kind,\n name,\n fields,\n fieldValueTypes,\n coveringFields,\n coveringFieldValueTypes,\n unique,\n scope,\n direction,\n where,\n ...(method === undefined ? {} : { method }),\n };\n}\n\n/**\n * Validates and canonicalizes a declaration's index method. `\"btree\"` (or\n * absent) canonicalizes to `undefined` so serialized declarations and\n * materialization signatures from before `method` existed stay\n * byte-identical. GIN-family methods index one expression and have no\n * ordered key columns, so multi-field, covering, unique, and partial\n * variants are rejected at declaration time rather than failing as\n * confusing DDL errors at materialization time.\n */\nfunction resolveAdvancedIndexMethod(\n method: RelationalIndexMethod | undefined,\n details: Readonly<{\n fieldCount: number;\n fieldValueType: ValueType | undefined;\n coveringFieldCount: number;\n keySystemColumnCount: number;\n unique: boolean;\n hasWhere: boolean;\n }>,\n): Exclude<RelationalIndexMethod, \"btree\"> | undefined {\n const resolved = method ?? \"btree\";\n if (resolved === \"btree\") return undefined;\n if (details.fieldCount !== 1) {\n throw new Error(\n `Index method \"${resolved}\" requires exactly one field (a GIN indexes one expression), got ${details.fieldCount}`,\n );\n }\n // Enforce the field-type contract the methods advertise: gin serves the\n // array containment predicates, trigram serves the string substring /\n // case-insensitive predicates. Anything else (including unresolvable\n // field types) would materialize an index no documented predicate can\n // ever use, so it is rejected here rather than silently costing write\n // amplification for nothing.\n if (resolved === \"gin\" && details.fieldValueType !== \"array\") {\n throw new Error(\n details.fieldValueType === \"string\" ?\n 'Index method \"gin\" serves array containment; for substring or case-insensitive matching on a string field use method: \"trigram\"'\n : `Index method \"gin\" requires an array field (it serves the array containment predicates), got field type \"${details.fieldValueType ?? \"unresolved\"}\"`,\n );\n }\n if (resolved === \"trigram\" && details.fieldValueType !== \"string\") {\n throw new Error(\n details.fieldValueType === \"array\" ?\n 'Index method \"trigram\" serves substring matching on string fields; for array containment use method: \"gin\"'\n : `Index method \"trigram\" requires a string field (it serves substring and case-insensitive matches), got field type \"${details.fieldValueType ?? \"unresolved\"}\"`,\n );\n }\n const extraKeyColumns: readonly [string, number][] = [\n [\"coveringFields\", details.coveringFieldCount],\n [\"keySystemColumns\", details.keySystemColumnCount],\n ];\n for (const [label, count] of extraKeyColumns) {\n if (count > 0) {\n throw new Error(\n `Index method \"${resolved}\" does not support ${label} (GIN indexes cannot serve index-only scans over extra columns)`,\n );\n }\n }\n if (details.unique) {\n throw new Error(\n `Index method \"${resolved}\" does not support unique (GIN indexes cannot enforce uniqueness)`,\n );\n }\n if (details.hasWhere) {\n throw new Error(\n `Index method \"${resolved}\" does not support a partial where clause`,\n );\n }\n return resolved;\n}\n\n// ============================================================\n// WHERE Builder\n// ============================================================\n\n/**\n * The WHERE builder currently only supports top-level fields.\n * Nested field access (e.g., `where.metadata.priority.gt(5)`) is not supported.\n * Use top-level field predicates like `where.status.eq(\"active\")`.\n *\n * For complex nested predicates, use `andWhere()`, `orWhere()`, and `notWhere()`\n * to compose multiple top-level conditions.\n */\n\nfunction normalizeWhereInput<Builder>(\n input:\n | ((where: Builder) => IndexWhereExpression)\n | IndexWhereExpression\n | undefined,\n createBuilder: () => Builder,\n): IndexWhereExpression | undefined {\n if (input === undefined) {\n return undefined;\n }\n\n if (typeof input === \"function\") {\n return input(createBuilder());\n }\n\n return input;\n}\n\ntype NodeShape = Readonly<Record<string, z.ZodType>>;\ntype EdgeShape = Readonly<Record<string, z.ZodType>>;\n\nfunction createNodeWhereBuilder<N extends NodeType>(\n node: N,\n schemaIntrospector: ReturnType<typeof createSchemaIntrospector>,\n): NodeIndexWhereBuilder<N> {\n const shape = getSchemaShape(node.schema);\n const system = createSystemColumnMapForNode();\n\n function getOperand(key: string): IndexWhereOperand {\n const systemColumn = system.get(key);\n if (systemColumn) {\n return {\n __type: \"index_operand_system\",\n column: systemColumn.column,\n valueType: systemColumn.valueType,\n };\n }\n\n if (!(key in shape)) {\n throw new Error(\n `Unknown field \"${key}\" in node index WHERE clause for \"${node.kind}\"`,\n );\n }\n\n const info = schemaIntrospector.getFieldTypeInfo(node.kind, key);\n const valueType = info?.valueType;\n\n return {\n __type: \"index_operand_prop\",\n field: key,\n valueType,\n };\n }\n\n return createWhereProxy<NodeIndexWhereBuilder<N>>((key) => getOperand(key));\n}\n\nfunction createEdgeWhereBuilder<E extends AnyEdgeType>(\n edge: E,\n schemaIntrospector: ReturnType<typeof createSchemaIntrospector>,\n): EdgeIndexWhereBuilder<E> {\n const shape = getSchemaShape(edge.schema);\n const system = createSystemColumnMapForEdge();\n\n function getOperand(key: string): IndexWhereOperand {\n const systemColumn = system.get(key);\n if (systemColumn) {\n return {\n __type: \"index_operand_system\",\n column: systemColumn.column,\n valueType: systemColumn.valueType,\n };\n }\n\n if (!(key in shape)) {\n throw new Error(\n `Unknown field \"${key}\" in edge index WHERE clause for \"${edge.kind}\"`,\n );\n }\n\n const info = schemaIntrospector.getEdgeFieldTypeInfo(edge.kind, key);\n const valueType = info?.valueType;\n\n return {\n __type: \"index_operand_prop\",\n field: key,\n valueType,\n };\n }\n\n return createWhereProxy<EdgeIndexWhereBuilder<E>>((key) => getOperand(key));\n}\n\nfunction createWhereProxy<TBuilder extends object>(\n getOperand: (key: string) => IndexWhereOperand,\n): TBuilder {\n return new Proxy(Object.create(null) as TBuilder, {\n get: (_target, property: string | symbol) => {\n if (typeof property !== \"string\") return;\n if (property === \"then\") return;\n if (property === \"toJSON\") return;\n\n const operand = getOperand(property);\n return createIndexWhereFieldBuilder(operand);\n },\n });\n}\n\nfunction createIndexWhereFieldBuilder<T>(\n operand: IndexWhereOperand,\n): IndexWhereFieldBuilder<T> {\n function isNull(): IndexWhereExpression {\n return { __type: \"index_where_null_check\", operand, op: \"isNull\" };\n }\n\n function isNotNull(): IndexWhereExpression {\n return { __type: \"index_where_null_check\", operand, op: \"isNotNull\" };\n }\n\n function comparison(op: IndexWhereOp, value: unknown): IndexWhereExpression {\n return {\n __type: \"index_where_comparison\",\n left: operand,\n op,\n right: toLiteralOrThrow(value, operand.valueType),\n };\n }\n\n function listComparison(\n op: IndexWhereOp,\n values: readonly unknown[],\n ): IndexWhereExpression {\n const literals = values.map((value) =>\n toLiteralOrThrow(value, operand.valueType),\n );\n return {\n __type: \"index_where_comparison\",\n left: operand,\n op,\n right: literals,\n };\n }\n\n return {\n eq: (value) => comparison(\"eq\", value),\n neq: (value) => comparison(\"neq\", value),\n gt: (value) => comparison(\"gt\", value),\n gte: (value) => comparison(\"gte\", value),\n lt: (value) => comparison(\"lt\", value),\n lte: (value) => comparison(\"lte\", value),\n in: (values) => listComparison(\"in\", values),\n notIn: (values) => listComparison(\"notIn\", values),\n isNull,\n isNotNull,\n };\n}\n\nfunction toLiteralOrThrow(\n value: unknown,\n preferredType: ValueType | undefined,\n): IndexWhereLiteral {\n if (value instanceof Date) {\n return {\n __type: \"index_where_literal\",\n value: value.toISOString(),\n valueType: \"date\",\n };\n }\n\n if (\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"boolean\"\n ) {\n const valueType = inferValueType(value, preferredType);\n return { __type: \"index_where_literal\", value, valueType };\n }\n\n throw new Error(\n `Unsupported literal value type in index WHERE clause: ${String(value)}`,\n );\n}\n\nfunction inferValueType(\n value: string | number | boolean,\n preferredType: ValueType | undefined,\n): ValueType {\n if (preferredType === \"date\" && typeof value === \"string\") {\n return \"date\";\n }\n if (preferredType === \"number\" && typeof value === \"string\") {\n return \"number\";\n }\n if (preferredType === \"boolean\" && typeof value === \"string\") {\n return \"boolean\";\n }\n\n if (typeof value === \"string\") return \"string\";\n if (typeof value === \"number\") return \"number\";\n return \"boolean\";\n}\n\nfunction toSystemColumnName(metaKey: string): SystemColumnName {\n const snake = metaKey.replaceAll(/([A-Z])/g, \"_$1\").toLowerCase();\n\n switch (snake) {\n case \"deleted_at\":\n case \"valid_from\":\n case \"valid_to\":\n case \"created_at\":\n case \"updated_at\": {\n return snake;\n }\n default: {\n throw new Error(`Unsupported system meta key: ${metaKey}`);\n }\n }\n}\n\nfunction createSystemColumnMapForNode(): Map<\n string,\n Readonly<{ column: SystemColumnName; valueType: ValueType | undefined }>\n> {\n const entries: (readonly [\n string,\n Readonly<{ column: SystemColumnName; valueType: ValueType | undefined }>,\n ])[] = [\n [\"graphId\", { column: \"graph_id\", valueType: \"string\" }],\n [\"kind\", { column: \"kind\", valueType: \"string\" }],\n [\"id\", { column: \"id\", valueType: \"string\" }],\n ];\n\n for (const key of NODE_META_KEYS) {\n if (key === \"version\") {\n entries.push([key, { column: \"version\", valueType: \"number\" }]);\n continue;\n }\n entries.push([key, { column: toSystemColumnName(key), valueType: \"date\" }]);\n }\n\n return new Map(entries);\n}\n\nfunction createSystemColumnMapForEdge(): Map<\n string,\n Readonly<{ column: SystemColumnName; valueType: ValueType | undefined }>\n> {\n const entries: (readonly [\n string,\n Readonly<{ column: SystemColumnName; valueType: ValueType | undefined }>,\n ])[] = [\n [\"graphId\", { column: \"graph_id\", valueType: \"string\" }],\n [\"kind\", { column: \"kind\", valueType: \"string\" }],\n [\"id\", { column: \"id\", valueType: \"string\" }],\n [\"fromKind\", { column: \"from_kind\", valueType: \"string\" }],\n [\"fromId\", { column: \"from_id\", valueType: \"string\" }],\n [\"toKind\", { column: \"to_kind\", valueType: \"string\" }],\n [\"toId\", { column: \"to_id\", valueType: \"string\" }],\n ];\n\n for (const key of EDGE_META_KEYS) {\n entries.push([key, { column: toSystemColumnName(key), valueType: \"date\" }]);\n }\n\n return new Map(entries);\n}\n\nfunction getSchemaShape(schema: z.ZodType): NodeShape | EdgeShape {\n if (schema.type !== \"object\") {\n throw new Error(\"Index definitions require an object schema\");\n }\n\n const def = schema.def as { shape?: Record<string, z.ZodType> };\n const shape = def.shape;\n if (!shape) {\n throw new Error(\"Index definitions require a resolvable object shape\");\n }\n\n return shape;\n}\n\n// ============================================================\n// Validation\n// ============================================================\n\nfunction assertNonEmpty(values: readonly unknown[], label: string): void {\n if (values.length === 0) {\n throw new Error(`Index ${label} must not be empty`);\n }\n}\n\nfunction assertUnique(values: readonly string[], label: string): void {\n const set = new Set<string>();\n for (const value of values) {\n if (set.has(value)) {\n throw new Error(`Index ${label} contains duplicate value: ${value}`);\n }\n set.add(value);\n }\n}\n\nfunction assertNoOverlap(\n a: readonly string[],\n b: readonly string[],\n aLabel: string,\n bLabel: string,\n): void {\n const set = new Set(a);\n for (const value of b) {\n if (set.has(value)) {\n throw new Error(`Index ${bLabel} must not overlap ${aLabel}: ${value}`);\n }\n }\n}\n\nfunction assertIndexableValueType(\n valueType: ValueType,\n context: string,\n options: Readonly<{ allowJsonFields: boolean }>,\n): void {\n if (valueType === \"embedding\") {\n throw new Error(\n `Cannot create props index for embedding field (${context}); embedding() fields are indexed automatically in the vector strategy's per-(kind, field) storage`,\n );\n }\n\n if (\n (valueType === \"array\" || valueType === \"object\") &&\n !options.allowJsonFields\n ) {\n throw new Error(\n `Cannot create btree props index for ${valueType} field (${context}); use method: \"gin\" instead`,\n );\n }\n}\n\ntype NormalizedIndexFields = Readonly<{\n pointers: readonly JsonPointer[];\n valueTypes: readonly (ValueType | undefined)[];\n}>;\n\nfunction normalizeNodeIndexFieldsOrThrow<N extends NodeType>(\n node: N,\n inputs: readonly IndexFieldInput<z.infer<N[\"schema\"]>>[],\n schemaIntrospector: ReturnType<typeof createSchemaIntrospector>,\n label: string,\n options: Readonly<{ allowJsonFields?: boolean }>,\n): NormalizedIndexFields {\n // Node `fields`/`coveringFields` are both optional (an index can be keyed\n // by `keySystemColumns` alone), so unlike the edge equivalent below, an\n // empty input is always valid here — `defineNodeIndex` enforces that at\n // least one of `fields`/`coveringFields`/`keySystemColumns` is non-empty.\n if (inputs.length === 0) {\n return { pointers: [], valueTypes: [] };\n }\n\n const pointers: JsonPointer[] = [];\n const valueTypes: (ValueType | undefined)[] = [];\n\n for (const input of inputs) {\n const pointer = normalizeIndexFieldPointer(input);\n const info = resolveNodeFieldTypeInfoOrThrow(\n node.kind,\n pointer,\n schemaIntrospector,\n );\n assertIndexableValueType(info.valueType, `node \"${node.kind}\" ${pointer}`, {\n allowJsonFields: options.allowJsonFields ?? false,\n });\n pointers.push(pointer);\n valueTypes.push(info.valueType);\n }\n\n assertUnique(pointers, label);\n\n return { pointers, valueTypes };\n}\n\nfunction normalizeEdgeIndexFieldsOrThrow<E extends AnyEdgeType>(\n edge: E,\n inputs: readonly IndexFieldInput<z.infer<E[\"schema\"]>>[],\n schemaIntrospector: ReturnType<typeof createSchemaIntrospector>,\n label: string,\n options: Readonly<{ allowEmpty: boolean; allowJsonFields?: boolean }>,\n): NormalizedIndexFields {\n if (inputs.length === 0 && options.allowEmpty) {\n return { pointers: [], valueTypes: [] };\n }\n assertNonEmpty(inputs, label);\n\n const pointers: JsonPointer[] = [];\n const valueTypes: (ValueType | undefined)[] = [];\n\n for (const input of inputs) {\n const pointer = normalizeIndexFieldPointer(input);\n const info = resolveEdgeFieldTypeInfoOrThrow(\n edge.kind,\n pointer,\n schemaIntrospector,\n );\n assertIndexableValueType(info.valueType, `edge \"${edge.kind}\" ${pointer}`, {\n allowJsonFields: options.allowJsonFields ?? false,\n });\n pointers.push(pointer);\n valueTypes.push(info.valueType);\n }\n\n assertUnique(pointers, label);\n\n return { pointers, valueTypes };\n}\n\nfunction normalizeIndexFieldPointer<T>(input: IndexFieldInput<T>): JsonPointer {\n if (Array.isArray(input)) {\n if (input.length === 0) {\n throw new Error(\"Index field JSON pointer must not be empty\");\n }\n return jsonPointer(input as readonly JsonPointerSegment[]);\n }\n\n if (typeof input === \"string\") {\n if (input.startsWith(\"/\")) {\n const pointer = normalizeJsonPointer(\n input as JsonPointerInput<Record<string, unknown>>,\n );\n if (pointer === \"\") {\n throw new Error(\"Index field JSON pointer must not be empty\");\n }\n return pointer;\n }\n return jsonPointer([input]);\n }\n\n throw new Error(`Unsupported index field input: ${String(input)}`);\n}\n\nfunction resolveNodeFieldTypeInfoOrThrow(\n nodeKind: string,\n pointer: JsonPointer,\n schemaIntrospector: ReturnType<typeof createSchemaIntrospector>,\n): FieldTypeInfo {\n const segments = parseJsonPointer(pointer);\n const [first, ...rest] = segments;\n if (!first) {\n throw new Error(\"Index field JSON pointer must not be empty\");\n }\n\n const rootInfo = schemaIntrospector.getFieldTypeInfo(nodeKind, first);\n if (!rootInfo) {\n throw new Error(\n `Unknown field \"${first}\" for node \"${nodeKind}\" in index definition`,\n );\n }\n\n if (rest.length === 0) {\n return rootInfo;\n }\n\n const resolved = resolveFieldTypeInfoAtJsonPointer(\n rootInfo,\n jsonPointer(rest),\n );\n if (!resolved) {\n throw new Error(\n `Unknown JSON pointer \"${pointer}\" for node \"${nodeKind}\" in index definition`,\n );\n }\n\n return resolved;\n}\n\nfunction resolveEdgeFieldTypeInfoOrThrow(\n edgeKind: string,\n pointer: JsonPointer,\n schemaIntrospector: ReturnType<typeof createSchemaIntrospector>,\n): FieldTypeInfo {\n const segments = parseJsonPointer(pointer);\n const [first, ...rest] = segments;\n if (!first) {\n throw new Error(\"Index field JSON pointer must not be empty\");\n }\n\n const rootInfo = schemaIntrospector.getEdgeFieldTypeInfo(edgeKind, first);\n if (!rootInfo) {\n throw new Error(\n `Unknown field \"${first}\" for edge \"${edgeKind}\" in index definition`,\n );\n }\n\n if (rest.length === 0) {\n return rootInfo;\n }\n\n const resolved = resolveFieldTypeInfoAtJsonPointer(\n rootInfo,\n jsonPointer(rest),\n );\n if (!resolved) {\n throw new Error(\n `Unknown JSON pointer \"${pointer}\" for edge \"${edgeKind}\" in index definition`,\n );\n }\n\n return resolved;\n}\n\n// ============================================================\n// Default Name Generation\n// ============================================================\n\ntype DefaultNameParts = Readonly<{\n kind: KindEntity;\n kindName: string;\n unique: boolean;\n scope: IndexScope;\n direction: EdgeIndexDirection;\n fields: readonly string[];\n coveringFields: readonly string[];\n /**\n * Node-only, defaults to `[]` for edges. Folded into the hash/name only\n * when non-empty so indexes that don't use it keep byte-identical\n * default names to before this field existed.\n */\n keySystemColumns?: readonly string[];\n}>;\n\nfunction generateDefaultIndexName(parts: DefaultNameParts): string {\n const keySystemColumns = parts.keySystemColumns ?? [];\n const hash = fnv1aBase36(\n JSON.stringify({\n kind: parts.kind,\n kindName: parts.kindName,\n unique: parts.unique,\n scope: parts.scope,\n direction: parts.direction,\n fields: parts.fields,\n covering: parts.coveringFields,\n ...(keySystemColumns.length > 0 ? { keySystemColumns } : {}),\n }),\n );\n\n const nameParts = [\n \"idx\",\n \"tg\",\n parts.kind,\n sanitizeIdentifierComponent(parts.kindName),\n parts.fields.length > 0 ?\n sanitizeIdentifierComponent(parts.fields.join(\"_\"))\n : undefined,\n parts.coveringFields.length > 0 ?\n `cov_${sanitizeIdentifierComponent(parts.coveringFields.join(\"_\"))}`\n : undefined,\n keySystemColumns.length > 0 ?\n `sys_${sanitizeIdentifierComponent(keySystemColumns.join(\"_\"))}`\n : undefined,\n parts.direction === \"none\" ? undefined : parts.direction,\n parts.unique ? \"uniq\" : undefined,\n parts.scope === \"graphAndKind\" ?\n undefined\n : sanitizeIdentifierComponent(parts.scope),\n hash,\n ].filter((part) => part !== undefined);\n\n const joined = nameParts.join(\"_\");\n return joined.length <= MAX_PG_IDENTIFIER_LENGTH ?\n joined\n : `${joined.slice(0, TRUNCATED_IDENTIFIER_MAX_LENGTH)}_${hash}`;\n}\n\nfunction sanitizeIdentifierComponent(value: string): string {\n return value\n .toLowerCase()\n .replaceAll(/[^a-z0-9_]+/g, \"_\")\n .replaceAll(/^_+|_+$/g, \"\")\n .slice(0, IDENTIFIER_COMPONENT_MAX_LENGTH);\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkHAHNRASW_cjs = require('./chunk-HAHNRASW.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkKTBTSHU6_cjs = require('./chunk-KTBTSHU6.cjs');
|
|
5
5
|
|
|
6
6
|
// src/core/types.ts
|
|
7
7
|
var NODE_TYPE_BRAND = "__nodeType";
|
|
@@ -10,7 +10,7 @@ function assertNonEmptyId(value, path) {
|
|
|
10
10
|
if (value.length > 0) {
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
|
-
throw new
|
|
13
|
+
throw new chunkKTBTSHU6_cjs.ValidationError(
|
|
14
14
|
`${path} must be a non-empty string.`,
|
|
15
15
|
{
|
|
16
16
|
issues: [
|
|
@@ -136,7 +136,7 @@ function validateConstraintNarrowing(name, edgeType, registration) {
|
|
|
136
136
|
const builtInFromNames = new Set(edgeType.from.map((node) => node.kind));
|
|
137
137
|
for (const fromNode of registration.from) {
|
|
138
138
|
if (!builtInFromNames.has(fromNode.kind)) {
|
|
139
|
-
throw new
|
|
139
|
+
throw new chunkKTBTSHU6_cjs.ConfigurationError(
|
|
140
140
|
`Edge "${name}" registration has 'from' kind "${fromNode.kind}" not in edge's built-in domain: [${[...builtInFromNames].join(", ")}]`,
|
|
141
141
|
{
|
|
142
142
|
edgeName: name,
|
|
@@ -152,7 +152,7 @@ function validateConstraintNarrowing(name, edgeType, registration) {
|
|
|
152
152
|
const builtInToNames = new Set(edgeType.to.map((node) => node.kind));
|
|
153
153
|
for (const toNode of registration.to) {
|
|
154
154
|
if (!builtInToNames.has(toNode.kind)) {
|
|
155
|
-
throw new
|
|
155
|
+
throw new chunkKTBTSHU6_cjs.ConfigurationError(
|
|
156
156
|
`Edge "${name}" registration has 'to' kind "${toNode.kind}" not in edge's built-in range: [${[...builtInToNames].join(", ")}]`,
|
|
157
157
|
{
|
|
158
158
|
edgeName: name,
|
|
@@ -228,7 +228,7 @@ function normalizeIndexes(inputs, nodes, edges) {
|
|
|
228
228
|
assertKindRegistered(declaration, edgeKinds, "edge");
|
|
229
229
|
}
|
|
230
230
|
if (seenNames.has(declaration.name)) {
|
|
231
|
-
throw new
|
|
231
|
+
throw new chunkKTBTSHU6_cjs.ConfigurationError(
|
|
232
232
|
`Duplicate index name "${declaration.name}" in defineGraph({ indexes }). Index names must be unique within a graph.`,
|
|
233
233
|
{ indexName: declaration.name },
|
|
234
234
|
{
|
|
@@ -251,7 +251,7 @@ function assertKindRegistered(declaration, registeredKinds, entity) {
|
|
|
251
251
|
if (registeredKinds.has(declaration.kind)) return;
|
|
252
252
|
const slot = entity === "node" ? "nodes" : "edges";
|
|
253
253
|
const suggestion = entity === "node" ? `Add { ${declaration.kind}: { type: ${declaration.kind} } } to defineGraph({ nodes }) or remove the index from "indexes".` : `Register the edge in defineGraph({ edges }) or remove the index from "indexes".`;
|
|
254
|
-
throw new
|
|
254
|
+
throw new chunkKTBTSHU6_cjs.ConfigurationError(
|
|
255
255
|
`Index "${declaration.name}" references ${entity} kind "${declaration.kind}" which is not registered in this graph's "${slot}".`,
|
|
256
256
|
{
|
|
257
257
|
indexName: declaration.name,
|
|
@@ -288,5 +288,5 @@ exports.isGraphDef = isGraphDef;
|
|
|
288
288
|
exports.isKnownKind = isKnownKind;
|
|
289
289
|
exports.isNodeType = isNodeType;
|
|
290
290
|
exports.mergeVectorIndexes = mergeVectorIndexes;
|
|
291
|
-
//# sourceMappingURL=chunk-
|
|
292
|
-
//# sourceMappingURL=chunk-
|
|
291
|
+
//# sourceMappingURL=chunk-ZPCKPLMX.cjs.map
|
|
292
|
+
//# sourceMappingURL=chunk-ZPCKPLMX.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/types.ts","../src/indexes/auto-derive.ts","../src/core/define-graph.ts"],"names":["ValidationError","getEmbeddingIndex","isEmbeddingSchema","ConfigurationError"],"mappings":";;;;;;AAyCO,IAAM,eAAA,GAAkB;AAGxB,IAAM,eAAA,GAAkB;AAQ/B,SAAS,gBAAA,CAAiB,OAAe,IAAA,EAAoB;AAC3D,EAAA,IAAI,KAAA,CAAM,SAAS,CAAA,EAAG;AACpB,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,IAAIA,iCAAA;AAAA,IACR,GAAG,IAAI,CAAA,4BAAA,CAAA;AAAA,IACP;AAAA,MACE,MAAA,EAAQ;AAAA,QACN;AAAA,UACE,IAAA;AAAA,UACA,OAAA,EAAS;AAAA;AACX;AACF,KACF;AAAA,IACA;AAAA,MACE,UAAA,EACE;AAAA;AACJ,GACF;AACF;AAkFO,SAAS,SACd,KAAA,EACW;AACX,EAAA,gBAAA,CAAiB,OAAO,UAAU,CAAA;AAClC,EAAA,OAAO,KAAA;AACT;AA4EO,SAAS,SACd,KAAA,EACW;AACX,EAAA,gBAAA,CAAiB,OAAO,UAAU,CAAA;AAClC,EA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,MAAA,CAAO,KAAA,CAAM,KAAA,EAAO,IAAI,KAAK,MAAA,CAAO,MAAA,CAAO,KAAA,CAAM,KAAA,EAAO,IAAI,CAAA;AAC5E","file":"chunk-NT6ILURI.cjs","sourcesContent":["import { type z } from \"zod\";\n\nimport { ValidationError } from \"../errors\";\n\n// ============================================================\n// Cross-cutting Discriminators\n// ============================================================\n\n/**\n * Which side of the bipartite graph a kind lives on. Used everywhere a\n * function takes \"the entity that owns a kind\" — error metadata,\n * extension classifiers, removal queues, schema diffs.\n */\nexport type KindEntity = \"node\" | \"edge\";\n\n/**\n * Which physical surface an index targets. Vector indexes don't own a\n * kind directly (they back a per-`(kind, field)` typed embedding table\n * owned by the active `VectorStrategy`), but they participate in the same\n * materialization and diff pipelines, so they share this discriminator.\n *\n * `\"system\"` marks TypeGraph's own base-relation indexes\n * (`SYSTEM_INDEX_DECLARATIONS`) — graph-independent, but materialized and\n * status-tracked through the same pipeline; their status rows carry the\n * relation key (e.g. `\"recordedNodes\"`) in the `kind` column.\n */\nexport type IndexEntity = \"node\" | \"edge\" | \"vector\" | \"system\";\n\n/**\n * Field-level null-check operations that round-trip through persisted\n * documents (unique-constraint where clauses, index where clauses,\n * graph-extension where clauses, IsNullPredicate). Consolidated so a\n * single rename or extension touches one site.\n */\nexport type NullCheckOp = \"isNull\" | \"isNotNull\";\n\n// ============================================================\n// Brand Keys for Nominal Typing\n// ============================================================\n\n/** Brand key for NodeType */\nexport const NODE_TYPE_BRAND = \"__nodeType\" as const;\n\n/** Brand key for EdgeType */\nexport const EDGE_TYPE_BRAND = \"__edgeType\" as const;\n\n/** Brand symbol for NodeId */\ndeclare const __nodeId: unique symbol;\n\n/** Brand symbol for EdgeId */\ndeclare const __edgeId: unique symbol;\n\nfunction assertNonEmptyId(value: string, path: string): void {\n if (value.length > 0) {\n return;\n }\n\n throw new ValidationError(\n `${path} must be a non-empty string.`,\n {\n issues: [\n {\n path,\n message: \"Expected a non-empty string.\",\n },\n ],\n },\n {\n suggestion:\n \"Use a persisted node or edge id value, or let TypeGraph generate an id on create.\",\n },\n );\n}\n\n// ============================================================\n// Node Type\n// ============================================================\n\n/**\n * Any JSON-serializable value.\n *\n * Mirrors the JSON wire format: primitives, arrays, and string-keyed objects.\n * `null` is included because the JSON spec requires it for \"no value here\";\n * this is the one place in the public API that uses `null` over `undefined`.\n */\nexport type JsonValue =\n | null\n | string\n | number\n | boolean\n | readonly JsonValue[]\n | Readonly<{ [key: string]: JsonValue }>;\n\n/**\n * Consumer-owned per-kind annotations.\n *\n * Stable labels attached to a node or edge kind at definition time — UI hints,\n * audit policy, provenance pointers, tooling annotations.\n *\n * **Consumer-owned, fully.** TypeGraph never reads, validates, or interprets\n * values in this field. Consumers own the entire namespace; there are no\n * reserved keys or extension prefixes. Future library-owned per-kind state,\n * if needed, will use a separate sibling field rather than carving out keys\n * here.\n *\n * **Annotations participate in schema hashing.** Any change to an annotation\n * value (or adding/removing an annotation key) bumps the canonical schema\n * hash and is reported as a `safe`-severity diff by `getSchemaChanges`. If\n * you don't want versioning for a piece of state, do not put it here.\n *\n * Values must be JSON-serializable — `bigint`, `function`, `symbol`, `undefined`,\n * `Date`, and other class instances are rejected at definition time so they can\n * never silently break schema hashing or storage round-trips.\n */\nexport type KindAnnotations = Readonly<Record<string, JsonValue>>;\n\n/**\n * A node type definition.\n *\n * Created via `defineNode()`. Represents a type of node in the graph\n * with an associated Zod schema for properties.\n */\nexport type NodeType<\n K extends string = string,\n S extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>,\n> = Readonly<{\n [NODE_TYPE_BRAND]: true;\n kind: K;\n schema: S;\n description: string | undefined;\n annotations: KindAnnotations | undefined;\n}>;\n\n/**\n * Branded node ID type.\n *\n * Prevents mixing IDs from different node types at compile time.\n */\nexport type NodeId<N extends NodeType> = string &\n Readonly<{\n [__nodeId]: N;\n }>;\n\n/**\n * Brands a non-empty string as a {@link NodeId}.\n *\n * Use this when a persisted node id has round-tripped through untyped storage\n * or an external boundary and must be passed back to read/update/delete\n * surfaces such as `getById`, `getByIds`, `update`, or `delete`.\n * Write surfaces that mint or claim ids, such as `create({ id })` and\n * `upsertById`, intentionally accept plain strings.\n *\n * @throws {ValidationError} when `value` is empty.\n */\nexport function asNodeId<N extends NodeType = NodeType>(\n value: string,\n): NodeId<N> {\n assertNonEmptyId(value, \"asNodeId\");\n return value as NodeId<N>;\n}\n\n/**\n * Infer the props type from a NodeType.\n */\nexport type NodeProps<N extends NodeType> = z.infer<N[\"schema\"]>;\n\n// ============================================================\n// Edge Type\n// ============================================================\n\n/**\n * An edge type definition.\n *\n * Created via `defineEdge()`. Represents a type of edge in the graph\n * with an optional Zod schema for properties.\n *\n * Optionally includes `from` and `to` arrays that define the allowed\n * source and target node types (domain and range constraints).\n */\nexport type EdgeType<\n K extends string = string,\n S extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>,\n From extends readonly NodeType[] | undefined = undefined,\n To extends readonly NodeType[] | undefined = undefined,\n> = Readonly<{\n [EDGE_TYPE_BRAND]: true;\n kind: K;\n schema: S;\n description: string | undefined;\n annotations: KindAnnotations | undefined;\n from: From;\n to: To;\n}>;\n\n/**\n * Base edge type for use in constraints - accepts any from/to configuration.\n */\nexport type AnyEdgeType = EdgeType<\n string,\n z.ZodObject<z.ZodRawShape>,\n readonly NodeType[] | undefined,\n readonly NodeType[] | undefined\n>;\n\n/**\n * An edge type that has both from and to constraints defined.\n * Can be used directly in defineGraph without an EdgeRegistration wrapper.\n */\nexport type EdgeTypeWithEndpoints = EdgeType<\n string,\n z.ZodObject<z.ZodRawShape>,\n readonly NodeType[],\n readonly NodeType[]\n>;\n\n/**\n * Branded edge ID type.\n *\n * Prevents mixing IDs from different edge types at compile time.\n */\nexport type EdgeId<E extends AnyEdgeType = AnyEdgeType> = string &\n Readonly<{\n [__edgeId]: E;\n }>;\n\n/**\n * Brands a non-empty string as an {@link EdgeId}.\n *\n * Use this when a persisted edge id has round-tripped through untyped storage\n * or an external boundary and must be passed back to read/update/delete\n * surfaces such as `getById`, `getByIds`, `update`, or `delete`.\n * Write surfaces that mint ids intentionally accept plain strings.\n *\n * @throws {ValidationError} when `value` is empty.\n */\nexport function asEdgeId<E extends AnyEdgeType = AnyEdgeType>(\n value: string,\n): EdgeId<E> {\n assertNonEmptyId(value, \"asEdgeId\");\n return value as EdgeId<E>;\n}\n\n/**\n * Infer the props type from an EdgeType.\n */\nexport type EdgeProps<E extends AnyEdgeType> = z.infer<E[\"schema\"]>;\n\n// ============================================================\n// Configuration Types\n// ============================================================\n\n/**\n * Delete behaviors for nodes.\n */\nexport type DeleteBehavior = \"restrict\" | \"cascade\" | \"disconnect\";\n\n/**\n * Edge cardinality constraints.\n */\nexport type Cardinality =\n | \"many\" // No constraint (default)\n | \"one\" // At most one edge of this kind from any source node\n | \"unique\" // At most one edge of this kind between any (source, target) pair\n | \"oneActive\"; // At most one edge with valid_to IS NULL from any source\n\n/**\n * Endpoint existence modes for edge validation.\n */\nexport type EndpointExistence =\n | \"notDeleted\" // Endpoint deleted_at IS NULL (default)\n | \"currentlyValid\" // Endpoint not deleted AND temporally valid\n | \"ever\"; // Endpoint exists in any state\n\n/**\n * Temporal query modes.\n */\nexport type TemporalMode =\n | \"current\" // Valid now AND not deleted\n | \"asOf\" // Valid at specific date AND not deleted\n | \"includeEnded\" // All validity periods AND not deleted\n | \"includeTombstones\"; // Everything including soft-deleted\n\n/**\n * Uniqueness constraint scope.\n */\nexport type UniquenessScope =\n | \"kind\" // Unique within this exact kind only\n | \"kindWithSubClasses\"; // Unique across this kind and all subclasses\n\n/**\n * Collation for uniqueness constraints.\n */\nexport type Collation = \"binary\" | \"caseInsensitive\";\n\n// ============================================================\n// Uniqueness Constraint\n// ============================================================\n\n/**\n * Uniqueness constraint definition.\n */\nexport type UniqueConstraint<\n S extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>,\n> = Readonly<{\n name: string;\n fields: readonly (keyof z.infer<S> & string)[];\n where?: (\n props: UniqueConstraintPredicateBuilder<S>,\n ) => UniqueConstraintPredicate;\n scope: UniquenessScope;\n collation: Collation;\n}>;\n\n/**\n * Predicate builder for uniqueness constraint where clause.\n * Uses -? to make all fields required in the builder, even if optional in the schema.\n */\ntype UniqueConstraintPredicateBuilder<S extends z.ZodObject<z.ZodRawShape>> =\n Readonly<{\n [K in keyof z.infer<S>]-?: UniqueConstraintField;\n }>;\n\n/**\n * Field operations for uniqueness constraint predicates.\n */\ntype UniqueConstraintField = Readonly<{\n isNull: () => UniqueConstraintPredicate;\n isNotNull: () => UniqueConstraintPredicate;\n}>;\n\n/**\n * A uniqueness constraint predicate (internal representation).\n */\ntype UniqueConstraintPredicate = Readonly<{\n __type: \"unique_predicate\";\n field: string;\n op: NullCheckOp;\n}>;\n\n// ============================================================\n// Node Registration\n// ============================================================\n\n/**\n * Node registration in a graph definition.\n */\nexport type NodeRegistration<N extends NodeType = NodeType> = Readonly<{\n type: N;\n unique?: readonly UniqueConstraint<N[\"schema\"]>[];\n onDelete?: DeleteBehavior;\n}>;\n\n// ============================================================\n// Edge Registration\n// ============================================================\n\n/**\n * Edge registration in a graph definition.\n */\nexport type EdgeRegistration<\n E extends AnyEdgeType = AnyEdgeType,\n FromTypes extends NodeType = NodeType,\n ToTypes extends NodeType = NodeType,\n> = Readonly<{\n type: E;\n from: readonly FromTypes[];\n to: readonly ToTypes[];\n cardinality?: Cardinality;\n endpointExistence?: EndpointExistence;\n}>;\n\n// ============================================================\n// Graph Defaults\n// ============================================================\n\n/**\n * Default settings for a graph.\n */\nexport type GraphDefaults = Readonly<{\n onNodeDelete?: DeleteBehavior;\n temporalMode?: TemporalMode;\n}>;\n\n// ============================================================\n// Type Helpers\n// ============================================================\n\n/**\n * Checks if a value is a NodeType.\n */\nexport function isNodeType(value: unknown): value is NodeType {\n return (\n typeof value === \"object\" &&\n value !== null &&\n NODE_TYPE_BRAND in value &&\n (value as Record<string, unknown>)[NODE_TYPE_BRAND] === true\n );\n}\n\n/**\n * Checks if a value is an EdgeType.\n */\nexport function isEdgeType(value: unknown): value is AnyEdgeType {\n return (\n typeof value === \"object\" &&\n value !== null &&\n EDGE_TYPE_BRAND in value &&\n (value as Record<string, unknown>)[EDGE_TYPE_BRAND] === true\n );\n}\n\n/**\n * Checks if a value is an EdgeType with both from and to constraints defined.\n * Such edges can be used directly in defineGraph without an EdgeRegistration wrapper.\n */\nexport function isEdgeTypeWithEndpoints(\n value: unknown,\n): value is EdgeTypeWithEndpoints {\n return (\n isEdgeType(value) &&\n Array.isArray(value.from) &&\n value.from.length > 0 &&\n Array.isArray(value.to) &&\n value.to.length > 0\n );\n}\n","/**\n * Auto-derive vector index declarations from `embedding()` brands on\n * node schemas.\n *\n * Walks each node's top-level Zod shape, finds fields wrapped in\n * `embedding(dimensions, opts)` (including `.optional()` /\n * `.nullable()` wrappers), and emits one `VectorIndexDeclaration` per\n * (kind, field) pair. The declaration carries the resolved index\n * configuration from the embedding brand — metric, indexType, HNSW /\n * IVFFlat params — so the materializer doesn't need to reach back into\n * the Zod schema.\n *\n * Auto-derivation is intentionally limited to TOP-LEVEL embedding\n * fields. Embeddings nested inside object properties are out of scope\n * for v1 — vector slots are materialized as flat `(kind, fieldPath)`\n * storage units, and top-level fields keep that contract explicit.\n *\n * Explicit `defineVectorIndex(node, fieldPath, opts)` declarations\n * passed via `defineGraph({ indexes })` take precedence — when an\n * explicit declaration matches the same (kind, fieldPath) as an\n * auto-derived one, the explicit version wins. This lets consumers\n * override defaults without losing auto-derivation for other fields.\n */\n\nimport { type z } from \"zod\";\n\nimport {\n getEmbeddingIndex,\n isEmbeddingSchema,\n type ResolvedEmbeddingIndex,\n} from \"../core/embedding\";\nimport { type NodeRegistration } from \"../core/types\";\nimport { type IndexDeclaration, type VectorIndexDeclaration } from \"./types\";\n\n/**\n * Auto-derive vector index declarations from embedding brands on a\n * map of node registrations. Returns one declaration per\n * (kind, top-level field) pair. Empty array when no embeddings found.\n *\n * Cross-graph status-table disambiguation does NOT happen here — the\n * declaration name stays clean (`tg_vec_{kind}_{field}_{metric}`) so\n * `pg_indexes` and result-entry inspection are readable. The\n * materializer composes a graph-scoped key (`${graphId}::${name}`)\n * for status-table identity, applied uniformly to both auto-derived\n * and explicit `VectorIndexDeclaration` entries — see\n * `vectorStatusKey` in `store/materialize-indexes.ts`. This keeps\n * the disambiguation rule in one place that BOTH paths go through,\n * rather than depending on the auto-derive caller to produce a\n * graph-scoped name.\n */\nexport function autoDeriveVectorIndexes(\n nodes: Record<string, NodeRegistration>,\n): readonly VectorIndexDeclaration[] {\n const out: VectorIndexDeclaration[] = [];\n for (const registration of Object.values(nodes)) {\n const node = registration.type;\n const shape = readObjectShape(node.schema);\n if (shape === undefined) continue;\n for (const [fieldName, fieldSchema] of Object.entries(shape)) {\n const config = readEmbeddingIndex(fieldSchema);\n if (config === undefined) continue;\n const dimensions = readEmbeddingDimensions(fieldSchema);\n if (dimensions === undefined) continue;\n out.push(buildAutoDerived(node.kind, fieldName, dimensions, config));\n }\n }\n return out;\n}\n\n/**\n * Merge auto-derived declarations with explicit ones, preferring\n * explicit on (kind, fieldPath) collisions. Returns a flat list of all\n * indexes; non-vector entries from `explicit` pass through unchanged.\n */\nexport function mergeVectorIndexes(\n explicit: readonly IndexDeclaration[],\n autoDerived: readonly VectorIndexDeclaration[],\n): readonly IndexDeclaration[] {\n if (autoDerived.length === 0) return explicit;\n const explicitVectorKeys = new Set<string>();\n for (const declaration of explicit) {\n if (declaration.entity === \"vector\") {\n explicitVectorKeys.add(`${declaration.kind}|${declaration.fieldPath}`);\n }\n }\n const filteredAuto = autoDerived.filter(\n (entry) => !explicitVectorKeys.has(`${entry.kind}|${entry.fieldPath}`),\n );\n return [...explicit, ...filteredAuto];\n}\n\n/**\n * Generate the deterministic vector index name. The visible prefix\n * `tg_vec_<kind>_<field>_<metric>` keeps it scannable in result-entry\n * inspection and the `typegraph_index_materializations` table.\n *\n * Cross-graph disambiguation is handled separately at the\n * materialization boundary (see `vectorStatusKey`) so the declaration\n * name doesn't need to carry `graphId` — the same auto-derived name\n * is reusable across graphs and the materializer composes a\n * graph-scoped status key for both auto-derived and explicit entries\n * uniformly.\n */\nfunction buildAutoDerived(\n kind: string,\n fieldName: string,\n dimensions: number,\n config: ResolvedEmbeddingIndex,\n): VectorIndexDeclaration {\n const fieldPath = fieldName;\n return Object.freeze({\n entity: \"vector\" as const,\n name: `tg_vec_${sanitize(kind)}_${sanitize(fieldName)}_${config.metric}`,\n kind,\n fieldPath,\n dimensions,\n metric: config.metric,\n indexType: config.indexType,\n indexParams: Object.freeze({\n m: config.m,\n efConstruction: config.efConstruction,\n lists: config.lists,\n }),\n });\n}\n\nfunction sanitize(value: string): string {\n return value.replaceAll(/[^a-zA-Z0-9]/g, \"_\").toLowerCase();\n}\n\nfunction readObjectShape(\n schema: z.ZodType,\n): Record<string, z.ZodType> | undefined {\n if ((schema as { type?: string }).type !== \"object\") return undefined;\n const shape = (schema.def as { shape?: Record<string, z.ZodType> }).shape;\n return shape;\n}\n\nfunction readEmbeddingIndex(\n schema: z.ZodType,\n): ResolvedEmbeddingIndex | undefined {\n for (const candidate of unwrapChain(schema)) {\n const config = getEmbeddingIndex(candidate);\n if (config !== undefined) return config;\n }\n return undefined;\n}\n\nfunction readEmbeddingDimensions(schema: z.ZodType): number | undefined {\n for (const candidate of unwrapChain(schema)) {\n if (isEmbeddingSchema(candidate)) {\n return (candidate as unknown as Record<string, number>)[\n \"_embeddingDimensions\"\n ];\n }\n }\n return undefined;\n}\n\n/**\n * Yield the schema and every reachable inner schema by repeatedly\n * applying `.unwrap()` (Zod 4 optional/nullable/default) and\n * `.def.innerType` (some wrappers). Cycle-guarded by depth and\n * reference identity. Generators stop at the first non-unwrappable\n * schema OR after 8 levels — deeper wrapping is pathological and not\n * worth supporting.\n */\nfunction* unwrapChain(schema: z.ZodType): Generator<z.ZodType, void, void> {\n const seen = new Set<z.ZodType>();\n let current: z.ZodType | undefined = schema;\n let depth = 0;\n while (current !== undefined && !seen.has(current) && depth < 8) {\n seen.add(current);\n yield current;\n current = unwrapOnce(current);\n depth++;\n }\n}\n\nfunction unwrapOnce(schema: z.ZodType): z.ZodType | undefined {\n // Zod 4 wrappers expose `.unwrap()` on optional/nullable/default.\n const candidate = schema as unknown as { unwrap?: () => z.ZodType };\n if (typeof candidate.unwrap === \"function\") return candidate.unwrap();\n // Some wrappers expose the inner schema via `.def.innerType`.\n return (schema as unknown as { def?: { innerType?: z.ZodType } }).def\n ?.innerType;\n}\n","import { ConfigurationError } from \"../errors/index\";\nimport { type GraphExtension } from \"../graph-extension/extension-types\";\nimport {\n autoDeriveVectorIndexes,\n mergeVectorIndexes,\n} from \"../indexes/auto-derive\";\nimport { type IndexDeclaration } from \"../indexes/types\";\nimport { type OntologyRelation } from \"../ontology/types\";\nimport {\n type AnyEdgeType,\n type DeleteBehavior,\n type EdgeRegistration,\n type EdgeTypeWithEndpoints,\n type GraphDefaults,\n isEdgeType,\n isEdgeTypeWithEndpoints,\n type KindEntity,\n type NodeRegistration,\n type NodeType,\n type TemporalMode,\n} from \"./types\";\n\n// ============================================================\n// Graph Definition Brand Symbol\n// ============================================================\n\n/** Brand key for GraphDef */\nconst GRAPH_DEF_BRAND = \"__graphDef\" as const;\n\n// ============================================================\n// Edge Entry Types\n// ============================================================\n\n/**\n * An edge entry in the graph definition.\n * Can be:\n * - EdgeType directly (constrained or unconstrained)\n * - EdgeRegistration object (always works, can override/narrow defaults)\n */\ntype EdgeEntry = EdgeRegistration | AnyEdgeType;\n\n/**\n * Normalized edge map type - all entries become EdgeRegistration.\n * For bare EdgeTypes, constrained endpoints are extracted from the type;\n * unconstrained edges fall back to all node types in the graph.\n */\ntype NormalizedEdges<\n TNodes extends Record<string, NodeRegistration>,\n TEdges extends Record<string, EdgeEntry>,\n> = {\n [K in keyof TEdges]: TEdges[K] extends EdgeRegistration ? TEdges[K]\n : TEdges[K] extends AnyEdgeType ?\n EdgeRegistration<\n TEdges[K],\n TEdges[K][\"from\"] extends readonly (infer N extends NodeType)[] ? N\n : TNodes[keyof TNodes][\"type\"],\n TEdges[K][\"to\"] extends readonly (infer N extends NodeType)[] ? N\n : TNodes[keyof TNodes][\"type\"]\n >\n : never;\n};\n\n// ============================================================\n// Edge Normalization Functions\n// ============================================================\n\n/**\n * Validates that an EdgeRegistration's constraints don't widen beyond\n * the edge type's built-in domain/range constraints.\n */\nfunction validateConstraintNarrowing(\n name: string,\n edgeType: EdgeTypeWithEndpoints,\n registration: EdgeRegistration,\n): void {\n const builtInFromNames = new Set(edgeType.from.map((node) => node.kind));\n for (const fromNode of registration.from) {\n if (!builtInFromNames.has(fromNode.kind)) {\n throw new ConfigurationError(\n `Edge \"${name}\" registration has 'from' kind \"${fromNode.kind}\" ` +\n `not in edge's built-in domain: [${[...builtInFromNames].join(\", \")}]`,\n {\n edgeName: name,\n invalidFrom: fromNode.kind,\n allowedFrom: [...builtInFromNames],\n },\n {\n suggestion: `Edge registration can only narrow, not widen, the edge type's built-in constraints.`,\n },\n );\n }\n }\n\n const builtInToNames = new Set(edgeType.to.map((node) => node.kind));\n for (const toNode of registration.to) {\n if (!builtInToNames.has(toNode.kind)) {\n throw new ConfigurationError(\n `Edge \"${name}\" registration has 'to' kind \"${toNode.kind}\" ` +\n `not in edge's built-in range: [${[...builtInToNames].join(\", \")}]`,\n {\n edgeName: name,\n invalidTo: toNode.kind,\n allowedTo: [...builtInToNames],\n },\n {\n suggestion: `Edge registration can only narrow, not widen, the edge type's built-in constraints.`,\n },\n );\n }\n }\n}\n\n/**\n * Normalizes a single edge entry to EdgeRegistration.\n */\nfunction normalizeEdgeEntry(\n name: string,\n entry: EdgeEntry,\n allNodeTypes: readonly NodeType[],\n): EdgeRegistration {\n if (isEdgeType(entry)) {\n if (isEdgeTypeWithEndpoints(entry)) {\n // EdgeType with from/to — convert to EdgeRegistration\n return { type: entry, from: entry.from, to: entry.to };\n }\n // Unconstrained EdgeType — allow any→any\n return { type: entry, from: allNodeTypes, to: allNodeTypes };\n }\n\n // Already EdgeRegistration — validate narrowing if edge has built-in constraints\n if (isEdgeTypeWithEndpoints(entry.type)) {\n validateConstraintNarrowing(name, entry.type, entry);\n }\n\n return entry;\n}\n\n/**\n * Normalizes all edge entries to EdgeRegistration.\n */\nfunction normalizeEdges(\n edges: Record<string, EdgeEntry>,\n allNodeTypes: readonly NodeType[],\n): Record<string, EdgeRegistration> {\n const result: Record<string, EdgeRegistration> = {};\n for (const [name, entry] of Object.entries(edges)) {\n result[name] = normalizeEdgeEntry(name, entry, allNodeTypes);\n }\n return result;\n}\n\n// ============================================================\n// Graph Definition Configuration\n// ============================================================\n\n/**\n * Configuration for defineGraph.\n */\ntype GraphDefConfig<\n TNodes extends Record<string, NodeRegistration>,\n TEdges extends Record<string, EdgeEntry>,\n TOntology extends readonly OntologyRelation[],\n> = Readonly<{\n /** Unique identifier for this graph */\n id: string;\n /** Node registrations */\n nodes: TNodes;\n /** Edge registrations or EdgeTypes with built-in domain/range */\n edges: TEdges;\n /** Ontology relations */\n ontology?: TOntology;\n /** Graph-wide defaults */\n defaults?: GraphDefaults;\n /**\n * Index declarations attached to this graph.\n *\n * Accepts the outputs of `defineNodeIndex` / `defineEdgeIndex` (which\n * already return `IndexDeclaration` values) or pre-built declarations\n * reconstructed from a stored schema or graph extension.\n *\n * Validated at definition time: every index must reference a `kind`\n * that exists in `nodes` / `edges`, and index `name`s must be unique\n * within the graph.\n *\n * Index DDL is **not** generated by `defineGraph`. Indexes flow into\n * `SerializedSchema.indexes` so they can later be materialized via\n * `store.materializeIndexes()` — lifting the storage concern out of\n * the schema-version commit path.\n */\n indexes?: readonly IndexDeclaration[];\n}>;\n\n// ============================================================\n// Graph Definition Type\n// ============================================================\n\n/**\n * A graph definition.\n *\n * This is a compile-time artifact that describes the structure of a graph.\n * Use `createStore()` to create a runtime store from this definition.\n */\nexport type GraphDef<\n TNodes extends Record<string, NodeRegistration> = Record<\n string,\n NodeRegistration\n >,\n TEdges extends Record<string, EdgeRegistration> = Record<\n string,\n EdgeRegistration\n >,\n TOntology extends readonly OntologyRelation[] = readonly OntologyRelation[],\n> = Readonly<{\n [GRAPH_DEF_BRAND]: true;\n id: string;\n nodes: TNodes;\n edges: TEdges;\n ontology: TOntology;\n defaults: Readonly<{\n onNodeDelete: DeleteBehavior;\n temporalMode: TemporalMode;\n }>;\n /**\n * Index declarations attached to this graph. Preserves whatever the\n * caller passed to `defineGraph` (including an explicit empty array)\n * for introspection purposes.\n *\n * The serialized canonical form is order-canonicalized (sorted by\n * `name`) and treats `undefined` and `[]` as the same \"no slice\" form\n * — an empty array does not bump the schema hash, since indexes are\n * an unordered set keyed by name and `[]` carries no semantic meaning\n * that an absent slice doesn't.\n */\n indexes: readonly IndexDeclaration[] | undefined;\n /**\n * Graph extension this graph was merged with, if any. Set by\n * `mergeGraphExtension`; never set by `defineGraph` directly.\n * Exists solely so re-serialization is stable — the rest of the\n * system reads the merged kinds through `nodes` / `edges` /\n * `ontology` and never inspects this field. Absent on graphs that\n * have never been extended; legacy graphs hash byte-identically.\n */\n extension: GraphExtension | undefined;\n /**\n * Soft-deprecated kind names attached to this graph. Set by the\n * loader from the persisted schema and by `store.deprecateKinds(...)`\n * / `store.undeprecateKinds(...)`. A purely informational signal\n * surfaced for introspection — does not gate reads, writes, or\n * queries. Defaults to the empty set on freshly-defined graphs.\n */\n deprecatedKinds: ReadonlySet<string>;\n}>;\n\n// ============================================================\n// Type Helpers\n// ============================================================\n\n/**\n * Extract node kind names from a GraphDef.\n */\nexport type NodeKinds<G extends GraphDef> = keyof G[\"nodes\"] & string;\n\n/**\n * Extract edge kind names from a GraphDef.\n */\nexport type EdgeKinds<G extends GraphDef> = keyof G[\"edges\"] & string;\n\n/**\n * Get a NodeType from a GraphDef by kind name.\n */\nexport type GetNodeType<\n G extends GraphDef,\n K extends NodeKinds<G>,\n> = G[\"nodes\"][K][\"type\"];\n\n/**\n * Get an EdgeType from a GraphDef by kind name.\n */\nexport type GetEdgeType<\n G extends GraphDef,\n K extends EdgeKinds<G>,\n> = G[\"edges\"][K][\"type\"];\n\n/**\n * Get all NodeTypes from a GraphDef.\n */\nexport type AllNodeTypes<G extends GraphDef> = {\n [K in NodeKinds<G>]: G[\"nodes\"][K][\"type\"];\n}[NodeKinds<G>];\n\n/**\n * Get all EdgeTypes from a GraphDef.\n */\nexport type AllEdgeTypes<G extends GraphDef> = {\n [K in EdgeKinds<G>]: G[\"edges\"][K][\"type\"];\n}[EdgeKinds<G>];\n\n// ============================================================\n// Define Graph Function\n// ============================================================\n\n/**\n * Creates a graph definition.\n *\n * @example\n * ```typescript\n * const graph = defineGraph({\n * id: \"my_graph\",\n * nodes: {\n * Person: { type: Person },\n * Company: { type: Company },\n * },\n * edges: {\n * // Traditional EdgeRegistration syntax\n * worksAt: {\n * type: worksAt,\n * from: [Person],\n * to: [Company],\n * cardinality: \"many\",\n * },\n * // Or use EdgeType directly if it has from/to defined\n * knows, // EdgeType with built-in domain/range\n * },\n * ontology: [\n * subClassOf(Company, Organization),\n * disjointWith(Person, Organization),\n * ],\n * defaults: {\n * onNodeDelete: \"restrict\",\n * temporalMode: \"current\",\n * },\n * });\n * ```\n */\nexport function defineGraph<\n const TNodes extends Record<string, NodeRegistration<NodeType>>,\n const TEdges extends Record<string, EdgeEntry>,\n const TOntology extends readonly OntologyRelation[],\n>(\n config: GraphDefConfig<TNodes, TEdges, TOntology>,\n): GraphDef<TNodes, NormalizedEdges<TNodes, TEdges>, TOntology> {\n const defaults = {\n onNodeDelete: config.defaults?.onNodeDelete ?? \"restrict\",\n temporalMode: config.defaults?.temporalMode ?? \"current\",\n } as const;\n\n const allNodeTypes = Object.values(config.nodes).map((reg) => reg.type);\n const normalizedEdges = normalizeEdges(config.edges, allNodeTypes);\n // Vector indexes are auto-derived from `embedding()` brands on node\n // schemas (see `autoDeriveVectorIndexes`). Explicit declarations\n // passed via `defineGraph({ indexes })` win on (kind, fieldPath)\n // collisions so consumers can override defaults — see\n // `mergeVectorIndexes`. The merged list flows through\n // `normalizeIndexes` for the standard kind-registered + unique-name\n // checks.\n //\n // Preservation rule: if the consumer never passed `indexes` at all\n // AND no embedding brands exist, leave `graph.indexes` undefined to\n // keep the introspection surface stable for legacy graphs. If the\n // consumer passed an explicit `[]`, surface it as `[]` (not\n // `undefined`) to match the contract pinned by the\n // \"preserves an explicit empty indexes array\" test.\n const autoVectorIndexes = autoDeriveVectorIndexes(config.nodes);\n const explicitProvided = config.indexes !== undefined;\n const mergedIndexes = mergeVectorIndexes(\n config.indexes ?? [],\n autoVectorIndexes,\n );\n const indexes =\n !explicitProvided && mergedIndexes.length === 0 ?\n undefined\n : normalizeIndexes(mergedIndexes, config.nodes, normalizedEdges);\n\n return Object.freeze({\n [GRAPH_DEF_BRAND]: true as const,\n id: config.id,\n nodes: config.nodes,\n edges: normalizedEdges,\n ontology: config.ontology ?? ([] as unknown as TOntology),\n defaults,\n indexes,\n extension: undefined,\n deprecatedKinds: EMPTY_DEPRECATED_KINDS,\n }) as GraphDef<TNodes, NormalizedEdges<TNodes, TEdges>, TOntology>;\n}\n\n// Sharing one frozen empty Set keeps the canonical-form hash stable\n// across graphs that never deprecate any kinds.\nconst EMPTY_DEPRECATED_KINDS: ReadonlySet<string> = Object.freeze(\n new Set<string>(),\n);\n\n// ============================================================\n// Index Normalization\n// ============================================================\n\n/**\n * Validates the `indexes` config slice:\n *\n * - Every index references a kind that exists in the graph's `nodes`\n * (for node indexes) or `edges` (for edge indexes).\n * - Index `name`s are unique within the graph.\n */\nfunction normalizeIndexes(\n inputs: readonly IndexDeclaration[],\n nodes: Record<string, NodeRegistration>,\n edges: Record<string, EdgeRegistration>,\n): readonly IndexDeclaration[] {\n if (inputs.length === 0) {\n return [];\n }\n\n const nodeKinds = collectKinds(nodes);\n const edgeKinds = collectKinds(edges);\n const seenNames = new Set<string>();\n\n for (const declaration of inputs) {\n if (declaration.entity === \"node\" || declaration.entity === \"vector\") {\n // Vector indexes attach to node kinds (the embedding lives on a\n // node field). Validation reuses the node-kind check.\n assertKindRegistered(declaration, nodeKinds, \"node\");\n } else {\n assertKindRegistered(declaration, edgeKinds, \"edge\");\n }\n\n if (seenNames.has(declaration.name)) {\n throw new ConfigurationError(\n `Duplicate index name \"${declaration.name}\" in defineGraph({ indexes }). ` +\n `Index names must be unique within a graph.`,\n { indexName: declaration.name },\n {\n suggestion: `Pass an explicit { name: \"...\" } to disambiguate.`,\n },\n );\n }\n seenNames.add(declaration.name);\n }\n\n return inputs;\n}\n\nfunction collectKinds(\n registrations: Record<string, { type: { kind: string } }>,\n): ReadonlySet<string> {\n const kinds = new Set<string>();\n for (const registration of Object.values(registrations)) {\n kinds.add(registration.type.kind);\n }\n return kinds;\n}\n\nfunction assertKindRegistered(\n declaration: IndexDeclaration,\n registeredKinds: ReadonlySet<string>,\n entity: KindEntity,\n): void {\n if (registeredKinds.has(declaration.kind)) return;\n\n const slot = entity === \"node\" ? \"nodes\" : \"edges\";\n const suggestion =\n entity === \"node\" ?\n `Add { ${declaration.kind}: { type: ${declaration.kind} } } to defineGraph({ nodes }) ` +\n `or remove the index from \"indexes\".`\n : `Register the edge in defineGraph({ edges }) or remove the index from \"indexes\".`;\n\n throw new ConfigurationError(\n `Index \"${declaration.name}\" references ${entity} kind \"${declaration.kind}\" ` +\n `which is not registered in this graph's \"${slot}\".`,\n {\n indexName: declaration.name,\n referencedKind: declaration.kind,\n availableKinds: [...registeredKinds],\n },\n { suggestion },\n );\n}\n\n// ============================================================\n// Graph Definition Utilities\n// ============================================================\n\n/**\n * Checks if a value is a GraphDef.\n */\nexport function isGraphDef(value: unknown): value is GraphDef {\n return (\n typeof value === \"object\" &&\n value !== null &&\n GRAPH_DEF_BRAND in value &&\n (value as Record<string, unknown>)[GRAPH_DEF_BRAND] === true\n );\n}\n\n/**\n * Gets all node kind names from a GraphDef.\n */\nexport function getNodeKinds<G extends GraphDef>(\n graph: G,\n): readonly (keyof G[\"nodes\"] & string)[] {\n return Object.keys(graph.nodes);\n}\n\n/**\n * Gets all edge kind names from a GraphDef.\n */\nexport function getEdgeKinds<G extends GraphDef>(\n graph: G,\n): readonly (keyof G[\"edges\"] & string)[] {\n return Object.keys(graph.edges);\n}\n\n/**\n * Returns true when `name` is registered as either a node or edge kind\n * on the given graph.\n */\nexport function isKnownKind(graph: GraphDef, name: string): boolean {\n return Object.hasOwn(graph.nodes, name) || Object.hasOwn(graph.edges, name);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/core/types.ts","../src/indexes/auto-derive.ts","../src/core/define-graph.ts"],"names":["ValidationError","getEmbeddingIndex","isEmbeddingSchema","ConfigurationError"],"mappings":";;;;;;AAyCO,IAAM,eAAA,GAAkB;AAGxB,IAAM,eAAA,GAAkB;AAQ/B,SAAS,gBAAA,CAAiB,OAAe,IAAA,EAAoB;AAC3D,EAAA,IAAI,KAAA,CAAM,SAAS,CAAA,EAAG;AACpB,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,IAAIA,iCAAA;AAAA,IACR,GAAG,IAAI,CAAA,4BAAA,CAAA;AAAA,IACP;AAAA,MACE,MAAA,EAAQ;AAAA,QACN;AAAA,UACE,IAAA;AAAA,UACA,OAAA,EAAS;AAAA;AACX;AACF,KACF;AAAA,IACA;AAAA,MACE,UAAA,EACE;AAAA;AACJ,GACF;AACF;AAkFO,SAAS,SACd,KAAA,EACW;AACX,EAAA,gBAAA,CAAiB,OAAO,UAAU,CAAA;AAClC,EAAA,OAAO,KAAA;AACT;AA4EO,SAAS,SACd,KAAA,EACW;AACX,EAAA,gBAAA,CAAiB,OAAO,UAAU,CAAA;AAClC,EAAA,OAAO,KAAA;AACT;AAsJO,SAAS,WAAW,KAAA,EAAmC;AAC5D,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,eAAA,IAAmB,KAAA,IAClB,KAAA,CAAkC,eAAe,CAAA,KAAM,IAAA;AAE5D;AAKO,SAAS,WAAW,KAAA,EAAsC;AAC/D,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,eAAA,IAAmB,KAAA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MAAM,UAAA,GACJ,WAAW,MAAA,GACT,CAAA,MAAA,EAAS,YAAY,IAAI,CAAA,UAAA,EAAa,WAAA,CAAY,IAAI,CAAA,kEAAA,CAAA,GAEtD,CAAA,+EAAA,CAAA;AAEJ,EAAA,MAAM,IAAIA,oCAAA;AAAA,IACR,CAAA,OAAA,EAAU,YAAY,IAAI,CAAA,aAAA,EAAgB,MAAM,CAAA,OAAA,EAAU,WAAA,CAAY,IAAI,CAAA,2CAAA,EAC5B,IAAI,CAAA,EAAA,CAAA;AAAA,IAClD;AAAA,MACE,WAAW,WAAA,CAAY,IAAA;AAAA,MACvB,gBAAgB,WAAA,CAAY,IAAA;AAAA,MAC5B,cAAA,EAAgB,CAAC,GAAG,eAAe;AAAA,KACrC;AAAA,IACA,EAAE,UAAA;AAAW,GACf;AACF;AASO,SAAS,WAAW,KAAA,EAAmC;AAC5D,EAAA,OACE,OAAO,UAAU,QAAA,IACjB,KAAA,KAAU,QACV,eAAA,IAAmB,KAAA,IAClB,KAAA,CAAkC,eAAe,CAAA,KAAM,IAAA;AAE5D;AAKO,SAAS,aACd,KAAA,EACwC;AACxC,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,KAAK,CAAA;AAChC;AAKO,SAAS,aACd,KAAA,EACwC;AACxC,EAAA,OAAO,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,KAAK,CAAA;AAChC;AAMO,SAAS,WAAA,CAAY,OAAiB,IAAA,EAAuB;AAClE,EAAA,OAAO,MAAA,CAAO,MAAA,CAAO,KAAA,CAAM,KAAA,EAAO,IAAI,KAAK,MAAA,CAAO,MAAA,CAAO,KAAA,CAAM,KAAA,EAAO,IAAI,CAAA;AAC5E","file":"chunk-ZPCKPLMX.cjs","sourcesContent":["import { type z } from \"zod\";\n\nimport { ValidationError } from \"../errors\";\n\n// ============================================================\n// Cross-cutting Discriminators\n// ============================================================\n\n/**\n * Which side of the bipartite graph a kind lives on. Used everywhere a\n * function takes \"the entity that owns a kind\" — error metadata,\n * extension classifiers, removal queues, schema diffs.\n */\nexport type KindEntity = \"node\" | \"edge\";\n\n/**\n * Which physical surface an index targets. Vector indexes don't own a\n * kind directly (they back a per-`(kind, field)` typed embedding table\n * owned by the active `VectorStrategy`), but they participate in the same\n * materialization and diff pipelines, so they share this discriminator.\n *\n * `\"system\"` marks TypeGraph's own base-relation indexes\n * (`SYSTEM_INDEX_DECLARATIONS`) — graph-independent, but materialized and\n * status-tracked through the same pipeline; their status rows carry the\n * relation key (e.g. `\"recordedNodes\"`) in the `kind` column.\n */\nexport type IndexEntity = \"node\" | \"edge\" | \"vector\" | \"system\";\n\n/**\n * Field-level null-check operations that round-trip through persisted\n * documents (unique-constraint where clauses, index where clauses,\n * graph-extension where clauses, IsNullPredicate). Consolidated so a\n * single rename or extension touches one site.\n */\nexport type NullCheckOp = \"isNull\" | \"isNotNull\";\n\n// ============================================================\n// Brand Keys for Nominal Typing\n// ============================================================\n\n/** Brand key for NodeType */\nexport const NODE_TYPE_BRAND = \"__nodeType\" as const;\n\n/** Brand key for EdgeType */\nexport const EDGE_TYPE_BRAND = \"__edgeType\" as const;\n\n/** Brand symbol for NodeId */\ndeclare const __nodeId: unique symbol;\n\n/** Brand symbol for EdgeId */\ndeclare const __edgeId: unique symbol;\n\nfunction assertNonEmptyId(value: string, path: string): void {\n if (value.length > 0) {\n return;\n }\n\n throw new ValidationError(\n `${path} must be a non-empty string.`,\n {\n issues: [\n {\n path,\n message: \"Expected a non-empty string.\",\n },\n ],\n },\n {\n suggestion:\n \"Use a persisted node or edge id value, or let TypeGraph generate an id on create.\",\n },\n );\n}\n\n// ============================================================\n// Node Type\n// ============================================================\n\n/**\n * Any JSON-serializable value.\n *\n * Mirrors the JSON wire format: primitives, arrays, and string-keyed objects.\n * `null` is included because the JSON spec requires it for \"no value here\";\n * this is the one place in the public API that uses `null` over `undefined`.\n */\nexport type JsonValue =\n | null\n | string\n | number\n | boolean\n | readonly JsonValue[]\n | Readonly<{ [key: string]: JsonValue }>;\n\n/**\n * Consumer-owned per-kind annotations.\n *\n * Stable labels attached to a node or edge kind at definition time — UI hints,\n * audit policy, provenance pointers, tooling annotations.\n *\n * **Consumer-owned, fully.** TypeGraph never reads, validates, or interprets\n * values in this field. Consumers own the entire namespace; there are no\n * reserved keys or extension prefixes. Future library-owned per-kind state,\n * if needed, will use a separate sibling field rather than carving out keys\n * here.\n *\n * **Annotations participate in schema hashing.** Any change to an annotation\n * value (or adding/removing an annotation key) bumps the canonical schema\n * hash and is reported as a `safe`-severity diff by `getSchemaChanges`. If\n * you don't want versioning for a piece of state, do not put it here.\n *\n * Values must be JSON-serializable — `bigint`, `function`, `symbol`, `undefined`,\n * `Date`, and other class instances are rejected at definition time so they can\n * never silently break schema hashing or storage round-trips.\n */\nexport type KindAnnotations = Readonly<Record<string, JsonValue>>;\n\n/**\n * A node type definition.\n *\n * Created via `defineNode()`. Represents a type of node in the graph\n * with an associated Zod schema for properties.\n */\nexport type NodeType<\n K extends string = string,\n S extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>,\n> = Readonly<{\n [NODE_TYPE_BRAND]: true;\n kind: K;\n schema: S;\n description: string | undefined;\n annotations: KindAnnotations | undefined;\n}>;\n\n/**\n * Branded node ID type.\n *\n * Prevents mixing IDs from different node types at compile time.\n */\nexport type NodeId<N extends NodeType> = string &\n Readonly<{\n [__nodeId]: N;\n }>;\n\n/**\n * Brands a non-empty string as a {@link NodeId}.\n *\n * Use this when a persisted node id has round-tripped through untyped storage\n * or an external boundary and must be passed back to read/update/delete\n * surfaces such as `getById`, `getByIds`, `update`, or `delete`.\n * Write surfaces that mint or claim ids, such as `create({ id })` and\n * `upsertById`, intentionally accept plain strings.\n *\n * @throws {ValidationError} when `value` is empty.\n */\nexport function asNodeId<N extends NodeType = NodeType>(\n value: string,\n): NodeId<N> {\n assertNonEmptyId(value, \"asNodeId\");\n return value as NodeId<N>;\n}\n\n/**\n * Infer the props type from a NodeType.\n */\nexport type NodeProps<N extends NodeType> = z.infer<N[\"schema\"]>;\n\n// ============================================================\n// Edge Type\n// ============================================================\n\n/**\n * An edge type definition.\n *\n * Created via `defineEdge()`. Represents a type of edge in the graph\n * with an optional Zod schema for properties.\n *\n * Optionally includes `from` and `to` arrays that define the allowed\n * source and target node types (domain and range constraints).\n */\nexport type EdgeType<\n K extends string = string,\n S extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>,\n From extends readonly NodeType[] | undefined = undefined,\n To extends readonly NodeType[] | undefined = undefined,\n> = Readonly<{\n [EDGE_TYPE_BRAND]: true;\n kind: K;\n schema: S;\n description: string | undefined;\n annotations: KindAnnotations | undefined;\n from: From;\n to: To;\n}>;\n\n/**\n * Base edge type for use in constraints - accepts any from/to configuration.\n */\nexport type AnyEdgeType = EdgeType<\n string,\n z.ZodObject<z.ZodRawShape>,\n readonly NodeType[] | undefined,\n readonly NodeType[] | undefined\n>;\n\n/**\n * An edge type that has both from and to constraints defined.\n * Can be used directly in defineGraph without an EdgeRegistration wrapper.\n */\nexport type EdgeTypeWithEndpoints = EdgeType<\n string,\n z.ZodObject<z.ZodRawShape>,\n readonly NodeType[],\n readonly NodeType[]\n>;\n\n/**\n * Branded edge ID type.\n *\n * Prevents mixing IDs from different edge types at compile time.\n */\nexport type EdgeId<E extends AnyEdgeType = AnyEdgeType> = string &\n Readonly<{\n [__edgeId]: E;\n }>;\n\n/**\n * Brands a non-empty string as an {@link EdgeId}.\n *\n * Use this when a persisted edge id has round-tripped through untyped storage\n * or an external boundary and must be passed back to read/update/delete\n * surfaces such as `getById`, `getByIds`, `update`, or `delete`.\n * Write surfaces that mint ids intentionally accept plain strings.\n *\n * @throws {ValidationError} when `value` is empty.\n */\nexport function asEdgeId<E extends AnyEdgeType = AnyEdgeType>(\n value: string,\n): EdgeId<E> {\n assertNonEmptyId(value, \"asEdgeId\");\n return value as EdgeId<E>;\n}\n\n/**\n * Infer the props type from an EdgeType.\n */\nexport type EdgeProps<E extends AnyEdgeType> = z.infer<E[\"schema\"]>;\n\n// ============================================================\n// Configuration Types\n// ============================================================\n\n/**\n * Delete behaviors for nodes.\n */\nexport type DeleteBehavior = \"restrict\" | \"cascade\" | \"disconnect\";\n\n/**\n * Edge cardinality constraints.\n */\nexport type Cardinality =\n | \"many\" // No constraint (default)\n | \"one\" // At most one edge of this kind from any source node\n | \"unique\" // At most one edge of this kind between any (source, target) pair\n | \"oneActive\"; // At most one edge with valid_to IS NULL from any source\n\n/**\n * Endpoint existence modes for edge validation.\n */\nexport type EndpointExistence =\n | \"notDeleted\" // Endpoint deleted_at IS NULL (default)\n | \"currentlyValid\" // Endpoint not deleted AND temporally valid\n | \"ever\"; // Endpoint exists in any state\n\n/**\n * Temporal query modes.\n */\nexport type TemporalMode =\n | \"current\" // Valid now AND not deleted\n | \"asOf\" // Valid at specific date AND not deleted\n | \"includeEnded\" // All validity periods AND not deleted\n | \"includeTombstones\"; // Everything including soft-deleted\n\n/**\n * Uniqueness constraint scope.\n */\nexport type UniquenessScope =\n | \"kind\" // Unique within this exact kind only\n | \"kindWithSubClasses\"; // Unique across this kind and all subclasses\n\n/**\n * Collation for uniqueness constraints.\n */\nexport type Collation = \"binary\" | \"caseInsensitive\";\n\n// ============================================================\n// Uniqueness Constraint\n// ============================================================\n\n/**\n * Uniqueness constraint definition.\n */\nexport type UniqueConstraint<\n S extends z.ZodObject<z.ZodRawShape> = z.ZodObject<z.ZodRawShape>,\n> = Readonly<{\n name: string;\n fields: readonly (keyof z.infer<S> & string)[];\n where?: (\n props: UniqueConstraintPredicateBuilder<S>,\n ) => UniqueConstraintPredicate;\n scope: UniquenessScope;\n collation: Collation;\n}>;\n\n/**\n * Predicate builder for uniqueness constraint where clause.\n * Uses -? to make all fields required in the builder, even if optional in the schema.\n */\ntype UniqueConstraintPredicateBuilder<S extends z.ZodObject<z.ZodRawShape>> =\n Readonly<{\n [K in keyof z.infer<S>]-?: UniqueConstraintField;\n }>;\n\n/**\n * Field operations for uniqueness constraint predicates.\n */\ntype UniqueConstraintField = Readonly<{\n isNull: () => UniqueConstraintPredicate;\n isNotNull: () => UniqueConstraintPredicate;\n}>;\n\n/**\n * A uniqueness constraint predicate (internal representation).\n */\ntype UniqueConstraintPredicate = Readonly<{\n __type: \"unique_predicate\";\n field: string;\n op: NullCheckOp;\n}>;\n\n// ============================================================\n// Node Registration\n// ============================================================\n\n/**\n * Node registration in a graph definition.\n */\nexport type NodeRegistration<N extends NodeType = NodeType> = Readonly<{\n type: N;\n unique?: readonly UniqueConstraint<N[\"schema\"]>[];\n onDelete?: DeleteBehavior;\n}>;\n\n// ============================================================\n// Edge Registration\n// ============================================================\n\n/**\n * Edge registration in a graph definition.\n */\nexport type EdgeRegistration<\n E extends AnyEdgeType = AnyEdgeType,\n FromTypes extends NodeType = NodeType,\n ToTypes extends NodeType = NodeType,\n> = Readonly<{\n type: E;\n from: readonly FromTypes[];\n to: readonly ToTypes[];\n cardinality?: Cardinality;\n endpointExistence?: EndpointExistence;\n}>;\n\n// ============================================================\n// Graph Defaults\n// ============================================================\n\n/**\n * Default settings for a graph.\n */\nexport type GraphDefaults = Readonly<{\n onNodeDelete?: DeleteBehavior;\n temporalMode?: TemporalMode;\n}>;\n\n// ============================================================\n// Type Helpers\n// ============================================================\n\n/**\n * Checks if a value is a NodeType.\n */\nexport function isNodeType(value: unknown): value is NodeType {\n return (\n typeof value === \"object\" &&\n value !== null &&\n NODE_TYPE_BRAND in value &&\n (value as Record<string, unknown>)[NODE_TYPE_BRAND] === true\n );\n}\n\n/**\n * Checks if a value is an EdgeType.\n */\nexport function isEdgeType(value: unknown): value is AnyEdgeType {\n return (\n typeof value === \"object\" &&\n value !== null &&\n EDGE_TYPE_BRAND in value &&\n (value as Record<string, unknown>)[EDGE_TYPE_BRAND] === true\n );\n}\n\n/**\n * Checks if a value is an EdgeType with both from and to constraints defined.\n * Such edges can be used directly in defineGraph without an EdgeRegistration wrapper.\n */\nexport function isEdgeTypeWithEndpoints(\n value: unknown,\n): value is EdgeTypeWithEndpoints {\n return (\n isEdgeType(value) &&\n Array.isArray(value.from) &&\n value.from.length > 0 &&\n Array.isArray(value.to) &&\n value.to.length > 0\n );\n}\n","/**\n * Auto-derive vector index declarations from `embedding()` brands on\n * node schemas.\n *\n * Walks each node's top-level Zod shape, finds fields wrapped in\n * `embedding(dimensions, opts)` (including `.optional()` /\n * `.nullable()` wrappers), and emits one `VectorIndexDeclaration` per\n * (kind, field) pair. The declaration carries the resolved index\n * configuration from the embedding brand — metric, indexType, HNSW /\n * IVFFlat params — so the materializer doesn't need to reach back into\n * the Zod schema.\n *\n * Auto-derivation is intentionally limited to TOP-LEVEL embedding\n * fields. Embeddings nested inside object properties are out of scope\n * for v1 — vector slots are materialized as flat `(kind, fieldPath)`\n * storage units, and top-level fields keep that contract explicit.\n *\n * Explicit `defineVectorIndex(node, fieldPath, opts)` declarations\n * passed via `defineGraph({ indexes })` take precedence — when an\n * explicit declaration matches the same (kind, fieldPath) as an\n * auto-derived one, the explicit version wins. This lets consumers\n * override defaults without losing auto-derivation for other fields.\n */\n\nimport { type z } from \"zod\";\n\nimport {\n getEmbeddingIndex,\n isEmbeddingSchema,\n type ResolvedEmbeddingIndex,\n} from \"../core/embedding\";\nimport { type NodeRegistration } from \"../core/types\";\nimport { type IndexDeclaration, type VectorIndexDeclaration } from \"./types\";\n\n/**\n * Auto-derive vector index declarations from embedding brands on a\n * map of node registrations. Returns one declaration per\n * (kind, top-level field) pair. Empty array when no embeddings found.\n *\n * Cross-graph status-table disambiguation does NOT happen here — the\n * declaration name stays clean (`tg_vec_{kind}_{field}_{metric}`) so\n * `pg_indexes` and result-entry inspection are readable. The\n * materializer composes a graph-scoped key (`${graphId}::${name}`)\n * for status-table identity, applied uniformly to both auto-derived\n * and explicit `VectorIndexDeclaration` entries — see\n * `vectorStatusKey` in `store/materialize-indexes.ts`. This keeps\n * the disambiguation rule in one place that BOTH paths go through,\n * rather than depending on the auto-derive caller to produce a\n * graph-scoped name.\n */\nexport function autoDeriveVectorIndexes(\n nodes: Record<string, NodeRegistration>,\n): readonly VectorIndexDeclaration[] {\n const out: VectorIndexDeclaration[] = [];\n for (const registration of Object.values(nodes)) {\n const node = registration.type;\n const shape = readObjectShape(node.schema);\n if (shape === undefined) continue;\n for (const [fieldName, fieldSchema] of Object.entries(shape)) {\n const config = readEmbeddingIndex(fieldSchema);\n if (config === undefined) continue;\n const dimensions = readEmbeddingDimensions(fieldSchema);\n if (dimensions === undefined) continue;\n out.push(buildAutoDerived(node.kind, fieldName, dimensions, config));\n }\n }\n return out;\n}\n\n/**\n * Merge auto-derived declarations with explicit ones, preferring\n * explicit on (kind, fieldPath) collisions. Returns a flat list of all\n * indexes; non-vector entries from `explicit` pass through unchanged.\n */\nexport function mergeVectorIndexes(\n explicit: readonly IndexDeclaration[],\n autoDerived: readonly VectorIndexDeclaration[],\n): readonly IndexDeclaration[] {\n if (autoDerived.length === 0) return explicit;\n const explicitVectorKeys = new Set<string>();\n for (const declaration of explicit) {\n if (declaration.entity === \"vector\") {\n explicitVectorKeys.add(`${declaration.kind}|${declaration.fieldPath}`);\n }\n }\n const filteredAuto = autoDerived.filter(\n (entry) => !explicitVectorKeys.has(`${entry.kind}|${entry.fieldPath}`),\n );\n return [...explicit, ...filteredAuto];\n}\n\n/**\n * Generate the deterministic vector index name. The visible prefix\n * `tg_vec_<kind>_<field>_<metric>` keeps it scannable in result-entry\n * inspection and the `typegraph_index_materializations` table.\n *\n * Cross-graph disambiguation is handled separately at the\n * materialization boundary (see `vectorStatusKey`) so the declaration\n * name doesn't need to carry `graphId` — the same auto-derived name\n * is reusable across graphs and the materializer composes a\n * graph-scoped status key for both auto-derived and explicit entries\n * uniformly.\n */\nfunction buildAutoDerived(\n kind: string,\n fieldName: string,\n dimensions: number,\n config: ResolvedEmbeddingIndex,\n): VectorIndexDeclaration {\n const fieldPath = fieldName;\n return Object.freeze({\n entity: \"vector\" as const,\n name: `tg_vec_${sanitize(kind)}_${sanitize(fieldName)}_${config.metric}`,\n kind,\n fieldPath,\n dimensions,\n metric: config.metric,\n indexType: config.indexType,\n indexParams: Object.freeze({\n m: config.m,\n efConstruction: config.efConstruction,\n lists: config.lists,\n }),\n });\n}\n\nfunction sanitize(value: string): string {\n return value.replaceAll(/[^a-zA-Z0-9]/g, \"_\").toLowerCase();\n}\n\nfunction readObjectShape(\n schema: z.ZodType,\n): Record<string, z.ZodType> | undefined {\n if ((schema as { type?: string }).type !== \"object\") return undefined;\n const shape = (schema.def as { shape?: Record<string, z.ZodType> }).shape;\n return shape;\n}\n\nfunction readEmbeddingIndex(\n schema: z.ZodType,\n): ResolvedEmbeddingIndex | undefined {\n for (const candidate of unwrapChain(schema)) {\n const config = getEmbeddingIndex(candidate);\n if (config !== undefined) return config;\n }\n return undefined;\n}\n\nfunction readEmbeddingDimensions(schema: z.ZodType): number | undefined {\n for (const candidate of unwrapChain(schema)) {\n if (isEmbeddingSchema(candidate)) {\n return (candidate as unknown as Record<string, number>)[\n \"_embeddingDimensions\"\n ];\n }\n }\n return undefined;\n}\n\n/**\n * Yield the schema and every reachable inner schema by repeatedly\n * applying `.unwrap()` (Zod 4 optional/nullable/default) and\n * `.def.innerType` (some wrappers). Cycle-guarded by depth and\n * reference identity. Generators stop at the first non-unwrappable\n * schema OR after 8 levels — deeper wrapping is pathological and not\n * worth supporting.\n */\nfunction* unwrapChain(schema: z.ZodType): Generator<z.ZodType, void, void> {\n const seen = new Set<z.ZodType>();\n let current: z.ZodType | undefined = schema;\n let depth = 0;\n while (current !== undefined && !seen.has(current) && depth < 8) {\n seen.add(current);\n yield current;\n current = unwrapOnce(current);\n depth++;\n }\n}\n\nfunction unwrapOnce(schema: z.ZodType): z.ZodType | undefined {\n // Zod 4 wrappers expose `.unwrap()` on optional/nullable/default.\n const candidate = schema as unknown as { unwrap?: () => z.ZodType };\n if (typeof candidate.unwrap === \"function\") return candidate.unwrap();\n // Some wrappers expose the inner schema via `.def.innerType`.\n return (schema as unknown as { def?: { innerType?: z.ZodType } }).def\n ?.innerType;\n}\n","import { ConfigurationError } from \"../errors/index\";\nimport { type GraphExtension } from \"../graph-extension/extension-types\";\nimport {\n autoDeriveVectorIndexes,\n mergeVectorIndexes,\n} from \"../indexes/auto-derive\";\nimport { type IndexDeclaration } from \"../indexes/types\";\nimport { type OntologyRelation } from \"../ontology/types\";\nimport {\n type AnyEdgeType,\n type DeleteBehavior,\n type EdgeRegistration,\n type EdgeTypeWithEndpoints,\n type GraphDefaults,\n isEdgeType,\n isEdgeTypeWithEndpoints,\n type KindEntity,\n type NodeRegistration,\n type NodeType,\n type TemporalMode,\n} from \"./types\";\n\n// ============================================================\n// Graph Definition Brand Symbol\n// ============================================================\n\n/** Brand key for GraphDef */\nconst GRAPH_DEF_BRAND = \"__graphDef\" as const;\n\n// ============================================================\n// Edge Entry Types\n// ============================================================\n\n/**\n * An edge entry in the graph definition.\n * Can be:\n * - EdgeType directly (constrained or unconstrained)\n * - EdgeRegistration object (always works, can override/narrow defaults)\n */\ntype EdgeEntry = EdgeRegistration | AnyEdgeType;\n\n/**\n * Normalized edge map type - all entries become EdgeRegistration.\n * For bare EdgeTypes, constrained endpoints are extracted from the type;\n * unconstrained edges fall back to all node types in the graph.\n */\ntype NormalizedEdges<\n TNodes extends Record<string, NodeRegistration>,\n TEdges extends Record<string, EdgeEntry>,\n> = {\n [K in keyof TEdges]: TEdges[K] extends EdgeRegistration ? TEdges[K]\n : TEdges[K] extends AnyEdgeType ?\n EdgeRegistration<\n TEdges[K],\n TEdges[K][\"from\"] extends readonly (infer N extends NodeType)[] ? N\n : TNodes[keyof TNodes][\"type\"],\n TEdges[K][\"to\"] extends readonly (infer N extends NodeType)[] ? N\n : TNodes[keyof TNodes][\"type\"]\n >\n : never;\n};\n\n// ============================================================\n// Edge Normalization Functions\n// ============================================================\n\n/**\n * Validates that an EdgeRegistration's constraints don't widen beyond\n * the edge type's built-in domain/range constraints.\n */\nfunction validateConstraintNarrowing(\n name: string,\n edgeType: EdgeTypeWithEndpoints,\n registration: EdgeRegistration,\n): void {\n const builtInFromNames = new Set(edgeType.from.map((node) => node.kind));\n for (const fromNode of registration.from) {\n if (!builtInFromNames.has(fromNode.kind)) {\n throw new ConfigurationError(\n `Edge \"${name}\" registration has 'from' kind \"${fromNode.kind}\" ` +\n `not in edge's built-in domain: [${[...builtInFromNames].join(\", \")}]`,\n {\n edgeName: name,\n invalidFrom: fromNode.kind,\n allowedFrom: [...builtInFromNames],\n },\n {\n suggestion: `Edge registration can only narrow, not widen, the edge type's built-in constraints.`,\n },\n );\n }\n }\n\n const builtInToNames = new Set(edgeType.to.map((node) => node.kind));\n for (const toNode of registration.to) {\n if (!builtInToNames.has(toNode.kind)) {\n throw new ConfigurationError(\n `Edge \"${name}\" registration has 'to' kind \"${toNode.kind}\" ` +\n `not in edge's built-in range: [${[...builtInToNames].join(\", \")}]`,\n {\n edgeName: name,\n invalidTo: toNode.kind,\n allowedTo: [...builtInToNames],\n },\n {\n suggestion: `Edge registration can only narrow, not widen, the edge type's built-in constraints.`,\n },\n );\n }\n }\n}\n\n/**\n * Normalizes a single edge entry to EdgeRegistration.\n */\nfunction normalizeEdgeEntry(\n name: string,\n entry: EdgeEntry,\n allNodeTypes: readonly NodeType[],\n): EdgeRegistration {\n if (isEdgeType(entry)) {\n if (isEdgeTypeWithEndpoints(entry)) {\n // EdgeType with from/to — convert to EdgeRegistration\n return { type: entry, from: entry.from, to: entry.to };\n }\n // Unconstrained EdgeType — allow any→any\n return { type: entry, from: allNodeTypes, to: allNodeTypes };\n }\n\n // Already EdgeRegistration — validate narrowing if edge has built-in constraints\n if (isEdgeTypeWithEndpoints(entry.type)) {\n validateConstraintNarrowing(name, entry.type, entry);\n }\n\n return entry;\n}\n\n/**\n * Normalizes all edge entries to EdgeRegistration.\n */\nfunction normalizeEdges(\n edges: Record<string, EdgeEntry>,\n allNodeTypes: readonly NodeType[],\n): Record<string, EdgeRegistration> {\n const result: Record<string, EdgeRegistration> = {};\n for (const [name, entry] of Object.entries(edges)) {\n result[name] = normalizeEdgeEntry(name, entry, allNodeTypes);\n }\n return result;\n}\n\n// ============================================================\n// Graph Definition Configuration\n// ============================================================\n\n/**\n * Configuration for defineGraph.\n */\ntype GraphDefConfig<\n TNodes extends Record<string, NodeRegistration>,\n TEdges extends Record<string, EdgeEntry>,\n TOntology extends readonly OntologyRelation[],\n> = Readonly<{\n /** Unique identifier for this graph */\n id: string;\n /** Node registrations */\n nodes: TNodes;\n /** Edge registrations or EdgeTypes with built-in domain/range */\n edges: TEdges;\n /** Ontology relations */\n ontology?: TOntology;\n /** Graph-wide defaults */\n defaults?: GraphDefaults;\n /**\n * Index declarations attached to this graph.\n *\n * Accepts the outputs of `defineNodeIndex` / `defineEdgeIndex` (which\n * already return `IndexDeclaration` values) or pre-built declarations\n * reconstructed from a stored schema or graph extension.\n *\n * Validated at definition time: every index must reference a `kind`\n * that exists in `nodes` / `edges`, and index `name`s must be unique\n * within the graph.\n *\n * Index DDL is **not** generated by `defineGraph`. Indexes flow into\n * `SerializedSchema.indexes` so they can later be materialized via\n * `store.materializeIndexes()` — lifting the storage concern out of\n * the schema-version commit path.\n */\n indexes?: readonly IndexDeclaration[];\n}>;\n\n// ============================================================\n// Graph Definition Type\n// ============================================================\n\n/**\n * A graph definition.\n *\n * This is a compile-time artifact that describes the structure of a graph.\n * Use `createStore()` to create a runtime store from this definition.\n */\nexport type GraphDef<\n TNodes extends Record<string, NodeRegistration> = Record<\n string,\n NodeRegistration\n >,\n TEdges extends Record<string, EdgeRegistration> = Record<\n string,\n EdgeRegistration\n >,\n TOntology extends readonly OntologyRelation[] = readonly OntologyRelation[],\n> = Readonly<{\n [GRAPH_DEF_BRAND]: true;\n id: string;\n nodes: TNodes;\n edges: TEdges;\n ontology: TOntology;\n defaults: Readonly<{\n onNodeDelete: DeleteBehavior;\n temporalMode: TemporalMode;\n }>;\n /**\n * Index declarations attached to this graph. Preserves whatever the\n * caller passed to `defineGraph` (including an explicit empty array)\n * for introspection purposes.\n *\n * The serialized canonical form is order-canonicalized (sorted by\n * `name`) and treats `undefined` and `[]` as the same \"no slice\" form\n * — an empty array does not bump the schema hash, since indexes are\n * an unordered set keyed by name and `[]` carries no semantic meaning\n * that an absent slice doesn't.\n */\n indexes: readonly IndexDeclaration[] | undefined;\n /**\n * Graph extension this graph was merged with, if any. Set by\n * `mergeGraphExtension`; never set by `defineGraph` directly.\n * Exists solely so re-serialization is stable — the rest of the\n * system reads the merged kinds through `nodes` / `edges` /\n * `ontology` and never inspects this field. Absent on graphs that\n * have never been extended; legacy graphs hash byte-identically.\n */\n extension: GraphExtension | undefined;\n /**\n * Soft-deprecated kind names attached to this graph. Set by the\n * loader from the persisted schema and by `store.deprecateKinds(...)`\n * / `store.undeprecateKinds(...)`. A purely informational signal\n * surfaced for introspection — does not gate reads, writes, or\n * queries. Defaults to the empty set on freshly-defined graphs.\n */\n deprecatedKinds: ReadonlySet<string>;\n}>;\n\n// ============================================================\n// Type Helpers\n// ============================================================\n\n/**\n * Extract node kind names from a GraphDef.\n */\nexport type NodeKinds<G extends GraphDef> = keyof G[\"nodes\"] & string;\n\n/**\n * Extract edge kind names from a GraphDef.\n */\nexport type EdgeKinds<G extends GraphDef> = keyof G[\"edges\"] & string;\n\n/**\n * Get a NodeType from a GraphDef by kind name.\n */\nexport type GetNodeType<\n G extends GraphDef,\n K extends NodeKinds<G>,\n> = G[\"nodes\"][K][\"type\"];\n\n/**\n * Get an EdgeType from a GraphDef by kind name.\n */\nexport type GetEdgeType<\n G extends GraphDef,\n K extends EdgeKinds<G>,\n> = G[\"edges\"][K][\"type\"];\n\n/**\n * Get all NodeTypes from a GraphDef.\n */\nexport type AllNodeTypes<G extends GraphDef> = {\n [K in NodeKinds<G>]: G[\"nodes\"][K][\"type\"];\n}[NodeKinds<G>];\n\n/**\n * Get all EdgeTypes from a GraphDef.\n */\nexport type AllEdgeTypes<G extends GraphDef> = {\n [K in EdgeKinds<G>]: G[\"edges\"][K][\"type\"];\n}[EdgeKinds<G>];\n\n// ============================================================\n// Define Graph Function\n// ============================================================\n\n/**\n * Creates a graph definition.\n *\n * @example\n * ```typescript\n * const graph = defineGraph({\n * id: \"my_graph\",\n * nodes: {\n * Person: { type: Person },\n * Company: { type: Company },\n * },\n * edges: {\n * // Traditional EdgeRegistration syntax\n * worksAt: {\n * type: worksAt,\n * from: [Person],\n * to: [Company],\n * cardinality: \"many\",\n * },\n * // Or use EdgeType directly if it has from/to defined\n * knows, // EdgeType with built-in domain/range\n * },\n * ontology: [\n * subClassOf(Company, Organization),\n * disjointWith(Person, Organization),\n * ],\n * defaults: {\n * onNodeDelete: \"restrict\",\n * temporalMode: \"current\",\n * },\n * });\n * ```\n */\nexport function defineGraph<\n const TNodes extends Record<string, NodeRegistration<NodeType>>,\n const TEdges extends Record<string, EdgeEntry>,\n const TOntology extends readonly OntologyRelation[],\n>(\n config: GraphDefConfig<TNodes, TEdges, TOntology>,\n): GraphDef<TNodes, NormalizedEdges<TNodes, TEdges>, TOntology> {\n const defaults = {\n onNodeDelete: config.defaults?.onNodeDelete ?? \"restrict\",\n temporalMode: config.defaults?.temporalMode ?? \"current\",\n } as const;\n\n const allNodeTypes = Object.values(config.nodes).map((reg) => reg.type);\n const normalizedEdges = normalizeEdges(config.edges, allNodeTypes);\n // Vector indexes are auto-derived from `embedding()` brands on node\n // schemas (see `autoDeriveVectorIndexes`). Explicit declarations\n // passed via `defineGraph({ indexes })` win on (kind, fieldPath)\n // collisions so consumers can override defaults — see\n // `mergeVectorIndexes`. The merged list flows through\n // `normalizeIndexes` for the standard kind-registered + unique-name\n // checks.\n //\n // Preservation rule: if the consumer never passed `indexes` at all\n // AND no embedding brands exist, leave `graph.indexes` undefined to\n // keep the introspection surface stable for legacy graphs. If the\n // consumer passed an explicit `[]`, surface it as `[]` (not\n // `undefined`) to match the contract pinned by the\n // \"preserves an explicit empty indexes array\" test.\n const autoVectorIndexes = autoDeriveVectorIndexes(config.nodes);\n const explicitProvided = config.indexes !== undefined;\n const mergedIndexes = mergeVectorIndexes(\n config.indexes ?? [],\n autoVectorIndexes,\n );\n const indexes =\n !explicitProvided && mergedIndexes.length === 0 ?\n undefined\n : normalizeIndexes(mergedIndexes, config.nodes, normalizedEdges);\n\n return Object.freeze({\n [GRAPH_DEF_BRAND]: true as const,\n id: config.id,\n nodes: config.nodes,\n edges: normalizedEdges,\n ontology: config.ontology ?? ([] as unknown as TOntology),\n defaults,\n indexes,\n extension: undefined,\n deprecatedKinds: EMPTY_DEPRECATED_KINDS,\n }) as GraphDef<TNodes, NormalizedEdges<TNodes, TEdges>, TOntology>;\n}\n\n// Sharing one frozen empty Set keeps the canonical-form hash stable\n// across graphs that never deprecate any kinds.\nconst EMPTY_DEPRECATED_KINDS: ReadonlySet<string> = Object.freeze(\n new Set<string>(),\n);\n\n// ============================================================\n// Index Normalization\n// ============================================================\n\n/**\n * Validates the `indexes` config slice:\n *\n * - Every index references a kind that exists in the graph's `nodes`\n * (for node indexes) or `edges` (for edge indexes).\n * - Index `name`s are unique within the graph.\n */\nfunction normalizeIndexes(\n inputs: readonly IndexDeclaration[],\n nodes: Record<string, NodeRegistration>,\n edges: Record<string, EdgeRegistration>,\n): readonly IndexDeclaration[] {\n if (inputs.length === 0) {\n return [];\n }\n\n const nodeKinds = collectKinds(nodes);\n const edgeKinds = collectKinds(edges);\n const seenNames = new Set<string>();\n\n for (const declaration of inputs) {\n if (declaration.entity === \"node\" || declaration.entity === \"vector\") {\n // Vector indexes attach to node kinds (the embedding lives on a\n // node field). Validation reuses the node-kind check.\n assertKindRegistered(declaration, nodeKinds, \"node\");\n } else {\n assertKindRegistered(declaration, edgeKinds, \"edge\");\n }\n\n if (seenNames.has(declaration.name)) {\n throw new ConfigurationError(\n `Duplicate index name \"${declaration.name}\" in defineGraph({ indexes }). ` +\n `Index names must be unique within a graph.`,\n { indexName: declaration.name },\n {\n suggestion: `Pass an explicit { name: \"...\" } to disambiguate.`,\n },\n );\n }\n seenNames.add(declaration.name);\n }\n\n return inputs;\n}\n\nfunction collectKinds(\n registrations: Record<string, { type: { kind: string } }>,\n): ReadonlySet<string> {\n const kinds = new Set<string>();\n for (const registration of Object.values(registrations)) {\n kinds.add(registration.type.kind);\n }\n return kinds;\n}\n\nfunction assertKindRegistered(\n declaration: IndexDeclaration,\n registeredKinds: ReadonlySet<string>,\n entity: KindEntity,\n): void {\n if (registeredKinds.has(declaration.kind)) return;\n\n const slot = entity === \"node\" ? \"nodes\" : \"edges\";\n const suggestion =\n entity === \"node\" ?\n `Add { ${declaration.kind}: { type: ${declaration.kind} } } to defineGraph({ nodes }) ` +\n `or remove the index from \"indexes\".`\n : `Register the edge in defineGraph({ edges }) or remove the index from \"indexes\".`;\n\n throw new ConfigurationError(\n `Index \"${declaration.name}\" references ${entity} kind \"${declaration.kind}\" ` +\n `which is not registered in this graph's \"${slot}\".`,\n {\n indexName: declaration.name,\n referencedKind: declaration.kind,\n availableKinds: [...registeredKinds],\n },\n { suggestion },\n );\n}\n\n// ============================================================\n// Graph Definition Utilities\n// ============================================================\n\n/**\n * Checks if a value is a GraphDef.\n */\nexport function isGraphDef(value: unknown): value is GraphDef {\n return (\n typeof value === \"object\" &&\n value !== null &&\n GRAPH_DEF_BRAND in value &&\n (value as Record<string, unknown>)[GRAPH_DEF_BRAND] === true\n );\n}\n\n/**\n * Gets all node kind names from a GraphDef.\n */\nexport function getNodeKinds<G extends GraphDef>(\n graph: G,\n): readonly (keyof G[\"nodes\"] & string)[] {\n return Object.keys(graph.nodes);\n}\n\n/**\n * Gets all edge kind names from a GraphDef.\n */\nexport function getEdgeKinds<G extends GraphDef>(\n graph: G,\n): readonly (keyof G[\"edges\"] & string)[] {\n return Object.keys(graph.edges);\n}\n\n/**\n * Returns true when `name` is registered as either a node or edge kind\n * on the given graph.\n */\nexport function isKnownKind(graph: GraphDef, name: string): boolean {\n return Object.hasOwn(graph.nodes, name) || Object.hasOwn(graph.edges, name);\n}\n"]}
|