@nicia-ai/typegraph 0.45.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 -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-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-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-UCQ3BFSY.cjs → chunk-7GT72YHH.cjs} +682 -332
- package/dist/chunk-7GT72YHH.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-ID4WXTKL.js → chunk-7Z5OR7KO.js} +2360 -605
- 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-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-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-FL5UQRES.js → chunk-DCQVHAYQ.js} +5 -5
- package/dist/{chunk-FL5UQRES.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-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-JIVMTW7W.js +3393 -0
- package/dist/chunk-JIVMTW7W.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-D54WH24V.cjs → chunk-LBJKZXDE.cjs} +115 -13
- package/dist/chunk-LBJKZXDE.cjs.map +1 -0
- package/dist/{chunk-4MEWSUVM.cjs → chunk-M4BDU5RX.cjs} +12 -12
- package/dist/chunk-M4BDU5RX.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-ZI6VQSZA.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-BNS75YNF.cjs → chunk-NK5Q7UNE.cjs} +10 -20
- package/dist/chunk-NK5Q7UNE.cjs.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-TKORQCG4.js → chunk-NQ6BRJBE.js} +386 -862
- 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-NAAMUYMS.cjs → chunk-PNN7RHVR.cjs} +58 -48
- 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-FQ7ZPOTZ.js → chunk-QLRESYPU.js} +637 -493
- package/dist/chunk-QLRESYPU.js.map +1 -0
- package/dist/{chunk-Q6EDCUXV.js → chunk-QWX5YA3K.js} +554 -204
- package/dist/chunk-QWX5YA3K.js.map +1 -0
- package/dist/{chunk-5EKPX6QU.js → chunk-RJS7DECT.js} +8 -9
- package/dist/chunk-RJS7DECT.js.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-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-TTAITEPJ.cjs +755 -0
- package/dist/chunk-TTAITEPJ.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-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-WEVQJ5LH.js +736 -0
- package/dist/chunk-WEVQJ5LH.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-YOALGKRE.cjs → chunk-XDF2UPEQ.cjs} +3521 -1766
- package/dist/chunk-XDF2UPEQ.cjs.map +1 -0
- package/dist/{chunk-J7LXTUTP.cjs → chunk-XMQSEJCF.cjs} +604 -1094
- 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-KMXWZLQX.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-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-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-66p92IPi.d.ts → store-DawaWWjJ.d.ts} +1280 -767
- package/dist/{store-view-A85FFRnk.d.cts → store-RwTJx8LX.d.cts} +1280 -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 +1 -1
- 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,26 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
3
|
+
var chunkTTAITEPJ_cjs = require('./chunk-TTAITEPJ.cjs');
|
|
4
|
+
var chunkXNLIZYRZ_cjs = require('./chunk-XNLIZYRZ.cjs');
|
|
5
|
+
var chunkXMQSEJCF_cjs = require('./chunk-XMQSEJCF.cjs');
|
|
6
|
+
var chunkPWLJ77UV_cjs = require('./chunk-PWLJ77UV.cjs');
|
|
7
|
+
var chunkNFCVHQ5P_cjs = require('./chunk-NFCVHQ5P.cjs');
|
|
8
|
+
var chunkXBYVV3MP_cjs = require('./chunk-XBYVV3MP.cjs');
|
|
9
|
+
var chunkE4WNQBEF_cjs = require('./chunk-E4WNQBEF.cjs');
|
|
10
|
+
var chunkQ7Q4WSLJ_cjs = require('./chunk-Q7Q4WSLJ.cjs');
|
|
11
|
+
var chunk4UGOKMI5_cjs = require('./chunk-4UGOKMI5.cjs');
|
|
12
|
+
var chunkVCRRKBLN_cjs = require('./chunk-VCRRKBLN.cjs');
|
|
12
13
|
var chunkHAHNRASW_cjs = require('./chunk-HAHNRASW.cjs');
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
14
|
+
var chunkLBJKZXDE_cjs = require('./chunk-LBJKZXDE.cjs');
|
|
15
|
+
var chunkNI72YOJB_cjs = require('./chunk-NI72YOJB.cjs');
|
|
16
|
+
var chunkA7J2YDDI_cjs = require('./chunk-A7J2YDDI.cjs');
|
|
17
|
+
var chunkN66HCGCY_cjs = require('./chunk-N66HCGCY.cjs');
|
|
16
18
|
|
|
17
19
|
// src/store/row-mappers.ts
|
|
18
20
|
function nullToUndefined(value) {
|
|
19
21
|
return value === null ? void 0 : value;
|
|
20
22
|
}
|
|
21
23
|
function rowToNode(row) {
|
|
22
|
-
const rawProps =
|
|
23
|
-
const props =
|
|
24
|
+
const rawProps = chunkXBYVV3MP_cjs.rowPropsToObject(row.props);
|
|
25
|
+
const props = chunkLBJKZXDE_cjs.filterReservedKeys(rawProps, chunkLBJKZXDE_cjs.RESERVED_NODE_KEYS);
|
|
24
26
|
return {
|
|
25
27
|
kind: row.kind,
|
|
26
28
|
id: row.id,
|
|
@@ -39,8 +41,8 @@ function rowToNodeMeta(row) {
|
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
43
|
function rowToEdge(row) {
|
|
42
|
-
const rawProps =
|
|
43
|
-
const props =
|
|
44
|
+
const rawProps = chunkXBYVV3MP_cjs.rowPropsToObject(row.props);
|
|
45
|
+
const props = chunkLBJKZXDE_cjs.filterReservedKeys(rawProps, chunkLBJKZXDE_cjs.RESERVED_EDGE_KEYS);
|
|
44
46
|
return {
|
|
45
47
|
id: row.id,
|
|
46
48
|
kind: row.kind,
|
|
@@ -62,65 +64,25 @@ function rowToEdgeMeta(row) {
|
|
|
62
64
|
};
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
// src/store/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (expectedVersion === void 0) return;
|
|
69
|
-
if ("transaction" in backend && !backend.capabilities.transactions) {
|
|
70
|
-
throw new chunkC4F7VJ5D_cjs.ConfigurationError(
|
|
71
|
-
"Schema-managed Store writes require a transactional backend so schema changes and entity writes can share one fence.",
|
|
72
|
-
{
|
|
73
|
-
code: "SCHEMA_WRITE_FENCE_UNSUPPORTED",
|
|
74
|
-
graphId: ctx.graphId
|
|
75
|
-
}
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
const lockSchemaVersionForWrite = backend.lockSchemaVersionForWrite;
|
|
79
|
-
if (lockSchemaVersionForWrite === void 0) {
|
|
80
|
-
throw new chunkC4F7VJ5D_cjs.ConfigurationError(
|
|
81
|
-
"This backend cannot fence schema-managed Store writes against a concurrent schema change.",
|
|
82
|
-
{
|
|
83
|
-
code: "SCHEMA_WRITE_FENCE_UNSUPPORTED",
|
|
84
|
-
graphId: ctx.graphId
|
|
85
|
-
}
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
await lockSchemaVersionForWrite({
|
|
89
|
-
graphId: ctx.graphId,
|
|
90
|
-
expectedVersion
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
function runInWriteTransaction(ctx, backend, fn, options) {
|
|
94
|
-
const ownsWriteLock = "transaction" in backend && backend.capabilities.transactions;
|
|
95
|
-
return chunkEKFUG4G7_cjs.runOptionallyInTransaction(backend, async (target) => {
|
|
96
|
-
await lockSchemaVersionForStoreWrite(ctx, target);
|
|
97
|
-
const lock = ctx.historyEnabled || ctx.revisionTrackingEnabled ? await chunkJ7LXTUTP_cjs.lockRecordedGraphWrite(target, ctx.graphId) : chunkJ7LXTUTP_cjs.uncapturedGraphWriteLock();
|
|
98
|
-
const result = await fn(target, lock);
|
|
99
|
-
if (ctx.revisionTrackingEnabled && !ctx.historyEnabled && (options?.didWrite?.(result) ?? true)) {
|
|
100
|
-
await chunkJ7LXTUTP_cjs.advanceRevisionClock(
|
|
101
|
-
target,
|
|
102
|
-
ctx.revisionSchema,
|
|
103
|
-
ctx.graphId,
|
|
104
|
-
ownsWriteLock
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
return result;
|
|
108
|
-
});
|
|
67
|
+
// src/store/constraints.ts
|
|
68
|
+
function edgeWriteNeedsConstraintFence(cardinality) {
|
|
69
|
+
return cardinality === "many" ? void 0 : "edgeCardinality";
|
|
109
70
|
}
|
|
110
|
-
function
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
71
|
+
function nodeWriteNeedsConstraintFence(registry, kind, uniqueConstraints, operation) {
|
|
72
|
+
if (operation === "create" && registry.getDisjointKinds(kind).length > 0) {
|
|
73
|
+
return "nodeDisjointness";
|
|
74
|
+
}
|
|
75
|
+
const sharedScope = uniqueConstraints.some(
|
|
76
|
+
(constraint) => chunkE4WNQBEF_cjs.getKindsForUniquenessCheck(kind, constraint.scope, registry).length > 1
|
|
114
77
|
);
|
|
78
|
+
return sharedScope ? "nodeUniquenessScope" : void 0;
|
|
115
79
|
}
|
|
116
|
-
|
|
117
|
-
// src/store/constraints.ts
|
|
118
80
|
async function checkDisjointnessConstraint(ctx, kind, id) {
|
|
119
81
|
const disjointKinds = ctx.registry.getDisjointKinds(kind);
|
|
120
82
|
for (const disjointKind of disjointKinds) {
|
|
121
83
|
const existing = await ctx.backend.getNode(ctx.graphId, disjointKind, id);
|
|
122
84
|
if (existing && !existing.deleted_at) {
|
|
123
|
-
const error =
|
|
85
|
+
const error = chunkE4WNQBEF_cjs.checkDisjointness(id, kind, [disjointKind], ctx.registry);
|
|
124
86
|
if (error) throw error;
|
|
125
87
|
}
|
|
126
88
|
}
|
|
@@ -137,7 +99,7 @@ async function checkCardinalityConstraint(ctx, edgeKind, cardinality, fromKind,
|
|
|
137
99
|
fromKind,
|
|
138
100
|
fromId
|
|
139
101
|
});
|
|
140
|
-
const error =
|
|
102
|
+
const error = chunkE4WNQBEF_cjs.checkCardinality(
|
|
141
103
|
edgeKind,
|
|
142
104
|
fromKind,
|
|
143
105
|
fromId,
|
|
@@ -157,7 +119,7 @@ async function checkCardinalityConstraint(ctx, edgeKind, cardinality, fromKind,
|
|
|
157
119
|
toKind,
|
|
158
120
|
toId
|
|
159
121
|
});
|
|
160
|
-
const error =
|
|
122
|
+
const error = chunkE4WNQBEF_cjs.checkUniqueEdge(
|
|
161
123
|
edgeKind,
|
|
162
124
|
fromKind,
|
|
163
125
|
fromId,
|
|
@@ -179,7 +141,7 @@ async function checkCardinalityConstraint(ctx, edgeKind, cardinality, fromKind,
|
|
|
179
141
|
fromId,
|
|
180
142
|
activeOnly: true
|
|
181
143
|
});
|
|
182
|
-
const error =
|
|
144
|
+
const error = chunkE4WNQBEF_cjs.checkCardinality(
|
|
183
145
|
edgeKind,
|
|
184
146
|
fromKind,
|
|
185
147
|
fromId,
|
|
@@ -193,31 +155,98 @@ async function checkCardinalityConstraint(ctx, edgeKind, cardinality, fromKind,
|
|
|
193
155
|
}
|
|
194
156
|
}
|
|
195
157
|
|
|
158
|
+
// src/store/operations/already-exists.ts
|
|
159
|
+
var ENTITY_LABELS = {
|
|
160
|
+
node: { title: "Node", article: "A node" },
|
|
161
|
+
edge: { title: "Edge", article: "An edge" }
|
|
162
|
+
};
|
|
163
|
+
function alreadyExistsError(entity, kind, id, detail, cause) {
|
|
164
|
+
const label = ENTITY_LABELS[entity];
|
|
165
|
+
return new chunkNI72YOJB_cjs.ValidationError(
|
|
166
|
+
`${label.title} already exists: ${detail}`,
|
|
167
|
+
{
|
|
168
|
+
entityType: entity,
|
|
169
|
+
kind,
|
|
170
|
+
operation: "create",
|
|
171
|
+
...id === void 0 ? {} : { id },
|
|
172
|
+
issues: [
|
|
173
|
+
{
|
|
174
|
+
path: "id",
|
|
175
|
+
code: chunkNI72YOJB_cjs.ENTITY_ALREADY_EXISTS_CODE,
|
|
176
|
+
message: `${label.article} with this ID already exists`
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
suggestion: `Use a different ID or update the existing ${entity}.`,
|
|
182
|
+
...cause === void 0 ? {} : { cause }
|
|
183
|
+
}
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
function createAlreadyExistsError(entity, kind, id) {
|
|
187
|
+
return alreadyExistsError(entity, kind, id, `${kind}/${id}`, void 0);
|
|
188
|
+
}
|
|
189
|
+
function isDuplicateKeyInsertError(error, entity) {
|
|
190
|
+
return error instanceof chunkNI72YOJB_cjs.DatabaseOperationError && error.details.operation === "insert" && error.details.entity === entity && error.details.reason === "duplicate_key";
|
|
191
|
+
}
|
|
192
|
+
function rethrowAsAlreadyExists(error, entity) {
|
|
193
|
+
if (!isDuplicateKeyInsertError(error, entity)) throw error;
|
|
194
|
+
const attempted = error.details.attempted ?? [];
|
|
195
|
+
const first = attempted[0];
|
|
196
|
+
if (first === void 0) throw error;
|
|
197
|
+
if (attempted.length === 1) {
|
|
198
|
+
throw alreadyExistsError(
|
|
199
|
+
entity,
|
|
200
|
+
first.kind,
|
|
201
|
+
first.id,
|
|
202
|
+
`${first.kind}/${first.id}`,
|
|
203
|
+
error
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
throw alreadyExistsError(
|
|
207
|
+
entity,
|
|
208
|
+
first.kind,
|
|
209
|
+
void 0,
|
|
210
|
+
`one of the ${attempted.length} ${first.kind} ids in the refused insert`,
|
|
211
|
+
error
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
async function withAlreadyExistsTranslation(entity, run) {
|
|
215
|
+
try {
|
|
216
|
+
return await run();
|
|
217
|
+
} catch (error) {
|
|
218
|
+
rethrowAsAlreadyExists(error, entity);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
196
222
|
// src/store/operations/node-operations.ts
|
|
197
223
|
function getNodeRegistration(graph, kind) {
|
|
224
|
+
if (!chunkN66HCGCY_cjs.hasOwnKey(graph.nodes, kind)) throw new chunkNI72YOJB_cjs.KindNotFoundError(kind, "node");
|
|
198
225
|
const registration = graph.nodes[kind];
|
|
199
|
-
if (registration === void 0) throw new
|
|
226
|
+
if (registration === void 0) throw new chunkNI72YOJB_cjs.KindNotFoundError(kind, "node");
|
|
200
227
|
return registration;
|
|
201
228
|
}
|
|
202
|
-
|
|
229
|
+
function nodeFencesConstraintProbe(ctx, kind, operation) {
|
|
230
|
+
if (!chunkN66HCGCY_cjs.hasOwnKey(ctx.graph.nodes, kind)) return void 0;
|
|
231
|
+
return nodeWriteNeedsConstraintFence(
|
|
232
|
+
ctx.registry,
|
|
233
|
+
kind,
|
|
234
|
+
getNodeRegistration(ctx.graph, kind).unique ?? [],
|
|
235
|
+
operation
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
function nodeBatchFencesConstraintProbe(ctx, inputs, operation) {
|
|
239
|
+
for (const input of inputs) {
|
|
240
|
+
const reason = nodeFencesConstraintProbe(ctx, input.kind, operation);
|
|
241
|
+
if (reason !== void 0) return reason;
|
|
242
|
+
}
|
|
243
|
+
return void 0;
|
|
244
|
+
}
|
|
203
245
|
function buildNodeCacheKey(graphId, kind, id) {
|
|
204
|
-
return
|
|
246
|
+
return chunkXNLIZYRZ_cjs.encodeTupleKey([graphId, kind, id]);
|
|
205
247
|
}
|
|
206
248
|
function buildUniqueCacheKey(graphId, nodeKind, constraintName, key) {
|
|
207
|
-
return
|
|
208
|
-
}
|
|
209
|
-
function createNodeAlreadyExistsError(kind, id) {
|
|
210
|
-
return new chunkC4F7VJ5D_cjs.ValidationError(
|
|
211
|
-
`Node already exists: ${kind}/${id}`,
|
|
212
|
-
{
|
|
213
|
-
entityType: "node",
|
|
214
|
-
kind,
|
|
215
|
-
operation: "create",
|
|
216
|
-
id,
|
|
217
|
-
issues: [{ path: "id", message: "A node with this ID already exists" }]
|
|
218
|
-
},
|
|
219
|
-
{ suggestion: `Use a different ID or update the existing node.` }
|
|
220
|
-
);
|
|
249
|
+
return chunkXNLIZYRZ_cjs.encodeTupleKey([graphId, nodeKind, constraintName, key]);
|
|
221
250
|
}
|
|
222
251
|
function buildInsertNodeParams(graphId, kind, id, props, validFrom, validTo) {
|
|
223
252
|
const insertParams = {
|
|
@@ -248,7 +277,7 @@ function resolveConstraint(graph, kind, constraintName) {
|
|
|
248
277
|
(candidate) => candidate.name === constraintName
|
|
249
278
|
);
|
|
250
279
|
if (constraint === void 0) {
|
|
251
|
-
throw new
|
|
280
|
+
throw new chunkNI72YOJB_cjs.NodeConstraintNotFoundError(constraintName, kind);
|
|
252
281
|
}
|
|
253
282
|
return constraint;
|
|
254
283
|
}
|
|
@@ -309,8 +338,8 @@ function createNodeBatchValidationBackend(graphId, registry, backend) {
|
|
|
309
338
|
}
|
|
310
339
|
function registerPendingUniqueEntries(kind, id, props, constraints) {
|
|
311
340
|
for (const constraint of constraints) {
|
|
312
|
-
if (!
|
|
313
|
-
const key =
|
|
341
|
+
if (!chunkE4WNQBEF_cjs.checkWherePredicate(constraint, props)) continue;
|
|
342
|
+
const key = chunkE4WNQBEF_cjs.computeUniqueKey(
|
|
314
343
|
props,
|
|
315
344
|
constraint.fields,
|
|
316
345
|
constraint.collation
|
|
@@ -323,7 +352,7 @@ function createNodeBatchValidationBackend(graphId, registry, backend) {
|
|
|
323
352
|
);
|
|
324
353
|
pendingUniqueOwners.set(concreteEntryKey, id);
|
|
325
354
|
if (constraint.scope !== "kind") {
|
|
326
|
-
const kindsToCheck =
|
|
355
|
+
const kindsToCheck = chunkE4WNQBEF_cjs.getKindsForUniquenessCheck(
|
|
327
356
|
kind,
|
|
328
357
|
constraint.scope,
|
|
329
358
|
registry
|
|
@@ -342,12 +371,12 @@ function createNodeBatchValidationBackend(graphId, registry, backend) {
|
|
|
342
371
|
}
|
|
343
372
|
function registerAppliedNodeUpdate(kind, id, oldProps, newProps, constraints) {
|
|
344
373
|
for (const constraint of constraints) {
|
|
345
|
-
const oldApplies =
|
|
346
|
-
const newApplies =
|
|
347
|
-
const oldKey = oldApplies ?
|
|
348
|
-
const newKey = newApplies ?
|
|
374
|
+
const oldApplies = chunkE4WNQBEF_cjs.checkWherePredicate(constraint, oldProps);
|
|
375
|
+
const newApplies = chunkE4WNQBEF_cjs.checkWherePredicate(constraint, newProps);
|
|
376
|
+
const oldKey = oldApplies ? chunkE4WNQBEF_cjs.computeUniqueKey(oldProps, constraint.fields, constraint.collation) : void 0;
|
|
377
|
+
const newKey = newApplies ? chunkE4WNQBEF_cjs.computeUniqueKey(newProps, constraint.fields, constraint.collation) : void 0;
|
|
349
378
|
if (oldKey === newKey) continue;
|
|
350
|
-
const kindsToCheck =
|
|
379
|
+
const kindsToCheck = chunkE4WNQBEF_cjs.getKindsForUniquenessCheck(
|
|
351
380
|
kind,
|
|
352
381
|
constraint.scope,
|
|
353
382
|
registry
|
|
@@ -387,7 +416,7 @@ function createNodeBatchValidationBackend(graphId, registry, backend) {
|
|
|
387
416
|
if (uniqueCache.has(cacheKey)) return;
|
|
388
417
|
uniqueCache.set(cacheKey, row);
|
|
389
418
|
}
|
|
390
|
-
const validationBackend =
|
|
419
|
+
const validationBackend = chunkXBYVV3MP_cjs.createBackendOverlay(backend, {
|
|
391
420
|
getNode: getNodeCached,
|
|
392
421
|
checkUnique: checkUniqueCached
|
|
393
422
|
});
|
|
@@ -404,25 +433,32 @@ function draftNodeCreate(ctx, input, id, options) {
|
|
|
404
433
|
const kind = input.kind;
|
|
405
434
|
const registration = getNodeRegistration(ctx.graph, kind);
|
|
406
435
|
const nodeKind = registration.type;
|
|
407
|
-
const validatedProps = options?.propsPreValidated === true ? input.props :
|
|
436
|
+
const validatedProps = options?.propsPreValidated === true ? input.props : chunkXNLIZYRZ_cjs.validateNodeProps(nodeKind.schema, input.props, {
|
|
408
437
|
kind,
|
|
409
438
|
operation: "create"
|
|
410
439
|
});
|
|
440
|
+
const validFrom = chunkQ7Q4WSLJ_cjs.validateOptionalCanonicalIsoDate(
|
|
441
|
+
input.validFrom,
|
|
442
|
+
"validFrom"
|
|
443
|
+
);
|
|
444
|
+
const validTo = chunkQ7Q4WSLJ_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo");
|
|
445
|
+
chunkQ7Q4WSLJ_cjs.assertOrderedValidityWindow(`${kind} "${id}"`, validFrom, validTo);
|
|
411
446
|
return {
|
|
412
447
|
kind,
|
|
413
448
|
id,
|
|
449
|
+
idProvided: input.id !== void 0,
|
|
414
450
|
nodeKind,
|
|
415
451
|
uniqueConstraints: registration.unique ?? [],
|
|
416
452
|
validatedProps,
|
|
417
|
-
validFrom
|
|
418
|
-
validTo
|
|
453
|
+
validFrom,
|
|
454
|
+
validTo
|
|
419
455
|
};
|
|
420
456
|
}
|
|
421
457
|
async function finishNodeCreatePreparation(ctx, draft, backend) {
|
|
422
458
|
const { kind, id, validatedProps, uniqueConstraints } = draft;
|
|
423
459
|
const existingNode = await backend.getNode(ctx.graphId, kind, id);
|
|
424
460
|
if (existingNode && !existingNode.deleted_at) {
|
|
425
|
-
throw
|
|
461
|
+
throw createAlreadyExistsError("node", kind, id);
|
|
426
462
|
}
|
|
427
463
|
const constraintContext = {
|
|
428
464
|
graphId: ctx.graphId,
|
|
@@ -430,8 +466,8 @@ async function finishNodeCreatePreparation(ctx, draft, backend) {
|
|
|
430
466
|
backend
|
|
431
467
|
};
|
|
432
468
|
await checkDisjointnessConstraint(constraintContext, kind, id);
|
|
433
|
-
await
|
|
434
|
-
|
|
469
|
+
await chunkTTAITEPJ_cjs.checkUniquenessConstraints(
|
|
470
|
+
chunkTTAITEPJ_cjs.createUniquenessContext(ctx.graphId, ctx.registry, backend),
|
|
435
471
|
kind,
|
|
436
472
|
id,
|
|
437
473
|
validatedProps,
|
|
@@ -440,6 +476,8 @@ async function finishNodeCreatePreparation(ctx, draft, backend) {
|
|
|
440
476
|
return {
|
|
441
477
|
kind,
|
|
442
478
|
id,
|
|
479
|
+
idProvided: draft.idProvided,
|
|
480
|
+
tombstone: existingNode,
|
|
443
481
|
nodeKind: draft.nodeKind,
|
|
444
482
|
validatedProps,
|
|
445
483
|
uniqueConstraints,
|
|
@@ -461,8 +499,8 @@ async function validateAndPrepareNodeCreate(ctx, input, id, backend, options) {
|
|
|
461
499
|
);
|
|
462
500
|
}
|
|
463
501
|
async function finalizeNodeCreateBatch(ctx, preparedCreates, backend, lock) {
|
|
464
|
-
await
|
|
465
|
-
|
|
502
|
+
await chunkTTAITEPJ_cjs.applyNodeInsertSideEffectsBatch(
|
|
503
|
+
chunkTTAITEPJ_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
|
|
466
504
|
preparedCreates.map((prepared) => ({
|
|
467
505
|
kind: prepared.kind,
|
|
468
506
|
id: prepared.id,
|
|
@@ -473,9 +511,12 @@ async function finalizeNodeCreateBatch(ctx, preparedCreates, backend, lock) {
|
|
|
473
511
|
backend
|
|
474
512
|
);
|
|
475
513
|
}
|
|
514
|
+
function foldReferences(preparedCreates) {
|
|
515
|
+
return preparedCreates.filter((prepared) => prepared.idProvided).map((prepared) => ({ kind: prepared.kind, id: prepared.id }));
|
|
516
|
+
}
|
|
476
517
|
async function finalizeNodeCreate(ctx, prepared, backend, lock) {
|
|
477
|
-
await
|
|
478
|
-
|
|
518
|
+
await chunkTTAITEPJ_cjs.applyNodeInsertSideEffects(
|
|
519
|
+
chunkTTAITEPJ_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
|
|
479
520
|
{
|
|
480
521
|
kind: prepared.kind,
|
|
481
522
|
id: prepared.id,
|
|
@@ -488,7 +529,7 @@ async function finalizeNodeCreate(ctx, prepared, backend, lock) {
|
|
|
488
529
|
}
|
|
489
530
|
function computeNodeUpdate(ctx, kind, id, existingProps, inputProps) {
|
|
490
531
|
const registration = getNodeRegistration(ctx.graph, kind);
|
|
491
|
-
const validatedProps =
|
|
532
|
+
const validatedProps = chunkXNLIZYRZ_cjs.validateNodeProps(
|
|
492
533
|
registration.type.schema,
|
|
493
534
|
{ ...existingProps, ...inputProps },
|
|
494
535
|
{ kind, operation: "update", id }
|
|
@@ -496,7 +537,7 @@ function computeNodeUpdate(ctx, kind, id, existingProps, inputProps) {
|
|
|
496
537
|
return { registration, validatedProps };
|
|
497
538
|
}
|
|
498
539
|
function resolveNodeUpdateProps(ctx, existing, inputProps) {
|
|
499
|
-
const existingProps =
|
|
540
|
+
const existingProps = chunkXBYVV3MP_cjs.rowPropsToObject(existing.props);
|
|
500
541
|
const { registration, validatedProps } = computeNodeUpdate(
|
|
501
542
|
ctx,
|
|
502
543
|
existing.kind,
|
|
@@ -516,43 +557,111 @@ function nodeUpsertDirtyCheck(ctx, kind, id, existingProps, inputProps) {
|
|
|
516
557
|
);
|
|
517
558
|
return {
|
|
518
559
|
validatedProps,
|
|
519
|
-
unchanged:
|
|
560
|
+
unchanged: chunkPWLJ77UV_cjs.canonicalEqual(validatedProps, existingProps)
|
|
520
561
|
};
|
|
521
562
|
}
|
|
522
563
|
async function performNodeUpdate(ctx, input, backend, lock, options) {
|
|
523
564
|
const { kind, id } = input;
|
|
524
565
|
const existing = await backend.getNode(ctx.graphId, kind, id);
|
|
525
|
-
if (!existing) throw new
|
|
566
|
+
if (!existing) throw new chunkNI72YOJB_cjs.NodeNotFoundError(kind, id);
|
|
526
567
|
const { registration, validatedProps } = resolveNodeUpdateProps(
|
|
527
568
|
ctx,
|
|
528
569
|
existing,
|
|
529
570
|
input.props
|
|
530
571
|
);
|
|
531
572
|
const nodeKind = registration.type;
|
|
532
|
-
const
|
|
533
|
-
|
|
573
|
+
const validFrom = chunkQ7Q4WSLJ_cjs.validateOptionalCanonicalIsoDate(
|
|
574
|
+
input.validFrom,
|
|
575
|
+
"validFrom"
|
|
576
|
+
);
|
|
577
|
+
const validTo = chunkQ7Q4WSLJ_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo");
|
|
578
|
+
const resurrectionInstant = options?.clearDeleted === true && existing.deleted_at !== void 0 ? chunkQ7Q4WSLJ_cjs.nowIso() : void 0;
|
|
579
|
+
const windowVerdict = chunkQ7Q4WSLJ_cjs.assertWritableValidityWindow(
|
|
580
|
+
`${kind} "${id}"`,
|
|
581
|
+
validFrom,
|
|
582
|
+
resurrectionInstant === void 0 ? {
|
|
583
|
+
effectiveValidFrom: existing.valid_from,
|
|
584
|
+
appliesStatedValidFrom: false,
|
|
585
|
+
effectiveBoundIsStored: true
|
|
586
|
+
} : {
|
|
587
|
+
effectiveValidFrom: resurrectionInstant,
|
|
588
|
+
appliesStatedValidFrom: true,
|
|
589
|
+
// The instant this write is about to stamp, not a bound the row holds.
|
|
590
|
+
effectiveBoundIsStored: false
|
|
591
|
+
},
|
|
592
|
+
validTo
|
|
593
|
+
);
|
|
594
|
+
const writeContext = chunkTTAITEPJ_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock);
|
|
595
|
+
const effectiveValidFrom = validFrom ?? resurrectionInstant;
|
|
534
596
|
const shared = {
|
|
535
597
|
schema: nodeKind.schema,
|
|
536
598
|
validatedProps,
|
|
537
599
|
uniqueConstraints: registration.unique ?? [],
|
|
538
|
-
...
|
|
600
|
+
...effectiveValidFrom !== void 0 && { validFrom: effectiveValidFrom },
|
|
601
|
+
...validTo !== void 0 && { validTo },
|
|
602
|
+
// The bound the verdict above READ, carried into the UPDATE's own `WHERE`
|
|
603
|
+
// so the row this writes is the row that was judged. The verdict hands over
|
|
604
|
+
// the predicate rather than a flag, so both conditions that decide it — did
|
|
605
|
+
// the verdict consult the effective bound, and WAS that bound the row's
|
|
606
|
+
// stored one — are answered where they are known. A plain
|
|
607
|
+
// `update({ props })` states no window, reads no bound, and stays unfenced:
|
|
608
|
+
// the same rule `UpdateEdgeParams`'s identity components follow, for the
|
|
609
|
+
// same reason. The resurrecting leg is judged against `resurrectionInstant`
|
|
610
|
+
// and so fences on `deleted_at IS NOT NULL` alone, converging through the
|
|
611
|
+
// recovery below.
|
|
612
|
+
...windowVerdict.storedLowerBoundFence
|
|
539
613
|
};
|
|
540
614
|
if (options?.clearDeleted) {
|
|
541
|
-
const row2 = await
|
|
615
|
+
const row2 = await chunkTTAITEPJ_cjs.applyNodeUpdate(
|
|
542
616
|
writeContext,
|
|
543
617
|
{ ...shared, existing, clearDeleted: true },
|
|
544
618
|
backend
|
|
545
619
|
);
|
|
546
620
|
return rowToNode(row2);
|
|
547
621
|
}
|
|
548
|
-
if (!
|
|
549
|
-
const row = await
|
|
622
|
+
if (!chunkXBYVV3MP_cjs.isLiveNodeRow(existing)) throw new chunkNI72YOJB_cjs.NodeNotFoundError(kind, id);
|
|
623
|
+
const row = await chunkTTAITEPJ_cjs.applyNodeUpdate(
|
|
550
624
|
writeContext,
|
|
551
625
|
{ ...shared, existing },
|
|
552
626
|
backend
|
|
553
627
|
);
|
|
554
628
|
return rowToNode(row);
|
|
555
629
|
}
|
|
630
|
+
var NODE_UPDATE_ATTEMPTS = 2;
|
|
631
|
+
async function performNodeUpdateWithResurrectionRecovery(ctx, input, target, lock, options) {
|
|
632
|
+
for (let attempt = 1; attempt <= NODE_UPDATE_ATTEMPTS; attempt += 1) {
|
|
633
|
+
try {
|
|
634
|
+
return await performNodeUpdate(
|
|
635
|
+
ctx,
|
|
636
|
+
input,
|
|
637
|
+
target,
|
|
638
|
+
lock,
|
|
639
|
+
attempt === 1 ? options : void 0
|
|
640
|
+
);
|
|
641
|
+
} catch (error) {
|
|
642
|
+
if (!isNodeUpdateNoRowError(error) || attempt === NODE_UPDATE_ATTEMPTS) {
|
|
643
|
+
throw nodeUpdateRaceError(input, error);
|
|
644
|
+
}
|
|
645
|
+
const current = await target.getNode(ctx.graphId, input.kind, input.id);
|
|
646
|
+
if (current === void 0 || current.deleted_at !== void 0) {
|
|
647
|
+
throw new chunkNI72YOJB_cjs.NodeNotFoundError(input.kind, input.id);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
throw new chunkNI72YOJB_cjs.NodeNotFoundError(input.kind, input.id);
|
|
652
|
+
}
|
|
653
|
+
function nodeUpdateRaceError(input, error) {
|
|
654
|
+
if (!isNodeUpdateNoRowError(error)) return error;
|
|
655
|
+
return new chunkNI72YOJB_cjs.DatabaseOperationError(
|
|
656
|
+
`Node update for ${input.kind} "${input.id}" could not be applied to a stable row after ${NODE_UPDATE_ATTEMPTS} attempts: the row was removed and recreated between each read and its write. A concurrent writer is replacing this node faster than it can be read; serialize the writers, or retry.`,
|
|
657
|
+
{
|
|
658
|
+
operation: "update",
|
|
659
|
+
entity: "node",
|
|
660
|
+
attempted: [{ kind: input.kind, id: input.id }]
|
|
661
|
+
},
|
|
662
|
+
{ cause: error }
|
|
663
|
+
);
|
|
664
|
+
}
|
|
556
665
|
async function primeBatchValidationCaches(ctx, drafts, backend, seams) {
|
|
557
666
|
if (backend.getNodes !== void 0) {
|
|
558
667
|
const idsByKind = /* @__PURE__ */ new Map();
|
|
@@ -574,19 +683,19 @@ async function primeBatchValidationCaches(ctx, drafts, backend, seams) {
|
|
|
574
683
|
const groups = /* @__PURE__ */ new Map();
|
|
575
684
|
for (const draft of drafts) {
|
|
576
685
|
for (const constraint of draft.uniqueConstraints) {
|
|
577
|
-
if (!
|
|
578
|
-
const key =
|
|
686
|
+
if (!chunkE4WNQBEF_cjs.checkWherePredicate(constraint, draft.validatedProps)) continue;
|
|
687
|
+
const key = chunkE4WNQBEF_cjs.computeUniqueKey(
|
|
579
688
|
draft.validatedProps,
|
|
580
689
|
constraint.fields,
|
|
581
690
|
constraint.collation
|
|
582
691
|
);
|
|
583
|
-
const kindsToCheck =
|
|
692
|
+
const kindsToCheck = chunkE4WNQBEF_cjs.getKindsForUniquenessCheck(
|
|
584
693
|
draft.kind,
|
|
585
694
|
constraint.scope,
|
|
586
695
|
ctx.registry
|
|
587
696
|
);
|
|
588
697
|
for (const kindToCheck of kindsToCheck) {
|
|
589
|
-
const groupKey = kindToCheck
|
|
698
|
+
const groupKey = chunkXNLIZYRZ_cjs.encodeTupleKey([kindToCheck, constraint.name]);
|
|
590
699
|
const group = groups.get(groupKey) ?? {
|
|
591
700
|
nodeKind: kindToCheck,
|
|
592
701
|
constraintName: constraint.name,
|
|
@@ -626,7 +735,7 @@ async function prepareBatchCreates(ctx, inputs, backend, options) {
|
|
|
626
735
|
seedUniqueRow
|
|
627
736
|
} = createNodeBatchValidationBackend(ctx.graphId, ctx.registry, backend);
|
|
628
737
|
const drafts = inputs.map(
|
|
629
|
-
(input) => draftNodeCreate(ctx, input, input.id ??
|
|
738
|
+
(input) => draftNodeCreate(ctx, input, input.id ?? chunkXMQSEJCF_cjs.generateId(), options)
|
|
630
739
|
);
|
|
631
740
|
await primeBatchValidationCaches(ctx, drafts, backend, {
|
|
632
741
|
seedNodeRow,
|
|
@@ -648,10 +757,60 @@ async function prepareBatchCreates(ctx, inputs, backend, options) {
|
|
|
648
757
|
prepared.uniqueConstraints
|
|
649
758
|
);
|
|
650
759
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
760
|
+
return preparedCreates;
|
|
761
|
+
}
|
|
762
|
+
function partitionCreates(preparedCreates) {
|
|
763
|
+
const inserts = [];
|
|
764
|
+
const resurrections = [];
|
|
765
|
+
for (const prepared of preparedCreates) {
|
|
766
|
+
if (prepared.tombstone === void 0) {
|
|
767
|
+
inserts.push(prepared);
|
|
768
|
+
} else {
|
|
769
|
+
resurrections.push(prepared);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
return { inserts, resurrections };
|
|
773
|
+
}
|
|
774
|
+
function isNodeUpdateNoRowError(error) {
|
|
775
|
+
return error instanceof chunkNI72YOJB_cjs.DatabaseOperationError && error.details.operation === "update" && error.details.entity === "node" && error.details.reason === "no_row_returned";
|
|
776
|
+
}
|
|
777
|
+
async function resurrectPreparedNode(ctx, target, lock, prepared) {
|
|
778
|
+
const current = await target.getNode(ctx.graphId, prepared.kind, prepared.id);
|
|
779
|
+
if (current === void 0) {
|
|
780
|
+
throw new chunkNI72YOJB_cjs.DatabaseOperationError(
|
|
781
|
+
`Node tombstone disappeared before resurrection: ${prepared.kind} ${prepared.id}`,
|
|
782
|
+
{ operation: "update", entity: "node" }
|
|
783
|
+
);
|
|
784
|
+
}
|
|
785
|
+
if (current.deleted_at === void 0) {
|
|
786
|
+
throw createAlreadyExistsError("node", prepared.kind, prepared.id);
|
|
787
|
+
}
|
|
788
|
+
try {
|
|
789
|
+
return await chunkTTAITEPJ_cjs.applyNodeUpdate(
|
|
790
|
+
chunkTTAITEPJ_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
|
|
791
|
+
{
|
|
792
|
+
existing: current,
|
|
793
|
+
clearDeleted: true,
|
|
794
|
+
schema: prepared.nodeKind.schema,
|
|
795
|
+
validatedProps: prepared.validatedProps,
|
|
796
|
+
uniqueConstraints: prepared.uniqueConstraints,
|
|
797
|
+
...prepared.insertParams.validFrom === void 0 ? {} : { validFrom: prepared.insertParams.validFrom },
|
|
798
|
+
...prepared.insertParams.validTo === void 0 ? {} : { validTo: prepared.insertParams.validTo }
|
|
799
|
+
},
|
|
800
|
+
target
|
|
801
|
+
);
|
|
802
|
+
} catch (error) {
|
|
803
|
+
if (!isNodeUpdateNoRowError(error)) throw error;
|
|
804
|
+
const afterFailure = await target.getNode(
|
|
805
|
+
ctx.graphId,
|
|
806
|
+
prepared.kind,
|
|
807
|
+
prepared.id
|
|
808
|
+
);
|
|
809
|
+
if (afterFailure !== void 0 && afterFailure.deleted_at === void 0) {
|
|
810
|
+
throw createAlreadyExistsError("node", prepared.kind, prepared.id);
|
|
811
|
+
}
|
|
812
|
+
throw error;
|
|
813
|
+
}
|
|
655
814
|
}
|
|
656
815
|
async function findUniqueRowAcrossKinds(backend, graphId, constraintName, key, kindsToCheck, includeDeleted) {
|
|
657
816
|
for (const kindToCheck of kindsToCheck) {
|
|
@@ -702,14 +861,16 @@ async function batchCheckUniqueAcrossKinds(backend, graphId, constraintName, uni
|
|
|
702
861
|
}
|
|
703
862
|
async function executeNodeCreateInternal(ctx, input, backend, options) {
|
|
704
863
|
const kind = input.kind;
|
|
705
|
-
const id = input.id ??
|
|
864
|
+
const id = input.id ?? chunkXMQSEJCF_cjs.generateId();
|
|
706
865
|
const opContext = ctx.createOperationContext("create", "node", kind, id);
|
|
707
866
|
const shouldReturnRow = options?.returnRow ?? true;
|
|
708
|
-
return runHookedWriteOperation(
|
|
867
|
+
return chunkXNLIZYRZ_cjs.runHookedWriteOperation(
|
|
709
868
|
ctx,
|
|
710
869
|
opContext,
|
|
711
870
|
backend,
|
|
712
871
|
async (target, lock) => {
|
|
872
|
+
const identity = ctx.identity;
|
|
873
|
+
if (identity !== void 0) await identity.lock(target);
|
|
713
874
|
const prepared = await validateAndPrepareNodeCreate(
|
|
714
875
|
ctx,
|
|
715
876
|
input,
|
|
@@ -717,18 +878,36 @@ async function executeNodeCreateInternal(ctx, input, backend, options) {
|
|
|
717
878
|
target,
|
|
718
879
|
options
|
|
719
880
|
);
|
|
720
|
-
|
|
721
|
-
if (
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
prepared
|
|
881
|
+
const existing = prepared.tombstone;
|
|
882
|
+
if (existing !== void 0) {
|
|
883
|
+
const resurrected = await resurrectPreparedNode(
|
|
884
|
+
ctx,
|
|
885
|
+
target,
|
|
886
|
+
lock,
|
|
887
|
+
prepared
|
|
727
888
|
);
|
|
889
|
+
if (identity !== void 0) {
|
|
890
|
+
await identity.foldCreated(target, foldReferences([prepared]));
|
|
891
|
+
}
|
|
892
|
+
return shouldReturnRow ? rowToNode(resurrected) : void 0;
|
|
728
893
|
}
|
|
894
|
+
const row = await withAlreadyExistsTranslation("node", async () => {
|
|
895
|
+
if (shouldReturnRow) return target.insertNode(prepared.insertParams);
|
|
896
|
+
await chunkXMQSEJCF_cjs.runInsertNoReturn(
|
|
897
|
+
chunkXMQSEJCF_cjs.nodeInsertDispatch(target),
|
|
898
|
+
prepared.insertParams
|
|
899
|
+
);
|
|
900
|
+
return;
|
|
901
|
+
});
|
|
729
902
|
await finalizeNodeCreate(ctx, prepared, target, lock);
|
|
903
|
+
if (identity !== void 0) {
|
|
904
|
+
await identity.foldCreated(target, foldReferences([prepared]));
|
|
905
|
+
}
|
|
730
906
|
if (row === void 0) return;
|
|
731
907
|
return rowToNode(row);
|
|
908
|
+
},
|
|
909
|
+
{
|
|
910
|
+
fencesConstraintProbe: nodeFencesConstraintProbe(ctx, kind, "create")
|
|
732
911
|
}
|
|
733
912
|
);
|
|
734
913
|
}
|
|
@@ -738,7 +917,7 @@ async function executeNodeCreate(ctx, input, backend, options) {
|
|
|
738
917
|
...options
|
|
739
918
|
});
|
|
740
919
|
if (!result) {
|
|
741
|
-
throw new
|
|
920
|
+
throw new chunkNI72YOJB_cjs.DatabaseOperationError(
|
|
742
921
|
"Node create failed: expected created node row",
|
|
743
922
|
{ operation: "insert", entity: "node" }
|
|
744
923
|
);
|
|
@@ -747,32 +926,92 @@ async function executeNodeCreate(ctx, input, backend, options) {
|
|
|
747
926
|
}
|
|
748
927
|
async function executeNodeCreateNoReturnBatch(ctx, inputs, backend) {
|
|
749
928
|
if (inputs.length === 0) return;
|
|
750
|
-
await runInWriteTransaction(
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
929
|
+
await chunkXNLIZYRZ_cjs.runInWriteTransaction(
|
|
930
|
+
ctx,
|
|
931
|
+
backend,
|
|
932
|
+
async (target, lock) => {
|
|
933
|
+
const identity = ctx.identity;
|
|
934
|
+
if (identity !== void 0) await identity.lock(target);
|
|
935
|
+
const preparedCreates = await prepareBatchCreates(ctx, inputs, target);
|
|
936
|
+
const partition = partitionCreates(preparedCreates);
|
|
937
|
+
await withAlreadyExistsTranslation(
|
|
938
|
+
"node",
|
|
939
|
+
() => chunkXMQSEJCF_cjs.runInsertBatch(
|
|
940
|
+
chunkXMQSEJCF_cjs.nodeInsertDispatch(target),
|
|
941
|
+
partition.inserts.map((prepared) => prepared.insertParams)
|
|
942
|
+
)
|
|
943
|
+
);
|
|
944
|
+
for (const prepared of partition.resurrections) {
|
|
945
|
+
await resurrectPreparedNode(ctx, target, lock, prepared);
|
|
946
|
+
}
|
|
947
|
+
await finalizeNodeCreateBatch(ctx, partition.inserts, target, lock);
|
|
948
|
+
if (identity !== void 0) {
|
|
949
|
+
await identity.foldCreated(target, foldReferences(preparedCreates));
|
|
950
|
+
}
|
|
951
|
+
},
|
|
952
|
+
{
|
|
953
|
+
fencesConstraintProbe: nodeBatchFencesConstraintProbe(
|
|
954
|
+
ctx,
|
|
955
|
+
inputs,
|
|
956
|
+
"create"
|
|
957
|
+
)
|
|
958
|
+
}
|
|
959
|
+
);
|
|
759
960
|
}
|
|
760
961
|
async function executeNodeCreateBatch(ctx, inputs, backend, options) {
|
|
761
962
|
if (inputs.length === 0) return [];
|
|
762
|
-
return runInWriteTransaction(
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
963
|
+
return chunkXNLIZYRZ_cjs.runInWriteTransaction(
|
|
964
|
+
ctx,
|
|
965
|
+
backend,
|
|
966
|
+
async (target, lock) => {
|
|
967
|
+
const identity = ctx.identity;
|
|
968
|
+
if (identity !== void 0) await identity.lock(target);
|
|
969
|
+
const preparedCreates = await prepareBatchCreates(
|
|
970
|
+
ctx,
|
|
971
|
+
inputs,
|
|
972
|
+
target,
|
|
973
|
+
options
|
|
974
|
+
);
|
|
975
|
+
const partition = partitionCreates(preparedCreates);
|
|
976
|
+
const inserted = await withAlreadyExistsTranslation(
|
|
977
|
+
"node",
|
|
978
|
+
() => chunkXMQSEJCF_cjs.runInsertBatchReturning(
|
|
979
|
+
chunkXMQSEJCF_cjs.nodeInsertDispatch(target),
|
|
980
|
+
partition.inserts.map((prepared) => prepared.insertParams)
|
|
981
|
+
)
|
|
982
|
+
);
|
|
983
|
+
const resurrected = [];
|
|
984
|
+
for (const prepared of partition.resurrections) {
|
|
985
|
+
resurrected.push(
|
|
986
|
+
await resurrectPreparedNode(ctx, target, lock, prepared)
|
|
987
|
+
);
|
|
988
|
+
}
|
|
989
|
+
await finalizeNodeCreateBatch(ctx, partition.inserts, target, lock);
|
|
990
|
+
const byReference = new Map(
|
|
991
|
+
[...inserted, ...resurrected].map((row) => [
|
|
992
|
+
chunkXNLIZYRZ_cjs.refKey({ kind: row.kind, id: row.id }),
|
|
993
|
+
row
|
|
994
|
+
])
|
|
995
|
+
);
|
|
996
|
+
const rows = preparedCreates.map(
|
|
997
|
+
(prepared) => chunkN66HCGCY_cjs.requireDefined(
|
|
998
|
+
byReference.get(chunkXNLIZYRZ_cjs.refKey({ kind: prepared.kind, id: prepared.id })),
|
|
999
|
+
`Missing written row for ${prepared.kind} ${prepared.id}`
|
|
1000
|
+
)
|
|
1001
|
+
);
|
|
1002
|
+
if (identity !== void 0) {
|
|
1003
|
+
await identity.foldCreated(target, foldReferences(preparedCreates));
|
|
1004
|
+
}
|
|
1005
|
+
return rows.map((row) => rowToNode(row));
|
|
1006
|
+
},
|
|
1007
|
+
{
|
|
1008
|
+
fencesConstraintProbe: nodeBatchFencesConstraintProbe(
|
|
1009
|
+
ctx,
|
|
1010
|
+
inputs,
|
|
1011
|
+
"create"
|
|
1012
|
+
)
|
|
1013
|
+
}
|
|
1014
|
+
);
|
|
776
1015
|
}
|
|
777
1016
|
async function executeNodeUpdate(ctx, input, backend, options) {
|
|
778
1017
|
const opContext = ctx.createOperationContext(
|
|
@@ -781,11 +1020,36 @@ async function executeNodeUpdate(ctx, input, backend, options) {
|
|
|
781
1020
|
input.kind,
|
|
782
1021
|
input.id
|
|
783
1022
|
);
|
|
784
|
-
return runHookedWriteOperation(
|
|
1023
|
+
return chunkXNLIZYRZ_cjs.runHookedWriteOperation(
|
|
785
1024
|
ctx,
|
|
786
1025
|
opContext,
|
|
787
1026
|
backend,
|
|
788
|
-
(target, lock) =>
|
|
1027
|
+
async (target, lock) => {
|
|
1028
|
+
const identity = ctx.identity;
|
|
1029
|
+
if (options?.clearDeleted && identity !== void 0) {
|
|
1030
|
+
await identity.lock(target);
|
|
1031
|
+
}
|
|
1032
|
+
const node = await performNodeUpdateWithResurrectionRecovery(
|
|
1033
|
+
ctx,
|
|
1034
|
+
input,
|
|
1035
|
+
target,
|
|
1036
|
+
lock,
|
|
1037
|
+
options
|
|
1038
|
+
);
|
|
1039
|
+
if (options?.clearDeleted && identity !== void 0) {
|
|
1040
|
+
await identity.foldCreated(target, [
|
|
1041
|
+
{ kind: input.kind, id: input.id }
|
|
1042
|
+
]);
|
|
1043
|
+
}
|
|
1044
|
+
return node;
|
|
1045
|
+
},
|
|
1046
|
+
{
|
|
1047
|
+
fencesConstraintProbe: nodeFencesConstraintProbe(
|
|
1048
|
+
ctx,
|
|
1049
|
+
input.kind,
|
|
1050
|
+
"update"
|
|
1051
|
+
)
|
|
1052
|
+
}
|
|
789
1053
|
);
|
|
790
1054
|
}
|
|
791
1055
|
async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candidateIdColumn, backend) {
|
|
@@ -793,19 +1057,19 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
|
|
|
793
1057
|
const schema = registration.type.schema;
|
|
794
1058
|
const uniqueConstraints = registration.unique ?? [];
|
|
795
1059
|
if (!backend.capabilities.transactions) {
|
|
796
|
-
throw new
|
|
1060
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
797
1061
|
"updateWhere() requires a transactional backend so validation and sidecars are atomic",
|
|
798
1062
|
{ code: "SET_UPDATE_TRANSACTIONS_REQUIRED", kind }
|
|
799
1063
|
);
|
|
800
1064
|
}
|
|
801
1065
|
if (backend.updateNodeSet === void 0) {
|
|
802
|
-
throw new
|
|
1066
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
803
1067
|
"This backend does not support set-based node updates",
|
|
804
1068
|
{ code: "SET_UPDATE_UNSUPPORTED", kind }
|
|
805
1069
|
);
|
|
806
1070
|
}
|
|
807
1071
|
if (Object.keys(inputPatch).length === 0) {
|
|
808
|
-
throw new
|
|
1072
|
+
throw new chunkNI72YOJB_cjs.ValidationError("updateWhere() patch must not be empty", {
|
|
809
1073
|
entityType: "node",
|
|
810
1074
|
kind,
|
|
811
1075
|
operation: "update",
|
|
@@ -816,7 +1080,7 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
|
|
|
816
1080
|
(property) => !Object.hasOwn(schema.shape, property)
|
|
817
1081
|
);
|
|
818
1082
|
if (unknownProperty !== void 0) {
|
|
819
|
-
throw new
|
|
1083
|
+
throw new chunkNI72YOJB_cjs.ValidationError(
|
|
820
1084
|
`Unknown ${kind} property in updateWhere() patch: ${unknownProperty}`,
|
|
821
1085
|
{
|
|
822
1086
|
entityType: "node",
|
|
@@ -831,22 +1095,22 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
|
|
|
831
1095
|
}
|
|
832
1096
|
);
|
|
833
1097
|
}
|
|
834
|
-
const parsedPatch =
|
|
1098
|
+
const parsedPatch = chunkXNLIZYRZ_cjs.validateNodeProps(schema.partial(), inputPatch, {
|
|
835
1099
|
kind,
|
|
836
1100
|
operation: "update"
|
|
837
1101
|
});
|
|
838
|
-
const patch =
|
|
1102
|
+
const patch = chunkN66HCGCY_cjs.createDataKeyedBag();
|
|
839
1103
|
const unsetProperties = [];
|
|
840
1104
|
for (const [property, value] of Object.entries(parsedPatch)) {
|
|
841
1105
|
if (value === void 0) {
|
|
842
1106
|
unsetProperties.push(property);
|
|
843
1107
|
continue;
|
|
844
1108
|
}
|
|
845
|
-
|
|
1109
|
+
chunkLBJKZXDE_cjs.assertJsonValue(value, property, `Node "${kind}" updateWhere patch`);
|
|
846
1110
|
patch[property] = value;
|
|
847
1111
|
}
|
|
848
1112
|
if (Object.keys(patch).length === 0 && unsetProperties.length === 0) {
|
|
849
|
-
throw new
|
|
1113
|
+
throw new chunkNI72YOJB_cjs.ValidationError(
|
|
850
1114
|
"updateWhere() patch has no recognized properties",
|
|
851
1115
|
{
|
|
852
1116
|
entityType: "node",
|
|
@@ -859,19 +1123,19 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
|
|
|
859
1123
|
);
|
|
860
1124
|
}
|
|
861
1125
|
if (uniqueConstraints.length > 0 && (backend.hardDeleteUniquesByNodeIds === void 0 || backend.insertUniqueBatch === void 0 || backend.checkUniqueBatch === void 0)) {
|
|
862
|
-
throw new
|
|
1126
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
863
1127
|
"updateWhere() requires batched uniqueness sidecar operations for constrained nodes",
|
|
864
1128
|
{ code: "SET_UPDATE_UNIQUENESS_UNSUPPORTED", kind }
|
|
865
1129
|
);
|
|
866
1130
|
}
|
|
867
1131
|
if (chunkHAHNRASW_cjs.getSearchableFields(schema).length > 0 && (backend.upsertFulltext === void 0 || backend.deleteFulltext === void 0 || backend.upsertFulltextBatch === void 0 || backend.deleteFulltextBatch === void 0)) {
|
|
868
|
-
throw new
|
|
1132
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
869
1133
|
"updateWhere() requires batched fulltext sidecar operations for searchable nodes",
|
|
870
1134
|
{ code: "SET_UPDATE_FULLTEXT_UNSUPPORTED", kind }
|
|
871
1135
|
);
|
|
872
1136
|
}
|
|
873
|
-
if (
|
|
874
|
-
throw new
|
|
1137
|
+
if (chunkTTAITEPJ_cjs.getEmbeddingFields(schema).length > 0 && (backend.upsertEmbedding === void 0 || backend.deleteEmbedding === void 0 || backend.upsertEmbeddingBatch === void 0 || backend.deleteEmbeddingBatch === void 0)) {
|
|
1138
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
875
1139
|
"updateWhere() requires batched vector sidecar operations for embedded nodes",
|
|
876
1140
|
{ code: "SET_UPDATE_VECTOR_UNSUPPORTED", kind }
|
|
877
1141
|
);
|
|
@@ -879,32 +1143,32 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
|
|
|
879
1143
|
const hookContext = ctx.createBulkOperationContext("updateWhere", kind);
|
|
880
1144
|
return ctx.withBulkOperationHooks(
|
|
881
1145
|
hookContext,
|
|
882
|
-
() => runInWriteTransaction(
|
|
1146
|
+
() => chunkXNLIZYRZ_cjs.runInWriteTransaction(
|
|
883
1147
|
ctx,
|
|
884
1148
|
backend,
|
|
885
1149
|
async (target, lock) => {
|
|
886
1150
|
const updateNodeSet = target.updateNodeSet;
|
|
887
1151
|
if (updateNodeSet === void 0) {
|
|
888
|
-
throw new
|
|
1152
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
889
1153
|
"The transaction backend does not support set-based node updates",
|
|
890
1154
|
{ code: "SET_UPDATE_UNSUPPORTED", kind }
|
|
891
1155
|
);
|
|
892
1156
|
}
|
|
893
1157
|
const hardDeleteUniquesByNodeIds = target.hardDeleteUniquesByNodeIds;
|
|
894
1158
|
if (uniqueConstraints.length > 0 && (hardDeleteUniquesByNodeIds === void 0 || target.insertUniqueBatch === void 0 || target.checkUniqueBatch === void 0)) {
|
|
895
|
-
throw new
|
|
1159
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
896
1160
|
"The transaction backend lacks batched uniqueness operations",
|
|
897
1161
|
{ code: "SET_UPDATE_UNIQUENESS_UNSUPPORTED", kind }
|
|
898
1162
|
);
|
|
899
1163
|
}
|
|
900
1164
|
if (chunkHAHNRASW_cjs.getSearchableFields(schema).length > 0 && (target.upsertFulltext === void 0 || target.deleteFulltext === void 0 || target.upsertFulltextBatch === void 0 || target.deleteFulltextBatch === void 0)) {
|
|
901
|
-
throw new
|
|
1165
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
902
1166
|
"The transaction backend lacks batched fulltext operations",
|
|
903
1167
|
{ code: "SET_UPDATE_FULLTEXT_UNSUPPORTED", kind }
|
|
904
1168
|
);
|
|
905
1169
|
}
|
|
906
|
-
if (
|
|
907
|
-
throw new
|
|
1170
|
+
if (chunkTTAITEPJ_cjs.getEmbeddingFields(schema).length > 0 && (target.upsertEmbedding === void 0 || target.deleteEmbedding === void 0 || target.upsertEmbeddingBatch === void 0 || target.deleteEmbeddingBatch === void 0)) {
|
|
1171
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
908
1172
|
"The transaction backend lacks batched vector operations",
|
|
909
1173
|
{ code: "SET_UPDATE_VECTOR_UNSUPPORTED", kind }
|
|
910
1174
|
);
|
|
@@ -919,14 +1183,14 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
|
|
|
919
1183
|
});
|
|
920
1184
|
if (result.affectedCount === 0) return { affectedCount: 0 };
|
|
921
1185
|
const sidecarItems = result.rows.map((row) => {
|
|
922
|
-
const props =
|
|
923
|
-
const validatedProps =
|
|
1186
|
+
const props = chunkXBYVV3MP_cjs.rowPropsToObject(row.props);
|
|
1187
|
+
const validatedProps = chunkXNLIZYRZ_cjs.validateNodeProps(schema, props, {
|
|
924
1188
|
kind,
|
|
925
1189
|
operation: "update",
|
|
926
1190
|
id: row.id
|
|
927
1191
|
});
|
|
928
|
-
if (!
|
|
929
|
-
throw new
|
|
1192
|
+
if (!chunkPWLJ77UV_cjs.canonicalEqual(validatedProps, props)) {
|
|
1193
|
+
throw new chunkNI72YOJB_cjs.ValidationError(
|
|
930
1194
|
`Set update would persist a non-canonical ${kind} row`,
|
|
931
1195
|
{
|
|
932
1196
|
entityType: "node",
|
|
@@ -955,15 +1219,15 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
|
|
|
955
1219
|
for (const constraint of uniqueConstraints) {
|
|
956
1220
|
const keyToId = /* @__PURE__ */ new Map();
|
|
957
1221
|
for (const item of sidecarItems) {
|
|
958
|
-
if (!
|
|
959
|
-
const key =
|
|
1222
|
+
if (!chunkE4WNQBEF_cjs.checkWherePredicate(constraint, item.props)) continue;
|
|
1223
|
+
const key = chunkE4WNQBEF_cjs.computeUniqueKey(
|
|
960
1224
|
item.props,
|
|
961
1225
|
constraint.fields,
|
|
962
1226
|
constraint.collation
|
|
963
1227
|
);
|
|
964
1228
|
const priorId = keyToId.get(key);
|
|
965
1229
|
if (priorId !== void 0 && priorId !== item.id) {
|
|
966
|
-
throw new
|
|
1230
|
+
throw new chunkNI72YOJB_cjs.UniquenessError({
|
|
967
1231
|
constraintName: constraint.name,
|
|
968
1232
|
kind,
|
|
969
1233
|
existingId: priorId,
|
|
@@ -975,12 +1239,12 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
|
|
|
975
1239
|
}
|
|
976
1240
|
const keys = [...keyToId.keys()];
|
|
977
1241
|
if (keys.length === 0) continue;
|
|
978
|
-
for (const kindToCheck of
|
|
1242
|
+
for (const kindToCheck of chunkE4WNQBEF_cjs.getKindsForUniquenessCheck(
|
|
979
1243
|
kind,
|
|
980
1244
|
constraint.scope,
|
|
981
1245
|
ctx.registry
|
|
982
1246
|
)) {
|
|
983
|
-
const existingRows = await
|
|
1247
|
+
const existingRows = await chunkN66HCGCY_cjs.requireDefined(
|
|
984
1248
|
target.checkUniqueBatch
|
|
985
1249
|
)({
|
|
986
1250
|
graphId: ctx.graphId,
|
|
@@ -992,54 +1256,87 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
|
|
|
992
1256
|
if (existing.concrete_kind === kind && affectedIds.has(existing.node_id)) {
|
|
993
1257
|
continue;
|
|
994
1258
|
}
|
|
995
|
-
throw new
|
|
1259
|
+
throw new chunkNI72YOJB_cjs.UniquenessError({
|
|
996
1260
|
constraintName: constraint.name,
|
|
997
1261
|
kind: kindToCheck,
|
|
998
1262
|
existingId: existing.node_id,
|
|
999
|
-
newId:
|
|
1263
|
+
newId: chunkN66HCGCY_cjs.requireDefined(keyToId.get(existing.key)),
|
|
1000
1264
|
fields: constraint.fields
|
|
1001
1265
|
});
|
|
1002
1266
|
}
|
|
1003
1267
|
}
|
|
1004
1268
|
}
|
|
1005
|
-
await
|
|
1269
|
+
await chunkN66HCGCY_cjs.requireDefined(hardDeleteUniquesByNodeIds)({
|
|
1006
1270
|
graphId: ctx.graphId,
|
|
1007
1271
|
concreteKind: kind,
|
|
1008
1272
|
nodeIds: result.rows.map((row) => row.id)
|
|
1009
1273
|
});
|
|
1010
1274
|
}
|
|
1011
|
-
await
|
|
1012
|
-
|
|
1275
|
+
await chunkTTAITEPJ_cjs.applyNodeInsertSideEffectsBatch(
|
|
1276
|
+
chunkTTAITEPJ_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
|
|
1013
1277
|
sidecarItems,
|
|
1014
1278
|
target
|
|
1015
1279
|
);
|
|
1016
1280
|
return { affectedCount: result.affectedCount };
|
|
1017
1281
|
},
|
|
1018
|
-
{
|
|
1282
|
+
{
|
|
1283
|
+
didWrite: (result) => result.affectedCount > 0,
|
|
1284
|
+
// The set update re-checks every changed unique key across the
|
|
1285
|
+
// constraint's scope before rebuilding the sidecars, so a shared-scope
|
|
1286
|
+
// constraint makes it a constrained write like any other update.
|
|
1287
|
+
fencesConstraintProbe: nodeFencesConstraintProbe(ctx, kind, "update")
|
|
1288
|
+
}
|
|
1019
1289
|
)
|
|
1020
1290
|
);
|
|
1021
1291
|
}
|
|
1022
1292
|
async function executeNodeUpsertUpdate(ctx, input, backend, options) {
|
|
1023
|
-
return runInWriteTransaction(
|
|
1293
|
+
return chunkXNLIZYRZ_cjs.runInWriteTransaction(
|
|
1024
1294
|
ctx,
|
|
1025
1295
|
backend,
|
|
1026
|
-
(target, lock) =>
|
|
1296
|
+
async (target, lock) => {
|
|
1297
|
+
const identity = ctx.identity;
|
|
1298
|
+
if (options?.clearDeleted && identity !== void 0) {
|
|
1299
|
+
await identity.lock(target);
|
|
1300
|
+
}
|
|
1301
|
+
const node = await performNodeUpdateWithResurrectionRecovery(
|
|
1302
|
+
ctx,
|
|
1303
|
+
input,
|
|
1304
|
+
target,
|
|
1305
|
+
lock,
|
|
1306
|
+
options
|
|
1307
|
+
);
|
|
1308
|
+
if (options?.clearDeleted && identity !== void 0) {
|
|
1309
|
+
await identity.foldCreated(target, [
|
|
1310
|
+
{ kind: input.kind, id: input.id }
|
|
1311
|
+
]);
|
|
1312
|
+
}
|
|
1313
|
+
return node;
|
|
1314
|
+
},
|
|
1315
|
+
{
|
|
1316
|
+
fencesConstraintProbe: nodeFencesConstraintProbe(
|
|
1317
|
+
ctx,
|
|
1318
|
+
input.kind,
|
|
1319
|
+
"update"
|
|
1320
|
+
)
|
|
1321
|
+
}
|
|
1027
1322
|
);
|
|
1028
1323
|
}
|
|
1029
1324
|
async function executeNodeDelete(ctx, kind, id, backend) {
|
|
1030
1325
|
const gate = await backend.getNode(ctx.graphId, kind, id);
|
|
1031
1326
|
if (!gate || gate.deleted_at) return;
|
|
1032
1327
|
const opContext = ctx.createOperationContext("delete", "node", kind, id);
|
|
1033
|
-
return runHookedWriteOperation(
|
|
1328
|
+
return chunkXNLIZYRZ_cjs.runHookedWriteOperation(
|
|
1034
1329
|
ctx,
|
|
1035
1330
|
opContext,
|
|
1036
1331
|
backend,
|
|
1037
1332
|
async (target, lock) => {
|
|
1333
|
+
const identity = ctx.identity;
|
|
1334
|
+
if (identity !== void 0) await identity.lock(target);
|
|
1038
1335
|
const registration = getNodeRegistration(ctx.graph, kind);
|
|
1039
1336
|
const preflight = await target.getNode(ctx.graphId, kind, id);
|
|
1040
|
-
if (!preflight || !
|
|
1041
|
-
await
|
|
1042
|
-
|
|
1337
|
+
if (!preflight || !chunkXBYVV3MP_cjs.isLiveNodeRow(preflight)) return;
|
|
1338
|
+
await chunkTTAITEPJ_cjs.applyNodeSoftDelete(
|
|
1339
|
+
chunkTTAITEPJ_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
|
|
1043
1340
|
{
|
|
1044
1341
|
existing: preflight,
|
|
1045
1342
|
schema: registration.type.schema,
|
|
@@ -1048,21 +1345,63 @@ async function executeNodeDelete(ctx, kind, id, backend) {
|
|
|
1048
1345
|
},
|
|
1049
1346
|
target
|
|
1050
1347
|
);
|
|
1348
|
+
if (identity !== void 0) {
|
|
1349
|
+
await identity.detachDeleted(target, { kind, id }, "soft");
|
|
1350
|
+
}
|
|
1051
1351
|
}
|
|
1052
1352
|
);
|
|
1053
1353
|
}
|
|
1354
|
+
async function executeNodeDeleteBatch(ctx, kind, ids, backend) {
|
|
1355
|
+
await chunkXNLIZYRZ_cjs.runInWriteTransaction(
|
|
1356
|
+
ctx,
|
|
1357
|
+
backend,
|
|
1358
|
+
async (target, lock) => {
|
|
1359
|
+
const identity = ctx.identity;
|
|
1360
|
+
if (identity !== void 0) await identity.lock(target);
|
|
1361
|
+
const registration = getNodeRegistration(ctx.graph, kind);
|
|
1362
|
+
const writeContext = chunkTTAITEPJ_cjs.createNodeWriteContext(
|
|
1363
|
+
ctx.graphId,
|
|
1364
|
+
ctx.registry,
|
|
1365
|
+
lock
|
|
1366
|
+
);
|
|
1367
|
+
let affectedCount = 0;
|
|
1368
|
+
for (const id of ids) {
|
|
1369
|
+
const preflight = await target.getNode(ctx.graphId, kind, id);
|
|
1370
|
+
if (!preflight || !chunkXBYVV3MP_cjs.isLiveNodeRow(preflight)) continue;
|
|
1371
|
+
await chunkTTAITEPJ_cjs.applyNodeSoftDelete(
|
|
1372
|
+
writeContext,
|
|
1373
|
+
{
|
|
1374
|
+
existing: preflight,
|
|
1375
|
+
schema: registration.type.schema,
|
|
1376
|
+
uniqueConstraints: registration.unique ?? [],
|
|
1377
|
+
onDelete: registration.onDelete
|
|
1378
|
+
},
|
|
1379
|
+
target
|
|
1380
|
+
);
|
|
1381
|
+
if (identity !== void 0) {
|
|
1382
|
+
await identity.detachDeleted(target, { kind, id }, "soft");
|
|
1383
|
+
}
|
|
1384
|
+
affectedCount += 1;
|
|
1385
|
+
}
|
|
1386
|
+
return affectedCount;
|
|
1387
|
+
},
|
|
1388
|
+
{ didWrite: (affectedCount) => affectedCount > 0 }
|
|
1389
|
+
);
|
|
1390
|
+
}
|
|
1054
1391
|
async function executeNodeHardDelete(ctx, kind, id, backend) {
|
|
1055
1392
|
const gate = await backend.getNode(ctx.graphId, kind, id);
|
|
1056
1393
|
if (!gate) return;
|
|
1057
1394
|
const opContext = ctx.createOperationContext("delete", "node", kind, id);
|
|
1058
|
-
return runHookedWriteOperation(
|
|
1395
|
+
return chunkXNLIZYRZ_cjs.runHookedWriteOperation(
|
|
1059
1396
|
ctx,
|
|
1060
1397
|
opContext,
|
|
1061
1398
|
backend,
|
|
1062
1399
|
async (target, lock) => {
|
|
1400
|
+
const identity = ctx.identity;
|
|
1401
|
+
if (identity !== void 0) await identity.lock(target);
|
|
1063
1402
|
const registration = getNodeRegistration(ctx.graph, kind);
|
|
1064
|
-
await
|
|
1065
|
-
|
|
1403
|
+
await chunkTTAITEPJ_cjs.applyNodeHardDelete(
|
|
1404
|
+
chunkTTAITEPJ_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
|
|
1066
1405
|
{
|
|
1067
1406
|
kind,
|
|
1068
1407
|
id,
|
|
@@ -1071,6 +1410,9 @@ async function executeNodeHardDelete(ctx, kind, id, backend) {
|
|
|
1071
1410
|
},
|
|
1072
1411
|
target
|
|
1073
1412
|
);
|
|
1413
|
+
if (identity !== void 0) {
|
|
1414
|
+
await identity.detachDeleted(target, { kind, id }, "hard");
|
|
1415
|
+
}
|
|
1074
1416
|
}
|
|
1075
1417
|
);
|
|
1076
1418
|
}
|
|
@@ -1078,12 +1420,12 @@ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, pro
|
|
|
1078
1420
|
const ifExists = options?.ifExists ?? "return";
|
|
1079
1421
|
const registration = getNodeRegistration(ctx.graph, kind);
|
|
1080
1422
|
const nodeKind = registration.type;
|
|
1081
|
-
const validatedProps =
|
|
1423
|
+
const validatedProps = chunkXNLIZYRZ_cjs.validateNodeProps(nodeKind.schema, props, {
|
|
1082
1424
|
kind,
|
|
1083
1425
|
operation: "create"
|
|
1084
1426
|
});
|
|
1085
1427
|
const constraint = resolveConstraint(ctx.graph, kind, constraintName);
|
|
1086
|
-
if (!
|
|
1428
|
+
if (!chunkE4WNQBEF_cjs.checkWherePredicate(constraint, validatedProps)) {
|
|
1087
1429
|
const node = await executeNodeCreate(
|
|
1088
1430
|
ctx,
|
|
1089
1431
|
{ kind, props: validatedProps },
|
|
@@ -1092,12 +1434,12 @@ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, pro
|
|
|
1092
1434
|
);
|
|
1093
1435
|
return { node, action: "created" };
|
|
1094
1436
|
}
|
|
1095
|
-
const key =
|
|
1437
|
+
const key = chunkE4WNQBEF_cjs.computeUniqueKey(
|
|
1096
1438
|
validatedProps,
|
|
1097
1439
|
constraint.fields,
|
|
1098
1440
|
constraint.collation
|
|
1099
1441
|
);
|
|
1100
|
-
const kindsToCheck =
|
|
1442
|
+
const kindsToCheck = chunkE4WNQBEF_cjs.getKindsForUniquenessCheck(
|
|
1101
1443
|
kind,
|
|
1102
1444
|
constraint.scope,
|
|
1103
1445
|
ctx.registry
|
|
@@ -1154,25 +1496,25 @@ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, pro
|
|
|
1154
1496
|
try {
|
|
1155
1497
|
return await attempt();
|
|
1156
1498
|
} catch (error) {
|
|
1157
|
-
if (!(error instanceof
|
|
1499
|
+
if (!(error instanceof chunkNI72YOJB_cjs.UniquenessError)) throw error;
|
|
1158
1500
|
return attempt();
|
|
1159
1501
|
}
|
|
1160
1502
|
}
|
|
1161
1503
|
async function executeNodeFindByConstraint(ctx, kind, constraintName, props, backend) {
|
|
1162
1504
|
const registration = getNodeRegistration(ctx.graph, kind);
|
|
1163
1505
|
const nodeKind = registration.type;
|
|
1164
|
-
const validatedProps =
|
|
1506
|
+
const validatedProps = chunkXNLIZYRZ_cjs.validateNodeProps(nodeKind.schema, props, {
|
|
1165
1507
|
kind,
|
|
1166
1508
|
operation: "create"
|
|
1167
1509
|
});
|
|
1168
1510
|
const constraint = resolveConstraint(ctx.graph, kind, constraintName);
|
|
1169
|
-
if (!
|
|
1170
|
-
const key =
|
|
1511
|
+
if (!chunkE4WNQBEF_cjs.checkWherePredicate(constraint, validatedProps)) return void 0;
|
|
1512
|
+
const key = chunkE4WNQBEF_cjs.computeUniqueKey(
|
|
1171
1513
|
validatedProps,
|
|
1172
1514
|
constraint.fields,
|
|
1173
1515
|
constraint.collation
|
|
1174
1516
|
);
|
|
1175
|
-
const kindsToCheck =
|
|
1517
|
+
const kindsToCheck = chunkE4WNQBEF_cjs.getKindsForUniquenessCheck(
|
|
1176
1518
|
kind,
|
|
1177
1519
|
constraint.scope,
|
|
1178
1520
|
ctx.registry
|
|
@@ -1198,12 +1540,12 @@ async function executeNodeFindByConstraint(ctx, kind, constraintName, props, bac
|
|
|
1198
1540
|
function validateAndComputeKeys(nodeKind, kind, constraint, items) {
|
|
1199
1541
|
const validated = [];
|
|
1200
1542
|
for (const item of items) {
|
|
1201
|
-
const validatedProps =
|
|
1543
|
+
const validatedProps = chunkXNLIZYRZ_cjs.validateNodeProps(nodeKind.schema, item.props, {
|
|
1202
1544
|
kind,
|
|
1203
1545
|
operation: "create"
|
|
1204
1546
|
});
|
|
1205
|
-
const applies =
|
|
1206
|
-
const key = applies ?
|
|
1547
|
+
const applies = chunkE4WNQBEF_cjs.checkWherePredicate(constraint, validatedProps);
|
|
1548
|
+
const key = applies ? chunkE4WNQBEF_cjs.computeUniqueKey(
|
|
1207
1549
|
validatedProps,
|
|
1208
1550
|
constraint.fields,
|
|
1209
1551
|
constraint.collation
|
|
@@ -1226,7 +1568,7 @@ async function executeNodeBulkFindByConstraint(ctx, kind, constraintName, items,
|
|
|
1226
1568
|
const constraint = resolveConstraint(ctx.graph, kind, constraintName);
|
|
1227
1569
|
const validated = validateAndComputeKeys(nodeKind, kind, constraint, items);
|
|
1228
1570
|
const uniqueKeys = collectUniqueKeys(validated);
|
|
1229
|
-
const kindsToCheck =
|
|
1571
|
+
const kindsToCheck = chunkE4WNQBEF_cjs.getKindsForUniquenessCheck(
|
|
1230
1572
|
kind,
|
|
1231
1573
|
constraint.scope,
|
|
1232
1574
|
ctx.registry
|
|
@@ -1276,10 +1618,10 @@ function resolveNodeIndex(graph, kind, indexName) {
|
|
|
1276
1618
|
(candidate) => candidate.entity === "node" && candidate.kind === kind && candidate.name === indexName
|
|
1277
1619
|
);
|
|
1278
1620
|
if (declaration?.entity !== "node") {
|
|
1279
|
-
throw new
|
|
1621
|
+
throw new chunkNI72YOJB_cjs.NodeIndexNotFoundError(indexName, kind);
|
|
1280
1622
|
}
|
|
1281
1623
|
if (declaration.method !== void 0) {
|
|
1282
|
-
throw new
|
|
1624
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
1283
1625
|
`bulkFindByIndex cannot probe index "${indexName}" (method "${declaration.method}"): only btree indexes serve equality probes.`,
|
|
1284
1626
|
{ indexName, kind, method: declaration.method }
|
|
1285
1627
|
);
|
|
@@ -1317,7 +1659,7 @@ function validateIndexProbeValue(value, valueType, pointer, kind) {
|
|
|
1317
1659
|
}
|
|
1318
1660
|
}
|
|
1319
1661
|
function indexProbeTypeError(pointer, kind, expected, value) {
|
|
1320
|
-
return new
|
|
1662
|
+
return new chunkNI72YOJB_cjs.ValidationError(
|
|
1321
1663
|
`Index probe value for "${pointer}" on node kind "${kind}" has an incompatible type`,
|
|
1322
1664
|
{
|
|
1323
1665
|
entityType: "node",
|
|
@@ -1351,7 +1693,7 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
|
|
|
1351
1693
|
if (items.length === 0) return [];
|
|
1352
1694
|
const index = resolveNodeIndex(ctx.graph, kind, indexName);
|
|
1353
1695
|
if (index.fields.length === 0) {
|
|
1354
|
-
throw new
|
|
1696
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
1355
1697
|
`bulkFindByIndex requires an index with at least one prop-based field on index "${indexName}" (node kind "${kind}")`,
|
|
1356
1698
|
{ indexName, kind },
|
|
1357
1699
|
{
|
|
@@ -1360,7 +1702,7 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
|
|
|
1360
1702
|
);
|
|
1361
1703
|
}
|
|
1362
1704
|
if (index.fieldValueTypes.includes("date")) {
|
|
1363
|
-
throw new
|
|
1705
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
1364
1706
|
`bulkFindByIndex does not support date-typed key fields on index "${indexName}" (node kind "${kind}")`,
|
|
1365
1707
|
{ indexName, kind },
|
|
1366
1708
|
{
|
|
@@ -1370,7 +1712,7 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
|
|
|
1370
1712
|
}
|
|
1371
1713
|
const limitPerInput = options?.limitPerInput;
|
|
1372
1714
|
if (limitPerInput !== void 0 && (!Number.isInteger(limitPerInput) || limitPerInput <= 0)) {
|
|
1373
|
-
throw new
|
|
1715
|
+
throw new chunkNI72YOJB_cjs.ValidationError(
|
|
1374
1716
|
"bulkFindByIndex limitPerInput must be a positive integer",
|
|
1375
1717
|
{
|
|
1376
1718
|
entityType: "node",
|
|
@@ -1385,10 +1727,10 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
|
|
|
1385
1727
|
}
|
|
1386
1728
|
);
|
|
1387
1729
|
}
|
|
1388
|
-
const adapter =
|
|
1730
|
+
const adapter = chunk4UGOKMI5_cjs.getDialect(backend.dialect);
|
|
1389
1731
|
const probes = items.map(
|
|
1390
1732
|
(item) => index.fields.map((pointer, position) => {
|
|
1391
|
-
const value =
|
|
1733
|
+
const value = chunkA7J2YDDI_cjs.resolveJsonPointer(item.props, pointer);
|
|
1392
1734
|
validateIndexProbeValue(
|
|
1393
1735
|
value,
|
|
1394
1736
|
index.fieldValueTypes[position],
|
|
@@ -1412,47 +1754,47 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
|
|
|
1412
1754
|
}
|
|
1413
1755
|
groupToInputs[existing]?.push(inputIndex);
|
|
1414
1756
|
}
|
|
1415
|
-
const schema = backend.tableNames ?
|
|
1757
|
+
const schema = backend.tableNames ? chunkNFCVHQ5P_cjs.createSqlSchema(backend.tableNames) : chunkNFCVHQ5P_cjs.DEFAULT_SQL_SCHEMA;
|
|
1416
1758
|
const compileContext = {
|
|
1417
1759
|
dialect: backend.dialect,
|
|
1418
|
-
propsColumn:
|
|
1419
|
-
systemColumn: (column) =>
|
|
1760
|
+
propsColumn: chunkVCRRKBLN_cjs.sql.raw(`"props"`),
|
|
1761
|
+
systemColumn: (column) => chunkVCRRKBLN_cjs.sql.raw(`"${column}"`)
|
|
1420
1762
|
};
|
|
1421
|
-
const fieldKeys =
|
|
1763
|
+
const fieldKeys = chunk4UGOKMI5_cjs.compileNodeIndexFieldKeys(index, compileContext);
|
|
1422
1764
|
const groupPredicates = groupProbes.map(
|
|
1423
|
-
(probe) =>
|
|
1765
|
+
(probe) => chunkVCRRKBLN_cjs.sql`(${chunkVCRRKBLN_cjs.sql.join(
|
|
1424
1766
|
fieldKeys.map((fieldKey, position) => {
|
|
1425
1767
|
const value = probe[position];
|
|
1426
1768
|
if (value === void 0 || value === null) {
|
|
1427
|
-
return
|
|
1769
|
+
return chunkVCRRKBLN_cjs.sql`${fieldKey} IS NULL`;
|
|
1428
1770
|
}
|
|
1429
1771
|
return adapter.nullSafeEquals(
|
|
1430
1772
|
fieldKey,
|
|
1431
|
-
|
|
1773
|
+
chunkVCRRKBLN_cjs.sql`${coerceIndexProbeBind(value, adapter)}`
|
|
1432
1774
|
);
|
|
1433
1775
|
}),
|
|
1434
|
-
|
|
1776
|
+
chunkVCRRKBLN_cjs.sql` AND `
|
|
1435
1777
|
)})`
|
|
1436
1778
|
);
|
|
1437
1779
|
const caseBranches = groupPredicates.map(
|
|
1438
|
-
(predicate, group) =>
|
|
1780
|
+
(predicate, group) => chunkVCRRKBLN_cjs.sql`WHEN ${predicate} THEN ${chunkVCRRKBLN_cjs.sql.raw(String(group))}`
|
|
1439
1781
|
);
|
|
1440
|
-
const probeIndexExpr =
|
|
1782
|
+
const probeIndexExpr = chunkVCRRKBLN_cjs.sql`CASE ${chunkVCRRKBLN_cjs.sql.join(caseBranches, chunkVCRRKBLN_cjs.sql` `)} ELSE NULL END`;
|
|
1441
1783
|
const conditions = [
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1784
|
+
chunkVCRRKBLN_cjs.sql`"graph_id" = ${ctx.graphId}`,
|
|
1785
|
+
chunkVCRRKBLN_cjs.sql`"kind" = ${kind}`,
|
|
1786
|
+
chunkVCRRKBLN_cjs.sql`"deleted_at" IS NULL`
|
|
1445
1787
|
];
|
|
1446
1788
|
if (index.where !== void 0) {
|
|
1447
|
-
conditions.push(
|
|
1789
|
+
conditions.push(chunk4UGOKMI5_cjs.compileIndexWhere(compileContext, index.where));
|
|
1448
1790
|
}
|
|
1449
|
-
conditions.push(
|
|
1450
|
-
const whereClause =
|
|
1451
|
-
const probedSelect =
|
|
1791
|
+
conditions.push(chunkVCRRKBLN_cjs.sql`(${chunkVCRRKBLN_cjs.sql.join(groupPredicates, chunkVCRRKBLN_cjs.sql` OR `)})`);
|
|
1792
|
+
const whereClause = chunkVCRRKBLN_cjs.sql.join(conditions, chunkVCRRKBLN_cjs.sql` AND `);
|
|
1793
|
+
const probedSelect = chunkVCRRKBLN_cjs.sql`SELECT "id", ${probeIndexExpr} AS probe_idx FROM ${schema.nodesTable} WHERE ${whereClause}`;
|
|
1452
1794
|
const capInSql = limitPerInput !== void 0 && backend.capabilities.windowFunctions;
|
|
1453
|
-
const query = capInSql ?
|
|
1795
|
+
const query = capInSql ? chunkVCRRKBLN_cjs.sql`SELECT "id", probe_idx FROM (SELECT "id", probe_idx, ROW_NUMBER() OVER (PARTITION BY probe_idx ORDER BY "id") AS probe_rank FROM (${probedSelect}) AS probed) AS ranked WHERE probe_rank <= ${limitPerInput} ORDER BY probe_idx, "id"` : chunkVCRRKBLN_cjs.sql`${probedSelect} ORDER BY probe_idx, "id"`;
|
|
1454
1796
|
const rawMatches = await backend.execute(
|
|
1455
|
-
|
|
1797
|
+
chunkVCRRKBLN_cjs.asCompiledRowsSql(query)
|
|
1456
1798
|
);
|
|
1457
1799
|
const matches = limitPerInput !== void 0 && !capInSql ? capMatchesPerGroup(rawMatches, limitPerInput) : rawMatches;
|
|
1458
1800
|
const nodesById = await hydrateNodesById(
|
|
@@ -1485,7 +1827,7 @@ function capMatchesPerGroup(matches, limitPerInput) {
|
|
|
1485
1827
|
return capped;
|
|
1486
1828
|
}
|
|
1487
1829
|
async function hydrateNodesById(backend, graphId, kind, ids) {
|
|
1488
|
-
const rowsById = await
|
|
1830
|
+
const rowsById = await chunkXMQSEJCF_cjs.getNodeRowsByIds(backend, graphId, kind, ids);
|
|
1489
1831
|
const nodesById = /* @__PURE__ */ new Map();
|
|
1490
1832
|
for (const [id, row] of rowsById) {
|
|
1491
1833
|
if (row.deleted_at !== void 0) continue;
|
|
@@ -1501,108 +1843,117 @@ async function executeNodeBulkGetOrCreateByConstraint(ctx, kind, constraintName,
|
|
|
1501
1843
|
const constraint = resolveConstraint(ctx.graph, kind, constraintName);
|
|
1502
1844
|
const validated = validateAndComputeKeys(nodeKind, kind, constraint, items);
|
|
1503
1845
|
const uniqueKeys = collectUniqueKeys(validated);
|
|
1504
|
-
const kindsToCheck =
|
|
1846
|
+
const kindsToCheck = chunkE4WNQBEF_cjs.getKindsForUniquenessCheck(
|
|
1505
1847
|
kind,
|
|
1506
1848
|
constraint.scope,
|
|
1507
1849
|
ctx.registry
|
|
1508
1850
|
);
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
ctx.graphId,
|
|
1512
|
-
constraint.name,
|
|
1513
|
-
uniqueKeys,
|
|
1514
|
-
kindsToCheck,
|
|
1515
|
-
true
|
|
1516
|
-
) : /* @__PURE__ */ new Map();
|
|
1517
|
-
const toCreate = [];
|
|
1518
|
-
const toFetch = [];
|
|
1519
|
-
const duplicateOf = [];
|
|
1520
|
-
const seenKeys = /* @__PURE__ */ new Map();
|
|
1521
|
-
for (const [index, { validatedProps, key }] of validated.entries()) {
|
|
1522
|
-
if (key === void 0) {
|
|
1523
|
-
toCreate.push({ index, input: { kind, props: validatedProps } });
|
|
1524
|
-
continue;
|
|
1525
|
-
}
|
|
1526
|
-
const previousIndex = seenKeys.get(key);
|
|
1527
|
-
if (previousIndex !== void 0) {
|
|
1528
|
-
duplicateOf.push({ index, sourceIndex: previousIndex });
|
|
1529
|
-
continue;
|
|
1530
|
-
}
|
|
1531
|
-
seenKeys.set(key, index);
|
|
1532
|
-
const existing = existingByKey.get(key);
|
|
1533
|
-
if (existing === void 0) {
|
|
1534
|
-
toCreate.push({ index, input: { kind, props: validatedProps } });
|
|
1535
|
-
} else {
|
|
1536
|
-
toFetch.push({
|
|
1537
|
-
index,
|
|
1538
|
-
nodeId: existing.node_id,
|
|
1539
|
-
concreteKind: existing.concrete_kind,
|
|
1540
|
-
validatedProps,
|
|
1541
|
-
isSoftDeleted: existing.deleted_at !== void 0
|
|
1542
|
-
});
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1545
|
-
const results = Array.from({ length: items.length });
|
|
1546
|
-
if (toCreate.length > 0) {
|
|
1547
|
-
const createInputs = toCreate.map((entry) => entry.input);
|
|
1548
|
-
const createdNodes = await executeNodeCreateBatch(
|
|
1549
|
-
ctx,
|
|
1550
|
-
createInputs,
|
|
1851
|
+
async function attempt() {
|
|
1852
|
+
const existingByKey = uniqueKeys.length > 0 ? await batchCheckUniqueAcrossKinds(
|
|
1551
1853
|
backend,
|
|
1552
|
-
{ propsPreValidated: true }
|
|
1553
|
-
);
|
|
1554
|
-
for (const [batchIndex, entry] of toCreate.entries()) {
|
|
1555
|
-
results[entry.index] = {
|
|
1556
|
-
node: chunk764JHTLT_cjs.requireDefined(createdNodes[batchIndex]),
|
|
1557
|
-
action: "created"
|
|
1558
|
-
};
|
|
1559
|
-
}
|
|
1560
|
-
}
|
|
1561
|
-
for (const entry of toFetch) {
|
|
1562
|
-
const { index, concreteKind, validatedProps, isSoftDeleted, nodeId } = entry;
|
|
1563
|
-
const existingRow = await backend.getNode(
|
|
1564
1854
|
ctx.graphId,
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1855
|
+
constraint.name,
|
|
1856
|
+
uniqueKeys,
|
|
1857
|
+
kindsToCheck,
|
|
1858
|
+
true
|
|
1859
|
+
) : /* @__PURE__ */ new Map();
|
|
1860
|
+
const toCreate = [];
|
|
1861
|
+
const toFetch = [];
|
|
1862
|
+
const duplicateOf = [];
|
|
1863
|
+
const seenKeys = /* @__PURE__ */ new Map();
|
|
1864
|
+
for (const [index, { validatedProps, key }] of validated.entries()) {
|
|
1865
|
+
if (key === void 0) {
|
|
1866
|
+
toCreate.push({ index, input: { kind, props: validatedProps } });
|
|
1867
|
+
continue;
|
|
1868
|
+
}
|
|
1869
|
+
const previousIndex = seenKeys.get(key);
|
|
1870
|
+
if (previousIndex !== void 0) {
|
|
1871
|
+
duplicateOf.push({ index, sourceIndex: previousIndex });
|
|
1872
|
+
continue;
|
|
1873
|
+
}
|
|
1874
|
+
seenKeys.set(key, index);
|
|
1875
|
+
const existing = existingByKey.get(key);
|
|
1876
|
+
if (existing === void 0) {
|
|
1877
|
+
toCreate.push({ index, input: { kind, props: validatedProps } });
|
|
1878
|
+
} else {
|
|
1879
|
+
toFetch.push({
|
|
1880
|
+
index,
|
|
1881
|
+
nodeId: existing.node_id,
|
|
1882
|
+
concreteKind: existing.concrete_kind,
|
|
1883
|
+
validatedProps
|
|
1884
|
+
});
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
const results = Array.from({ length: items.length });
|
|
1888
|
+
if (toCreate.length > 0) {
|
|
1889
|
+
const createInputs = toCreate.map((entry) => entry.input);
|
|
1890
|
+
const createdNodes = await executeNodeCreateBatch(
|
|
1570
1891
|
ctx,
|
|
1571
|
-
|
|
1892
|
+
createInputs,
|
|
1572
1893
|
backend,
|
|
1573
1894
|
{ propsPreValidated: true }
|
|
1574
1895
|
);
|
|
1575
|
-
|
|
1576
|
-
|
|
1896
|
+
for (const [batchIndex, entry] of toCreate.entries()) {
|
|
1897
|
+
results[entry.index] = {
|
|
1898
|
+
node: chunkN66HCGCY_cjs.requireDefined(createdNodes[batchIndex]),
|
|
1899
|
+
action: "created"
|
|
1900
|
+
};
|
|
1901
|
+
}
|
|
1577
1902
|
}
|
|
1578
|
-
|
|
1579
|
-
const
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
props: validatedProps
|
|
1585
|
-
},
|
|
1586
|
-
backend,
|
|
1587
|
-
{ clearDeleted: isSoftDeleted }
|
|
1903
|
+
for (const entry of toFetch) {
|
|
1904
|
+
const { index, concreteKind, validatedProps, nodeId } = entry;
|
|
1905
|
+
const existingRow = await backend.getNode(
|
|
1906
|
+
ctx.graphId,
|
|
1907
|
+
concreteKind,
|
|
1908
|
+
nodeId
|
|
1588
1909
|
);
|
|
1589
|
-
|
|
1590
|
-
node
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1910
|
+
if (existingRow === void 0) {
|
|
1911
|
+
const node = await executeNodeCreate(
|
|
1912
|
+
ctx,
|
|
1913
|
+
{ kind, props: validatedProps },
|
|
1914
|
+
backend,
|
|
1915
|
+
{ propsPreValidated: true }
|
|
1916
|
+
);
|
|
1917
|
+
results[index] = { node, action: "created" };
|
|
1918
|
+
continue;
|
|
1919
|
+
}
|
|
1920
|
+
const isSoftDeleted = existingRow.deleted_at !== void 0;
|
|
1921
|
+
if (isSoftDeleted || ifExists === "update") {
|
|
1922
|
+
const node = await executeNodeUpsertUpdate(
|
|
1923
|
+
ctx,
|
|
1924
|
+
{
|
|
1925
|
+
kind: concreteKind,
|
|
1926
|
+
id: existingRow.id,
|
|
1927
|
+
props: validatedProps
|
|
1928
|
+
},
|
|
1929
|
+
backend,
|
|
1930
|
+
{ clearDeleted: isSoftDeleted }
|
|
1931
|
+
);
|
|
1932
|
+
results[index] = {
|
|
1933
|
+
node,
|
|
1934
|
+
action: isSoftDeleted ? "resurrected" : "updated"
|
|
1935
|
+
};
|
|
1936
|
+
} else {
|
|
1937
|
+
results[index] = { node: rowToNode(existingRow), action: "found" };
|
|
1938
|
+
}
|
|
1595
1939
|
}
|
|
1940
|
+
for (const { index, sourceIndex } of duplicateOf) {
|
|
1941
|
+
const sourceResult = chunkN66HCGCY_cjs.requireDefined(results[sourceIndex]);
|
|
1942
|
+
results[index] = { node: sourceResult.node, action: "found" };
|
|
1943
|
+
}
|
|
1944
|
+
return results;
|
|
1596
1945
|
}
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1946
|
+
try {
|
|
1947
|
+
return await attempt();
|
|
1948
|
+
} catch (error) {
|
|
1949
|
+
if (!(error instanceof chunkNI72YOJB_cjs.UniquenessError)) throw error;
|
|
1950
|
+
return attempt();
|
|
1600
1951
|
}
|
|
1601
|
-
return results;
|
|
1602
1952
|
}
|
|
1603
1953
|
|
|
1604
1954
|
exports.checkCardinalityConstraint = checkCardinalityConstraint;
|
|
1605
1955
|
exports.createNodeBatchValidationBackend = createNodeBatchValidationBackend;
|
|
1956
|
+
exports.edgeWriteNeedsConstraintFence = edgeWriteNeedsConstraintFence;
|
|
1606
1957
|
exports.executeNodeBulkFindByConstraint = executeNodeBulkFindByConstraint;
|
|
1607
1958
|
exports.executeNodeBulkFindByIndex = executeNodeBulkFindByIndex;
|
|
1608
1959
|
exports.executeNodeBulkGetOrCreateByConstraint = executeNodeBulkGetOrCreateByConstraint;
|
|
@@ -1610,20 +1961,19 @@ exports.executeNodeCreate = executeNodeCreate;
|
|
|
1610
1961
|
exports.executeNodeCreateBatch = executeNodeCreateBatch;
|
|
1611
1962
|
exports.executeNodeCreateNoReturnBatch = executeNodeCreateNoReturnBatch;
|
|
1612
1963
|
exports.executeNodeDelete = executeNodeDelete;
|
|
1964
|
+
exports.executeNodeDeleteBatch = executeNodeDeleteBatch;
|
|
1613
1965
|
exports.executeNodeFindByConstraint = executeNodeFindByConstraint;
|
|
1614
1966
|
exports.executeNodeGetOrCreateByConstraint = executeNodeGetOrCreateByConstraint;
|
|
1615
1967
|
exports.executeNodeHardDelete = executeNodeHardDelete;
|
|
1616
1968
|
exports.executeNodeUpdate = executeNodeUpdate;
|
|
1617
1969
|
exports.executeNodeUpdateWhere = executeNodeUpdateWhere;
|
|
1618
1970
|
exports.executeNodeUpsertUpdate = executeNodeUpsertUpdate;
|
|
1619
|
-
exports.lockSchemaVersionForStoreWrite = lockSchemaVersionForStoreWrite;
|
|
1620
1971
|
exports.nodeUpsertDirtyCheck = nodeUpsertDirtyCheck;
|
|
1621
1972
|
exports.primeBatchValidationCaches = primeBatchValidationCaches;
|
|
1622
1973
|
exports.rowToEdge = rowToEdge;
|
|
1623
1974
|
exports.rowToEdgeMeta = rowToEdgeMeta;
|
|
1624
1975
|
exports.rowToNode = rowToNode;
|
|
1625
1976
|
exports.rowToNodeMeta = rowToNodeMeta;
|
|
1626
|
-
exports.
|
|
1627
|
-
|
|
1628
|
-
//# sourceMappingURL=chunk-
|
|
1629
|
-
//# sourceMappingURL=chunk-UCQ3BFSY.cjs.map
|
|
1977
|
+
exports.withAlreadyExistsTranslation = withAlreadyExistsTranslation;
|
|
1978
|
+
//# sourceMappingURL=chunk-7GT72YHH.cjs.map
|
|
1979
|
+
//# sourceMappingURL=chunk-7GT72YHH.cjs.map
|