@nicia-ai/typegraph 0.44.0 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend/drizzle/indexes.cjs +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 -43
- 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 -39
- 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 -44
- 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 -40
- 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-XMYJY7NI.js → chunk-2LG2XB2M.js} +3 -3
- package/dist/{chunk-XMYJY7NI.js.map → chunk-2LG2XB2M.js.map} +1 -1
- package/dist/{chunk-QGKILWGZ.cjs → chunk-2NA5DYLO.cjs} +4 -4
- package/dist/{chunk-QGKILWGZ.cjs.map → chunk-2NA5DYLO.cjs.map} +1 -1
- package/dist/{chunk-5MUSU4ZP.cjs → chunk-3DHZCOT7.cjs} +20 -20
- package/dist/chunk-3DHZCOT7.cjs.map +1 -0
- package/dist/{chunk-OVUUTCPJ.cjs → chunk-4UGOKMI5.cjs} +268 -150
- package/dist/chunk-4UGOKMI5.cjs.map +1 -0
- package/dist/{chunk-FRHHDHKH.js → chunk-5262ZMTR.js} +26 -5
- package/dist/chunk-5262ZMTR.js.map +1 -0
- package/dist/{chunk-HOIFFY4M.js → chunk-5763DULU.js} +248 -76
- package/dist/chunk-5763DULU.js.map +1 -0
- package/dist/{chunk-7G32LIQM.js → chunk-5UVRGXD3.js} +277 -7
- package/dist/chunk-5UVRGXD3.js.map +1 -0
- package/dist/{chunk-IIT5K7SK.cjs → chunk-62ZP23AW.cjs} +15 -15
- package/dist/{chunk-IIT5K7SK.cjs.map → chunk-62ZP23AW.cjs.map} +1 -1
- package/dist/{chunk-S4KQ5LV4.js → chunk-775A4ZMN.js} +40 -6
- package/dist/chunk-775A4ZMN.js.map +1 -0
- package/dist/{chunk-QYWINYEA.cjs → chunk-7BQXPCGN.cjs} +830 -170
- 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-7GT72YHH.cjs +1979 -0
- package/dist/chunk-7GT72YHH.cjs.map +1 -0
- package/dist/{chunk-SQRD2CYF.js → chunk-7VQXLT5O.js} +717 -76
- package/dist/chunk-7VQXLT5O.js.map +1 -0
- package/dist/{chunk-BCP7LLOY.js → chunk-7Z5OR7KO.js} +2706 -625
- package/dist/chunk-7Z5OR7KO.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-FMMIX6N4.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-PAW2XUZN.js → chunk-ASTI57H3.js} +3 -3
- package/dist/{chunk-PAW2XUZN.js.map → chunk-ASTI57H3.js.map} +1 -1
- package/dist/{chunk-FMGEZBAQ.js → chunk-BKCUOV7A.js} +27 -5
- package/dist/chunk-BKCUOV7A.js.map +1 -0
- package/dist/chunk-BSFJMMV3.cjs +268 -0
- package/dist/chunk-BSFJMMV3.cjs.map +1 -0
- package/dist/{chunk-63KCKSSH.js → chunk-C23WSN5E.js} +209 -24
- package/dist/chunk-C23WSN5E.js.map +1 -0
- package/dist/{chunk-JRP3VGHS.js → chunk-CBTIUB76.js} +3 -3
- package/dist/{chunk-JRP3VGHS.js.map → chunk-CBTIUB76.js.map} +1 -1
- package/dist/chunk-CNV4TXJG.js +58 -0
- package/dist/chunk-CNV4TXJG.js.map +1 -0
- package/dist/{chunk-QB6VMOJ2.cjs → chunk-CXBHOOIQ.cjs} +45 -10
- package/dist/chunk-CXBHOOIQ.cjs.map +1 -0
- package/dist/{chunk-46GDII45.js → chunk-DCQVHAYQ.js} +5 -5
- package/dist/{chunk-46GDII45.js.map → chunk-DCQVHAYQ.js.map} +1 -1
- package/dist/chunk-DLNROMQ7.js +306 -0
- package/dist/chunk-DLNROMQ7.js.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-BNUFUFAU.js → chunk-HFHTMECK.js} +7 -7
- package/dist/chunk-HFHTMECK.js.map +1 -0
- package/dist/{chunk-TFMVL4QH.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-JIVMTW7W.js +3393 -0
- package/dist/chunk-JIVMTW7W.js.map +1 -0
- package/dist/{chunk-2Y4IFKW7.js → chunk-JXA2ZP2Q.js} +6 -17
- 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-K5ELX2GT.js +248 -0
- package/dist/chunk-K5ELX2GT.js.map +1 -0
- package/dist/chunk-LBJKZXDE.cjs +257 -0
- package/dist/chunk-LBJKZXDE.cjs.map +1 -0
- package/dist/{chunk-FGO5JFVJ.cjs → chunk-M4BDU5RX.cjs} +12 -12
- package/dist/{chunk-FGO5JFVJ.cjs.map → chunk-M4BDU5RX.cjs.map} +1 -1
- package/dist/{chunk-MIJKEVV7.js → chunk-MSY7FSX4.js} +37 -4
- package/dist/chunk-MSY7FSX4.js.map +1 -0
- package/dist/{chunk-ST3LPB2V.cjs → chunk-MUK4BU7K.cjs} +788 -146
- package/dist/chunk-MUK4BU7K.cjs.map +1 -0
- package/dist/{chunk-MCHP7RHZ.cjs → chunk-MXJDTH5B.cjs} +64 -41
- package/dist/chunk-MXJDTH5B.cjs.map +1 -0
- package/dist/{chunk-2VLBGQBY.cjs → chunk-N3257XE6.cjs} +724 -577
- package/dist/chunk-N3257XE6.cjs.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-EE7N5XXQ.cjs → chunk-NK5Q7UNE.cjs} +10 -21
- package/dist/chunk-NK5Q7UNE.cjs.map +1 -0
- package/dist/{chunk-PHXITZE4.js → chunk-NMWDXFPH.js} +4 -4
- package/dist/{chunk-PHXITZE4.js.map → chunk-NMWDXFPH.js.map} +1 -1
- package/dist/{chunk-FSXTPBRN.js → chunk-NQ6BRJBE.js} +416 -850
- package/dist/chunk-NQ6BRJBE.js.map +1 -0
- package/dist/chunk-OH5E5KIO.js +2057 -0
- package/dist/chunk-OH5E5KIO.js.map +1 -0
- package/dist/chunk-ONU3HIED.cjs +2082 -0
- package/dist/chunk-ONU3HIED.cjs.map +1 -0
- package/dist/{chunk-STQ3BSED.cjs → chunk-PNN7RHVR.cjs} +66 -44
- package/dist/chunk-PNN7RHVR.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-ACSVZPK7.cjs → chunk-PWLJ77UV.cjs} +5 -3
- package/dist/chunk-PWLJ77UV.cjs.map +1 -0
- package/dist/chunk-Q7Q4WSLJ.cjs +328 -0
- package/dist/chunk-Q7Q4WSLJ.cjs.map +1 -0
- package/dist/{chunk-BEFM74L2.js → chunk-QLRESYPU.js} +637 -493
- package/dist/chunk-QLRESYPU.js.map +1 -0
- package/dist/{chunk-SBPC5IP3.js → chunk-QWX5YA3K.js} +784 -202
- package/dist/chunk-QWX5YA3K.js.map +1 -0
- package/dist/{chunk-TCRIQMBU.js → chunk-RJS7DECT.js} +8 -9
- package/dist/chunk-RJS7DECT.js.map +1 -0
- package/dist/{chunk-6JZUSDY2.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-IJTLXNGJ.js → chunk-T4XNKYXB.js} +780 -127
- package/dist/chunk-T4XNKYXB.js.map +1 -0
- package/dist/{chunk-PDGEXGS6.cjs → chunk-TQR4KBY2.cjs} +354 -182
- package/dist/chunk-TQR4KBY2.cjs.map +1 -0
- package/dist/chunk-TTAITEPJ.cjs +755 -0
- package/dist/chunk-TTAITEPJ.cjs.map +1 -0
- package/dist/{chunk-NN3QSOVS.cjs → chunk-U5SON7R2.cjs} +27 -27
- package/dist/{chunk-NN3QSOVS.cjs.map → chunk-U5SON7R2.cjs.map} +1 -1
- package/dist/{chunk-A2I2XO52.cjs → chunk-U63GDNRC.cjs} +32 -26
- package/dist/chunk-U63GDNRC.cjs.map +1 -0
- package/dist/{chunk-YNULOIR5.cjs → chunk-UDISNXDL.cjs} +64 -43
- package/dist/chunk-UDISNXDL.cjs.map +1 -0
- package/dist/{chunk-GWEDD3DH.js → chunk-UV3SN74I.js} +5 -5
- package/dist/{chunk-GWEDD3DH.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-EFELJVLA.js → chunk-VGTJPTIC.js} +28 -5
- package/dist/chunk-VGTJPTIC.js.map +1 -0
- package/dist/chunk-VQH4VAWD.cjs +12 -0
- package/dist/{chunk-EPTSMFH7.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-WEVQJ5LH.js +736 -0
- package/dist/chunk-WEVQJ5LH.js.map +1 -0
- package/dist/{chunk-3PRKZW6D.cjs → chunk-XBYVV3MP.cjs} +60 -5
- package/dist/chunk-XBYVV3MP.cjs.map +1 -0
- package/dist/{chunk-GFRGG2US.cjs → chunk-XCAGZAKP.cjs} +7 -7
- package/dist/{chunk-GFRGG2US.cjs.map → chunk-XCAGZAKP.cjs.map} +1 -1
- package/dist/{chunk-XR4YZFKW.cjs → chunk-XDF2UPEQ.cjs} +3864 -1783
- package/dist/chunk-XDF2UPEQ.cjs.map +1 -0
- package/dist/{chunk-7V2FGGI2.cjs → chunk-XMQSEJCF.cjs} +632 -1080
- package/dist/chunk-XMQSEJCF.cjs.map +1 -0
- package/dist/chunk-XNLIZYRZ.cjs +3432 -0
- package/dist/chunk-XNLIZYRZ.cjs.map +1 -0
- package/dist/{chunk-66UVLHQA.cjs → chunk-XNSI2FJO.cjs} +99 -100
- package/dist/chunk-XNSI2FJO.cjs.map +1 -0
- package/dist/chunk-XQSCL77R.cjs +60 -0
- package/dist/chunk-XQSCL77R.cjs.map +1 -0
- package/dist/{chunk-SVJ5GEXW.cjs → chunk-XUO3KQFO.cjs} +2 -2
- package/dist/chunk-XUO3KQFO.cjs.map +1 -0
- package/dist/{chunk-HJH3RMXG.cjs → chunk-YAAM3M2S.cjs} +10 -10
- package/dist/{chunk-HJH3RMXG.cjs.map → chunk-YAAM3M2S.cjs.map} +1 -1
- package/dist/{chunk-ATLN63JA.js → chunk-YBFHZUXX.js} +6 -6
- package/dist/{chunk-ATLN63JA.js.map → chunk-YBFHZUXX.js.map} +1 -1
- package/dist/{chunk-K3BUWSFR.js → chunk-YDFDBE6D.js} +119 -6
- package/dist/chunk-YDFDBE6D.js.map +1 -0
- package/dist/{chunk-OSZPLZIV.cjs → chunk-YVWGEQJE.cjs} +318 -132
- 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 -41
- package/dist/core/index.d.cts +4 -5
- package/dist/core/index.d.ts +4 -5
- package/dist/core/index.js +8 -9
- package/dist/{ddl-eWg7hx6R.d.cts → ddl-BJcOp4WZ.d.cts} +3 -3
- package/dist/{ddl-D5369kOY.d.ts → ddl-BXfGHbPN.d.ts} +3 -3
- package/dist/graph-extension/index.cjs +26 -23
- 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 -8
- package/dist/graph-merge/index.cjs +2459 -655
- 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 -468
- package/dist/graph-merge/index.js.map +1 -1
- package/dist/{index-By89Sezh.d.ts → index-BSHvKfok.d.ts} +221 -10
- package/dist/{index-DcQ3Sxs-.d.cts → index-DxaYCv8Y.d.cts} +221 -10
- package/dist/index.cjs +330 -269
- 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 -50
- 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 -50
- 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 -24
- package/dist/interchange/index.js.map +1 -1
- package/dist/{manager-B0KjKE93.d.ts → manager-CfZAimti.d.ts} +36 -5
- package/dist/{manager-Cn0NFIhN.d.cts → manager-HGk6E_HW.d.cts} +36 -5
- package/dist/{materialize-indexes-BD4V3svD.d.ts → materialize-indexes-6A7dWGtb.d.cts} +10 -2
- package/dist/{materialize-indexes-DVRhd5h4.d.cts → materialize-indexes-BMJP6Tms.d.ts} +10 -2
- package/dist/{postgres-DaEWvN4x.d.cts → postgres-DFYWENdR.d.cts} +1961 -439
- package/dist/{postgres-u0a0HN2D.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 -49
- package/dist/schema/index.d.cts +9 -16
- package/dist/schema/index.d.ts +9 -16
- package/dist/schema/index.js +23 -22
- package/dist/{searchable-CnYEancP.d.ts → searchable-9OQoPuRs.d.ts} +1 -2
- package/dist/{searchable-BT7j9_IK.d.cts → searchable-CIje5XYD.d.cts} +1 -2
- package/dist/{sqlite-BrMoSsI7.d.cts → sqlite-DerU5tc7.d.ts} +2029 -347
- package/dist/{sqlite-CHhZUyO5.d.ts → sqlite-DitnISa9.d.cts} +2029 -347
- package/dist/{store-view-Bvdku0Ht.d.ts → store-DawaWWjJ.d.ts} +3145 -2556
- package/dist/{store-view-w-md0nQ4.d.cts → store-RwTJx8LX.d.cts} +3145 -2556
- package/dist/{temporal-BCORwUau.d.cts → temporal-Bn-Fi8FJ.d.cts} +1 -1
- package/dist/{temporal--x9T8K4S.d.ts → temporal-BtM4UALv.d.ts} +1 -1
- package/dist/{types-6-WJmSD4.d.cts → types-CoIx8HX5.d.cts} +1 -1
- package/dist/{types-Cjvkj0jA.d.ts → types-HkveCCx0.d.cts} +866 -21
- package/dist/{types-Cjvkj0jA.d.cts → types-HkveCCx0.d.ts} +866 -21
- package/dist/{types-COODtTJU.d.ts → types-KFfk-8Ah.d.ts} +1 -1
- package/dist/{where-CUQmCR6d.d.cts → where--fk7_0kv.d.cts} +1 -1
- package/dist/{where-5xVawAwL.d.ts → where-ws5hf-Ov.d.ts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-2BIG7U6E.cjs +0 -83
- package/dist/chunk-2BIG7U6E.cjs.map +0 -1
- package/dist/chunk-2L54C2C2.js +0 -144
- package/dist/chunk-2L54C2C2.js.map +0 -1
- package/dist/chunk-2VLBGQBY.cjs.map +0 -1
- package/dist/chunk-2WDD2NO3.js +0 -59
- package/dist/chunk-2WDD2NO3.js.map +0 -1
- package/dist/chunk-2Y4IFKW7.js.map +0 -1
- package/dist/chunk-35S6P5ZU.js +0 -27
- package/dist/chunk-35S6P5ZU.js.map +0 -1
- package/dist/chunk-3PRKZW6D.cjs.map +0 -1
- package/dist/chunk-4MB3AQAQ.js.map +0 -1
- package/dist/chunk-4SZ6XPTG.cjs +0 -12
- package/dist/chunk-5MUSU4ZP.cjs.map +0 -1
- package/dist/chunk-63KCKSSH.js.map +0 -1
- package/dist/chunk-66UVLHQA.cjs.map +0 -1
- package/dist/chunk-6JZUSDY2.cjs.map +0 -1
- package/dist/chunk-764JHTLT.cjs +0 -15
- package/dist/chunk-764JHTLT.cjs.map +0 -1
- package/dist/chunk-7G32LIQM.js.map +0 -1
- package/dist/chunk-7V2FGGI2.cjs.map +0 -1
- package/dist/chunk-A2I2XO52.cjs.map +0 -1
- package/dist/chunk-A4PBRX4C.cjs +0 -100
- package/dist/chunk-A4PBRX4C.cjs.map +0 -1
- package/dist/chunk-ACSVZPK7.cjs.map +0 -1
- package/dist/chunk-ALFUGRYB.cjs +0 -1282
- package/dist/chunk-ALFUGRYB.cjs.map +0 -1
- package/dist/chunk-B75XRV3O.js +0 -125
- package/dist/chunk-B75XRV3O.js.map +0 -1
- package/dist/chunk-BCP7LLOY.js.map +0 -1
- package/dist/chunk-BEFM74L2.js.map +0 -1
- package/dist/chunk-BNUFUFAU.js.map +0 -1
- package/dist/chunk-C4F7VJ5D.cjs.map +0 -1
- package/dist/chunk-CPEL3YIR.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-EE7N5XXQ.cjs.map +0 -1
- package/dist/chunk-EFELJVLA.js.map +0 -1
- package/dist/chunk-EPTSMFH7.cjs +0 -12
- 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-FMGEZBAQ.js.map +0 -1
- package/dist/chunk-FMMIX6N4.js.map +0 -1
- package/dist/chunk-FRHHDHKH.js.map +0 -1
- package/dist/chunk-FSXTPBRN.js.map +0 -1
- package/dist/chunk-G6Q5UM7U.js.map +0 -1
- package/dist/chunk-GYA4JRP5.js.map +0 -1
- package/dist/chunk-HOHAJ2NR.cjs +0 -61
- package/dist/chunk-HOHAJ2NR.cjs.map +0 -1
- package/dist/chunk-HOIFFY4M.js.map +0 -1
- package/dist/chunk-IIMQJYAM.js +0 -81
- package/dist/chunk-IIMQJYAM.js.map +0 -1
- package/dist/chunk-IJTLXNGJ.js.map +0 -1
- package/dist/chunk-ITE4IXAK.js +0 -25
- package/dist/chunk-ITE4IXAK.js.map +0 -1
- package/dist/chunk-K3BUWSFR.js.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-MCHP7RHZ.cjs.map +0 -1
- package/dist/chunk-MIJKEVV7.js.map +0 -1
- package/dist/chunk-NCX65HBY.cjs +0 -1396
- package/dist/chunk-NCX65HBY.cjs.map +0 -1
- package/dist/chunk-OSZPLZIV.cjs.map +0 -1
- package/dist/chunk-OVUUTCPJ.cjs.map +0 -1
- package/dist/chunk-PDGEXGS6.cjs.map +0 -1
- package/dist/chunk-QB6VMOJ2.cjs.map +0 -1
- package/dist/chunk-QMQLUA66.js +0 -12
- package/dist/chunk-QMQLUA66.js.map +0 -1
- package/dist/chunk-QYWINYEA.cjs.map +0 -1
- package/dist/chunk-S4KQ5LV4.js.map +0 -1
- package/dist/chunk-SBPC5IP3.js.map +0 -1
- package/dist/chunk-SJDMVITW.cjs.map +0 -1
- package/dist/chunk-SNXVDZAJ.js.map +0 -1
- package/dist/chunk-SQRD2CYF.js.map +0 -1
- package/dist/chunk-ST3LPB2V.cjs.map +0 -1
- package/dist/chunk-STQ3BSED.cjs.map +0 -1
- package/dist/chunk-SVJ5GEXW.cjs.map +0 -1
- package/dist/chunk-TCRIQMBU.js.map +0 -1
- package/dist/chunk-TDXIBCGY.cjs.map +0 -1
- package/dist/chunk-TFMVL4QH.js.map +0 -1
- package/dist/chunk-TRF4EBJT.cjs +0 -30
- package/dist/chunk-TRF4EBJT.cjs.map +0 -1
- package/dist/chunk-TVLKA4AY.js +0 -94
- package/dist/chunk-TVLKA4AY.js.map +0 -1
- package/dist/chunk-UR7W5YQK.js.map +0 -1
- package/dist/chunk-VITTKBWF.js +0 -1263
- package/dist/chunk-VITTKBWF.js.map +0 -1
- package/dist/chunk-WBUFJ7BS.cjs +0 -131
- package/dist/chunk-WBUFJ7BS.cjs.map +0 -1
- package/dist/chunk-XR4YZFKW.cjs.map +0 -1
- package/dist/chunk-YNULOIR5.cjs.map +0 -1
- package/dist/chunk-ZDH3DX3C.cjs +0 -30
- package/dist/chunk-ZDH3DX3C.cjs.map +0 -1
- package/dist/chunk-ZTAJL4DT.cjs +0 -85
- package/dist/chunk-ZTAJL4DT.cjs.map +0 -1
- package/dist/define-graph-DVF-oN1i.d.cts +0 -173
- package/dist/define-graph-SvYXOl78.d.ts +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-DLNROMQ7.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) {
|
|
@@ -1137,6 +1108,7 @@ var GRAPH_BACKEND_PROJECTION_KEYS = [
|
|
|
1137
1108
|
"insertNodesBatch",
|
|
1138
1109
|
"insertNodesBatchReturning",
|
|
1139
1110
|
"updateNode",
|
|
1111
|
+
"updateNodeSet",
|
|
1140
1112
|
"deleteNode",
|
|
1141
1113
|
"hardDeleteNode",
|
|
1142
1114
|
"getNode",
|
|
@@ -1159,10 +1131,12 @@ var GRAPH_BACKEND_PROJECTION_KEYS = [
|
|
|
1159
1131
|
"countNodesByKind",
|
|
1160
1132
|
"findEdgesByKind",
|
|
1161
1133
|
"findEdgesByEndpointSet",
|
|
1134
|
+
"findEdgesByHeterogeneousEndpointSet",
|
|
1162
1135
|
"countEdgesByKind",
|
|
1163
1136
|
"insertUnique",
|
|
1164
1137
|
"insertUniqueBatch",
|
|
1165
1138
|
"deleteUnique",
|
|
1139
|
+
"hardDeleteUniquesByNodeIds",
|
|
1166
1140
|
"checkUnique",
|
|
1167
1141
|
"checkUniqueBatch",
|
|
1168
1142
|
"getActiveSchema",
|
|
@@ -1170,11 +1144,13 @@ var GRAPH_BACKEND_PROJECTION_KEYS = [
|
|
|
1170
1144
|
"commitSchemaVersion",
|
|
1171
1145
|
"commitSchemaVersionIfKindsEmpty",
|
|
1172
1146
|
"lockSchemaVersionForWrite",
|
|
1147
|
+
"commitSchemaVersionWithPreflight",
|
|
1173
1148
|
"setActiveVersion",
|
|
1174
1149
|
"schemaWriteTransaction",
|
|
1175
1150
|
"upsertEmbedding",
|
|
1176
1151
|
"upsertEmbeddingBatch",
|
|
1177
1152
|
"deleteEmbedding",
|
|
1153
|
+
"deleteEmbeddingBatch",
|
|
1178
1154
|
"vectorSearch",
|
|
1179
1155
|
"createVectorIndex",
|
|
1180
1156
|
"dropVectorIndex",
|
|
@@ -1207,7 +1183,12 @@ var GRAPH_BACKEND_PROJECTION_KEYS = [
|
|
|
1207
1183
|
"assertVectorSlotsInitialized",
|
|
1208
1184
|
"deleteVectorSlotContribution",
|
|
1209
1185
|
"verifyContributions",
|
|
1186
|
+
"repairContributions",
|
|
1187
|
+
"probeContributions",
|
|
1188
|
+
"rebuildContribution",
|
|
1210
1189
|
"ensureFulltextTable",
|
|
1190
|
+
"ensureIdentityTables",
|
|
1191
|
+
"identityTableDdl",
|
|
1211
1192
|
"getReconciliationMarker",
|
|
1212
1193
|
"setReconciliationMarker",
|
|
1213
1194
|
"clearGraph",
|
|
@@ -1228,7 +1209,9 @@ function projectBackendMembers(backend, keys) {
|
|
|
1228
1209
|
if (!Reflect.has(backend, key)) return [];
|
|
1229
1210
|
return [[key, Reflect.get(backend, key)]];
|
|
1230
1211
|
});
|
|
1231
|
-
|
|
1212
|
+
const projection = Object.fromEntries(entries);
|
|
1213
|
+
inheritSerializedTransactionResource(projection, backend);
|
|
1214
|
+
return projection;
|
|
1232
1215
|
}
|
|
1233
1216
|
function createGraphBackendProjection(backend) {
|
|
1234
1217
|
return projectBackendMembers(backend, GRAPH_BACKEND_PROJECTION_KEYS);
|
|
@@ -1269,6 +1252,7 @@ async function runInsertBatch(dispatch, params) {
|
|
|
1269
1252
|
}
|
|
1270
1253
|
}
|
|
1271
1254
|
async function runInsertBatchReturning(dispatch, params) {
|
|
1255
|
+
if (params.length === 0) return [];
|
|
1272
1256
|
if (dispatch.batchReturning !== void 0) {
|
|
1273
1257
|
return dispatch.batchReturning(params);
|
|
1274
1258
|
}
|
|
@@ -1279,6 +1263,174 @@ async function runInsertBatchReturning(dispatch, params) {
|
|
|
1279
1263
|
return rows;
|
|
1280
1264
|
}
|
|
1281
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
|
+
|
|
1282
1434
|
// src/query/compiler/predicates.ts
|
|
1283
1435
|
var COMPARISON_OP_SQL = {
|
|
1284
1436
|
eq: "=",
|
|
@@ -2058,8 +2210,31 @@ var RECORDED_EDGE_COLUMNS = [
|
|
|
2058
2210
|
"tx_id",
|
|
2059
2211
|
"meta"
|
|
2060
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
|
+
];
|
|
2061
2233
|
var RECORDED_NODE_COLUMN_LIST = sql.raw(RECORDED_NODE_COLUMNS.join(", "));
|
|
2062
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
|
+
);
|
|
2063
2238
|
var RECORDED_BIND_PARAM_BUDGET = 900;
|
|
2064
2239
|
function recordedBindParamBudget(target) {
|
|
2065
2240
|
const budget = target.capabilities.maxBindParameters ?? RECORDED_BIND_PARAM_BUDGET;
|
|
@@ -2113,6 +2288,26 @@ var recordedEdgeCells = {
|
|
|
2113
2288
|
to_kind: (row) => sql`${row.to_kind}`,
|
|
2114
2289
|
to_id: (row) => sql`${row.to_id}`
|
|
2115
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
|
+
};
|
|
2116
2311
|
function recordedValuesTuple(columns, cells, row, recordedRevision, operation) {
|
|
2117
2312
|
const tuple = columns.map(
|
|
2118
2313
|
(column) => cells[column](row, recordedRevision, operation)
|
|
@@ -2144,6 +2339,9 @@ function recordedNodeChunkSize(target) {
|
|
|
2144
2339
|
function recordedEdgeChunkSize(target) {
|
|
2145
2340
|
return recordedChunkSize(target, RECORDED_EDGE_COLUMNS.length);
|
|
2146
2341
|
}
|
|
2342
|
+
function recordedIdentityAssertionChunkSize(target) {
|
|
2343
|
+
return recordedChunkSize(target, RECORDED_IDENTITY_ASSERTION_COLUMNS.length);
|
|
2344
|
+
}
|
|
2147
2345
|
function insertRecordedNodeRows(target, table, inserts, recordedRevision) {
|
|
2148
2346
|
return insertRecordedRows(
|
|
2149
2347
|
target,
|
|
@@ -2166,6 +2364,17 @@ function insertRecordedEdgeRows(target, table, inserts, recordedRevision) {
|
|
|
2166
2364
|
recordedRevision
|
|
2167
2365
|
);
|
|
2168
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
|
+
}
|
|
2169
2378
|
|
|
2170
2379
|
// src/store/recorded-capture/flush.ts
|
|
2171
2380
|
function entityKey(entity) {
|
|
@@ -2176,6 +2385,9 @@ function entityKey(entity) {
|
|
|
2176
2385
|
case "edge": {
|
|
2177
2386
|
return `edge\0${entity.graphId}\0${entity.id}`;
|
|
2178
2387
|
}
|
|
2388
|
+
case "identity": {
|
|
2389
|
+
return `identity\0${entity.graphId}\0${entity.id}`;
|
|
2390
|
+
}
|
|
2179
2391
|
}
|
|
2180
2392
|
}
|
|
2181
2393
|
async function closeOpenReturning(target, table, graphId, ids, recordedRevision, kind) {
|
|
@@ -2277,6 +2489,42 @@ async function flushEdges(target, schema, graphId, entities, recordedRevision) {
|
|
|
2277
2489
|
);
|
|
2278
2490
|
}
|
|
2279
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
|
+
}
|
|
2280
2528
|
async function closeOpenByKind(target, table, graphId, kind, recordedRevision) {
|
|
2281
2529
|
await executeStatement(
|
|
2282
2530
|
target,
|
|
@@ -2381,7 +2629,19 @@ function isCompatibleColumnType(dialect, declaredType, kind) {
|
|
|
2381
2629
|
if (dialect === "sqlite") return hasSqliteAffinity(declaredType, kind);
|
|
2382
2630
|
return kind === "revision" ? declaredType === "bigint" : declaredType === "timestamp with time zone";
|
|
2383
2631
|
}
|
|
2384
|
-
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
|
+
] : [];
|
|
2385
2645
|
return [
|
|
2386
2646
|
{
|
|
2387
2647
|
table: schema.tables.recordedNodes,
|
|
@@ -2412,11 +2672,12 @@ function requiredRecordedColumns(schema) {
|
|
|
2412
2672
|
table: schema.tables.recordedClock,
|
|
2413
2673
|
column: "recorded_at",
|
|
2414
2674
|
kind: "wall-time"
|
|
2415
|
-
}
|
|
2675
|
+
},
|
|
2676
|
+
...identityColumns
|
|
2416
2677
|
];
|
|
2417
2678
|
}
|
|
2418
|
-
async function assertCurrentRecordedSchema(backend, schema) {
|
|
2419
|
-
const requirements = requiredRecordedColumns(schema);
|
|
2679
|
+
async function assertCurrentRecordedSchema(backend, schema, includeIdentity = false) {
|
|
2680
|
+
const requirements = requiredRecordedColumns(schema, includeIdentity);
|
|
2420
2681
|
const tables = [...new Set(requirements.map((entry) => entry.table))];
|
|
2421
2682
|
const columnTypes = new Map(
|
|
2422
2683
|
await Promise.all(
|
|
@@ -2425,6 +2686,20 @@ async function assertCurrentRecordedSchema(backend, schema) {
|
|
|
2425
2686
|
)
|
|
2426
2687
|
)
|
|
2427
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
|
+
}
|
|
2428
2703
|
const incompatible = requirements.flatMap((requirement) => {
|
|
2429
2704
|
const actual = columnTypes.get(requirement.table)?.get(requirement.column);
|
|
2430
2705
|
if (actual !== void 0 && isCompatibleColumnType(backend.dialect, actual, requirement.kind)) {
|
|
@@ -2512,6 +2787,9 @@ function createRecordedCaptureSession() {
|
|
|
2512
2787
|
touchEdge(graphId, id, afterImage) {
|
|
2513
2788
|
touch({ entity: "edge", graphId, id, afterImage });
|
|
2514
2789
|
},
|
|
2790
|
+
touchIdentityAssertion(graphId, id, afterImage) {
|
|
2791
|
+
touch({ entity: "identity", graphId, id, afterImage });
|
|
2792
|
+
},
|
|
2515
2793
|
async flush(target, schema, ownsWriteLock) {
|
|
2516
2794
|
if (sealed) {
|
|
2517
2795
|
throw new ConfigurationError(
|
|
@@ -2540,6 +2818,9 @@ function createRecordedCaptureSession() {
|
|
|
2540
2818
|
const edges = entities.filter(
|
|
2541
2819
|
(entity) => entity.entity === "edge"
|
|
2542
2820
|
);
|
|
2821
|
+
const identityAssertions = entities.filter(
|
|
2822
|
+
(entity) => entity.entity === "identity"
|
|
2823
|
+
);
|
|
2543
2824
|
await flushNodes(
|
|
2544
2825
|
target,
|
|
2545
2826
|
schema,
|
|
@@ -2554,12 +2835,33 @@ function createRecordedCaptureSession() {
|
|
|
2554
2835
|
edges,
|
|
2555
2836
|
recordedCommit.revision
|
|
2556
2837
|
);
|
|
2838
|
+
await flushIdentityAssertions(
|
|
2839
|
+
target,
|
|
2840
|
+
schema,
|
|
2841
|
+
graphId,
|
|
2842
|
+
identityAssertions,
|
|
2843
|
+
recordedCommit.revision
|
|
2844
|
+
);
|
|
2557
2845
|
}
|
|
2558
2846
|
touched.clear();
|
|
2559
2847
|
return recordedByGraph;
|
|
2560
2848
|
}
|
|
2561
2849
|
};
|
|
2562
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
|
+
}
|
|
2563
2865
|
function createRecordedTransactionBackend(target, session, schema) {
|
|
2564
2866
|
const nodeDispatch = nodeInsertDispatch(target);
|
|
2565
2867
|
const edgeDispatch = edgeInsertDispatch(target);
|
|
@@ -2628,6 +2930,17 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
2628
2930
|
session.touchNode(params.graphId, params.kind, params.id, row);
|
|
2629
2931
|
return row;
|
|
2630
2932
|
},
|
|
2933
|
+
...target.updateNodeSet === void 0 ? {} : {
|
|
2934
|
+
async updateNodeSet(params) {
|
|
2935
|
+
session.assertOpen();
|
|
2936
|
+
await lockGraph(params.graphId);
|
|
2937
|
+
const result = await requireDefined(target.updateNodeSet)(params);
|
|
2938
|
+
for (const row of result.rows) {
|
|
2939
|
+
session.touchNode(row.graph_id, row.kind, row.id, row);
|
|
2940
|
+
}
|
|
2941
|
+
return result;
|
|
2942
|
+
}
|
|
2943
|
+
},
|
|
2631
2944
|
async deleteNode(params) {
|
|
2632
2945
|
session.assertOpen();
|
|
2633
2946
|
await lockGraph(params.graphId);
|
|
@@ -2732,6 +3045,8 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
2732
3045
|
}
|
|
2733
3046
|
});
|
|
2734
3047
|
registerRecordedGraphLockMemo(overlay, graphLocks);
|
|
3048
|
+
recordedIdentityBindings.set(overlay, { target, session });
|
|
3049
|
+
recordedIdentityBindings.set(target, { target, session });
|
|
2735
3050
|
return overlay;
|
|
2736
3051
|
}
|
|
2737
3052
|
function createRecordedTransactionScope(target, schema, ownsWriteLock = false) {
|
|
@@ -2791,6 +3106,20 @@ function createRecordedBackend(backend, schema) {
|
|
|
2791
3106
|
async updateNode(params) {
|
|
2792
3107
|
return capture((target) => target.updateNode(params));
|
|
2793
3108
|
},
|
|
3109
|
+
...backend.updateNodeSet === void 0 ? {} : {
|
|
3110
|
+
async updateNodeSet(params) {
|
|
3111
|
+
return capture((target) => {
|
|
3112
|
+
const updateNodeSet = target.updateNodeSet;
|
|
3113
|
+
if (updateNodeSet === void 0) {
|
|
3114
|
+
throw new ConfigurationError(
|
|
3115
|
+
"Recorded updateNodeSet capability disappeared inside a transaction",
|
|
3116
|
+
{ operation: "updateNodeSet" }
|
|
3117
|
+
);
|
|
3118
|
+
}
|
|
3119
|
+
return updateNodeSet(params);
|
|
3120
|
+
});
|
|
3121
|
+
}
|
|
3122
|
+
},
|
|
2794
3123
|
async deleteNode(params) {
|
|
2795
3124
|
await capture((target) => target.deleteNode(params));
|
|
2796
3125
|
},
|
|
@@ -2861,791 +3190,28 @@ function createRecordedBackend(backend, schema) {
|
|
|
2861
3190
|
});
|
|
2862
3191
|
}
|
|
2863
3192
|
|
|
2864
|
-
// src/
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
return;
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
if (isValidEmbeddingValue(value)) {
|
|
2885
|
-
await backend.upsertEmbedding({
|
|
2886
|
-
graphId: ctx.graphId,
|
|
2887
|
-
nodeKind: ctx.nodeKind,
|
|
2888
|
-
nodeId: ctx.nodeId,
|
|
2889
|
-
fieldPath: field.fieldPath,
|
|
2890
|
-
embedding: value,
|
|
2891
|
-
dimensions: field.dimensions,
|
|
2892
|
-
metric: field.metric,
|
|
2893
|
-
indexType: field.indexType
|
|
2894
|
-
});
|
|
2895
|
-
} else if (value === void 0) {
|
|
2896
|
-
await backend.deleteEmbedding({
|
|
2897
|
-
graphId: ctx.graphId,
|
|
2898
|
-
nodeKind: ctx.nodeKind,
|
|
2899
|
-
nodeId: ctx.nodeId,
|
|
2900
|
-
fieldPath: field.fieldPath,
|
|
2901
|
-
dimensions: field.dimensions,
|
|
2902
|
-
metric: field.metric,
|
|
2903
|
-
indexType: field.indexType
|
|
2904
|
-
});
|
|
2905
|
-
}
|
|
2906
|
-
}
|
|
2907
|
-
}
|
|
2908
|
-
async function syncEmbeddingsBatchForKind(args, schema, items) {
|
|
2909
|
-
const { graphId, nodeKind, backend } = args;
|
|
2910
|
-
if (!backend.upsertEmbedding || !backend.deleteEmbedding) {
|
|
2911
|
-
return;
|
|
2912
|
-
}
|
|
2913
|
-
const embeddingFields = getEmbeddingFields(schema);
|
|
2914
|
-
if (embeddingFields.length === 0) {
|
|
2915
|
-
return;
|
|
2916
|
-
}
|
|
2917
|
-
for (const field of embeddingFields) {
|
|
2918
|
-
const rows = [];
|
|
2919
|
-
const deletionIds = [];
|
|
2920
|
-
for (const item of items) {
|
|
2921
|
-
const value = item.props[field.fieldPath];
|
|
2922
|
-
if (isValidEmbeddingValue(value)) {
|
|
2923
|
-
rows.push({ nodeId: item.nodeId, embedding: value });
|
|
2924
|
-
} else if (value === void 0) {
|
|
2925
|
-
deletionIds.push(item.nodeId);
|
|
2926
|
-
}
|
|
2927
|
-
}
|
|
2928
|
-
if (rows.length > 0) {
|
|
2929
|
-
if (backend.upsertEmbeddingBatch === void 0) {
|
|
2930
|
-
for (const row of rows) {
|
|
2931
|
-
await backend.upsertEmbedding({
|
|
2932
|
-
graphId,
|
|
2933
|
-
nodeKind,
|
|
2934
|
-
nodeId: row.nodeId,
|
|
2935
|
-
fieldPath: field.fieldPath,
|
|
2936
|
-
embedding: row.embedding,
|
|
2937
|
-
dimensions: field.dimensions,
|
|
2938
|
-
metric: field.metric,
|
|
2939
|
-
indexType: field.indexType
|
|
2940
|
-
});
|
|
2941
|
-
}
|
|
2942
|
-
} else {
|
|
2943
|
-
await backend.upsertEmbeddingBatch({
|
|
2944
|
-
graphId,
|
|
2945
|
-
nodeKind,
|
|
2946
|
-
fieldPath: field.fieldPath,
|
|
2947
|
-
dimensions: field.dimensions,
|
|
2948
|
-
metric: field.metric,
|
|
2949
|
-
indexType: field.indexType,
|
|
2950
|
-
rows
|
|
2951
|
-
});
|
|
2952
|
-
}
|
|
2953
|
-
}
|
|
2954
|
-
for (const nodeId of deletionIds) {
|
|
2955
|
-
await backend.deleteEmbedding({
|
|
2956
|
-
graphId,
|
|
2957
|
-
nodeKind,
|
|
2958
|
-
nodeId,
|
|
2959
|
-
fieldPath: field.fieldPath,
|
|
2960
|
-
dimensions: field.dimensions,
|
|
2961
|
-
metric: field.metric,
|
|
2962
|
-
indexType: field.indexType
|
|
2963
|
-
});
|
|
2964
|
-
}
|
|
2965
|
-
}
|
|
2966
|
-
}
|
|
2967
|
-
async function deleteNodeEmbeddings(ctx, schema) {
|
|
2968
|
-
const { backend } = ctx;
|
|
2969
|
-
if (!backend.deleteEmbedding) {
|
|
2970
|
-
return;
|
|
2971
|
-
}
|
|
2972
|
-
const embeddingFields = getEmbeddingFields(schema);
|
|
2973
|
-
if (embeddingFields.length === 0) {
|
|
2974
|
-
return;
|
|
2975
|
-
}
|
|
2976
|
-
for (const field of embeddingFields) {
|
|
2977
|
-
await backend.deleteEmbedding({
|
|
2978
|
-
graphId: ctx.graphId,
|
|
2979
|
-
nodeKind: ctx.nodeKind,
|
|
2980
|
-
nodeId: ctx.nodeId,
|
|
2981
|
-
fieldPath: field.fieldPath,
|
|
2982
|
-
dimensions: field.dimensions,
|
|
2983
|
-
metric: field.metric,
|
|
2984
|
-
indexType: field.indexType
|
|
2985
|
-
});
|
|
2986
|
-
}
|
|
2987
|
-
}
|
|
2988
|
-
function isValidEmbeddingValue(value) {
|
|
2989
|
-
if (!Array.isArray(value)) {
|
|
2990
|
-
return false;
|
|
2991
|
-
}
|
|
2992
|
-
return value.every((n) => typeof n === "number" && Number.isFinite(n));
|
|
2993
|
-
}
|
|
2994
|
-
|
|
2995
|
-
// src/store/fulltext-sync.ts
|
|
2996
|
-
var FIELD_SEPARATOR = "\n";
|
|
2997
|
-
function resolveCombinedLanguage(fields) {
|
|
2998
|
-
return fields[0]?.metadata.language ?? DEFAULT_SEARCHABLE_LANGUAGE;
|
|
2999
|
-
}
|
|
3000
|
-
function computeFulltextContent(schema, props) {
|
|
3001
|
-
const searchableFields = getSearchableFields(schema);
|
|
3002
|
-
if (searchableFields.length === 0) return void 0;
|
|
3003
|
-
const parts = [];
|
|
3004
|
-
for (const field of searchableFields) {
|
|
3005
|
-
const value = props[field.fieldPath];
|
|
3006
|
-
if (typeof value === "string" && value.length > 0) {
|
|
3007
|
-
parts.push(value);
|
|
3008
|
-
}
|
|
3009
|
-
}
|
|
3010
|
-
if (parts.length === 0) return void 0;
|
|
3011
|
-
return {
|
|
3012
|
-
content: parts.join(FIELD_SEPARATOR),
|
|
3013
|
-
language: resolveCombinedLanguage(searchableFields)
|
|
3014
|
-
};
|
|
3015
|
-
}
|
|
3016
|
-
async function syncFulltext(ctx, schema, props) {
|
|
3017
|
-
const { backend } = ctx;
|
|
3018
|
-
if (!backend.upsertFulltext || !backend.deleteFulltext) {
|
|
3019
|
-
return;
|
|
3020
|
-
}
|
|
3021
|
-
const computed = computeFulltextContent(schema, props);
|
|
3022
|
-
if (computed !== void 0) {
|
|
3023
|
-
await backend.upsertFulltext({
|
|
3024
|
-
graphId: ctx.graphId,
|
|
3025
|
-
nodeKind: ctx.nodeKind,
|
|
3026
|
-
nodeId: ctx.nodeId,
|
|
3027
|
-
content: computed.content,
|
|
3028
|
-
language: computed.language
|
|
3029
|
-
});
|
|
3030
|
-
return;
|
|
3031
|
-
}
|
|
3032
|
-
if (getSearchableFields(schema).length === 0) return;
|
|
3033
|
-
await backend.deleteFulltext({
|
|
3034
|
-
graphId: ctx.graphId,
|
|
3035
|
-
nodeKind: ctx.nodeKind,
|
|
3036
|
-
nodeId: ctx.nodeId
|
|
3037
|
-
});
|
|
3038
|
-
}
|
|
3039
|
-
async function syncFulltextBatchForKind(args, schema, items) {
|
|
3040
|
-
const { graphId, nodeKind, backend } = args;
|
|
3041
|
-
if (!backend.upsertFulltext || !backend.deleteFulltext) {
|
|
3042
|
-
return;
|
|
3043
|
-
}
|
|
3044
|
-
const rows = [];
|
|
3045
|
-
const emptyContentIds = [];
|
|
3046
|
-
const hasSearchableFields = getSearchableFields(schema).length > 0;
|
|
3047
|
-
for (const item of items) {
|
|
3048
|
-
const computed = computeFulltextContent(schema, item.props);
|
|
3049
|
-
if (computed !== void 0) {
|
|
3050
|
-
rows.push({
|
|
3051
|
-
nodeId: item.nodeId,
|
|
3052
|
-
content: computed.content,
|
|
3053
|
-
language: computed.language
|
|
3054
|
-
});
|
|
3055
|
-
} else if (hasSearchableFields) {
|
|
3056
|
-
emptyContentIds.push(item.nodeId);
|
|
3057
|
-
}
|
|
3058
|
-
}
|
|
3059
|
-
if (rows.length > 0) {
|
|
3060
|
-
if (backend.upsertFulltextBatch === void 0) {
|
|
3061
|
-
for (const row of rows) {
|
|
3062
|
-
await backend.upsertFulltext({
|
|
3063
|
-
graphId,
|
|
3064
|
-
nodeKind,
|
|
3065
|
-
nodeId: row.nodeId,
|
|
3066
|
-
content: row.content,
|
|
3067
|
-
language: row.language
|
|
3068
|
-
});
|
|
3069
|
-
}
|
|
3070
|
-
} else {
|
|
3071
|
-
await backend.upsertFulltextBatch({ graphId, nodeKind, rows });
|
|
3072
|
-
}
|
|
3073
|
-
}
|
|
3074
|
-
if (emptyContentIds.length > 0) {
|
|
3075
|
-
if (backend.deleteFulltextBatch === void 0) {
|
|
3076
|
-
for (const nodeId of emptyContentIds) {
|
|
3077
|
-
await backend.deleteFulltext({ graphId, nodeKind, nodeId });
|
|
3078
|
-
}
|
|
3079
|
-
} else {
|
|
3080
|
-
await backend.deleteFulltextBatch({
|
|
3081
|
-
graphId,
|
|
3082
|
-
nodeKind,
|
|
3083
|
-
nodeIds: emptyContentIds
|
|
3084
|
-
});
|
|
3085
|
-
}
|
|
3086
|
-
}
|
|
3087
|
-
}
|
|
3088
|
-
async function deleteNodeFulltext(ctx, schema) {
|
|
3089
|
-
const { backend } = ctx;
|
|
3090
|
-
if (!backend.deleteFulltext) {
|
|
3091
|
-
return;
|
|
3092
|
-
}
|
|
3093
|
-
if (getSearchableFields(schema).length === 0) {
|
|
3094
|
-
return;
|
|
3095
|
-
}
|
|
3096
|
-
await backend.deleteFulltext({
|
|
3097
|
-
graphId: ctx.graphId,
|
|
3098
|
-
nodeKind: ctx.nodeKind,
|
|
3099
|
-
nodeId: ctx.nodeId
|
|
3100
|
-
});
|
|
3101
|
-
}
|
|
3102
|
-
|
|
3103
|
-
// src/constraints/index.ts
|
|
3104
|
-
var UNIQUE_KEY_SEPARATOR = "";
|
|
3105
|
-
var UNIQUE_KEY_NULL_MARKER = "";
|
|
3106
|
-
function computeUniqueKey(props, fields, collation) {
|
|
3107
|
-
const values = fields.map((field) => {
|
|
3108
|
-
const value = props[field];
|
|
3109
|
-
if (value === void 0 || value === null) {
|
|
3110
|
-
return UNIQUE_KEY_NULL_MARKER;
|
|
3111
|
-
}
|
|
3112
|
-
const stringValue = typeof value === "string" ? value : typeof value === "number" || typeof value === "boolean" ? value.toString() : JSON.stringify(value);
|
|
3113
|
-
return collation === "caseInsensitive" ? stringValue.toLowerCase() : stringValue;
|
|
3114
|
-
});
|
|
3115
|
-
return values.join(UNIQUE_KEY_SEPARATOR);
|
|
3116
|
-
}
|
|
3117
|
-
function checkWherePredicate(constraint, props) {
|
|
3118
|
-
if (!constraint.where) {
|
|
3119
|
-
return true;
|
|
3120
|
-
}
|
|
3121
|
-
const predicateBuilder = buildPredicateContext(props);
|
|
3122
|
-
const predicate2 = constraint.where(predicateBuilder);
|
|
3123
|
-
return evaluatePredicate(predicate2, props);
|
|
3124
|
-
}
|
|
3125
|
-
function buildPredicateContext(props) {
|
|
3126
|
-
const context = {};
|
|
3127
|
-
for (const key of Object.keys(props)) {
|
|
3128
|
-
context[key] = {
|
|
3129
|
-
isNull: () => ({
|
|
3130
|
-
__type: "unique_predicate",
|
|
3131
|
-
field: key,
|
|
3132
|
-
op: "isNull"
|
|
3133
|
-
}),
|
|
3134
|
-
isNotNull: () => ({
|
|
3135
|
-
__type: "unique_predicate",
|
|
3136
|
-
field: key,
|
|
3137
|
-
op: "isNotNull"
|
|
3138
|
-
})
|
|
3139
|
-
};
|
|
3140
|
-
}
|
|
3141
|
-
return context;
|
|
3142
|
-
}
|
|
3143
|
-
function evaluatePredicate(predicate2, props) {
|
|
3144
|
-
if (typeof predicate2 !== "object" || predicate2 === null || !("__type" in predicate2)) {
|
|
3145
|
-
return true;
|
|
3146
|
-
}
|
|
3147
|
-
const pred = predicate2;
|
|
3148
|
-
if (pred.__type !== "unique_predicate") {
|
|
3149
|
-
return true;
|
|
3150
|
-
}
|
|
3151
|
-
const value = props[pred.field];
|
|
3152
|
-
if (pred.op === "isNull") {
|
|
3153
|
-
return value === null || value === void 0;
|
|
3154
|
-
}
|
|
3155
|
-
return isPresent(value);
|
|
3156
|
-
}
|
|
3157
|
-
function getKindsForUniquenessCheck(baseKind, scope, registry) {
|
|
3158
|
-
if (scope === "kind") {
|
|
3159
|
-
return [baseKind];
|
|
3160
|
-
}
|
|
3161
|
-
const root = findRootAncestor(baseKind, registry);
|
|
3162
|
-
return registry.expandSubClasses(root);
|
|
3163
|
-
}
|
|
3164
|
-
function findRootAncestor(kind, registry) {
|
|
3165
|
-
const ancestors = registry.getAncestors(kind);
|
|
3166
|
-
if (ancestors.size === 0) {
|
|
3167
|
-
return kind;
|
|
3168
|
-
}
|
|
3169
|
-
for (const ancestor of ancestors) {
|
|
3170
|
-
if (registry.getAncestors(ancestor).size === 0) {
|
|
3171
|
-
return ancestor;
|
|
3172
|
-
}
|
|
3173
|
-
}
|
|
3174
|
-
const firstAncestor = [...ancestors][0];
|
|
3175
|
-
return firstAncestor ? findRootAncestor(firstAncestor, registry) : kind;
|
|
3176
|
-
}
|
|
3177
|
-
function checkCardinality(edgeKind, fromKind, fromId, cardinality, existingEdgeCount, hasActiveEdge) {
|
|
3178
|
-
switch (cardinality) {
|
|
3179
|
-
case "many": {
|
|
3180
|
-
return void 0;
|
|
3181
|
-
}
|
|
3182
|
-
case "one": {
|
|
3183
|
-
if (existingEdgeCount > 0) {
|
|
3184
|
-
return new CardinalityError({
|
|
3185
|
-
edgeKind,
|
|
3186
|
-
fromKind,
|
|
3187
|
-
fromId,
|
|
3188
|
-
cardinality: "one",
|
|
3189
|
-
existingCount: existingEdgeCount
|
|
3190
|
-
});
|
|
3191
|
-
}
|
|
3192
|
-
return void 0;
|
|
3193
|
-
}
|
|
3194
|
-
case "unique": {
|
|
3195
|
-
return void 0;
|
|
3196
|
-
}
|
|
3197
|
-
case "oneActive": {
|
|
3198
|
-
if (hasActiveEdge) {
|
|
3199
|
-
return new CardinalityError({
|
|
3200
|
-
edgeKind,
|
|
3201
|
-
fromKind,
|
|
3202
|
-
fromId,
|
|
3203
|
-
cardinality: "oneActive",
|
|
3204
|
-
existingCount: 1
|
|
3205
|
-
});
|
|
3206
|
-
}
|
|
3207
|
-
return void 0;
|
|
3208
|
-
}
|
|
3209
|
-
}
|
|
3210
|
-
}
|
|
3211
|
-
function checkUniqueEdge(edgeKind, fromKind, fromId, _toKind, _toId, existingCount) {
|
|
3212
|
-
if (existingCount > 0) {
|
|
3213
|
-
return new CardinalityError({
|
|
3214
|
-
edgeKind,
|
|
3215
|
-
fromKind,
|
|
3216
|
-
fromId,
|
|
3217
|
-
cardinality: "unique",
|
|
3218
|
-
existingCount
|
|
3219
|
-
});
|
|
3220
|
-
}
|
|
3221
|
-
return void 0;
|
|
3222
|
-
}
|
|
3223
|
-
function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registry) {
|
|
3224
|
-
const validFromKinds = registration.from.map((node) => node.kind);
|
|
3225
|
-
if (!registry.isAssignableToAny(fromKind, validFromKinds)) {
|
|
3226
|
-
return new EndpointError({
|
|
3227
|
-
edgeKind,
|
|
3228
|
-
endpoint: "from",
|
|
3229
|
-
actualKind: fromKind,
|
|
3230
|
-
expectedKinds: validFromKinds
|
|
3231
|
-
});
|
|
3232
|
-
}
|
|
3233
|
-
const validToKinds = registration.to.map((node) => node.kind);
|
|
3234
|
-
if (!registry.isAssignableToAny(toKind, validToKinds)) {
|
|
3235
|
-
return new EndpointError({
|
|
3236
|
-
edgeKind,
|
|
3237
|
-
endpoint: "to",
|
|
3238
|
-
actualKind: toKind,
|
|
3239
|
-
expectedKinds: validToKinds
|
|
3240
|
-
});
|
|
3241
|
-
}
|
|
3242
|
-
return void 0;
|
|
3243
|
-
}
|
|
3244
|
-
function checkDisjointness(nodeId, nodeKind, existingKinds, registry) {
|
|
3245
|
-
for (const existingKind of existingKinds) {
|
|
3246
|
-
if (registry.areDisjoint(nodeKind, existingKind)) {
|
|
3247
|
-
return new DisjointError({
|
|
3248
|
-
nodeId,
|
|
3249
|
-
attemptedKind: nodeKind,
|
|
3250
|
-
conflictingKind: existingKind
|
|
3251
|
-
});
|
|
3252
|
-
}
|
|
3253
|
-
}
|
|
3254
|
-
return void 0;
|
|
3255
|
-
}
|
|
3256
|
-
|
|
3257
|
-
// src/store/uniqueness.ts
|
|
3258
|
-
function createUniquenessContext(graphId, registry, backend) {
|
|
3259
|
-
return { graphId, registry, backend };
|
|
3260
|
-
}
|
|
3261
|
-
async function checkUniquenessConstraints(ctx, kind, id, props, constraints) {
|
|
3262
|
-
for (const constraint of constraints) {
|
|
3263
|
-
if (!checkWherePredicate(constraint, props)) {
|
|
3264
|
-
continue;
|
|
3265
|
-
}
|
|
3266
|
-
const key = computeUniqueKey(
|
|
3267
|
-
props,
|
|
3268
|
-
constraint.fields,
|
|
3269
|
-
constraint.collation
|
|
3270
|
-
);
|
|
3271
|
-
const kindsToCheck = getKindsForUniquenessCheck(
|
|
3272
|
-
kind,
|
|
3273
|
-
constraint.scope,
|
|
3274
|
-
ctx.registry
|
|
3275
|
-
);
|
|
3276
|
-
for (const kindToCheck of kindsToCheck) {
|
|
3277
|
-
const existing = await ctx.backend.checkUnique({
|
|
3278
|
-
graphId: ctx.graphId,
|
|
3279
|
-
nodeKind: kindToCheck,
|
|
3280
|
-
constraintName: constraint.name,
|
|
3281
|
-
key
|
|
3282
|
-
});
|
|
3283
|
-
if (existing && existing.node_id !== id) {
|
|
3284
|
-
throw new UniquenessError({
|
|
3285
|
-
constraintName: constraint.name,
|
|
3286
|
-
kind: kindToCheck,
|
|
3287
|
-
existingId: existing.node_id,
|
|
3288
|
-
newId: id,
|
|
3289
|
-
fields: constraint.fields
|
|
3290
|
-
});
|
|
3291
|
-
}
|
|
3292
|
-
}
|
|
3293
|
-
}
|
|
3294
|
-
}
|
|
3295
|
-
async function insertUniquenessEntries(ctx, kind, id, props, constraints) {
|
|
3296
|
-
for (const constraint of constraints) {
|
|
3297
|
-
if (!checkWherePredicate(constraint, props)) {
|
|
3298
|
-
continue;
|
|
3299
|
-
}
|
|
3300
|
-
const key = computeUniqueKey(
|
|
3301
|
-
props,
|
|
3302
|
-
constraint.fields,
|
|
3303
|
-
constraint.collation
|
|
3304
|
-
);
|
|
3305
|
-
await ctx.backend.insertUnique({
|
|
3306
|
-
graphId: ctx.graphId,
|
|
3307
|
-
nodeKind: kind,
|
|
3308
|
-
constraintName: constraint.name,
|
|
3309
|
-
key,
|
|
3310
|
-
nodeId: id,
|
|
3311
|
-
concreteKind: kind
|
|
3312
|
-
});
|
|
3313
|
-
}
|
|
3314
|
-
}
|
|
3315
|
-
async function insertUniquenessEntriesBatch(ctx, items) {
|
|
3316
|
-
const entries = [];
|
|
3317
|
-
for (const item of items) {
|
|
3318
|
-
for (const constraint of item.constraints) {
|
|
3319
|
-
if (!checkWherePredicate(constraint, item.props)) {
|
|
3320
|
-
continue;
|
|
3321
|
-
}
|
|
3322
|
-
entries.push({
|
|
3323
|
-
graphId: ctx.graphId,
|
|
3324
|
-
nodeKind: item.kind,
|
|
3325
|
-
constraintName: constraint.name,
|
|
3326
|
-
key: computeUniqueKey(
|
|
3327
|
-
item.props,
|
|
3328
|
-
constraint.fields,
|
|
3329
|
-
constraint.collation
|
|
3330
|
-
),
|
|
3331
|
-
nodeId: item.id,
|
|
3332
|
-
concreteKind: item.kind
|
|
3333
|
-
});
|
|
3334
|
-
}
|
|
3335
|
-
}
|
|
3336
|
-
if (entries.length === 0) return;
|
|
3337
|
-
if (ctx.backend.insertUniqueBatch !== void 0) {
|
|
3338
|
-
await ctx.backend.insertUniqueBatch(entries);
|
|
3339
|
-
return;
|
|
3340
|
-
}
|
|
3341
|
-
for (const entry of entries) {
|
|
3342
|
-
await ctx.backend.insertUnique(entry);
|
|
3343
|
-
}
|
|
3344
|
-
}
|
|
3345
|
-
async function deleteUniquenessEntries(ctx, kind, props, constraints) {
|
|
3346
|
-
for (const constraint of constraints) {
|
|
3347
|
-
if (!checkWherePredicate(constraint, props)) {
|
|
3348
|
-
continue;
|
|
3349
|
-
}
|
|
3350
|
-
const key = computeUniqueKey(
|
|
3351
|
-
props,
|
|
3352
|
-
constraint.fields,
|
|
3353
|
-
constraint.collation
|
|
3354
|
-
);
|
|
3355
|
-
await ctx.backend.deleteUnique({
|
|
3356
|
-
graphId: ctx.graphId,
|
|
3357
|
-
nodeKind: kind,
|
|
3358
|
-
constraintName: constraint.name,
|
|
3359
|
-
key
|
|
3360
|
-
});
|
|
3361
|
-
}
|
|
3362
|
-
}
|
|
3363
|
-
async function updateUniquenessEntries(ctx, kind, id, oldProps, newProps, constraints) {
|
|
3364
|
-
const pending = [];
|
|
3365
|
-
for (const constraint of constraints) {
|
|
3366
|
-
const oldApplies = checkWherePredicate(constraint, oldProps);
|
|
3367
|
-
const newApplies = checkWherePredicate(constraint, newProps);
|
|
3368
|
-
const oldKey = oldApplies ? computeUniqueKey(oldProps, constraint.fields, constraint.collation) : void 0;
|
|
3369
|
-
const newKey = newApplies ? computeUniqueKey(newProps, constraint.fields, constraint.collation) : void 0;
|
|
3370
|
-
if (!oldApplies && !newApplies) {
|
|
3371
|
-
continue;
|
|
3372
|
-
}
|
|
3373
|
-
if (oldApplies && newApplies && oldKey === newKey) {
|
|
3374
|
-
continue;
|
|
3375
|
-
}
|
|
3376
|
-
if (newApplies && newKey !== void 0) {
|
|
3377
|
-
const kindsToCheck = getKindsForUniquenessCheck(
|
|
3378
|
-
kind,
|
|
3379
|
-
constraint.scope,
|
|
3380
|
-
ctx.registry
|
|
3381
|
-
);
|
|
3382
|
-
for (const kindToCheck of kindsToCheck) {
|
|
3383
|
-
const existing = await ctx.backend.checkUnique({
|
|
3384
|
-
graphId: ctx.graphId,
|
|
3385
|
-
nodeKind: kindToCheck,
|
|
3386
|
-
constraintName: constraint.name,
|
|
3387
|
-
key: newKey
|
|
3388
|
-
});
|
|
3389
|
-
if (existing && existing.node_id !== id) {
|
|
3390
|
-
throw new UniquenessError({
|
|
3391
|
-
constraintName: constraint.name,
|
|
3392
|
-
kind: kindToCheck,
|
|
3393
|
-
existingId: existing.node_id,
|
|
3394
|
-
newId: id,
|
|
3395
|
-
fields: constraint.fields
|
|
3396
|
-
});
|
|
3397
|
-
}
|
|
3398
|
-
}
|
|
3399
|
-
}
|
|
3400
|
-
pending.push({ constraintName: constraint.name, oldKey, newKey });
|
|
3401
|
-
}
|
|
3402
|
-
for (const mutation of pending) {
|
|
3403
|
-
if (mutation.oldKey !== void 0) {
|
|
3404
|
-
await ctx.backend.deleteUnique({
|
|
3405
|
-
graphId: ctx.graphId,
|
|
3406
|
-
nodeKind: kind,
|
|
3407
|
-
constraintName: mutation.constraintName,
|
|
3408
|
-
key: mutation.oldKey
|
|
3409
|
-
});
|
|
3410
|
-
}
|
|
3411
|
-
}
|
|
3412
|
-
for (const mutation of pending) {
|
|
3413
|
-
if (mutation.newKey !== void 0) {
|
|
3414
|
-
await ctx.backend.insertUnique({
|
|
3415
|
-
graphId: ctx.graphId,
|
|
3416
|
-
nodeKind: kind,
|
|
3417
|
-
constraintName: mutation.constraintName,
|
|
3418
|
-
key: mutation.newKey,
|
|
3419
|
-
nodeId: id,
|
|
3420
|
-
concreteKind: kind
|
|
3421
|
-
});
|
|
3422
|
-
}
|
|
3423
|
-
}
|
|
3424
|
-
}
|
|
3425
|
-
|
|
3426
|
-
// src/store/operations/node-write-pipeline.ts
|
|
3427
|
-
function createNodeWriteContext(graphId, registry, lock) {
|
|
3428
|
-
return { graphId, registry, lock };
|
|
3429
|
-
}
|
|
3430
|
-
function uniquenessContext(ctx, backend) {
|
|
3431
|
-
return createUniquenessContext(ctx.graphId, ctx.registry, backend);
|
|
3432
|
-
}
|
|
3433
|
-
function nodeSyncContext(ctx, kind, id, backend) {
|
|
3434
|
-
return { graphId: ctx.graphId, nodeKind: kind, nodeId: id, backend };
|
|
3435
|
-
}
|
|
3436
|
-
async function enforceNodeDeleteBehavior(ctx, args, backend, policy) {
|
|
3437
|
-
if (policy?.enforceDeleteBehavior === false) return;
|
|
3438
|
-
const behavior = args.onDelete ?? "restrict";
|
|
3439
|
-
const connectedEdges = await backend.findEdgesConnectedTo({
|
|
3440
|
-
graphId: ctx.graphId,
|
|
3441
|
-
nodeKind: args.kind,
|
|
3442
|
-
nodeId: args.id
|
|
3443
|
-
});
|
|
3444
|
-
if (connectedEdges.length === 0) return;
|
|
3445
|
-
switch (behavior) {
|
|
3446
|
-
case "restrict": {
|
|
3447
|
-
throw new RestrictedDeleteError({
|
|
3448
|
-
nodeKind: args.kind,
|
|
3449
|
-
nodeId: args.id,
|
|
3450
|
-
edgeCount: connectedEdges.length,
|
|
3451
|
-
edgeKinds: [...new Set(connectedEdges.map((edge) => edge.kind))]
|
|
3452
|
-
});
|
|
3453
|
-
}
|
|
3454
|
-
case "cascade":
|
|
3455
|
-
case "disconnect": {
|
|
3456
|
-
const batchDelete = args.mode === "hard" ? backend.hardDeleteEdgesBatch : backend.deleteEdgesBatch;
|
|
3457
|
-
if (batchDelete !== void 0) {
|
|
3458
|
-
await batchDelete({
|
|
3459
|
-
graphId: ctx.graphId,
|
|
3460
|
-
ids: connectedEdges.map((edge) => edge.id)
|
|
3461
|
-
});
|
|
3462
|
-
break;
|
|
3463
|
-
}
|
|
3464
|
-
for (const edge of connectedEdges) {
|
|
3465
|
-
await (args.mode === "hard" ? backend.hardDeleteEdge({ graphId: ctx.graphId, id: edge.id }) : backend.deleteEdge({ graphId: ctx.graphId, id: edge.id }));
|
|
3466
|
-
}
|
|
3467
|
-
break;
|
|
3468
|
-
}
|
|
3469
|
-
}
|
|
3470
|
-
}
|
|
3471
|
-
async function applyNodeInsertSideEffects(ctx, args, backend) {
|
|
3472
|
-
await insertUniquenessEntries(
|
|
3473
|
-
uniquenessContext(ctx, backend),
|
|
3474
|
-
args.kind,
|
|
3475
|
-
args.id,
|
|
3476
|
-
args.props,
|
|
3477
|
-
args.uniqueConstraints
|
|
3478
|
-
);
|
|
3479
|
-
await Promise.all([
|
|
3480
|
-
syncEmbeddings(
|
|
3481
|
-
nodeSyncContext(ctx, args.kind, args.id, backend),
|
|
3482
|
-
args.schema,
|
|
3483
|
-
args.props
|
|
3484
|
-
),
|
|
3485
|
-
syncFulltext(
|
|
3486
|
-
nodeSyncContext(ctx, args.kind, args.id, backend),
|
|
3487
|
-
args.schema,
|
|
3488
|
-
args.props
|
|
3489
|
-
)
|
|
3490
|
-
]);
|
|
3491
|
-
}
|
|
3492
|
-
async function applyNodeInsertSideEffectsBatch(ctx, items, backend) {
|
|
3493
|
-
if (items.length === 0) return;
|
|
3494
|
-
await insertUniquenessEntriesBatch(
|
|
3495
|
-
uniquenessContext(ctx, backend),
|
|
3496
|
-
items.map((item) => ({
|
|
3497
|
-
kind: item.kind,
|
|
3498
|
-
id: item.id,
|
|
3499
|
-
props: item.props,
|
|
3500
|
-
constraints: item.uniqueConstraints
|
|
3501
|
-
}))
|
|
3502
|
-
);
|
|
3503
|
-
const byKind = /* @__PURE__ */ new Map();
|
|
3504
|
-
for (const item of items) {
|
|
3505
|
-
const group = byKind.get(item.kind) ?? { schema: item.schema, rows: [] };
|
|
3506
|
-
group.rows.push({ nodeId: item.id, props: item.props });
|
|
3507
|
-
byKind.set(item.kind, group);
|
|
3508
|
-
}
|
|
3509
|
-
await Promise.all(
|
|
3510
|
-
[...byKind.entries()].flatMap(([kind, group]) => {
|
|
3511
|
-
const syncArguments = { graphId: ctx.graphId, nodeKind: kind, backend };
|
|
3512
|
-
return [
|
|
3513
|
-
syncEmbeddingsBatchForKind(syncArguments, group.schema, group.rows),
|
|
3514
|
-
syncFulltextBatchForKind(syncArguments, group.schema, group.rows)
|
|
3515
|
-
];
|
|
3516
|
-
})
|
|
3517
|
-
);
|
|
3518
|
-
}
|
|
3519
|
-
function parseRowProps(row) {
|
|
3520
|
-
return rowPropsToObject(row.props);
|
|
3521
|
-
}
|
|
3522
|
-
async function applyNodeUpdate(ctx, args, backend) {
|
|
3523
|
-
const { kind, id } = args.existing;
|
|
3524
|
-
if (args.existing.deleted_at === void 0) {
|
|
3525
|
-
await updateUniquenessEntries(
|
|
3526
|
-
uniquenessContext(ctx, backend),
|
|
3527
|
-
kind,
|
|
3528
|
-
id,
|
|
3529
|
-
parseRowProps(args.existing),
|
|
3530
|
-
args.validatedProps,
|
|
3531
|
-
args.uniqueConstraints
|
|
3532
|
-
);
|
|
3533
|
-
} else {
|
|
3534
|
-
await checkUniquenessConstraints(
|
|
3535
|
-
uniquenessContext(ctx, backend),
|
|
3536
|
-
kind,
|
|
3537
|
-
id,
|
|
3538
|
-
args.validatedProps,
|
|
3539
|
-
args.uniqueConstraints
|
|
3540
|
-
);
|
|
3541
|
-
await insertUniquenessEntries(
|
|
3542
|
-
uniquenessContext(ctx, backend),
|
|
3543
|
-
kind,
|
|
3544
|
-
id,
|
|
3545
|
-
args.validatedProps,
|
|
3546
|
-
args.uniqueConstraints
|
|
3547
|
-
);
|
|
3548
|
-
}
|
|
3549
|
-
const updateParams = {
|
|
3550
|
-
graphId: ctx.graphId,
|
|
3551
|
-
kind,
|
|
3552
|
-
id,
|
|
3553
|
-
props: args.validatedProps,
|
|
3554
|
-
incrementVersion: true
|
|
3555
|
-
};
|
|
3556
|
-
if (args.validTo !== void 0) updateParams.validTo = args.validTo;
|
|
3557
|
-
if (args.clearDeleted) updateParams.clearDeleted = true;
|
|
3558
|
-
const row = await backend.updateNode(updateParams);
|
|
3559
|
-
await Promise.all([
|
|
3560
|
-
syncEmbeddings(
|
|
3561
|
-
nodeSyncContext(ctx, kind, id, backend),
|
|
3562
|
-
args.schema,
|
|
3563
|
-
args.validatedProps
|
|
3564
|
-
),
|
|
3565
|
-
syncFulltext(
|
|
3566
|
-
nodeSyncContext(ctx, kind, id, backend),
|
|
3567
|
-
args.schema,
|
|
3568
|
-
args.validatedProps
|
|
3569
|
-
)
|
|
3570
|
-
]);
|
|
3571
|
-
return row;
|
|
3572
|
-
}
|
|
3573
|
-
async function applyNodeSoftDelete(ctx, args, backend, policy) {
|
|
3574
|
-
const { kind, id } = args.existing;
|
|
3575
|
-
await enforceNodeDeleteBehavior(
|
|
3576
|
-
ctx,
|
|
3577
|
-
{ kind, id, mode: "soft", onDelete: args.onDelete },
|
|
3578
|
-
backend,
|
|
3579
|
-
policy
|
|
3580
|
-
);
|
|
3581
|
-
await backend.deleteNode({
|
|
3582
|
-
graphId: ctx.graphId,
|
|
3583
|
-
kind,
|
|
3584
|
-
id
|
|
3585
|
-
});
|
|
3586
|
-
await deleteUniquenessEntries(
|
|
3587
|
-
uniquenessContext(ctx, backend),
|
|
3588
|
-
kind,
|
|
3589
|
-
parseRowProps(args.existing),
|
|
3590
|
-
args.uniqueConstraints
|
|
3591
|
-
);
|
|
3592
|
-
await deleteNodeEmbeddings(
|
|
3593
|
-
nodeSyncContext(ctx, kind, id, backend),
|
|
3594
|
-
args.schema
|
|
3595
|
-
);
|
|
3596
|
-
await deleteNodeFulltext(
|
|
3597
|
-
nodeSyncContext(ctx, kind, id, backend),
|
|
3598
|
-
args.schema
|
|
3599
|
-
);
|
|
3600
|
-
}
|
|
3601
|
-
async function applyNodeHardDelete(ctx, args, backend) {
|
|
3602
|
-
await enforceNodeDeleteBehavior(
|
|
3603
|
-
ctx,
|
|
3604
|
-
{ kind: args.kind, id: args.id, mode: "hard", onDelete: args.onDelete },
|
|
3605
|
-
backend
|
|
3606
|
-
);
|
|
3607
|
-
await backend.hardDeleteNode({
|
|
3608
|
-
graphId: ctx.graphId,
|
|
3609
|
-
kind: args.kind,
|
|
3610
|
-
id: args.id
|
|
3611
|
-
});
|
|
3612
|
-
await deleteNodeEmbeddings(
|
|
3613
|
-
nodeSyncContext(ctx, args.kind, args.id, backend),
|
|
3614
|
-
args.schema
|
|
3615
|
-
);
|
|
3616
|
-
}
|
|
3617
|
-
async function applyNodeResurrect(ctx, args, backend) {
|
|
3618
|
-
const { kind, id } = args.existing;
|
|
3619
|
-
const props = parseRowProps(args.existing);
|
|
3620
|
-
await checkUniquenessConstraints(
|
|
3621
|
-
uniquenessContext(ctx, backend),
|
|
3622
|
-
kind,
|
|
3623
|
-
id,
|
|
3624
|
-
props,
|
|
3625
|
-
args.uniqueConstraints
|
|
3626
|
-
);
|
|
3627
|
-
await insertUniquenessEntries(
|
|
3628
|
-
uniquenessContext(ctx, backend),
|
|
3629
|
-
kind,
|
|
3630
|
-
id,
|
|
3631
|
-
props,
|
|
3632
|
-
args.uniqueConstraints
|
|
3633
|
-
);
|
|
3634
|
-
const row = await backend.updateNode({
|
|
3635
|
-
graphId: ctx.graphId,
|
|
3636
|
-
kind,
|
|
3637
|
-
id,
|
|
3638
|
-
props,
|
|
3639
|
-
incrementVersion: true,
|
|
3640
|
-
clearDeleted: true
|
|
3641
|
-
});
|
|
3642
|
-
await Promise.all([
|
|
3643
|
-
syncEmbeddings(nodeSyncContext(ctx, kind, id, backend), args.schema, props),
|
|
3644
|
-
syncFulltext(nodeSyncContext(ctx, kind, id, backend), args.schema, props)
|
|
3645
|
-
]);
|
|
3646
|
-
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;
|
|
3647
3213
|
}
|
|
3648
3214
|
|
|
3649
|
-
export {
|
|
3650
|
-
//# sourceMappingURL=chunk-
|
|
3651
|
-
//# 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-NQ6BRJBE.js.map
|
|
3217
|
+
//# sourceMappingURL=chunk-NQ6BRJBE.js.map
|