@nicia-ai/typegraph 0.45.0 → 0.46.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 +11 -11
- package/dist/backend/drizzle/indexes.d.cts +1 -1
- package/dist/backend/drizzle/indexes.d.ts +1 -1
- package/dist/backend/drizzle/indexes.js +7 -7
- package/dist/backend/index.cjs +53 -54
- package/dist/backend/index.d.cts +3 -3
- package/dist/backend/index.d.ts +3 -3
- package/dist/backend/index.js +13 -14
- package/dist/backend/postgres/index.cjs +29 -30
- package/dist/backend/postgres/index.d.cts +7 -7
- package/dist/backend/postgres/index.d.ts +7 -7
- package/dist/backend/postgres/index.js +16 -17
- package/dist/backend/postgres/pglite-store.cjs +48 -42
- package/dist/backend/postgres/pglite-store.cjs.map +1 -1
- package/dist/backend/postgres/pglite-store.d.cts +15 -9
- package/dist/backend/postgres/pglite-store.d.ts +15 -9
- package/dist/backend/postgres/pglite-store.js +44 -38
- package/dist/backend/postgres/pglite-store.js.map +1 -1
- package/dist/backend/postgres/pglite.cjs +18 -19
- package/dist/backend/postgres/pglite.d.cts +4 -4
- package/dist/backend/postgres/pglite.d.ts +4 -4
- package/dist/backend/postgres/pglite.js +17 -18
- package/dist/backend/sqlite/index.cjs +26 -27
- package/dist/backend/sqlite/index.d.cts +6 -6
- package/dist/backend/sqlite/index.d.ts +6 -6
- package/dist/backend/sqlite/index.js +14 -15
- package/dist/backend/sqlite/libsql.cjs +21 -22
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +15 -8
- package/dist/backend/sqlite/libsql.d.ts +15 -8
- package/dist/backend/sqlite/libsql.js +17 -18
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local-store.cjs +49 -43
- package/dist/backend/sqlite/local-store.cjs.map +1 -1
- package/dist/backend/sqlite/local-store.d.cts +15 -10
- package/dist/backend/sqlite/local-store.d.ts +15 -10
- package/dist/backend/sqlite/local-store.js +45 -39
- package/dist/backend/sqlite/local-store.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +19 -20
- package/dist/backend/sqlite/local.d.cts +3 -3
- package/dist/backend/sqlite/local.d.ts +3 -3
- package/dist/backend/sqlite/local.js +17 -18
- package/dist/{chunk-S3ZRKJHY.js → chunk-2LG2XB2M.js} +3 -3
- package/dist/{chunk-S3ZRKJHY.js.map → chunk-2LG2XB2M.js.map} +1 -1
- package/dist/{chunk-7PF2L3H6.cjs → chunk-2NA5DYLO.cjs} +4 -4
- package/dist/{chunk-7PF2L3H6.cjs.map → chunk-2NA5DYLO.cjs.map} +1 -1
- package/dist/chunk-2Z2Z3ZD6.js +58 -0
- package/dist/chunk-2Z2Z3ZD6.js.map +1 -0
- package/dist/{chunk-VVQM4CZD.cjs → chunk-3DHZCOT7.cjs} +20 -20
- package/dist/{chunk-VVQM4CZD.cjs.map → chunk-3DHZCOT7.cjs.map} +1 -1
- package/dist/{chunk-JXUTCSXX.cjs → chunk-4UGOKMI5.cjs} +250 -158
- package/dist/chunk-4UGOKMI5.cjs.map +1 -0
- package/dist/{chunk-RFRM3Q5K.js → chunk-5262ZMTR.js} +14 -5
- package/dist/chunk-5262ZMTR.js.map +1 -0
- package/dist/{chunk-QRNYDV5Z.js → chunk-5763DULU.js} +214 -69
- package/dist/chunk-5763DULU.js.map +1 -0
- package/dist/{chunk-BGYJW37L.js → chunk-5UVRGXD3.js} +277 -7
- package/dist/chunk-5UVRGXD3.js.map +1 -0
- package/dist/{chunk-QR24DJDF.cjs → chunk-62ZP23AW.cjs} +15 -15
- package/dist/{chunk-QR24DJDF.cjs.map → chunk-62ZP23AW.cjs.map} +1 -1
- package/dist/{chunk-ZI6VQSZA.cjs → chunk-65E3XWGF.cjs} +724 -577
- package/dist/chunk-65E3XWGF.cjs.map +1 -0
- package/dist/{chunk-S4KQ5LV4.js → chunk-775A4ZMN.js} +40 -6
- package/dist/chunk-775A4ZMN.js.map +1 -0
- package/dist/{chunk-J2ICGNHO.cjs → chunk-7BQXPCGN.cjs} +830 -169
- package/dist/chunk-7BQXPCGN.cjs.map +1 -0
- package/dist/{chunk-FJMPR3OH.cjs → chunk-7EO3TCQB.cjs} +33 -7
- package/dist/chunk-7EO3TCQB.cjs.map +1 -0
- package/dist/{chunk-DXEEHSGN.js → chunk-7VQXLT5O.js} +436 -43
- package/dist/chunk-7VQXLT5O.js.map +1 -0
- package/dist/chunk-A4OC4DVN.cjs +12 -0
- package/dist/{chunk-4SZ6XPTG.cjs.map → chunk-A4OC4DVN.cjs.map} +1 -1
- package/dist/{chunk-TDXIBCGY.cjs → chunk-A7J2YDDI.cjs} +5 -3
- package/dist/chunk-A7J2YDDI.cjs.map +1 -0
- package/dist/{chunk-55ITBQJI.js → chunk-AKLS3BYZ.js} +56 -5
- package/dist/chunk-AKLS3BYZ.js.map +1 -0
- package/dist/{chunk-D7PG5D5K.js → chunk-AMKPPFUO.js} +32 -6
- package/dist/chunk-AMKPPFUO.js.map +1 -0
- package/dist/{chunk-WUFASQUO.js → chunk-ASTI57H3.js} +3 -3
- package/dist/{chunk-WUFASQUO.js.map → chunk-ASTI57H3.js.map} +1 -1
- package/dist/{chunk-4QIKLIGG.js → chunk-BKCUOV7A.js} +15 -5
- package/dist/chunk-BKCUOV7A.js.map +1 -0
- package/dist/{chunk-JQXSZHF2.cjs → chunk-BSFJMMV3.cjs} +134 -7
- package/dist/chunk-BSFJMMV3.cjs.map +1 -0
- package/dist/{chunk-4GUTQPVO.js → chunk-C23WSN5E.js} +185 -24
- package/dist/chunk-C23WSN5E.js.map +1 -0
- package/dist/{chunk-QLUXRWKL.js → chunk-CBTIUB76.js} +3 -3
- package/dist/{chunk-QLUXRWKL.js.map → chunk-CBTIUB76.js.map} +1 -1
- package/dist/chunk-CMWHLBVN.cjs +2082 -0
- package/dist/chunk-CMWHLBVN.cjs.map +1 -0
- package/dist/{chunk-QB6VMOJ2.cjs → chunk-CXBHOOIQ.cjs} +45 -10
- package/dist/chunk-CXBHOOIQ.cjs.map +1 -0
- package/dist/{chunk-FL5UQRES.js → chunk-DCQVHAYQ.js} +5 -5
- package/dist/{chunk-FL5UQRES.js.map → chunk-DCQVHAYQ.js.map} +1 -1
- package/dist/chunk-DTVWX77L.cjs +3432 -0
- package/dist/chunk-DTVWX77L.cjs.map +1 -0
- package/dist/chunk-DYATYRY4.js +47 -0
- package/dist/chunk-DYATYRY4.js.map +1 -0
- package/dist/chunk-E4WNQBEF.cjs +217 -0
- package/dist/chunk-E4WNQBEF.cjs.map +1 -0
- package/dist/{chunk-G6Q5UM7U.js → chunk-FWJKWH6U.js} +5 -3
- package/dist/chunk-FWJKWH6U.js.map +1 -0
- package/dist/chunk-GF3KXUTW.js +3393 -0
- package/dist/chunk-GF3KXUTW.js.map +1 -0
- package/dist/{chunk-VTN3C3CH.js → chunk-HFHTMECK.js} +7 -7
- package/dist/{chunk-VTN3C3CH.js.map → chunk-HFHTMECK.js.map} +1 -1
- package/dist/{chunk-FLEQ2HBK.js → chunk-I5MOXA4H.js} +20 -14
- package/dist/chunk-I5MOXA4H.js.map +1 -0
- package/dist/{chunk-4MB3AQAQ.js → chunk-J3WZ3FA2.js} +77 -3
- package/dist/chunk-J3WZ3FA2.js.map +1 -0
- package/dist/{chunk-UR7W5YQK.js → chunk-JBQQ7THH.js} +5 -3
- package/dist/chunk-JBQQ7THH.js.map +1 -0
- package/dist/{chunk-TKP5T34P.js → chunk-JXA2ZP2Q.js} +6 -16
- package/dist/chunk-JXA2ZP2Q.js.map +1 -0
- package/dist/{chunk-GYA4JRP5.js → chunk-JXXDZTMN.js} +2 -2
- package/dist/chunk-JXXDZTMN.js.map +1 -0
- package/dist/chunk-JZUR7ZWE.js +254 -0
- package/dist/chunk-JZUR7ZWE.js.map +1 -0
- package/dist/{chunk-42PYUGLS.js → chunk-K5ELX2GT.js} +108 -8
- package/dist/chunk-K5ELX2GT.js.map +1 -0
- package/dist/{chunk-Q6EDCUXV.js → chunk-L65OU2U3.js} +556 -204
- package/dist/chunk-L65OU2U3.js.map +1 -0
- package/dist/{chunk-D54WH24V.cjs → chunk-LBJKZXDE.cjs} +115 -13
- package/dist/chunk-LBJKZXDE.cjs.map +1 -0
- package/dist/{chunk-FQ7ZPOTZ.js → chunk-LGHCOKTT.js} +637 -493
- package/dist/chunk-LGHCOKTT.js.map +1 -0
- package/dist/chunk-M3WP7RQZ.js +736 -0
- package/dist/chunk-M3WP7RQZ.js.map +1 -0
- package/dist/{chunk-4MEWSUVM.cjs → chunk-M4BDU5RX.cjs} +12 -12
- package/dist/chunk-M4BDU5RX.cjs.map +1 -0
- package/dist/chunk-MCLYU6BN.cjs +332 -0
- package/dist/chunk-MCLYU6BN.cjs.map +1 -0
- package/dist/{chunk-MIJKEVV7.js → chunk-MSY7FSX4.js} +37 -4
- package/dist/chunk-MSY7FSX4.js.map +1 -0
- package/dist/{chunk-H7VE3FL4.cjs → chunk-MUK4BU7K.cjs} +519 -125
- package/dist/chunk-MUK4BU7K.cjs.map +1 -0
- package/dist/{chunk-D56XG4EI.cjs → chunk-MXJDTH5B.cjs} +56 -45
- package/dist/chunk-MXJDTH5B.cjs.map +1 -0
- package/dist/{chunk-5EKPX6QU.js → chunk-MZLPX2R7.js} +8 -9
- package/dist/chunk-MZLPX2R7.js.map +1 -0
- package/dist/chunk-N66HCGCY.cjs +57 -0
- package/dist/chunk-N66HCGCY.cjs.map +1 -0
- package/dist/{chunk-CPEL3YIR.cjs → chunk-NFCVHQ5P.cjs} +55 -22
- package/dist/chunk-NFCVHQ5P.cjs.map +1 -0
- package/dist/{chunk-C4F7VJ5D.cjs → chunk-NI72YOJB.cjs} +84 -2
- package/dist/chunk-NI72YOJB.cjs.map +1 -0
- package/dist/{chunk-BNS75YNF.cjs → chunk-NK5Q7UNE.cjs} +10 -20
- package/dist/chunk-NK5Q7UNE.cjs.map +1 -0
- package/dist/{chunk-TKORQCG4.js → chunk-NLI2AVEF.js} +386 -862
- package/dist/chunk-NLI2AVEF.js.map +1 -0
- package/dist/{chunk-YMTXMPV6.js → chunk-NMWDXFPH.js} +4 -4
- package/dist/{chunk-YMTXMPV6.js.map → chunk-NMWDXFPH.js.map} +1 -1
- package/dist/{chunk-J7LXTUTP.cjs → chunk-PF6F5NLJ.cjs} +604 -1094
- package/dist/chunk-PF6F5NLJ.cjs.map +1 -0
- package/dist/{chunk-NAAMUYMS.cjs → chunk-PNN7RHVR.cjs} +58 -48
- package/dist/chunk-PNN7RHVR.cjs.map +1 -0
- package/dist/{chunk-YOALGKRE.cjs → chunk-PNTCATDE.cjs} +3528 -1763
- package/dist/chunk-PNTCATDE.cjs.map +1 -0
- package/dist/{chunk-6DCB664D.js → chunk-PQBQG7IM.js} +3 -3
- package/dist/{chunk-6DCB664D.js.map → chunk-PQBQG7IM.js.map} +1 -1
- package/dist/{chunk-UCQ3BFSY.cjs → chunk-PT7RIRIZ.cjs} +684 -332
- package/dist/chunk-PT7RIRIZ.cjs.map +1 -0
- package/dist/{chunk-ACSVZPK7.cjs → chunk-PWLJ77UV.cjs} +5 -3
- package/dist/chunk-PWLJ77UV.cjs.map +1 -0
- package/dist/chunk-Q3G6A4I3.cjs +755 -0
- package/dist/chunk-Q3G6A4I3.cjs.map +1 -0
- package/dist/{chunk-Z3WO6MND.cjs → chunk-RMQLSPA2.cjs} +297 -27
- package/dist/chunk-RMQLSPA2.cjs.map +1 -0
- package/dist/{chunk-SJDMVITW.cjs → chunk-RT5ZY4XA.cjs} +6 -5
- package/dist/chunk-RT5ZY4XA.cjs.map +1 -0
- package/dist/{chunk-ID4WXTKL.js → chunk-S6PW7VV5.js} +2382 -617
- package/dist/chunk-S6PW7VV5.js.map +1 -0
- package/dist/{chunk-4GUBTVPV.js → chunk-T4XNKYXB.js} +780 -126
- package/dist/chunk-T4XNKYXB.js.map +1 -0
- package/dist/{chunk-YDWLUT5V.cjs → chunk-TQR4KBY2.cjs} +323 -178
- package/dist/chunk-TQR4KBY2.cjs.map +1 -0
- package/dist/{chunk-OOA273IJ.cjs → chunk-U5SON7R2.cjs} +27 -27
- package/dist/{chunk-OOA273IJ.cjs.map → chunk-U5SON7R2.cjs.map} +1 -1
- package/dist/{chunk-IX64T5OL.cjs → chunk-U63GDNRC.cjs} +32 -26
- package/dist/chunk-U63GDNRC.cjs.map +1 -0
- package/dist/{chunk-WDBXJOU5.cjs → chunk-UDISNXDL.cjs} +56 -47
- package/dist/chunk-UDISNXDL.cjs.map +1 -0
- package/dist/{chunk-EFEOOCJ3.js → chunk-UV3SN74I.js} +5 -5
- package/dist/{chunk-EFEOOCJ3.js.map → chunk-UV3SN74I.js.map} +1 -1
- package/dist/{chunk-U5W4LKZV.cjs → chunk-VCRRKBLN.cjs} +9 -9
- package/dist/{chunk-U5W4LKZV.cjs.map → chunk-VCRRKBLN.cjs.map} +1 -1
- package/dist/{chunk-ISLPNELU.js → chunk-VGTJPTIC.js} +16 -5
- package/dist/chunk-VGTJPTIC.js.map +1 -0
- package/dist/chunk-VLT6PEWR.cjs +60 -0
- package/dist/chunk-VLT6PEWR.cjs.map +1 -0
- package/dist/chunk-VQH4VAWD.cjs +12 -0
- package/dist/{chunk-B3F2D3SP.cjs.map → chunk-VQH4VAWD.cjs.map} +1 -1
- package/dist/{chunk-SNXVDZAJ.js → chunk-W6OG3HDG.js} +5 -4
- package/dist/chunk-W6OG3HDG.js.map +1 -0
- package/dist/chunk-WDGA7IYB.js +207 -0
- package/dist/chunk-WDGA7IYB.js.map +1 -0
- package/dist/chunk-WQZLUGVR.js +2057 -0
- package/dist/chunk-WQZLUGVR.js.map +1 -0
- package/dist/{chunk-EKFUG4G7.cjs → chunk-XBYVV3MP.cjs} +60 -5
- package/dist/chunk-XBYVV3MP.cjs.map +1 -0
- package/dist/{chunk-5GAONX5G.cjs → chunk-XCAGZAKP.cjs} +7 -7
- package/dist/{chunk-5GAONX5G.cjs.map → chunk-XCAGZAKP.cjs.map} +1 -1
- package/dist/chunk-XL7SLCXS.js +309 -0
- package/dist/chunk-XL7SLCXS.js.map +1 -0
- package/dist/{chunk-SVJ5GEXW.cjs → chunk-XUO3KQFO.cjs} +2 -2
- package/dist/chunk-XUO3KQFO.cjs.map +1 -0
- package/dist/{chunk-F4NHQHEZ.cjs → chunk-YAAM3M2S.cjs} +10 -10
- package/dist/{chunk-F4NHQHEZ.cjs.map → chunk-YAAM3M2S.cjs.map} +1 -1
- package/dist/{chunk-RUQS6M7G.js → chunk-YBFHZUXX.js} +6 -6
- package/dist/chunk-YBFHZUXX.js.map +1 -0
- package/dist/{chunk-KMXWZLQX.cjs → chunk-YBQOHKHN.cjs} +99 -100
- package/dist/chunk-YBQOHKHN.cjs.map +1 -0
- package/dist/{chunk-PVUI6KGR.js → chunk-YDFDBE6D.js} +93 -6
- package/dist/chunk-YDFDBE6D.js.map +1 -0
- package/dist/{chunk-P7GTYOLB.cjs → chunk-YVWGEQJE.cjs} +297 -135
- package/dist/chunk-YVWGEQJE.cjs.map +1 -0
- package/dist/{chunk-QT6V3YRH.js → chunk-YWGVVALJ.js} +3 -3
- package/dist/{chunk-QT6V3YRH.js.map → chunk-YWGVVALJ.js.map} +1 -1
- package/dist/core/index.cjs +40 -40
- package/dist/core/index.d.cts +4 -5
- package/dist/core/index.d.ts +4 -5
- package/dist/core/index.js +8 -8
- package/dist/{ddl-BG4J805L.d.cts → ddl-BJcOp4WZ.d.cts} +3 -3
- package/dist/{ddl-CgiS9QLj.d.ts → ddl-BXfGHbPN.d.ts} +3 -3
- package/dist/graph-extension/index.cjs +26 -22
- package/dist/graph-extension/index.d.cts +16 -6
- package/dist/graph-extension/index.d.ts +16 -6
- package/dist/graph-extension/index.js +7 -7
- package/dist/graph-merge/index.cjs +2459 -654
- package/dist/graph-merge/index.cjs.map +1 -1
- package/dist/graph-merge/index.d.cts +170 -33
- package/dist/graph-merge/index.d.ts +170 -33
- package/dist/graph-merge/index.js +2269 -467
- package/dist/graph-merge/index.js.map +1 -1
- package/dist/{index-C3y_98iN.d.cts → index-BSHvKfok.d.ts} +221 -10
- package/dist/{index-BBxZCUdu.d.ts → index-DxaYCv8Y.d.cts} +221 -10
- package/dist/index.cjs +330 -268
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +590 -576
- package/dist/index.d.ts +590 -576
- package/dist/index.js +73 -49
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +17 -17
- package/dist/indexes/index.d.cts +4 -4
- package/dist/indexes/index.d.ts +4 -4
- package/dist/indexes/index.js +10 -10
- package/dist/interchange/index.cjs +165 -51
- package/dist/interchange/index.cjs.map +1 -1
- package/dist/interchange/index.d.cts +261 -16
- package/dist/interchange/index.d.ts +261 -16
- package/dist/interchange/index.js +128 -25
- package/dist/interchange/index.js.map +1 -1
- package/dist/{manager-YoLEfcc1.d.ts → manager-CfZAimti.d.ts} +36 -5
- package/dist/{manager-KS7CGQQT.d.cts → manager-HGk6E_HW.d.cts} +36 -5
- package/dist/{materialize-indexes-Bhhyb1B3.d.ts → materialize-indexes-6A7dWGtb.d.cts} +10 -2
- package/dist/{materialize-indexes-OHRWypW6.d.cts → materialize-indexes-BMJP6Tms.d.ts} +10 -2
- package/dist/{postgres-DpkW3R5Y.d.cts → postgres-DFYWENdR.d.cts} +1961 -439
- package/dist/{postgres-DwqyIniy.d.ts → postgres-e7a9TdvR.d.ts} +1961 -439
- package/dist/profiler/index.cjs +15 -15
- package/dist/profiler/index.d.cts +9 -10
- package/dist/profiler/index.d.ts +9 -10
- package/dist/profiler/index.js +4 -4
- package/dist/provenance/index.cjs +46 -48
- 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 +12 -14
- package/dist/provenance/index.js.map +1 -1
- package/dist/schema/index.cjs +50 -48
- package/dist/schema/index.d.cts +9 -16
- package/dist/schema/index.d.ts +9 -16
- package/dist/schema/index.js +23 -21
- package/dist/{searchable-DLWEfC4a.d.ts → searchable-9OQoPuRs.d.ts} +1 -2
- package/dist/{searchable-CIZL8Hyw.d.cts → searchable-CIje5XYD.d.cts} +1 -2
- package/dist/{sqlite-DY0WODUK.d.cts → sqlite-DerU5tc7.d.ts} +2029 -347
- package/dist/{sqlite-L-VIRzqA.d.ts → sqlite-DitnISa9.d.cts} +2029 -347
- package/dist/{store-view-A85FFRnk.d.cts → store-B0h6x7wo.d.cts} +1289 -767
- package/dist/{store-view-66p92IPi.d.ts → store-ClQ-MZQS.d.ts} +1289 -767
- package/dist/{temporal-BNbjXqer.d.cts → temporal-Bn-Fi8FJ.d.cts} +1 -1
- package/dist/{temporal-Bob6Nfbp.d.ts → temporal-BtM4UALv.d.ts} +1 -1
- package/dist/{types-DeORZhxn.d.cts → types-CoIx8HX5.d.cts} +1 -1
- package/dist/{types-Ch9a0Dx6.d.ts → types-HkveCCx0.d.cts} +726 -5
- package/dist/{types-Ch9a0Dx6.d.cts → types-HkveCCx0.d.ts} +726 -5
- package/dist/{types-ClCzT-dT.d.ts → types-KFfk-8Ah.d.ts} +1 -1
- package/dist/{where-DPw52ksb.d.cts → where--fk7_0kv.d.cts} +1 -1
- package/dist/{where-kWUZPvEA.d.ts → where-ws5hf-Ov.d.ts} +1 -1
- package/package.json +3 -3
- package/dist/chunk-2L54C2C2.js +0 -144
- package/dist/chunk-2L54C2C2.js.map +0 -1
- package/dist/chunk-35S6P5ZU.js +0 -27
- package/dist/chunk-35S6P5ZU.js.map +0 -1
- package/dist/chunk-42PYUGLS.js.map +0 -1
- package/dist/chunk-4GUBTVPV.js.map +0 -1
- package/dist/chunk-4GUTQPVO.js.map +0 -1
- package/dist/chunk-4MB3AQAQ.js.map +0 -1
- package/dist/chunk-4MEWSUVM.cjs.map +0 -1
- package/dist/chunk-4QIKLIGG.js.map +0 -1
- package/dist/chunk-4SZ6XPTG.cjs +0 -12
- package/dist/chunk-55ITBQJI.js.map +0 -1
- package/dist/chunk-5EKPX6QU.js.map +0 -1
- package/dist/chunk-6RYPD3NJ.cjs +0 -1282
- package/dist/chunk-6RYPD3NJ.cjs.map +0 -1
- package/dist/chunk-764JHTLT.cjs +0 -15
- package/dist/chunk-764JHTLT.cjs.map +0 -1
- package/dist/chunk-ACSVZPK7.cjs.map +0 -1
- package/dist/chunk-B3F2D3SP.cjs +0 -12
- package/dist/chunk-BGYJW37L.js.map +0 -1
- package/dist/chunk-BNS75YNF.cjs.map +0 -1
- package/dist/chunk-C4F7VJ5D.cjs.map +0 -1
- package/dist/chunk-CBKG6HEP.js +0 -1263
- package/dist/chunk-CBKG6HEP.js.map +0 -1
- package/dist/chunk-CPEL3YIR.cjs.map +0 -1
- package/dist/chunk-D54WH24V.cjs.map +0 -1
- package/dist/chunk-D56XG4EI.cjs.map +0 -1
- package/dist/chunk-D7PG5D5K.js.map +0 -1
- package/dist/chunk-DI74SMXS.cjs +0 -29
- package/dist/chunk-DI74SMXS.cjs.map +0 -1
- package/dist/chunk-DK2S42XB.js +0 -77
- package/dist/chunk-DK2S42XB.js.map +0 -1
- package/dist/chunk-DRACN6XG.js +0 -27
- package/dist/chunk-DRACN6XG.js.map +0 -1
- package/dist/chunk-DXEEHSGN.js.map +0 -1
- package/dist/chunk-EKFUG4G7.cjs.map +0 -1
- package/dist/chunk-EQ7JKLZO.cjs +0 -157
- package/dist/chunk-EQ7JKLZO.cjs.map +0 -1
- package/dist/chunk-FJMPR3OH.cjs.map +0 -1
- package/dist/chunk-FLEQ2HBK.js.map +0 -1
- package/dist/chunk-FQ7ZPOTZ.js.map +0 -1
- package/dist/chunk-G6Q5UM7U.js.map +0 -1
- package/dist/chunk-GYA4JRP5.js.map +0 -1
- package/dist/chunk-H7VE3FL4.cjs.map +0 -1
- package/dist/chunk-ID4WXTKL.js.map +0 -1
- package/dist/chunk-ISLPNELU.js.map +0 -1
- package/dist/chunk-ITE4IXAK.js +0 -25
- package/dist/chunk-ITE4IXAK.js.map +0 -1
- package/dist/chunk-IX64T5OL.cjs.map +0 -1
- package/dist/chunk-J2ICGNHO.cjs.map +0 -1
- package/dist/chunk-J7LXTUTP.cjs.map +0 -1
- package/dist/chunk-JQXSZHF2.cjs.map +0 -1
- package/dist/chunk-JXUTCSXX.cjs.map +0 -1
- package/dist/chunk-KCO5EFJU.js +0 -79
- package/dist/chunk-KCO5EFJU.js.map +0 -1
- package/dist/chunk-KKYELPZ2.cjs +0 -83
- package/dist/chunk-KKYELPZ2.cjs.map +0 -1
- package/dist/chunk-KMXWZLQX.cjs.map +0 -1
- package/dist/chunk-MIJKEVV7.js.map +0 -1
- package/dist/chunk-NAAMUYMS.cjs.map +0 -1
- package/dist/chunk-P7GTYOLB.cjs.map +0 -1
- package/dist/chunk-PVUI6KGR.js.map +0 -1
- package/dist/chunk-Q6EDCUXV.js.map +0 -1
- package/dist/chunk-QB6VMOJ2.cjs.map +0 -1
- package/dist/chunk-QC4MCOFV.cjs +0 -83
- package/dist/chunk-QC4MCOFV.cjs.map +0 -1
- package/dist/chunk-QMQLUA66.js +0 -12
- package/dist/chunk-QMQLUA66.js.map +0 -1
- package/dist/chunk-QRNYDV5Z.js.map +0 -1
- package/dist/chunk-RFRM3Q5K.js.map +0 -1
- package/dist/chunk-RUQS6M7G.js.map +0 -1
- package/dist/chunk-S4KQ5LV4.js.map +0 -1
- package/dist/chunk-SJDMVITW.cjs.map +0 -1
- package/dist/chunk-SNXVDZAJ.js.map +0 -1
- package/dist/chunk-SVJ5GEXW.cjs.map +0 -1
- package/dist/chunk-TDXIBCGY.cjs.map +0 -1
- package/dist/chunk-TKORQCG4.js.map +0 -1
- package/dist/chunk-TKP5T34P.js.map +0 -1
- package/dist/chunk-TRF4EBJT.cjs +0 -30
- package/dist/chunk-TRF4EBJT.cjs.map +0 -1
- package/dist/chunk-UCQ3BFSY.cjs.map +0 -1
- package/dist/chunk-UR7W5YQK.js.map +0 -1
- package/dist/chunk-V34A6R5V.js +0 -134
- package/dist/chunk-V34A6R5V.js.map +0 -1
- package/dist/chunk-WDAVPX46.js +0 -81
- package/dist/chunk-WDAVPX46.js.map +0 -1
- package/dist/chunk-WDBXJOU5.cjs.map +0 -1
- package/dist/chunk-YDWLUT5V.cjs.map +0 -1
- package/dist/chunk-YOALGKRE.cjs.map +0 -1
- package/dist/chunk-Z3WO6MND.cjs.map +0 -1
- package/dist/chunk-ZDH3DX3C.cjs +0 -30
- package/dist/chunk-ZDH3DX3C.cjs.map +0 -1
- package/dist/chunk-ZI6VQSZA.cjs.map +0 -1
- package/dist/chunk-ZTAJL4DT.cjs +0 -85
- package/dist/chunk-ZTAJL4DT.cjs.map +0 -1
- package/dist/define-graph-BGrJahvp.d.ts +0 -173
- package/dist/define-graph-alREY2wj.d.cts +0 -173
|
@@ -1,56 +1,14 @@
|
|
|
1
|
-
import { groupBy, chunk } from './chunk-
|
|
2
|
-
import { createSqlSchema } from './chunk-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { requireDefined, isPresent } from './chunk-
|
|
10
|
-
import { resolveEmbeddingFields, getSearchableFields, DEFAULT_SEARCHABLE_LANGUAGE } from './chunk-PC2UBAUB.js';
|
|
11
|
-
import { ConfigurationError, UnsupportedPredicateError, CompilerInvariantError, CardinalityError, EndpointError, DisjointError, UniquenessError, RestrictedDeleteError } from './chunk-4MB3AQAQ.js';
|
|
12
|
-
import { normalizeJsonPointer, joinJsonPointers, jsonPointer } from './chunk-G6Q5UM7U.js';
|
|
1
|
+
import { withRecordedRelationsPrecondition, groupBy, chunk } from './chunk-JZUR7ZWE.js';
|
|
2
|
+
import { createSqlSchema } from './chunk-MSY7FSX4.js';
|
|
3
|
+
import { inheritSerializedTransactionResource, createBackendOverlay, rowPropsToJsonText } from './chunk-AKLS3BYZ.js';
|
|
4
|
+
import { nowIso, optionalRecordedInstantParts, createRecordedInstant, parseRecordedInstant, RECORDED_MAX_REVISION, canonicalizeDatabaseTimestamp } from './chunk-XL7SLCXS.js';
|
|
5
|
+
import { sql, asCompiledRowsSql, likeEscapeClause, asCompiledStatementSql, LIKE_ESCAPE_CHARACTER } from './chunk-PQBQG7IM.js';
|
|
6
|
+
import { resolveFieldTypeInfoAtJsonPointer } from './chunk-W6OG3HDG.js';
|
|
7
|
+
import { ConfigurationError, UnsupportedPredicateError, CompilerInvariantError } from './chunk-J3WZ3FA2.js';
|
|
8
|
+
import { normalizeJsonPointer, joinJsonPointers, jsonPointer } from './chunk-FWJKWH6U.js';
|
|
9
|
+
import { requireDefined, isPresent } from './chunk-DYATYRY4.js';
|
|
13
10
|
import { nanoid } from 'nanoid';
|
|
14
11
|
|
|
15
|
-
// src/store/types.ts
|
|
16
|
-
var AUTO_REFRESH_STATISTICS_ROW_THRESHOLD = 1e3;
|
|
17
|
-
var TRANSACTION_RUNTIME = typeGraphGlobalSymbol(
|
|
18
|
-
"transaction-runtime-v1"
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
// src/store/runtime-port.ts
|
|
22
|
-
var STORE_RUNTIME = typeGraphGlobalSymbol("store-runtime-v1");
|
|
23
|
-
function storeRuntime(store) {
|
|
24
|
-
const runtime = store[STORE_RUNTIME];
|
|
25
|
-
if (runtime === void 0) {
|
|
26
|
-
throw new TypeError(
|
|
27
|
-
"Cannot access this Store's runtime port. The Store may come from an incompatible TypeGraph version."
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
return runtime;
|
|
31
|
-
}
|
|
32
|
-
function storeBackend(store) {
|
|
33
|
-
return storeRuntime(store).backend;
|
|
34
|
-
}
|
|
35
|
-
function transactionBackend(transaction) {
|
|
36
|
-
const runtime = transaction[TRANSACTION_RUNTIME];
|
|
37
|
-
if (runtime === void 0) {
|
|
38
|
-
throw new TypeError(
|
|
39
|
-
"Cannot access this transaction's runtime port. The transaction may come from an incompatible TypeGraph version."
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
return runtime.backend;
|
|
43
|
-
}
|
|
44
|
-
function transactionNodeOperationHookRunner(transaction) {
|
|
45
|
-
const runtime = transaction[TRANSACTION_RUNTIME];
|
|
46
|
-
if (runtime === void 0) {
|
|
47
|
-
throw new TypeError(
|
|
48
|
-
"Cannot access this transaction's runtime port. The transaction may come from an incompatible TypeGraph version."
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
return runtime.runNodeOperationHooks;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
12
|
// src/query/compiler/temporal.ts
|
|
55
13
|
var pinnedReadInstant;
|
|
56
14
|
function withPinnedReadInstant(emit) {
|
|
@@ -74,6 +32,7 @@ function currentReadInstantFor(mode) {
|
|
|
74
32
|
}
|
|
75
33
|
function compileTemporalFilter(options) {
|
|
76
34
|
const { mode, asOf, tableAlias, currentTimestamp, recordedAsOf } = options;
|
|
35
|
+
const recorded = optionalRecordedInstantParts(recordedAsOf, "recordedAsOf");
|
|
77
36
|
const prefix = tableAlias ? sql.raw(`${tableAlias}.`) : sql.raw("");
|
|
78
37
|
const deletedAt = sql`${prefix}deleted_at`;
|
|
79
38
|
const validFrom = sql`${prefix}valid_from`;
|
|
@@ -81,7 +40,7 @@ function compileTemporalFilter(options) {
|
|
|
81
40
|
const validFilter = (() => {
|
|
82
41
|
switch (mode) {
|
|
83
42
|
case "current": {
|
|
84
|
-
const now =
|
|
43
|
+
const now = recorded === void 0 ? currentTimestamp ?? currentReadInstant() : sql`${recorded.recordedAt}`;
|
|
85
44
|
return sql`${deletedAt} IS NULL AND (${validFrom} IS NULL OR ${validFrom} <= ${now}) AND (${validTo} IS NULL OR ${validTo} > ${now})`;
|
|
86
45
|
}
|
|
87
46
|
case "asOf": {
|
|
@@ -101,14 +60,11 @@ function compileTemporalFilter(options) {
|
|
|
101
60
|
}
|
|
102
61
|
}
|
|
103
62
|
})();
|
|
104
|
-
if (
|
|
63
|
+
if (recorded === void 0) return validFilter;
|
|
105
64
|
const recordedFrom = sql`${prefix}recorded_from`;
|
|
106
65
|
const recordedTo = sql`${prefix}recorded_to`;
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
"recordedAsOf"
|
|
110
|
-
).revision;
|
|
111
|
-
return sql`(${validFilter}) AND ${recordedFrom} <= ${recordedRevision} AND ${recordedRevision} < ${recordedTo}`;
|
|
66
|
+
const { revision } = recorded;
|
|
67
|
+
return sql`(${validFilter}) AND ${recordedFrom} <= ${revision} AND ${revision} < ${recordedTo}`;
|
|
112
68
|
}
|
|
113
69
|
function extractTemporalOptions(ast, tableAlias) {
|
|
114
70
|
return {
|
|
@@ -1068,10 +1024,22 @@ async function writeRecordedClock(target, schema, graphId, parts) {
|
|
|
1068
1024
|
INSERT INTO ${schema.recordedClockTable} (graph_id, revision, recorded_at)
|
|
1069
1025
|
VALUES (${graphId}, ${parts.revision}, ${parts.recordedAt})
|
|
1070
1026
|
ON CONFLICT (graph_id) DO UPDATE
|
|
1071
|
-
SET revision =
|
|
1027
|
+
SET revision = excluded.revision, recorded_at = excluded.recorded_at
|
|
1028
|
+
WHERE ${schema.recordedClockTable}.revision < excluded.revision
|
|
1072
1029
|
`
|
|
1073
1030
|
);
|
|
1074
1031
|
}
|
|
1032
|
+
async function assertRecordedClockAdvanced(target, schema, graphId, revision) {
|
|
1033
|
+
const stored = await readRecordedClockParts(target, schema, graphId);
|
|
1034
|
+
if (stored?.revision === revision) return;
|
|
1035
|
+
throw new ConfigurationError(
|
|
1036
|
+
"Recorded commit allocation was refused: the supplied previous revision was stale, so the write would have moved the graph's revision clock backward.",
|
|
1037
|
+
{ graphId, allocatedRevision: revision, storedRevision: stored?.revision },
|
|
1038
|
+
{
|
|
1039
|
+
suggestion: "Read the previous revision inside the same transaction that allocates the commit (omit previousRevision), or hold the per-graph write lock across the read and the allocation."
|
|
1040
|
+
}
|
|
1041
|
+
);
|
|
1042
|
+
}
|
|
1075
1043
|
async function lockRecordedClock(target, schema, graphId, ownsWriteLock) {
|
|
1076
1044
|
switch (target.dialect) {
|
|
1077
1045
|
case "postgres": {
|
|
@@ -1112,6 +1080,9 @@ async function allocateRecordedCommit(target, schema, graphId, ownsWriteLock, pr
|
|
|
1112
1080
|
}
|
|
1113
1081
|
const instant = createRecordedInstant(revision, recordedAt);
|
|
1114
1082
|
await writeRecordedClock(target, schema, graphId, { revision, recordedAt });
|
|
1083
|
+
if (previousRevision !== void 0) {
|
|
1084
|
+
await assertRecordedClockAdvanced(target, schema, graphId, revision);
|
|
1085
|
+
}
|
|
1115
1086
|
return { instant, revision, recordedAt };
|
|
1116
1087
|
}
|
|
1117
1088
|
async function advanceRevisionClock(target, schema, graphId, ownsWriteLock, previousRevision) {
|
|
@@ -1173,6 +1144,7 @@ var GRAPH_BACKEND_PROJECTION_KEYS = [
|
|
|
1173
1144
|
"commitSchemaVersion",
|
|
1174
1145
|
"commitSchemaVersionIfKindsEmpty",
|
|
1175
1146
|
"lockSchemaVersionForWrite",
|
|
1147
|
+
"commitSchemaVersionWithPreflight",
|
|
1176
1148
|
"setActiveVersion",
|
|
1177
1149
|
"schemaWriteTransaction",
|
|
1178
1150
|
"upsertEmbedding",
|
|
@@ -1212,7 +1184,11 @@ var GRAPH_BACKEND_PROJECTION_KEYS = [
|
|
|
1212
1184
|
"deleteVectorSlotContribution",
|
|
1213
1185
|
"verifyContributions",
|
|
1214
1186
|
"repairContributions",
|
|
1187
|
+
"probeContributions",
|
|
1188
|
+
"rebuildContribution",
|
|
1215
1189
|
"ensureFulltextTable",
|
|
1190
|
+
"ensureIdentityTables",
|
|
1191
|
+
"identityTableDdl",
|
|
1216
1192
|
"getReconciliationMarker",
|
|
1217
1193
|
"setReconciliationMarker",
|
|
1218
1194
|
"clearGraph",
|
|
@@ -1233,7 +1209,9 @@ function projectBackendMembers(backend, keys) {
|
|
|
1233
1209
|
if (!Reflect.has(backend, key)) return [];
|
|
1234
1210
|
return [[key, Reflect.get(backend, key)]];
|
|
1235
1211
|
});
|
|
1236
|
-
|
|
1212
|
+
const projection = Object.fromEntries(entries);
|
|
1213
|
+
inheritSerializedTransactionResource(projection, backend);
|
|
1214
|
+
return projection;
|
|
1237
1215
|
}
|
|
1238
1216
|
function createGraphBackendProjection(backend) {
|
|
1239
1217
|
return projectBackendMembers(backend, GRAPH_BACKEND_PROJECTION_KEYS);
|
|
@@ -1274,6 +1252,7 @@ async function runInsertBatch(dispatch, params) {
|
|
|
1274
1252
|
}
|
|
1275
1253
|
}
|
|
1276
1254
|
async function runInsertBatchReturning(dispatch, params) {
|
|
1255
|
+
if (params.length === 0) return [];
|
|
1277
1256
|
if (dispatch.batchReturning !== void 0) {
|
|
1278
1257
|
return dispatch.batchReturning(params);
|
|
1279
1258
|
}
|
|
@@ -1284,6 +1263,174 @@ async function runInsertBatchReturning(dispatch, params) {
|
|
|
1284
1263
|
return rows;
|
|
1285
1264
|
}
|
|
1286
1265
|
|
|
1266
|
+
// src/identity/historical-sql.ts
|
|
1267
|
+
var IDENTITY_ASSERTION_COLUMNS = sql.raw(
|
|
1268
|
+
[
|
|
1269
|
+
"graph_id",
|
|
1270
|
+
"id",
|
|
1271
|
+
"rel",
|
|
1272
|
+
"a_kind",
|
|
1273
|
+
"a_id",
|
|
1274
|
+
"b_kind",
|
|
1275
|
+
"b_id",
|
|
1276
|
+
"valid_from",
|
|
1277
|
+
"valid_to",
|
|
1278
|
+
"created_at",
|
|
1279
|
+
"updated_at",
|
|
1280
|
+
"deleted_at",
|
|
1281
|
+
"ended_by_kind",
|
|
1282
|
+
"ended_by_id"
|
|
1283
|
+
].join(", ")
|
|
1284
|
+
);
|
|
1285
|
+
function identitySqlCoordinate(coordinate, currentInstant) {
|
|
1286
|
+
return {
|
|
1287
|
+
validMode: coordinate?.valid.mode ?? "current",
|
|
1288
|
+
validAsOf: coordinate?.valid.asOf,
|
|
1289
|
+
recorded: optionalRecordedInstantParts(
|
|
1290
|
+
coordinate?.recorded?.asOf,
|
|
1291
|
+
"recorded.asOf"
|
|
1292
|
+
),
|
|
1293
|
+
currentInstant: typeof currentInstant === "string" ? sql`${currentInstant}` : currentInstant
|
|
1294
|
+
};
|
|
1295
|
+
}
|
|
1296
|
+
function validityInstant(coordinate) {
|
|
1297
|
+
if (coordinate.validMode === "asOf" && coordinate.validAsOf !== void 0) {
|
|
1298
|
+
return sql`${coordinate.validAsOf}`;
|
|
1299
|
+
}
|
|
1300
|
+
if (coordinate.recorded !== void 0) {
|
|
1301
|
+
return sql`${coordinate.recorded.recordedAt}`;
|
|
1302
|
+
}
|
|
1303
|
+
return coordinate.currentInstant;
|
|
1304
|
+
}
|
|
1305
|
+
function qualifiedColumn(alias, column) {
|
|
1306
|
+
return sql`${sql.identifier(alias)}.${sql.identifier(column)}`;
|
|
1307
|
+
}
|
|
1308
|
+
function identityNodeVisibilitySql(coordinate, alias) {
|
|
1309
|
+
const deletedAt = qualifiedColumn(alias, "deleted_at");
|
|
1310
|
+
if (coordinate.validMode === "includeTombstones") return sql`1 = 1`;
|
|
1311
|
+
if (coordinate.validMode === "includeEnded") {
|
|
1312
|
+
return sql`${deletedAt} IS NULL`;
|
|
1313
|
+
}
|
|
1314
|
+
const validFrom = qualifiedColumn(alias, "valid_from");
|
|
1315
|
+
const validTo = qualifiedColumn(alias, "valid_to");
|
|
1316
|
+
const instant = validityInstant(coordinate);
|
|
1317
|
+
return sql`
|
|
1318
|
+
${deletedAt} IS NULL
|
|
1319
|
+
AND (${validFrom} IS NULL OR ${validFrom} <= ${instant})
|
|
1320
|
+
AND (${validTo} IS NULL OR ${validTo} > ${instant})
|
|
1321
|
+
`;
|
|
1322
|
+
}
|
|
1323
|
+
function structuralFoldVisibilitySql(coordinate, alias) {
|
|
1324
|
+
const deletedAt = qualifiedColumn(alias, "deleted_at");
|
|
1325
|
+
if (coordinate.recorded !== void 0) return sql`${deletedAt} IS NULL`;
|
|
1326
|
+
if (coordinate.validMode !== "asOf") return sql`${deletedAt} IS NULL`;
|
|
1327
|
+
const createdAt = qualifiedColumn(alias, "created_at");
|
|
1328
|
+
const instant = validityInstant(coordinate);
|
|
1329
|
+
return sql`${createdAt} <= ${instant} AND (${deletedAt} IS NULL OR ${deletedAt} > ${instant})`;
|
|
1330
|
+
}
|
|
1331
|
+
function identityNodeSnapshotSource(schema, graphId, coordinate) {
|
|
1332
|
+
const table = coordinate.recorded === void 0 ? schema.nodesTable : schema.recordedNodesTable;
|
|
1333
|
+
const recordedFilter = coordinate.recorded === void 0 ? sql`` : sql`
|
|
1334
|
+
AND recorded_from <= ${coordinate.recorded.revision}
|
|
1335
|
+
AND recorded_to > ${coordinate.recorded.revision}
|
|
1336
|
+
`;
|
|
1337
|
+
return sql`
|
|
1338
|
+
SELECT kind, id, valid_from, valid_to, created_at, deleted_at
|
|
1339
|
+
FROM ${table}
|
|
1340
|
+
WHERE graph_id = ${graphId}
|
|
1341
|
+
${recordedFilter}
|
|
1342
|
+
`;
|
|
1343
|
+
}
|
|
1344
|
+
function identityAssertionSnapshotSource(schema, graphId, coordinate, relation) {
|
|
1345
|
+
const table = coordinate.recorded === void 0 ? schema.identityAssertionsTable : schema.recordedIdentityAssertionsTable;
|
|
1346
|
+
const recordedFilter = coordinate.recorded === void 0 ? sql`` : sql`
|
|
1347
|
+
AND recorded_from <= ${coordinate.recorded.revision}
|
|
1348
|
+
AND recorded_to > ${coordinate.recorded.revision}
|
|
1349
|
+
`;
|
|
1350
|
+
const relationFilter = relation === void 0 ? sql`` : sql`AND rel = ${relation}`;
|
|
1351
|
+
const instant = validityInstant(coordinate);
|
|
1352
|
+
return sql`
|
|
1353
|
+
SELECT ${IDENTITY_ASSERTION_COLUMNS}
|
|
1354
|
+
FROM ${table}
|
|
1355
|
+
WHERE graph_id = ${graphId}
|
|
1356
|
+
${recordedFilter}
|
|
1357
|
+
AND deleted_at IS NULL
|
|
1358
|
+
${relationFilter}
|
|
1359
|
+
AND valid_from <= ${instant}
|
|
1360
|
+
AND (valid_to IS NULL OR valid_to > ${instant})
|
|
1361
|
+
`;
|
|
1362
|
+
}
|
|
1363
|
+
function historicalIdentityReconstructionCtes(input) {
|
|
1364
|
+
const nodes = identityNodeSnapshotSource(
|
|
1365
|
+
input.schema,
|
|
1366
|
+
input.graphId,
|
|
1367
|
+
input.coordinate
|
|
1368
|
+
);
|
|
1369
|
+
const assertions = identityAssertionSnapshotSource(
|
|
1370
|
+
input.schema,
|
|
1371
|
+
input.graphId,
|
|
1372
|
+
input.coordinate,
|
|
1373
|
+
"same"
|
|
1374
|
+
);
|
|
1375
|
+
const sameIdEdges = input.sameIdAcrossKinds === "fold" ? sql`
|
|
1376
|
+
UNION ALL
|
|
1377
|
+
SELECT left_node.kind, left_node.id, right_node.kind, right_node.id
|
|
1378
|
+
FROM node_snapshot left_node
|
|
1379
|
+
JOIN node_snapshot right_node
|
|
1380
|
+
ON right_node.id = left_node.id
|
|
1381
|
+
AND right_node.kind <> left_node.kind
|
|
1382
|
+
WHERE ${structuralFoldVisibilitySql(input.coordinate, "left_node")}
|
|
1383
|
+
AND ${structuralFoldVisibilitySql(input.coordinate, "right_node")}
|
|
1384
|
+
` : sql``;
|
|
1385
|
+
return sql`
|
|
1386
|
+
node_snapshot(kind, id, valid_from, valid_to, created_at, deleted_at) AS (
|
|
1387
|
+
${nodes}
|
|
1388
|
+
),
|
|
1389
|
+
same_assertions(a_kind, a_id, b_kind, b_id) AS (
|
|
1390
|
+
SELECT a_kind, a_id, b_kind, b_id FROM (${assertions}) identity_assertions
|
|
1391
|
+
),
|
|
1392
|
+
identity_edges(a_kind, a_id, b_kind, b_id) AS (
|
|
1393
|
+
SELECT a_kind, a_id, b_kind, b_id FROM same_assertions
|
|
1394
|
+
UNION ALL
|
|
1395
|
+
SELECT b_kind, b_id, a_kind, a_id FROM same_assertions
|
|
1396
|
+
${sameIdEdges}
|
|
1397
|
+
),
|
|
1398
|
+
seeds(seed_kind, seed_id) AS (
|
|
1399
|
+
${input.seedSource}
|
|
1400
|
+
),
|
|
1401
|
+
identity_members(seed_kind, seed_id, kind, id) AS (
|
|
1402
|
+
SELECT seeds.seed_kind, seeds.seed_id, seeds.seed_kind, seeds.seed_id
|
|
1403
|
+
FROM seeds
|
|
1404
|
+
JOIN node_snapshot n
|
|
1405
|
+
ON n.kind = seeds.seed_kind AND n.id = seeds.seed_id
|
|
1406
|
+
WHERE ${identityNodeVisibilitySql(input.coordinate, "n")}
|
|
1407
|
+
UNION
|
|
1408
|
+
SELECT member.seed_kind, member.seed_id, edge.b_kind, edge.b_id
|
|
1409
|
+
FROM identity_members member
|
|
1410
|
+
JOIN identity_edges edge
|
|
1411
|
+
ON edge.a_kind = member.kind
|
|
1412
|
+
AND edge.a_id = member.id
|
|
1413
|
+
)
|
|
1414
|
+
`;
|
|
1415
|
+
}
|
|
1416
|
+
var IDENTITY_PEER_CLASS_COLUMNS = sql.raw(
|
|
1417
|
+
["seed_kind", "seed_id", "kind", "id"].join(", ")
|
|
1418
|
+
);
|
|
1419
|
+
function historicalIdentityPeerClassQuery(input) {
|
|
1420
|
+
const reconstruction = historicalIdentityReconstructionCtes({
|
|
1421
|
+
...input,
|
|
1422
|
+
seedSource: sql`SELECT DISTINCT a_kind, a_id FROM identity_edges`
|
|
1423
|
+
});
|
|
1424
|
+
return sql`
|
|
1425
|
+
WITH RECURSIVE
|
|
1426
|
+
${reconstruction}
|
|
1427
|
+
SELECT member.seed_kind, member.seed_id, member.kind, member.id
|
|
1428
|
+
FROM identity_members member
|
|
1429
|
+
JOIN node_snapshot n ON n.kind = member.kind AND n.id = member.id
|
|
1430
|
+
WHERE ${identityNodeVisibilitySql(input.coordinate, "n")}
|
|
1431
|
+
`;
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1287
1434
|
// src/query/compiler/predicates.ts
|
|
1288
1435
|
var COMPARISON_OP_SQL = {
|
|
1289
1436
|
eq: "=",
|
|
@@ -2063,8 +2210,31 @@ var RECORDED_EDGE_COLUMNS = [
|
|
|
2063
2210
|
"tx_id",
|
|
2064
2211
|
"meta"
|
|
2065
2212
|
];
|
|
2213
|
+
var RECORDED_IDENTITY_ASSERTION_COLUMNS = [
|
|
2214
|
+
"history_id",
|
|
2215
|
+
"graph_id",
|
|
2216
|
+
"id",
|
|
2217
|
+
"rel",
|
|
2218
|
+
"a_kind",
|
|
2219
|
+
"a_id",
|
|
2220
|
+
"b_kind",
|
|
2221
|
+
"b_id",
|
|
2222
|
+
"valid_from",
|
|
2223
|
+
"valid_to",
|
|
2224
|
+
"created_at",
|
|
2225
|
+
"updated_at",
|
|
2226
|
+
"deleted_at",
|
|
2227
|
+
"ended_by_kind",
|
|
2228
|
+
"ended_by_id",
|
|
2229
|
+
"recorded_from",
|
|
2230
|
+
"recorded_to",
|
|
2231
|
+
"op"
|
|
2232
|
+
];
|
|
2066
2233
|
var RECORDED_NODE_COLUMN_LIST = sql.raw(RECORDED_NODE_COLUMNS.join(", "));
|
|
2067
2234
|
var RECORDED_EDGE_COLUMN_LIST = sql.raw(RECORDED_EDGE_COLUMNS.join(", "));
|
|
2235
|
+
var RECORDED_IDENTITY_ASSERTION_COLUMN_LIST = sql.raw(
|
|
2236
|
+
RECORDED_IDENTITY_ASSERTION_COLUMNS.join(", ")
|
|
2237
|
+
);
|
|
2068
2238
|
var RECORDED_BIND_PARAM_BUDGET = 900;
|
|
2069
2239
|
function recordedBindParamBudget(target) {
|
|
2070
2240
|
const budget = target.capabilities.maxBindParameters ?? RECORDED_BIND_PARAM_BUDGET;
|
|
@@ -2118,6 +2288,26 @@ var recordedEdgeCells = {
|
|
|
2118
2288
|
to_kind: (row) => sql`${row.to_kind}`,
|
|
2119
2289
|
to_id: (row) => sql`${row.to_id}`
|
|
2120
2290
|
};
|
|
2291
|
+
var recordedIdentityAssertionCells = {
|
|
2292
|
+
history_id: () => sql`${generateId()}`,
|
|
2293
|
+
graph_id: (row) => sql`${row.graph_id}`,
|
|
2294
|
+
id: (row) => sql`${row.id}`,
|
|
2295
|
+
rel: (row) => sql`${row.rel}`,
|
|
2296
|
+
a_kind: (row) => sql`${row.a_kind}`,
|
|
2297
|
+
a_id: (row) => sql`${row.a_id}`,
|
|
2298
|
+
b_kind: (row) => sql`${row.b_kind}`,
|
|
2299
|
+
b_id: (row) => sql`${row.b_id}`,
|
|
2300
|
+
valid_from: (row) => sql`${row.valid_from}`,
|
|
2301
|
+
valid_to: (row) => sql`${row.valid_to ?? sql.raw("NULL")}`,
|
|
2302
|
+
created_at: (row) => sql`${row.created_at}`,
|
|
2303
|
+
updated_at: (row) => sql`${row.updated_at}`,
|
|
2304
|
+
deleted_at: (row) => sql`${row.deleted_at ?? sql.raw("NULL")}`,
|
|
2305
|
+
ended_by_kind: (row) => sql`${row.ended_by_kind ?? sql.raw("NULL")}`,
|
|
2306
|
+
ended_by_id: (row) => sql`${row.ended_by_id ?? sql.raw("NULL")}`,
|
|
2307
|
+
recorded_from: (_row, recordedRevision) => sql`${recordedRevision}`,
|
|
2308
|
+
recorded_to: () => sql`${RECORDED_MAX_REVISION}`,
|
|
2309
|
+
op: (_row, _recordedRevision, operation) => sql`${operation}`
|
|
2310
|
+
};
|
|
2121
2311
|
function recordedValuesTuple(columns, cells, row, recordedRevision, operation) {
|
|
2122
2312
|
const tuple = columns.map(
|
|
2123
2313
|
(column) => cells[column](row, recordedRevision, operation)
|
|
@@ -2149,6 +2339,9 @@ function recordedNodeChunkSize(target) {
|
|
|
2149
2339
|
function recordedEdgeChunkSize(target) {
|
|
2150
2340
|
return recordedChunkSize(target, RECORDED_EDGE_COLUMNS.length);
|
|
2151
2341
|
}
|
|
2342
|
+
function recordedIdentityAssertionChunkSize(target) {
|
|
2343
|
+
return recordedChunkSize(target, RECORDED_IDENTITY_ASSERTION_COLUMNS.length);
|
|
2344
|
+
}
|
|
2152
2345
|
function insertRecordedNodeRows(target, table, inserts, recordedRevision) {
|
|
2153
2346
|
return insertRecordedRows(
|
|
2154
2347
|
target,
|
|
@@ -2171,6 +2364,17 @@ function insertRecordedEdgeRows(target, table, inserts, recordedRevision) {
|
|
|
2171
2364
|
recordedRevision
|
|
2172
2365
|
);
|
|
2173
2366
|
}
|
|
2367
|
+
function insertRecordedIdentityAssertionRows(target, table, inserts, recordedRevision) {
|
|
2368
|
+
return insertRecordedRows(
|
|
2369
|
+
target,
|
|
2370
|
+
table,
|
|
2371
|
+
RECORDED_IDENTITY_ASSERTION_COLUMN_LIST,
|
|
2372
|
+
RECORDED_IDENTITY_ASSERTION_COLUMNS,
|
|
2373
|
+
recordedIdentityAssertionCells,
|
|
2374
|
+
inserts,
|
|
2375
|
+
recordedRevision
|
|
2376
|
+
);
|
|
2377
|
+
}
|
|
2174
2378
|
|
|
2175
2379
|
// src/store/recorded-capture/flush.ts
|
|
2176
2380
|
function entityKey(entity) {
|
|
@@ -2181,6 +2385,9 @@ function entityKey(entity) {
|
|
|
2181
2385
|
case "edge": {
|
|
2182
2386
|
return `edge\0${entity.graphId}\0${entity.id}`;
|
|
2183
2387
|
}
|
|
2388
|
+
case "identity": {
|
|
2389
|
+
return `identity\0${entity.graphId}\0${entity.id}`;
|
|
2390
|
+
}
|
|
2184
2391
|
}
|
|
2185
2392
|
}
|
|
2186
2393
|
async function closeOpenReturning(target, table, graphId, ids, recordedRevision, kind) {
|
|
@@ -2282,6 +2489,42 @@ async function flushEdges(target, schema, graphId, entities, recordedRevision) {
|
|
|
2282
2489
|
);
|
|
2283
2490
|
}
|
|
2284
2491
|
}
|
|
2492
|
+
async function getIdentityAssertionRowsByIds(target, schema, graphId, ids) {
|
|
2493
|
+
if (ids.length === 0) return /* @__PURE__ */ new Map();
|
|
2494
|
+
const rows = await target.execute(
|
|
2495
|
+
asCompiledRowsSql(sql`
|
|
2496
|
+
SELECT ${IDENTITY_ASSERTION_COLUMNS}
|
|
2497
|
+
FROM ${schema.identityAssertionsTable}
|
|
2498
|
+
WHERE graph_id = ${graphId}
|
|
2499
|
+
AND id IN (${sqlValueList(ids)})
|
|
2500
|
+
`)
|
|
2501
|
+
);
|
|
2502
|
+
return new Map(rows.map((row) => [row.id, row]));
|
|
2503
|
+
}
|
|
2504
|
+
async function flushIdentityAssertions(target, schema, graphId, entities, recordedRevision) {
|
|
2505
|
+
if (entities.length === 0) return;
|
|
2506
|
+
const chunkSize = recordedIdentityAssertionChunkSize(target);
|
|
2507
|
+
for (const entityChunk of chunk(entities, chunkSize)) {
|
|
2508
|
+
const ids = entityChunk.map((entity) => entity.id);
|
|
2509
|
+
const closed = await closeOpenReturning(
|
|
2510
|
+
target,
|
|
2511
|
+
schema.recordedIdentityAssertionsTable,
|
|
2512
|
+
graphId,
|
|
2513
|
+
ids,
|
|
2514
|
+
recordedRevision
|
|
2515
|
+
);
|
|
2516
|
+
const afterById = await resolveAfterImages(
|
|
2517
|
+
entityChunk,
|
|
2518
|
+
(missing) => getIdentityAssertionRowsByIds(target, schema, graphId, missing)
|
|
2519
|
+
);
|
|
2520
|
+
await insertRecordedIdentityAssertionRows(
|
|
2521
|
+
target,
|
|
2522
|
+
schema.recordedIdentityAssertionsTable,
|
|
2523
|
+
recordedInsertsFor(afterById, closed),
|
|
2524
|
+
recordedRevision
|
|
2525
|
+
);
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2285
2528
|
async function closeOpenByKind(target, table, graphId, kind, recordedRevision) {
|
|
2286
2529
|
await executeStatement(
|
|
2287
2530
|
target,
|
|
@@ -2386,7 +2629,19 @@ function isCompatibleColumnType(dialect, declaredType, kind) {
|
|
|
2386
2629
|
if (dialect === "sqlite") return hasSqliteAffinity(declaredType, kind);
|
|
2387
2630
|
return kind === "revision" ? declaredType === "bigint" : declaredType === "timestamp with time zone";
|
|
2388
2631
|
}
|
|
2389
|
-
function requiredRecordedColumns(schema) {
|
|
2632
|
+
function requiredRecordedColumns(schema, includeIdentity) {
|
|
2633
|
+
const identityColumns = includeIdentity ? [
|
|
2634
|
+
{
|
|
2635
|
+
table: schema.tables.recordedIdentityAssertions,
|
|
2636
|
+
column: "recorded_from",
|
|
2637
|
+
kind: "revision"
|
|
2638
|
+
},
|
|
2639
|
+
{
|
|
2640
|
+
table: schema.tables.recordedIdentityAssertions,
|
|
2641
|
+
column: "recorded_to",
|
|
2642
|
+
kind: "revision"
|
|
2643
|
+
}
|
|
2644
|
+
] : [];
|
|
2390
2645
|
return [
|
|
2391
2646
|
{
|
|
2392
2647
|
table: schema.tables.recordedNodes,
|
|
@@ -2417,11 +2672,12 @@ function requiredRecordedColumns(schema) {
|
|
|
2417
2672
|
table: schema.tables.recordedClock,
|
|
2418
2673
|
column: "recorded_at",
|
|
2419
2674
|
kind: "wall-time"
|
|
2420
|
-
}
|
|
2675
|
+
},
|
|
2676
|
+
...identityColumns
|
|
2421
2677
|
];
|
|
2422
2678
|
}
|
|
2423
|
-
async function assertCurrentRecordedSchema(backend, schema) {
|
|
2424
|
-
const requirements = requiredRecordedColumns(schema);
|
|
2679
|
+
async function assertCurrentRecordedSchema(backend, schema, includeIdentity = false) {
|
|
2680
|
+
const requirements = requiredRecordedColumns(schema, includeIdentity);
|
|
2425
2681
|
const tables = [...new Set(requirements.map((entry) => entry.table))];
|
|
2426
2682
|
const columnTypes = new Map(
|
|
2427
2683
|
await Promise.all(
|
|
@@ -2430,6 +2686,20 @@ async function assertCurrentRecordedSchema(backend, schema) {
|
|
|
2430
2686
|
)
|
|
2431
2687
|
)
|
|
2432
2688
|
);
|
|
2689
|
+
const recordedIdentityTable = schema.tables.recordedIdentityAssertions;
|
|
2690
|
+
if (includeIdentity && (columnTypes.get(recordedIdentityTable)?.size ?? 0) === 0) {
|
|
2691
|
+
throw new ConfigurationError(
|
|
2692
|
+
"Recorded identity history is not provisioned for this database.",
|
|
2693
|
+
{
|
|
2694
|
+
code: "RECORDED_IDENTITY_SCHEMA_MISSING",
|
|
2695
|
+
dialect: backend.dialect,
|
|
2696
|
+
table: recordedIdentityTable
|
|
2697
|
+
},
|
|
2698
|
+
{
|
|
2699
|
+
suggestion: "Restore the missing recorded identity ledger from backup. If this is confirmed first-time identity enablement with no identity history to preserve, provision the relation through the backend's privileged setup path before reopening with history: true."
|
|
2700
|
+
}
|
|
2701
|
+
);
|
|
2702
|
+
}
|
|
2433
2703
|
const incompatible = requirements.flatMap((requirement) => {
|
|
2434
2704
|
const actual = columnTypes.get(requirement.table)?.get(requirement.column);
|
|
2435
2705
|
if (actual !== void 0 && isCompatibleColumnType(backend.dialect, actual, requirement.kind)) {
|
|
@@ -2517,6 +2787,9 @@ function createRecordedCaptureSession() {
|
|
|
2517
2787
|
touchEdge(graphId, id, afterImage) {
|
|
2518
2788
|
touch({ entity: "edge", graphId, id, afterImage });
|
|
2519
2789
|
},
|
|
2790
|
+
touchIdentityAssertion(graphId, id, afterImage) {
|
|
2791
|
+
touch({ entity: "identity", graphId, id, afterImage });
|
|
2792
|
+
},
|
|
2520
2793
|
async flush(target, schema, ownsWriteLock) {
|
|
2521
2794
|
if (sealed) {
|
|
2522
2795
|
throw new ConfigurationError(
|
|
@@ -2545,6 +2818,9 @@ function createRecordedCaptureSession() {
|
|
|
2545
2818
|
const edges = entities.filter(
|
|
2546
2819
|
(entity) => entity.entity === "edge"
|
|
2547
2820
|
);
|
|
2821
|
+
const identityAssertions = entities.filter(
|
|
2822
|
+
(entity) => entity.entity === "identity"
|
|
2823
|
+
);
|
|
2548
2824
|
await flushNodes(
|
|
2549
2825
|
target,
|
|
2550
2826
|
schema,
|
|
@@ -2559,12 +2835,33 @@ function createRecordedCaptureSession() {
|
|
|
2559
2835
|
edges,
|
|
2560
2836
|
recordedCommit.revision
|
|
2561
2837
|
);
|
|
2838
|
+
await flushIdentityAssertions(
|
|
2839
|
+
target,
|
|
2840
|
+
schema,
|
|
2841
|
+
graphId,
|
|
2842
|
+
identityAssertions,
|
|
2843
|
+
recordedCommit.revision
|
|
2844
|
+
);
|
|
2562
2845
|
}
|
|
2563
2846
|
touched.clear();
|
|
2564
2847
|
return recordedByGraph;
|
|
2565
2848
|
}
|
|
2566
2849
|
};
|
|
2567
2850
|
}
|
|
2851
|
+
var recordedIdentityBindings = /* @__PURE__ */ new WeakMap();
|
|
2852
|
+
function ignoreIdentityTouch() {
|
|
2853
|
+
return;
|
|
2854
|
+
}
|
|
2855
|
+
async function withRecordedIdentityMutationTarget(target, fn) {
|
|
2856
|
+
const binding = recordedIdentityBindings.get(target);
|
|
2857
|
+
if (binding === void 0) {
|
|
2858
|
+
return fn(target, ignoreIdentityTouch);
|
|
2859
|
+
}
|
|
2860
|
+
binding.session.assertOpen();
|
|
2861
|
+
return fn(binding.target, (graphId, id, afterImage) => {
|
|
2862
|
+
binding.session.touchIdentityAssertion(graphId, id, afterImage);
|
|
2863
|
+
});
|
|
2864
|
+
}
|
|
2568
2865
|
function createRecordedTransactionBackend(target, session, schema) {
|
|
2569
2866
|
const nodeDispatch = nodeInsertDispatch(target);
|
|
2570
2867
|
const edgeDispatch = edgeInsertDispatch(target);
|
|
@@ -2748,6 +3045,8 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
2748
3045
|
}
|
|
2749
3046
|
});
|
|
2750
3047
|
registerRecordedGraphLockMemo(overlay, graphLocks);
|
|
3048
|
+
recordedIdentityBindings.set(overlay, { target, session });
|
|
3049
|
+
recordedIdentityBindings.set(target, { target, session });
|
|
2751
3050
|
return overlay;
|
|
2752
3051
|
}
|
|
2753
3052
|
function createRecordedTransactionScope(target, schema, ownsWriteLock = false) {
|
|
@@ -2891,803 +3190,28 @@ function createRecordedBackend(backend, schema) {
|
|
|
2891
3190
|
});
|
|
2892
3191
|
}
|
|
2893
3192
|
|
|
2894
|
-
// src/
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
return;
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
if (isValidEmbeddingValue(value)) {
|
|
2915
|
-
await backend.upsertEmbedding({
|
|
2916
|
-
graphId: ctx.graphId,
|
|
2917
|
-
nodeKind: ctx.nodeKind,
|
|
2918
|
-
nodeId: ctx.nodeId,
|
|
2919
|
-
fieldPath: field.fieldPath,
|
|
2920
|
-
embedding: value,
|
|
2921
|
-
dimensions: field.dimensions,
|
|
2922
|
-
metric: field.metric,
|
|
2923
|
-
indexType: field.indexType
|
|
2924
|
-
});
|
|
2925
|
-
} else if (value === void 0) {
|
|
2926
|
-
await backend.deleteEmbedding({
|
|
2927
|
-
graphId: ctx.graphId,
|
|
2928
|
-
nodeKind: ctx.nodeKind,
|
|
2929
|
-
nodeId: ctx.nodeId,
|
|
2930
|
-
fieldPath: field.fieldPath,
|
|
2931
|
-
dimensions: field.dimensions,
|
|
2932
|
-
metric: field.metric,
|
|
2933
|
-
indexType: field.indexType
|
|
2934
|
-
});
|
|
2935
|
-
}
|
|
2936
|
-
}
|
|
2937
|
-
}
|
|
2938
|
-
async function syncEmbeddingsBatchForKind(args, schema, items) {
|
|
2939
|
-
const { graphId, nodeKind, backend } = args;
|
|
2940
|
-
if (!backend.upsertEmbedding || !backend.deleteEmbedding) {
|
|
2941
|
-
return;
|
|
2942
|
-
}
|
|
2943
|
-
const embeddingFields = getEmbeddingFields(schema);
|
|
2944
|
-
if (embeddingFields.length === 0) {
|
|
2945
|
-
return;
|
|
2946
|
-
}
|
|
2947
|
-
for (const field of embeddingFields) {
|
|
2948
|
-
const rows = [];
|
|
2949
|
-
const deletionIds = [];
|
|
2950
|
-
for (const item of items) {
|
|
2951
|
-
const value = item.props[field.fieldPath];
|
|
2952
|
-
if (isValidEmbeddingValue(value)) {
|
|
2953
|
-
rows.push({ nodeId: item.nodeId, embedding: value });
|
|
2954
|
-
} else if (value === void 0) {
|
|
2955
|
-
deletionIds.push(item.nodeId);
|
|
2956
|
-
}
|
|
2957
|
-
}
|
|
2958
|
-
if (rows.length > 0) {
|
|
2959
|
-
if (backend.upsertEmbeddingBatch === void 0) {
|
|
2960
|
-
for (const row of rows) {
|
|
2961
|
-
await backend.upsertEmbedding({
|
|
2962
|
-
graphId,
|
|
2963
|
-
nodeKind,
|
|
2964
|
-
nodeId: row.nodeId,
|
|
2965
|
-
fieldPath: field.fieldPath,
|
|
2966
|
-
embedding: row.embedding,
|
|
2967
|
-
dimensions: field.dimensions,
|
|
2968
|
-
metric: field.metric,
|
|
2969
|
-
indexType: field.indexType
|
|
2970
|
-
});
|
|
2971
|
-
}
|
|
2972
|
-
} else {
|
|
2973
|
-
await backend.upsertEmbeddingBatch({
|
|
2974
|
-
graphId,
|
|
2975
|
-
nodeKind,
|
|
2976
|
-
fieldPath: field.fieldPath,
|
|
2977
|
-
dimensions: field.dimensions,
|
|
2978
|
-
metric: field.metric,
|
|
2979
|
-
indexType: field.indexType,
|
|
2980
|
-
rows
|
|
2981
|
-
});
|
|
2982
|
-
}
|
|
2983
|
-
}
|
|
2984
|
-
if (deletionIds.length > 0 && backend.deleteEmbeddingBatch !== void 0) {
|
|
2985
|
-
await backend.deleteEmbeddingBatch({
|
|
2986
|
-
graphId,
|
|
2987
|
-
nodeKind,
|
|
2988
|
-
nodeIds: deletionIds,
|
|
2989
|
-
fieldPath: field.fieldPath,
|
|
2990
|
-
dimensions: field.dimensions,
|
|
2991
|
-
metric: field.metric,
|
|
2992
|
-
indexType: field.indexType
|
|
2993
|
-
});
|
|
2994
|
-
} else {
|
|
2995
|
-
for (const nodeId of deletionIds) {
|
|
2996
|
-
await backend.deleteEmbedding({
|
|
2997
|
-
graphId,
|
|
2998
|
-
nodeKind,
|
|
2999
|
-
nodeId,
|
|
3000
|
-
fieldPath: field.fieldPath,
|
|
3001
|
-
dimensions: field.dimensions,
|
|
3002
|
-
metric: field.metric,
|
|
3003
|
-
indexType: field.indexType
|
|
3004
|
-
});
|
|
3005
|
-
}
|
|
3006
|
-
}
|
|
3007
|
-
}
|
|
3008
|
-
}
|
|
3009
|
-
async function deleteNodeEmbeddings(ctx, schema) {
|
|
3010
|
-
const { backend } = ctx;
|
|
3011
|
-
if (!backend.deleteEmbedding) {
|
|
3012
|
-
return;
|
|
3013
|
-
}
|
|
3014
|
-
const embeddingFields = getEmbeddingFields(schema);
|
|
3015
|
-
if (embeddingFields.length === 0) {
|
|
3016
|
-
return;
|
|
3017
|
-
}
|
|
3018
|
-
for (const field of embeddingFields) {
|
|
3019
|
-
await backend.deleteEmbedding({
|
|
3020
|
-
graphId: ctx.graphId,
|
|
3021
|
-
nodeKind: ctx.nodeKind,
|
|
3022
|
-
nodeId: ctx.nodeId,
|
|
3023
|
-
fieldPath: field.fieldPath,
|
|
3024
|
-
dimensions: field.dimensions,
|
|
3025
|
-
metric: field.metric,
|
|
3026
|
-
indexType: field.indexType
|
|
3027
|
-
});
|
|
3028
|
-
}
|
|
3029
|
-
}
|
|
3030
|
-
function isValidEmbeddingValue(value) {
|
|
3031
|
-
if (!Array.isArray(value)) {
|
|
3032
|
-
return false;
|
|
3033
|
-
}
|
|
3034
|
-
return value.every((n) => typeof n === "number" && Number.isFinite(n));
|
|
3035
|
-
}
|
|
3036
|
-
|
|
3037
|
-
// src/store/fulltext-sync.ts
|
|
3038
|
-
var FIELD_SEPARATOR = "\n";
|
|
3039
|
-
function resolveCombinedLanguage(fields) {
|
|
3040
|
-
return fields[0]?.metadata.language ?? DEFAULT_SEARCHABLE_LANGUAGE;
|
|
3041
|
-
}
|
|
3042
|
-
function computeFulltextContent(schema, props) {
|
|
3043
|
-
const searchableFields = getSearchableFields(schema);
|
|
3044
|
-
if (searchableFields.length === 0) return void 0;
|
|
3045
|
-
const parts = [];
|
|
3046
|
-
for (const field of searchableFields) {
|
|
3047
|
-
const value = props[field.fieldPath];
|
|
3048
|
-
if (typeof value === "string" && value.length > 0) {
|
|
3049
|
-
parts.push(value);
|
|
3050
|
-
}
|
|
3051
|
-
}
|
|
3052
|
-
if (parts.length === 0) return void 0;
|
|
3053
|
-
return {
|
|
3054
|
-
content: parts.join(FIELD_SEPARATOR),
|
|
3055
|
-
language: resolveCombinedLanguage(searchableFields)
|
|
3056
|
-
};
|
|
3057
|
-
}
|
|
3058
|
-
async function syncFulltext(ctx, schema, props) {
|
|
3059
|
-
const { backend } = ctx;
|
|
3060
|
-
if (!backend.upsertFulltext || !backend.deleteFulltext) {
|
|
3061
|
-
return;
|
|
3062
|
-
}
|
|
3063
|
-
const computed = computeFulltextContent(schema, props);
|
|
3064
|
-
if (computed !== void 0) {
|
|
3065
|
-
await backend.upsertFulltext({
|
|
3066
|
-
graphId: ctx.graphId,
|
|
3067
|
-
nodeKind: ctx.nodeKind,
|
|
3068
|
-
nodeId: ctx.nodeId,
|
|
3069
|
-
content: computed.content,
|
|
3070
|
-
language: computed.language
|
|
3071
|
-
});
|
|
3072
|
-
return;
|
|
3073
|
-
}
|
|
3074
|
-
if (getSearchableFields(schema).length === 0) return;
|
|
3075
|
-
await backend.deleteFulltext({
|
|
3076
|
-
graphId: ctx.graphId,
|
|
3077
|
-
nodeKind: ctx.nodeKind,
|
|
3078
|
-
nodeId: ctx.nodeId
|
|
3079
|
-
});
|
|
3080
|
-
}
|
|
3081
|
-
async function syncFulltextBatchForKind(args, schema, items) {
|
|
3082
|
-
const { graphId, nodeKind, backend } = args;
|
|
3083
|
-
if (!backend.upsertFulltext || !backend.deleteFulltext) {
|
|
3084
|
-
return;
|
|
3085
|
-
}
|
|
3086
|
-
const rows = [];
|
|
3087
|
-
const emptyContentIds = [];
|
|
3088
|
-
const hasSearchableFields = getSearchableFields(schema).length > 0;
|
|
3089
|
-
for (const item of items) {
|
|
3090
|
-
const computed = computeFulltextContent(schema, item.props);
|
|
3091
|
-
if (computed !== void 0) {
|
|
3092
|
-
rows.push({
|
|
3093
|
-
nodeId: item.nodeId,
|
|
3094
|
-
content: computed.content,
|
|
3095
|
-
language: computed.language
|
|
3096
|
-
});
|
|
3097
|
-
} else if (hasSearchableFields) {
|
|
3098
|
-
emptyContentIds.push(item.nodeId);
|
|
3099
|
-
}
|
|
3100
|
-
}
|
|
3101
|
-
if (rows.length > 0) {
|
|
3102
|
-
if (backend.upsertFulltextBatch === void 0) {
|
|
3103
|
-
for (const row of rows) {
|
|
3104
|
-
await backend.upsertFulltext({
|
|
3105
|
-
graphId,
|
|
3106
|
-
nodeKind,
|
|
3107
|
-
nodeId: row.nodeId,
|
|
3108
|
-
content: row.content,
|
|
3109
|
-
language: row.language
|
|
3110
|
-
});
|
|
3111
|
-
}
|
|
3112
|
-
} else {
|
|
3113
|
-
await backend.upsertFulltextBatch({ graphId, nodeKind, rows });
|
|
3114
|
-
}
|
|
3115
|
-
}
|
|
3116
|
-
if (emptyContentIds.length > 0) {
|
|
3117
|
-
if (backend.deleteFulltextBatch === void 0) {
|
|
3118
|
-
for (const nodeId of emptyContentIds) {
|
|
3119
|
-
await backend.deleteFulltext({ graphId, nodeKind, nodeId });
|
|
3120
|
-
}
|
|
3121
|
-
} else {
|
|
3122
|
-
await backend.deleteFulltextBatch({
|
|
3123
|
-
graphId,
|
|
3124
|
-
nodeKind,
|
|
3125
|
-
nodeIds: emptyContentIds
|
|
3126
|
-
});
|
|
3127
|
-
}
|
|
3128
|
-
}
|
|
3129
|
-
}
|
|
3130
|
-
async function deleteNodeFulltext(ctx, schema) {
|
|
3131
|
-
const { backend } = ctx;
|
|
3132
|
-
if (!backend.deleteFulltext) {
|
|
3133
|
-
return;
|
|
3134
|
-
}
|
|
3135
|
-
if (getSearchableFields(schema).length === 0) {
|
|
3136
|
-
return;
|
|
3137
|
-
}
|
|
3138
|
-
await backend.deleteFulltext({
|
|
3139
|
-
graphId: ctx.graphId,
|
|
3140
|
-
nodeKind: ctx.nodeKind,
|
|
3141
|
-
nodeId: ctx.nodeId
|
|
3142
|
-
});
|
|
3143
|
-
}
|
|
3144
|
-
|
|
3145
|
-
// src/constraints/index.ts
|
|
3146
|
-
var UNIQUE_KEY_SEPARATOR = "";
|
|
3147
|
-
var UNIQUE_KEY_NULL_MARKER = "";
|
|
3148
|
-
function computeUniqueKey(props, fields, collation) {
|
|
3149
|
-
const values = fields.map((field) => {
|
|
3150
|
-
const value = props[field];
|
|
3151
|
-
if (value === void 0 || value === null) {
|
|
3152
|
-
return UNIQUE_KEY_NULL_MARKER;
|
|
3153
|
-
}
|
|
3154
|
-
const stringValue = typeof value === "string" ? value : typeof value === "number" || typeof value === "boolean" ? value.toString() : JSON.stringify(value);
|
|
3155
|
-
return collation === "caseInsensitive" ? stringValue.toLowerCase() : stringValue;
|
|
3156
|
-
});
|
|
3157
|
-
return values.join(UNIQUE_KEY_SEPARATOR);
|
|
3158
|
-
}
|
|
3159
|
-
function checkWherePredicate(constraint, props) {
|
|
3160
|
-
if (!constraint.where) {
|
|
3161
|
-
return true;
|
|
3162
|
-
}
|
|
3163
|
-
const predicateBuilder = buildPredicateContext(props);
|
|
3164
|
-
const predicate2 = constraint.where(predicateBuilder);
|
|
3165
|
-
return evaluatePredicate(predicate2, props);
|
|
3166
|
-
}
|
|
3167
|
-
function buildPredicateContext(props) {
|
|
3168
|
-
const context = {};
|
|
3169
|
-
for (const key of Object.keys(props)) {
|
|
3170
|
-
context[key] = {
|
|
3171
|
-
isNull: () => ({
|
|
3172
|
-
__type: "unique_predicate",
|
|
3173
|
-
field: key,
|
|
3174
|
-
op: "isNull"
|
|
3175
|
-
}),
|
|
3176
|
-
isNotNull: () => ({
|
|
3177
|
-
__type: "unique_predicate",
|
|
3178
|
-
field: key,
|
|
3179
|
-
op: "isNotNull"
|
|
3180
|
-
})
|
|
3181
|
-
};
|
|
3182
|
-
}
|
|
3183
|
-
return context;
|
|
3184
|
-
}
|
|
3185
|
-
function evaluatePredicate(predicate2, props) {
|
|
3186
|
-
if (typeof predicate2 !== "object" || predicate2 === null || !("__type" in predicate2)) {
|
|
3187
|
-
return true;
|
|
3188
|
-
}
|
|
3189
|
-
const pred = predicate2;
|
|
3190
|
-
if (pred.__type !== "unique_predicate") {
|
|
3191
|
-
return true;
|
|
3192
|
-
}
|
|
3193
|
-
const value = props[pred.field];
|
|
3194
|
-
if (pred.op === "isNull") {
|
|
3195
|
-
return value === null || value === void 0;
|
|
3196
|
-
}
|
|
3197
|
-
return isPresent(value);
|
|
3198
|
-
}
|
|
3199
|
-
function getKindsForUniquenessCheck(baseKind, scope, registry) {
|
|
3200
|
-
if (scope === "kind") {
|
|
3201
|
-
return [baseKind];
|
|
3202
|
-
}
|
|
3203
|
-
const root = findRootAncestor(baseKind, registry);
|
|
3204
|
-
return registry.expandSubClasses(root);
|
|
3205
|
-
}
|
|
3206
|
-
function findRootAncestor(kind, registry) {
|
|
3207
|
-
const ancestors = registry.getAncestors(kind);
|
|
3208
|
-
if (ancestors.size === 0) {
|
|
3209
|
-
return kind;
|
|
3210
|
-
}
|
|
3211
|
-
for (const ancestor of ancestors) {
|
|
3212
|
-
if (registry.getAncestors(ancestor).size === 0) {
|
|
3213
|
-
return ancestor;
|
|
3214
|
-
}
|
|
3215
|
-
}
|
|
3216
|
-
const firstAncestor = [...ancestors][0];
|
|
3217
|
-
return firstAncestor ? findRootAncestor(firstAncestor, registry) : kind;
|
|
3218
|
-
}
|
|
3219
|
-
function checkCardinality(edgeKind, fromKind, fromId, cardinality, existingEdgeCount, hasActiveEdge) {
|
|
3220
|
-
switch (cardinality) {
|
|
3221
|
-
case "many": {
|
|
3222
|
-
return void 0;
|
|
3223
|
-
}
|
|
3224
|
-
case "one": {
|
|
3225
|
-
if (existingEdgeCount > 0) {
|
|
3226
|
-
return new CardinalityError({
|
|
3227
|
-
edgeKind,
|
|
3228
|
-
fromKind,
|
|
3229
|
-
fromId,
|
|
3230
|
-
cardinality: "one",
|
|
3231
|
-
existingCount: existingEdgeCount
|
|
3232
|
-
});
|
|
3233
|
-
}
|
|
3234
|
-
return void 0;
|
|
3235
|
-
}
|
|
3236
|
-
case "unique": {
|
|
3237
|
-
return void 0;
|
|
3238
|
-
}
|
|
3239
|
-
case "oneActive": {
|
|
3240
|
-
if (hasActiveEdge) {
|
|
3241
|
-
return new CardinalityError({
|
|
3242
|
-
edgeKind,
|
|
3243
|
-
fromKind,
|
|
3244
|
-
fromId,
|
|
3245
|
-
cardinality: "oneActive",
|
|
3246
|
-
existingCount: 1
|
|
3247
|
-
});
|
|
3248
|
-
}
|
|
3249
|
-
return void 0;
|
|
3250
|
-
}
|
|
3251
|
-
}
|
|
3252
|
-
}
|
|
3253
|
-
function checkUniqueEdge(edgeKind, fromKind, fromId, _toKind, _toId, existingCount) {
|
|
3254
|
-
if (existingCount > 0) {
|
|
3255
|
-
return new CardinalityError({
|
|
3256
|
-
edgeKind,
|
|
3257
|
-
fromKind,
|
|
3258
|
-
fromId,
|
|
3259
|
-
cardinality: "unique",
|
|
3260
|
-
existingCount
|
|
3261
|
-
});
|
|
3262
|
-
}
|
|
3263
|
-
return void 0;
|
|
3264
|
-
}
|
|
3265
|
-
function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registry) {
|
|
3266
|
-
const validFromKinds = registration.from.map((node) => node.kind);
|
|
3267
|
-
if (!registry.isAssignableToAny(fromKind, validFromKinds)) {
|
|
3268
|
-
return new EndpointError({
|
|
3269
|
-
edgeKind,
|
|
3270
|
-
endpoint: "from",
|
|
3271
|
-
actualKind: fromKind,
|
|
3272
|
-
expectedKinds: validFromKinds
|
|
3273
|
-
});
|
|
3274
|
-
}
|
|
3275
|
-
const validToKinds = registration.to.map((node) => node.kind);
|
|
3276
|
-
if (!registry.isAssignableToAny(toKind, validToKinds)) {
|
|
3277
|
-
return new EndpointError({
|
|
3278
|
-
edgeKind,
|
|
3279
|
-
endpoint: "to",
|
|
3280
|
-
actualKind: toKind,
|
|
3281
|
-
expectedKinds: validToKinds
|
|
3282
|
-
});
|
|
3283
|
-
}
|
|
3284
|
-
return void 0;
|
|
3285
|
-
}
|
|
3286
|
-
function checkDisjointness(nodeId, nodeKind, existingKinds, registry) {
|
|
3287
|
-
for (const existingKind of existingKinds) {
|
|
3288
|
-
if (registry.areDisjoint(nodeKind, existingKind)) {
|
|
3289
|
-
return new DisjointError({
|
|
3290
|
-
nodeId,
|
|
3291
|
-
attemptedKind: nodeKind,
|
|
3292
|
-
conflictingKind: existingKind
|
|
3293
|
-
});
|
|
3294
|
-
}
|
|
3295
|
-
}
|
|
3296
|
-
return void 0;
|
|
3297
|
-
}
|
|
3298
|
-
|
|
3299
|
-
// src/store/uniqueness.ts
|
|
3300
|
-
function createUniquenessContext(graphId, registry, backend) {
|
|
3301
|
-
return { graphId, registry, backend };
|
|
3302
|
-
}
|
|
3303
|
-
async function checkUniquenessConstraints(ctx, kind, id, props, constraints) {
|
|
3304
|
-
for (const constraint of constraints) {
|
|
3305
|
-
if (!checkWherePredicate(constraint, props)) {
|
|
3306
|
-
continue;
|
|
3307
|
-
}
|
|
3308
|
-
const key = computeUniqueKey(
|
|
3309
|
-
props,
|
|
3310
|
-
constraint.fields,
|
|
3311
|
-
constraint.collation
|
|
3312
|
-
);
|
|
3313
|
-
const kindsToCheck = getKindsForUniquenessCheck(
|
|
3314
|
-
kind,
|
|
3315
|
-
constraint.scope,
|
|
3316
|
-
ctx.registry
|
|
3317
|
-
);
|
|
3318
|
-
for (const kindToCheck of kindsToCheck) {
|
|
3319
|
-
const existing = await ctx.backend.checkUnique({
|
|
3320
|
-
graphId: ctx.graphId,
|
|
3321
|
-
nodeKind: kindToCheck,
|
|
3322
|
-
constraintName: constraint.name,
|
|
3323
|
-
key
|
|
3324
|
-
});
|
|
3325
|
-
if (existing && existing.node_id !== id) {
|
|
3326
|
-
throw new UniquenessError({
|
|
3327
|
-
constraintName: constraint.name,
|
|
3328
|
-
kind: kindToCheck,
|
|
3329
|
-
existingId: existing.node_id,
|
|
3330
|
-
newId: id,
|
|
3331
|
-
fields: constraint.fields
|
|
3332
|
-
});
|
|
3333
|
-
}
|
|
3334
|
-
}
|
|
3335
|
-
}
|
|
3336
|
-
}
|
|
3337
|
-
async function insertUniquenessEntries(ctx, kind, id, props, constraints) {
|
|
3338
|
-
for (const constraint of constraints) {
|
|
3339
|
-
if (!checkWherePredicate(constraint, props)) {
|
|
3340
|
-
continue;
|
|
3341
|
-
}
|
|
3342
|
-
const key = computeUniqueKey(
|
|
3343
|
-
props,
|
|
3344
|
-
constraint.fields,
|
|
3345
|
-
constraint.collation
|
|
3346
|
-
);
|
|
3347
|
-
await ctx.backend.insertUnique({
|
|
3348
|
-
graphId: ctx.graphId,
|
|
3349
|
-
nodeKind: kind,
|
|
3350
|
-
constraintName: constraint.name,
|
|
3351
|
-
key,
|
|
3352
|
-
nodeId: id,
|
|
3353
|
-
concreteKind: kind
|
|
3354
|
-
});
|
|
3355
|
-
}
|
|
3356
|
-
}
|
|
3357
|
-
async function insertUniquenessEntriesBatch(ctx, items) {
|
|
3358
|
-
const entries = [];
|
|
3359
|
-
for (const item of items) {
|
|
3360
|
-
for (const constraint of item.constraints) {
|
|
3361
|
-
if (!checkWherePredicate(constraint, item.props)) {
|
|
3362
|
-
continue;
|
|
3363
|
-
}
|
|
3364
|
-
entries.push({
|
|
3365
|
-
graphId: ctx.graphId,
|
|
3366
|
-
nodeKind: item.kind,
|
|
3367
|
-
constraintName: constraint.name,
|
|
3368
|
-
key: computeUniqueKey(
|
|
3369
|
-
item.props,
|
|
3370
|
-
constraint.fields,
|
|
3371
|
-
constraint.collation
|
|
3372
|
-
),
|
|
3373
|
-
nodeId: item.id,
|
|
3374
|
-
concreteKind: item.kind
|
|
3375
|
-
});
|
|
3376
|
-
}
|
|
3377
|
-
}
|
|
3378
|
-
if (entries.length === 0) return;
|
|
3379
|
-
if (ctx.backend.insertUniqueBatch !== void 0) {
|
|
3380
|
-
await ctx.backend.insertUniqueBatch(entries);
|
|
3381
|
-
return;
|
|
3382
|
-
}
|
|
3383
|
-
for (const entry of entries) {
|
|
3384
|
-
await ctx.backend.insertUnique(entry);
|
|
3385
|
-
}
|
|
3386
|
-
}
|
|
3387
|
-
async function deleteUniquenessEntries(ctx, kind, props, constraints) {
|
|
3388
|
-
for (const constraint of constraints) {
|
|
3389
|
-
if (!checkWherePredicate(constraint, props)) {
|
|
3390
|
-
continue;
|
|
3391
|
-
}
|
|
3392
|
-
const key = computeUniqueKey(
|
|
3393
|
-
props,
|
|
3394
|
-
constraint.fields,
|
|
3395
|
-
constraint.collation
|
|
3396
|
-
);
|
|
3397
|
-
await ctx.backend.deleteUnique({
|
|
3398
|
-
graphId: ctx.graphId,
|
|
3399
|
-
nodeKind: kind,
|
|
3400
|
-
constraintName: constraint.name,
|
|
3401
|
-
key
|
|
3402
|
-
});
|
|
3403
|
-
}
|
|
3404
|
-
}
|
|
3405
|
-
async function updateUniquenessEntries(ctx, kind, id, oldProps, newProps, constraints) {
|
|
3406
|
-
const pending = [];
|
|
3407
|
-
for (const constraint of constraints) {
|
|
3408
|
-
const oldApplies = checkWherePredicate(constraint, oldProps);
|
|
3409
|
-
const newApplies = checkWherePredicate(constraint, newProps);
|
|
3410
|
-
const oldKey = oldApplies ? computeUniqueKey(oldProps, constraint.fields, constraint.collation) : void 0;
|
|
3411
|
-
const newKey = newApplies ? computeUniqueKey(newProps, constraint.fields, constraint.collation) : void 0;
|
|
3412
|
-
if (!oldApplies && !newApplies) {
|
|
3413
|
-
continue;
|
|
3414
|
-
}
|
|
3415
|
-
if (oldApplies && newApplies && oldKey === newKey) {
|
|
3416
|
-
continue;
|
|
3417
|
-
}
|
|
3418
|
-
if (newApplies && newKey !== void 0) {
|
|
3419
|
-
const kindsToCheck = getKindsForUniquenessCheck(
|
|
3420
|
-
kind,
|
|
3421
|
-
constraint.scope,
|
|
3422
|
-
ctx.registry
|
|
3423
|
-
);
|
|
3424
|
-
for (const kindToCheck of kindsToCheck) {
|
|
3425
|
-
const existing = await ctx.backend.checkUnique({
|
|
3426
|
-
graphId: ctx.graphId,
|
|
3427
|
-
nodeKind: kindToCheck,
|
|
3428
|
-
constraintName: constraint.name,
|
|
3429
|
-
key: newKey
|
|
3430
|
-
});
|
|
3431
|
-
if (existing && existing.node_id !== id) {
|
|
3432
|
-
throw new UniquenessError({
|
|
3433
|
-
constraintName: constraint.name,
|
|
3434
|
-
kind: kindToCheck,
|
|
3435
|
-
existingId: existing.node_id,
|
|
3436
|
-
newId: id,
|
|
3437
|
-
fields: constraint.fields
|
|
3438
|
-
});
|
|
3439
|
-
}
|
|
3440
|
-
}
|
|
3441
|
-
}
|
|
3442
|
-
pending.push({ constraintName: constraint.name, oldKey, newKey });
|
|
3443
|
-
}
|
|
3444
|
-
for (const mutation of pending) {
|
|
3445
|
-
if (mutation.oldKey !== void 0) {
|
|
3446
|
-
await ctx.backend.deleteUnique({
|
|
3447
|
-
graphId: ctx.graphId,
|
|
3448
|
-
nodeKind: kind,
|
|
3449
|
-
constraintName: mutation.constraintName,
|
|
3450
|
-
key: mutation.oldKey
|
|
3451
|
-
});
|
|
3452
|
-
}
|
|
3453
|
-
}
|
|
3454
|
-
for (const mutation of pending) {
|
|
3455
|
-
if (mutation.newKey !== void 0) {
|
|
3456
|
-
await ctx.backend.insertUnique({
|
|
3457
|
-
graphId: ctx.graphId,
|
|
3458
|
-
nodeKind: kind,
|
|
3459
|
-
constraintName: mutation.constraintName,
|
|
3460
|
-
key: mutation.newKey,
|
|
3461
|
-
nodeId: id,
|
|
3462
|
-
concreteKind: kind
|
|
3463
|
-
});
|
|
3464
|
-
}
|
|
3465
|
-
}
|
|
3466
|
-
}
|
|
3467
|
-
|
|
3468
|
-
// src/store/operations/node-write-pipeline.ts
|
|
3469
|
-
function createNodeWriteContext(graphId, registry, lock) {
|
|
3470
|
-
return { graphId, registry, lock };
|
|
3471
|
-
}
|
|
3472
|
-
function uniquenessContext(ctx, backend) {
|
|
3473
|
-
return createUniquenessContext(ctx.graphId, ctx.registry, backend);
|
|
3474
|
-
}
|
|
3475
|
-
function nodeSyncContext(ctx, kind, id, backend) {
|
|
3476
|
-
return { graphId: ctx.graphId, nodeKind: kind, nodeId: id, backend };
|
|
3477
|
-
}
|
|
3478
|
-
async function enforceNodeDeleteBehavior(ctx, args, backend, policy) {
|
|
3479
|
-
if (policy?.enforceDeleteBehavior === false) return;
|
|
3480
|
-
const behavior = args.onDelete ?? "restrict";
|
|
3481
|
-
const connectedEdges = await backend.findEdgesConnectedTo({
|
|
3482
|
-
graphId: ctx.graphId,
|
|
3483
|
-
nodeKind: args.kind,
|
|
3484
|
-
nodeId: args.id
|
|
3485
|
-
});
|
|
3486
|
-
if (connectedEdges.length === 0) return;
|
|
3487
|
-
switch (behavior) {
|
|
3488
|
-
case "restrict": {
|
|
3489
|
-
throw new RestrictedDeleteError({
|
|
3490
|
-
nodeKind: args.kind,
|
|
3491
|
-
nodeId: args.id,
|
|
3492
|
-
edgeCount: connectedEdges.length,
|
|
3493
|
-
edgeKinds: [...new Set(connectedEdges.map((edge) => edge.kind))]
|
|
3494
|
-
});
|
|
3495
|
-
}
|
|
3496
|
-
case "cascade":
|
|
3497
|
-
case "disconnect": {
|
|
3498
|
-
const batchDelete = args.mode === "hard" ? backend.hardDeleteEdgesBatch : backend.deleteEdgesBatch;
|
|
3499
|
-
if (batchDelete !== void 0) {
|
|
3500
|
-
await batchDelete({
|
|
3501
|
-
graphId: ctx.graphId,
|
|
3502
|
-
ids: connectedEdges.map((edge) => edge.id)
|
|
3503
|
-
});
|
|
3504
|
-
break;
|
|
3505
|
-
}
|
|
3506
|
-
for (const edge of connectedEdges) {
|
|
3507
|
-
await (args.mode === "hard" ? backend.hardDeleteEdge({ graphId: ctx.graphId, id: edge.id }) : backend.deleteEdge({ graphId: ctx.graphId, id: edge.id }));
|
|
3508
|
-
}
|
|
3509
|
-
break;
|
|
3510
|
-
}
|
|
3511
|
-
}
|
|
3512
|
-
}
|
|
3513
|
-
async function applyNodeInsertSideEffects(ctx, args, backend) {
|
|
3514
|
-
await insertUniquenessEntries(
|
|
3515
|
-
uniquenessContext(ctx, backend),
|
|
3516
|
-
args.kind,
|
|
3517
|
-
args.id,
|
|
3518
|
-
args.props,
|
|
3519
|
-
args.uniqueConstraints
|
|
3520
|
-
);
|
|
3521
|
-
await Promise.all([
|
|
3522
|
-
syncEmbeddings(
|
|
3523
|
-
nodeSyncContext(ctx, args.kind, args.id, backend),
|
|
3524
|
-
args.schema,
|
|
3525
|
-
args.props
|
|
3526
|
-
),
|
|
3527
|
-
syncFulltext(
|
|
3528
|
-
nodeSyncContext(ctx, args.kind, args.id, backend),
|
|
3529
|
-
args.schema,
|
|
3530
|
-
args.props
|
|
3531
|
-
)
|
|
3532
|
-
]);
|
|
3533
|
-
}
|
|
3534
|
-
async function applyNodeInsertSideEffectsBatch(ctx, items, backend) {
|
|
3535
|
-
if (items.length === 0) return;
|
|
3536
|
-
await insertUniquenessEntriesBatch(
|
|
3537
|
-
uniquenessContext(ctx, backend),
|
|
3538
|
-
items.map((item) => ({
|
|
3539
|
-
kind: item.kind,
|
|
3540
|
-
id: item.id,
|
|
3541
|
-
props: item.props,
|
|
3542
|
-
constraints: item.uniqueConstraints
|
|
3543
|
-
}))
|
|
3544
|
-
);
|
|
3545
|
-
const byKind = /* @__PURE__ */ new Map();
|
|
3546
|
-
for (const item of items) {
|
|
3547
|
-
const group = byKind.get(item.kind) ?? { schema: item.schema, rows: [] };
|
|
3548
|
-
group.rows.push({ nodeId: item.id, props: item.props });
|
|
3549
|
-
byKind.set(item.kind, group);
|
|
3550
|
-
}
|
|
3551
|
-
await Promise.all(
|
|
3552
|
-
[...byKind.entries()].flatMap(([kind, group]) => {
|
|
3553
|
-
const syncArguments = { graphId: ctx.graphId, nodeKind: kind, backend };
|
|
3554
|
-
return [
|
|
3555
|
-
syncEmbeddingsBatchForKind(syncArguments, group.schema, group.rows),
|
|
3556
|
-
syncFulltextBatchForKind(syncArguments, group.schema, group.rows)
|
|
3557
|
-
];
|
|
3558
|
-
})
|
|
3559
|
-
);
|
|
3560
|
-
}
|
|
3561
|
-
function parseRowProps(row) {
|
|
3562
|
-
return rowPropsToObject(row.props);
|
|
3563
|
-
}
|
|
3564
|
-
async function applyNodeUpdate(ctx, args, backend) {
|
|
3565
|
-
const { kind, id } = args.existing;
|
|
3566
|
-
if (args.existing.deleted_at === void 0) {
|
|
3567
|
-
await updateUniquenessEntries(
|
|
3568
|
-
uniquenessContext(ctx, backend),
|
|
3569
|
-
kind,
|
|
3570
|
-
id,
|
|
3571
|
-
parseRowProps(args.existing),
|
|
3572
|
-
args.validatedProps,
|
|
3573
|
-
args.uniqueConstraints
|
|
3574
|
-
);
|
|
3575
|
-
} else {
|
|
3576
|
-
await checkUniquenessConstraints(
|
|
3577
|
-
uniquenessContext(ctx, backend),
|
|
3578
|
-
kind,
|
|
3579
|
-
id,
|
|
3580
|
-
args.validatedProps,
|
|
3581
|
-
args.uniqueConstraints
|
|
3582
|
-
);
|
|
3583
|
-
await insertUniquenessEntries(
|
|
3584
|
-
uniquenessContext(ctx, backend),
|
|
3585
|
-
kind,
|
|
3586
|
-
id,
|
|
3587
|
-
args.validatedProps,
|
|
3588
|
-
args.uniqueConstraints
|
|
3589
|
-
);
|
|
3590
|
-
}
|
|
3591
|
-
const updateParams = {
|
|
3592
|
-
graphId: ctx.graphId,
|
|
3593
|
-
kind,
|
|
3594
|
-
id,
|
|
3595
|
-
props: args.validatedProps,
|
|
3596
|
-
incrementVersion: true
|
|
3597
|
-
};
|
|
3598
|
-
if (args.validTo !== void 0) updateParams.validTo = args.validTo;
|
|
3599
|
-
if (args.clearDeleted) updateParams.clearDeleted = true;
|
|
3600
|
-
const row = await backend.updateNode(updateParams);
|
|
3601
|
-
await Promise.all([
|
|
3602
|
-
syncEmbeddings(
|
|
3603
|
-
nodeSyncContext(ctx, kind, id, backend),
|
|
3604
|
-
args.schema,
|
|
3605
|
-
args.validatedProps
|
|
3606
|
-
),
|
|
3607
|
-
syncFulltext(
|
|
3608
|
-
nodeSyncContext(ctx, kind, id, backend),
|
|
3609
|
-
args.schema,
|
|
3610
|
-
args.validatedProps
|
|
3611
|
-
)
|
|
3612
|
-
]);
|
|
3613
|
-
return row;
|
|
3614
|
-
}
|
|
3615
|
-
async function applyNodeSoftDelete(ctx, args, backend, policy) {
|
|
3616
|
-
const { kind, id } = args.existing;
|
|
3617
|
-
await enforceNodeDeleteBehavior(
|
|
3618
|
-
ctx,
|
|
3619
|
-
{ kind, id, mode: "soft", onDelete: args.onDelete },
|
|
3620
|
-
backend,
|
|
3621
|
-
policy
|
|
3622
|
-
);
|
|
3623
|
-
await backend.deleteNode({
|
|
3624
|
-
graphId: ctx.graphId,
|
|
3625
|
-
kind,
|
|
3626
|
-
id
|
|
3627
|
-
});
|
|
3628
|
-
await deleteUniquenessEntries(
|
|
3629
|
-
uniquenessContext(ctx, backend),
|
|
3630
|
-
kind,
|
|
3631
|
-
parseRowProps(args.existing),
|
|
3632
|
-
args.uniqueConstraints
|
|
3633
|
-
);
|
|
3634
|
-
await deleteNodeEmbeddings(
|
|
3635
|
-
nodeSyncContext(ctx, kind, id, backend),
|
|
3636
|
-
args.schema
|
|
3637
|
-
);
|
|
3638
|
-
await deleteNodeFulltext(
|
|
3639
|
-
nodeSyncContext(ctx, kind, id, backend),
|
|
3640
|
-
args.schema
|
|
3641
|
-
);
|
|
3642
|
-
}
|
|
3643
|
-
async function applyNodeHardDelete(ctx, args, backend) {
|
|
3644
|
-
await enforceNodeDeleteBehavior(
|
|
3645
|
-
ctx,
|
|
3646
|
-
{ kind: args.kind, id: args.id, mode: "hard", onDelete: args.onDelete },
|
|
3647
|
-
backend
|
|
3648
|
-
);
|
|
3649
|
-
await backend.hardDeleteNode({
|
|
3650
|
-
graphId: ctx.graphId,
|
|
3651
|
-
kind: args.kind,
|
|
3652
|
-
id: args.id
|
|
3653
|
-
});
|
|
3654
|
-
await deleteNodeEmbeddings(
|
|
3655
|
-
nodeSyncContext(ctx, args.kind, args.id, backend),
|
|
3656
|
-
args.schema
|
|
3657
|
-
);
|
|
3658
|
-
}
|
|
3659
|
-
async function applyNodeResurrect(ctx, args, backend) {
|
|
3660
|
-
const { kind, id } = args.existing;
|
|
3661
|
-
const props = parseRowProps(args.existing);
|
|
3662
|
-
await checkUniquenessConstraints(
|
|
3663
|
-
uniquenessContext(ctx, backend),
|
|
3664
|
-
kind,
|
|
3665
|
-
id,
|
|
3666
|
-
props,
|
|
3667
|
-
args.uniqueConstraints
|
|
3668
|
-
);
|
|
3669
|
-
await insertUniquenessEntries(
|
|
3670
|
-
uniquenessContext(ctx, backend),
|
|
3671
|
-
kind,
|
|
3672
|
-
id,
|
|
3673
|
-
props,
|
|
3674
|
-
args.uniqueConstraints
|
|
3675
|
-
);
|
|
3676
|
-
const row = await backend.updateNode({
|
|
3677
|
-
graphId: ctx.graphId,
|
|
3678
|
-
kind,
|
|
3679
|
-
id,
|
|
3680
|
-
props,
|
|
3681
|
-
incrementVersion: true,
|
|
3682
|
-
clearDeleted: true
|
|
3683
|
-
});
|
|
3684
|
-
await Promise.all([
|
|
3685
|
-
syncEmbeddings(nodeSyncContext(ctx, kind, id, backend), args.schema, props),
|
|
3686
|
-
syncFulltext(nodeSyncContext(ctx, kind, id, backend), args.schema, props)
|
|
3687
|
-
]);
|
|
3688
|
-
return row;
|
|
3193
|
+
// src/utils/compare.ts
|
|
3194
|
+
function compareStrings(left, right) {
|
|
3195
|
+
if (left < right) return -1;
|
|
3196
|
+
return left > right ? 1 : 0;
|
|
3197
|
+
}
|
|
3198
|
+
function compareCodePoints(left, right) {
|
|
3199
|
+
if (left === right) return 0;
|
|
3200
|
+
let leftIndex = 0;
|
|
3201
|
+
let rightIndex = 0;
|
|
3202
|
+
while (leftIndex < left.length && rightIndex < right.length) {
|
|
3203
|
+
const leftPoint = requireDefined(left.codePointAt(leftIndex));
|
|
3204
|
+
const rightPoint = requireDefined(right.codePointAt(rightIndex));
|
|
3205
|
+
if (leftPoint !== rightPoint) return leftPoint < rightPoint ? -1 : 1;
|
|
3206
|
+
leftIndex += leftPoint > 65535 ? 2 : 1;
|
|
3207
|
+
rightIndex += rightPoint > 65535 ? 2 : 1;
|
|
3208
|
+
}
|
|
3209
|
+
const leftExhausted = leftIndex >= left.length;
|
|
3210
|
+
const rightExhausted = rightIndex >= right.length;
|
|
3211
|
+
if (leftExhausted && rightExhausted) return 0;
|
|
3212
|
+
return leftExhausted ? -1 : 1;
|
|
3689
3213
|
}
|
|
3690
3214
|
|
|
3691
|
-
export {
|
|
3692
|
-
//# sourceMappingURL=chunk-
|
|
3693
|
-
//# sourceMappingURL=chunk-
|
|
3215
|
+
export { CURRENT_READ_INSTANT_PLACEHOLDER, IDENTITY_ASSERTION_COLUMNS, IDENTITY_PEER_CLASS_COLUMNS, advanceRevisionClock, arrayField, assertCurrentRecordedSchema, assertRecordedCaptureTransactionIsolation, assertRevisionTrackableBackend, baseField, buildFieldBuilderForTypeInfo, buildPredicateIndex, closeRecordedHardDeletedKind, compareCodePoints, compareStrings, compileFieldValue, compileKindFilter, compilePredicateClauses, compilePredicateExpression, compileTemporalFilter, createFulltextAccessor, createGraphBackendProjection, createRecordedBackend, createRecordedTransactionScope, currentReadInstant, currentReadInstantFor, dateField, edgeInsertDispatch, ensureRevisionOrigin, exists, extractFulltextMatchPredicates, extractTemporalOptions, extractVectorSimilarityPredicates, fieldRef, generateId, getEdgeRowsByIds, getFieldPointer, getHybridTargetAlias, getNodeKindsForAlias, getNodeRowsByIds, getPredicatesForAlias, historicalIdentityPeerClassQuery, historicalIdentityReconstructionCtes, identityAssertionSnapshotSource, identityNodeSnapshotSource, identityNodeVisibilitySql, identitySqlCoordinate, inSubquery, isParameterRef, lockRecordedGraphWrite, nodeInsertDispatch, notExists, notInSubquery, numberField, objectField, param, projectBackendMembers, readRecordedClock, readRevisionOrigin, recordedBindParamBudget, recordedCaptureRequiresCallbackTransactionError, resolveParameterValueType, runInsertBatch, runInsertBatchReturning, runInsertNoReturn, sqlValueList, stringField, throwHistoryUnsafeSqlAccess, throwRevisionTrackingUnsafeSqlAccess, uncapturedGraphWriteLock, withPinnedReadInstant, withRecordedFlushObserver, withRecordedIdentityMutationTarget };
|
|
3216
|
+
//# sourceMappingURL=chunk-NLI2AVEF.js.map
|
|
3217
|
+
//# sourceMappingURL=chunk-NLI2AVEF.js.map
|