@nicia-ai/typegraph 0.45.0 → 0.46.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend/drizzle/indexes.cjs +11 -11
- package/dist/backend/drizzle/indexes.d.cts +1 -1
- package/dist/backend/drizzle/indexes.d.ts +1 -1
- package/dist/backend/drizzle/indexes.js +7 -7
- package/dist/backend/index.cjs +53 -54
- package/dist/backend/index.d.cts +3 -3
- package/dist/backend/index.d.ts +3 -3
- package/dist/backend/index.js +13 -14
- package/dist/backend/postgres/index.cjs +29 -30
- package/dist/backend/postgres/index.d.cts +7 -7
- package/dist/backend/postgres/index.d.ts +7 -7
- package/dist/backend/postgres/index.js +16 -17
- package/dist/backend/postgres/pglite-store.cjs +48 -42
- package/dist/backend/postgres/pglite-store.cjs.map +1 -1
- package/dist/backend/postgres/pglite-store.d.cts +15 -9
- package/dist/backend/postgres/pglite-store.d.ts +15 -9
- package/dist/backend/postgres/pglite-store.js +44 -38
- package/dist/backend/postgres/pglite-store.js.map +1 -1
- package/dist/backend/postgres/pglite.cjs +18 -19
- package/dist/backend/postgres/pglite.d.cts +4 -4
- package/dist/backend/postgres/pglite.d.ts +4 -4
- package/dist/backend/postgres/pglite.js +17 -18
- package/dist/backend/sqlite/index.cjs +26 -27
- package/dist/backend/sqlite/index.d.cts +6 -6
- package/dist/backend/sqlite/index.d.ts +6 -6
- package/dist/backend/sqlite/index.js +14 -15
- package/dist/backend/sqlite/libsql.cjs +21 -22
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +15 -8
- package/dist/backend/sqlite/libsql.d.ts +15 -8
- package/dist/backend/sqlite/libsql.js +17 -18
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local-store.cjs +49 -43
- package/dist/backend/sqlite/local-store.cjs.map +1 -1
- package/dist/backend/sqlite/local-store.d.cts +15 -10
- package/dist/backend/sqlite/local-store.d.ts +15 -10
- package/dist/backend/sqlite/local-store.js +45 -39
- package/dist/backend/sqlite/local-store.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +19 -20
- package/dist/backend/sqlite/local.d.cts +3 -3
- package/dist/backend/sqlite/local.d.ts +3 -3
- package/dist/backend/sqlite/local.js +17 -18
- package/dist/{chunk-S3ZRKJHY.js → chunk-2LG2XB2M.js} +3 -3
- package/dist/{chunk-S3ZRKJHY.js.map → chunk-2LG2XB2M.js.map} +1 -1
- package/dist/{chunk-7PF2L3H6.cjs → chunk-2NA5DYLO.cjs} +4 -4
- package/dist/{chunk-7PF2L3H6.cjs.map → chunk-2NA5DYLO.cjs.map} +1 -1
- package/dist/chunk-2Z2Z3ZD6.js +58 -0
- package/dist/chunk-2Z2Z3ZD6.js.map +1 -0
- package/dist/{chunk-VVQM4CZD.cjs → chunk-3DHZCOT7.cjs} +20 -20
- package/dist/{chunk-VVQM4CZD.cjs.map → chunk-3DHZCOT7.cjs.map} +1 -1
- package/dist/{chunk-JXUTCSXX.cjs → chunk-4UGOKMI5.cjs} +250 -158
- package/dist/chunk-4UGOKMI5.cjs.map +1 -0
- package/dist/{chunk-RFRM3Q5K.js → chunk-5262ZMTR.js} +14 -5
- package/dist/chunk-5262ZMTR.js.map +1 -0
- package/dist/{chunk-QRNYDV5Z.js → chunk-5763DULU.js} +214 -69
- package/dist/chunk-5763DULU.js.map +1 -0
- package/dist/{chunk-BGYJW37L.js → chunk-5UVRGXD3.js} +277 -7
- package/dist/chunk-5UVRGXD3.js.map +1 -0
- package/dist/{chunk-QR24DJDF.cjs → chunk-62ZP23AW.cjs} +15 -15
- package/dist/{chunk-QR24DJDF.cjs.map → chunk-62ZP23AW.cjs.map} +1 -1
- package/dist/{chunk-ZI6VQSZA.cjs → chunk-65E3XWGF.cjs} +724 -577
- package/dist/chunk-65E3XWGF.cjs.map +1 -0
- package/dist/{chunk-S4KQ5LV4.js → chunk-775A4ZMN.js} +40 -6
- package/dist/chunk-775A4ZMN.js.map +1 -0
- package/dist/{chunk-J2ICGNHO.cjs → chunk-7BQXPCGN.cjs} +830 -169
- package/dist/chunk-7BQXPCGN.cjs.map +1 -0
- package/dist/{chunk-FJMPR3OH.cjs → chunk-7EO3TCQB.cjs} +33 -7
- package/dist/chunk-7EO3TCQB.cjs.map +1 -0
- package/dist/{chunk-DXEEHSGN.js → chunk-7VQXLT5O.js} +436 -43
- package/dist/chunk-7VQXLT5O.js.map +1 -0
- package/dist/chunk-A4OC4DVN.cjs +12 -0
- package/dist/{chunk-4SZ6XPTG.cjs.map → chunk-A4OC4DVN.cjs.map} +1 -1
- package/dist/{chunk-TDXIBCGY.cjs → chunk-A7J2YDDI.cjs} +5 -3
- package/dist/chunk-A7J2YDDI.cjs.map +1 -0
- package/dist/{chunk-55ITBQJI.js → chunk-AKLS3BYZ.js} +56 -5
- package/dist/chunk-AKLS3BYZ.js.map +1 -0
- package/dist/{chunk-D7PG5D5K.js → chunk-AMKPPFUO.js} +32 -6
- package/dist/chunk-AMKPPFUO.js.map +1 -0
- package/dist/{chunk-WUFASQUO.js → chunk-ASTI57H3.js} +3 -3
- package/dist/{chunk-WUFASQUO.js.map → chunk-ASTI57H3.js.map} +1 -1
- package/dist/{chunk-4QIKLIGG.js → chunk-BKCUOV7A.js} +15 -5
- package/dist/chunk-BKCUOV7A.js.map +1 -0
- package/dist/{chunk-JQXSZHF2.cjs → chunk-BSFJMMV3.cjs} +134 -7
- package/dist/chunk-BSFJMMV3.cjs.map +1 -0
- package/dist/{chunk-4GUTQPVO.js → chunk-C23WSN5E.js} +185 -24
- package/dist/chunk-C23WSN5E.js.map +1 -0
- package/dist/{chunk-QLUXRWKL.js → chunk-CBTIUB76.js} +3 -3
- package/dist/{chunk-QLUXRWKL.js.map → chunk-CBTIUB76.js.map} +1 -1
- package/dist/chunk-CMWHLBVN.cjs +2082 -0
- package/dist/chunk-CMWHLBVN.cjs.map +1 -0
- package/dist/{chunk-QB6VMOJ2.cjs → chunk-CXBHOOIQ.cjs} +45 -10
- package/dist/chunk-CXBHOOIQ.cjs.map +1 -0
- package/dist/{chunk-FL5UQRES.js → chunk-DCQVHAYQ.js} +5 -5
- package/dist/{chunk-FL5UQRES.js.map → chunk-DCQVHAYQ.js.map} +1 -1
- package/dist/chunk-DTVWX77L.cjs +3432 -0
- package/dist/chunk-DTVWX77L.cjs.map +1 -0
- package/dist/chunk-DYATYRY4.js +47 -0
- package/dist/chunk-DYATYRY4.js.map +1 -0
- package/dist/chunk-E4WNQBEF.cjs +217 -0
- package/dist/chunk-E4WNQBEF.cjs.map +1 -0
- package/dist/{chunk-G6Q5UM7U.js → chunk-FWJKWH6U.js} +5 -3
- package/dist/chunk-FWJKWH6U.js.map +1 -0
- package/dist/chunk-GF3KXUTW.js +3393 -0
- package/dist/chunk-GF3KXUTW.js.map +1 -0
- package/dist/{chunk-VTN3C3CH.js → chunk-HFHTMECK.js} +7 -7
- package/dist/{chunk-VTN3C3CH.js.map → chunk-HFHTMECK.js.map} +1 -1
- package/dist/{chunk-FLEQ2HBK.js → chunk-I5MOXA4H.js} +20 -14
- package/dist/chunk-I5MOXA4H.js.map +1 -0
- package/dist/{chunk-4MB3AQAQ.js → chunk-J3WZ3FA2.js} +77 -3
- package/dist/chunk-J3WZ3FA2.js.map +1 -0
- package/dist/{chunk-UR7W5YQK.js → chunk-JBQQ7THH.js} +5 -3
- package/dist/chunk-JBQQ7THH.js.map +1 -0
- package/dist/{chunk-TKP5T34P.js → chunk-JXA2ZP2Q.js} +6 -16
- package/dist/chunk-JXA2ZP2Q.js.map +1 -0
- package/dist/{chunk-GYA4JRP5.js → chunk-JXXDZTMN.js} +2 -2
- package/dist/chunk-JXXDZTMN.js.map +1 -0
- package/dist/chunk-JZUR7ZWE.js +254 -0
- package/dist/chunk-JZUR7ZWE.js.map +1 -0
- package/dist/{chunk-42PYUGLS.js → chunk-K5ELX2GT.js} +108 -8
- package/dist/chunk-K5ELX2GT.js.map +1 -0
- package/dist/{chunk-Q6EDCUXV.js → chunk-L65OU2U3.js} +556 -204
- package/dist/chunk-L65OU2U3.js.map +1 -0
- package/dist/{chunk-D54WH24V.cjs → chunk-LBJKZXDE.cjs} +115 -13
- package/dist/chunk-LBJKZXDE.cjs.map +1 -0
- package/dist/{chunk-FQ7ZPOTZ.js → chunk-LGHCOKTT.js} +637 -493
- package/dist/chunk-LGHCOKTT.js.map +1 -0
- package/dist/chunk-M3WP7RQZ.js +736 -0
- package/dist/chunk-M3WP7RQZ.js.map +1 -0
- package/dist/{chunk-4MEWSUVM.cjs → chunk-M4BDU5RX.cjs} +12 -12
- package/dist/chunk-M4BDU5RX.cjs.map +1 -0
- package/dist/chunk-MCLYU6BN.cjs +332 -0
- package/dist/chunk-MCLYU6BN.cjs.map +1 -0
- package/dist/{chunk-MIJKEVV7.js → chunk-MSY7FSX4.js} +37 -4
- package/dist/chunk-MSY7FSX4.js.map +1 -0
- package/dist/{chunk-H7VE3FL4.cjs → chunk-MUK4BU7K.cjs} +519 -125
- package/dist/chunk-MUK4BU7K.cjs.map +1 -0
- package/dist/{chunk-D56XG4EI.cjs → chunk-MXJDTH5B.cjs} +56 -45
- package/dist/chunk-MXJDTH5B.cjs.map +1 -0
- package/dist/{chunk-5EKPX6QU.js → chunk-MZLPX2R7.js} +8 -9
- package/dist/chunk-MZLPX2R7.js.map +1 -0
- package/dist/chunk-N66HCGCY.cjs +57 -0
- package/dist/chunk-N66HCGCY.cjs.map +1 -0
- package/dist/{chunk-CPEL3YIR.cjs → chunk-NFCVHQ5P.cjs} +55 -22
- package/dist/chunk-NFCVHQ5P.cjs.map +1 -0
- package/dist/{chunk-C4F7VJ5D.cjs → chunk-NI72YOJB.cjs} +84 -2
- package/dist/chunk-NI72YOJB.cjs.map +1 -0
- package/dist/{chunk-BNS75YNF.cjs → chunk-NK5Q7UNE.cjs} +10 -20
- package/dist/chunk-NK5Q7UNE.cjs.map +1 -0
- package/dist/{chunk-TKORQCG4.js → chunk-NLI2AVEF.js} +386 -862
- package/dist/chunk-NLI2AVEF.js.map +1 -0
- package/dist/{chunk-YMTXMPV6.js → chunk-NMWDXFPH.js} +4 -4
- package/dist/{chunk-YMTXMPV6.js.map → chunk-NMWDXFPH.js.map} +1 -1
- package/dist/{chunk-J7LXTUTP.cjs → chunk-PF6F5NLJ.cjs} +604 -1094
- package/dist/chunk-PF6F5NLJ.cjs.map +1 -0
- package/dist/{chunk-NAAMUYMS.cjs → chunk-PNN7RHVR.cjs} +58 -48
- package/dist/chunk-PNN7RHVR.cjs.map +1 -0
- package/dist/{chunk-YOALGKRE.cjs → chunk-PNTCATDE.cjs} +3528 -1763
- package/dist/chunk-PNTCATDE.cjs.map +1 -0
- package/dist/{chunk-6DCB664D.js → chunk-PQBQG7IM.js} +3 -3
- package/dist/{chunk-6DCB664D.js.map → chunk-PQBQG7IM.js.map} +1 -1
- package/dist/{chunk-UCQ3BFSY.cjs → chunk-PT7RIRIZ.cjs} +684 -332
- package/dist/chunk-PT7RIRIZ.cjs.map +1 -0
- package/dist/{chunk-ACSVZPK7.cjs → chunk-PWLJ77UV.cjs} +5 -3
- package/dist/chunk-PWLJ77UV.cjs.map +1 -0
- package/dist/chunk-Q3G6A4I3.cjs +755 -0
- package/dist/chunk-Q3G6A4I3.cjs.map +1 -0
- package/dist/{chunk-Z3WO6MND.cjs → chunk-RMQLSPA2.cjs} +297 -27
- package/dist/chunk-RMQLSPA2.cjs.map +1 -0
- package/dist/{chunk-SJDMVITW.cjs → chunk-RT5ZY4XA.cjs} +6 -5
- package/dist/chunk-RT5ZY4XA.cjs.map +1 -0
- package/dist/{chunk-ID4WXTKL.js → chunk-S6PW7VV5.js} +2382 -617
- package/dist/chunk-S6PW7VV5.js.map +1 -0
- package/dist/{chunk-4GUBTVPV.js → chunk-T4XNKYXB.js} +780 -126
- package/dist/chunk-T4XNKYXB.js.map +1 -0
- package/dist/{chunk-YDWLUT5V.cjs → chunk-TQR4KBY2.cjs} +323 -178
- package/dist/chunk-TQR4KBY2.cjs.map +1 -0
- package/dist/{chunk-OOA273IJ.cjs → chunk-U5SON7R2.cjs} +27 -27
- package/dist/{chunk-OOA273IJ.cjs.map → chunk-U5SON7R2.cjs.map} +1 -1
- package/dist/{chunk-IX64T5OL.cjs → chunk-U63GDNRC.cjs} +32 -26
- package/dist/chunk-U63GDNRC.cjs.map +1 -0
- package/dist/{chunk-WDBXJOU5.cjs → chunk-UDISNXDL.cjs} +56 -47
- package/dist/chunk-UDISNXDL.cjs.map +1 -0
- package/dist/{chunk-EFEOOCJ3.js → chunk-UV3SN74I.js} +5 -5
- package/dist/{chunk-EFEOOCJ3.js.map → chunk-UV3SN74I.js.map} +1 -1
- package/dist/{chunk-U5W4LKZV.cjs → chunk-VCRRKBLN.cjs} +9 -9
- package/dist/{chunk-U5W4LKZV.cjs.map → chunk-VCRRKBLN.cjs.map} +1 -1
- package/dist/{chunk-ISLPNELU.js → chunk-VGTJPTIC.js} +16 -5
- package/dist/chunk-VGTJPTIC.js.map +1 -0
- package/dist/chunk-VLT6PEWR.cjs +60 -0
- package/dist/chunk-VLT6PEWR.cjs.map +1 -0
- package/dist/chunk-VQH4VAWD.cjs +12 -0
- package/dist/{chunk-B3F2D3SP.cjs.map → chunk-VQH4VAWD.cjs.map} +1 -1
- package/dist/{chunk-SNXVDZAJ.js → chunk-W6OG3HDG.js} +5 -4
- package/dist/chunk-W6OG3HDG.js.map +1 -0
- package/dist/chunk-WDGA7IYB.js +207 -0
- package/dist/chunk-WDGA7IYB.js.map +1 -0
- package/dist/chunk-WQZLUGVR.js +2057 -0
- package/dist/chunk-WQZLUGVR.js.map +1 -0
- package/dist/{chunk-EKFUG4G7.cjs → chunk-XBYVV3MP.cjs} +60 -5
- package/dist/chunk-XBYVV3MP.cjs.map +1 -0
- package/dist/{chunk-5GAONX5G.cjs → chunk-XCAGZAKP.cjs} +7 -7
- package/dist/{chunk-5GAONX5G.cjs.map → chunk-XCAGZAKP.cjs.map} +1 -1
- package/dist/chunk-XL7SLCXS.js +309 -0
- package/dist/chunk-XL7SLCXS.js.map +1 -0
- package/dist/{chunk-SVJ5GEXW.cjs → chunk-XUO3KQFO.cjs} +2 -2
- package/dist/chunk-XUO3KQFO.cjs.map +1 -0
- package/dist/{chunk-F4NHQHEZ.cjs → chunk-YAAM3M2S.cjs} +10 -10
- package/dist/{chunk-F4NHQHEZ.cjs.map → chunk-YAAM3M2S.cjs.map} +1 -1
- package/dist/{chunk-RUQS6M7G.js → chunk-YBFHZUXX.js} +6 -6
- package/dist/chunk-YBFHZUXX.js.map +1 -0
- package/dist/{chunk-KMXWZLQX.cjs → chunk-YBQOHKHN.cjs} +99 -100
- package/dist/chunk-YBQOHKHN.cjs.map +1 -0
- package/dist/{chunk-PVUI6KGR.js → chunk-YDFDBE6D.js} +93 -6
- package/dist/chunk-YDFDBE6D.js.map +1 -0
- package/dist/{chunk-P7GTYOLB.cjs → chunk-YVWGEQJE.cjs} +297 -135
- package/dist/chunk-YVWGEQJE.cjs.map +1 -0
- package/dist/{chunk-QT6V3YRH.js → chunk-YWGVVALJ.js} +3 -3
- package/dist/{chunk-QT6V3YRH.js.map → chunk-YWGVVALJ.js.map} +1 -1
- package/dist/core/index.cjs +40 -40
- package/dist/core/index.d.cts +4 -5
- package/dist/core/index.d.ts +4 -5
- package/dist/core/index.js +8 -8
- package/dist/{ddl-BG4J805L.d.cts → ddl-BJcOp4WZ.d.cts} +3 -3
- package/dist/{ddl-CgiS9QLj.d.ts → ddl-BXfGHbPN.d.ts} +3 -3
- package/dist/graph-extension/index.cjs +26 -22
- package/dist/graph-extension/index.d.cts +16 -6
- package/dist/graph-extension/index.d.ts +16 -6
- package/dist/graph-extension/index.js +7 -7
- package/dist/graph-merge/index.cjs +2459 -654
- package/dist/graph-merge/index.cjs.map +1 -1
- package/dist/graph-merge/index.d.cts +170 -33
- package/dist/graph-merge/index.d.ts +170 -33
- package/dist/graph-merge/index.js +2269 -467
- package/dist/graph-merge/index.js.map +1 -1
- package/dist/{index-C3y_98iN.d.cts → index-BSHvKfok.d.ts} +221 -10
- package/dist/{index-BBxZCUdu.d.ts → index-DxaYCv8Y.d.cts} +221 -10
- package/dist/index.cjs +330 -268
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +590 -576
- package/dist/index.d.ts +590 -576
- package/dist/index.js +73 -49
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +17 -17
- package/dist/indexes/index.d.cts +4 -4
- package/dist/indexes/index.d.ts +4 -4
- package/dist/indexes/index.js +10 -10
- package/dist/interchange/index.cjs +165 -51
- package/dist/interchange/index.cjs.map +1 -1
- package/dist/interchange/index.d.cts +261 -16
- package/dist/interchange/index.d.ts +261 -16
- package/dist/interchange/index.js +128 -25
- package/dist/interchange/index.js.map +1 -1
- package/dist/{manager-YoLEfcc1.d.ts → manager-CfZAimti.d.ts} +36 -5
- package/dist/{manager-KS7CGQQT.d.cts → manager-HGk6E_HW.d.cts} +36 -5
- package/dist/{materialize-indexes-Bhhyb1B3.d.ts → materialize-indexes-6A7dWGtb.d.cts} +10 -2
- package/dist/{materialize-indexes-OHRWypW6.d.cts → materialize-indexes-BMJP6Tms.d.ts} +10 -2
- package/dist/{postgres-DpkW3R5Y.d.cts → postgres-DFYWENdR.d.cts} +1961 -439
- package/dist/{postgres-DwqyIniy.d.ts → postgres-e7a9TdvR.d.ts} +1961 -439
- package/dist/profiler/index.cjs +15 -15
- package/dist/profiler/index.d.cts +9 -10
- package/dist/profiler/index.d.ts +9 -10
- package/dist/profiler/index.js +4 -4
- package/dist/provenance/index.cjs +46 -48
- package/dist/provenance/index.cjs.map +1 -1
- package/dist/provenance/index.d.cts +7 -7
- package/dist/provenance/index.d.ts +7 -7
- package/dist/provenance/index.js +12 -14
- package/dist/provenance/index.js.map +1 -1
- package/dist/schema/index.cjs +50 -48
- package/dist/schema/index.d.cts +9 -16
- package/dist/schema/index.d.ts +9 -16
- package/dist/schema/index.js +23 -21
- package/dist/{searchable-DLWEfC4a.d.ts → searchable-9OQoPuRs.d.ts} +1 -2
- package/dist/{searchable-CIZL8Hyw.d.cts → searchable-CIje5XYD.d.cts} +1 -2
- package/dist/{sqlite-DY0WODUK.d.cts → sqlite-DerU5tc7.d.ts} +2029 -347
- package/dist/{sqlite-L-VIRzqA.d.ts → sqlite-DitnISa9.d.cts} +2029 -347
- package/dist/{store-view-A85FFRnk.d.cts → store-B0h6x7wo.d.cts} +1289 -767
- package/dist/{store-view-66p92IPi.d.ts → store-ClQ-MZQS.d.ts} +1289 -767
- package/dist/{temporal-BNbjXqer.d.cts → temporal-Bn-Fi8FJ.d.cts} +1 -1
- package/dist/{temporal-Bob6Nfbp.d.ts → temporal-BtM4UALv.d.ts} +1 -1
- package/dist/{types-DeORZhxn.d.cts → types-CoIx8HX5.d.cts} +1 -1
- package/dist/{types-Ch9a0Dx6.d.ts → types-HkveCCx0.d.cts} +726 -5
- package/dist/{types-Ch9a0Dx6.d.cts → types-HkveCCx0.d.ts} +726 -5
- package/dist/{types-ClCzT-dT.d.ts → types-KFfk-8Ah.d.ts} +1 -1
- package/dist/{where-DPw52ksb.d.cts → where--fk7_0kv.d.cts} +1 -1
- package/dist/{where-kWUZPvEA.d.ts → where-ws5hf-Ov.d.ts} +1 -1
- package/package.json +3 -3
- package/dist/chunk-2L54C2C2.js +0 -144
- package/dist/chunk-2L54C2C2.js.map +0 -1
- package/dist/chunk-35S6P5ZU.js +0 -27
- package/dist/chunk-35S6P5ZU.js.map +0 -1
- package/dist/chunk-42PYUGLS.js.map +0 -1
- package/dist/chunk-4GUBTVPV.js.map +0 -1
- package/dist/chunk-4GUTQPVO.js.map +0 -1
- package/dist/chunk-4MB3AQAQ.js.map +0 -1
- package/dist/chunk-4MEWSUVM.cjs.map +0 -1
- package/dist/chunk-4QIKLIGG.js.map +0 -1
- package/dist/chunk-4SZ6XPTG.cjs +0 -12
- package/dist/chunk-55ITBQJI.js.map +0 -1
- package/dist/chunk-5EKPX6QU.js.map +0 -1
- package/dist/chunk-6RYPD3NJ.cjs +0 -1282
- package/dist/chunk-6RYPD3NJ.cjs.map +0 -1
- package/dist/chunk-764JHTLT.cjs +0 -15
- package/dist/chunk-764JHTLT.cjs.map +0 -1
- package/dist/chunk-ACSVZPK7.cjs.map +0 -1
- package/dist/chunk-B3F2D3SP.cjs +0 -12
- package/dist/chunk-BGYJW37L.js.map +0 -1
- package/dist/chunk-BNS75YNF.cjs.map +0 -1
- package/dist/chunk-C4F7VJ5D.cjs.map +0 -1
- package/dist/chunk-CBKG6HEP.js +0 -1263
- package/dist/chunk-CBKG6HEP.js.map +0 -1
- package/dist/chunk-CPEL3YIR.cjs.map +0 -1
- package/dist/chunk-D54WH24V.cjs.map +0 -1
- package/dist/chunk-D56XG4EI.cjs.map +0 -1
- package/dist/chunk-D7PG5D5K.js.map +0 -1
- package/dist/chunk-DI74SMXS.cjs +0 -29
- package/dist/chunk-DI74SMXS.cjs.map +0 -1
- package/dist/chunk-DK2S42XB.js +0 -77
- package/dist/chunk-DK2S42XB.js.map +0 -1
- package/dist/chunk-DRACN6XG.js +0 -27
- package/dist/chunk-DRACN6XG.js.map +0 -1
- package/dist/chunk-DXEEHSGN.js.map +0 -1
- package/dist/chunk-EKFUG4G7.cjs.map +0 -1
- package/dist/chunk-EQ7JKLZO.cjs +0 -157
- package/dist/chunk-EQ7JKLZO.cjs.map +0 -1
- package/dist/chunk-FJMPR3OH.cjs.map +0 -1
- package/dist/chunk-FLEQ2HBK.js.map +0 -1
- package/dist/chunk-FQ7ZPOTZ.js.map +0 -1
- package/dist/chunk-G6Q5UM7U.js.map +0 -1
- package/dist/chunk-GYA4JRP5.js.map +0 -1
- package/dist/chunk-H7VE3FL4.cjs.map +0 -1
- package/dist/chunk-ID4WXTKL.js.map +0 -1
- package/dist/chunk-ISLPNELU.js.map +0 -1
- package/dist/chunk-ITE4IXAK.js +0 -25
- package/dist/chunk-ITE4IXAK.js.map +0 -1
- package/dist/chunk-IX64T5OL.cjs.map +0 -1
- package/dist/chunk-J2ICGNHO.cjs.map +0 -1
- package/dist/chunk-J7LXTUTP.cjs.map +0 -1
- package/dist/chunk-JQXSZHF2.cjs.map +0 -1
- package/dist/chunk-JXUTCSXX.cjs.map +0 -1
- package/dist/chunk-KCO5EFJU.js +0 -79
- package/dist/chunk-KCO5EFJU.js.map +0 -1
- package/dist/chunk-KKYELPZ2.cjs +0 -83
- package/dist/chunk-KKYELPZ2.cjs.map +0 -1
- package/dist/chunk-KMXWZLQX.cjs.map +0 -1
- package/dist/chunk-MIJKEVV7.js.map +0 -1
- package/dist/chunk-NAAMUYMS.cjs.map +0 -1
- package/dist/chunk-P7GTYOLB.cjs.map +0 -1
- package/dist/chunk-PVUI6KGR.js.map +0 -1
- package/dist/chunk-Q6EDCUXV.js.map +0 -1
- package/dist/chunk-QB6VMOJ2.cjs.map +0 -1
- package/dist/chunk-QC4MCOFV.cjs +0 -83
- package/dist/chunk-QC4MCOFV.cjs.map +0 -1
- package/dist/chunk-QMQLUA66.js +0 -12
- package/dist/chunk-QMQLUA66.js.map +0 -1
- package/dist/chunk-QRNYDV5Z.js.map +0 -1
- package/dist/chunk-RFRM3Q5K.js.map +0 -1
- package/dist/chunk-RUQS6M7G.js.map +0 -1
- package/dist/chunk-S4KQ5LV4.js.map +0 -1
- package/dist/chunk-SJDMVITW.cjs.map +0 -1
- package/dist/chunk-SNXVDZAJ.js.map +0 -1
- package/dist/chunk-SVJ5GEXW.cjs.map +0 -1
- package/dist/chunk-TDXIBCGY.cjs.map +0 -1
- package/dist/chunk-TKORQCG4.js.map +0 -1
- package/dist/chunk-TKP5T34P.js.map +0 -1
- package/dist/chunk-TRF4EBJT.cjs +0 -30
- package/dist/chunk-TRF4EBJT.cjs.map +0 -1
- package/dist/chunk-UCQ3BFSY.cjs.map +0 -1
- package/dist/chunk-UR7W5YQK.js.map +0 -1
- package/dist/chunk-V34A6R5V.js +0 -134
- package/dist/chunk-V34A6R5V.js.map +0 -1
- package/dist/chunk-WDAVPX46.js +0 -81
- package/dist/chunk-WDAVPX46.js.map +0 -1
- package/dist/chunk-WDBXJOU5.cjs.map +0 -1
- package/dist/chunk-YDWLUT5V.cjs.map +0 -1
- package/dist/chunk-YOALGKRE.cjs.map +0 -1
- package/dist/chunk-Z3WO6MND.cjs.map +0 -1
- package/dist/chunk-ZDH3DX3C.cjs +0 -30
- package/dist/chunk-ZDH3DX3C.cjs.map +0 -1
- package/dist/chunk-ZI6VQSZA.cjs.map +0 -1
- package/dist/chunk-ZTAJL4DT.cjs +0 -85
- package/dist/chunk-ZTAJL4DT.cjs.map +0 -1
- package/dist/define-graph-BGrJahvp.d.ts +0 -173
- package/dist/define-graph-alREY2wj.d.cts +0 -173
|
@@ -1,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 chunkQ3G6A4I3_cjs = require('./chunk-Q3G6A4I3.cjs');
|
|
4
|
+
var chunkDTVWX77L_cjs = require('./chunk-DTVWX77L.cjs');
|
|
5
|
+
var chunkPF6F5NLJ_cjs = require('./chunk-PF6F5NLJ.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 chunkMCLYU6BN_cjs = require('./chunk-MCLYU6BN.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 chunkDTVWX77L_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 chunkDTVWX77L_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 : chunkDTVWX77L_cjs.validateNodeProps(nodeKind.schema, input.props, {
|
|
408
437
|
kind,
|
|
409
438
|
operation: "create"
|
|
410
439
|
});
|
|
440
|
+
const validFrom = chunkMCLYU6BN_cjs.validateOptionalCanonicalIsoDate(
|
|
441
|
+
input.validFrom,
|
|
442
|
+
"validFrom"
|
|
443
|
+
);
|
|
444
|
+
const validTo = chunkMCLYU6BN_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo");
|
|
445
|
+
chunkMCLYU6BN_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 chunkQ3G6A4I3_cjs.checkUniquenessConstraints(
|
|
470
|
+
chunkQ3G6A4I3_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 chunkQ3G6A4I3_cjs.applyNodeInsertSideEffectsBatch(
|
|
503
|
+
chunkQ3G6A4I3_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 chunkQ3G6A4I3_cjs.applyNodeInsertSideEffects(
|
|
519
|
+
chunkQ3G6A4I3_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 = chunkDTVWX77L_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,113 @@ 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 validTo =
|
|
533
|
-
const
|
|
573
|
+
const validTo = chunkMCLYU6BN_cjs.validateOptionalCanonicalIsoDate(input.validTo, "validTo");
|
|
574
|
+
const resurrectionInstant = options?.clearDeleted === true && existing.deleted_at !== void 0 ? chunkMCLYU6BN_cjs.nowIso() : void 0;
|
|
575
|
+
const preservesLiveLowerBound = resurrectionInstant === void 0 && chunkMCLYU6BN_cjs.preservesImmutableLowerBound(input.onImmutableLowerBound);
|
|
576
|
+
const statedValidFrom = chunkMCLYU6BN_cjs.validateOptionalCanonicalIsoDate(
|
|
577
|
+
input.validFrom,
|
|
578
|
+
"validFrom"
|
|
579
|
+
);
|
|
580
|
+
const validFrom = preservesLiveLowerBound ? void 0 : statedValidFrom;
|
|
581
|
+
const windowVerdict = chunkMCLYU6BN_cjs.assertWritableValidityWindow(
|
|
582
|
+
`${kind} "${id}"`,
|
|
583
|
+
validFrom,
|
|
584
|
+
resurrectionInstant === void 0 ? {
|
|
585
|
+
effectiveValidFrom: existing.valid_from,
|
|
586
|
+
appliesStatedValidFrom: false,
|
|
587
|
+
effectiveBoundIsStored: true
|
|
588
|
+
} : {
|
|
589
|
+
effectiveValidFrom: resurrectionInstant,
|
|
590
|
+
appliesStatedValidFrom: true,
|
|
591
|
+
// The instant this write is about to stamp, not a bound the row holds.
|
|
592
|
+
effectiveBoundIsStored: false
|
|
593
|
+
},
|
|
594
|
+
validTo
|
|
595
|
+
);
|
|
596
|
+
const writeContext = chunkQ3G6A4I3_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock);
|
|
597
|
+
const effectiveValidFrom = validFrom ?? resurrectionInstant;
|
|
534
598
|
const shared = {
|
|
535
599
|
schema: nodeKind.schema,
|
|
536
600
|
validatedProps,
|
|
537
601
|
uniqueConstraints: registration.unique ?? [],
|
|
538
|
-
...
|
|
602
|
+
...effectiveValidFrom !== void 0 && { validFrom: effectiveValidFrom },
|
|
603
|
+
...validTo !== void 0 && { validTo },
|
|
604
|
+
// The bound the verdict above READ, carried into the UPDATE's own `WHERE`
|
|
605
|
+
// so the row this writes is the row that was judged. The verdict hands over
|
|
606
|
+
// the predicate rather than a flag, so both conditions that decide it — did
|
|
607
|
+
// the verdict consult the effective bound, and WAS that bound the row's
|
|
608
|
+
// stored one — are answered where they are known. A plain
|
|
609
|
+
// `update({ props })` states no window, reads no bound, and stays unfenced:
|
|
610
|
+
// the same rule `UpdateEdgeParams`'s identity components follow, for the
|
|
611
|
+
// same reason. The resurrecting leg is judged against `resurrectionInstant`
|
|
612
|
+
// and so fences on `deleted_at IS NOT NULL` alone, converging through the
|
|
613
|
+
// recovery below.
|
|
614
|
+
...windowVerdict.storedLowerBoundFence
|
|
539
615
|
};
|
|
540
616
|
if (options?.clearDeleted) {
|
|
541
|
-
const row2 = await
|
|
617
|
+
const row2 = await chunkQ3G6A4I3_cjs.applyNodeUpdate(
|
|
542
618
|
writeContext,
|
|
543
619
|
{ ...shared, existing, clearDeleted: true },
|
|
544
620
|
backend
|
|
545
621
|
);
|
|
546
622
|
return rowToNode(row2);
|
|
547
623
|
}
|
|
548
|
-
if (!
|
|
549
|
-
const row = await
|
|
624
|
+
if (!chunkXBYVV3MP_cjs.isLiveNodeRow(existing)) throw new chunkNI72YOJB_cjs.NodeNotFoundError(kind, id);
|
|
625
|
+
const row = await chunkQ3G6A4I3_cjs.applyNodeUpdate(
|
|
550
626
|
writeContext,
|
|
551
627
|
{ ...shared, existing },
|
|
552
628
|
backend
|
|
553
629
|
);
|
|
554
630
|
return rowToNode(row);
|
|
555
631
|
}
|
|
632
|
+
var NODE_UPDATE_ATTEMPTS = 2;
|
|
633
|
+
async function performNodeUpdateWithResurrectionRecovery(ctx, input, target, lock, options) {
|
|
634
|
+
for (let attempt = 1; attempt <= NODE_UPDATE_ATTEMPTS; attempt += 1) {
|
|
635
|
+
try {
|
|
636
|
+
return await performNodeUpdate(
|
|
637
|
+
ctx,
|
|
638
|
+
input,
|
|
639
|
+
target,
|
|
640
|
+
lock,
|
|
641
|
+
attempt === 1 ? options : void 0
|
|
642
|
+
);
|
|
643
|
+
} catch (error) {
|
|
644
|
+
if (!isNodeUpdateNoRowError(error) || attempt === NODE_UPDATE_ATTEMPTS) {
|
|
645
|
+
throw nodeUpdateRaceError(input, error);
|
|
646
|
+
}
|
|
647
|
+
const current = await target.getNode(ctx.graphId, input.kind, input.id);
|
|
648
|
+
if (current === void 0 || current.deleted_at !== void 0) {
|
|
649
|
+
throw new chunkNI72YOJB_cjs.NodeNotFoundError(input.kind, input.id);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
throw new chunkNI72YOJB_cjs.NodeNotFoundError(input.kind, input.id);
|
|
654
|
+
}
|
|
655
|
+
function nodeUpdateRaceError(input, error) {
|
|
656
|
+
if (!isNodeUpdateNoRowError(error)) return error;
|
|
657
|
+
return new chunkNI72YOJB_cjs.DatabaseOperationError(
|
|
658
|
+
`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.`,
|
|
659
|
+
{
|
|
660
|
+
operation: "update",
|
|
661
|
+
entity: "node",
|
|
662
|
+
attempted: [{ kind: input.kind, id: input.id }]
|
|
663
|
+
},
|
|
664
|
+
{ cause: error }
|
|
665
|
+
);
|
|
666
|
+
}
|
|
556
667
|
async function primeBatchValidationCaches(ctx, drafts, backend, seams) {
|
|
557
668
|
if (backend.getNodes !== void 0) {
|
|
558
669
|
const idsByKind = /* @__PURE__ */ new Map();
|
|
@@ -574,19 +685,19 @@ async function primeBatchValidationCaches(ctx, drafts, backend, seams) {
|
|
|
574
685
|
const groups = /* @__PURE__ */ new Map();
|
|
575
686
|
for (const draft of drafts) {
|
|
576
687
|
for (const constraint of draft.uniqueConstraints) {
|
|
577
|
-
if (!
|
|
578
|
-
const key =
|
|
688
|
+
if (!chunkE4WNQBEF_cjs.checkWherePredicate(constraint, draft.validatedProps)) continue;
|
|
689
|
+
const key = chunkE4WNQBEF_cjs.computeUniqueKey(
|
|
579
690
|
draft.validatedProps,
|
|
580
691
|
constraint.fields,
|
|
581
692
|
constraint.collation
|
|
582
693
|
);
|
|
583
|
-
const kindsToCheck =
|
|
694
|
+
const kindsToCheck = chunkE4WNQBEF_cjs.getKindsForUniquenessCheck(
|
|
584
695
|
draft.kind,
|
|
585
696
|
constraint.scope,
|
|
586
697
|
ctx.registry
|
|
587
698
|
);
|
|
588
699
|
for (const kindToCheck of kindsToCheck) {
|
|
589
|
-
const groupKey = kindToCheck
|
|
700
|
+
const groupKey = chunkDTVWX77L_cjs.encodeTupleKey([kindToCheck, constraint.name]);
|
|
590
701
|
const group = groups.get(groupKey) ?? {
|
|
591
702
|
nodeKind: kindToCheck,
|
|
592
703
|
constraintName: constraint.name,
|
|
@@ -626,7 +737,7 @@ async function prepareBatchCreates(ctx, inputs, backend, options) {
|
|
|
626
737
|
seedUniqueRow
|
|
627
738
|
} = createNodeBatchValidationBackend(ctx.graphId, ctx.registry, backend);
|
|
628
739
|
const drafts = inputs.map(
|
|
629
|
-
(input) => draftNodeCreate(ctx, input, input.id ??
|
|
740
|
+
(input) => draftNodeCreate(ctx, input, input.id ?? chunkPF6F5NLJ_cjs.generateId(), options)
|
|
630
741
|
);
|
|
631
742
|
await primeBatchValidationCaches(ctx, drafts, backend, {
|
|
632
743
|
seedNodeRow,
|
|
@@ -648,10 +759,60 @@ async function prepareBatchCreates(ctx, inputs, backend, options) {
|
|
|
648
759
|
prepared.uniqueConstraints
|
|
649
760
|
);
|
|
650
761
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
762
|
+
return preparedCreates;
|
|
763
|
+
}
|
|
764
|
+
function partitionCreates(preparedCreates) {
|
|
765
|
+
const inserts = [];
|
|
766
|
+
const resurrections = [];
|
|
767
|
+
for (const prepared of preparedCreates) {
|
|
768
|
+
if (prepared.tombstone === void 0) {
|
|
769
|
+
inserts.push(prepared);
|
|
770
|
+
} else {
|
|
771
|
+
resurrections.push(prepared);
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
return { inserts, resurrections };
|
|
775
|
+
}
|
|
776
|
+
function isNodeUpdateNoRowError(error) {
|
|
777
|
+
return error instanceof chunkNI72YOJB_cjs.DatabaseOperationError && error.details.operation === "update" && error.details.entity === "node" && error.details.reason === "no_row_returned";
|
|
778
|
+
}
|
|
779
|
+
async function resurrectPreparedNode(ctx, target, lock, prepared) {
|
|
780
|
+
const current = await target.getNode(ctx.graphId, prepared.kind, prepared.id);
|
|
781
|
+
if (current === void 0) {
|
|
782
|
+
throw new chunkNI72YOJB_cjs.DatabaseOperationError(
|
|
783
|
+
`Node tombstone disappeared before resurrection: ${prepared.kind} ${prepared.id}`,
|
|
784
|
+
{ operation: "update", entity: "node" }
|
|
785
|
+
);
|
|
786
|
+
}
|
|
787
|
+
if (current.deleted_at === void 0) {
|
|
788
|
+
throw createAlreadyExistsError("node", prepared.kind, prepared.id);
|
|
789
|
+
}
|
|
790
|
+
try {
|
|
791
|
+
return await chunkQ3G6A4I3_cjs.applyNodeUpdate(
|
|
792
|
+
chunkQ3G6A4I3_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
|
|
793
|
+
{
|
|
794
|
+
existing: current,
|
|
795
|
+
clearDeleted: true,
|
|
796
|
+
schema: prepared.nodeKind.schema,
|
|
797
|
+
validatedProps: prepared.validatedProps,
|
|
798
|
+
uniqueConstraints: prepared.uniqueConstraints,
|
|
799
|
+
...prepared.insertParams.validFrom === void 0 ? {} : { validFrom: prepared.insertParams.validFrom },
|
|
800
|
+
...prepared.insertParams.validTo === void 0 ? {} : { validTo: prepared.insertParams.validTo }
|
|
801
|
+
},
|
|
802
|
+
target
|
|
803
|
+
);
|
|
804
|
+
} catch (error) {
|
|
805
|
+
if (!isNodeUpdateNoRowError(error)) throw error;
|
|
806
|
+
const afterFailure = await target.getNode(
|
|
807
|
+
ctx.graphId,
|
|
808
|
+
prepared.kind,
|
|
809
|
+
prepared.id
|
|
810
|
+
);
|
|
811
|
+
if (afterFailure !== void 0 && afterFailure.deleted_at === void 0) {
|
|
812
|
+
throw createAlreadyExistsError("node", prepared.kind, prepared.id);
|
|
813
|
+
}
|
|
814
|
+
throw error;
|
|
815
|
+
}
|
|
655
816
|
}
|
|
656
817
|
async function findUniqueRowAcrossKinds(backend, graphId, constraintName, key, kindsToCheck, includeDeleted) {
|
|
657
818
|
for (const kindToCheck of kindsToCheck) {
|
|
@@ -702,14 +863,16 @@ async function batchCheckUniqueAcrossKinds(backend, graphId, constraintName, uni
|
|
|
702
863
|
}
|
|
703
864
|
async function executeNodeCreateInternal(ctx, input, backend, options) {
|
|
704
865
|
const kind = input.kind;
|
|
705
|
-
const id = input.id ??
|
|
866
|
+
const id = input.id ?? chunkPF6F5NLJ_cjs.generateId();
|
|
706
867
|
const opContext = ctx.createOperationContext("create", "node", kind, id);
|
|
707
868
|
const shouldReturnRow = options?.returnRow ?? true;
|
|
708
|
-
return runHookedWriteOperation(
|
|
869
|
+
return chunkDTVWX77L_cjs.runHookedWriteOperation(
|
|
709
870
|
ctx,
|
|
710
871
|
opContext,
|
|
711
872
|
backend,
|
|
712
873
|
async (target, lock) => {
|
|
874
|
+
const identity = ctx.identity;
|
|
875
|
+
if (identity !== void 0) await identity.lock(target);
|
|
713
876
|
const prepared = await validateAndPrepareNodeCreate(
|
|
714
877
|
ctx,
|
|
715
878
|
input,
|
|
@@ -717,18 +880,36 @@ async function executeNodeCreateInternal(ctx, input, backend, options) {
|
|
|
717
880
|
target,
|
|
718
881
|
options
|
|
719
882
|
);
|
|
720
|
-
|
|
721
|
-
if (
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
prepared
|
|
883
|
+
const existing = prepared.tombstone;
|
|
884
|
+
if (existing !== void 0) {
|
|
885
|
+
const resurrected = await resurrectPreparedNode(
|
|
886
|
+
ctx,
|
|
887
|
+
target,
|
|
888
|
+
lock,
|
|
889
|
+
prepared
|
|
727
890
|
);
|
|
891
|
+
if (identity !== void 0) {
|
|
892
|
+
await identity.foldCreated(target, foldReferences([prepared]));
|
|
893
|
+
}
|
|
894
|
+
return shouldReturnRow ? rowToNode(resurrected) : void 0;
|
|
728
895
|
}
|
|
896
|
+
const row = await withAlreadyExistsTranslation("node", async () => {
|
|
897
|
+
if (shouldReturnRow) return target.insertNode(prepared.insertParams);
|
|
898
|
+
await chunkPF6F5NLJ_cjs.runInsertNoReturn(
|
|
899
|
+
chunkPF6F5NLJ_cjs.nodeInsertDispatch(target),
|
|
900
|
+
prepared.insertParams
|
|
901
|
+
);
|
|
902
|
+
return;
|
|
903
|
+
});
|
|
729
904
|
await finalizeNodeCreate(ctx, prepared, target, lock);
|
|
905
|
+
if (identity !== void 0) {
|
|
906
|
+
await identity.foldCreated(target, foldReferences([prepared]));
|
|
907
|
+
}
|
|
730
908
|
if (row === void 0) return;
|
|
731
909
|
return rowToNode(row);
|
|
910
|
+
},
|
|
911
|
+
{
|
|
912
|
+
fencesConstraintProbe: nodeFencesConstraintProbe(ctx, kind, "create")
|
|
732
913
|
}
|
|
733
914
|
);
|
|
734
915
|
}
|
|
@@ -738,7 +919,7 @@ async function executeNodeCreate(ctx, input, backend, options) {
|
|
|
738
919
|
...options
|
|
739
920
|
});
|
|
740
921
|
if (!result) {
|
|
741
|
-
throw new
|
|
922
|
+
throw new chunkNI72YOJB_cjs.DatabaseOperationError(
|
|
742
923
|
"Node create failed: expected created node row",
|
|
743
924
|
{ operation: "insert", entity: "node" }
|
|
744
925
|
);
|
|
@@ -747,32 +928,92 @@ async function executeNodeCreate(ctx, input, backend, options) {
|
|
|
747
928
|
}
|
|
748
929
|
async function executeNodeCreateNoReturnBatch(ctx, inputs, backend) {
|
|
749
930
|
if (inputs.length === 0) return;
|
|
750
|
-
await runInWriteTransaction(
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
931
|
+
await chunkDTVWX77L_cjs.runInWriteTransaction(
|
|
932
|
+
ctx,
|
|
933
|
+
backend,
|
|
934
|
+
async (target, lock) => {
|
|
935
|
+
const identity = ctx.identity;
|
|
936
|
+
if (identity !== void 0) await identity.lock(target);
|
|
937
|
+
const preparedCreates = await prepareBatchCreates(ctx, inputs, target);
|
|
938
|
+
const partition = partitionCreates(preparedCreates);
|
|
939
|
+
await withAlreadyExistsTranslation(
|
|
940
|
+
"node",
|
|
941
|
+
() => chunkPF6F5NLJ_cjs.runInsertBatch(
|
|
942
|
+
chunkPF6F5NLJ_cjs.nodeInsertDispatch(target),
|
|
943
|
+
partition.inserts.map((prepared) => prepared.insertParams)
|
|
944
|
+
)
|
|
945
|
+
);
|
|
946
|
+
for (const prepared of partition.resurrections) {
|
|
947
|
+
await resurrectPreparedNode(ctx, target, lock, prepared);
|
|
948
|
+
}
|
|
949
|
+
await finalizeNodeCreateBatch(ctx, partition.inserts, target, lock);
|
|
950
|
+
if (identity !== void 0) {
|
|
951
|
+
await identity.foldCreated(target, foldReferences(preparedCreates));
|
|
952
|
+
}
|
|
953
|
+
},
|
|
954
|
+
{
|
|
955
|
+
fencesConstraintProbe: nodeBatchFencesConstraintProbe(
|
|
956
|
+
ctx,
|
|
957
|
+
inputs,
|
|
958
|
+
"create"
|
|
959
|
+
)
|
|
960
|
+
}
|
|
961
|
+
);
|
|
759
962
|
}
|
|
760
963
|
async function executeNodeCreateBatch(ctx, inputs, backend, options) {
|
|
761
964
|
if (inputs.length === 0) return [];
|
|
762
|
-
return runInWriteTransaction(
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
965
|
+
return chunkDTVWX77L_cjs.runInWriteTransaction(
|
|
966
|
+
ctx,
|
|
967
|
+
backend,
|
|
968
|
+
async (target, lock) => {
|
|
969
|
+
const identity = ctx.identity;
|
|
970
|
+
if (identity !== void 0) await identity.lock(target);
|
|
971
|
+
const preparedCreates = await prepareBatchCreates(
|
|
972
|
+
ctx,
|
|
973
|
+
inputs,
|
|
974
|
+
target,
|
|
975
|
+
options
|
|
976
|
+
);
|
|
977
|
+
const partition = partitionCreates(preparedCreates);
|
|
978
|
+
const inserted = await withAlreadyExistsTranslation(
|
|
979
|
+
"node",
|
|
980
|
+
() => chunkPF6F5NLJ_cjs.runInsertBatchReturning(
|
|
981
|
+
chunkPF6F5NLJ_cjs.nodeInsertDispatch(target),
|
|
982
|
+
partition.inserts.map((prepared) => prepared.insertParams)
|
|
983
|
+
)
|
|
984
|
+
);
|
|
985
|
+
const resurrected = [];
|
|
986
|
+
for (const prepared of partition.resurrections) {
|
|
987
|
+
resurrected.push(
|
|
988
|
+
await resurrectPreparedNode(ctx, target, lock, prepared)
|
|
989
|
+
);
|
|
990
|
+
}
|
|
991
|
+
await finalizeNodeCreateBatch(ctx, partition.inserts, target, lock);
|
|
992
|
+
const byReference = new Map(
|
|
993
|
+
[...inserted, ...resurrected].map((row) => [
|
|
994
|
+
chunkDTVWX77L_cjs.refKey({ kind: row.kind, id: row.id }),
|
|
995
|
+
row
|
|
996
|
+
])
|
|
997
|
+
);
|
|
998
|
+
const rows = preparedCreates.map(
|
|
999
|
+
(prepared) => chunkN66HCGCY_cjs.requireDefined(
|
|
1000
|
+
byReference.get(chunkDTVWX77L_cjs.refKey({ kind: prepared.kind, id: prepared.id })),
|
|
1001
|
+
`Missing written row for ${prepared.kind} ${prepared.id}`
|
|
1002
|
+
)
|
|
1003
|
+
);
|
|
1004
|
+
if (identity !== void 0) {
|
|
1005
|
+
await identity.foldCreated(target, foldReferences(preparedCreates));
|
|
1006
|
+
}
|
|
1007
|
+
return rows.map((row) => rowToNode(row));
|
|
1008
|
+
},
|
|
1009
|
+
{
|
|
1010
|
+
fencesConstraintProbe: nodeBatchFencesConstraintProbe(
|
|
1011
|
+
ctx,
|
|
1012
|
+
inputs,
|
|
1013
|
+
"create"
|
|
1014
|
+
)
|
|
1015
|
+
}
|
|
1016
|
+
);
|
|
776
1017
|
}
|
|
777
1018
|
async function executeNodeUpdate(ctx, input, backend, options) {
|
|
778
1019
|
const opContext = ctx.createOperationContext(
|
|
@@ -781,11 +1022,36 @@ async function executeNodeUpdate(ctx, input, backend, options) {
|
|
|
781
1022
|
input.kind,
|
|
782
1023
|
input.id
|
|
783
1024
|
);
|
|
784
|
-
return runHookedWriteOperation(
|
|
1025
|
+
return chunkDTVWX77L_cjs.runHookedWriteOperation(
|
|
785
1026
|
ctx,
|
|
786
1027
|
opContext,
|
|
787
1028
|
backend,
|
|
788
|
-
(target, lock) =>
|
|
1029
|
+
async (target, lock) => {
|
|
1030
|
+
const identity = ctx.identity;
|
|
1031
|
+
if (options?.clearDeleted && identity !== void 0) {
|
|
1032
|
+
await identity.lock(target);
|
|
1033
|
+
}
|
|
1034
|
+
const node = await performNodeUpdateWithResurrectionRecovery(
|
|
1035
|
+
ctx,
|
|
1036
|
+
input,
|
|
1037
|
+
target,
|
|
1038
|
+
lock,
|
|
1039
|
+
options
|
|
1040
|
+
);
|
|
1041
|
+
if (options?.clearDeleted && identity !== void 0) {
|
|
1042
|
+
await identity.foldCreated(target, [
|
|
1043
|
+
{ kind: input.kind, id: input.id }
|
|
1044
|
+
]);
|
|
1045
|
+
}
|
|
1046
|
+
return node;
|
|
1047
|
+
},
|
|
1048
|
+
{
|
|
1049
|
+
fencesConstraintProbe: nodeFencesConstraintProbe(
|
|
1050
|
+
ctx,
|
|
1051
|
+
input.kind,
|
|
1052
|
+
"update"
|
|
1053
|
+
)
|
|
1054
|
+
}
|
|
789
1055
|
);
|
|
790
1056
|
}
|
|
791
1057
|
async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candidateIdColumn, backend) {
|
|
@@ -793,19 +1059,19 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
|
|
|
793
1059
|
const schema = registration.type.schema;
|
|
794
1060
|
const uniqueConstraints = registration.unique ?? [];
|
|
795
1061
|
if (!backend.capabilities.transactions) {
|
|
796
|
-
throw new
|
|
1062
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
797
1063
|
"updateWhere() requires a transactional backend so validation and sidecars are atomic",
|
|
798
1064
|
{ code: "SET_UPDATE_TRANSACTIONS_REQUIRED", kind }
|
|
799
1065
|
);
|
|
800
1066
|
}
|
|
801
1067
|
if (backend.updateNodeSet === void 0) {
|
|
802
|
-
throw new
|
|
1068
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
803
1069
|
"This backend does not support set-based node updates",
|
|
804
1070
|
{ code: "SET_UPDATE_UNSUPPORTED", kind }
|
|
805
1071
|
);
|
|
806
1072
|
}
|
|
807
1073
|
if (Object.keys(inputPatch).length === 0) {
|
|
808
|
-
throw new
|
|
1074
|
+
throw new chunkNI72YOJB_cjs.ValidationError("updateWhere() patch must not be empty", {
|
|
809
1075
|
entityType: "node",
|
|
810
1076
|
kind,
|
|
811
1077
|
operation: "update",
|
|
@@ -816,7 +1082,7 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
|
|
|
816
1082
|
(property) => !Object.hasOwn(schema.shape, property)
|
|
817
1083
|
);
|
|
818
1084
|
if (unknownProperty !== void 0) {
|
|
819
|
-
throw new
|
|
1085
|
+
throw new chunkNI72YOJB_cjs.ValidationError(
|
|
820
1086
|
`Unknown ${kind} property in updateWhere() patch: ${unknownProperty}`,
|
|
821
1087
|
{
|
|
822
1088
|
entityType: "node",
|
|
@@ -831,22 +1097,22 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
|
|
|
831
1097
|
}
|
|
832
1098
|
);
|
|
833
1099
|
}
|
|
834
|
-
const parsedPatch =
|
|
1100
|
+
const parsedPatch = chunkDTVWX77L_cjs.validateNodeProps(schema.partial(), inputPatch, {
|
|
835
1101
|
kind,
|
|
836
1102
|
operation: "update"
|
|
837
1103
|
});
|
|
838
|
-
const patch =
|
|
1104
|
+
const patch = chunkN66HCGCY_cjs.createDataKeyedBag();
|
|
839
1105
|
const unsetProperties = [];
|
|
840
1106
|
for (const [property, value] of Object.entries(parsedPatch)) {
|
|
841
1107
|
if (value === void 0) {
|
|
842
1108
|
unsetProperties.push(property);
|
|
843
1109
|
continue;
|
|
844
1110
|
}
|
|
845
|
-
|
|
1111
|
+
chunkLBJKZXDE_cjs.assertJsonValue(value, property, `Node "${kind}" updateWhere patch`);
|
|
846
1112
|
patch[property] = value;
|
|
847
1113
|
}
|
|
848
1114
|
if (Object.keys(patch).length === 0 && unsetProperties.length === 0) {
|
|
849
|
-
throw new
|
|
1115
|
+
throw new chunkNI72YOJB_cjs.ValidationError(
|
|
850
1116
|
"updateWhere() patch has no recognized properties",
|
|
851
1117
|
{
|
|
852
1118
|
entityType: "node",
|
|
@@ -859,19 +1125,19 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
|
|
|
859
1125
|
);
|
|
860
1126
|
}
|
|
861
1127
|
if (uniqueConstraints.length > 0 && (backend.hardDeleteUniquesByNodeIds === void 0 || backend.insertUniqueBatch === void 0 || backend.checkUniqueBatch === void 0)) {
|
|
862
|
-
throw new
|
|
1128
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
863
1129
|
"updateWhere() requires batched uniqueness sidecar operations for constrained nodes",
|
|
864
1130
|
{ code: "SET_UPDATE_UNIQUENESS_UNSUPPORTED", kind }
|
|
865
1131
|
);
|
|
866
1132
|
}
|
|
867
1133
|
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
|
|
1134
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
869
1135
|
"updateWhere() requires batched fulltext sidecar operations for searchable nodes",
|
|
870
1136
|
{ code: "SET_UPDATE_FULLTEXT_UNSUPPORTED", kind }
|
|
871
1137
|
);
|
|
872
1138
|
}
|
|
873
|
-
if (
|
|
874
|
-
throw new
|
|
1139
|
+
if (chunkQ3G6A4I3_cjs.getEmbeddingFields(schema).length > 0 && (backend.upsertEmbedding === void 0 || backend.deleteEmbedding === void 0 || backend.upsertEmbeddingBatch === void 0 || backend.deleteEmbeddingBatch === void 0)) {
|
|
1140
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
875
1141
|
"updateWhere() requires batched vector sidecar operations for embedded nodes",
|
|
876
1142
|
{ code: "SET_UPDATE_VECTOR_UNSUPPORTED", kind }
|
|
877
1143
|
);
|
|
@@ -879,32 +1145,32 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
|
|
|
879
1145
|
const hookContext = ctx.createBulkOperationContext("updateWhere", kind);
|
|
880
1146
|
return ctx.withBulkOperationHooks(
|
|
881
1147
|
hookContext,
|
|
882
|
-
() => runInWriteTransaction(
|
|
1148
|
+
() => chunkDTVWX77L_cjs.runInWriteTransaction(
|
|
883
1149
|
ctx,
|
|
884
1150
|
backend,
|
|
885
1151
|
async (target, lock) => {
|
|
886
1152
|
const updateNodeSet = target.updateNodeSet;
|
|
887
1153
|
if (updateNodeSet === void 0) {
|
|
888
|
-
throw new
|
|
1154
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
889
1155
|
"The transaction backend does not support set-based node updates",
|
|
890
1156
|
{ code: "SET_UPDATE_UNSUPPORTED", kind }
|
|
891
1157
|
);
|
|
892
1158
|
}
|
|
893
1159
|
const hardDeleteUniquesByNodeIds = target.hardDeleteUniquesByNodeIds;
|
|
894
1160
|
if (uniqueConstraints.length > 0 && (hardDeleteUniquesByNodeIds === void 0 || target.insertUniqueBatch === void 0 || target.checkUniqueBatch === void 0)) {
|
|
895
|
-
throw new
|
|
1161
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
896
1162
|
"The transaction backend lacks batched uniqueness operations",
|
|
897
1163
|
{ code: "SET_UPDATE_UNIQUENESS_UNSUPPORTED", kind }
|
|
898
1164
|
);
|
|
899
1165
|
}
|
|
900
1166
|
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
|
|
1167
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
902
1168
|
"The transaction backend lacks batched fulltext operations",
|
|
903
1169
|
{ code: "SET_UPDATE_FULLTEXT_UNSUPPORTED", kind }
|
|
904
1170
|
);
|
|
905
1171
|
}
|
|
906
|
-
if (
|
|
907
|
-
throw new
|
|
1172
|
+
if (chunkQ3G6A4I3_cjs.getEmbeddingFields(schema).length > 0 && (target.upsertEmbedding === void 0 || target.deleteEmbedding === void 0 || target.upsertEmbeddingBatch === void 0 || target.deleteEmbeddingBatch === void 0)) {
|
|
1173
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
908
1174
|
"The transaction backend lacks batched vector operations",
|
|
909
1175
|
{ code: "SET_UPDATE_VECTOR_UNSUPPORTED", kind }
|
|
910
1176
|
);
|
|
@@ -919,14 +1185,14 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
|
|
|
919
1185
|
});
|
|
920
1186
|
if (result.affectedCount === 0) return { affectedCount: 0 };
|
|
921
1187
|
const sidecarItems = result.rows.map((row) => {
|
|
922
|
-
const props =
|
|
923
|
-
const validatedProps =
|
|
1188
|
+
const props = chunkXBYVV3MP_cjs.rowPropsToObject(row.props);
|
|
1189
|
+
const validatedProps = chunkDTVWX77L_cjs.validateNodeProps(schema, props, {
|
|
924
1190
|
kind,
|
|
925
1191
|
operation: "update",
|
|
926
1192
|
id: row.id
|
|
927
1193
|
});
|
|
928
|
-
if (!
|
|
929
|
-
throw new
|
|
1194
|
+
if (!chunkPWLJ77UV_cjs.canonicalEqual(validatedProps, props)) {
|
|
1195
|
+
throw new chunkNI72YOJB_cjs.ValidationError(
|
|
930
1196
|
`Set update would persist a non-canonical ${kind} row`,
|
|
931
1197
|
{
|
|
932
1198
|
entityType: "node",
|
|
@@ -955,15 +1221,15 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
|
|
|
955
1221
|
for (const constraint of uniqueConstraints) {
|
|
956
1222
|
const keyToId = /* @__PURE__ */ new Map();
|
|
957
1223
|
for (const item of sidecarItems) {
|
|
958
|
-
if (!
|
|
959
|
-
const key =
|
|
1224
|
+
if (!chunkE4WNQBEF_cjs.checkWherePredicate(constraint, item.props)) continue;
|
|
1225
|
+
const key = chunkE4WNQBEF_cjs.computeUniqueKey(
|
|
960
1226
|
item.props,
|
|
961
1227
|
constraint.fields,
|
|
962
1228
|
constraint.collation
|
|
963
1229
|
);
|
|
964
1230
|
const priorId = keyToId.get(key);
|
|
965
1231
|
if (priorId !== void 0 && priorId !== item.id) {
|
|
966
|
-
throw new
|
|
1232
|
+
throw new chunkNI72YOJB_cjs.UniquenessError({
|
|
967
1233
|
constraintName: constraint.name,
|
|
968
1234
|
kind,
|
|
969
1235
|
existingId: priorId,
|
|
@@ -975,12 +1241,12 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
|
|
|
975
1241
|
}
|
|
976
1242
|
const keys = [...keyToId.keys()];
|
|
977
1243
|
if (keys.length === 0) continue;
|
|
978
|
-
for (const kindToCheck of
|
|
1244
|
+
for (const kindToCheck of chunkE4WNQBEF_cjs.getKindsForUniquenessCheck(
|
|
979
1245
|
kind,
|
|
980
1246
|
constraint.scope,
|
|
981
1247
|
ctx.registry
|
|
982
1248
|
)) {
|
|
983
|
-
const existingRows = await
|
|
1249
|
+
const existingRows = await chunkN66HCGCY_cjs.requireDefined(
|
|
984
1250
|
target.checkUniqueBatch
|
|
985
1251
|
)({
|
|
986
1252
|
graphId: ctx.graphId,
|
|
@@ -992,54 +1258,87 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
|
|
|
992
1258
|
if (existing.concrete_kind === kind && affectedIds.has(existing.node_id)) {
|
|
993
1259
|
continue;
|
|
994
1260
|
}
|
|
995
|
-
throw new
|
|
1261
|
+
throw new chunkNI72YOJB_cjs.UniquenessError({
|
|
996
1262
|
constraintName: constraint.name,
|
|
997
1263
|
kind: kindToCheck,
|
|
998
1264
|
existingId: existing.node_id,
|
|
999
|
-
newId:
|
|
1265
|
+
newId: chunkN66HCGCY_cjs.requireDefined(keyToId.get(existing.key)),
|
|
1000
1266
|
fields: constraint.fields
|
|
1001
1267
|
});
|
|
1002
1268
|
}
|
|
1003
1269
|
}
|
|
1004
1270
|
}
|
|
1005
|
-
await
|
|
1271
|
+
await chunkN66HCGCY_cjs.requireDefined(hardDeleteUniquesByNodeIds)({
|
|
1006
1272
|
graphId: ctx.graphId,
|
|
1007
1273
|
concreteKind: kind,
|
|
1008
1274
|
nodeIds: result.rows.map((row) => row.id)
|
|
1009
1275
|
});
|
|
1010
1276
|
}
|
|
1011
|
-
await
|
|
1012
|
-
|
|
1277
|
+
await chunkQ3G6A4I3_cjs.applyNodeInsertSideEffectsBatch(
|
|
1278
|
+
chunkQ3G6A4I3_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
|
|
1013
1279
|
sidecarItems,
|
|
1014
1280
|
target
|
|
1015
1281
|
);
|
|
1016
1282
|
return { affectedCount: result.affectedCount };
|
|
1017
1283
|
},
|
|
1018
|
-
{
|
|
1284
|
+
{
|
|
1285
|
+
didWrite: (result) => result.affectedCount > 0,
|
|
1286
|
+
// The set update re-checks every changed unique key across the
|
|
1287
|
+
// constraint's scope before rebuilding the sidecars, so a shared-scope
|
|
1288
|
+
// constraint makes it a constrained write like any other update.
|
|
1289
|
+
fencesConstraintProbe: nodeFencesConstraintProbe(ctx, kind, "update")
|
|
1290
|
+
}
|
|
1019
1291
|
)
|
|
1020
1292
|
);
|
|
1021
1293
|
}
|
|
1022
1294
|
async function executeNodeUpsertUpdate(ctx, input, backend, options) {
|
|
1023
|
-
return runInWriteTransaction(
|
|
1295
|
+
return chunkDTVWX77L_cjs.runInWriteTransaction(
|
|
1024
1296
|
ctx,
|
|
1025
1297
|
backend,
|
|
1026
|
-
(target, lock) =>
|
|
1298
|
+
async (target, lock) => {
|
|
1299
|
+
const identity = ctx.identity;
|
|
1300
|
+
if (options?.clearDeleted && identity !== void 0) {
|
|
1301
|
+
await identity.lock(target);
|
|
1302
|
+
}
|
|
1303
|
+
const node = await performNodeUpdateWithResurrectionRecovery(
|
|
1304
|
+
ctx,
|
|
1305
|
+
input,
|
|
1306
|
+
target,
|
|
1307
|
+
lock,
|
|
1308
|
+
options
|
|
1309
|
+
);
|
|
1310
|
+
if (options?.clearDeleted && identity !== void 0) {
|
|
1311
|
+
await identity.foldCreated(target, [
|
|
1312
|
+
{ kind: input.kind, id: input.id }
|
|
1313
|
+
]);
|
|
1314
|
+
}
|
|
1315
|
+
return node;
|
|
1316
|
+
},
|
|
1317
|
+
{
|
|
1318
|
+
fencesConstraintProbe: nodeFencesConstraintProbe(
|
|
1319
|
+
ctx,
|
|
1320
|
+
input.kind,
|
|
1321
|
+
"update"
|
|
1322
|
+
)
|
|
1323
|
+
}
|
|
1027
1324
|
);
|
|
1028
1325
|
}
|
|
1029
1326
|
async function executeNodeDelete(ctx, kind, id, backend) {
|
|
1030
1327
|
const gate = await backend.getNode(ctx.graphId, kind, id);
|
|
1031
1328
|
if (!gate || gate.deleted_at) return;
|
|
1032
1329
|
const opContext = ctx.createOperationContext("delete", "node", kind, id);
|
|
1033
|
-
return runHookedWriteOperation(
|
|
1330
|
+
return chunkDTVWX77L_cjs.runHookedWriteOperation(
|
|
1034
1331
|
ctx,
|
|
1035
1332
|
opContext,
|
|
1036
1333
|
backend,
|
|
1037
1334
|
async (target, lock) => {
|
|
1335
|
+
const identity = ctx.identity;
|
|
1336
|
+
if (identity !== void 0) await identity.lock(target);
|
|
1038
1337
|
const registration = getNodeRegistration(ctx.graph, kind);
|
|
1039
1338
|
const preflight = await target.getNode(ctx.graphId, kind, id);
|
|
1040
|
-
if (!preflight || !
|
|
1041
|
-
await
|
|
1042
|
-
|
|
1339
|
+
if (!preflight || !chunkXBYVV3MP_cjs.isLiveNodeRow(preflight)) return;
|
|
1340
|
+
await chunkQ3G6A4I3_cjs.applyNodeSoftDelete(
|
|
1341
|
+
chunkQ3G6A4I3_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
|
|
1043
1342
|
{
|
|
1044
1343
|
existing: preflight,
|
|
1045
1344
|
schema: registration.type.schema,
|
|
@@ -1048,21 +1347,63 @@ async function executeNodeDelete(ctx, kind, id, backend) {
|
|
|
1048
1347
|
},
|
|
1049
1348
|
target
|
|
1050
1349
|
);
|
|
1350
|
+
if (identity !== void 0) {
|
|
1351
|
+
await identity.detachDeleted(target, { kind, id }, "soft");
|
|
1352
|
+
}
|
|
1051
1353
|
}
|
|
1052
1354
|
);
|
|
1053
1355
|
}
|
|
1356
|
+
async function executeNodeDeleteBatch(ctx, kind, ids, backend) {
|
|
1357
|
+
await chunkDTVWX77L_cjs.runInWriteTransaction(
|
|
1358
|
+
ctx,
|
|
1359
|
+
backend,
|
|
1360
|
+
async (target, lock) => {
|
|
1361
|
+
const identity = ctx.identity;
|
|
1362
|
+
if (identity !== void 0) await identity.lock(target);
|
|
1363
|
+
const registration = getNodeRegistration(ctx.graph, kind);
|
|
1364
|
+
const writeContext = chunkQ3G6A4I3_cjs.createNodeWriteContext(
|
|
1365
|
+
ctx.graphId,
|
|
1366
|
+
ctx.registry,
|
|
1367
|
+
lock
|
|
1368
|
+
);
|
|
1369
|
+
let affectedCount = 0;
|
|
1370
|
+
for (const id of ids) {
|
|
1371
|
+
const preflight = await target.getNode(ctx.graphId, kind, id);
|
|
1372
|
+
if (!preflight || !chunkXBYVV3MP_cjs.isLiveNodeRow(preflight)) continue;
|
|
1373
|
+
await chunkQ3G6A4I3_cjs.applyNodeSoftDelete(
|
|
1374
|
+
writeContext,
|
|
1375
|
+
{
|
|
1376
|
+
existing: preflight,
|
|
1377
|
+
schema: registration.type.schema,
|
|
1378
|
+
uniqueConstraints: registration.unique ?? [],
|
|
1379
|
+
onDelete: registration.onDelete
|
|
1380
|
+
},
|
|
1381
|
+
target
|
|
1382
|
+
);
|
|
1383
|
+
if (identity !== void 0) {
|
|
1384
|
+
await identity.detachDeleted(target, { kind, id }, "soft");
|
|
1385
|
+
}
|
|
1386
|
+
affectedCount += 1;
|
|
1387
|
+
}
|
|
1388
|
+
return affectedCount;
|
|
1389
|
+
},
|
|
1390
|
+
{ didWrite: (affectedCount) => affectedCount > 0 }
|
|
1391
|
+
);
|
|
1392
|
+
}
|
|
1054
1393
|
async function executeNodeHardDelete(ctx, kind, id, backend) {
|
|
1055
1394
|
const gate = await backend.getNode(ctx.graphId, kind, id);
|
|
1056
1395
|
if (!gate) return;
|
|
1057
1396
|
const opContext = ctx.createOperationContext("delete", "node", kind, id);
|
|
1058
|
-
return runHookedWriteOperation(
|
|
1397
|
+
return chunkDTVWX77L_cjs.runHookedWriteOperation(
|
|
1059
1398
|
ctx,
|
|
1060
1399
|
opContext,
|
|
1061
1400
|
backend,
|
|
1062
1401
|
async (target, lock) => {
|
|
1402
|
+
const identity = ctx.identity;
|
|
1403
|
+
if (identity !== void 0) await identity.lock(target);
|
|
1063
1404
|
const registration = getNodeRegistration(ctx.graph, kind);
|
|
1064
|
-
await
|
|
1065
|
-
|
|
1405
|
+
await chunkQ3G6A4I3_cjs.applyNodeHardDelete(
|
|
1406
|
+
chunkQ3G6A4I3_cjs.createNodeWriteContext(ctx.graphId, ctx.registry, lock),
|
|
1066
1407
|
{
|
|
1067
1408
|
kind,
|
|
1068
1409
|
id,
|
|
@@ -1071,6 +1412,9 @@ async function executeNodeHardDelete(ctx, kind, id, backend) {
|
|
|
1071
1412
|
},
|
|
1072
1413
|
target
|
|
1073
1414
|
);
|
|
1415
|
+
if (identity !== void 0) {
|
|
1416
|
+
await identity.detachDeleted(target, { kind, id }, "hard");
|
|
1417
|
+
}
|
|
1074
1418
|
}
|
|
1075
1419
|
);
|
|
1076
1420
|
}
|
|
@@ -1078,12 +1422,12 @@ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, pro
|
|
|
1078
1422
|
const ifExists = options?.ifExists ?? "return";
|
|
1079
1423
|
const registration = getNodeRegistration(ctx.graph, kind);
|
|
1080
1424
|
const nodeKind = registration.type;
|
|
1081
|
-
const validatedProps =
|
|
1425
|
+
const validatedProps = chunkDTVWX77L_cjs.validateNodeProps(nodeKind.schema, props, {
|
|
1082
1426
|
kind,
|
|
1083
1427
|
operation: "create"
|
|
1084
1428
|
});
|
|
1085
1429
|
const constraint = resolveConstraint(ctx.graph, kind, constraintName);
|
|
1086
|
-
if (!
|
|
1430
|
+
if (!chunkE4WNQBEF_cjs.checkWherePredicate(constraint, validatedProps)) {
|
|
1087
1431
|
const node = await executeNodeCreate(
|
|
1088
1432
|
ctx,
|
|
1089
1433
|
{ kind, props: validatedProps },
|
|
@@ -1092,12 +1436,12 @@ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, pro
|
|
|
1092
1436
|
);
|
|
1093
1437
|
return { node, action: "created" };
|
|
1094
1438
|
}
|
|
1095
|
-
const key =
|
|
1439
|
+
const key = chunkE4WNQBEF_cjs.computeUniqueKey(
|
|
1096
1440
|
validatedProps,
|
|
1097
1441
|
constraint.fields,
|
|
1098
1442
|
constraint.collation
|
|
1099
1443
|
);
|
|
1100
|
-
const kindsToCheck =
|
|
1444
|
+
const kindsToCheck = chunkE4WNQBEF_cjs.getKindsForUniquenessCheck(
|
|
1101
1445
|
kind,
|
|
1102
1446
|
constraint.scope,
|
|
1103
1447
|
ctx.registry
|
|
@@ -1154,25 +1498,25 @@ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, pro
|
|
|
1154
1498
|
try {
|
|
1155
1499
|
return await attempt();
|
|
1156
1500
|
} catch (error) {
|
|
1157
|
-
if (!(error instanceof
|
|
1501
|
+
if (!(error instanceof chunkNI72YOJB_cjs.UniquenessError)) throw error;
|
|
1158
1502
|
return attempt();
|
|
1159
1503
|
}
|
|
1160
1504
|
}
|
|
1161
1505
|
async function executeNodeFindByConstraint(ctx, kind, constraintName, props, backend) {
|
|
1162
1506
|
const registration = getNodeRegistration(ctx.graph, kind);
|
|
1163
1507
|
const nodeKind = registration.type;
|
|
1164
|
-
const validatedProps =
|
|
1508
|
+
const validatedProps = chunkDTVWX77L_cjs.validateNodeProps(nodeKind.schema, props, {
|
|
1165
1509
|
kind,
|
|
1166
1510
|
operation: "create"
|
|
1167
1511
|
});
|
|
1168
1512
|
const constraint = resolveConstraint(ctx.graph, kind, constraintName);
|
|
1169
|
-
if (!
|
|
1170
|
-
const key =
|
|
1513
|
+
if (!chunkE4WNQBEF_cjs.checkWherePredicate(constraint, validatedProps)) return void 0;
|
|
1514
|
+
const key = chunkE4WNQBEF_cjs.computeUniqueKey(
|
|
1171
1515
|
validatedProps,
|
|
1172
1516
|
constraint.fields,
|
|
1173
1517
|
constraint.collation
|
|
1174
1518
|
);
|
|
1175
|
-
const kindsToCheck =
|
|
1519
|
+
const kindsToCheck = chunkE4WNQBEF_cjs.getKindsForUniquenessCheck(
|
|
1176
1520
|
kind,
|
|
1177
1521
|
constraint.scope,
|
|
1178
1522
|
ctx.registry
|
|
@@ -1198,12 +1542,12 @@ async function executeNodeFindByConstraint(ctx, kind, constraintName, props, bac
|
|
|
1198
1542
|
function validateAndComputeKeys(nodeKind, kind, constraint, items) {
|
|
1199
1543
|
const validated = [];
|
|
1200
1544
|
for (const item of items) {
|
|
1201
|
-
const validatedProps =
|
|
1545
|
+
const validatedProps = chunkDTVWX77L_cjs.validateNodeProps(nodeKind.schema, item.props, {
|
|
1202
1546
|
kind,
|
|
1203
1547
|
operation: "create"
|
|
1204
1548
|
});
|
|
1205
|
-
const applies =
|
|
1206
|
-
const key = applies ?
|
|
1549
|
+
const applies = chunkE4WNQBEF_cjs.checkWherePredicate(constraint, validatedProps);
|
|
1550
|
+
const key = applies ? chunkE4WNQBEF_cjs.computeUniqueKey(
|
|
1207
1551
|
validatedProps,
|
|
1208
1552
|
constraint.fields,
|
|
1209
1553
|
constraint.collation
|
|
@@ -1226,7 +1570,7 @@ async function executeNodeBulkFindByConstraint(ctx, kind, constraintName, items,
|
|
|
1226
1570
|
const constraint = resolveConstraint(ctx.graph, kind, constraintName);
|
|
1227
1571
|
const validated = validateAndComputeKeys(nodeKind, kind, constraint, items);
|
|
1228
1572
|
const uniqueKeys = collectUniqueKeys(validated);
|
|
1229
|
-
const kindsToCheck =
|
|
1573
|
+
const kindsToCheck = chunkE4WNQBEF_cjs.getKindsForUniquenessCheck(
|
|
1230
1574
|
kind,
|
|
1231
1575
|
constraint.scope,
|
|
1232
1576
|
ctx.registry
|
|
@@ -1276,10 +1620,10 @@ function resolveNodeIndex(graph, kind, indexName) {
|
|
|
1276
1620
|
(candidate) => candidate.entity === "node" && candidate.kind === kind && candidate.name === indexName
|
|
1277
1621
|
);
|
|
1278
1622
|
if (declaration?.entity !== "node") {
|
|
1279
|
-
throw new
|
|
1623
|
+
throw new chunkNI72YOJB_cjs.NodeIndexNotFoundError(indexName, kind);
|
|
1280
1624
|
}
|
|
1281
1625
|
if (declaration.method !== void 0) {
|
|
1282
|
-
throw new
|
|
1626
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
1283
1627
|
`bulkFindByIndex cannot probe index "${indexName}" (method "${declaration.method}"): only btree indexes serve equality probes.`,
|
|
1284
1628
|
{ indexName, kind, method: declaration.method }
|
|
1285
1629
|
);
|
|
@@ -1317,7 +1661,7 @@ function validateIndexProbeValue(value, valueType, pointer, kind) {
|
|
|
1317
1661
|
}
|
|
1318
1662
|
}
|
|
1319
1663
|
function indexProbeTypeError(pointer, kind, expected, value) {
|
|
1320
|
-
return new
|
|
1664
|
+
return new chunkNI72YOJB_cjs.ValidationError(
|
|
1321
1665
|
`Index probe value for "${pointer}" on node kind "${kind}" has an incompatible type`,
|
|
1322
1666
|
{
|
|
1323
1667
|
entityType: "node",
|
|
@@ -1351,7 +1695,7 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
|
|
|
1351
1695
|
if (items.length === 0) return [];
|
|
1352
1696
|
const index = resolveNodeIndex(ctx.graph, kind, indexName);
|
|
1353
1697
|
if (index.fields.length === 0) {
|
|
1354
|
-
throw new
|
|
1698
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
1355
1699
|
`bulkFindByIndex requires an index with at least one prop-based field on index "${indexName}" (node kind "${kind}")`,
|
|
1356
1700
|
{ indexName, kind },
|
|
1357
1701
|
{
|
|
@@ -1360,7 +1704,7 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
|
|
|
1360
1704
|
);
|
|
1361
1705
|
}
|
|
1362
1706
|
if (index.fieldValueTypes.includes("date")) {
|
|
1363
|
-
throw new
|
|
1707
|
+
throw new chunkNI72YOJB_cjs.ConfigurationError(
|
|
1364
1708
|
`bulkFindByIndex does not support date-typed key fields on index "${indexName}" (node kind "${kind}")`,
|
|
1365
1709
|
{ indexName, kind },
|
|
1366
1710
|
{
|
|
@@ -1370,7 +1714,7 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
|
|
|
1370
1714
|
}
|
|
1371
1715
|
const limitPerInput = options?.limitPerInput;
|
|
1372
1716
|
if (limitPerInput !== void 0 && (!Number.isInteger(limitPerInput) || limitPerInput <= 0)) {
|
|
1373
|
-
throw new
|
|
1717
|
+
throw new chunkNI72YOJB_cjs.ValidationError(
|
|
1374
1718
|
"bulkFindByIndex limitPerInput must be a positive integer",
|
|
1375
1719
|
{
|
|
1376
1720
|
entityType: "node",
|
|
@@ -1385,10 +1729,10 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
|
|
|
1385
1729
|
}
|
|
1386
1730
|
);
|
|
1387
1731
|
}
|
|
1388
|
-
const adapter =
|
|
1732
|
+
const adapter = chunk4UGOKMI5_cjs.getDialect(backend.dialect);
|
|
1389
1733
|
const probes = items.map(
|
|
1390
1734
|
(item) => index.fields.map((pointer, position) => {
|
|
1391
|
-
const value =
|
|
1735
|
+
const value = chunkA7J2YDDI_cjs.resolveJsonPointer(item.props, pointer);
|
|
1392
1736
|
validateIndexProbeValue(
|
|
1393
1737
|
value,
|
|
1394
1738
|
index.fieldValueTypes[position],
|
|
@@ -1412,47 +1756,47 @@ async function executeNodeBulkFindByIndex(ctx, kind, indexName, items, backend,
|
|
|
1412
1756
|
}
|
|
1413
1757
|
groupToInputs[existing]?.push(inputIndex);
|
|
1414
1758
|
}
|
|
1415
|
-
const schema = backend.tableNames ?
|
|
1759
|
+
const schema = backend.tableNames ? chunkNFCVHQ5P_cjs.createSqlSchema(backend.tableNames) : chunkNFCVHQ5P_cjs.DEFAULT_SQL_SCHEMA;
|
|
1416
1760
|
const compileContext = {
|
|
1417
1761
|
dialect: backend.dialect,
|
|
1418
|
-
propsColumn:
|
|
1419
|
-
systemColumn: (column) =>
|
|
1762
|
+
propsColumn: chunkVCRRKBLN_cjs.sql.raw(`"props"`),
|
|
1763
|
+
systemColumn: (column) => chunkVCRRKBLN_cjs.sql.raw(`"${column}"`)
|
|
1420
1764
|
};
|
|
1421
|
-
const fieldKeys =
|
|
1765
|
+
const fieldKeys = chunk4UGOKMI5_cjs.compileNodeIndexFieldKeys(index, compileContext);
|
|
1422
1766
|
const groupPredicates = groupProbes.map(
|
|
1423
|
-
(probe) =>
|
|
1767
|
+
(probe) => chunkVCRRKBLN_cjs.sql`(${chunkVCRRKBLN_cjs.sql.join(
|
|
1424
1768
|
fieldKeys.map((fieldKey, position) => {
|
|
1425
1769
|
const value = probe[position];
|
|
1426
1770
|
if (value === void 0 || value === null) {
|
|
1427
|
-
return
|
|
1771
|
+
return chunkVCRRKBLN_cjs.sql`${fieldKey} IS NULL`;
|
|
1428
1772
|
}
|
|
1429
1773
|
return adapter.nullSafeEquals(
|
|
1430
1774
|
fieldKey,
|
|
1431
|
-
|
|
1775
|
+
chunkVCRRKBLN_cjs.sql`${coerceIndexProbeBind(value, adapter)}`
|
|
1432
1776
|
);
|
|
1433
1777
|
}),
|
|
1434
|
-
|
|
1778
|
+
chunkVCRRKBLN_cjs.sql` AND `
|
|
1435
1779
|
)})`
|
|
1436
1780
|
);
|
|
1437
1781
|
const caseBranches = groupPredicates.map(
|
|
1438
|
-
(predicate, group) =>
|
|
1782
|
+
(predicate, group) => chunkVCRRKBLN_cjs.sql`WHEN ${predicate} THEN ${chunkVCRRKBLN_cjs.sql.raw(String(group))}`
|
|
1439
1783
|
);
|
|
1440
|
-
const probeIndexExpr =
|
|
1784
|
+
const probeIndexExpr = chunkVCRRKBLN_cjs.sql`CASE ${chunkVCRRKBLN_cjs.sql.join(caseBranches, chunkVCRRKBLN_cjs.sql` `)} ELSE NULL END`;
|
|
1441
1785
|
const conditions = [
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1786
|
+
chunkVCRRKBLN_cjs.sql`"graph_id" = ${ctx.graphId}`,
|
|
1787
|
+
chunkVCRRKBLN_cjs.sql`"kind" = ${kind}`,
|
|
1788
|
+
chunkVCRRKBLN_cjs.sql`"deleted_at" IS NULL`
|
|
1445
1789
|
];
|
|
1446
1790
|
if (index.where !== void 0) {
|
|
1447
|
-
conditions.push(
|
|
1791
|
+
conditions.push(chunk4UGOKMI5_cjs.compileIndexWhere(compileContext, index.where));
|
|
1448
1792
|
}
|
|
1449
|
-
conditions.push(
|
|
1450
|
-
const whereClause =
|
|
1451
|
-
const probedSelect =
|
|
1793
|
+
conditions.push(chunkVCRRKBLN_cjs.sql`(${chunkVCRRKBLN_cjs.sql.join(groupPredicates, chunkVCRRKBLN_cjs.sql` OR `)})`);
|
|
1794
|
+
const whereClause = chunkVCRRKBLN_cjs.sql.join(conditions, chunkVCRRKBLN_cjs.sql` AND `);
|
|
1795
|
+
const probedSelect = chunkVCRRKBLN_cjs.sql`SELECT "id", ${probeIndexExpr} AS probe_idx FROM ${schema.nodesTable} WHERE ${whereClause}`;
|
|
1452
1796
|
const capInSql = limitPerInput !== void 0 && backend.capabilities.windowFunctions;
|
|
1453
|
-
const query = capInSql ?
|
|
1797
|
+
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
1798
|
const rawMatches = await backend.execute(
|
|
1455
|
-
|
|
1799
|
+
chunkVCRRKBLN_cjs.asCompiledRowsSql(query)
|
|
1456
1800
|
);
|
|
1457
1801
|
const matches = limitPerInput !== void 0 && !capInSql ? capMatchesPerGroup(rawMatches, limitPerInput) : rawMatches;
|
|
1458
1802
|
const nodesById = await hydrateNodesById(
|
|
@@ -1485,7 +1829,7 @@ function capMatchesPerGroup(matches, limitPerInput) {
|
|
|
1485
1829
|
return capped;
|
|
1486
1830
|
}
|
|
1487
1831
|
async function hydrateNodesById(backend, graphId, kind, ids) {
|
|
1488
|
-
const rowsById = await
|
|
1832
|
+
const rowsById = await chunkPF6F5NLJ_cjs.getNodeRowsByIds(backend, graphId, kind, ids);
|
|
1489
1833
|
const nodesById = /* @__PURE__ */ new Map();
|
|
1490
1834
|
for (const [id, row] of rowsById) {
|
|
1491
1835
|
if (row.deleted_at !== void 0) continue;
|
|
@@ -1501,108 +1845,117 @@ async function executeNodeBulkGetOrCreateByConstraint(ctx, kind, constraintName,
|
|
|
1501
1845
|
const constraint = resolveConstraint(ctx.graph, kind, constraintName);
|
|
1502
1846
|
const validated = validateAndComputeKeys(nodeKind, kind, constraint, items);
|
|
1503
1847
|
const uniqueKeys = collectUniqueKeys(validated);
|
|
1504
|
-
const kindsToCheck =
|
|
1848
|
+
const kindsToCheck = chunkE4WNQBEF_cjs.getKindsForUniquenessCheck(
|
|
1505
1849
|
kind,
|
|
1506
1850
|
constraint.scope,
|
|
1507
1851
|
ctx.registry
|
|
1508
1852
|
);
|
|
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,
|
|
1853
|
+
async function attempt() {
|
|
1854
|
+
const existingByKey = uniqueKeys.length > 0 ? await batchCheckUniqueAcrossKinds(
|
|
1551
1855
|
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
1856
|
ctx.graphId,
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1857
|
+
constraint.name,
|
|
1858
|
+
uniqueKeys,
|
|
1859
|
+
kindsToCheck,
|
|
1860
|
+
true
|
|
1861
|
+
) : /* @__PURE__ */ new Map();
|
|
1862
|
+
const toCreate = [];
|
|
1863
|
+
const toFetch = [];
|
|
1864
|
+
const duplicateOf = [];
|
|
1865
|
+
const seenKeys = /* @__PURE__ */ new Map();
|
|
1866
|
+
for (const [index, { validatedProps, key }] of validated.entries()) {
|
|
1867
|
+
if (key === void 0) {
|
|
1868
|
+
toCreate.push({ index, input: { kind, props: validatedProps } });
|
|
1869
|
+
continue;
|
|
1870
|
+
}
|
|
1871
|
+
const previousIndex = seenKeys.get(key);
|
|
1872
|
+
if (previousIndex !== void 0) {
|
|
1873
|
+
duplicateOf.push({ index, sourceIndex: previousIndex });
|
|
1874
|
+
continue;
|
|
1875
|
+
}
|
|
1876
|
+
seenKeys.set(key, index);
|
|
1877
|
+
const existing = existingByKey.get(key);
|
|
1878
|
+
if (existing === void 0) {
|
|
1879
|
+
toCreate.push({ index, input: { kind, props: validatedProps } });
|
|
1880
|
+
} else {
|
|
1881
|
+
toFetch.push({
|
|
1882
|
+
index,
|
|
1883
|
+
nodeId: existing.node_id,
|
|
1884
|
+
concreteKind: existing.concrete_kind,
|
|
1885
|
+
validatedProps
|
|
1886
|
+
});
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
const results = Array.from({ length: items.length });
|
|
1890
|
+
if (toCreate.length > 0) {
|
|
1891
|
+
const createInputs = toCreate.map((entry) => entry.input);
|
|
1892
|
+
const createdNodes = await executeNodeCreateBatch(
|
|
1570
1893
|
ctx,
|
|
1571
|
-
|
|
1894
|
+
createInputs,
|
|
1572
1895
|
backend,
|
|
1573
1896
|
{ propsPreValidated: true }
|
|
1574
1897
|
);
|
|
1575
|
-
|
|
1576
|
-
|
|
1898
|
+
for (const [batchIndex, entry] of toCreate.entries()) {
|
|
1899
|
+
results[entry.index] = {
|
|
1900
|
+
node: chunkN66HCGCY_cjs.requireDefined(createdNodes[batchIndex]),
|
|
1901
|
+
action: "created"
|
|
1902
|
+
};
|
|
1903
|
+
}
|
|
1577
1904
|
}
|
|
1578
|
-
|
|
1579
|
-
const
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
props: validatedProps
|
|
1585
|
-
},
|
|
1586
|
-
backend,
|
|
1587
|
-
{ clearDeleted: isSoftDeleted }
|
|
1905
|
+
for (const entry of toFetch) {
|
|
1906
|
+
const { index, concreteKind, validatedProps, nodeId } = entry;
|
|
1907
|
+
const existingRow = await backend.getNode(
|
|
1908
|
+
ctx.graphId,
|
|
1909
|
+
concreteKind,
|
|
1910
|
+
nodeId
|
|
1588
1911
|
);
|
|
1589
|
-
|
|
1590
|
-
node
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1912
|
+
if (existingRow === void 0) {
|
|
1913
|
+
const node = await executeNodeCreate(
|
|
1914
|
+
ctx,
|
|
1915
|
+
{ kind, props: validatedProps },
|
|
1916
|
+
backend,
|
|
1917
|
+
{ propsPreValidated: true }
|
|
1918
|
+
);
|
|
1919
|
+
results[index] = { node, action: "created" };
|
|
1920
|
+
continue;
|
|
1921
|
+
}
|
|
1922
|
+
const isSoftDeleted = existingRow.deleted_at !== void 0;
|
|
1923
|
+
if (isSoftDeleted || ifExists === "update") {
|
|
1924
|
+
const node = await executeNodeUpsertUpdate(
|
|
1925
|
+
ctx,
|
|
1926
|
+
{
|
|
1927
|
+
kind: concreteKind,
|
|
1928
|
+
id: existingRow.id,
|
|
1929
|
+
props: validatedProps
|
|
1930
|
+
},
|
|
1931
|
+
backend,
|
|
1932
|
+
{ clearDeleted: isSoftDeleted }
|
|
1933
|
+
);
|
|
1934
|
+
results[index] = {
|
|
1935
|
+
node,
|
|
1936
|
+
action: isSoftDeleted ? "resurrected" : "updated"
|
|
1937
|
+
};
|
|
1938
|
+
} else {
|
|
1939
|
+
results[index] = { node: rowToNode(existingRow), action: "found" };
|
|
1940
|
+
}
|
|
1595
1941
|
}
|
|
1942
|
+
for (const { index, sourceIndex } of duplicateOf) {
|
|
1943
|
+
const sourceResult = chunkN66HCGCY_cjs.requireDefined(results[sourceIndex]);
|
|
1944
|
+
results[index] = { node: sourceResult.node, action: "found" };
|
|
1945
|
+
}
|
|
1946
|
+
return results;
|
|
1596
1947
|
}
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1948
|
+
try {
|
|
1949
|
+
return await attempt();
|
|
1950
|
+
} catch (error) {
|
|
1951
|
+
if (!(error instanceof chunkNI72YOJB_cjs.UniquenessError)) throw error;
|
|
1952
|
+
return attempt();
|
|
1600
1953
|
}
|
|
1601
|
-
return results;
|
|
1602
1954
|
}
|
|
1603
1955
|
|
|
1604
1956
|
exports.checkCardinalityConstraint = checkCardinalityConstraint;
|
|
1605
1957
|
exports.createNodeBatchValidationBackend = createNodeBatchValidationBackend;
|
|
1958
|
+
exports.edgeWriteNeedsConstraintFence = edgeWriteNeedsConstraintFence;
|
|
1606
1959
|
exports.executeNodeBulkFindByConstraint = executeNodeBulkFindByConstraint;
|
|
1607
1960
|
exports.executeNodeBulkFindByIndex = executeNodeBulkFindByIndex;
|
|
1608
1961
|
exports.executeNodeBulkGetOrCreateByConstraint = executeNodeBulkGetOrCreateByConstraint;
|
|
@@ -1610,20 +1963,19 @@ exports.executeNodeCreate = executeNodeCreate;
|
|
|
1610
1963
|
exports.executeNodeCreateBatch = executeNodeCreateBatch;
|
|
1611
1964
|
exports.executeNodeCreateNoReturnBatch = executeNodeCreateNoReturnBatch;
|
|
1612
1965
|
exports.executeNodeDelete = executeNodeDelete;
|
|
1966
|
+
exports.executeNodeDeleteBatch = executeNodeDeleteBatch;
|
|
1613
1967
|
exports.executeNodeFindByConstraint = executeNodeFindByConstraint;
|
|
1614
1968
|
exports.executeNodeGetOrCreateByConstraint = executeNodeGetOrCreateByConstraint;
|
|
1615
1969
|
exports.executeNodeHardDelete = executeNodeHardDelete;
|
|
1616
1970
|
exports.executeNodeUpdate = executeNodeUpdate;
|
|
1617
1971
|
exports.executeNodeUpdateWhere = executeNodeUpdateWhere;
|
|
1618
1972
|
exports.executeNodeUpsertUpdate = executeNodeUpsertUpdate;
|
|
1619
|
-
exports.lockSchemaVersionForStoreWrite = lockSchemaVersionForStoreWrite;
|
|
1620
1973
|
exports.nodeUpsertDirtyCheck = nodeUpsertDirtyCheck;
|
|
1621
1974
|
exports.primeBatchValidationCaches = primeBatchValidationCaches;
|
|
1622
1975
|
exports.rowToEdge = rowToEdge;
|
|
1623
1976
|
exports.rowToEdgeMeta = rowToEdgeMeta;
|
|
1624
1977
|
exports.rowToNode = rowToNode;
|
|
1625
1978
|
exports.rowToNodeMeta = rowToNodeMeta;
|
|
1626
|
-
exports.
|
|
1627
|
-
|
|
1628
|
-
//# sourceMappingURL=chunk-
|
|
1629
|
-
//# sourceMappingURL=chunk-UCQ3BFSY.cjs.map
|
|
1979
|
+
exports.withAlreadyExistsTranslation = withAlreadyExistsTranslation;
|
|
1980
|
+
//# sourceMappingURL=chunk-PT7RIRIZ.cjs.map
|
|
1981
|
+
//# sourceMappingURL=chunk-PT7RIRIZ.cjs.map
|