@nicia-ai/typegraph 0.46.1 → 0.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -1
- package/dist/backend/drizzle/indexes.cjs +9 -9
- package/dist/backend/drizzle/indexes.d.cts +1 -1
- package/dist/backend/drizzle/indexes.d.ts +1 -1
- package/dist/backend/drizzle/indexes.js +5 -5
- package/dist/backend/index.cjs +50 -49
- package/dist/backend/index.d.cts +3 -3
- package/dist/backend/index.d.ts +3 -3
- package/dist/backend/index.js +11 -10
- package/dist/backend/postgres/index.cjs +27 -26
- package/dist/backend/postgres/index.d.cts +6 -6
- package/dist/backend/postgres/index.d.ts +6 -6
- package/dist/backend/postgres/index.js +14 -13
- package/dist/backend/postgres/pglite-store.cjs +34 -33
- package/dist/backend/postgres/pglite-store.cjs.map +1 -1
- package/dist/backend/postgres/pglite-store.d.cts +8 -8
- package/dist/backend/postgres/pglite-store.d.ts +8 -8
- package/dist/backend/postgres/pglite-store.js +30 -29
- package/dist/backend/postgres/pglite-store.js.map +1 -1
- package/dist/backend/postgres/pglite.cjs +16 -15
- package/dist/backend/postgres/pglite.d.cts +3 -3
- package/dist/backend/postgres/pglite.d.ts +3 -3
- package/dist/backend/postgres/pglite.js +15 -14
- package/dist/backend/sqlite/index.cjs +24 -23
- package/dist/backend/sqlite/index.d.cts +6 -6
- package/dist/backend/sqlite/index.d.ts +6 -6
- package/dist/backend/sqlite/index.js +12 -11
- package/dist/backend/sqlite/libsql.cjs +19 -18
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +3 -3
- package/dist/backend/sqlite/libsql.d.ts +3 -3
- package/dist/backend/sqlite/libsql.js +14 -13
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local-store.cjs +35 -34
- package/dist/backend/sqlite/local-store.cjs.map +1 -1
- package/dist/backend/sqlite/local-store.d.cts +8 -8
- package/dist/backend/sqlite/local-store.d.ts +8 -8
- package/dist/backend/sqlite/local-store.js +31 -30
- package/dist/backend/sqlite/local-store.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +17 -16
- package/dist/backend/sqlite/local.d.cts +3 -3
- package/dist/backend/sqlite/local.d.ts +3 -3
- package/dist/backend/sqlite/local.js +15 -14
- package/dist/{chunk-NK5Q7UNE.cjs → chunk-26YKDNUD.cjs} +10 -10
- package/dist/{chunk-NK5Q7UNE.cjs.map → chunk-26YKDNUD.cjs.map} +1 -1
- package/dist/{chunk-PQBQG7IM.js → chunk-3DMMGT6S.js} +3 -3
- package/dist/{chunk-PQBQG7IM.js.map → chunk-3DMMGT6S.js.map} +1 -1
- package/dist/{chunk-XBYVV3MP.cjs → chunk-3HGRTCDU.cjs} +6 -4
- package/dist/chunk-3HGRTCDU.cjs.map +1 -0
- package/dist/{chunk-NFCVHQ5P.cjs → chunk-3U5ABFDW.cjs} +26 -26
- package/dist/{chunk-NFCVHQ5P.cjs.map → chunk-3U5ABFDW.cjs.map} +1 -1
- package/dist/{chunk-MCLYU6BN.cjs → chunk-425IZOQ5.cjs} +11 -164
- package/dist/chunk-425IZOQ5.cjs.map +1 -0
- package/dist/{chunk-M4BDU5RX.cjs → chunk-5FBRVORR.cjs} +12 -12
- package/dist/{chunk-M4BDU5RX.cjs.map → chunk-5FBRVORR.cjs.map} +1 -1
- package/dist/{chunk-C23WSN5E.js → chunk-5FT3TLPK.js} +20 -14
- package/dist/chunk-5FT3TLPK.js.map +1 -0
- package/dist/{chunk-YBFHZUXX.js → chunk-5UMTUOM5.js} +6 -6
- package/dist/{chunk-YBFHZUXX.js.map → chunk-5UMTUOM5.js.map} +1 -1
- package/dist/{chunk-HFHTMECK.js → chunk-6FWSNSRE.js} +7 -7
- package/dist/{chunk-HFHTMECK.js.map → chunk-6FWSNSRE.js.map} +1 -1
- package/dist/{chunk-65E3XWGF.cjs → chunk-6JVZSOHQ.cjs} +91 -91
- package/dist/{chunk-65E3XWGF.cjs.map → chunk-6JVZSOHQ.cjs.map} +1 -1
- package/dist/chunk-6KFLYYOC.cjs +161 -0
- package/dist/chunk-6KFLYYOC.cjs.map +1 -0
- package/dist/{chunk-LBJKZXDE.cjs → chunk-6NGW27EO.cjs} +10 -10
- package/dist/{chunk-LBJKZXDE.cjs.map → chunk-6NGW27EO.cjs.map} +1 -1
- package/dist/{chunk-5UVRGXD3.js → chunk-6SWPJEYN.js} +5 -5
- package/dist/{chunk-5UVRGXD3.js.map → chunk-6SWPJEYN.js.map} +1 -1
- package/dist/{chunk-BKCUOV7A.js → chunk-7SQSZN2J.js} +5 -5
- package/dist/{chunk-BKCUOV7A.js.map → chunk-7SQSZN2J.js.map} +1 -1
- package/dist/{chunk-YAAM3M2S.cjs → chunk-AMMWA76F.cjs} +51 -59
- package/dist/chunk-AMMWA76F.cjs.map +1 -0
- package/dist/{chunk-62ZP23AW.cjs → chunk-AOSSQDVO.cjs} +13 -13
- package/dist/{chunk-62ZP23AW.cjs.map → chunk-AOSSQDVO.cjs.map} +1 -1
- package/dist/{chunk-NLI2AVEF.js → chunk-AVGUJWVX.js} +30 -10
- package/dist/chunk-AVGUJWVX.js.map +1 -0
- package/dist/{chunk-TQR4KBY2.cjs → chunk-BCQ76AXA.cjs} +262 -155
- package/dist/chunk-BCQ76AXA.cjs.map +1 -0
- package/dist/{chunk-CXBHOOIQ.cjs → chunk-BFUOME67.cjs} +11 -11
- package/dist/{chunk-CXBHOOIQ.cjs.map → chunk-BFUOME67.cjs.map} +1 -1
- package/dist/{chunk-PNTCATDE.cjs → chunk-BR7SHKGM.cjs} +1672 -1400
- package/dist/chunk-BR7SHKGM.cjs.map +1 -0
- package/dist/{chunk-ASTI57H3.js → chunk-CHAOFCHV.js} +3 -3
- package/dist/{chunk-ASTI57H3.js.map → chunk-CHAOFCHV.js.map} +1 -1
- package/dist/chunk-CICO5GXD.cjs +12 -0
- package/dist/{chunk-A4OC4DVN.cjs.map → chunk-CICO5GXD.cjs.map} +1 -1
- package/dist/{chunk-T4XNKYXB.js → chunk-D5R42W5D.js} +4 -4
- package/dist/{chunk-T4XNKYXB.js.map → chunk-D5R42W5D.js.map} +1 -1
- package/dist/{chunk-S6PW7VV5.js → chunk-DJZTXBWY.js} +410 -138
- package/dist/chunk-DJZTXBWY.js.map +1 -0
- package/dist/{chunk-UDISNXDL.cjs → chunk-DO7SAMEK.cjs} +47 -47
- package/dist/{chunk-UDISNXDL.cjs.map → chunk-DO7SAMEK.cjs.map} +1 -1
- package/dist/{chunk-VCRRKBLN.cjs → chunk-EDN4Y4ZG.cjs} +9 -9
- package/dist/{chunk-VCRRKBLN.cjs.map → chunk-EDN4Y4ZG.cjs.map} +1 -1
- package/dist/{chunk-YVWGEQJE.cjs → chunk-EMIB2RXD.cjs} +139 -133
- package/dist/chunk-EMIB2RXD.cjs.map +1 -0
- package/dist/{chunk-2Z2Z3ZD6.js → chunk-EP4RUYD6.js} +3 -3
- package/dist/{chunk-2Z2Z3ZD6.js.map → chunk-EP4RUYD6.js.map} +1 -1
- package/dist/{chunk-M3WP7RQZ.js → chunk-FNOMT74T.js} +10 -8
- package/dist/chunk-FNOMT74T.js.map +1 -0
- package/dist/{chunk-E4WNQBEF.cjs → chunk-FQPEMEWX.cjs} +12 -12
- package/dist/{chunk-E4WNQBEF.cjs.map → chunk-FQPEMEWX.cjs.map} +1 -1
- package/dist/{chunk-WDGA7IYB.js → chunk-GLHXM7C4.js} +3 -3
- package/dist/{chunk-WDGA7IYB.js.map → chunk-GLHXM7C4.js.map} +1 -1
- package/dist/{chunk-7BQXPCGN.cjs → chunk-GYEG3ZLZ.cjs} +10 -10
- package/dist/{chunk-7BQXPCGN.cjs.map → chunk-GYEG3ZLZ.cjs.map} +1 -1
- package/dist/{chunk-VLT6PEWR.cjs → chunk-GYUJZARH.cjs} +4 -4
- package/dist/{chunk-VLT6PEWR.cjs.map → chunk-GYUJZARH.cjs.map} +1 -1
- package/dist/{chunk-RMQLSPA2.cjs → chunk-HDL2ARHX.cjs} +27 -27
- package/dist/{chunk-RMQLSPA2.cjs.map → chunk-HDL2ARHX.cjs.map} +1 -1
- package/dist/{chunk-775A4ZMN.js → chunk-HEV35TGT.js} +4 -4
- package/dist/{chunk-775A4ZMN.js.map → chunk-HEV35TGT.js.map} +1 -1
- package/dist/{chunk-3DHZCOT7.cjs → chunk-I4G3SQPF.cjs} +20 -20
- package/dist/{chunk-3DHZCOT7.cjs.map → chunk-I4G3SQPF.cjs.map} +1 -1
- package/dist/{chunk-VGTJPTIC.js → chunk-JONXFAPO.js} +5 -5
- package/dist/{chunk-VGTJPTIC.js.map → chunk-JONXFAPO.js.map} +1 -1
- package/dist/{chunk-BSFJMMV3.cjs → chunk-JR6SX5RH.cjs} +4 -4
- package/dist/{chunk-BSFJMMV3.cjs.map → chunk-JR6SX5RH.cjs.map} +1 -1
- package/dist/{chunk-YBQOHKHN.cjs → chunk-KABFHAL7.cjs} +100 -99
- package/dist/chunk-KABFHAL7.cjs.map +1 -0
- package/dist/{chunk-7VQXLT5O.js → chunk-KH7XW7VV.js} +111 -27
- package/dist/chunk-KH7XW7VV.js.map +1 -0
- package/dist/{chunk-DCQVHAYQ.js → chunk-KKBDXCLQ.js} +4 -4
- package/dist/{chunk-DCQVHAYQ.js.map → chunk-KKBDXCLQ.js.map} +1 -1
- package/dist/{chunk-4UGOKMI5.cjs → chunk-L3LQNR34.cjs} +161 -161
- package/dist/{chunk-4UGOKMI5.cjs.map → chunk-L3LQNR34.cjs.map} +1 -1
- package/dist/{chunk-NMWDXFPH.js → chunk-LEWHMOUY.js} +46 -56
- package/dist/chunk-LEWHMOUY.js.map +1 -0
- package/dist/{chunk-U63GDNRC.cjs → chunk-LRQKXRXO.cjs} +4 -4
- package/dist/{chunk-U63GDNRC.cjs.map → chunk-LRQKXRXO.cjs.map} +1 -1
- package/dist/{chunk-5763DULU.js → chunk-M35DF33T.js} +147 -40
- package/dist/chunk-M35DF33T.js.map +1 -0
- package/dist/{chunk-Q3G6A4I3.cjs → chunk-MFZR4QKM.cjs} +30 -28
- package/dist/chunk-MFZR4QKM.cjs.map +1 -0
- package/dist/chunk-MKJ4KXL5.cjs +12 -0
- package/dist/{chunk-VQH4VAWD.cjs.map → chunk-MKJ4KXL5.cjs.map} +1 -1
- package/dist/{chunk-NI72YOJB.cjs → chunk-MRDBBHIZ.cjs} +70 -2
- package/dist/chunk-MRDBBHIZ.cjs.map +1 -0
- package/dist/{chunk-DTVWX77L.cjs → chunk-MX4DHSQP.cjs} +1023 -360
- package/dist/chunk-MX4DHSQP.cjs.map +1 -0
- package/dist/{chunk-2LG2XB2M.js → chunk-MYKHJI2J.js} +3 -3
- package/dist/{chunk-2LG2XB2M.js.map → chunk-MYKHJI2J.js.map} +1 -1
- package/dist/{chunk-JZUR7ZWE.js → chunk-NAZ2RA4L.js} +3 -3
- package/dist/{chunk-JZUR7ZWE.js.map → chunk-NAZ2RA4L.js.map} +1 -1
- package/dist/{chunk-XL7SLCXS.js → chunk-NG2RB5WL.js} +4 -145
- package/dist/chunk-NG2RB5WL.js.map +1 -0
- package/dist/{chunk-GF3KXUTW.js → chunk-NNQ6A3RM.js} +803 -143
- package/dist/chunk-NNQ6A3RM.js.map +1 -0
- package/dist/{chunk-MSY7FSX4.js → chunk-NVY5CJFP.js} +4 -4
- package/dist/{chunk-MSY7FSX4.js.map → chunk-NVY5CJFP.js.map} +1 -1
- package/dist/{chunk-XCAGZAKP.cjs → chunk-OI2GQ25X.cjs} +7 -7
- package/dist/{chunk-XCAGZAKP.cjs.map → chunk-OI2GQ25X.cjs.map} +1 -1
- package/dist/{chunk-PF6F5NLJ.cjs → chunk-OIFSOPSR.cjs} +259 -238
- package/dist/chunk-OIFSOPSR.cjs.map +1 -0
- package/dist/{chunk-UV3SN74I.js → chunk-OMZ37BM2.js} +5 -5
- package/dist/{chunk-UV3SN74I.js.map → chunk-OMZ37BM2.js.map} +1 -1
- package/dist/{chunk-PNN7RHVR.cjs → chunk-OORXGFL5.cjs} +48 -48
- package/dist/{chunk-PNN7RHVR.cjs.map → chunk-OORXGFL5.cjs.map} +1 -1
- package/dist/{chunk-YWGVVALJ.js → chunk-OVI7IXYX.js} +3 -3
- package/dist/{chunk-YWGVVALJ.js.map → chunk-OVI7IXYX.js.map} +1 -1
- package/dist/{chunk-I5MOXA4H.js → chunk-P6YLZTRE.js} +3 -3
- package/dist/{chunk-I5MOXA4H.js.map → chunk-P6YLZTRE.js.map} +1 -1
- package/dist/{chunk-WQZLUGVR.js → chunk-QS3NQZVC.js} +82 -16
- package/dist/chunk-QS3NQZVC.js.map +1 -0
- package/dist/{chunk-5262ZMTR.js → chunk-QTD6HX4O.js} +5 -5
- package/dist/{chunk-5262ZMTR.js.map → chunk-QTD6HX4O.js.map} +1 -1
- package/dist/{chunk-MXJDTH5B.cjs → chunk-ROR5ZR6A.cjs} +45 -45
- package/dist/{chunk-MXJDTH5B.cjs.map → chunk-ROR5ZR6A.cjs.map} +1 -1
- package/dist/{chunk-CBTIUB76.js → chunk-SDBBMD4N.js} +3 -3
- package/dist/{chunk-CBTIUB76.js.map → chunk-SDBBMD4N.js.map} +1 -1
- package/dist/{chunk-L65OU2U3.js → chunk-SE6EGQSD.js} +78 -16
- package/dist/chunk-SE6EGQSD.js.map +1 -0
- package/dist/{chunk-JXA2ZP2Q.js → chunk-SHFBB23Q.js} +4 -4
- package/dist/{chunk-JXA2ZP2Q.js.map → chunk-SHFBB23Q.js.map} +1 -1
- package/dist/{chunk-AKLS3BYZ.js → chunk-SHSSRCFR.js} +5 -3
- package/dist/chunk-SHSSRCFR.js.map +1 -0
- package/dist/{chunk-2NA5DYLO.cjs → chunk-TZEGUG6D.cjs} +4 -4
- package/dist/{chunk-2NA5DYLO.cjs.map → chunk-TZEGUG6D.cjs.map} +1 -1
- package/dist/{chunk-CMWHLBVN.cjs → chunk-U5EDAVOJ.cjs} +140 -74
- package/dist/chunk-U5EDAVOJ.cjs.map +1 -0
- package/dist/{chunk-MUK4BU7K.cjs → chunk-UPAJHMW3.cjs} +210 -126
- package/dist/chunk-UPAJHMW3.cjs.map +1 -0
- package/dist/{chunk-PT7RIRIZ.cjs → chunk-WGX7JH7E.cjs} +235 -170
- package/dist/chunk-WGX7JH7E.cjs.map +1 -0
- package/dist/{chunk-U5SON7R2.cjs → chunk-WODMN3Q2.cjs} +27 -27
- package/dist/{chunk-U5SON7R2.cjs.map → chunk-WODMN3Q2.cjs.map} +1 -1
- package/dist/{chunk-K5ELX2GT.js → chunk-XVWOYKIK.js} +3 -3
- package/dist/{chunk-K5ELX2GT.js.map → chunk-XVWOYKIK.js.map} +1 -1
- package/dist/chunk-XY5OMOJD.js +147 -0
- package/dist/chunk-XY5OMOJD.js.map +1 -0
- package/dist/{chunk-LGHCOKTT.js → chunk-XYBQI6LE.js} +14 -14
- package/dist/{chunk-LGHCOKTT.js.map → chunk-XYBQI6LE.js.map} +1 -1
- package/dist/{chunk-YDFDBE6D.js → chunk-ZDKTPBGV.js} +4 -4
- package/dist/{chunk-YDFDBE6D.js.map → chunk-ZDKTPBGV.js.map} +1 -1
- package/dist/{chunk-MZLPX2R7.js → chunk-ZHNXLS3C.js} +9 -8
- package/dist/chunk-ZHNXLS3C.js.map +1 -0
- package/dist/{chunk-J3WZ3FA2.js → chunk-ZLONH2UD.js} +67 -3
- package/dist/chunk-ZLONH2UD.js.map +1 -0
- package/dist/core/index.cjs +28 -27
- package/dist/core/index.d.cts +4 -4
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +8 -7
- package/dist/{ddl-BXfGHbPN.d.ts → ddl-CprnMXJ-.d.ts} +3 -3
- package/dist/{ddl-BJcOp4WZ.d.cts → ddl-DJA7Lci5.d.cts} +3 -3
- 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 +4 -4
- package/dist/graph-merge/index.cjs +3204 -635
- package/dist/graph-merge/index.cjs.map +1 -1
- package/dist/graph-merge/index.d.cts +502 -60
- package/dist/graph-merge/index.d.ts +502 -60
- package/dist/graph-merge/index.js +2979 -427
- package/dist/graph-merge/index.js.map +1 -1
- package/dist/{index-BSHvKfok.d.ts → index-CHTv4XMZ.d.cts} +64 -3
- package/dist/{index-DxaYCv8Y.d.cts → index-CzoJ3MUw.d.ts} +64 -3
- package/dist/index.cjs +232 -215
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +35 -34
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +13 -13
- package/dist/indexes/index.d.cts +4 -4
- package/dist/indexes/index.d.ts +4 -4
- package/dist/indexes/index.js +6 -6
- package/dist/interchange/index.cjs +53 -52
- package/dist/interchange/index.cjs.map +1 -1
- package/dist/interchange/index.d.cts +17 -13
- package/dist/interchange/index.d.ts +17 -13
- package/dist/interchange/index.js +17 -16
- package/dist/interchange/index.js.map +1 -1
- package/dist/{manager-CfZAimti.d.ts → manager-B6sOQzcQ.d.ts} +2 -2
- package/dist/{manager-HGk6E_HW.d.cts → manager-DlY1vlla.d.cts} +2 -2
- package/dist/{materialize-indexes-BMJP6Tms.d.ts → materialize-indexes-DQL4xcpf.d.ts} +1 -1
- package/dist/{materialize-indexes-6A7dWGtb.d.cts → materialize-indexes-sskhp-c_.d.cts} +1 -1
- package/dist/{postgres-DFYWENdR.d.cts → postgres-B6YOUcaK.d.ts} +1 -1
- package/dist/{postgres-e7a9TdvR.d.ts → postgres-BXy_nyMs.d.cts} +1 -1
- package/dist/profiler/index.d.cts +9 -9
- package/dist/profiler/index.d.ts +9 -9
- package/dist/provenance/index.cjs +43 -42
- package/dist/provenance/index.cjs.map +1 -1
- package/dist/provenance/index.d.cts +7 -7
- package/dist/provenance/index.d.ts +7 -7
- package/dist/provenance/index.js +10 -9
- package/dist/provenance/index.js.map +1 -1
- package/dist/schema/index.cjs +45 -44
- package/dist/schema/index.d.cts +6 -6
- package/dist/schema/index.d.ts +6 -6
- package/dist/schema/index.js +18 -17
- package/dist/{searchable-CIje5XYD.d.cts → searchable-0Cn_lY8U.d.cts} +1 -1
- package/dist/{searchable-9OQoPuRs.d.ts → searchable-D9gMiwcS.d.ts} +1 -1
- package/dist/{sqlite-DerU5tc7.d.ts → sqlite-ClXuBYAj.d.ts} +1 -1
- package/dist/{sqlite-DitnISa9.d.cts → sqlite-DioSxaPe.d.cts} +1 -1
- package/dist/{store-ClQ-MZQS.d.ts → store-5j-w5onJ.d.ts} +128 -69
- package/dist/{store-B0h6x7wo.d.cts → store-CFedKGU5.d.cts} +128 -69
- package/dist/{temporal-Bn-Fi8FJ.d.cts → temporal-Ce1pG0S1.d.cts} +1 -1
- package/dist/{temporal-BtM4UALv.d.ts → temporal-CjO9FH1l.d.ts} +1 -1
- package/dist/{types-KFfk-8Ah.d.ts → types-BrdOFu48.d.ts} +1 -1
- package/dist/{types-HkveCCx0.d.ts → types-DKkMJZjR.d.cts} +39 -12
- package/dist/{types-HkveCCx0.d.cts → types-DKkMJZjR.d.ts} +39 -12
- package/dist/{types-CoIx8HX5.d.cts → types-oj_OGAaZ.d.cts} +1 -1
- package/dist/{where-ws5hf-Ov.d.ts → where-C8w2627G.d.ts} +1 -1
- package/dist/{where--fk7_0kv.d.cts → where-D1wKCJ4Q.d.cts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-5763DULU.js.map +0 -1
- package/dist/chunk-7VQXLT5O.js.map +0 -1
- package/dist/chunk-A4OC4DVN.cjs +0 -12
- package/dist/chunk-AKLS3BYZ.js.map +0 -1
- package/dist/chunk-C23WSN5E.js.map +0 -1
- package/dist/chunk-CMWHLBVN.cjs.map +0 -1
- package/dist/chunk-DTVWX77L.cjs.map +0 -1
- package/dist/chunk-GF3KXUTW.js.map +0 -1
- package/dist/chunk-J3WZ3FA2.js.map +0 -1
- package/dist/chunk-L65OU2U3.js.map +0 -1
- package/dist/chunk-M3WP7RQZ.js.map +0 -1
- package/dist/chunk-MCLYU6BN.cjs.map +0 -1
- package/dist/chunk-MUK4BU7K.cjs.map +0 -1
- package/dist/chunk-MZLPX2R7.js.map +0 -1
- package/dist/chunk-NI72YOJB.cjs.map +0 -1
- package/dist/chunk-NLI2AVEF.js.map +0 -1
- package/dist/chunk-NMWDXFPH.js.map +0 -1
- package/dist/chunk-PF6F5NLJ.cjs.map +0 -1
- package/dist/chunk-PNTCATDE.cjs.map +0 -1
- package/dist/chunk-PT7RIRIZ.cjs.map +0 -1
- package/dist/chunk-Q3G6A4I3.cjs.map +0 -1
- package/dist/chunk-S6PW7VV5.js.map +0 -1
- package/dist/chunk-TQR4KBY2.cjs.map +0 -1
- package/dist/chunk-VQH4VAWD.cjs +0 -12
- package/dist/chunk-WQZLUGVR.js.map +0 -1
- package/dist/chunk-XBYVV3MP.cjs.map +0 -1
- package/dist/chunk-XL7SLCXS.js.map +0 -1
- package/dist/chunk-YAAM3M2S.cjs.map +0 -1
- package/dist/chunk-YBQOHKHN.cjs.map +0 -1
- package/dist/chunk-YVWGEQJE.cjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MAX_PG_IDENTIFIER_LENGTH } from './chunk-2EBMPJBO.js';
|
|
2
|
-
import { typeGraphGlobalSymbol, sql, isSqlFragment } from './chunk-
|
|
3
|
-
import { ConfigurationError } from './chunk-
|
|
2
|
+
import { typeGraphGlobalSymbol, sql, isSqlFragment } from './chunk-3DMMGT6S.js';
|
|
3
|
+
import { ConfigurationError } from './chunk-ZLONH2UD.js';
|
|
4
4
|
|
|
5
5
|
// src/query/compiler/schema.ts
|
|
6
6
|
var SQL_SCHEMA_BRAND = typeGraphGlobalSymbol("sql-schema-v1");
|
|
@@ -240,5 +240,5 @@ var FULLTEXT_CTE_ALIAS = "cte_fulltext";
|
|
|
240
240
|
var HYBRID_CANDIDATES_CTE_ALIAS = "cte_relevance_candidates";
|
|
241
241
|
|
|
242
242
|
export { ALIAS_CTE_PREFIX, DEFAULT_SQL_SCHEMA, EMBEDDINGS_CTE_ALIAS, FULLTEXT_CTE_ALIAS, HYBRID_CANDIDATES_CTE_ALIAS, createRecordedReadBinding, createSqlSchema, recordedReadSchemaFor, recordedReadSqlSchema, recordedRelation, requireExternalRecordedReadSource, requireRecordedReadBinding, requireSqlSchema, vectorSlotKey };
|
|
243
|
-
//# sourceMappingURL=chunk-
|
|
244
|
-
//# sourceMappingURL=chunk-
|
|
243
|
+
//# sourceMappingURL=chunk-NVY5CJFP.js.map
|
|
244
|
+
//# sourceMappingURL=chunk-NVY5CJFP.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/query/compiler/schema.ts"],"names":[],"mappings":";;;;;AAaA,IAAM,gBAAA,GAAkC,sBAAsB,eAAe,CAAA;AAiGtE,IAAe,YAAf,MAAoD;AAc3D,CAAA;AAEA,IAAM,mBAAA,GAAN,cAAkC,SAAA,CAAU;AAAA,EAEjC,MAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,kBAAA;AAAA,EACA,kBAAA;AAAA,EACA,kBAAA;AAAA,EACA,oBAAA;AAAA,EACA,uBAAA;AAAA,EACA,+BAAA;AAAA,EACA,oBAAA;AAAA,EACA,uBAAA;AAAA,EACA,aAAA;AAAA,EAET,YAAY,MAAA,EAAyB;AACnC,IAAA,KAAA,EAAM;AACN,IAAA,MAAA,CAAO,cAAA,CAAe,MAAM,gBAAA,EAAkB;AAAA,MAC5C,YAAA,EAAc,KAAA;AAAA,MACd,UAAA,EAAY,KAAA;AAAA,MACZ,KAAA,EAAO,IAAA;AAAA,MACP,QAAA,EAAU;AAAA,KACX,CAAA;AACD,IAAA,IAAA,CAAK,SAAS,MAAA,CAAO,MAAA;AACrB,IAAA,IAAA,CAAK,aAAa,MAAA,CAAO,UAAA;AACzB,IAAA,IAAA,CAAK,aAAa,MAAA,CAAO,UAAA;AACzB,IAAA,IAAA,CAAK,qBAAqB,MAAA,CAAO,kBAAA;AACjC,IAAA,IAAA,CAAK,qBAAqB,MAAA,CAAO,kBAAA;AACjC,IAAA,IAAA,C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ides table and column identifiers that the query compiler uses.\n * This allows the compiler to work with custom table names instead of\n * hard-coded defaults.\n */\nimport { type VectorIndexType, type VectorMetric } from \"../../backend/types\";\nimport { MAX_PG_IDENTIFIER_LENGTH } from \"../../constants\";\nimport { ConfigurationError } from \"../../errors\";\nimport { typeGraphGlobalSymbol } from \"../../utils/global-symbol\";\nimport { isSqlFragment, sql, type SqlFragment } from \"../sql-fragment\";\n\nconst SQL_SCHEMA_BRAND: unique symbol = typeGraphGlobalSymbol(\"sql-schema-v1\");\n\n/**\n * Table names for TypeGraph SQL schema.\n *\n * Carries every customizable physical-table name the backend exposes,\n * including the secondary tables (`uniques`) that the query compiler\n * itself doesn't reference but `materializeRemovals` and other\n * cleanup paths need to address by name. Backends without a\n * `uniques` table (custom embeddings-only stores) leave it as the\n * default — the cleanup path is a no-op for kinds with no unique\n * rows.\n */\nexport type SqlTableNames = Readonly<{\n /** Nodes table name (default: \"typegraph_nodes\") */\n nodes: string;\n /** Edges table name (default: \"typegraph_edges\") */\n edges: string;\n /** Recorded node relation table name (default: \"typegraph_recorded_nodes\") */\n recordedNodes?: string | undefined;\n /** Recorded edge relation table name (default: \"typegraph_recorded_edges\") */\n recordedEdges?: string | undefined;\n /** Recorded-time commit clock table name (default: \"typegraph_recorded_clock\") */\n recordedClock?: string | undefined;\n /** Durable per-graph revision-origin table name (default: \"typegraph_revision_origins\") */\n revisionOrigins?: string | undefined;\n /** Identity assertion ledger (default: \"typegraph_identity_assertions\") */\n identityAssertions?: string | undefined;\n /** Recorded identity assertion relation */\n recordedIdentityAssertions?: string | undefined;\n /** Derived current identity closure */\n identityClosure?: string | undefined;\n /** Derived separation relation over identity classes */\n identitySeparation?: string | undefined;\n /** Node fulltext table name (default: \"typegraph_node_fulltext\") */\n fulltext: string;\n /** Node uniques table name (default: \"typegraph_node_uniques\") */\n uniques: string;\n}>;\n\nexport type ResolvedSqlTableNames = Readonly<{\n /** Nodes table name */\n nodes: string;\n /** Edges table name */\n edges: string;\n /** Recorded node relation table name */\n recordedNodes: string;\n /** Recorded edge relation table name */\n recordedEdges: string;\n /** Recorded-time commit clock table name */\n recordedClock: string;\n /** Durable per-graph revision-origin table name */\n revisionOrigins: string;\n identityAssertions: string;\n recordedIdentityAssertions: string;\n identityClosure: string;\n identitySeparation: string;\n /** Node fulltext table name */\n fulltext: string;\n /** Node uniques table name */\n uniques: string;\n}>;\n\ntype SqlSchemaFields = Readonly<{\n /** Table names */\n tables: ResolvedSqlTableNames;\n /** Get a `SqlFragment` reference to the nodes table. */\n nodesTable: SqlFragment;\n /** Get a `SqlFragment` reference to the edges table. */\n edgesTable: SqlFragment;\n /** Get a `SqlFragment` reference to the recorded node relation. */\n recordedNodesTable: SqlFragment;\n /** Get a `SqlFragment` reference to the recorded edge relation. */\n recordedEdgesTable: SqlFragment;\n /** Get a `SqlFragment` reference to the recorded-time commit clock. */\n recordedClockTable: SqlFragment;\n /** Get a `SqlFragment` reference to the durable per-graph revision origins. */\n revisionOriginsTable: SqlFragment;\n /** Get a `SqlFragment` reference to the identity assertion ledger. */\n identityAssertionsTable: SqlFragment;\n /** Get a `SqlFragment` reference to the recorded identity assertion relation. */\n recordedIdentityAssertionsTable: SqlFragment;\n /** Get a `SqlFragment` reference to the derived identity closure. */\n identityClosureTable: SqlFragment;\n /** Get a `SqlFragment` reference to the derived identity separation relation. */\n identitySeparationTable: SqlFragment;\n /** Get a `SqlFragment` reference to the fulltext table. */\n fulltextTable: SqlFragment;\n}>;\n\n/**\n * SQL schema configuration for query compilation.\n * Contains table identifiers and utility methods for generating `SqlFragment` references.\n *\n * Branded and frozen by {@link createSqlSchema}; callers should not construct\n * schema-shaped objects by hand.\n */\nexport abstract class SqlSchema implements SqlSchemaFields {\n declare private readonly typeGraphSqlSchemaBrand: true;\n abstract readonly tables: ResolvedSqlTableNames;\n abstract readonly nodesTable: SqlFragment;\n abstract readonly edgesTable: SqlFragment;\n abstract readonly recordedNodesTable: SqlFragment;\n abstract readonly recordedEdgesTable: SqlFragment;\n abstract readonly recordedClockTable: SqlFragment;\n abstract readonly revisionOriginsTable: SqlFragment;\n abstract readonly identityAssertionsTable: SqlFragment;\n abstract readonly recordedIdentityAssertionsTable: SqlFragment;\n abstract readonly identityClosureTable: SqlFragment;\n abstract readonly identitySeparationTable: SqlFragment;\n abstract readonly fulltextTable: SqlFragment;\n}\n\nclass SqlSchemaDescriptor extends SqlSchema {\n declare readonly [SQL_SCHEMA_BRAND]: true;\n readonly tables: ResolvedSqlTableNames;\n readonly nodesTable: SqlFragment;\n readonly edgesTable: SqlFragment;\n readonly recordedNodesTable: SqlFragment;\n readonly recordedEdgesTable: SqlFragment;\n readonly recordedClockTable: SqlFragment;\n readonly revisionOriginsTable: SqlFragment;\n readonly identityAssertionsTable: SqlFragment;\n readonly recordedIdentityAssertionsTable: SqlFragment;\n readonly identityClosureTable: SqlFragment;\n readonly identitySeparationTable: SqlFragment;\n readonly fulltextTable: SqlFragment;\n\n constructor(fields: SqlSchemaFields) {\n super();\n Object.defineProperty(this, SQL_SCHEMA_BRAND, {\n configurable: false,\n enumerable: false,\n value: true,\n writable: false,\n });\n this.tables = fields.tables;\n this.nodesTable = fields.nodesTable;\n this.edgesTable = fields.edgesTable;\n this.recordedNodesTable = fields.recordedNodesTable;\n this.recordedEdgesTable = fields.recordedEdgesTable;\n this.recordedClockTable = fields.recordedClockTable;\n this.revisionOriginsTable = fields.revisionOriginsTable;\n this.identityAssertionsTable = fields.identityAssertionsTable;\n this.recordedIdentityAssertionsTable =\n fields.recordedIdentityAssertionsTable;\n this.identityClosureTable = fields.identityClosureTable;\n this.identitySeparationTable = fields.identitySeparationTable;\n this.fulltextTable = fields.fulltextTable;\n Object.freeze(this);\n }\n}\n\n/**\n * Default table names matching the standard TypeGraph schema.\n */\nconst DEFAULT_TABLE_NAMES: ResolvedSqlTableNames = {\n nodes: \"typegraph_nodes\",\n edges: \"typegraph_edges\",\n recordedNodes: \"typegraph_recorded_nodes\",\n recordedEdges: \"typegraph_recorded_edges\",\n recordedClock: \"typegraph_recorded_clock\",\n revisionOrigins: \"typegraph_revision_origins\",\n identityAssertions: \"typegraph_identity_assertions\",\n recordedIdentityAssertions: \"typegraph_recorded_identity_assertions\",\n identityClosure: \"typegraph_identity_closure\",\n identitySeparation: \"typegraph_identity_separation\",\n fulltext: \"typegraph_node_fulltext\",\n uniques: \"typegraph_node_uniques\",\n};\n\nfunction resolveTableNames(\n names: Partial<SqlTableNames>,\n): ResolvedSqlTableNames {\n return {\n nodes: names.nodes ?? DEFAULT_TABLE_NAMES.nodes,\n edges: names.edges ?? DEFAULT_TABLE_NAMES.edges,\n recordedNodes: names.recordedNodes ?? DEFAULT_TABLE_NAMES.recordedNodes,\n recordedEdges: names.recordedEdges ?? DEFAULT_TABLE_NAMES.recordedEdges,\n recordedClock: names.recordedClock ?? DEFAULT_TABLE_NAMES.recordedClock,\n revisionOrigins:\n names.revisionOrigins ?? DEFAULT_TABLE_NAMES.revisionOrigins,\n identityAssertions:\n names.identityAssertions ?? DEFAULT_TABLE_NAMES.identityAssertions,\n recordedIdentityAssertions:\n names.recordedIdentityAssertions ??\n DEFAULT_TABLE_NAMES.recordedIdentityAssertions,\n identityClosure:\n names.identityClosure ?? DEFAULT_TABLE_NAMES.identityClosure,\n identitySeparation:\n names.identitySeparation ?? DEFAULT_TABLE_NAMES.identitySeparation,\n fulltext: names.fulltext ?? DEFAULT_TABLE_NAMES.fulltext,\n uniques: names.uniques ?? DEFAULT_TABLE_NAMES.uniques,\n };\n}\n\n/**\n * Regex for valid SQL identifiers.\n * Must start with a letter or underscore.\n * Can contain letters, digits, underscores, and dollar signs.\n * Dollar signs are a PostgreSQL extension but commonly supported.\n */\nconst VALID_IDENTIFIER_PATTERN = /^[a-z_][a-z0-9_$]*$/i;\n\n/**\n * Validates that a table name is a valid SQL identifier.\n *\n * @throws Error if the table name is invalid\n */\nfunction validateTableName(name: string, label: string): void {\n if (!name || name.length === 0) {\n throw new ConfigurationError(`${label} table name cannot be empty`);\n }\n if (name.length > MAX_PG_IDENTIFIER_LENGTH) {\n throw new ConfigurationError(\n `${label} table name exceeds maximum length of ${MAX_PG_IDENTIFIER_LENGTH} characters`,\n );\n }\n if (!VALID_IDENTIFIER_PATTERN.test(name)) {\n throw new ConfigurationError(\n `${label} table name \"${name}\" is not a valid SQL identifier. ` +\n `Table names must start with a letter or underscore and contain only letters, digits, underscores, or dollar signs.`,\n );\n }\n}\n\nfunction freezeSqlSchema(fields: SqlSchemaFields): SqlSchema {\n return new SqlSchemaDescriptor(fields);\n}\n\nfunction isSqlSchema(schema: unknown): schema is SqlSchema {\n if (typeof schema !== \"object\" || schema === null) return false;\n const candidate = schema as Record<PropertyKey, unknown>;\n return (\n candidate[SQL_SCHEMA_BRAND] === true &&\n typeof candidate[\"tables\"] === \"object\" &&\n candidate[\"tables\"] !== null &&\n Object.isFrozen(candidate[\"tables\"]) &&\n isSqlFragment(candidate[\"nodesTable\"]) &&\n isSqlFragment(candidate[\"edgesTable\"]) &&\n isSqlFragment(candidate[\"recordedNodesTable\"]) &&\n isSqlFragment(candidate[\"recordedEdgesTable\"]) &&\n isSqlFragment(candidate[\"recordedClockTable\"]) &&\n isSqlFragment(candidate[\"revisionOriginsTable\"]) &&\n isSqlFragment(candidate[\"fulltextTable\"]) &&\n Object.isFrozen(candidate)\n );\n}\n\nexport function requireSqlSchema(\n schema: unknown,\n surface = \"SqlSchema\",\n): SqlSchema {\n if (isSqlSchema(schema)) return schema;\n throw new ConfigurationError(\n `${surface} must be created with createSqlSchema(...).`,\n { code: \"INVALID_SQL_SCHEMA\", surface },\n {\n suggestion:\n \"Pass the result of createSqlSchema(...) instead of a plain schema-shaped object.\",\n },\n );\n}\n\n/**\n * Creates a SqlSchema configuration from table names.\n *\n * Table names are validated to ensure they are valid SQL identifiers.\n * This prevents SQL injection and ensures compatibility across databases.\n *\n * @param names - Optional custom table names (defaults to standard names)\n * @returns SqlSchema configuration for query compilation\n * @throws Error if any table name is invalid\n *\n * @example\n * ```typescript\n * // Use default table names\n * const schema = createSqlSchema();\n *\n * // Use custom table names\n * const schema = createSqlSchema({\n * nodes: \"myapp_nodes\",\n * edges: \"myapp_edges\",\n * fulltext: \"myapp_fulltext\",\n * });\n * ```\n */\nexport function createSqlSchema(names: Partial<SqlTableNames> = {}): SqlSchema {\n const tables = resolveTableNames(names);\n\n // Validate all table names\n validateTableName(tables.nodes, \"nodes\");\n validateTableName(tables.edges, \"edges\");\n validateTableName(tables.recordedNodes, \"recordedNodes\");\n validateTableName(tables.recordedEdges, \"recordedEdges\");\n validateTableName(tables.recordedClock, \"recordedClock\");\n validateTableName(tables.revisionOrigins, \"revisionOrigins\");\n validateTableName(tables.identityAssertions, \"identityAssertions\");\n validateTableName(\n tables.recordedIdentityAssertions,\n \"recordedIdentityAssertions\",\n );\n validateTableName(tables.identityClosure, \"identityClosure\");\n validateTableName(tables.identitySeparation, \"identitySeparation\");\n validateTableName(tables.fulltext, \"fulltext\");\n validateTableName(tables.uniques, \"uniques\");\n\n return freezeSqlSchema({\n tables: Object.freeze(tables),\n nodesTable: sql.identifier(tables.nodes),\n edgesTable: sql.identifier(tables.edges),\n recordedNodesTable: sql.identifier(tables.recordedNodes),\n recordedEdgesTable: sql.identifier(tables.recordedEdges),\n recordedClockTable: sql.identifier(tables.recordedClock),\n revisionOriginsTable: sql.identifier(tables.revisionOrigins),\n identityAssertionsTable: sql.identifier(tables.identityAssertions),\n recordedIdentityAssertionsTable: sql.identifier(\n tables.recordedIdentityAssertions,\n ),\n identityClosureTable: sql.identifier(tables.identityClosure),\n identitySeparationTable: sql.identifier(tables.identitySeparation),\n fulltextTable: sql.identifier(tables.fulltext),\n });\n}\n\n/**\n * The recorded/system-time relation a read coordinate may reconstruct from.\n *\n * TypeGraph's built-in capture relation is bound by `createStore(..., {\n * history: true })`. Hosts can also bind externally populated row-compatible\n * recorded relations through `recordedRelation({ schema })`. Keeping both as\n * explicit values separates the read contract from the write-capture mechanism\n * so future external/TMS-owned recorded relations can feed the same query\n * machinery without changing StoreView or ReadCoordinate.\n */\nconst EXTERNAL_RECORDED_READ_SOURCE: unique symbol = typeGraphGlobalSymbol(\n \"external-recorded-read-source-v1\",\n);\n\nexport type ExternalRecordedReadSource = Readonly<{\n source: \"external\";\n schema: SqlSchema;\n [EXTERNAL_RECORDED_READ_SOURCE]: true;\n}>;\n\ntype ExternalRecordedReadSourceCandidate = Readonly<{\n source?: unknown;\n schema?: unknown;\n [EXTERNAL_RECORDED_READ_SOURCE]?: unknown;\n}>;\n\nconst TYPEGRAPH_RECORDED_READ_SOURCE: unique symbol = typeGraphGlobalSymbol(\n \"typegraph-recorded-read-source-v1\",\n);\n\nexport type TypeGraphRecordedReadSource = Readonly<{\n source: \"typegraph-capture\";\n schema: SqlSchema;\n [TYPEGRAPH_RECORDED_READ_SOURCE]: true;\n}>;\n\ntype RecordedReadSource =\n ExternalRecordedReadSource | TypeGraphRecordedReadSource;\n\nexport type RecordedReadBinding = RecordedReadSource;\n\nexport type RecordedRelationOptions = Readonly<{\n schema: SqlSchema;\n}>;\n\nexport function recordedRelation(\n options: RecordedRelationOptions,\n): ExternalRecordedReadSource {\n const schema = requireSqlSchema(options.schema, \"recordedRelation schema\");\n return Object.freeze({\n source: \"external\",\n schema,\n [EXTERNAL_RECORDED_READ_SOURCE]: true as const,\n });\n}\n\nexport function requireExternalRecordedReadSource(\n source: unknown,\n): ExternalRecordedReadSource | undefined {\n if (source === undefined) return undefined;\n if (isExternalRecordedReadSource(source)) return source;\n throw new ConfigurationError(\n \"recordedRead must be created with recordedRelation({ schema }).\",\n { code: \"INVALID_RECORDED_READ_SOURCE\" },\n {\n suggestion:\n \"Pass { recordedRead: recordedRelation({ schema }) } for an externally populated recorded relation. Use { history: true } when TypeGraph should capture writes.\",\n },\n );\n}\n\nfunction isExternalRecordedReadSource(\n source: unknown,\n): source is ExternalRecordedReadSource {\n if (typeof source !== \"object\" || source === null) return false;\n const candidate = source as ExternalRecordedReadSourceCandidate;\n return (\n candidate.source === \"external\" &&\n candidate[EXTERNAL_RECORDED_READ_SOURCE] === true &&\n isSqlSchema(candidate.schema) &&\n Object.isFrozen(candidate)\n );\n}\n\nexport function createRecordedReadBinding(\n schema: SqlSchema,\n): TypeGraphRecordedReadSource {\n const readSchema = requireSqlSchema(schema, \"recorded read binding schema\");\n return Object.freeze({\n source: \"typegraph-capture\",\n schema: readSchema,\n [TYPEGRAPH_RECORDED_READ_SOURCE]: true as const,\n });\n}\n\nexport function requireRecordedReadBinding(\n binding: unknown,\n surface: string,\n): RecordedReadBinding {\n if (isRecordedReadBinding(binding)) return binding;\n if (binding !== undefined) {\n throw new ConfigurationError(\n \"Recorded-time reads require a recorded read relation created by TypeGraph.\",\n { code: \"INVALID_RECORDED_READ_BINDING\", surface },\n {\n suggestion:\n \"Use createStore(graph, backend, { history: true }) or { recordedRead: recordedRelation({ schema }) } instead of passing a plain object.\",\n },\n );\n }\n throw new ConfigurationError(\n \"Recorded-time reads require a recorded read relation.\",\n { code: \"RECORDED_READ_REQUIRES_BINDING\", surface },\n {\n suggestion:\n \"Create the store with createStore(graph, backend, { history: true }) to bind TypeGraph's built-in captured relation, or pass { recordedRead: recordedRelation({ schema }) } for an externally populated recorded relation.\",\n },\n );\n}\n\ntype TypeGraphRecordedReadSourceCandidate = Readonly<{\n source?: unknown;\n schema?: unknown;\n [TYPEGRAPH_RECORDED_READ_SOURCE]?: unknown;\n}>;\n\nfunction isTypeGraphRecordedReadSource(\n source: unknown,\n): source is TypeGraphRecordedReadSource {\n if (typeof source !== \"object\" || source === null) return false;\n const candidate = source as TypeGraphRecordedReadSourceCandidate;\n return (\n candidate.source === \"typegraph-capture\" &&\n candidate[TYPEGRAPH_RECORDED_READ_SOURCE] === true &&\n isSqlSchema(candidate.schema) &&\n Object.isFrozen(candidate)\n );\n}\n\nfunction isRecordedReadBinding(\n binding: unknown,\n): binding is RecordedReadBinding {\n return (\n isExternalRecordedReadSource(binding) ||\n isTypeGraphRecordedReadSource(binding)\n );\n}\n\n/**\n * Returns a schema view whose primary node/edge sources are the recorded-time\n * relations. The recorded relations are row-compatible with the live tables\n * for every column the query compiler, subgraph extractor, and algorithms\n * already read; the temporal filter adds the `recorded_from/to` predicate.\n */\nexport function recordedReadSqlSchema(binding: RecordedReadBinding): SqlSchema {\n const { schema } = requireRecordedReadBinding(\n binding,\n \"recorded-read-schema\",\n );\n return freezeSqlSchema({\n tables: schema.tables,\n nodesTable: schema.recordedNodesTable,\n edgesTable: schema.recordedEdgesTable,\n recordedNodesTable: schema.recordedNodesTable,\n recordedEdgesTable: schema.recordedEdgesTable,\n recordedClockTable: schema.recordedClockTable,\n revisionOriginsTable: schema.revisionOriginsTable,\n identityAssertionsTable: schema.identityAssertionsTable,\n recordedIdentityAssertionsTable: schema.recordedIdentityAssertionsTable,\n identityClosureTable: schema.identityClosureTable,\n identitySeparationTable: schema.identitySeparationTable,\n fulltextTable: schema.fulltextTable,\n });\n}\n\n/**\n * Resolves the read schema for a coordinate: the live schema when no recorded\n * pin is set, or the recorded-relation view when `recordedAsOf` is present. The\n * single place every read path decides whether to source the recorded tables.\n */\nexport function recordedReadSchemaFor(\n schema: SqlSchema,\n recordedAsOf: string | undefined,\n binding: RecordedReadBinding | undefined,\n surface: string,\n): SqlSchema {\n const baseSchema = requireSqlSchema(schema, `${surface} schema`);\n if (recordedAsOf === undefined) return baseSchema;\n return recordedReadSqlSchema(requireRecordedReadBinding(binding, surface));\n}\n\n/**\n * Default SqlSchema using standard TypeGraph table names.\n */\nexport const DEFAULT_SQL_SCHEMA: SqlSchema = createSqlSchema();\n\n/**\n * The compiler's resolved view of one declared embedding field — the\n * `(dimensions, metric, indexType)` a {@link VectorStrategy} needs to\n * name and scan the field's typed per-`(kind, field)` storage. Sourced\n * from the registered node schema's `embedding()` declaration when the\n * store builds its compile options.\n */\nexport type VectorSlotDescriptor = Readonly<{\n dimensions: number;\n metric: VectorMetric;\n indexType: VectorIndexType;\n}>;\n\n/**\n * Map of declared embedding slots keyed by {@link vectorSlotKey} -\n * `\"<nodeKind>\\0<fieldPath>\"` (NUL-separated). Carries every `(concrete kind,\n * fieldPath)` that declares an embedding field, so the compiler's\n * `field.similarTo(...)` CTE can UNION ALL the per-field tables for the\n * kinds in an alias that actually declare the field (only\n * `includeSubClasses` yields more than one).\n */\nexport type VectorSlotMap = ReadonlyMap<string, VectorSlotDescriptor>;\n\n/** NUL-delimited composite key for {@link VectorSlotMap}. */\nexport function vectorSlotKey(nodeKind: string, fieldPath: string): string {\n return `${nodeKind}\\u0000${fieldPath}`;\n}\n\n/**\n * CTE aliases used by the standard query emitter. Joining on these names\n * across multiple builder files is fragile when typed as raw strings —\n * import these constants instead.\n */\nexport const ALIAS_CTE_PREFIX = \"cte_\" as const;\nexport const EMBEDDINGS_CTE_ALIAS = \"cte_embeddings\" as const;\nexport const FULLTEXT_CTE_ALIAS = \"cte_fulltext\" as const;\nexport const HYBRID_CANDIDATES_CTE_ALIAS = \"cte_relevance_candidates\" as const;\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/query/compiler/schema.ts"],"names":[],"mappings":";;;;;AAaA,IAAM,gBAAA,GAAkC,sBAAsB,eAAe,CAAA;AAiGtE,IAAe,YAAf,MAAoD;AAc3D,CAAA;AAEA,IAAM,mBAAA,GAAN,cAAkC,SAAA,CAAU;AAAA,EAEjC,MAAA;AAAA,EACA,UAAA;AAAA,EACA,UAAA;AAAA,EACA,kBAAA;AAAA,EACA,kBAAA;AAAA,EACA,kBAAA;AAAA,EACA,oBAAA;AAAA,EACA,uBAAA;AAAA,EACA,+BAAA;AAAA,EACA,oBAAA;AAAA,EACA,uBAAA;AAAA,EACA,aAAA;AAAA,EAET,YAAY,MAAA,EAAyB;AACnC,IAAA,KAAA,EAAM;AACN,IAAA,MAAA,CAAO,cAAA,CAAe,MAAM,gBAAA,EAAkB;AAAA,MAC5C,YAAA,EAAc,KAAA;AAAA,MACd,UAAA,EAAY,KAAA;AAAA,MACZ,KAAA,EAAO,IAAA;AAAA,MACP,QAAA,EAAU;AAAA,KACX,CAA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SAAA,EAA2B;AACzE,EAAA,OAAO,CAAA,EAAG,QAAQ,CAAA,EAAA,EAAS,SAAS,CAAA,CAAA;AACtC;AAOO,IAAM,gBAAA,GAAmB;AACzB,IAAM,oBAAA,GAAuB;AAC7B,IAAM,kBAAA,GAAqB;AAC3B,IAAM,2BAAA,GAA8B","file":"chunk-NVY5CJFP.js","sourcesContent":["/**\n * SQL Schema Configuration for Query Compilation\n *\n * Provides table and column identifiers that the query compiler uses.\n * This allows the compiler to work with custom table names instead of\n * hard-coded defaults.\n */\nimport { type VectorIndexType, type VectorMetric } from \"../../backend/types\";\nimport { MAX_PG_IDENTIFIER_LENGTH } from \"../../constants\";\nimport { ConfigurationError } from \"../../errors\";\nimport { typeGraphGlobalSymbol } from \"../../utils/global-symbol\";\nimport { isSqlFragment, sql, type SqlFragment } from \"../sql-fragment\";\n\nconst SQL_SCHEMA_BRAND: unique symbol = typeGraphGlobalSymbol(\"sql-schema-v1\");\n\n/**\n * Table names for TypeGraph SQL schema.\n *\n * Carries every customizable physical-table name the backend exposes,\n * including the secondary tables (`uniques`) that the query compiler\n * itself doesn't reference but `materializeRemovals` and other\n * cleanup paths need to address by name. Backends without a\n * `uniques` table (custom embeddings-only stores) leave it as the\n * default — the cleanup path is a no-op for kinds with no unique\n * rows.\n */\nexport type SqlTableNames = Readonly<{\n /** Nodes table name (default: \"typegraph_nodes\") */\n nodes: string;\n /** Edges table name (default: \"typegraph_edges\") */\n edges: string;\n /** Recorded node relation table name (default: \"typegraph_recorded_nodes\") */\n recordedNodes?: string | undefined;\n /** Recorded edge relation table name (default: \"typegraph_recorded_edges\") */\n recordedEdges?: string | undefined;\n /** Recorded-time commit clock table name (default: \"typegraph_recorded_clock\") */\n recordedClock?: string | undefined;\n /** Durable per-graph revision-origin table name (default: \"typegraph_revision_origins\") */\n revisionOrigins?: string | undefined;\n /** Identity assertion ledger (default: \"typegraph_identity_assertions\") */\n identityAssertions?: string | undefined;\n /** Recorded identity assertion relation */\n recordedIdentityAssertions?: string | undefined;\n /** Derived current identity closure */\n identityClosure?: string | undefined;\n /** Derived separation relation over identity classes */\n identitySeparation?: string | undefined;\n /** Node fulltext table name (default: \"typegraph_node_fulltext\") */\n fulltext: string;\n /** Node uniques table name (default: \"typegraph_node_uniques\") */\n uniques: string;\n}>;\n\nexport type ResolvedSqlTableNames = Readonly<{\n /** Nodes table name */\n nodes: string;\n /** Edges table name */\n edges: string;\n /** Recorded node relation table name */\n recordedNodes: string;\n /** Recorded edge relation table name */\n recordedEdges: string;\n /** Recorded-time commit clock table name */\n recordedClock: string;\n /** Durable per-graph revision-origin table name */\n revisionOrigins: string;\n identityAssertions: string;\n recordedIdentityAssertions: string;\n identityClosure: string;\n identitySeparation: string;\n /** Node fulltext table name */\n fulltext: string;\n /** Node uniques table name */\n uniques: string;\n}>;\n\ntype SqlSchemaFields = Readonly<{\n /** Table names */\n tables: ResolvedSqlTableNames;\n /** Get a `SqlFragment` reference to the nodes table. */\n nodesTable: SqlFragment;\n /** Get a `SqlFragment` reference to the edges table. */\n edgesTable: SqlFragment;\n /** Get a `SqlFragment` reference to the recorded node relation. */\n recordedNodesTable: SqlFragment;\n /** Get a `SqlFragment` reference to the recorded edge relation. */\n recordedEdgesTable: SqlFragment;\n /** Get a `SqlFragment` reference to the recorded-time commit clock. */\n recordedClockTable: SqlFragment;\n /** Get a `SqlFragment` reference to the durable per-graph revision origins. */\n revisionOriginsTable: SqlFragment;\n /** Get a `SqlFragment` reference to the identity assertion ledger. */\n identityAssertionsTable: SqlFragment;\n /** Get a `SqlFragment` reference to the recorded identity assertion relation. */\n recordedIdentityAssertionsTable: SqlFragment;\n /** Get a `SqlFragment` reference to the derived identity closure. */\n identityClosureTable: SqlFragment;\n /** Get a `SqlFragment` reference to the derived identity separation relation. */\n identitySeparationTable: SqlFragment;\n /** Get a `SqlFragment` reference to the fulltext table. */\n fulltextTable: SqlFragment;\n}>;\n\n/**\n * SQL schema configuration for query compilation.\n * Contains table identifiers and utility methods for generating `SqlFragment` references.\n *\n * Branded and frozen by {@link createSqlSchema}; callers should not construct\n * schema-shaped objects by hand.\n */\nexport abstract class SqlSchema implements SqlSchemaFields {\n declare private readonly typeGraphSqlSchemaBrand: true;\n abstract readonly tables: ResolvedSqlTableNames;\n abstract readonly nodesTable: SqlFragment;\n abstract readonly edgesTable: SqlFragment;\n abstract readonly recordedNodesTable: SqlFragment;\n abstract readonly recordedEdgesTable: SqlFragment;\n abstract readonly recordedClockTable: SqlFragment;\n abstract readonly revisionOriginsTable: SqlFragment;\n abstract readonly identityAssertionsTable: SqlFragment;\n abstract readonly recordedIdentityAssertionsTable: SqlFragment;\n abstract readonly identityClosureTable: SqlFragment;\n abstract readonly identitySeparationTable: SqlFragment;\n abstract readonly fulltextTable: SqlFragment;\n}\n\nclass SqlSchemaDescriptor extends SqlSchema {\n declare readonly [SQL_SCHEMA_BRAND]: true;\n readonly tables: ResolvedSqlTableNames;\n readonly nodesTable: SqlFragment;\n readonly edgesTable: SqlFragment;\n readonly recordedNodesTable: SqlFragment;\n readonly recordedEdgesTable: SqlFragment;\n readonly recordedClockTable: SqlFragment;\n readonly revisionOriginsTable: SqlFragment;\n readonly identityAssertionsTable: SqlFragment;\n readonly recordedIdentityAssertionsTable: SqlFragment;\n readonly identityClosureTable: SqlFragment;\n readonly identitySeparationTable: SqlFragment;\n readonly fulltextTable: SqlFragment;\n\n constructor(fields: SqlSchemaFields) {\n super();\n Object.defineProperty(this, SQL_SCHEMA_BRAND, {\n configurable: false,\n enumerable: false,\n value: true,\n writable: false,\n });\n this.tables = fields.tables;\n this.nodesTable = fields.nodesTable;\n this.edgesTable = fields.edgesTable;\n this.recordedNodesTable = fields.recordedNodesTable;\n this.recordedEdgesTable = fields.recordedEdgesTable;\n this.recordedClockTable = fields.recordedClockTable;\n this.revisionOriginsTable = fields.revisionOriginsTable;\n this.identityAssertionsTable = fields.identityAssertionsTable;\n this.recordedIdentityAssertionsTable =\n fields.recordedIdentityAssertionsTable;\n this.identityClosureTable = fields.identityClosureTable;\n this.identitySeparationTable = fields.identitySeparationTable;\n this.fulltextTable = fields.fulltextTable;\n Object.freeze(this);\n }\n}\n\n/**\n * Default table names matching the standard TypeGraph schema.\n */\nconst DEFAULT_TABLE_NAMES: ResolvedSqlTableNames = {\n nodes: \"typegraph_nodes\",\n edges: \"typegraph_edges\",\n recordedNodes: \"typegraph_recorded_nodes\",\n recordedEdges: \"typegraph_recorded_edges\",\n recordedClock: \"typegraph_recorded_clock\",\n revisionOrigins: \"typegraph_revision_origins\",\n identityAssertions: \"typegraph_identity_assertions\",\n recordedIdentityAssertions: \"typegraph_recorded_identity_assertions\",\n identityClosure: \"typegraph_identity_closure\",\n identitySeparation: \"typegraph_identity_separation\",\n fulltext: \"typegraph_node_fulltext\",\n uniques: \"typegraph_node_uniques\",\n};\n\nfunction resolveTableNames(\n names: Partial<SqlTableNames>,\n): ResolvedSqlTableNames {\n return {\n nodes: names.nodes ?? DEFAULT_TABLE_NAMES.nodes,\n edges: names.edges ?? DEFAULT_TABLE_NAMES.edges,\n recordedNodes: names.recordedNodes ?? DEFAULT_TABLE_NAMES.recordedNodes,\n recordedEdges: names.recordedEdges ?? DEFAULT_TABLE_NAMES.recordedEdges,\n recordedClock: names.recordedClock ?? DEFAULT_TABLE_NAMES.recordedClock,\n revisionOrigins:\n names.revisionOrigins ?? DEFAULT_TABLE_NAMES.revisionOrigins,\n identityAssertions:\n names.identityAssertions ?? DEFAULT_TABLE_NAMES.identityAssertions,\n recordedIdentityAssertions:\n names.recordedIdentityAssertions ??\n DEFAULT_TABLE_NAMES.recordedIdentityAssertions,\n identityClosure:\n names.identityClosure ?? DEFAULT_TABLE_NAMES.identityClosure,\n identitySeparation:\n names.identitySeparation ?? DEFAULT_TABLE_NAMES.identitySeparation,\n fulltext: names.fulltext ?? DEFAULT_TABLE_NAMES.fulltext,\n uniques: names.uniques ?? DEFAULT_TABLE_NAMES.uniques,\n };\n}\n\n/**\n * Regex for valid SQL identifiers.\n * Must start with a letter or underscore.\n * Can contain letters, digits, underscores, and dollar signs.\n * Dollar signs are a PostgreSQL extension but commonly supported.\n */\nconst VALID_IDENTIFIER_PATTERN = /^[a-z_][a-z0-9_$]*$/i;\n\n/**\n * Validates that a table name is a valid SQL identifier.\n *\n * @throws Error if the table name is invalid\n */\nfunction validateTableName(name: string, label: string): void {\n if (!name || name.length === 0) {\n throw new ConfigurationError(`${label} table name cannot be empty`);\n }\n if (name.length > MAX_PG_IDENTIFIER_LENGTH) {\n throw new ConfigurationError(\n `${label} table name exceeds maximum length of ${MAX_PG_IDENTIFIER_LENGTH} characters`,\n );\n }\n if (!VALID_IDENTIFIER_PATTERN.test(name)) {\n throw new ConfigurationError(\n `${label} table name \"${name}\" is not a valid SQL identifier. ` +\n `Table names must start with a letter or underscore and contain only letters, digits, underscores, or dollar signs.`,\n );\n }\n}\n\nfunction freezeSqlSchema(fields: SqlSchemaFields): SqlSchema {\n return new SqlSchemaDescriptor(fields);\n}\n\nfunction isSqlSchema(schema: unknown): schema is SqlSchema {\n if (typeof schema !== \"object\" || schema === null) return false;\n const candidate = schema as Record<PropertyKey, unknown>;\n return (\n candidate[SQL_SCHEMA_BRAND] === true &&\n typeof candidate[\"tables\"] === \"object\" &&\n candidate[\"tables\"] !== null &&\n Object.isFrozen(candidate[\"tables\"]) &&\n isSqlFragment(candidate[\"nodesTable\"]) &&\n isSqlFragment(candidate[\"edgesTable\"]) &&\n isSqlFragment(candidate[\"recordedNodesTable\"]) &&\n isSqlFragment(candidate[\"recordedEdgesTable\"]) &&\n isSqlFragment(candidate[\"recordedClockTable\"]) &&\n isSqlFragment(candidate[\"revisionOriginsTable\"]) &&\n isSqlFragment(candidate[\"fulltextTable\"]) &&\n Object.isFrozen(candidate)\n );\n}\n\nexport function requireSqlSchema(\n schema: unknown,\n surface = \"SqlSchema\",\n): SqlSchema {\n if (isSqlSchema(schema)) return schema;\n throw new ConfigurationError(\n `${surface} must be created with createSqlSchema(...).`,\n { code: \"INVALID_SQL_SCHEMA\", surface },\n {\n suggestion:\n \"Pass the result of createSqlSchema(...) instead of a plain schema-shaped object.\",\n },\n );\n}\n\n/**\n * Creates a SqlSchema configuration from table names.\n *\n * Table names are validated to ensure they are valid SQL identifiers.\n * This prevents SQL injection and ensures compatibility across databases.\n *\n * @param names - Optional custom table names (defaults to standard names)\n * @returns SqlSchema configuration for query compilation\n * @throws Error if any table name is invalid\n *\n * @example\n * ```typescript\n * // Use default table names\n * const schema = createSqlSchema();\n *\n * // Use custom table names\n * const schema = createSqlSchema({\n * nodes: \"myapp_nodes\",\n * edges: \"myapp_edges\",\n * fulltext: \"myapp_fulltext\",\n * });\n * ```\n */\nexport function createSqlSchema(names: Partial<SqlTableNames> = {}): SqlSchema {\n const tables = resolveTableNames(names);\n\n // Validate all table names\n validateTableName(tables.nodes, \"nodes\");\n validateTableName(tables.edges, \"edges\");\n validateTableName(tables.recordedNodes, \"recordedNodes\");\n validateTableName(tables.recordedEdges, \"recordedEdges\");\n validateTableName(tables.recordedClock, \"recordedClock\");\n validateTableName(tables.revisionOrigins, \"revisionOrigins\");\n validateTableName(tables.identityAssertions, \"identityAssertions\");\n validateTableName(\n tables.recordedIdentityAssertions,\n \"recordedIdentityAssertions\",\n );\n validateTableName(tables.identityClosure, \"identityClosure\");\n validateTableName(tables.identitySeparation, \"identitySeparation\");\n validateTableName(tables.fulltext, \"fulltext\");\n validateTableName(tables.uniques, \"uniques\");\n\n return freezeSqlSchema({\n tables: Object.freeze(tables),\n nodesTable: sql.identifier(tables.nodes),\n edgesTable: sql.identifier(tables.edges),\n recordedNodesTable: sql.identifier(tables.recordedNodes),\n recordedEdgesTable: sql.identifier(tables.recordedEdges),\n recordedClockTable: sql.identifier(tables.recordedClock),\n revisionOriginsTable: sql.identifier(tables.revisionOrigins),\n identityAssertionsTable: sql.identifier(tables.identityAssertions),\n recordedIdentityAssertionsTable: sql.identifier(\n tables.recordedIdentityAssertions,\n ),\n identityClosureTable: sql.identifier(tables.identityClosure),\n identitySeparationTable: sql.identifier(tables.identitySeparation),\n fulltextTable: sql.identifier(tables.fulltext),\n });\n}\n\n/**\n * The recorded/system-time relation a read coordinate may reconstruct from.\n *\n * TypeGraph's built-in capture relation is bound by `createStore(..., {\n * history: true })`. Hosts can also bind externally populated row-compatible\n * recorded relations through `recordedRelation({ schema })`. Keeping both as\n * explicit values separates the read contract from the write-capture mechanism\n * so future external/TMS-owned recorded relations can feed the same query\n * machinery without changing StoreView or ReadCoordinate.\n */\nconst EXTERNAL_RECORDED_READ_SOURCE: unique symbol = typeGraphGlobalSymbol(\n \"external-recorded-read-source-v1\",\n);\n\nexport type ExternalRecordedReadSource = Readonly<{\n source: \"external\";\n schema: SqlSchema;\n [EXTERNAL_RECORDED_READ_SOURCE]: true;\n}>;\n\ntype ExternalRecordedReadSourceCandidate = Readonly<{\n source?: unknown;\n schema?: unknown;\n [EXTERNAL_RECORDED_READ_SOURCE]?: unknown;\n}>;\n\nconst TYPEGRAPH_RECORDED_READ_SOURCE: unique symbol = typeGraphGlobalSymbol(\n \"typegraph-recorded-read-source-v1\",\n);\n\nexport type TypeGraphRecordedReadSource = Readonly<{\n source: \"typegraph-capture\";\n schema: SqlSchema;\n [TYPEGRAPH_RECORDED_READ_SOURCE]: true;\n}>;\n\ntype RecordedReadSource =\n ExternalRecordedReadSource | TypeGraphRecordedReadSource;\n\nexport type RecordedReadBinding = RecordedReadSource;\n\nexport type RecordedRelationOptions = Readonly<{\n schema: SqlSchema;\n}>;\n\nexport function recordedRelation(\n options: RecordedRelationOptions,\n): ExternalRecordedReadSource {\n const schema = requireSqlSchema(options.schema, \"recordedRelation schema\");\n return Object.freeze({\n source: \"external\",\n schema,\n [EXTERNAL_RECORDED_READ_SOURCE]: true as const,\n });\n}\n\nexport function requireExternalRecordedReadSource(\n source: unknown,\n): ExternalRecordedReadSource | undefined {\n if (source === undefined) return undefined;\n if (isExternalRecordedReadSource(source)) return source;\n throw new ConfigurationError(\n \"recordedRead must be created with recordedRelation({ schema }).\",\n { code: \"INVALID_RECORDED_READ_SOURCE\" },\n {\n suggestion:\n \"Pass { recordedRead: recordedRelation({ schema }) } for an externally populated recorded relation. Use { history: true } when TypeGraph should capture writes.\",\n },\n );\n}\n\nfunction isExternalRecordedReadSource(\n source: unknown,\n): source is ExternalRecordedReadSource {\n if (typeof source !== \"object\" || source === null) return false;\n const candidate = source as ExternalRecordedReadSourceCandidate;\n return (\n candidate.source === \"external\" &&\n candidate[EXTERNAL_RECORDED_READ_SOURCE] === true &&\n isSqlSchema(candidate.schema) &&\n Object.isFrozen(candidate)\n );\n}\n\nexport function createRecordedReadBinding(\n schema: SqlSchema,\n): TypeGraphRecordedReadSource {\n const readSchema = requireSqlSchema(schema, \"recorded read binding schema\");\n return Object.freeze({\n source: \"typegraph-capture\",\n schema: readSchema,\n [TYPEGRAPH_RECORDED_READ_SOURCE]: true as const,\n });\n}\n\nexport function requireRecordedReadBinding(\n binding: unknown,\n surface: string,\n): RecordedReadBinding {\n if (isRecordedReadBinding(binding)) return binding;\n if (binding !== undefined) {\n throw new ConfigurationError(\n \"Recorded-time reads require a recorded read relation created by TypeGraph.\",\n { code: \"INVALID_RECORDED_READ_BINDING\", surface },\n {\n suggestion:\n \"Use createStore(graph, backend, { history: true }) or { recordedRead: recordedRelation({ schema }) } instead of passing a plain object.\",\n },\n );\n }\n throw new ConfigurationError(\n \"Recorded-time reads require a recorded read relation.\",\n { code: \"RECORDED_READ_REQUIRES_BINDING\", surface },\n {\n suggestion:\n \"Create the store with createStore(graph, backend, { history: true }) to bind TypeGraph's built-in captured relation, or pass { recordedRead: recordedRelation({ schema }) } for an externally populated recorded relation.\",\n },\n );\n}\n\ntype TypeGraphRecordedReadSourceCandidate = Readonly<{\n source?: unknown;\n schema?: unknown;\n [TYPEGRAPH_RECORDED_READ_SOURCE]?: unknown;\n}>;\n\nfunction isTypeGraphRecordedReadSource(\n source: unknown,\n): source is TypeGraphRecordedReadSource {\n if (typeof source !== \"object\" || source === null) return false;\n const candidate = source as TypeGraphRecordedReadSourceCandidate;\n return (\n candidate.source === \"typegraph-capture\" &&\n candidate[TYPEGRAPH_RECORDED_READ_SOURCE] === true &&\n isSqlSchema(candidate.schema) &&\n Object.isFrozen(candidate)\n );\n}\n\nfunction isRecordedReadBinding(\n binding: unknown,\n): binding is RecordedReadBinding {\n return (\n isExternalRecordedReadSource(binding) ||\n isTypeGraphRecordedReadSource(binding)\n );\n}\n\n/**\n * Returns a schema view whose primary node/edge sources are the recorded-time\n * relations. The recorded relations are row-compatible with the live tables\n * for every column the query compiler, subgraph extractor, and algorithms\n * already read; the temporal filter adds the `recorded_from/to` predicate.\n */\nexport function recordedReadSqlSchema(binding: RecordedReadBinding): SqlSchema {\n const { schema } = requireRecordedReadBinding(\n binding,\n \"recorded-read-schema\",\n );\n return freezeSqlSchema({\n tables: schema.tables,\n nodesTable: schema.recordedNodesTable,\n edgesTable: schema.recordedEdgesTable,\n recordedNodesTable: schema.recordedNodesTable,\n recordedEdgesTable: schema.recordedEdgesTable,\n recordedClockTable: schema.recordedClockTable,\n revisionOriginsTable: schema.revisionOriginsTable,\n identityAssertionsTable: schema.identityAssertionsTable,\n recordedIdentityAssertionsTable: schema.recordedIdentityAssertionsTable,\n identityClosureTable: schema.identityClosureTable,\n identitySeparationTable: schema.identitySeparationTable,\n fulltextTable: schema.fulltextTable,\n });\n}\n\n/**\n * Resolves the read schema for a coordinate: the live schema when no recorded\n * pin is set, or the recorded-relation view when `recordedAsOf` is present. The\n * single place every read path decides whether to source the recorded tables.\n */\nexport function recordedReadSchemaFor(\n schema: SqlSchema,\n recordedAsOf: string | undefined,\n binding: RecordedReadBinding | undefined,\n surface: string,\n): SqlSchema {\n const baseSchema = requireSqlSchema(schema, `${surface} schema`);\n if (recordedAsOf === undefined) return baseSchema;\n return recordedReadSqlSchema(requireRecordedReadBinding(binding, surface));\n}\n\n/**\n * Default SqlSchema using standard TypeGraph table names.\n */\nexport const DEFAULT_SQL_SCHEMA: SqlSchema = createSqlSchema();\n\n/**\n * The compiler's resolved view of one declared embedding field — the\n * `(dimensions, metric, indexType)` a {@link VectorStrategy} needs to\n * name and scan the field's typed per-`(kind, field)` storage. Sourced\n * from the registered node schema's `embedding()` declaration when the\n * store builds its compile options.\n */\nexport type VectorSlotDescriptor = Readonly<{\n dimensions: number;\n metric: VectorMetric;\n indexType: VectorIndexType;\n}>;\n\n/**\n * Map of declared embedding slots keyed by {@link vectorSlotKey} -\n * `\"<nodeKind>\\0<fieldPath>\"` (NUL-separated). Carries every `(concrete kind,\n * fieldPath)` that declares an embedding field, so the compiler's\n * `field.similarTo(...)` CTE can UNION ALL the per-field tables for the\n * kinds in an alias that actually declare the field (only\n * `includeSubClasses` yields more than one).\n */\nexport type VectorSlotMap = ReadonlyMap<string, VectorSlotDescriptor>;\n\n/** NUL-delimited composite key for {@link VectorSlotMap}. */\nexport function vectorSlotKey(nodeKind: string, fieldPath: string): string {\n return `${nodeKind}\\u0000${fieldPath}`;\n}\n\n/**\n * CTE aliases used by the standard query emitter. Joining on these names\n * across multiple builder files is fragile when typed as raw strings —\n * import these constants instead.\n */\nexport const ALIAS_CTE_PREFIX = \"cte_\" as const;\nexport const EMBEDDINGS_CTE_ALIAS = \"cte_embeddings\" as const;\nexport const FULLTEXT_CTE_ALIAS = \"cte_fulltext\" as const;\nexport const HYBRID_CANDIDATES_CTE_ALIAS = \"cte_relevance_candidates\" as const;\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkL3LQNR34_cjs = require('./chunk-L3LQNR34.cjs');
|
|
4
4
|
|
|
5
5
|
// src/indexes/system.ts
|
|
6
6
|
var SYSTEM_INDEX_DECLARATIONS = [
|
|
@@ -175,7 +175,7 @@ var MAX_SQL_IDENTIFIER_LENGTH = 63;
|
|
|
175
175
|
function systemIndexName(physicalTableName, suffix) {
|
|
176
176
|
const full = `${physicalTableName}_${suffix}`;
|
|
177
177
|
if (full.length <= MAX_SQL_IDENTIFIER_LENGTH) return full;
|
|
178
|
-
const hash =
|
|
178
|
+
const hash = chunkL3LQNR34_cjs.shortHash(JSON.stringify([physicalTableName, suffix]));
|
|
179
179
|
return `${full.slice(0, MAX_SQL_IDENTIFIER_LENGTH - 1 - hash.length)}_${hash}`;
|
|
180
180
|
}
|
|
181
181
|
function resolveSystemIndexNames(overrides) {
|
|
@@ -200,11 +200,11 @@ function assertNoSystemIndexNameCollision(indexes, overrides) {
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
function generateSystemIndexDDL(declaration, physicalTableName, options) {
|
|
203
|
-
const name =
|
|
203
|
+
const name = chunkL3LQNR34_cjs.quoteIdentifier(
|
|
204
204
|
systemIndexName(physicalTableName, declaration.suffix)
|
|
205
205
|
);
|
|
206
|
-
const table =
|
|
207
|
-
const columns = declaration.columns.map((column) =>
|
|
206
|
+
const table = chunkL3LQNR34_cjs.quoteIdentifier(physicalTableName);
|
|
207
|
+
const columns = declaration.columns.map((column) => chunkL3LQNR34_cjs.quoteIdentifier(column)).join(", ");
|
|
208
208
|
const concurrently = options.concurrent ? "CONCURRENTLY " : "";
|
|
209
209
|
return `CREATE INDEX ${concurrently}IF NOT EXISTS ${name} ON ${table} (${columns});`;
|
|
210
210
|
}
|
|
@@ -215,5 +215,5 @@ exports.generateSystemIndexDDL = generateSystemIndexDDL;
|
|
|
215
215
|
exports.resolveSystemIndexNames = resolveSystemIndexNames;
|
|
216
216
|
exports.resolveSystemIndexTableName = resolveSystemIndexTableName;
|
|
217
217
|
exports.systemIndexName = systemIndexName;
|
|
218
|
-
//# sourceMappingURL=chunk-
|
|
219
|
-
//# sourceMappingURL=chunk-
|
|
218
|
+
//# sourceMappingURL=chunk-OI2GQ25X.cjs.map
|
|
219
|
+
//# sourceMappingURL=chunk-OI2GQ25X.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/indexes/system.ts"],"names":["shortHash","quoteIdentifier"],"mappings":";;;;;AA6EO,IAA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CAAgB,iBAAA,EAAmB,WAAA,CAAY,MAAM;AAAA,GACvD;AACA,EAAA,MAAM,KAAA,GAAQA,kCAAgB,iBAAiB,CAAA;AAC/C,EAAA,MAAM,OAAA,GAAU,WAAA,CAAY,OAAA,CACzB,GAAA,CAAI,CAAC,MAAA,KAAWA,iCAAA,CAAgB,MAAM,CAAC,CAAA,CACvC,IAAA,CAAK,IAAI,CAAA;AACZ,EAAA,MAAM,YAAA,GAAe,OAAA,CAAQ,UAAA,GAAa,eAAA,GAAkB,EAAA;AAC5D,EAAA,OAAO,gBAAgB,YAAY,CAAA,cAAA,EAAiB,IAAI,CAAA,IAAA,EAAO,KAAK,KAAK,OAAO,CAAA,EAAA,CAAA;AAClF","file":"chunk-XCAGZAKP.cjs","sourcesContent":["/**\n * System-index declarations — the single source of truth for the plain\n * btree indexes TypeGraph ships on its own relations.\n *\n * Both dialect schema factories (`createSqliteTables` /\n * `createPostgresTables`) derive their Drizzle index builders from this\n * list, so the two dialects cannot drift, and\n * `materializeSystemIndexes()` derives the same indexes as runtime DDL so\n * an index added in a new library version reaches already-initialized\n * databases (bootstrap DDL only runs on first boot — see\n * `loadActiveSchemaWithBootstrap`).\n *\n * Scope: non-unique btree column indexes on the four graph relations,\n * where performance iteration actually happens. Primary keys, unique /\n * partial-unique constraints, and status-table indexes are structural —\n * they are created with their table and never retrofitted — and stay in\n * the schema files.\n *\n * Changing a declaration's shape under the same suffix is a signature\n * drift: `materializeSystemIndexes` reports `failed` for it until the\n * operator drops the old physical index. Rename (new suffix) instead,\n * exactly like graph-declared indexes. Two acknowledged limits of that\n * contract: on databases whose indexes were bootstrap-created (no status\n * rows) an in-place reshape is undetectable at runtime — the rename rule\n * is enforced by review and the parity tests; and a renamed suffix\n * strands the old physical index (the runner only adds). When the first\n * rename actually happens, add a retired-suffixes list + drop path here.\n */\nimport { quoteIdentifier, shortHash } from \"../query/dialect/vector-strategy\";\n\n/** The TypeGraph relations that carry system indexes. */\nexport type SystemIndexTable =\n \"nodes\" | \"edges\" | \"recordedNodes\" | \"recordedEdges\";\n\ntype LiveColumn =\n | \"graph_id\"\n | \"kind\"\n | \"id\"\n | \"deleted_at\"\n | \"valid_from\"\n | \"valid_to\"\n | \"created_at\";\n\ntype LiveEdgeColumn =\n LiveColumn | \"from_kind\" | \"from_id\" | \"to_kind\" | \"to_id\";\n\ntype RecordedColumn =\n | \"graph_id\"\n | \"kind\"\n | \"id\"\n | \"valid_from\"\n | \"valid_to\"\n | \"recorded_from\"\n | \"recorded_to\";\n\ntype RecordedEdgeColumn =\n RecordedColumn | \"from_kind\" | \"from_id\" | \"to_kind\" | \"to_id\";\n\ntype SystemIndexColumnsFor<T extends SystemIndexTable> =\n T extends \"nodes\" ? LiveColumn\n : T extends \"edges\" ? LiveEdgeColumn\n : T extends \"recordedNodes\" ? RecordedColumn\n : RecordedEdgeColumn;\n\ntype SystemIndexDeclarationFor<T extends SystemIndexTable> = Readonly<{\n table: T;\n /** Physical index name is `${physicalTableName}_${suffix}`. */\n suffix: string;\n columns: readonly [SystemIndexColumnsFor<T>, ...SystemIndexColumnsFor<T>[]];\n}>;\n\nexport type SystemIndexDeclaration =\n | SystemIndexDeclarationFor<\"nodes\">\n | SystemIndexDeclarationFor<\"edges\">\n | SystemIndexDeclarationFor<\"recordedNodes\">\n | SystemIndexDeclarationFor<\"recordedEdges\">;\n\nexport const SYSTEM_INDEX_DECLARATIONS: readonly SystemIndexDeclaration[] = [\n // ---------------------------------------------------------- nodes\n { table: \"nodes\", suffix: \"kind_idx\", columns: [\"graph_id\", \"kind\"] },\n // Listing shape: kind partition ordered by creation with the\n // soft-delete column ahead of it so `deleted_at IS NULL` list queries\n // stay index-served.\n {\n table: \"nodes\",\n suffix: \"kind_created_idx\",\n columns: [\"graph_id\", \"kind\", \"deleted_at\", \"created_at\"],\n },\n {\n table: \"nodes\",\n suffix: \"deleted_idx\",\n columns: [\"graph_id\", \"deleted_at\"],\n },\n {\n table: \"nodes\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n // Bare-id lookup: the primary key leads with `kind` (graph_id, kind,\n // id), so a `WHERE graph_id = ? AND id = ?` probe that doesn't know the\n // kind can't seek it — SQLite falls back to a graph_id-only scan of\n // every node in the graph (~3M at LDBC SF1).\n // `store.algorithms.degree`'s node-kind subquery does exactly that\n // lookup (it resolves the seed's kind by id), so without this index\n // degree is a full nodes scan (~95ms at SF1). See typegraph#280.\n { table: \"nodes\", suffix: \"id_idx\", columns: [\"graph_id\", \"id\"] },\n\n // ---------------------------------------------------------- edges\n { table: \"edges\", suffix: \"kind_idx\", columns: [\"graph_id\", \"kind\"] },\n // Directional traversal index (outgoing): supports endpoint lookups\n // and extra filtering by edge kind / target kind. Includes every\n // system column the compiled query's soft-delete/temporal-validity\n // predicate touches (deleted_at, valid_from, valid_to), trailed by\n // to_id — the compiled traversal join reads `n.id = e.to_id` for an\n // outgoing traversal (standard-builders.ts), so without to_id here\n // the join still fetches the edge's heap row for that one column\n // even with the seek/predicate columns covered.\n {\n table: \"edges\",\n suffix: \"from_idx\",\n columns: [\n \"graph_id\",\n \"from_kind\",\n \"from_id\",\n \"kind\",\n \"to_kind\",\n \"deleted_at\",\n \"valid_from\",\n \"valid_to\",\n \"to_id\",\n ],\n },\n // Directional traversal index (incoming): mirrors from_idx for\n // reverse traversals, trailed by from_id for the same reason\n // (`n.id = e.from_id` for an incoming traversal).\n {\n table: \"edges\",\n suffix: \"to_idx\",\n columns: [\n \"graph_id\",\n \"to_kind\",\n \"to_id\",\n \"kind\",\n \"from_kind\",\n \"deleted_at\",\n \"valid_from\",\n \"valid_to\",\n \"from_id\",\n ],\n },\n {\n table: \"edges\",\n suffix: \"kind_created_idx\",\n columns: [\"graph_id\", \"kind\", \"deleted_at\", \"created_at\"],\n },\n {\n table: \"edges\",\n suffix: \"deleted_idx\",\n columns: [\"graph_id\", \"deleted_at\"],\n },\n {\n table: \"edges\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n // Cardinality enforcement: the one-per-endpoint check probes for a\n // currently-valid edge of a kind from a specific endpoint.\n {\n table: \"edges\",\n suffix: \"cardinality_idx\",\n columns: [\"graph_id\", \"kind\", \"from_kind\", \"from_id\", \"valid_to\"],\n },\n\n // ---------------------------------------------------------- recordedNodes\n {\n table: \"recordedNodes\",\n suffix: \"entity_idx\",\n columns: [\"graph_id\", \"kind\", \"id\", \"recorded_from\", \"recorded_to\"],\n },\n {\n table: \"recordedNodes\",\n suffix: \"open_idx\",\n columns: [\"graph_id\", \"recorded_to\"],\n },\n {\n table: \"recordedNodes\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n // Bare-id lookup parity with the live nodes table: recorded-pinned\n // reads swap this relation in as the node source, and `entity_idx`\n // leads with `kind`, so the same kind-by-bare-id probe (e.g.\n // `degree()` at a recorded coordinate) would otherwise scan every\n // historical version in the graph. See typegraph#280.\n { table: \"recordedNodes\", suffix: \"id_idx\", columns: [\"graph_id\", \"id\"] },\n\n // ---------------------------------------------------------- recordedEdges\n {\n table: \"recordedEdges\",\n suffix: \"entity_idx\",\n columns: [\"graph_id\", \"kind\", \"id\", \"recorded_from\", \"recorded_to\"],\n },\n {\n table: \"recordedEdges\",\n suffix: \"open_idx\",\n columns: [\"graph_id\", \"recorded_to\"],\n },\n {\n table: \"recordedEdges\",\n suffix: \"from_idx\",\n columns: [\n \"graph_id\",\n \"from_kind\",\n \"from_id\",\n \"kind\",\n \"to_kind\",\n \"recorded_from\",\n \"recorded_to\",\n ],\n },\n {\n table: \"recordedEdges\",\n suffix: \"to_idx\",\n columns: [\n \"graph_id\",\n \"to_kind\",\n \"to_id\",\n \"kind\",\n \"from_kind\",\n \"recorded_from\",\n \"recorded_to\",\n ],\n },\n {\n table: \"recordedEdges\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n];\n\n/** Default physical table names for the system-index relations. */\nconst DEFAULT_SYSTEM_INDEX_TABLE_NAMES: Readonly<\n Record<SystemIndexTable, string>\n> = {\n nodes: \"typegraph_nodes\",\n edges: \"typegraph_edges\",\n recordedNodes: \"typegraph_recorded_nodes\",\n recordedEdges: \"typegraph_recorded_edges\",\n};\n\n/**\n * Resolves the physical table name for a system-index relation, honoring\n * a backend's table-name overrides.\n */\nexport function resolveSystemIndexTableName(\n table: SystemIndexTable,\n overrides:\n Readonly<Partial<Record<SystemIndexTable, string | undefined>>> | undefined,\n): string {\n return overrides?.[table] ?? DEFAULT_SYSTEM_INDEX_TABLE_NAMES[table];\n}\n\n/**\n * PostgreSQL truncates identifiers to NAMEDATALEN-1 = 63 bytes SILENTLY —\n * two suffixes of one long custom table name would collide after\n * truncation, and the catalog probes (which compare by exact name) would\n * never match the stored name, re-attempting the build on every boot.\n * SQLite has no such limit but uses the same bound so the two dialects'\n * index sets stay in byte-for-byte parity. (Char-based like the vector\n * identifier bound — multibyte table names are out of scope.)\n */\nconst MAX_SQL_IDENTIFIER_LENGTH = 63;\n\n/**\n * Physical index name: `${physicalTableName}_${suffix}`, deterministically\n * truncated + hash-suffixed past the 63-char identifier bound so distinct\n * indexes stay distinct. Single choke point — the Drizzle builders, the\n * runtime DDL, the catalog probes, and the status keys all derive the\n * name here, so they can never disagree.\n */\nexport function systemIndexName(\n physicalTableName: string,\n suffix: string,\n): string {\n const full = `${physicalTableName}_${suffix}`;\n if (full.length <= MAX_SQL_IDENTIFIER_LENGTH) return full;\n const hash = shortHash(JSON.stringify([physicalTableName, suffix]));\n return `${full.slice(0, MAX_SQL_IDENTIFIER_LENGTH - 1 - hash.length)}_${hash}`;\n}\n\n/**\n * Every system index name for a deployment's (possibly overridden) table\n * names. Graph-declared index names must not collide with these: a\n * colliding `CREATE INDEX IF NOT EXISTS` would silently no-op against the\n * system index (wrong shape) while recording a false success — see the\n * guards in the schema factories and `materializeIndexes`.\n */\nexport function resolveSystemIndexNames(\n overrides:\n Readonly<Partial<Record<SystemIndexTable, string | undefined>>> | undefined,\n): ReadonlySet<string> {\n return new Set(\n SYSTEM_INDEX_DECLARATIONS.map((declaration) =>\n systemIndexName(\n resolveSystemIndexTableName(declaration.table, overrides),\n declaration.suffix,\n ),\n ),\n );\n}\n\n/**\n * Rejects graph-declared indexes whose names collide with this\n * deployment's system index names. Called by both dialect schema\n * factories so a colliding declaration fails at table-definition time\n * instead of silently no-opping against the (differently shaped) system\n * index at CREATE INDEX IF NOT EXISTS time. `materializeIndexes` applies\n * the same check per-declaration on its runtime path.\n */\nexport function assertNoSystemIndexNameCollision(\n indexes: readonly Readonly<{ name: string }>[],\n overrides:\n Readonly<Partial<Record<SystemIndexTable, string | undefined>>> | undefined,\n): void {\n if (indexes.length === 0) return;\n const reserved = resolveSystemIndexNames(overrides);\n for (const index of indexes) {\n if (reserved.has(index.name)) {\n throw new Error(\n `Index name \"${index.name}\" collides with a TypeGraph system ` +\n `index. Choose a different name — system index names are ` +\n `reserved, and a same-named CREATE INDEX IF NOT EXISTS would ` +\n `silently no-op against the system index instead of creating ` +\n `the declared one.`,\n );\n }\n }\n}\n\n/**\n * Runtime DDL for one system index — byte-compatible with the index the\n * bootstrap path creates from the Drizzle schema (same name, same\n * columns), plus `CONCURRENTLY` where the dialect supports building\n * without blocking writes.\n */\nexport function generateSystemIndexDDL(\n declaration: SystemIndexDeclaration,\n physicalTableName: string,\n options: Readonly<{ concurrent: boolean }>,\n): string {\n const name = quoteIdentifier(\n systemIndexName(physicalTableName, declaration.suffix),\n );\n const table = quoteIdentifier(physicalTableName);\n const columns = declaration.columns\n .map((column) => quoteIdentifier(column))\n .join(\", \");\n const concurrently = options.concurrent ? \"CONCURRENTLY \" : \"\";\n return `CREATE INDEX ${concurrently}IF NOT EXISTS ${name} ON ${table} (${columns});`;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/indexes/system.ts"],"names":["shortHash","quoteIdentifier"],"mappings":";;;;;AA6EO,IAAM,yBAAA,GAA+D;AAAA;AAAA,EAE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,MAAM;AAAA,GACvD;AACA,EAAA,MAAM,KAAA,GAAQA,kCAAgB,iBAAiB,CAAA;AAC/C,EAAA,MAAM,OAAA,GAAU,WAAA,CAAY,OAAA,CACzB,GAAA,CAAI,CAAC,MAAA,KAAWA,iCAAA,CAAgB,MAAM,CAAC,CAAA,CACvC,IAAA,CAAK,IAAI,CAAA;AACZ,EAAA,MAAM,YAAA,GAAe,OAAA,CAAQ,UAAA,GAAa,eAAA,GAAkB,EAAA;AAC5D,EAAA,OAAO,gBAAgB,YAAY,CAAA,cAAA,EAAiB,IAAI,CAAA,IAAA,EAAO,KAAK,KAAK,OAAO,CAAA,EAAA,CAAA;AAClF","file":"chunk-OI2GQ25X.cjs","sourcesContent":["/**\n * System-index declarations — the single source of truth for the plain\n * btree indexes TypeGraph ships on its own relations.\n *\n * Both dialect schema factories (`createSqliteTables` /\n * `createPostgresTables`) derive their Drizzle index builders from this\n * list, so the two dialects cannot drift, and\n * `materializeSystemIndexes()` derives the same indexes as runtime DDL so\n * an index added in a new library version reaches already-initialized\n * databases (bootstrap DDL only runs on first boot — see\n * `loadActiveSchemaWithBootstrap`).\n *\n * Scope: non-unique btree column indexes on the four graph relations,\n * where performance iteration actually happens. Primary keys, unique /\n * partial-unique constraints, and status-table indexes are structural —\n * they are created with their table and never retrofitted — and stay in\n * the schema files.\n *\n * Changing a declaration's shape under the same suffix is a signature\n * drift: `materializeSystemIndexes` reports `failed` for it until the\n * operator drops the old physical index. Rename (new suffix) instead,\n * exactly like graph-declared indexes. Two acknowledged limits of that\n * contract: on databases whose indexes were bootstrap-created (no status\n * rows) an in-place reshape is undetectable at runtime — the rename rule\n * is enforced by review and the parity tests; and a renamed suffix\n * strands the old physical index (the runner only adds). When the first\n * rename actually happens, add a retired-suffixes list + drop path here.\n */\nimport { quoteIdentifier, shortHash } from \"../query/dialect/vector-strategy\";\n\n/** The TypeGraph relations that carry system indexes. */\nexport type SystemIndexTable =\n \"nodes\" | \"edges\" | \"recordedNodes\" | \"recordedEdges\";\n\ntype LiveColumn =\n | \"graph_id\"\n | \"kind\"\n | \"id\"\n | \"deleted_at\"\n | \"valid_from\"\n | \"valid_to\"\n | \"created_at\";\n\ntype LiveEdgeColumn =\n LiveColumn | \"from_kind\" | \"from_id\" | \"to_kind\" | \"to_id\";\n\ntype RecordedColumn =\n | \"graph_id\"\n | \"kind\"\n | \"id\"\n | \"valid_from\"\n | \"valid_to\"\n | \"recorded_from\"\n | \"recorded_to\";\n\ntype RecordedEdgeColumn =\n RecordedColumn | \"from_kind\" | \"from_id\" | \"to_kind\" | \"to_id\";\n\ntype SystemIndexColumnsFor<T extends SystemIndexTable> =\n T extends \"nodes\" ? LiveColumn\n : T extends \"edges\" ? LiveEdgeColumn\n : T extends \"recordedNodes\" ? RecordedColumn\n : RecordedEdgeColumn;\n\ntype SystemIndexDeclarationFor<T extends SystemIndexTable> = Readonly<{\n table: T;\n /** Physical index name is `${physicalTableName}_${suffix}`. */\n suffix: string;\n columns: readonly [SystemIndexColumnsFor<T>, ...SystemIndexColumnsFor<T>[]];\n}>;\n\nexport type SystemIndexDeclaration =\n | SystemIndexDeclarationFor<\"nodes\">\n | SystemIndexDeclarationFor<\"edges\">\n | SystemIndexDeclarationFor<\"recordedNodes\">\n | SystemIndexDeclarationFor<\"recordedEdges\">;\n\nexport const SYSTEM_INDEX_DECLARATIONS: readonly SystemIndexDeclaration[] = [\n // ---------------------------------------------------------- nodes\n { table: \"nodes\", suffix: \"kind_idx\", columns: [\"graph_id\", \"kind\"] },\n // Listing shape: kind partition ordered by creation with the\n // soft-delete column ahead of it so `deleted_at IS NULL` list queries\n // stay index-served.\n {\n table: \"nodes\",\n suffix: \"kind_created_idx\",\n columns: [\"graph_id\", \"kind\", \"deleted_at\", \"created_at\"],\n },\n {\n table: \"nodes\",\n suffix: \"deleted_idx\",\n columns: [\"graph_id\", \"deleted_at\"],\n },\n {\n table: \"nodes\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n // Bare-id lookup: the primary key leads with `kind` (graph_id, kind,\n // id), so a `WHERE graph_id = ? AND id = ?` probe that doesn't know the\n // kind can't seek it — SQLite falls back to a graph_id-only scan of\n // every node in the graph (~3M at LDBC SF1).\n // `store.algorithms.degree`'s node-kind subquery does exactly that\n // lookup (it resolves the seed's kind by id), so without this index\n // degree is a full nodes scan (~95ms at SF1). See typegraph#280.\n { table: \"nodes\", suffix: \"id_idx\", columns: [\"graph_id\", \"id\"] },\n\n // ---------------------------------------------------------- edges\n { table: \"edges\", suffix: \"kind_idx\", columns: [\"graph_id\", \"kind\"] },\n // Directional traversal index (outgoing): supports endpoint lookups\n // and extra filtering by edge kind / target kind. Includes every\n // system column the compiled query's soft-delete/temporal-validity\n // predicate touches (deleted_at, valid_from, valid_to), trailed by\n // to_id — the compiled traversal join reads `n.id = e.to_id` for an\n // outgoing traversal (standard-builders.ts), so without to_id here\n // the join still fetches the edge's heap row for that one column\n // even with the seek/predicate columns covered.\n {\n table: \"edges\",\n suffix: \"from_idx\",\n columns: [\n \"graph_id\",\n \"from_kind\",\n \"from_id\",\n \"kind\",\n \"to_kind\",\n \"deleted_at\",\n \"valid_from\",\n \"valid_to\",\n \"to_id\",\n ],\n },\n // Directional traversal index (incoming): mirrors from_idx for\n // reverse traversals, trailed by from_id for the same reason\n // (`n.id = e.from_id` for an incoming traversal).\n {\n table: \"edges\",\n suffix: \"to_idx\",\n columns: [\n \"graph_id\",\n \"to_kind\",\n \"to_id\",\n \"kind\",\n \"from_kind\",\n \"deleted_at\",\n \"valid_from\",\n \"valid_to\",\n \"from_id\",\n ],\n },\n {\n table: \"edges\",\n suffix: \"kind_created_idx\",\n columns: [\"graph_id\", \"kind\", \"deleted_at\", \"created_at\"],\n },\n {\n table: \"edges\",\n suffix: \"deleted_idx\",\n columns: [\"graph_id\", \"deleted_at\"],\n },\n {\n table: \"edges\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n // Cardinality enforcement: the one-per-endpoint check probes for a\n // currently-valid edge of a kind from a specific endpoint.\n {\n table: \"edges\",\n suffix: \"cardinality_idx\",\n columns: [\"graph_id\", \"kind\", \"from_kind\", \"from_id\", \"valid_to\"],\n },\n\n // ---------------------------------------------------------- recordedNodes\n {\n table: \"recordedNodes\",\n suffix: \"entity_idx\",\n columns: [\"graph_id\", \"kind\", \"id\", \"recorded_from\", \"recorded_to\"],\n },\n {\n table: \"recordedNodes\",\n suffix: \"open_idx\",\n columns: [\"graph_id\", \"recorded_to\"],\n },\n {\n table: \"recordedNodes\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n // Bare-id lookup parity with the live nodes table: recorded-pinned\n // reads swap this relation in as the node source, and `entity_idx`\n // leads with `kind`, so the same kind-by-bare-id probe (e.g.\n // `degree()` at a recorded coordinate) would otherwise scan every\n // historical version in the graph. See typegraph#280.\n { table: \"recordedNodes\", suffix: \"id_idx\", columns: [\"graph_id\", \"id\"] },\n\n // ---------------------------------------------------------- recordedEdges\n {\n table: \"recordedEdges\",\n suffix: \"entity_idx\",\n columns: [\"graph_id\", \"kind\", \"id\", \"recorded_from\", \"recorded_to\"],\n },\n {\n table: \"recordedEdges\",\n suffix: \"open_idx\",\n columns: [\"graph_id\", \"recorded_to\"],\n },\n {\n table: \"recordedEdges\",\n suffix: \"from_idx\",\n columns: [\n \"graph_id\",\n \"from_kind\",\n \"from_id\",\n \"kind\",\n \"to_kind\",\n \"recorded_from\",\n \"recorded_to\",\n ],\n },\n {\n table: \"recordedEdges\",\n suffix: \"to_idx\",\n columns: [\n \"graph_id\",\n \"to_kind\",\n \"to_id\",\n \"kind\",\n \"from_kind\",\n \"recorded_from\",\n \"recorded_to\",\n ],\n },\n {\n table: \"recordedEdges\",\n suffix: \"valid_idx\",\n columns: [\"graph_id\", \"valid_from\", \"valid_to\"],\n },\n];\n\n/** Default physical table names for the system-index relations. */\nconst DEFAULT_SYSTEM_INDEX_TABLE_NAMES: Readonly<\n Record<SystemIndexTable, string>\n> = {\n nodes: \"typegraph_nodes\",\n edges: \"typegraph_edges\",\n recordedNodes: \"typegraph_recorded_nodes\",\n recordedEdges: \"typegraph_recorded_edges\",\n};\n\n/**\n * Resolves the physical table name for a system-index relation, honoring\n * a backend's table-name overrides.\n */\nexport function resolveSystemIndexTableName(\n table: SystemIndexTable,\n overrides:\n Readonly<Partial<Record<SystemIndexTable, string | undefined>>> | undefined,\n): string {\n return overrides?.[table] ?? DEFAULT_SYSTEM_INDEX_TABLE_NAMES[table];\n}\n\n/**\n * PostgreSQL truncates identifiers to NAMEDATALEN-1 = 63 bytes SILENTLY —\n * two suffixes of one long custom table name would collide after\n * truncation, and the catalog probes (which compare by exact name) would\n * never match the stored name, re-attempting the build on every boot.\n * SQLite has no such limit but uses the same bound so the two dialects'\n * index sets stay in byte-for-byte parity. (Char-based like the vector\n * identifier bound — multibyte table names are out of scope.)\n */\nconst MAX_SQL_IDENTIFIER_LENGTH = 63;\n\n/**\n * Physical index name: `${physicalTableName}_${suffix}`, deterministically\n * truncated + hash-suffixed past the 63-char identifier bound so distinct\n * indexes stay distinct. Single choke point — the Drizzle builders, the\n * runtime DDL, the catalog probes, and the status keys all derive the\n * name here, so they can never disagree.\n */\nexport function systemIndexName(\n physicalTableName: string,\n suffix: string,\n): string {\n const full = `${physicalTableName}_${suffix}`;\n if (full.length <= MAX_SQL_IDENTIFIER_LENGTH) return full;\n const hash = shortHash(JSON.stringify([physicalTableName, suffix]));\n return `${full.slice(0, MAX_SQL_IDENTIFIER_LENGTH - 1 - hash.length)}_${hash}`;\n}\n\n/**\n * Every system index name for a deployment's (possibly overridden) table\n * names. Graph-declared index names must not collide with these: a\n * colliding `CREATE INDEX IF NOT EXISTS` would silently no-op against the\n * system index (wrong shape) while recording a false success — see the\n * guards in the schema factories and `materializeIndexes`.\n */\nexport function resolveSystemIndexNames(\n overrides:\n Readonly<Partial<Record<SystemIndexTable, string | undefined>>> | undefined,\n): ReadonlySet<string> {\n return new Set(\n SYSTEM_INDEX_DECLARATIONS.map((declaration) =>\n systemIndexName(\n resolveSystemIndexTableName(declaration.table, overrides),\n declaration.suffix,\n ),\n ),\n );\n}\n\n/**\n * Rejects graph-declared indexes whose names collide with this\n * deployment's system index names. Called by both dialect schema\n * factories so a colliding declaration fails at table-definition time\n * instead of silently no-opping against the (differently shaped) system\n * index at CREATE INDEX IF NOT EXISTS time. `materializeIndexes` applies\n * the same check per-declaration on its runtime path.\n */\nexport function assertNoSystemIndexNameCollision(\n indexes: readonly Readonly<{ name: string }>[],\n overrides:\n Readonly<Partial<Record<SystemIndexTable, string | undefined>>> | undefined,\n): void {\n if (indexes.length === 0) return;\n const reserved = resolveSystemIndexNames(overrides);\n for (const index of indexes) {\n if (reserved.has(index.name)) {\n throw new Error(\n `Index name \"${index.name}\" collides with a TypeGraph system ` +\n `index. Choose a different name — system index names are ` +\n `reserved, and a same-named CREATE INDEX IF NOT EXISTS would ` +\n `silently no-op against the system index instead of creating ` +\n `the declared one.`,\n );\n }\n }\n}\n\n/**\n * Runtime DDL for one system index — byte-compatible with the index the\n * bootstrap path creates from the Drizzle schema (same name, same\n * columns), plus `CONCURRENTLY` where the dialect supports building\n * without blocking writes.\n */\nexport function generateSystemIndexDDL(\n declaration: SystemIndexDeclaration,\n physicalTableName: string,\n options: Readonly<{ concurrent: boolean }>,\n): string {\n const name = quoteIdentifier(\n systemIndexName(physicalTableName, declaration.suffix),\n );\n const table = quoteIdentifier(physicalTableName);\n const columns = declaration.columns\n .map((column) => quoteIdentifier(column))\n .join(\", \");\n const concurrently = options.concurrent ? \"CONCURRENTLY \" : \"\";\n return `CREATE INDEX ${concurrently}IF NOT EXISTS ${name} ON ${table} (${columns});`;\n}\n"]}
|