@nicia-ai/typegraph 0.49.0 → 0.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend/drizzle/indexes.cjs +9 -9
- package/dist/backend/drizzle/indexes.d.cts +1 -1
- package/dist/backend/drizzle/indexes.d.ts +1 -1
- package/dist/backend/drizzle/indexes.js +5 -5
- package/dist/backend/index.cjs +56 -52
- package/dist/backend/index.d.cts +3 -3
- package/dist/backend/index.d.ts +3 -3
- package/dist/backend/index.js +11 -11
- package/dist/backend/postgres/index.cjs +34 -28
- package/dist/backend/postgres/index.d.cts +7 -7
- package/dist/backend/postgres/index.d.ts +7 -7
- package/dist/backend/postgres/index.js +17 -15
- package/dist/backend/postgres/pglite-store.cjs +36 -35
- package/dist/backend/postgres/pglite-store.cjs.map +1 -1
- package/dist/backend/postgres/pglite-store.d.cts +8 -8
- package/dist/backend/postgres/pglite-store.d.ts +8 -8
- package/dist/backend/postgres/pglite-store.js +32 -31
- package/dist/backend/postgres/pglite-store.js.map +1 -1
- package/dist/backend/postgres/pglite.cjs +19 -17
- package/dist/backend/postgres/pglite.d.cts +3 -3
- package/dist/backend/postgres/pglite.d.ts +3 -3
- package/dist/backend/postgres/pglite.js +18 -16
- package/dist/backend/sqlite/index.cjs +31 -25
- package/dist/backend/sqlite/index.d.cts +7 -7
- package/dist/backend/sqlite/index.d.ts +7 -7
- package/dist/backend/sqlite/index.js +15 -13
- package/dist/backend/sqlite/libsql.cjs +22 -20
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +3 -3
- package/dist/backend/sqlite/libsql.d.ts +3 -3
- package/dist/backend/sqlite/libsql.js +17 -15
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local-store.cjs +37 -36
- package/dist/backend/sqlite/local-store.cjs.map +1 -1
- package/dist/backend/sqlite/local-store.d.cts +8 -8
- package/dist/backend/sqlite/local-store.d.ts +8 -8
- package/dist/backend/sqlite/local-store.js +33 -32
- package/dist/backend/sqlite/local-store.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +20 -18
- package/dist/backend/sqlite/local.d.cts +3 -3
- package/dist/backend/sqlite/local.d.ts +3 -3
- package/dist/backend/sqlite/local.js +18 -16
- package/dist/{chunk-LTXQOEIC.js → chunk-2CYI5HRH.js} +248 -203
- package/dist/chunk-2CYI5HRH.js.map +1 -0
- package/dist/{chunk-KF6K7TGH.js → chunk-2GIV5X4P.js} +702 -422
- package/dist/chunk-2GIV5X4P.js.map +1 -0
- package/dist/{chunk-2TYSSBU5.js → chunk-2Q45FAIE.js} +15 -15
- package/dist/{chunk-2TYSSBU5.js.map → chunk-2Q45FAIE.js.map} +1 -1
- package/dist/{chunk-WODMN3Q2.cjs → chunk-45YZXI6X.cjs} +27 -27
- package/dist/{chunk-WODMN3Q2.cjs.map → chunk-45YZXI6X.cjs.map} +1 -1
- package/dist/{chunk-3DMMGT6S.js → chunk-46UGOVRW.js} +3 -3
- package/dist/{chunk-3DMMGT6S.js.map → chunk-46UGOVRW.js.map} +1 -1
- package/dist/{chunk-GLHXM7C4.js → chunk-5LKOVCPP.js} +60 -23
- package/dist/chunk-5LKOVCPP.js.map +1 -0
- package/dist/{chunk-JFRT7S3B.cjs → chunk-5OWHU7Z7.cjs} +261 -459
- package/dist/chunk-5OWHU7Z7.cjs.map +1 -0
- package/dist/{chunk-7SQSZN2J.js → chunk-5PP4KRPV.js} +5 -5
- package/dist/{chunk-7SQSZN2J.js.map → chunk-5PP4KRPV.js.map} +1 -1
- package/dist/chunk-6KQEICJ6.cjs +12 -0
- package/dist/{chunk-MKJ4KXL5.cjs.map → chunk-6KQEICJ6.cjs.map} +1 -1
- package/dist/{chunk-6SWPJEYN.js → chunk-6LEOAIIB.js} +40 -6
- package/dist/chunk-6LEOAIIB.js.map +1 -0
- package/dist/{chunk-DZAICA5J.js → chunk-6NKSE5AU.js} +4 -4
- package/dist/{chunk-DZAICA5J.js.map → chunk-6NKSE5AU.js.map} +1 -1
- package/dist/{chunk-OVI7IXYX.js → chunk-6S3PTHL4.js} +3 -3
- package/dist/{chunk-OVI7IXYX.js.map → chunk-6S3PTHL4.js.map} +1 -1
- package/dist/{chunk-3FPR224C.cjs → chunk-7CCMCMJO.cjs} +102 -102
- package/dist/{chunk-3FPR224C.cjs.map → chunk-7CCMCMJO.cjs.map} +1 -1
- package/dist/{chunk-SHFBB23Q.js → chunk-7OWE7WD6.js} +6 -4
- package/dist/chunk-7OWE7WD6.js.map +1 -0
- package/dist/chunk-7PRMDZIA.cjs +182 -0
- package/dist/chunk-7PRMDZIA.cjs.map +1 -0
- package/dist/{chunk-CHAOFCHV.js → chunk-AH2A74OZ.js} +3 -3
- package/dist/{chunk-CHAOFCHV.js.map → chunk-AH2A74OZ.js.map} +1 -1
- package/dist/{chunk-OORXGFL5.cjs → chunk-BYBDM423.cjs} +48 -48
- package/dist/{chunk-OORXGFL5.cjs.map → chunk-BYBDM423.cjs.map} +1 -1
- package/dist/{chunk-JB6T4GLL.cjs → chunk-C76WFIVZ.cjs} +808 -519
- package/dist/chunk-C76WFIVZ.cjs.map +1 -0
- package/dist/{chunk-3G5W2U2L.cjs → chunk-CS6JTQQ2.cjs} +302 -257
- package/dist/chunk-CS6JTQQ2.cjs.map +1 -0
- package/dist/{chunk-AOSSQDVO.cjs → chunk-CSNOYIB4.cjs} +13 -13
- package/dist/{chunk-AOSSQDVO.cjs.map → chunk-CSNOYIB4.cjs.map} +1 -1
- package/dist/{chunk-HEV35TGT.js → chunk-DI6VC62F.js} +13 -4
- package/dist/chunk-DI6VC62F.js.map +1 -0
- package/dist/{chunk-2QGYQBS2.cjs → chunk-DWUDZ66O.cjs} +10 -10
- package/dist/{chunk-2QGYQBS2.cjs.map → chunk-DWUDZ66O.cjs.map} +1 -1
- package/dist/{chunk-ZDKTPBGV.js → chunk-EDLKIQRI.js} +4 -4
- package/dist/{chunk-ZDKTPBGV.js.map → chunk-EDLKIQRI.js.map} +1 -1
- package/dist/chunk-EH3JZJUM.cjs +567 -0
- package/dist/chunk-EH3JZJUM.cjs.map +1 -0
- package/dist/{chunk-S5TERQVW.js → chunk-FX5ZW6PN.js} +196 -33
- package/dist/chunk-FX5ZW6PN.js.map +1 -0
- package/dist/{chunk-XVWOYKIK.js → chunk-FZHF5UWR.js} +3 -3
- package/dist/{chunk-XVWOYKIK.js.map → chunk-FZHF5UWR.js.map} +1 -1
- package/dist/{chunk-BFUOME67.cjs → chunk-G2TLHH6T.cjs} +20 -11
- package/dist/chunk-G2TLHH6T.cjs.map +1 -0
- package/dist/{chunk-5PRKMB24.cjs → chunk-GHZPZNFC.cjs} +12 -4
- package/dist/chunk-GHZPZNFC.cjs.map +1 -0
- package/dist/{chunk-ZFMCDJGB.js → chunk-GVYVGGPJ.js} +11 -199
- package/dist/chunk-GVYVGGPJ.js.map +1 -0
- package/dist/{chunk-SDBBMD4N.js → chunk-H3XP6BAV.js} +3 -3
- package/dist/{chunk-SDBBMD4N.js.map → chunk-H3XP6BAV.js.map} +1 -1
- package/dist/{chunk-ROR5ZR6A.cjs → chunk-HSEZ7X6Y.cjs} +45 -45
- package/dist/{chunk-ROR5ZR6A.cjs.map → chunk-HSEZ7X6Y.cjs.map} +1 -1
- package/dist/{chunk-LRQKXRXO.cjs → chunk-HY5BNOUN.cjs} +4 -4
- package/dist/{chunk-LRQKXRXO.cjs.map → chunk-HY5BNOUN.cjs.map} +1 -1
- package/dist/chunk-HZUB5CON.js +27 -0
- package/dist/chunk-HZUB5CON.js.map +1 -0
- package/dist/{chunk-MYKHJI2J.js → chunk-I5C6OTKR.js} +3 -3
- package/dist/{chunk-MYKHJI2J.js.map → chunk-I5C6OTKR.js.map} +1 -1
- package/dist/{chunk-3U5ABFDW.cjs → chunk-IHK5KA2Q.cjs} +31 -28
- package/dist/chunk-IHK5KA2Q.cjs.map +1 -0
- package/dist/{chunk-26YKDNUD.cjs → chunk-IPRP6TDL.cjs} +12 -10
- package/dist/chunk-IPRP6TDL.cjs.map +1 -0
- package/dist/{chunk-UGHG7PGX.js → chunk-IRPYOHRC.js} +26 -4
- package/dist/chunk-IRPYOHRC.js.map +1 -0
- package/dist/{chunk-7UOLHNWC.cjs → chunk-ISKCIQF2.cjs} +20 -20
- package/dist/{chunk-7UOLHNWC.cjs.map → chunk-ISKCIQF2.cjs.map} +1 -1
- package/dist/{chunk-7LZJNLA5.js → chunk-JG5XIJDY.js} +57 -31
- package/dist/chunk-JG5XIJDY.js.map +1 -0
- package/dist/{chunk-YYUHLYM2.cjs → chunk-K2XYLVVB.cjs} +134 -133
- package/dist/chunk-K2XYLVVB.cjs.map +1 -0
- package/dist/{chunk-5K2BKEBD.js → chunk-K46SDNQD.js} +10 -4
- package/dist/chunk-K46SDNQD.js.map +1 -0
- package/dist/{chunk-TZEGUG6D.cjs → chunk-K6VKTBST.cjs} +4 -4
- package/dist/{chunk-TZEGUG6D.cjs.map → chunk-K6VKTBST.cjs.map} +1 -1
- package/dist/chunk-KWNWG4RC.cjs +12 -0
- package/dist/{chunk-CICO5GXD.cjs.map → chunk-KWNWG4RC.cjs.map} +1 -1
- package/dist/{chunk-FQPEMEWX.cjs → chunk-LLVOQOWE.cjs} +80 -32
- package/dist/chunk-LLVOQOWE.cjs.map +1 -0
- package/dist/{chunk-TQHGE7UC.cjs → chunk-M5MSP3BI.cjs} +18 -10
- package/dist/chunk-M5MSP3BI.cjs.map +1 -0
- package/dist/{chunk-Z2JCLZFJ.js → chunk-MJPZNEJZ.js} +273 -291
- package/dist/chunk-MJPZNEJZ.js.map +1 -0
- package/dist/{chunk-TUNPBZY3.cjs → chunk-MM3JHVKZ.cjs} +4 -4
- package/dist/{chunk-TUNPBZY3.cjs.map → chunk-MM3JHVKZ.cjs.map} +1 -1
- package/dist/{chunk-BRRP76WO.js → chunk-MX7EKQPM.js} +457 -299
- package/dist/chunk-MX7EKQPM.js.map +1 -0
- package/dist/{chunk-D4QLTJSM.js → chunk-MZ34E2GN.js} +13 -12
- package/dist/chunk-MZ34E2GN.js.map +1 -0
- package/dist/{chunk-EDN4Y4ZG.cjs → chunk-OJHD3LXJ.cjs} +9 -9
- package/dist/{chunk-EDN4Y4ZG.cjs.map → chunk-OJHD3LXJ.cjs.map} +1 -1
- package/dist/{chunk-DO7SAMEK.cjs → chunk-ON47CBE4.cjs} +47 -47
- package/dist/{chunk-DO7SAMEK.cjs.map → chunk-ON47CBE4.cjs.map} +1 -1
- package/dist/{chunk-6LN7FIVU.js → chunk-PALYTHGM.js} +11 -4
- package/dist/chunk-PALYTHGM.js.map +1 -0
- package/dist/{chunk-YVF2EM7B.js → chunk-R7MRFE5P.js} +3 -3
- package/dist/{chunk-YVF2EM7B.js.map → chunk-R7MRFE5P.js.map} +1 -1
- package/dist/{chunk-EZEEWCFJ.cjs → chunk-RDP6ZRSM.cjs} +435 -265
- package/dist/chunk-RDP6ZRSM.cjs.map +1 -0
- package/dist/{chunk-GYEG3ZLZ.cjs → chunk-RJMHU2MG.cjs} +121 -18
- package/dist/chunk-RJMHU2MG.cjs.map +1 -0
- package/dist/chunk-RWUWTJQY.cjs +30 -0
- package/dist/chunk-RWUWTJQY.cjs.map +1 -0
- package/dist/{chunk-JPD2CTC3.js → chunk-S33YQEL7.js} +7 -7
- package/dist/{chunk-JPD2CTC3.js.map → chunk-S33YQEL7.js.map} +1 -1
- package/dist/chunk-S3SDEQMC.js +532 -0
- package/dist/chunk-S3SDEQMC.js.map +1 -0
- package/dist/{chunk-OI2GQ25X.cjs → chunk-SHC7BCG5.cjs} +7 -7
- package/dist/{chunk-OI2GQ25X.cjs.map → chunk-SHC7BCG5.cjs.map} +1 -1
- package/dist/{chunk-L3LQNR34.cjs → chunk-TEC24ZDA.cjs} +161 -161
- package/dist/{chunk-L3LQNR34.cjs.map → chunk-TEC24ZDA.cjs.map} +1 -1
- package/dist/{chunk-HDL2ARHX.cjs → chunk-TP4NJTI3.cjs} +63 -27
- package/dist/chunk-TP4NJTI3.cjs.map +1 -0
- package/dist/{chunk-UMGZDVOA.cjs → chunk-TTCOPKUL.cjs} +124 -124
- package/dist/{chunk-UMGZDVOA.cjs.map → chunk-TTCOPKUL.cjs.map} +1 -1
- package/dist/chunk-TUVD4DFR.cjs +1207 -0
- package/dist/chunk-TUVD4DFR.cjs.map +1 -0
- package/dist/{chunk-UGHQV7MP.cjs → chunk-TYGGUWMS.cjs} +178 -152
- package/dist/chunk-TYGGUWMS.cjs.map +1 -0
- package/dist/{chunk-WIC7DRXW.js → chunk-U3Z7XKAG.js} +7 -7
- package/dist/{chunk-WIC7DRXW.js.map → chunk-U3Z7XKAG.js.map} +1 -1
- package/dist/{chunk-NACVVDWB.js → chunk-U5EL6JUV.js} +10 -10
- package/dist/{chunk-NACVVDWB.js.map → chunk-U5EL6JUV.js.map} +1 -1
- package/dist/{chunk-OMZ37BM2.js → chunk-V76FGHY3.js} +5 -5
- package/dist/{chunk-OMZ37BM2.js.map → chunk-V76FGHY3.js.map} +1 -1
- package/dist/{chunk-6NGW27EO.cjs → chunk-VLBTRXA2.cjs} +10 -10
- package/dist/{chunk-6NGW27EO.cjs.map → chunk-VLBTRXA2.cjs.map} +1 -1
- package/dist/chunk-VTJVMP4I.js +1182 -0
- package/dist/chunk-VTJVMP4I.js.map +1 -0
- package/dist/{chunk-QTD6HX4O.js → chunk-W5SOCUBL.js} +5 -5
- package/dist/{chunk-QTD6HX4O.js.map → chunk-W5SOCUBL.js.map} +1 -1
- package/dist/{chunk-SR725PWF.cjs → chunk-WCLMKNQE.cjs} +1750 -1592
- package/dist/chunk-WCLMKNQE.cjs.map +1 -0
- package/dist/{chunk-2O4PCIZ6.cjs → chunk-WK23PGTP.cjs} +13 -13
- package/dist/{chunk-2O4PCIZ6.cjs.map → chunk-WK23PGTP.cjs.map} +1 -1
- package/dist/{chunk-KKBDXCLQ.js → chunk-WQBAQZHR.js} +4 -4
- package/dist/{chunk-KKBDXCLQ.js.map → chunk-WQBAQZHR.js.map} +1 -1
- package/dist/{chunk-MRDBBHIZ.cjs → chunk-X4GDXBOP.cjs} +2 -2
- package/dist/chunk-X4GDXBOP.cjs.map +1 -0
- package/dist/{chunk-3QNZ5SAJ.cjs → chunk-XMY2SXOH.cjs} +437 -455
- package/dist/chunk-XMY2SXOH.cjs.map +1 -0
- package/dist/{chunk-D5R42W5D.js → chunk-XZW2CTNO.js} +115 -12
- package/dist/chunk-XZW2CTNO.js.map +1 -0
- package/dist/{chunk-NVY5CJFP.js → chunk-Y55DLLEG.js} +9 -6
- package/dist/chunk-Y55DLLEG.js.map +1 -0
- package/dist/chunk-YA36ABIL.js +174 -0
- package/dist/chunk-YA36ABIL.js.map +1 -0
- package/dist/{chunk-ZLONH2UD.js → chunk-YDEJQWOL.js} +2 -2
- package/dist/chunk-YDEJQWOL.js.map +1 -0
- package/dist/{chunk-JONXFAPO.js → chunk-ZAQUKCUC.js} +5 -5
- package/dist/{chunk-JONXFAPO.js.map → chunk-ZAQUKCUC.js.map} +1 -1
- package/dist/{chunk-SIT26LAZ.cjs → chunk-ZBFZGLZE.cjs} +29 -5
- package/dist/chunk-ZBFZGLZE.cjs.map +1 -0
- package/dist/{chunk-P6YLZTRE.js → chunk-ZRJTM7MT.js} +3 -3
- package/dist/{chunk-P6YLZTRE.js.map → chunk-ZRJTM7MT.js.map} +1 -1
- package/dist/core/index.cjs +29 -28
- package/dist/core/index.d.cts +4 -4
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +9 -8
- package/dist/{ddl-D_oW-EVO.d.ts → ddl-B49O7dB_.d.ts} +3 -3
- package/dist/{ddl-BL1NZLMY.d.cts → ddl-DcZG660s.d.cts} +3 -3
- package/dist/graph-extension/index.cjs +21 -20
- package/dist/graph-extension/index.d.cts +4 -4
- package/dist/graph-extension/index.d.ts +4 -4
- package/dist/graph-extension/index.js +5 -4
- package/dist/graph-merge/index.cjs +305 -303
- package/dist/graph-merge/index.cjs.map +1 -1
- package/dist/graph-merge/index.d.cts +9 -9
- package/dist/graph-merge/index.d.ts +9 -9
- package/dist/graph-merge/index.js +29 -27
- package/dist/graph-merge/index.js.map +1 -1
- package/dist/{index-D7d1u2gr.d.ts → index-B0PrmE3K.d.cts} +16 -2
- package/dist/{index-COs_z6nV.d.cts → index-CwcXsL5R.d.ts} +16 -2
- package/dist/index.cjs +223 -222
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -12
- package/dist/index.d.ts +12 -12
- package/dist/index.js +37 -36
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +13 -13
- package/dist/indexes/index.d.cts +4 -4
- package/dist/indexes/index.d.ts +4 -4
- package/dist/indexes/index.js +6 -6
- package/dist/{ingestion-import-target-dNeL7iAv.d.ts → ingestion-import-target-CI8OWIkM.d.ts} +1 -1
- package/dist/{ingestion-import-target-XPxZYw89.d.cts → ingestion-import-target-DCpfM1PX.d.cts} +1 -1
- package/dist/interchange/index.cjs +55 -54
- package/dist/interchange/index.cjs.map +1 -1
- package/dist/interchange/index.d.cts +19 -8
- package/dist/interchange/index.d.ts +19 -8
- package/dist/interchange/index.js +19 -18
- package/dist/interchange/index.js.map +1 -1
- package/dist/{manager-D9eRT_ns.d.ts → manager-Cfg1ENj1.d.ts} +30 -2
- package/dist/{manager-CYaff3n3.d.cts → manager-D348fa6W.d.cts} +30 -2
- package/dist/{materialize-indexes-DJ3ykH59.d.ts → materialize-indexes-C9GG3O3C.d.ts} +1 -1
- package/dist/{materialize-indexes-DTtAnvfY.d.cts → materialize-indexes-CrSiW_lT.d.cts} +1 -1
- package/dist/{postgres-CcL4bAHS.d.ts → postgres-CH1kkM5J.d.cts} +279 -2
- package/dist/{postgres-DMj39MEu.d.cts → postgres-UStOycLI.d.ts} +279 -2
- package/dist/profiler/index.d.cts +9 -9
- package/dist/profiler/index.d.ts +9 -9
- package/dist/provenance/index.cjs +46 -44
- 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 -10
- package/dist/provenance/index.js.map +1 -1
- package/dist/{repair-validity-windows-DlUSqwCg.d.ts → repair-validity-windows-BtOEe2pS.d.ts} +2 -2
- package/dist/{repair-validity-windows-BFNZvd_H.d.cts → repair-validity-windows-aWX7VNvv.d.cts} +2 -2
- package/dist/schema/index.cjs +46 -46
- package/dist/schema/index.d.cts +6 -6
- package/dist/schema/index.d.ts +6 -6
- package/dist/schema/index.js +19 -19
- package/dist/{searchable-DHJMh_nj.d.cts → searchable-C8-RrL3l.d.cts} +1 -1
- package/dist/{searchable-bpE1bBfc.d.ts → searchable-z4BiFfHI.d.ts} +1 -1
- package/dist/{sqlite-YppHrNFb.d.cts → sqlite-Cyx9j9o6.d.cts} +309 -2
- package/dist/{sqlite-D7Oz0SQh.d.ts → sqlite-axLw5Lo5.d.ts} +309 -2
- package/dist/{store-bphCSo7z.d.cts → store-CTfQ9taw.d.ts} +102 -13
- package/dist/{store-DRrFCx5x.d.ts → store-DR9J7JVB.d.cts} +102 -13
- package/dist/{temporal-5GqpYCk2.d.cts → temporal-B4Ky4wzh.d.cts} +1 -1
- package/dist/{temporal-CbnLzTmM.d.ts → temporal-CBOrERz5.d.ts} +1 -1
- package/dist/{types-CXAhpW-c.d.cts → types-BE921wRl.d.cts} +1 -1
- package/dist/{types-Bx74kaTt.d.ts → types-BScHXVM7.d.ts} +1 -1
- package/dist/{types-BqFZTQmV.d.cts → types-CWg4dTjj.d.cts} +257 -6
- package/dist/{types-BqFZTQmV.d.ts → types-CWg4dTjj.d.ts} +257 -6
- package/dist/{where-O-k2wgYm.d.ts → where-BWXUPV3C.d.ts} +1 -1
- package/dist/{where-DI_Fqz-X.d.cts → where-CNtx1aLc.d.cts} +1 -1
- package/package.json +3 -2
- package/dist/chunk-26YKDNUD.cjs.map +0 -1
- package/dist/chunk-3G5W2U2L.cjs.map +0 -1
- package/dist/chunk-3KOY4FH3.cjs +0 -934
- package/dist/chunk-3KOY4FH3.cjs.map +0 -1
- package/dist/chunk-3QNZ5SAJ.cjs.map +0 -1
- package/dist/chunk-3U5ABFDW.cjs.map +0 -1
- package/dist/chunk-5K2BKEBD.js.map +0 -1
- package/dist/chunk-5PRKMB24.cjs.map +0 -1
- package/dist/chunk-6LN7FIVU.js.map +0 -1
- package/dist/chunk-6SWPJEYN.js.map +0 -1
- package/dist/chunk-7LZJNLA5.js.map +0 -1
- package/dist/chunk-BFUOME67.cjs.map +0 -1
- package/dist/chunk-BRRP76WO.js.map +0 -1
- package/dist/chunk-CICO5GXD.cjs +0 -12
- package/dist/chunk-D4QLTJSM.js.map +0 -1
- package/dist/chunk-D5R42W5D.js.map +0 -1
- package/dist/chunk-EZEEWCFJ.cjs.map +0 -1
- package/dist/chunk-FA2AFWLP.cjs +0 -167
- package/dist/chunk-FA2AFWLP.cjs.map +0 -1
- package/dist/chunk-FQPEMEWX.cjs.map +0 -1
- package/dist/chunk-GLHXM7C4.js.map +0 -1
- package/dist/chunk-GYEG3ZLZ.cjs.map +0 -1
- package/dist/chunk-HDL2ARHX.cjs.map +0 -1
- package/dist/chunk-HEV35TGT.js.map +0 -1
- package/dist/chunk-I4GAZH5Z.js +0 -913
- package/dist/chunk-I4GAZH5Z.js.map +0 -1
- package/dist/chunk-JB6T4GLL.cjs.map +0 -1
- package/dist/chunk-JBQQ7THH.js +0 -20
- package/dist/chunk-JBQQ7THH.js.map +0 -1
- package/dist/chunk-JFRT7S3B.cjs.map +0 -1
- package/dist/chunk-KF6K7TGH.js.map +0 -1
- package/dist/chunk-LTXQOEIC.js.map +0 -1
- package/dist/chunk-MKJ4KXL5.cjs +0 -12
- package/dist/chunk-MRDBBHIZ.cjs.map +0 -1
- package/dist/chunk-NVY5CJFP.js.map +0 -1
- package/dist/chunk-PWLJ77UV.cjs +0 -23
- package/dist/chunk-PWLJ77UV.cjs.map +0 -1
- package/dist/chunk-S5TERQVW.js.map +0 -1
- package/dist/chunk-SHFBB23Q.js.map +0 -1
- package/dist/chunk-SIT26LAZ.cjs.map +0 -1
- package/dist/chunk-SR725PWF.cjs.map +0 -1
- package/dist/chunk-TQHGE7UC.cjs.map +0 -1
- package/dist/chunk-UGHG7PGX.js.map +0 -1
- package/dist/chunk-UGHQV7MP.cjs.map +0 -1
- package/dist/chunk-YIURNGXI.js +0 -155
- package/dist/chunk-YIURNGXI.js.map +0 -1
- package/dist/chunk-YYUHLYM2.cjs.map +0 -1
- package/dist/chunk-Z2JCLZFJ.js.map +0 -1
- package/dist/chunk-ZFMCDJGB.js.map +0 -1
- package/dist/chunk-ZLONH2UD.js.map +0 -1
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { deriveBackend } from './chunk-
|
|
6
|
-
import { createSqlSchema, DEFAULT_SQL_SCHEMA } from './chunk-
|
|
7
|
-
import { rowPropsToObject, isLiveNodeRow } from './chunk-
|
|
8
|
-
import {
|
|
9
|
-
import { validateOptionalCanonicalIsoDate, nowIso, resolveStampedValidityLowerBound, assertOrderedValidityWindow, preservesImmutableLowerBound, assertWritableValidityWindow } from './chunk-
|
|
10
|
-
import { getDialect, compileNodeIndexFieldKeys, compileIndexWhere } from './chunk-
|
|
11
|
-
import { sql, asCompiledRowsSql } from './chunk-
|
|
1
|
+
import { nodeClaimSites, nodeClaimEntries, getEmbeddingFields, createNodeWriteContext, applyNodeSetUpdate, applyNodeResurrect, applyNodeHardDelete, applyNodeSoftDelete, applyNodeUpdate, withNodeCreateClaimsBatch, applyNodeInsertSyncFansBatch, withNodeCreateClaims, applyNodeInsertSyncFans, checkUniquenessConstraints, createUniquenessContext } from './chunk-VTJVMP4I.js';
|
|
2
|
+
import { EDGE_CARDINALITY_SPECS, claimEdgeCardinalityBatch, claimEdgeCardinality, purgeEdgeClaims } from './chunk-YA36ABIL.js';
|
|
3
|
+
import { refKey } from './chunk-GVYVGGPJ.js';
|
|
4
|
+
import { runInWriteTransaction, runHookedWriteOperation, validateNodeProps, getNodeRowsByIds, generateId, nodeInsertDispatch, edgeInsertDispatch, runInsertBatch, runInsertBatchReturning, runInsertNoReturn } from './chunk-FX5ZW6PN.js';
|
|
5
|
+
import { deriveBackend, canonicalEqual } from './chunk-IRPYOHRC.js';
|
|
6
|
+
import { createSqlSchema, DEFAULT_SQL_SCHEMA } from './chunk-Y55DLLEG.js';
|
|
7
|
+
import { rowPropsToObject, isLiveNodeRow } from './chunk-PALYTHGM.js';
|
|
8
|
+
import { checkDisjointness, checkUniqueEdge, checkCardinality, uniquenessProbeKinds, encodeTupleKey, checkWherePredicate, computeUniqueKey } from './chunk-5LKOVCPP.js';
|
|
9
|
+
import { assertsStoredLowerBound, assertsStoredUpperBound, validateOptionalCanonicalIsoDate, nowIso, resolveStampedValidityLowerBound, assertOrderedValidityWindow, preservesImmutableLowerBound, assertWritableValidityWindow } from './chunk-K46SDNQD.js';
|
|
10
|
+
import { getDialect, compileNodeIndexFieldKeys, compileIndexWhere } from './chunk-EDLKIQRI.js';
|
|
11
|
+
import { sql, asCompiledRowsSql } from './chunk-46UGOVRW.js';
|
|
12
12
|
import { getSearchableFields } from './chunk-PC2UBAUB.js';
|
|
13
|
-
import { filterReservedKeys, RESERVED_NODE_KEYS, RESERVED_EDGE_KEYS, assertJsonValue } from './chunk-
|
|
14
|
-
import { ValidationError, ConfigurationError, DatabaseOperationError, UniquenessError,
|
|
13
|
+
import { filterReservedKeys, RESERVED_NODE_KEYS, RESERVED_EDGE_KEYS, assertJsonValue } from './chunk-FZHF5UWR.js';
|
|
14
|
+
import { ValidationError, ConfigurationError, DatabaseOperationError, UniquenessError, KindNotFoundError, NodeConstraintNotFoundError, NodeIndexNotFoundError, ENTITY_ALREADY_EXISTS_CODE, NodeNotFoundError } from './chunk-YDEJQWOL.js';
|
|
15
15
|
import { resolveJsonPointer } from './chunk-FWJKWH6U.js';
|
|
16
|
-
import {
|
|
16
|
+
import { createDataKeyedBag, requireDefined, hasOwnKey } from './chunk-DYATYRY4.js';
|
|
17
17
|
|
|
18
18
|
// src/store/row-mappers.ts
|
|
19
19
|
function nullToUndefined(value) {
|
|
@@ -68,13 +68,29 @@ function edgeWriteNeedsConstraintFence(cardinality) {
|
|
|
68
68
|
return cardinality === "many" ? void 0 : "edgeCardinality";
|
|
69
69
|
}
|
|
70
70
|
function nodeWriteNeedsConstraintFence(registry, kind, uniqueConstraints, operation) {
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
return nodeClaimSites(registry, kind, uniqueConstraints, operation).find(
|
|
72
|
+
(site) => site.needsLockFence
|
|
73
|
+
)?.refusalReason;
|
|
74
|
+
}
|
|
75
|
+
function graphOwesClaims(graph, registry) {
|
|
76
|
+
for (const [kind, registration] of Object.entries(graph.nodes)) {
|
|
77
|
+
for (const operation of ["create", "update"]) {
|
|
78
|
+
const gating = nodeClaimSites(
|
|
79
|
+
registry,
|
|
80
|
+
kind,
|
|
81
|
+
registration.unique ?? [],
|
|
82
|
+
operation
|
|
83
|
+
).find((site) => site.placement === "pre-insert");
|
|
84
|
+
if (gating !== void 0) return gating.refusalReason;
|
|
85
|
+
}
|
|
73
86
|
}
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
87
|
+
for (const registration of Object.values(graph.edges)) {
|
|
88
|
+
const reason = edgeWriteNeedsConstraintFence(
|
|
89
|
+
registration.cardinality ?? "many"
|
|
90
|
+
);
|
|
91
|
+
if (reason !== void 0) return reason;
|
|
92
|
+
}
|
|
93
|
+
return void 0;
|
|
78
94
|
}
|
|
79
95
|
async function checkDisjointnessConstraint(ctx, kind, id) {
|
|
80
96
|
const disjointKinds = ctx.registry.getDisjointKinds(kind);
|
|
@@ -87,71 +103,435 @@ async function checkDisjointnessConstraint(ctx, kind, id) {
|
|
|
87
103
|
}
|
|
88
104
|
}
|
|
89
105
|
async function checkCardinalityConstraint(ctx, edgeKind, cardinality, fromKind, fromId, toKind, toId, validTo) {
|
|
90
|
-
|
|
91
|
-
|
|
106
|
+
if (cardinality === "many") return;
|
|
107
|
+
const spec = EDGE_CARDINALITY_SPECS[cardinality];
|
|
108
|
+
if (!spec.claimsWhenBornEnded && validTo !== void 0) return;
|
|
109
|
+
if (spec.keyShape === "fromAndTo") {
|
|
110
|
+
const exists = await ctx.backend.edgeExistsBetween({
|
|
111
|
+
graphId: ctx.graphId,
|
|
112
|
+
edgeKind,
|
|
113
|
+
fromKind,
|
|
114
|
+
fromId,
|
|
115
|
+
toKind,
|
|
116
|
+
toId
|
|
117
|
+
});
|
|
118
|
+
const error2 = checkUniqueEdge(
|
|
119
|
+
edgeKind,
|
|
120
|
+
fromKind,
|
|
121
|
+
fromId,
|
|
122
|
+
toKind,
|
|
123
|
+
toId,
|
|
124
|
+
exists ? 1 : 0
|
|
125
|
+
);
|
|
126
|
+
if (error2) throw error2;
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const count = await ctx.backend.countEdgesFrom({
|
|
130
|
+
graphId: ctx.graphId,
|
|
131
|
+
edgeKind,
|
|
132
|
+
fromKind,
|
|
133
|
+
fromId,
|
|
134
|
+
activeOnly: spec.holderLiveness === "liveAndActive"
|
|
135
|
+
});
|
|
136
|
+
const error = checkCardinality(
|
|
137
|
+
edgeKind,
|
|
138
|
+
fromKind,
|
|
139
|
+
fromId,
|
|
140
|
+
cardinality,
|
|
141
|
+
count,
|
|
142
|
+
count > 0
|
|
143
|
+
);
|
|
144
|
+
if (error) throw error;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// src/store/operations/edge-batch-validation.ts
|
|
148
|
+
function buildEdgeEndpointCacheKey(graphId, kind, id) {
|
|
149
|
+
return encodeTupleKey([graphId, kind, id]);
|
|
150
|
+
}
|
|
151
|
+
function buildEdgeFromCacheKey(graphId, edgeKind, fromKind, fromId) {
|
|
152
|
+
return encodeTupleKey([graphId, edgeKind, fromKind, fromId]);
|
|
153
|
+
}
|
|
154
|
+
function buildEdgeBetweenCacheKey(graphId, edgeKind, fromKind, fromId, toKind, toId) {
|
|
155
|
+
return encodeTupleKey([graphId, edgeKind, fromKind, fromId, toKind, toId]);
|
|
156
|
+
}
|
|
157
|
+
function buildCountEdgesFromCacheKey(params) {
|
|
158
|
+
const activeOnly = params.activeOnly === true ? "1" : "0";
|
|
159
|
+
return encodeTupleKey([
|
|
160
|
+
params.graphId,
|
|
161
|
+
params.edgeKind,
|
|
162
|
+
params.fromKind,
|
|
163
|
+
params.fromId,
|
|
164
|
+
activeOnly
|
|
165
|
+
]);
|
|
166
|
+
}
|
|
167
|
+
function incrementPendingCount(counts, key) {
|
|
168
|
+
const previous = counts.get(key) ?? 0;
|
|
169
|
+
counts.set(key, previous + 1);
|
|
170
|
+
}
|
|
171
|
+
function createEdgeBatchValidationBackend(backend) {
|
|
172
|
+
const endpointCache = /* @__PURE__ */ new Map();
|
|
173
|
+
const countEdgesFromCache = /* @__PURE__ */ new Map();
|
|
174
|
+
const edgeExistsCache = /* @__PURE__ */ new Map();
|
|
175
|
+
const pendingOneCounts = /* @__PURE__ */ new Map();
|
|
176
|
+
const pendingOneActiveCounts = /* @__PURE__ */ new Map();
|
|
177
|
+
const pendingUniquePairs = /* @__PURE__ */ new Set();
|
|
178
|
+
async function getNodeCached(graphId, kind, id) {
|
|
179
|
+
const cacheKey = buildEdgeEndpointCacheKey(graphId, kind, id);
|
|
180
|
+
if (endpointCache.has(cacheKey)) {
|
|
181
|
+
return endpointCache.get(cacheKey);
|
|
182
|
+
}
|
|
183
|
+
const node = await backend.getNode(graphId, kind, id);
|
|
184
|
+
endpointCache.set(cacheKey, node);
|
|
185
|
+
return node;
|
|
186
|
+
}
|
|
187
|
+
function seedEndpointRow(graphId, kind, id, row) {
|
|
188
|
+
const cacheKey = buildEdgeEndpointCacheKey(graphId, kind, id);
|
|
189
|
+
if (endpointCache.has(cacheKey)) return;
|
|
190
|
+
endpointCache.set(cacheKey, row);
|
|
191
|
+
}
|
|
192
|
+
async function countEdgesFromCached(params) {
|
|
193
|
+
const cacheKey = buildCountEdgesFromCacheKey(params);
|
|
194
|
+
let baseCount = countEdgesFromCache.get(cacheKey);
|
|
195
|
+
if (baseCount === void 0) {
|
|
196
|
+
baseCount = await backend.countEdgesFrom(params);
|
|
197
|
+
countEdgesFromCache.set(cacheKey, baseCount);
|
|
198
|
+
}
|
|
199
|
+
const pendingKey = buildEdgeFromCacheKey(
|
|
200
|
+
params.graphId,
|
|
201
|
+
params.edgeKind,
|
|
202
|
+
params.fromKind,
|
|
203
|
+
params.fromId
|
|
204
|
+
);
|
|
205
|
+
const pendingCount = params.activeOnly === true ? pendingOneActiveCounts.get(pendingKey) ?? 0 : pendingOneCounts.get(pendingKey) ?? 0;
|
|
206
|
+
return baseCount + pendingCount;
|
|
207
|
+
}
|
|
208
|
+
async function edgeExistsBetweenCached(params) {
|
|
209
|
+
const cacheKey = buildEdgeBetweenCacheKey(
|
|
210
|
+
params.graphId,
|
|
211
|
+
params.edgeKind,
|
|
212
|
+
params.fromKind,
|
|
213
|
+
params.fromId,
|
|
214
|
+
params.toKind,
|
|
215
|
+
params.toId
|
|
216
|
+
);
|
|
217
|
+
if (pendingUniquePairs.has(cacheKey)) {
|
|
218
|
+
return true;
|
|
219
|
+
}
|
|
220
|
+
if (edgeExistsCache.has(cacheKey)) {
|
|
221
|
+
return edgeExistsCache.get(cacheKey) ?? false;
|
|
222
|
+
}
|
|
223
|
+
const exists = await backend.edgeExistsBetween(params);
|
|
224
|
+
edgeExistsCache.set(cacheKey, exists);
|
|
225
|
+
return exists;
|
|
226
|
+
}
|
|
227
|
+
function registerPendingEdgeForCardinality(insertParams, cardinality) {
|
|
228
|
+
const fromCacheKey = buildEdgeFromCacheKey(
|
|
229
|
+
insertParams.graphId,
|
|
230
|
+
insertParams.kind,
|
|
231
|
+
insertParams.fromKind,
|
|
232
|
+
insertParams.fromId
|
|
233
|
+
);
|
|
234
|
+
if (cardinality === "one") {
|
|
235
|
+
incrementPendingCount(pendingOneCounts, fromCacheKey);
|
|
92
236
|
return;
|
|
93
237
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
fromKind,
|
|
99
|
-
fromId
|
|
100
|
-
});
|
|
101
|
-
const error = checkCardinality(
|
|
102
|
-
edgeKind,
|
|
103
|
-
fromKind,
|
|
104
|
-
fromId,
|
|
105
|
-
"one",
|
|
106
|
-
count,
|
|
107
|
-
false
|
|
108
|
-
);
|
|
109
|
-
if (error) throw error;
|
|
238
|
+
if (cardinality === "oneActive") {
|
|
239
|
+
if (insertParams.validTo === void 0) {
|
|
240
|
+
incrementPendingCount(pendingOneActiveCounts, fromCacheKey);
|
|
241
|
+
}
|
|
110
242
|
return;
|
|
111
243
|
}
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
fromKind,
|
|
117
|
-
fromId,
|
|
118
|
-
toKind,
|
|
119
|
-
toId
|
|
120
|
-
});
|
|
121
|
-
const error = checkUniqueEdge(
|
|
122
|
-
edgeKind,
|
|
123
|
-
fromKind,
|
|
124
|
-
fromId,
|
|
125
|
-
toKind,
|
|
126
|
-
toId,
|
|
127
|
-
exists ? 1 : 0
|
|
244
|
+
if (cardinality === "unique") {
|
|
245
|
+
const uniqueCacheKey = buildEdgeBetweenCacheKey(
|
|
246
|
+
insertParams.graphId,
|
|
247
|
+
insertParams.kind,
|
|
248
|
+
insertParams.fromKind,
|
|
249
|
+
insertParams.fromId,
|
|
250
|
+
insertParams.toKind,
|
|
251
|
+
insertParams.toId
|
|
128
252
|
);
|
|
129
|
-
|
|
130
|
-
return;
|
|
253
|
+
pendingUniquePairs.add(uniqueCacheKey);
|
|
131
254
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
255
|
+
}
|
|
256
|
+
const validationBackend = deriveBackend(backend, {
|
|
257
|
+
getNode: getNodeCached,
|
|
258
|
+
countEdgesFrom: countEdgesFromCached,
|
|
259
|
+
edgeExistsBetween: edgeExistsBetweenCached
|
|
260
|
+
});
|
|
261
|
+
return {
|
|
262
|
+
backend: validationBackend,
|
|
263
|
+
registerPendingEdgeForCardinality,
|
|
264
|
+
seedEndpointRow
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// src/store/operations/edge-write-pipeline.ts
|
|
269
|
+
function createEdgeWriteContext(graphId, lock) {
|
|
270
|
+
return { graphId, lock };
|
|
271
|
+
}
|
|
272
|
+
async function applyEdgeUpdate(ctx, args, backend) {
|
|
273
|
+
const { claim, ...rowWork } = args;
|
|
274
|
+
if (claim !== void 0) await claimEdgeCardinality(backend, claim);
|
|
275
|
+
const updateParams = { graphId: ctx.graphId, ...rowWork };
|
|
276
|
+
return backend.updateEdge(updateParams);
|
|
277
|
+
}
|
|
278
|
+
function applyEdgeSoftDelete(ctx, work, backend) {
|
|
279
|
+
return backend.deleteEdge({
|
|
280
|
+
graphId: ctx.graphId,
|
|
281
|
+
id: work.id,
|
|
282
|
+
kind: work.kind
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
async function applyEdgeHardDelete(ctx, work, backend) {
|
|
286
|
+
await backend.hardDeleteEdge({
|
|
287
|
+
graphId: ctx.graphId,
|
|
288
|
+
id: work.id,
|
|
289
|
+
kind: work.kind
|
|
290
|
+
});
|
|
291
|
+
if (work.holdsCardinalityClaim) {
|
|
292
|
+
await purgeEdgeClaims(backend, ctx.graphId, [work.id]);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// src/store/operations/write-fences.ts
|
|
297
|
+
function createWriteParamsDraft() {
|
|
298
|
+
return {};
|
|
299
|
+
}
|
|
300
|
+
function assertsStoredWindowState(fences) {
|
|
301
|
+
return assertsStoredLowerBound(fences.validityLowerBound) || assertsStoredUpperBound(fences.validityUpperBound);
|
|
302
|
+
}
|
|
303
|
+
var UnsupportedWriteFenceError = class extends Error {
|
|
304
|
+
fence;
|
|
305
|
+
kind;
|
|
306
|
+
constructor(fence, kind) {
|
|
307
|
+
super(
|
|
308
|
+
`The ${kind} statement cannot carry the "${fence}" fence, so the write is refused rather than run unfenced. Assert nothing ({}) or use a write shape whose statement carries it.`
|
|
309
|
+
);
|
|
310
|
+
this.name = "UnsupportedWriteFenceError";
|
|
311
|
+
this.fence = fence;
|
|
312
|
+
this.kind = kind;
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
function applyValidityLowerBound(fence, draft) {
|
|
316
|
+
if (!assertsStoredLowerBound(fence)) return;
|
|
317
|
+
draft.expectedValidFrom = fence.expectedValidFrom;
|
|
318
|
+
}
|
|
319
|
+
var NODE_UPDATE_FENCE_APPLIERS = {
|
|
320
|
+
validityLowerBound: applyValidityLowerBound
|
|
321
|
+
};
|
|
322
|
+
var NODE_SET_UPDATE_FENCE_APPLIERS = {
|
|
323
|
+
validityLowerBound: (fence) => {
|
|
324
|
+
if (!assertsStoredLowerBound(fence)) return;
|
|
325
|
+
throw new UnsupportedWriteFenceError("validityLowerBound", "nodeSetUpdate");
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
function applyEdgeIdentity(fence, draft) {
|
|
329
|
+
draft.kind = fence.kind;
|
|
330
|
+
if (fence.fromKind !== void 0) draft.fromKind = fence.fromKind;
|
|
331
|
+
if (fence.fromId !== void 0) draft.fromId = fence.fromId;
|
|
332
|
+
if (fence.toKind !== void 0) draft.toKind = fence.toKind;
|
|
333
|
+
if (fence.toId !== void 0) draft.toId = fence.toId;
|
|
334
|
+
}
|
|
335
|
+
function applyValidityUpperBound(fence, draft) {
|
|
336
|
+
if (!assertsStoredUpperBound(fence)) return;
|
|
337
|
+
draft.expectedValidTo = fence.expectedValidTo;
|
|
338
|
+
}
|
|
339
|
+
var EDGE_UPDATE_FENCE_APPLIERS = {
|
|
340
|
+
validityLowerBound: applyValidityLowerBound,
|
|
341
|
+
validityUpperBound: applyValidityUpperBound,
|
|
342
|
+
edgeIdentity: applyEdgeIdentity
|
|
343
|
+
};
|
|
344
|
+
function applyWriteFences(appliers, fences, draft) {
|
|
345
|
+
for (const key of Object.keys(appliers)) {
|
|
346
|
+
const applier = appliers[key];
|
|
347
|
+
applier(fences[key], draft);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// src/store/operations/write-session.ts
|
|
352
|
+
function unfencedTarget(target) {
|
|
353
|
+
return target;
|
|
354
|
+
}
|
|
355
|
+
function edgeBatchClaims(work) {
|
|
356
|
+
return work.flatMap((item) => item.claim === void 0 ? [] : [item.claim]);
|
|
357
|
+
}
|
|
358
|
+
function createWriteSession(ctx, target, lock) {
|
|
359
|
+
const writeContext = createNodeWriteContext(ctx.graphId, ctx.registry, lock);
|
|
360
|
+
const dispatch = nodeInsertDispatch(target);
|
|
361
|
+
const edgeContext = createEdgeWriteContext(ctx.graphId, lock);
|
|
362
|
+
const edgeDispatch = edgeInsertDispatch(target);
|
|
363
|
+
return {
|
|
364
|
+
// The pinned coordination order, spelled once per insert shape:
|
|
365
|
+
// pre-insert claims, the row, post-insert claims, the sync fans. The claim
|
|
366
|
+
// seam owns the two groups and the compensation between them; this surface
|
|
367
|
+
// owns only "the row write it gates is THIS one".
|
|
368
|
+
createNode: async (work) => {
|
|
369
|
+
const row = await withNodeCreateClaims(
|
|
370
|
+
writeContext,
|
|
371
|
+
work.claim,
|
|
372
|
+
target,
|
|
373
|
+
() => dispatch.one(work.params)
|
|
374
|
+
);
|
|
375
|
+
await applyNodeInsertSyncFans(writeContext, work.sideEffects, target);
|
|
376
|
+
return row;
|
|
377
|
+
},
|
|
378
|
+
createNodeNoReturn: async (work) => {
|
|
379
|
+
await withNodeCreateClaims(
|
|
380
|
+
writeContext,
|
|
381
|
+
work.claim,
|
|
382
|
+
target,
|
|
383
|
+
() => runInsertNoReturn(dispatch, work.params)
|
|
384
|
+
);
|
|
385
|
+
await applyNodeInsertSyncFans(writeContext, work.sideEffects, target);
|
|
386
|
+
},
|
|
387
|
+
createNodes: async (work) => {
|
|
388
|
+
const rows = await withNodeCreateClaimsBatch(
|
|
389
|
+
writeContext,
|
|
390
|
+
work.map((item) => item.claim),
|
|
391
|
+
target,
|
|
392
|
+
() => runInsertBatchReturning(
|
|
393
|
+
dispatch,
|
|
394
|
+
work.map((item) => item.params)
|
|
395
|
+
)
|
|
396
|
+
);
|
|
397
|
+
await applyNodeInsertSyncFansBatch(
|
|
398
|
+
writeContext,
|
|
399
|
+
work.map((item) => item.sideEffects),
|
|
400
|
+
target
|
|
401
|
+
);
|
|
402
|
+
return rows;
|
|
403
|
+
},
|
|
404
|
+
createNodesNoReturn: async (work) => {
|
|
405
|
+
await withNodeCreateClaimsBatch(
|
|
406
|
+
writeContext,
|
|
407
|
+
work.map((item) => item.claim),
|
|
408
|
+
target,
|
|
409
|
+
() => runInsertBatch(
|
|
410
|
+
dispatch,
|
|
411
|
+
work.map((item) => item.params)
|
|
412
|
+
)
|
|
413
|
+
);
|
|
414
|
+
await applyNodeInsertSyncFansBatch(
|
|
415
|
+
writeContext,
|
|
416
|
+
work.map((item) => item.sideEffects),
|
|
417
|
+
target
|
|
418
|
+
);
|
|
419
|
+
},
|
|
420
|
+
reviseNode: (work, fences) => {
|
|
421
|
+
const draft = createWriteParamsDraft();
|
|
422
|
+
applyWriteFences(NODE_UPDATE_FENCE_APPLIERS, fences, draft);
|
|
423
|
+
return applyNodeUpdate(writeContext, { ...work, ...draft }, target);
|
|
424
|
+
},
|
|
425
|
+
retireNode: (work, policy) => applyNodeSoftDelete(writeContext, work, target, policy),
|
|
426
|
+
purgeNode: (work) => applyNodeHardDelete(writeContext, work, target),
|
|
427
|
+
reviveNode: (work) => applyNodeResurrect(writeContext, work, target),
|
|
428
|
+
reviseNodeSet: (work, fences) => {
|
|
429
|
+
applyWriteFences(
|
|
430
|
+
NODE_SET_UPDATE_FENCE_APPLIERS,
|
|
431
|
+
fences,
|
|
432
|
+
createWriteParamsDraft()
|
|
433
|
+
);
|
|
434
|
+
return applyNodeSetUpdate(writeContext, work, target);
|
|
435
|
+
},
|
|
436
|
+
// An edge write obliges no DERIVED data, so these apply no sync fans — but a
|
|
437
|
+
// constrained kind owes its cardinality claim, at the same PRE-INSERT
|
|
438
|
+
// placement a node's scope-spanning claim takes and for the same reason: the
|
|
439
|
+
// probe that authorised the insert read a population no key fences. The
|
|
440
|
+
// batch issues ONE sorted statement (`claimEdgeCardinalityBatch` orders by
|
|
441
|
+
// `compareClaimTargets`), so a batch and a peer batch take their row locks
|
|
442
|
+
// in the same order.
|
|
443
|
+
createEdge: async (work) => {
|
|
444
|
+
if (work.claim !== void 0) {
|
|
445
|
+
await claimEdgeCardinality(target, work.claim);
|
|
135
446
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
count > 0
|
|
447
|
+
return edgeDispatch.one(work.params);
|
|
448
|
+
},
|
|
449
|
+
createEdgeNoReturn: async (work) => {
|
|
450
|
+
if (work.claim !== void 0) {
|
|
451
|
+
await claimEdgeCardinality(target, work.claim);
|
|
452
|
+
}
|
|
453
|
+
await runInsertNoReturn(edgeDispatch, work.params);
|
|
454
|
+
},
|
|
455
|
+
createEdges: async (work) => {
|
|
456
|
+
await claimEdgeCardinalityBatch(target, edgeBatchClaims(work));
|
|
457
|
+
return runInsertBatchReturning(
|
|
458
|
+
edgeDispatch,
|
|
459
|
+
work.map((item) => item.params)
|
|
150
460
|
);
|
|
151
|
-
|
|
152
|
-
|
|
461
|
+
},
|
|
462
|
+
createEdgesNoReturn: async (work) => {
|
|
463
|
+
await claimEdgeCardinalityBatch(target, edgeBatchClaims(work));
|
|
464
|
+
await runInsertBatch(
|
|
465
|
+
edgeDispatch,
|
|
466
|
+
work.map((item) => item.params)
|
|
467
|
+
);
|
|
468
|
+
},
|
|
469
|
+
reviseEdge: (work, fences) => {
|
|
470
|
+
const draft = createWriteParamsDraft();
|
|
471
|
+
applyWriteFences(EDGE_UPDATE_FENCE_APPLIERS, fences, draft);
|
|
472
|
+
return applyEdgeUpdate(edgeContext, { ...work, ...draft }, target);
|
|
473
|
+
},
|
|
474
|
+
retireEdge: (work) => applyEdgeSoftDelete(edgeContext, work, target),
|
|
475
|
+
purgeEdge: (work) => applyEdgeHardDelete(edgeContext, work, target)
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// src/store/operations/write-executor.ts
|
|
480
|
+
function planFrame(ctx, plan, rowWork) {
|
|
481
|
+
return async (target, lock) => {
|
|
482
|
+
if (plan.requiresIdentityLock) {
|
|
483
|
+
const acquireIdentityLock = requireDefined(
|
|
484
|
+
ctx.identityLock,
|
|
485
|
+
"write plan declares identity participation with no acquirer"
|
|
486
|
+
);
|
|
487
|
+
await acquireIdentityLock(target);
|
|
153
488
|
}
|
|
154
|
-
|
|
489
|
+
const mintSessionOver = (sessionTarget) => createWriteSession(ctx, sessionTarget, lock);
|
|
490
|
+
const mintOverlaidSession = (reads) => mintSessionOver(deriveBackend(target, reads));
|
|
491
|
+
return rowWork(
|
|
492
|
+
mintSessionOver(target),
|
|
493
|
+
target,
|
|
494
|
+
mintOverlaidSession
|
|
495
|
+
);
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
function planTransactionOptions(plan, options) {
|
|
499
|
+
return { ...options, fencesConstraintProbe: plan.constraintProbe };
|
|
500
|
+
}
|
|
501
|
+
function runWritePlan(ctx, plan, backend, rowWork, options) {
|
|
502
|
+
return runInWriteTransaction(
|
|
503
|
+
ctx,
|
|
504
|
+
backend,
|
|
505
|
+
planFrame(ctx, plan, rowWork),
|
|
506
|
+
planTransactionOptions(plan, options)
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
function runHookedWritePlan(ctx, opContext, plan, backend, rowWork, options) {
|
|
510
|
+
return runHookedWriteOperation(
|
|
511
|
+
ctx,
|
|
512
|
+
opContext,
|
|
513
|
+
backend,
|
|
514
|
+
planFrame(ctx, plan, rowWork),
|
|
515
|
+
planTransactionOptions(plan, options)
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// src/store/operations/write-plan.ts
|
|
520
|
+
function nodeWritePlan(constraintProbe, requiresIdentityLock) {
|
|
521
|
+
return { entity: "node", constraintProbe, requiresIdentityLock };
|
|
522
|
+
}
|
|
523
|
+
function nodeBatchWritePlan(constraintProbes, requiresIdentityLock) {
|
|
524
|
+
return {
|
|
525
|
+
entity: "node",
|
|
526
|
+
constraintProbe: constraintProbes.find((probe) => probe !== void 0),
|
|
527
|
+
requiresIdentityLock
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
function edgeWritePlan(constraintProbe) {
|
|
531
|
+
return { entity: "edge", constraintProbe, requiresIdentityLock: false };
|
|
532
|
+
}
|
|
533
|
+
function mixedWritePlan(constraintProbe, requiresIdentityLock) {
|
|
534
|
+
return { entity: "mixed", constraintProbe, requiresIdentityLock };
|
|
155
535
|
}
|
|
156
536
|
|
|
157
537
|
// src/store/validity-end.ts
|
|
@@ -266,12 +646,18 @@ function nodeFencesConstraintProbe(ctx, kind, operation) {
|
|
|
266
646
|
operation
|
|
267
647
|
);
|
|
268
648
|
}
|
|
269
|
-
function
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
649
|
+
function nodeBatchConstraintProbes(ctx, inputs, operation) {
|
|
650
|
+
return inputs.map(
|
|
651
|
+
(input) => nodeFencesConstraintProbe(ctx, input.kind, operation)
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
function nodeWritePlanContext(ctx) {
|
|
655
|
+
const identity = ctx.identity;
|
|
656
|
+
if (identity === void 0) return ctx;
|
|
657
|
+
return { ...ctx, identityLock: identity.lock };
|
|
658
|
+
}
|
|
659
|
+
function nodeRequiresIdentityLock(ctx) {
|
|
660
|
+
return ctx.identity !== void 0;
|
|
275
661
|
}
|
|
276
662
|
function buildNodeCacheKey(graphId, kind, id) {
|
|
277
663
|
return encodeTupleKey([graphId, kind, id]);
|
|
@@ -290,14 +676,14 @@ function buildInsertNodeParams(graphId, kind, id, props, validFrom, validTo) {
|
|
|
290
676
|
if (validTo !== void 0) insertParams.validTo = validTo;
|
|
291
677
|
return insertParams;
|
|
292
678
|
}
|
|
293
|
-
function createPendingUniqueRow(graphId, nodeKind, constraintName, key,
|
|
679
|
+
function createPendingUniqueRow(graphId, nodeKind, constraintName, key, owner) {
|
|
294
680
|
return {
|
|
295
681
|
graph_id: graphId,
|
|
296
682
|
node_kind: nodeKind,
|
|
297
683
|
constraint_name: constraintName,
|
|
298
684
|
key,
|
|
299
|
-
node_id: nodeId,
|
|
300
|
-
concrete_kind:
|
|
685
|
+
node_id: owner.nodeId,
|
|
686
|
+
concrete_kind: owner.concreteKind,
|
|
301
687
|
deleted_at: void 0
|
|
302
688
|
};
|
|
303
689
|
}
|
|
@@ -312,7 +698,7 @@ function resolveConstraint(graph, kind, constraintName) {
|
|
|
312
698
|
}
|
|
313
699
|
return constraint;
|
|
314
700
|
}
|
|
315
|
-
function
|
|
701
|
+
function createNodeBatchValidationSeams(graphId, registry, backend) {
|
|
316
702
|
const nodeCache = /* @__PURE__ */ new Map();
|
|
317
703
|
const pendingNodes = /* @__PURE__ */ new Map();
|
|
318
704
|
const uniqueCache = /* @__PURE__ */ new Map();
|
|
@@ -368,71 +754,72 @@ function createNodeBatchValidationBackend(graphId, registry, backend) {
|
|
|
368
754
|
});
|
|
369
755
|
}
|
|
370
756
|
function registerPendingUniqueEntries(kind, id, props, constraints) {
|
|
371
|
-
for (const
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
757
|
+
for (const entry of nodeClaimEntries(
|
|
758
|
+
registry,
|
|
759
|
+
kind,
|
|
760
|
+
id,
|
|
761
|
+
props,
|
|
762
|
+
constraints,
|
|
763
|
+
"create"
|
|
764
|
+
)) {
|
|
765
|
+
pendingUniqueOwners.set(
|
|
766
|
+
buildUniqueCacheKey(
|
|
767
|
+
graphId,
|
|
768
|
+
entry.axis,
|
|
769
|
+
entry.constraintName,
|
|
770
|
+
entry.key
|
|
771
|
+
),
|
|
772
|
+
{ concreteKind: kind, nodeId: id }
|
|
383
773
|
);
|
|
384
|
-
pendingUniqueOwners.set(concreteEntryKey, id);
|
|
385
|
-
if (constraint.scope !== "kind") {
|
|
386
|
-
const kindsToCheck = getKindsForUniquenessCheck(
|
|
387
|
-
kind,
|
|
388
|
-
constraint.scope,
|
|
389
|
-
registry
|
|
390
|
-
);
|
|
391
|
-
for (const kindToCheck of kindsToCheck) {
|
|
392
|
-
const inheritedEntryKey = buildUniqueCacheKey(
|
|
393
|
-
graphId,
|
|
394
|
-
kindToCheck,
|
|
395
|
-
constraint.name,
|
|
396
|
-
key
|
|
397
|
-
);
|
|
398
|
-
pendingUniqueOwners.set(inheritedEntryKey, id);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
774
|
}
|
|
402
775
|
}
|
|
403
776
|
function registerAppliedNodeUpdate(kind, id, oldProps, newProps, constraints) {
|
|
777
|
+
const owner = { concreteKind: kind, nodeId: id };
|
|
778
|
+
const oldEntries = new Map(
|
|
779
|
+
nodeClaimEntries(registry, kind, id, oldProps, constraints, "update").map(
|
|
780
|
+
(entry) => [entry.constraintName, entry]
|
|
781
|
+
)
|
|
782
|
+
);
|
|
783
|
+
const newEntries = new Map(
|
|
784
|
+
nodeClaimEntries(registry, kind, id, newProps, constraints, "update").map(
|
|
785
|
+
(entry) => [entry.constraintName, entry]
|
|
786
|
+
)
|
|
787
|
+
);
|
|
404
788
|
for (const constraint of constraints) {
|
|
405
|
-
const
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
const
|
|
409
|
-
if (oldKey === newKey) continue;
|
|
410
|
-
const kindsToCheck = getKindsForUniquenessCheck(
|
|
789
|
+
const oldEntry = oldEntries.get(constraint.name);
|
|
790
|
+
const newEntry = newEntries.get(constraint.name);
|
|
791
|
+
if (oldEntry?.key === newEntry?.key) continue;
|
|
792
|
+
const kindsToCheck = uniquenessProbeKinds(
|
|
411
793
|
kind,
|
|
412
794
|
constraint.scope,
|
|
413
795
|
registry
|
|
414
796
|
);
|
|
415
|
-
if (
|
|
797
|
+
if (oldEntry !== void 0) {
|
|
416
798
|
for (const kindToCheck of kindsToCheck) {
|
|
417
799
|
const cacheKey = buildUniqueCacheKey(
|
|
418
800
|
graphId,
|
|
419
801
|
kindToCheck,
|
|
420
802
|
constraint.name,
|
|
421
|
-
|
|
803
|
+
oldEntry.key
|
|
422
804
|
);
|
|
423
805
|
pendingUniqueOwners.delete(cacheKey);
|
|
424
806
|
uniqueCache.set(cacheKey, void 0);
|
|
425
807
|
}
|
|
426
808
|
}
|
|
427
|
-
if (
|
|
809
|
+
if (newEntry !== void 0) {
|
|
428
810
|
for (const kindToCheck of kindsToCheck) {
|
|
429
811
|
const cacheKey = buildUniqueCacheKey(
|
|
430
812
|
graphId,
|
|
431
813
|
kindToCheck,
|
|
432
814
|
constraint.name,
|
|
433
|
-
|
|
815
|
+
newEntry.key
|
|
434
816
|
);
|
|
435
|
-
|
|
817
|
+
if (kindToCheck === newEntry.axis) {
|
|
818
|
+
pendingUniqueOwners.set(cacheKey, owner);
|
|
819
|
+
continue;
|
|
820
|
+
}
|
|
821
|
+
pendingUniqueOwners.delete(cacheKey);
|
|
822
|
+
uniqueCache.set(cacheKey, void 0);
|
|
436
823
|
}
|
|
437
824
|
}
|
|
438
825
|
}
|
|
@@ -447,12 +834,13 @@ function createNodeBatchValidationBackend(graphId, registry, backend) {
|
|
|
447
834
|
if (uniqueCache.has(cacheKey)) return;
|
|
448
835
|
uniqueCache.set(cacheKey, row);
|
|
449
836
|
}
|
|
450
|
-
const
|
|
837
|
+
const reads = {
|
|
451
838
|
getNode: getNodeCached,
|
|
452
839
|
checkUnique: checkUniqueCached
|
|
453
|
-
}
|
|
840
|
+
};
|
|
454
841
|
return {
|
|
455
|
-
|
|
842
|
+
reads,
|
|
843
|
+
reader: deriveBackend(backend, reads),
|
|
456
844
|
registerPendingNode,
|
|
457
845
|
registerPendingUniqueEntries,
|
|
458
846
|
registerAppliedNodeUpdate,
|
|
@@ -529,35 +917,33 @@ async function validateAndPrepareNodeCreate(ctx, input, id, backend, options) {
|
|
|
529
917
|
backend
|
|
530
918
|
);
|
|
531
919
|
}
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
920
|
+
function nodeCreateSideEffectItem(prepared) {
|
|
921
|
+
return {
|
|
922
|
+
kind: prepared.kind,
|
|
923
|
+
id: prepared.id,
|
|
924
|
+
schema: prepared.nodeKind.schema,
|
|
925
|
+
props: prepared.validatedProps,
|
|
926
|
+
uniqueConstraints: prepared.uniqueConstraints
|
|
927
|
+
};
|
|
928
|
+
}
|
|
929
|
+
function nodeCreateClaimItem(prepared) {
|
|
930
|
+
return {
|
|
931
|
+
kind: prepared.kind,
|
|
932
|
+
id: prepared.id,
|
|
933
|
+
props: prepared.validatedProps,
|
|
934
|
+
constraints: prepared.uniqueConstraints
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
function nodeInsertWork(prepared) {
|
|
938
|
+
return {
|
|
939
|
+
params: prepared.insertParams,
|
|
940
|
+
claim: nodeCreateClaimItem(prepared),
|
|
941
|
+
sideEffects: nodeCreateSideEffectItem(prepared)
|
|
942
|
+
};
|
|
544
943
|
}
|
|
545
944
|
function foldReferences(preparedCreates) {
|
|
546
945
|
return preparedCreates.filter((prepared) => prepared.idProvided).map((prepared) => ({ kind: prepared.kind, id: prepared.id }));
|
|
547
946
|
}
|
|
548
|
-
async function finalizeNodeCreate(ctx, prepared, backend, lock) {
|
|
549
|
-
await applyNodeInsertSideEffects(
|
|
550
|
-
createNodeWriteContext(ctx.graphId, ctx.registry, lock),
|
|
551
|
-
{
|
|
552
|
-
kind: prepared.kind,
|
|
553
|
-
id: prepared.id,
|
|
554
|
-
schema: prepared.nodeKind.schema,
|
|
555
|
-
props: prepared.validatedProps,
|
|
556
|
-
uniqueConstraints: prepared.uniqueConstraints
|
|
557
|
-
},
|
|
558
|
-
backend
|
|
559
|
-
);
|
|
560
|
-
}
|
|
561
947
|
function computeNodeUpdate(ctx, kind, id, existingProps, inputProps) {
|
|
562
948
|
const registration = getNodeRegistration(ctx.graph, kind);
|
|
563
949
|
const validatedProps = validateNodeProps(
|
|
@@ -591,10 +977,10 @@ function nodeUpsertDirtyCheck(ctx, kind, id, existingProps, inputProps) {
|
|
|
591
977
|
unchanged: canonicalEqual(validatedProps, existingProps)
|
|
592
978
|
};
|
|
593
979
|
}
|
|
594
|
-
async function performNodeUpdate(ctx, input,
|
|
980
|
+
async function performNodeUpdate(ctx, input, session, target, options) {
|
|
595
981
|
const { kind, id } = input;
|
|
596
982
|
assertValidityEndMutation(input, { entityType: "node", kind, id });
|
|
597
|
-
const existing = await
|
|
983
|
+
const existing = await target.getNode(ctx.graphId, kind, id);
|
|
598
984
|
if (!existing) throw new NodeNotFoundError(kind, id);
|
|
599
985
|
const { registration, validatedProps } = resolveNodeUpdateProps(
|
|
600
986
|
ctx,
|
|
@@ -626,55 +1012,44 @@ async function performNodeUpdate(ctx, input, backend, lock, options) {
|
|
|
626
1012
|
},
|
|
627
1013
|
validTo
|
|
628
1014
|
);
|
|
629
|
-
const writeContext = createNodeWriteContext(ctx.graphId, ctx.registry, lock);
|
|
630
1015
|
const shared = {
|
|
631
1016
|
schema: nodeKind.schema,
|
|
632
1017
|
validatedProps,
|
|
633
1018
|
uniqueConstraints: registration.unique ?? [],
|
|
634
1019
|
...validTo !== void 0 && { validTo },
|
|
635
|
-
...input.clearValidTo === true && { clearValidTo: true }
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
// the verdict consult the effective bound, and WAS that bound the row's
|
|
640
|
-
// stored one — are answered where they are known. A plain
|
|
641
|
-
// `update({ props })` states no window, reads no bound, and stays unfenced:
|
|
642
|
-
// the same rule `UpdateEdgeParams`'s identity components follow, for the
|
|
643
|
-
// same reason. The resurrecting leg is judged against `resurrectionInstant`
|
|
644
|
-
// and so fences on `deleted_at IS NOT NULL` alone, converging through the
|
|
645
|
-
// recovery below.
|
|
646
|
-
...windowVerdict.storedLowerBoundFence
|
|
1020
|
+
...input.clearValidTo === true && { clearValidTo: true }
|
|
1021
|
+
};
|
|
1022
|
+
const fences = {
|
|
1023
|
+
validityLowerBound: windowVerdict.storedLowerBoundFence
|
|
647
1024
|
};
|
|
648
1025
|
if (options?.clearDeleted) {
|
|
649
1026
|
const resurrectionLowerBound = resurrectionInstant === void 0 ? validFrom !== void 0 && { validFrom } : { validFrom: resurrectionBound ?? null };
|
|
650
|
-
const row2 = await
|
|
651
|
-
writeContext,
|
|
1027
|
+
const row2 = await session.reviseNode(
|
|
652
1028
|
{ ...shared, existing, clearDeleted: true, ...resurrectionLowerBound },
|
|
653
|
-
|
|
1029
|
+
fences
|
|
654
1030
|
);
|
|
655
1031
|
return rowToNode(row2);
|
|
656
1032
|
}
|
|
657
1033
|
if (!isLiveNodeRow(existing)) throw new NodeNotFoundError(kind, id);
|
|
658
|
-
const row = await
|
|
659
|
-
writeContext,
|
|
1034
|
+
const row = await session.reviseNode(
|
|
660
1035
|
// An in-place update must not rewrite the stored bound, so it keeps the
|
|
661
1036
|
// conditional spread: `buildUpdateNode` ignores `validFrom` off the
|
|
662
1037
|
// resurrection leg, and stating one here would claim a rewrite that no
|
|
663
1038
|
// statement performs.
|
|
664
1039
|
{ ...shared, existing, ...validFrom !== void 0 && { validFrom } },
|
|
665
|
-
|
|
1040
|
+
fences
|
|
666
1041
|
);
|
|
667
1042
|
return rowToNode(row);
|
|
668
1043
|
}
|
|
669
1044
|
var NODE_UPDATE_ATTEMPTS = 2;
|
|
670
|
-
async function performNodeUpdateWithResurrectionRecovery(ctx, input,
|
|
1045
|
+
async function performNodeUpdateWithResurrectionRecovery(ctx, input, session, target, options) {
|
|
671
1046
|
for (let attempt = 1; attempt <= NODE_UPDATE_ATTEMPTS; attempt += 1) {
|
|
672
1047
|
try {
|
|
673
1048
|
return await performNodeUpdate(
|
|
674
1049
|
ctx,
|
|
675
1050
|
input,
|
|
1051
|
+
session,
|
|
676
1052
|
target,
|
|
677
|
-
lock,
|
|
678
1053
|
attempt === 1 ? options : void 0
|
|
679
1054
|
);
|
|
680
1055
|
} catch (error) {
|
|
@@ -721,14 +1096,18 @@ async function primeBatchValidationCaches(ctx, drafts, backend, seams) {
|
|
|
721
1096
|
if (backend.checkUniqueBatch !== void 0) {
|
|
722
1097
|
const groups = /* @__PURE__ */ new Map();
|
|
723
1098
|
for (const draft of drafts) {
|
|
724
|
-
for (const
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
1099
|
+
for (const entry of nodeClaimEntries(
|
|
1100
|
+
ctx.registry,
|
|
1101
|
+
draft.kind,
|
|
1102
|
+
draft.id,
|
|
1103
|
+
draft.validatedProps,
|
|
1104
|
+
draft.uniqueConstraints,
|
|
1105
|
+
"create"
|
|
1106
|
+
)) {
|
|
1107
|
+
if (entry.refusal.kind !== "uniqueness") continue;
|
|
1108
|
+
const constraint = entry.refusal.constraint;
|
|
1109
|
+
const key = entry.key;
|
|
1110
|
+
const kindsToCheck = uniquenessProbeKinds(
|
|
732
1111
|
draft.kind,
|
|
733
1112
|
constraint.scope,
|
|
734
1113
|
ctx.registry
|
|
@@ -767,12 +1146,12 @@ async function primeBatchValidationCaches(ctx, drafts, backend, seams) {
|
|
|
767
1146
|
}
|
|
768
1147
|
async function prepareBatchCreates(ctx, inputs, backend, options) {
|
|
769
1148
|
const {
|
|
770
|
-
|
|
1149
|
+
reader: validationBackend,
|
|
771
1150
|
registerPendingNode,
|
|
772
1151
|
registerPendingUniqueEntries,
|
|
773
1152
|
seedNodeRow,
|
|
774
1153
|
seedUniqueRow
|
|
775
|
-
} =
|
|
1154
|
+
} = createNodeBatchValidationSeams(ctx.graphId, ctx.registry, backend);
|
|
776
1155
|
const drafts = inputs.map(
|
|
777
1156
|
(input) => draftNodeCreate(ctx, input, input.id ?? generateId(), options)
|
|
778
1157
|
);
|
|
@@ -813,7 +1192,7 @@ function partitionCreates(preparedCreates) {
|
|
|
813
1192
|
function isNodeUpdateNoRowError(error) {
|
|
814
1193
|
return error instanceof DatabaseOperationError && error.details.operation === "update" && error.details.entity === "node" && error.details.reason === "no_row_returned";
|
|
815
1194
|
}
|
|
816
|
-
async function resurrectPreparedNode(ctx,
|
|
1195
|
+
async function resurrectPreparedNode(ctx, session, target, prepared) {
|
|
817
1196
|
const current = await target.getNode(ctx.graphId, prepared.kind, prepared.id);
|
|
818
1197
|
if (current === void 0) {
|
|
819
1198
|
throw new DatabaseOperationError(
|
|
@@ -831,8 +1210,7 @@ async function resurrectPreparedNode(ctx, target, lock, prepared) {
|
|
|
831
1210
|
resurrectionInstant
|
|
832
1211
|
);
|
|
833
1212
|
try {
|
|
834
|
-
return await
|
|
835
|
-
createNodeWriteContext(ctx.graphId, ctx.registry, lock),
|
|
1213
|
+
return await session.reviseNode(
|
|
836
1214
|
{
|
|
837
1215
|
existing: current,
|
|
838
1216
|
clearDeleted: true,
|
|
@@ -845,7 +1223,11 @@ async function resurrectPreparedNode(ctx, target, lock, prepared) {
|
|
|
845
1223
|
validFrom: resurrectionBound ?? null,
|
|
846
1224
|
...prepared.insertParams.validTo === void 0 ? {} : { validTo: prepared.insertParams.validTo }
|
|
847
1225
|
},
|
|
848
|
-
|
|
1226
|
+
// This resurrection reads no stored bound: it rewrites the whole window
|
|
1227
|
+
// and is fenced by the UPDATE's own `deleted_at IS NOT NULL` predicate,
|
|
1228
|
+
// so it asserts nothing about `valid_from`. `{}` is how a write states
|
|
1229
|
+
// that, and it is the only way to state it.
|
|
1230
|
+
{ validityLowerBound: {} }
|
|
849
1231
|
);
|
|
850
1232
|
} catch (error) {
|
|
851
1233
|
if (!isNodeUpdateNoRowError(error)) throw error;
|
|
@@ -860,7 +1242,12 @@ async function resurrectPreparedNode(ctx, target, lock, prepared) {
|
|
|
860
1242
|
throw error;
|
|
861
1243
|
}
|
|
862
1244
|
}
|
|
1245
|
+
function prefersClaimRow(incumbent, candidate) {
|
|
1246
|
+
if (incumbent === void 0) return true;
|
|
1247
|
+
return incumbent.deleted_at !== void 0 && candidate.deleted_at === void 0;
|
|
1248
|
+
}
|
|
863
1249
|
async function findUniqueRowAcrossKinds(backend, graphId, constraintName, key, kindsToCheck, includeDeleted) {
|
|
1250
|
+
let preferred;
|
|
864
1251
|
for (const kindToCheck of kindsToCheck) {
|
|
865
1252
|
const row = await backend.checkUnique({
|
|
866
1253
|
graphId,
|
|
@@ -869,16 +1256,22 @@ async function findUniqueRowAcrossKinds(backend, graphId, constraintName, key, k
|
|
|
869
1256
|
key,
|
|
870
1257
|
includeDeleted
|
|
871
1258
|
});
|
|
872
|
-
if (row
|
|
1259
|
+
if (row === void 0) continue;
|
|
1260
|
+
if (!prefersClaimRow(preferred, row)) continue;
|
|
1261
|
+
preferred = row;
|
|
1262
|
+
if (row.deleted_at === void 0) return row;
|
|
873
1263
|
}
|
|
874
|
-
return
|
|
1264
|
+
return preferred;
|
|
875
1265
|
}
|
|
876
1266
|
async function batchCheckUniqueAcrossKinds(backend, graphId, constraintName, uniqueKeys, kindsToCheck, includeDeleted) {
|
|
877
1267
|
const existingByKey = /* @__PURE__ */ new Map();
|
|
878
1268
|
for (const kindToCheck of kindsToCheck) {
|
|
879
1269
|
if (backend.checkUniqueBatch === void 0) {
|
|
880
1270
|
for (const key of uniqueKeys) {
|
|
881
|
-
|
|
1271
|
+
const incumbent = existingByKey.get(key);
|
|
1272
|
+
if (incumbent !== void 0 && incumbent.deleted_at === void 0) {
|
|
1273
|
+
continue;
|
|
1274
|
+
}
|
|
882
1275
|
const row = await backend.checkUnique({
|
|
883
1276
|
graphId,
|
|
884
1277
|
nodeKind: kindToCheck,
|
|
@@ -886,7 +1279,7 @@ async function batchCheckUniqueAcrossKinds(backend, graphId, constraintName, uni
|
|
|
886
1279
|
key,
|
|
887
1280
|
includeDeleted
|
|
888
1281
|
});
|
|
889
|
-
if (row !== void 0) {
|
|
1282
|
+
if (row !== void 0 && prefersClaimRow(incumbent, row)) {
|
|
890
1283
|
existingByKey.set(row.key, row);
|
|
891
1284
|
}
|
|
892
1285
|
}
|
|
@@ -899,7 +1292,7 @@ async function batchCheckUniqueAcrossKinds(backend, graphId, constraintName, uni
|
|
|
899
1292
|
includeDeleted
|
|
900
1293
|
});
|
|
901
1294
|
for (const row of rows) {
|
|
902
|
-
if (
|
|
1295
|
+
if (prefersClaimRow(existingByKey.get(row.key), row)) {
|
|
903
1296
|
existingByKey.set(row.key, row);
|
|
904
1297
|
}
|
|
905
1298
|
}
|
|
@@ -912,13 +1305,16 @@ async function executeNodeCreateInternal(ctx, input, backend, options) {
|
|
|
912
1305
|
const id = input.id ?? generateId();
|
|
913
1306
|
const opContext = ctx.createOperationContext("create", "node", kind, id);
|
|
914
1307
|
const shouldReturnRow = options?.returnRow ?? true;
|
|
915
|
-
return
|
|
916
|
-
ctx,
|
|
1308
|
+
return runHookedWritePlan(
|
|
1309
|
+
nodeWritePlanContext(ctx),
|
|
917
1310
|
opContext,
|
|
1311
|
+
nodeWritePlan(
|
|
1312
|
+
nodeFencesConstraintProbe(ctx, kind, "create"),
|
|
1313
|
+
nodeRequiresIdentityLock(ctx)
|
|
1314
|
+
),
|
|
918
1315
|
backend,
|
|
919
|
-
async (
|
|
1316
|
+
async (session, target) => {
|
|
920
1317
|
const identity = ctx.identity;
|
|
921
|
-
if (identity !== void 0) await identity.lock(target);
|
|
922
1318
|
const prepared = await validateAndPrepareNodeCreate(
|
|
923
1319
|
ctx,
|
|
924
1320
|
input,
|
|
@@ -930,8 +1326,8 @@ async function executeNodeCreateInternal(ctx, input, backend, options) {
|
|
|
930
1326
|
if (existing !== void 0) {
|
|
931
1327
|
const resurrected = await resurrectPreparedNode(
|
|
932
1328
|
ctx,
|
|
1329
|
+
session,
|
|
933
1330
|
target,
|
|
934
|
-
lock,
|
|
935
1331
|
prepared
|
|
936
1332
|
);
|
|
937
1333
|
if (identity !== void 0) {
|
|
@@ -940,22 +1336,16 @@ async function executeNodeCreateInternal(ctx, input, backend, options) {
|
|
|
940
1336
|
return shouldReturnRow ? rowToNode(resurrected) : void 0;
|
|
941
1337
|
}
|
|
942
1338
|
const row = await withAlreadyExistsTranslation("node", async () => {
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
prepared.insertParams
|
|
947
|
-
);
|
|
1339
|
+
const work = nodeInsertWork(prepared);
|
|
1340
|
+
if (shouldReturnRow) return session.createNode(work);
|
|
1341
|
+
await session.createNodeNoReturn(work);
|
|
948
1342
|
return;
|
|
949
1343
|
});
|
|
950
|
-
await finalizeNodeCreate(ctx, prepared, target, lock);
|
|
951
1344
|
if (identity !== void 0) {
|
|
952
1345
|
await identity.foldCreated(target, foldReferences([prepared]));
|
|
953
1346
|
}
|
|
954
1347
|
if (row === void 0) return;
|
|
955
1348
|
return rowToNode(row);
|
|
956
|
-
},
|
|
957
|
-
{
|
|
958
|
-
fencesConstraintProbe: nodeFencesConstraintProbe(ctx, kind, "create")
|
|
959
1349
|
}
|
|
960
1350
|
);
|
|
961
1351
|
}
|
|
@@ -974,46 +1364,43 @@ async function executeNodeCreate(ctx, input, backend, options) {
|
|
|
974
1364
|
}
|
|
975
1365
|
async function executeNodeCreateNoReturnBatch(ctx, inputs, backend) {
|
|
976
1366
|
if (inputs.length === 0) return;
|
|
977
|
-
await
|
|
978
|
-
ctx,
|
|
1367
|
+
await runWritePlan(
|
|
1368
|
+
nodeWritePlanContext(ctx),
|
|
1369
|
+
nodeBatchWritePlan(
|
|
1370
|
+
nodeBatchConstraintProbes(ctx, inputs, "create"),
|
|
1371
|
+
nodeRequiresIdentityLock(ctx)
|
|
1372
|
+
),
|
|
979
1373
|
backend,
|
|
980
|
-
async (
|
|
1374
|
+
async (session, target) => {
|
|
981
1375
|
const identity = ctx.identity;
|
|
982
|
-
if (identity !== void 0) await identity.lock(target);
|
|
983
1376
|
const preparedCreates = await prepareBatchCreates(ctx, inputs, target);
|
|
984
1377
|
const partition = partitionCreates(preparedCreates);
|
|
985
1378
|
await withAlreadyExistsTranslation(
|
|
986
1379
|
"node",
|
|
987
|
-
() =>
|
|
988
|
-
|
|
989
|
-
partition.inserts.map((prepared) => prepared.insertParams)
|
|
1380
|
+
() => session.createNodesNoReturn(
|
|
1381
|
+
partition.inserts.map((prepared) => nodeInsertWork(prepared))
|
|
990
1382
|
)
|
|
991
1383
|
);
|
|
992
1384
|
for (const prepared of partition.resurrections) {
|
|
993
|
-
await resurrectPreparedNode(ctx,
|
|
1385
|
+
await resurrectPreparedNode(ctx, session, target, prepared);
|
|
994
1386
|
}
|
|
995
|
-
await finalizeNodeCreateBatch(ctx, partition.inserts, target, lock);
|
|
996
1387
|
if (identity !== void 0) {
|
|
997
1388
|
await identity.foldCreated(target, foldReferences(preparedCreates));
|
|
998
1389
|
}
|
|
999
|
-
},
|
|
1000
|
-
{
|
|
1001
|
-
fencesConstraintProbe: nodeBatchFencesConstraintProbe(
|
|
1002
|
-
ctx,
|
|
1003
|
-
inputs,
|
|
1004
|
-
"create"
|
|
1005
|
-
)
|
|
1006
1390
|
}
|
|
1007
1391
|
);
|
|
1008
1392
|
}
|
|
1009
1393
|
async function executeNodeCreateBatch(ctx, inputs, backend, options) {
|
|
1010
1394
|
if (inputs.length === 0) return [];
|
|
1011
|
-
return
|
|
1012
|
-
ctx,
|
|
1395
|
+
return runWritePlan(
|
|
1396
|
+
nodeWritePlanContext(ctx),
|
|
1397
|
+
nodeBatchWritePlan(
|
|
1398
|
+
nodeBatchConstraintProbes(ctx, inputs, "create"),
|
|
1399
|
+
nodeRequiresIdentityLock(ctx)
|
|
1400
|
+
),
|
|
1013
1401
|
backend,
|
|
1014
|
-
async (
|
|
1402
|
+
async (session, target) => {
|
|
1015
1403
|
const identity = ctx.identity;
|
|
1016
|
-
if (identity !== void 0) await identity.lock(target);
|
|
1017
1404
|
const preparedCreates = await prepareBatchCreates(
|
|
1018
1405
|
ctx,
|
|
1019
1406
|
inputs,
|
|
@@ -1023,18 +1410,16 @@ async function executeNodeCreateBatch(ctx, inputs, backend, options) {
|
|
|
1023
1410
|
const partition = partitionCreates(preparedCreates);
|
|
1024
1411
|
const inserted = await withAlreadyExistsTranslation(
|
|
1025
1412
|
"node",
|
|
1026
|
-
() =>
|
|
1027
|
-
|
|
1028
|
-
partition.inserts.map((prepared) => prepared.insertParams)
|
|
1413
|
+
() => session.createNodes(
|
|
1414
|
+
partition.inserts.map((prepared) => nodeInsertWork(prepared))
|
|
1029
1415
|
)
|
|
1030
1416
|
);
|
|
1031
1417
|
const resurrected = [];
|
|
1032
1418
|
for (const prepared of partition.resurrections) {
|
|
1033
1419
|
resurrected.push(
|
|
1034
|
-
await resurrectPreparedNode(ctx,
|
|
1420
|
+
await resurrectPreparedNode(ctx, session, target, prepared)
|
|
1035
1421
|
);
|
|
1036
1422
|
}
|
|
1037
|
-
await finalizeNodeCreateBatch(ctx, partition.inserts, target, lock);
|
|
1038
1423
|
const byReference = new Map(
|
|
1039
1424
|
[...inserted, ...resurrected].map((row) => [
|
|
1040
1425
|
refKey({ kind: row.kind, id: row.id }),
|
|
@@ -1051,39 +1436,36 @@ async function executeNodeCreateBatch(ctx, inputs, backend, options) {
|
|
|
1051
1436
|
await identity.foldCreated(target, foldReferences(preparedCreates));
|
|
1052
1437
|
}
|
|
1053
1438
|
return rows.map((row) => rowToNode(row));
|
|
1054
|
-
},
|
|
1055
|
-
{
|
|
1056
|
-
fencesConstraintProbe: nodeBatchFencesConstraintProbe(
|
|
1057
|
-
ctx,
|
|
1058
|
-
inputs,
|
|
1059
|
-
"create"
|
|
1060
|
-
)
|
|
1061
1439
|
}
|
|
1062
1440
|
);
|
|
1063
1441
|
}
|
|
1064
1442
|
async function executeNodeUpdate(ctx, input, backend, options) {
|
|
1443
|
+
if (input.clearValidTo === true) {
|
|
1444
|
+
assertClearValidToSupported(backend, "node");
|
|
1445
|
+
}
|
|
1065
1446
|
const opContext = ctx.createOperationContext(
|
|
1066
1447
|
"update",
|
|
1067
1448
|
"node",
|
|
1068
1449
|
input.kind,
|
|
1069
1450
|
input.id
|
|
1070
1451
|
);
|
|
1071
|
-
return
|
|
1072
|
-
ctx,
|
|
1452
|
+
return runHookedWritePlan(
|
|
1453
|
+
nodeWritePlanContext(ctx),
|
|
1073
1454
|
opContext,
|
|
1455
|
+
nodeWritePlan(
|
|
1456
|
+
nodeFencesConstraintProbe(ctx, input.kind, "update"),
|
|
1457
|
+
// Identity participates in an update when it RESURRECTS, and when it
|
|
1458
|
+
// states a validity end: a live-row update cannot change a node's kind, so
|
|
1459
|
+
// nothing folds, but an end reads the identity assertions that touch it.
|
|
1460
|
+
options?.clearDeleted === true || input.validTo !== void 0 ? nodeRequiresIdentityLock(ctx) : false
|
|
1461
|
+
),
|
|
1074
1462
|
backend,
|
|
1075
|
-
async (
|
|
1076
|
-
if (input.clearValidTo === true) {
|
|
1077
|
-
assertClearValidToSupported(backend, "node");
|
|
1078
|
-
}
|
|
1463
|
+
async (session, target) => {
|
|
1079
1464
|
const validTo = validateOptionalCanonicalIsoDate(
|
|
1080
1465
|
input.validTo,
|
|
1081
1466
|
"validTo"
|
|
1082
1467
|
);
|
|
1083
1468
|
const identity = ctx.identity;
|
|
1084
|
-
if (identity !== void 0 && (options?.clearDeleted === true || input.validTo !== void 0)) {
|
|
1085
|
-
await identity.lock(target);
|
|
1086
|
-
}
|
|
1087
1469
|
if (identity !== void 0 && validTo !== void 0) {
|
|
1088
1470
|
await identity.requireValidityEndCompatible(
|
|
1089
1471
|
target,
|
|
@@ -1094,8 +1476,8 @@ async function executeNodeUpdate(ctx, input, backend, options) {
|
|
|
1094
1476
|
const node = await performNodeUpdateWithResurrectionRecovery(
|
|
1095
1477
|
ctx,
|
|
1096
1478
|
input,
|
|
1479
|
+
session,
|
|
1097
1480
|
target,
|
|
1098
|
-
lock,
|
|
1099
1481
|
options
|
|
1100
1482
|
);
|
|
1101
1483
|
if (options?.clearDeleted && identity !== void 0) {
|
|
@@ -1104,13 +1486,6 @@ async function executeNodeUpdate(ctx, input, backend, options) {
|
|
|
1104
1486
|
]);
|
|
1105
1487
|
}
|
|
1106
1488
|
return node;
|
|
1107
|
-
},
|
|
1108
|
-
{
|
|
1109
|
-
fencesConstraintProbe: nodeFencesConstraintProbe(
|
|
1110
|
-
ctx,
|
|
1111
|
-
input.kind,
|
|
1112
|
-
"update"
|
|
1113
|
-
)
|
|
1114
1489
|
}
|
|
1115
1490
|
);
|
|
1116
1491
|
}
|
|
@@ -1205,107 +1580,32 @@ async function executeNodeUpdateWhere(ctx, kind, inputPatch, candidateIds, candi
|
|
|
1205
1580
|
const hookContext = ctx.createBulkOperationContext("updateWhere", kind);
|
|
1206
1581
|
return ctx.withBulkOperationHooks(
|
|
1207
1582
|
hookContext,
|
|
1208
|
-
() =>
|
|
1209
|
-
ctx,
|
|
1583
|
+
() => runWritePlan(
|
|
1584
|
+
nodeWritePlanContext(ctx),
|
|
1585
|
+
// The set update re-checks every changed unique key across the
|
|
1586
|
+
// constraint's scope before rebuilding the sidecars, so a shared-scope
|
|
1587
|
+
// constraint makes it a constrained write like any other update.
|
|
1588
|
+
// Identity does not participate: a set update rewrites props, and no
|
|
1589
|
+
// patch can change a node's kind.
|
|
1590
|
+
nodeWritePlan(nodeFencesConstraintProbe(ctx, kind, "update"), false),
|
|
1210
1591
|
backend,
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
if (updateNodeSet === void 0) {
|
|
1214
|
-
throw new ConfigurationError(
|
|
1215
|
-
"The transaction backend does not support set-based node updates",
|
|
1216
|
-
{ code: "SET_UPDATE_UNSUPPORTED", kind }
|
|
1217
|
-
);
|
|
1218
|
-
}
|
|
1219
|
-
const hardDeleteUniquesByNodeIds = target.hardDeleteUniquesByNodeIds;
|
|
1220
|
-
if (uniqueConstraints.length > 0 && (hardDeleteUniquesByNodeIds === void 0 || target.insertUniqueBatch === void 0 || target.checkUniqueBatch === void 0)) {
|
|
1221
|
-
throw new ConfigurationError(
|
|
1222
|
-
"The transaction backend lacks batched uniqueness operations",
|
|
1223
|
-
{ code: "SET_UPDATE_UNIQUENESS_UNSUPPORTED", kind }
|
|
1224
|
-
);
|
|
1225
|
-
}
|
|
1226
|
-
if (getSearchableFields(schema).length > 0 && (target.upsertFulltext === void 0 || target.deleteFulltext === void 0 || target.upsertFulltextBatch === void 0 || target.deleteFulltextBatch === void 0)) {
|
|
1227
|
-
throw new ConfigurationError(
|
|
1228
|
-
"The transaction backend lacks batched fulltext operations",
|
|
1229
|
-
{ code: "SET_UPDATE_FULLTEXT_UNSUPPORTED", kind }
|
|
1230
|
-
);
|
|
1231
|
-
}
|
|
1232
|
-
if (getEmbeddingFields(schema).length > 0 && (target.upsertEmbedding === void 0 || target.deleteEmbedding === void 0 || target.upsertEmbeddingBatch === void 0 || target.deleteEmbeddingBatch === void 0)) {
|
|
1233
|
-
throw new ConfigurationError(
|
|
1234
|
-
"The transaction backend lacks batched vector operations",
|
|
1235
|
-
{ code: "SET_UPDATE_VECTOR_UNSUPPORTED", kind }
|
|
1236
|
-
);
|
|
1237
|
-
}
|
|
1238
|
-
const result = await updateNodeSet({
|
|
1239
|
-
graphId: ctx.graphId,
|
|
1592
|
+
(session) => session.reviseNodeSet(
|
|
1593
|
+
{
|
|
1240
1594
|
kind,
|
|
1595
|
+
schema,
|
|
1596
|
+
uniqueConstraints,
|
|
1241
1597
|
patch,
|
|
1242
1598
|
unsetProperties,
|
|
1243
1599
|
candidateIds,
|
|
1244
1600
|
candidateIdColumn
|
|
1245
|
-
}
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
});
|
|
1254
|
-
if (!canonicalEqual(validatedProps, props)) {
|
|
1255
|
-
throw new ValidationError(
|
|
1256
|
-
`Set update would persist a non-canonical ${kind} row`,
|
|
1257
|
-
{
|
|
1258
|
-
entityType: "node",
|
|
1259
|
-
kind,
|
|
1260
|
-
operation: "update",
|
|
1261
|
-
id: row.id,
|
|
1262
|
-
issues: [
|
|
1263
|
-
{
|
|
1264
|
-
path: "props",
|
|
1265
|
-
message: "The complete row requires schema normalization"
|
|
1266
|
-
}
|
|
1267
|
-
]
|
|
1268
|
-
}
|
|
1269
|
-
);
|
|
1270
|
-
}
|
|
1271
|
-
return {
|
|
1272
|
-
kind,
|
|
1273
|
-
id: row.id,
|
|
1274
|
-
schema,
|
|
1275
|
-
props: validatedProps,
|
|
1276
|
-
uniqueConstraints
|
|
1277
|
-
};
|
|
1278
|
-
});
|
|
1279
|
-
if (uniqueConstraints.length > 0) {
|
|
1280
|
-
await validateResolvedNodeUniqueness(
|
|
1281
|
-
createUniquenessContext(ctx.graphId, ctx.registry, target),
|
|
1282
|
-
sidecarItems.map((item) => ({
|
|
1283
|
-
kind: item.kind,
|
|
1284
|
-
id: item.id,
|
|
1285
|
-
props: item.props,
|
|
1286
|
-
constraints: item.uniqueConstraints
|
|
1287
|
-
}))
|
|
1288
|
-
);
|
|
1289
|
-
await requireDefined(hardDeleteUniquesByNodeIds)({
|
|
1290
|
-
graphId: ctx.graphId,
|
|
1291
|
-
concreteKind: kind,
|
|
1292
|
-
nodeIds: result.rows.map((row) => row.id)
|
|
1293
|
-
});
|
|
1294
|
-
}
|
|
1295
|
-
await applyNodeInsertSideEffectsBatch(
|
|
1296
|
-
createNodeWriteContext(ctx.graphId, ctx.registry, lock),
|
|
1297
|
-
sidecarItems,
|
|
1298
|
-
target
|
|
1299
|
-
);
|
|
1300
|
-
return { affectedCount: result.affectedCount };
|
|
1301
|
-
},
|
|
1302
|
-
{
|
|
1303
|
-
didWrite: (result) => result.affectedCount > 0,
|
|
1304
|
-
// The set update re-checks every changed unique key across the
|
|
1305
|
-
// constraint's scope before rebuilding the sidecars, so a shared-scope
|
|
1306
|
-
// constraint makes it a constrained write like any other update.
|
|
1307
|
-
fencesConstraintProbe: nodeFencesConstraintProbe(ctx, kind, "update")
|
|
1308
|
-
}
|
|
1601
|
+
},
|
|
1602
|
+
// This path states no window — it patches properties — so the write
|
|
1603
|
+
// asserts no stored lower bound. The set UPDATE has no field to
|
|
1604
|
+
// carry one, so a future windowed set update is refused here rather
|
|
1605
|
+
// than run unfenced.
|
|
1606
|
+
{ validityLowerBound: {} }
|
|
1607
|
+
),
|
|
1608
|
+
{ didWrite: (result) => result.affectedCount > 0 }
|
|
1309
1609
|
)
|
|
1310
1610
|
);
|
|
1311
1611
|
}
|
|
@@ -1313,18 +1613,22 @@ async function executeNodeUpsertUpdate(ctx, input, backend, options) {
|
|
|
1313
1613
|
if (input.clearValidTo === true) {
|
|
1314
1614
|
assertClearValidToSupported(backend, "node");
|
|
1315
1615
|
}
|
|
1316
|
-
return
|
|
1317
|
-
ctx,
|
|
1616
|
+
return runWritePlan(
|
|
1617
|
+
nodeWritePlanContext(ctx),
|
|
1618
|
+
nodeWritePlan(
|
|
1619
|
+
nodeFencesConstraintProbe(ctx, input.kind, "update"),
|
|
1620
|
+
// Conditional for the same reason as {@link executeNodeUpdate}: a
|
|
1621
|
+
// resurrecting upsert folds, and stating a validity end reads the
|
|
1622
|
+
// identity's other members, so both take the lock.
|
|
1623
|
+
options?.clearDeleted === true || input.validTo !== void 0 ? nodeRequiresIdentityLock(ctx) : false
|
|
1624
|
+
),
|
|
1318
1625
|
backend,
|
|
1319
|
-
async (
|
|
1626
|
+
async (session, target) => {
|
|
1320
1627
|
const validTo = validateOptionalCanonicalIsoDate(
|
|
1321
1628
|
input.validTo,
|
|
1322
1629
|
"validTo"
|
|
1323
1630
|
);
|
|
1324
1631
|
const identity = ctx.identity;
|
|
1325
|
-
if (identity !== void 0 && (options?.clearDeleted === true || input.validTo !== void 0)) {
|
|
1326
|
-
await identity.lock(target);
|
|
1327
|
-
}
|
|
1328
1632
|
if (identity !== void 0 && validTo !== void 0) {
|
|
1329
1633
|
await identity.requireValidityEndCompatible(
|
|
1330
1634
|
target,
|
|
@@ -1335,8 +1639,8 @@ async function executeNodeUpsertUpdate(ctx, input, backend, options) {
|
|
|
1335
1639
|
const node = await performNodeUpdateWithResurrectionRecovery(
|
|
1336
1640
|
ctx,
|
|
1337
1641
|
input,
|
|
1642
|
+
session,
|
|
1338
1643
|
target,
|
|
1339
|
-
lock,
|
|
1340
1644
|
options
|
|
1341
1645
|
);
|
|
1342
1646
|
if (options?.clearDeleted && identity !== void 0) {
|
|
@@ -1345,13 +1649,6 @@ async function executeNodeUpsertUpdate(ctx, input, backend, options) {
|
|
|
1345
1649
|
]);
|
|
1346
1650
|
}
|
|
1347
1651
|
return node;
|
|
1348
|
-
},
|
|
1349
|
-
{
|
|
1350
|
-
fencesConstraintProbe: nodeFencesConstraintProbe(
|
|
1351
|
-
ctx,
|
|
1352
|
-
input.kind,
|
|
1353
|
-
"update"
|
|
1354
|
-
)
|
|
1355
1652
|
}
|
|
1356
1653
|
);
|
|
1357
1654
|
}
|
|
@@ -1359,26 +1656,22 @@ async function executeNodeDelete(ctx, kind, id, backend) {
|
|
|
1359
1656
|
const gate = await backend.getNode(ctx.graphId, kind, id);
|
|
1360
1657
|
if (!gate || gate.deleted_at) return;
|
|
1361
1658
|
const opContext = ctx.createOperationContext("delete", "node", kind, id);
|
|
1362
|
-
return
|
|
1363
|
-
ctx,
|
|
1659
|
+
return runHookedWritePlan(
|
|
1660
|
+
nodeWritePlanContext(ctx),
|
|
1364
1661
|
opContext,
|
|
1662
|
+
nodeWritePlan(void 0, nodeRequiresIdentityLock(ctx)),
|
|
1365
1663
|
backend,
|
|
1366
|
-
async (
|
|
1664
|
+
async (session, target) => {
|
|
1367
1665
|
const identity = ctx.identity;
|
|
1368
|
-
if (identity !== void 0) await identity.lock(target);
|
|
1369
1666
|
const registration = getNodeRegistration(ctx.graph, kind);
|
|
1370
1667
|
const preflight = await target.getNode(ctx.graphId, kind, id);
|
|
1371
1668
|
if (!preflight || !isLiveNodeRow(preflight)) return;
|
|
1372
|
-
await
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
onDelete: registration.onDelete
|
|
1379
|
-
},
|
|
1380
|
-
target
|
|
1381
|
-
);
|
|
1669
|
+
await session.retireNode({
|
|
1670
|
+
existing: preflight,
|
|
1671
|
+
schema: registration.type.schema,
|
|
1672
|
+
uniqueConstraints: registration.unique ?? [],
|
|
1673
|
+
onDelete: registration.onDelete
|
|
1674
|
+
});
|
|
1382
1675
|
if (identity !== void 0) {
|
|
1383
1676
|
await identity.detachDeleted(target, { kind, id }, "soft");
|
|
1384
1677
|
}
|
|
@@ -1386,32 +1679,23 @@ async function executeNodeDelete(ctx, kind, id, backend) {
|
|
|
1386
1679
|
);
|
|
1387
1680
|
}
|
|
1388
1681
|
async function executeNodeDeleteBatch(ctx, kind, ids, backend) {
|
|
1389
|
-
await
|
|
1390
|
-
ctx,
|
|
1682
|
+
await runWritePlan(
|
|
1683
|
+
nodeWritePlanContext(ctx),
|
|
1684
|
+
nodeWritePlan(void 0, nodeRequiresIdentityLock(ctx)),
|
|
1391
1685
|
backend,
|
|
1392
|
-
async (
|
|
1686
|
+
async (session, target) => {
|
|
1393
1687
|
const identity = ctx.identity;
|
|
1394
|
-
if (identity !== void 0) await identity.lock(target);
|
|
1395
1688
|
const registration = getNodeRegistration(ctx.graph, kind);
|
|
1396
|
-
const writeContext = createNodeWriteContext(
|
|
1397
|
-
ctx.graphId,
|
|
1398
|
-
ctx.registry,
|
|
1399
|
-
lock
|
|
1400
|
-
);
|
|
1401
1689
|
let affectedCount = 0;
|
|
1402
1690
|
for (const id of ids) {
|
|
1403
1691
|
const preflight = await target.getNode(ctx.graphId, kind, id);
|
|
1404
1692
|
if (!preflight || !isLiveNodeRow(preflight)) continue;
|
|
1405
|
-
await
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
onDelete: registration.onDelete
|
|
1412
|
-
},
|
|
1413
|
-
target
|
|
1414
|
-
);
|
|
1693
|
+
await session.retireNode({
|
|
1694
|
+
existing: preflight,
|
|
1695
|
+
schema: registration.type.schema,
|
|
1696
|
+
uniqueConstraints: registration.unique ?? [],
|
|
1697
|
+
onDelete: registration.onDelete
|
|
1698
|
+
});
|
|
1415
1699
|
if (identity !== void 0) {
|
|
1416
1700
|
await identity.detachDeleted(target, { kind, id }, "soft");
|
|
1417
1701
|
}
|
|
@@ -1426,24 +1710,20 @@ async function executeNodeHardDelete(ctx, kind, id, backend) {
|
|
|
1426
1710
|
const gate = await backend.getNode(ctx.graphId, kind, id);
|
|
1427
1711
|
if (!gate) return;
|
|
1428
1712
|
const opContext = ctx.createOperationContext("delete", "node", kind, id);
|
|
1429
|
-
return
|
|
1430
|
-
ctx,
|
|
1713
|
+
return runHookedWritePlan(
|
|
1714
|
+
nodeWritePlanContext(ctx),
|
|
1431
1715
|
opContext,
|
|
1716
|
+
nodeWritePlan(void 0, nodeRequiresIdentityLock(ctx)),
|
|
1432
1717
|
backend,
|
|
1433
|
-
async (
|
|
1718
|
+
async (session, target) => {
|
|
1434
1719
|
const identity = ctx.identity;
|
|
1435
|
-
if (identity !== void 0) await identity.lock(target);
|
|
1436
1720
|
const registration = getNodeRegistration(ctx.graph, kind);
|
|
1437
|
-
await
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
onDelete: registration.onDelete
|
|
1444
|
-
},
|
|
1445
|
-
target
|
|
1446
|
-
);
|
|
1721
|
+
await session.purgeNode({
|
|
1722
|
+
kind,
|
|
1723
|
+
id,
|
|
1724
|
+
schema: registration.type.schema,
|
|
1725
|
+
onDelete: registration.onDelete
|
|
1726
|
+
});
|
|
1447
1727
|
if (identity !== void 0) {
|
|
1448
1728
|
await identity.detachDeleted(target, { kind, id }, "hard");
|
|
1449
1729
|
}
|
|
@@ -1473,7 +1753,7 @@ async function executeNodeGetOrCreateByConstraint(ctx, kind, constraintName, pro
|
|
|
1473
1753
|
constraint.fields,
|
|
1474
1754
|
constraint.collation
|
|
1475
1755
|
);
|
|
1476
|
-
const kindsToCheck =
|
|
1756
|
+
const kindsToCheck = uniquenessProbeKinds(
|
|
1477
1757
|
kind,
|
|
1478
1758
|
constraint.scope,
|
|
1479
1759
|
ctx.registry
|
|
@@ -1548,7 +1828,7 @@ async function executeNodeFindByConstraint(ctx, kind, constraintName, props, bac
|
|
|
1548
1828
|
constraint.fields,
|
|
1549
1829
|
constraint.collation
|
|
1550
1830
|
);
|
|
1551
|
-
const kindsToCheck =
|
|
1831
|
+
const kindsToCheck = uniquenessProbeKinds(
|
|
1552
1832
|
kind,
|
|
1553
1833
|
constraint.scope,
|
|
1554
1834
|
ctx.registry
|
|
@@ -1602,7 +1882,7 @@ async function executeNodeBulkFindByConstraint(ctx, kind, constraintName, items,
|
|
|
1602
1882
|
const constraint = resolveConstraint(ctx.graph, kind, constraintName);
|
|
1603
1883
|
const validated = validateAndComputeKeys(nodeKind, kind, constraint, items);
|
|
1604
1884
|
const uniqueKeys = collectUniqueKeys(validated);
|
|
1605
|
-
const kindsToCheck =
|
|
1885
|
+
const kindsToCheck = uniquenessProbeKinds(
|
|
1606
1886
|
kind,
|
|
1607
1887
|
constraint.scope,
|
|
1608
1888
|
ctx.registry
|
|
@@ -1877,7 +2157,7 @@ async function executeNodeBulkGetOrCreateByConstraint(ctx, kind, constraintName,
|
|
|
1877
2157
|
const constraint = resolveConstraint(ctx.graph, kind, constraintName);
|
|
1878
2158
|
const validated = validateAndComputeKeys(nodeKind, kind, constraint, items);
|
|
1879
2159
|
const uniqueKeys = collectUniqueKeys(validated);
|
|
1880
|
-
const kindsToCheck =
|
|
2160
|
+
const kindsToCheck = uniquenessProbeKinds(
|
|
1881
2161
|
kind,
|
|
1882
2162
|
constraint.scope,
|
|
1883
2163
|
ctx.registry
|
|
@@ -1985,6 +2265,6 @@ async function executeNodeBulkGetOrCreateByConstraint(ctx, kind, constraintName,
|
|
|
1985
2265
|
}
|
|
1986
2266
|
}
|
|
1987
2267
|
|
|
1988
|
-
export { assertClearValidToSupported, assertValidityEndMutation, checkCardinalityConstraint,
|
|
1989
|
-
//# sourceMappingURL=chunk-
|
|
1990
|
-
//# sourceMappingURL=chunk-
|
|
2268
|
+
export { assertClearValidToSupported, assertValidityEndMutation, assertsStoredWindowState, checkCardinalityConstraint, checkDisjointnessConstraint, createEdgeBatchValidationBackend, createNodeBatchValidationSeams, edgeWriteNeedsConstraintFence, edgeWritePlan, executeNodeBulkFindByConstraint, executeNodeBulkFindByIndex, executeNodeBulkGetOrCreateByConstraint, executeNodeCreate, executeNodeCreateBatch, executeNodeCreateNoReturnBatch, executeNodeDelete, executeNodeDeleteBatch, executeNodeFindByConstraint, executeNodeGetOrCreateByConstraint, executeNodeHardDelete, executeNodeUpdate, executeNodeUpdateWhere, executeNodeUpsertUpdate, graphOwesClaims, mixedWritePlan, nodeUpsertDirtyCheck, primeBatchValidationCaches, rowToEdge, rowToEdgeMeta, rowToNode, rowToNodeMeta, runHookedWritePlan, runWritePlan, unfencedTarget, validityEndAfterMutation, withAlreadyExistsTranslation };
|
|
2269
|
+
//# sourceMappingURL=chunk-2GIV5X4P.js.map
|
|
2270
|
+
//# sourceMappingURL=chunk-2GIV5X4P.js.map
|