@nicia-ai/typegraph 0.49.0 → 0.51.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/README.md +12 -0
- package/dist/backend/drizzle/indexes.cjs +11 -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 +7 -5
- package/dist/backend/index.cjs +190 -53
- package/dist/backend/index.d.cts +90 -4
- package/dist/backend/index.d.ts +90 -4
- package/dist/backend/index.js +9 -12
- package/dist/backend/postgres/index.cjs +36 -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 +19 -15
- package/dist/backend/postgres/pglite-store.cjs +7 -62
- 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 +7 -62
- package/dist/backend/postgres/pglite-store.js.map +1 -1
- package/dist/backend/postgres/pglite.cjs +21 -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 +20 -16
- package/dist/backend/sqlite/index.cjs +33 -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 +17 -13
- package/dist/backend/sqlite/libsql.cjs +24 -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 +19 -15
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local-store.cjs +9 -64
- 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 +8 -64
- package/dist/backend/sqlite/local-store.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +25 -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 +21 -16
- package/dist/chunk-2CVDZCXH.cjs +1278 -0
- package/dist/chunk-2CVDZCXH.cjs.map +1 -0
- package/dist/{chunk-MYKHJI2J.js → chunk-2DWTBNSH.js} +3 -3
- package/dist/{chunk-MYKHJI2J.js.map → chunk-2DWTBNSH.js.map} +1 -1
- package/dist/{chunk-JB6T4GLL.cjs → chunk-2KCTP3U2.cjs} +870 -528
- package/dist/chunk-2KCTP3U2.cjs.map +1 -0
- package/dist/{chunk-OORXGFL5.cjs → chunk-322TBTOQ.cjs} +48 -48
- package/dist/{chunk-OORXGFL5.cjs.map → chunk-322TBTOQ.cjs.map} +1 -1
- package/dist/{chunk-FA2AFWLP.cjs → chunk-36SX6QXP.cjs} +31 -12
- package/dist/chunk-36SX6QXP.cjs.map +1 -0
- package/dist/{chunk-SDBBMD4N.js → chunk-36VYWVQU.js} +3 -3
- package/dist/{chunk-SDBBMD4N.js.map → chunk-36VYWVQU.js.map} +1 -1
- package/dist/chunk-4DKY6RIU.js +1253 -0
- package/dist/chunk-4DKY6RIU.js.map +1 -0
- package/dist/chunk-4QKOZYMV.js +9 -0
- package/dist/chunk-4QKOZYMV.js.map +1 -0
- package/dist/{chunk-WIC7DRXW.js → chunk-57JM6NW3.js} +9 -19
- package/dist/chunk-57JM6NW3.js.map +1 -0
- package/dist/chunk-5WWEYV4H.cjs +5113 -0
- package/dist/chunk-5WWEYV4H.cjs.map +1 -0
- package/dist/chunk-6KQEICJ6.cjs +12 -0
- package/dist/{chunk-MKJ4KXL5.cjs.map → chunk-6KQEICJ6.cjs.map} +1 -1
- 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-KKBDXCLQ.js → chunk-6NLYIMJO.js} +4 -4
- package/dist/{chunk-KKBDXCLQ.js.map → chunk-6NLYIMJO.js.map} +1 -1
- package/dist/{chunk-BFUOME67.cjs → chunk-7B7I7YAW.cjs} +20 -11
- package/dist/chunk-7B7I7YAW.cjs.map +1 -0
- package/dist/{chunk-ZDKTPBGV.js → chunk-7G5IYROL.js} +6 -548
- package/dist/chunk-7G5IYROL.js.map +1 -0
- package/dist/{chunk-3DMMGT6S.js → chunk-7QFRK6PU.js} +4 -8
- package/dist/chunk-7QFRK6PU.js.map +1 -0
- package/dist/chunk-A4C4NJ5U.cjs +12 -0
- package/dist/chunk-A4C4NJ5U.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-UGHQV7MP.cjs → chunk-B3MN7EJR.cjs} +228 -162
- package/dist/chunk-B3MN7EJR.cjs.map +1 -0
- package/dist/{chunk-TZEGUG6D.cjs → chunk-BZ5MVITP.cjs} +4 -4
- package/dist/{chunk-TZEGUG6D.cjs.map → chunk-BZ5MVITP.cjs.map} +1 -1
- package/dist/{chunk-YVF2EM7B.js → chunk-CAI6SMP6.js} +3 -3
- package/dist/{chunk-YVF2EM7B.js.map → chunk-CAI6SMP6.js.map} +1 -1
- package/dist/{chunk-JONXFAPO.js → chunk-CBOD7TXH.js} +5 -5
- package/dist/{chunk-JONXFAPO.js.map → chunk-CBOD7TXH.js.map} +1 -1
- package/dist/{chunk-FQPEMEWX.cjs → chunk-CRZ56SZU.cjs} +81 -32
- package/dist/chunk-CRZ56SZU.cjs.map +1 -0
- package/dist/{chunk-DO7SAMEK.cjs → chunk-D3GWARN7.cjs} +47 -47
- package/dist/{chunk-DO7SAMEK.cjs.map → chunk-D3GWARN7.cjs.map} +1 -1
- package/dist/{chunk-QTD6HX4O.js → chunk-D3OUDFU7.js} +5 -5
- package/dist/{chunk-QTD6HX4O.js.map → chunk-D3OUDFU7.js.map} +1 -1
- 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-EKG2UXNX.cjs +23 -0
- package/dist/chunk-EKG2UXNX.cjs.map +1 -0
- package/dist/chunk-FMMW3KX7.cjs +148 -0
- package/dist/chunk-FMMW3KX7.cjs.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-H2VWDQWC.cjs +571 -0
- package/dist/chunk-H2VWDQWC.cjs.map +1 -0
- package/dist/chunk-H4FY6OZK.js +13 -0
- package/dist/chunk-H4FY6OZK.js.map +1 -0
- package/dist/{chunk-EDN4Y4ZG.cjs → chunk-H5IJSROF.cjs} +9 -15
- package/dist/chunk-H5IJSROF.cjs.map +1 -0
- package/dist/chunk-HZUB5CON.js +27 -0
- package/dist/chunk-HZUB5CON.js.map +1 -0
- package/dist/{chunk-NACVVDWB.js → chunk-I5IOSA27.js} +103 -105
- package/dist/chunk-I5IOSA27.js.map +1 -0
- package/dist/{chunk-OI2GQ25X.cjs → chunk-I7YAY2VQ.cjs} +7 -7
- package/dist/{chunk-OI2GQ25X.cjs.map → chunk-I7YAY2VQ.cjs.map} +1 -1
- package/dist/chunk-IRCWIA3R.js +20 -0
- package/dist/chunk-IRCWIA3R.js.map +1 -0
- package/dist/chunk-IVQBLXBK.cjs +55 -0
- package/dist/chunk-IVQBLXBK.cjs.map +1 -0
- package/dist/{chunk-7SQSZN2J.js → chunk-IZD4HTCP.js} +5 -5
- package/dist/{chunk-7SQSZN2J.js.map → chunk-IZD4HTCP.js.map} +1 -1
- package/dist/{chunk-3FPR224C.cjs → chunk-JHRUZ73O.cjs} +116 -107
- package/dist/chunk-JHRUZ73O.cjs.map +1 -0
- package/dist/{chunk-EZEEWCFJ.cjs → chunk-JQKMEKKW.cjs} +525 -298
- package/dist/chunk-JQKMEKKW.cjs.map +1 -0
- package/dist/chunk-JVA3KDEA.cjs +691 -0
- package/dist/chunk-JVA3KDEA.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-7LZJNLA5.js → chunk-K67P5DLL.js} +108 -42
- package/dist/chunk-K67P5DLL.js.map +1 -0
- package/dist/{chunk-3G5W2U2L.cjs → chunk-KACEYDYV.cjs} +335 -258
- package/dist/chunk-KACEYDYV.cjs.map +1 -0
- package/dist/{chunk-JFRT7S3B.cjs → chunk-L6EVYIID.cjs} +318 -478
- package/dist/chunk-L6EVYIID.cjs.map +1 -0
- package/dist/{chunk-SHFBB23Q.js → chunk-LI4K2KEJ.js} +6 -4
- package/dist/chunk-LI4K2KEJ.js.map +1 -0
- package/dist/chunk-LKZDQ2B4.js +1581 -0
- package/dist/chunk-LKZDQ2B4.js.map +1 -0
- package/dist/{chunk-WODMN3Q2.cjs → chunk-LLFPQOBA.cjs} +27 -27
- package/dist/{chunk-WODMN3Q2.cjs.map → chunk-LLFPQOBA.cjs.map} +1 -1
- package/dist/{chunk-P6YLZTRE.js → chunk-LZMQ3SFK.js} +3 -3
- package/dist/{chunk-P6YLZTRE.js.map → chunk-LZMQ3SFK.js.map} +1 -1
- package/dist/{chunk-HEV35TGT.js → chunk-M3VTS3F6.js} +13 -4
- package/dist/chunk-M3VTS3F6.js.map +1 -0
- package/dist/{chunk-TQHGE7UC.cjs → chunk-M5MSP3BI.cjs} +18 -10
- package/dist/chunk-M5MSP3BI.cjs.map +1 -0
- package/dist/{chunk-D4QLTJSM.js → chunk-NBOS7BY3.js} +63 -23
- package/dist/chunk-NBOS7BY3.js.map +1 -0
- package/dist/chunk-NGQDGL5X.js +140 -0
- package/dist/chunk-NGQDGL5X.js.map +1 -0
- package/dist/{chunk-SIT26LAZ.cjs → chunk-NLX5OWK7.cjs} +33 -5
- package/dist/chunk-NLX5OWK7.cjs.map +1 -0
- package/dist/chunk-NUQ2YFFH.cjs +1637 -0
- package/dist/chunk-NUQ2YFFH.cjs.map +1 -0
- package/dist/{chunk-UMGZDVOA.cjs → chunk-OGL4X4PH.cjs} +206 -208
- package/dist/chunk-OGL4X4PH.cjs.map +1 -0
- package/dist/{chunk-LRQKXRXO.cjs → chunk-OTNTGEXR.cjs} +4 -4
- package/dist/{chunk-LRQKXRXO.cjs.map → chunk-OTNTGEXR.cjs.map} +1 -1
- package/dist/chunk-OTWE63BW.js +53 -0
- package/dist/chunk-OTWE63BW.js.map +1 -0
- package/dist/chunk-PC5NGH5A.js +549 -0
- package/dist/chunk-PC5NGH5A.js.map +1 -0
- package/dist/{chunk-26YKDNUD.cjs → chunk-PS3TUWJM.cjs} +12 -10
- package/dist/chunk-PS3TUWJM.cjs.map +1 -0
- package/dist/{chunk-OMZ37BM2.js → chunk-PVFFH7TL.js} +5 -5
- package/dist/{chunk-OMZ37BM2.js.map → chunk-PVFFH7TL.js.map} +1 -1
- package/dist/chunk-QCD5JKU4.cjs +15 -0
- package/dist/chunk-QCD5JKU4.cjs.map +1 -0
- package/dist/{chunk-UGHG7PGX.js → chunk-QG5VEOKX.js} +30 -4
- package/dist/chunk-QG5VEOKX.js.map +1 -0
- package/dist/{chunk-TUNPBZY3.cjs → chunk-QLLZM5I3.cjs} +4 -4
- package/dist/{chunk-TUNPBZY3.cjs.map → chunk-QLLZM5I3.cjs.map} +1 -1
- package/dist/{chunk-BRRP76WO.js → chunk-RCBG6YMT.js} +781 -375
- package/dist/chunk-RCBG6YMT.js.map +1 -0
- package/dist/{chunk-LTXQOEIC.js → chunk-RI7RJH4G.js} +281 -204
- package/dist/chunk-RI7RJH4G.js.map +1 -0
- package/dist/{chunk-GYEG3ZLZ.cjs → chunk-RJMHU2MG.cjs} +121 -18
- package/dist/chunk-RJMHU2MG.cjs.map +1 -0
- package/dist/{chunk-GLHXM7C4.js → chunk-RVUL2HXY.js} +61 -23
- package/dist/chunk-RVUL2HXY.js.map +1 -0
- package/dist/chunk-RWUWTJQY.cjs +30 -0
- package/dist/chunk-RWUWTJQY.cjs.map +1 -0
- package/dist/{chunk-2O4PCIZ6.cjs → chunk-S5GU4LUN.cjs} +13 -13
- package/dist/{chunk-2O4PCIZ6.cjs.map → chunk-S5GU4LUN.cjs.map} +1 -1
- package/dist/{chunk-JPD2CTC3.js → chunk-SDPWO2Z5.js} +7 -7
- package/dist/{chunk-JPD2CTC3.js.map → chunk-SDPWO2Z5.js.map} +1 -1
- package/dist/{chunk-OVI7IXYX.js → chunk-SLGGT2XD.js} +3 -3
- package/dist/{chunk-OVI7IXYX.js.map → chunk-SLGGT2XD.js.map} +1 -1
- package/dist/{chunk-ROR5ZR6A.cjs → chunk-TIJUA4I6.cjs} +45 -45
- package/dist/{chunk-ROR5ZR6A.cjs.map → chunk-TIJUA4I6.cjs.map} +1 -1
- package/dist/{chunk-AOSSQDVO.cjs → chunk-TM54OBHX.cjs} +13 -13
- package/dist/{chunk-AOSSQDVO.cjs.map → chunk-TM54OBHX.cjs.map} +1 -1
- package/dist/{chunk-KF6K7TGH.js → chunk-TYEYRCXL.js} +766 -433
- package/dist/chunk-TYEYRCXL.js.map +1 -0
- package/dist/{chunk-Z2JCLZFJ.js → chunk-UKOVGCRN.js} +2151 -570
- package/dist/chunk-UKOVGCRN.js.map +1 -0
- package/dist/chunk-UYKDYE5D.cjs +12 -0
- package/dist/{chunk-CICO5GXD.cjs.map → chunk-UYKDYE5D.cjs.map} +1 -1
- package/dist/{chunk-S5TERQVW.js → chunk-VAAC7L57.js} +284 -66
- package/dist/chunk-VAAC7L57.js.map +1 -0
- package/dist/{chunk-7UOLHNWC.cjs → chunk-VKHXYVN7.cjs} +22 -33
- package/dist/chunk-VKHXYVN7.cjs.map +1 -0
- 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-YIURNGXI.js → chunk-VUQZNUHU.js} +22 -6
- package/dist/chunk-VUQZNUHU.js.map +1 -0
- package/dist/{chunk-YYUHLYM2.cjs → chunk-WDM5WQK4.cjs} +183 -143
- package/dist/chunk-WDM5WQK4.cjs.map +1 -0
- package/dist/{chunk-ZFMCDJGB.js → chunk-WFSYYU4W.js} +70 -220
- package/dist/chunk-WFSYYU4W.js.map +1 -0
- package/dist/{chunk-SR725PWF.cjs → chunk-WRBV2FNH.cjs} +2065 -1659
- package/dist/chunk-WRBV2FNH.cjs.map +1 -0
- package/dist/{chunk-MRDBBHIZ.cjs → chunk-X4GDXBOP.cjs} +2 -2
- package/dist/chunk-X4GDXBOP.cjs.map +1 -0
- package/dist/chunk-XORONCV3.js +202 -0
- package/dist/chunk-XORONCV3.js.map +1 -0
- package/dist/{chunk-D5R42W5D.js → chunk-XZW2CTNO.js} +115 -12
- package/dist/chunk-XZW2CTNO.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-2TYSSBU5.js → chunk-YT2IVFAI.js} +30 -21
- package/dist/chunk-YT2IVFAI.js.map +1 -0
- package/dist/chunk-ZGVTNKTX.cjs +217 -0
- package/dist/chunk-ZGVTNKTX.cjs.map +1 -0
- 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-BvcbgzHo.d.ts} +3 -3
- package/dist/{ddl-BL1NZLMY.d.cts → ddl-Ufebz5q5.d.cts} +3 -3
- package/dist/graph-extension/index.cjs +21 -20
- package/dist/graph-extension/index.d.cts +2 -4
- package/dist/graph-extension/index.d.ts +2 -4
- package/dist/graph-extension/index.js +5 -4
- package/dist/graph-merge/index.cjs +324 -307
- package/dist/graph-merge/index.cjs.map +1 -1
- package/dist/graph-merge/index.d.cts +8 -9
- package/dist/graph-merge/index.d.ts +8 -9
- package/dist/graph-merge/index.js +51 -34
- package/dist/graph-merge/index.js.map +1 -1
- package/dist/index.cjs +224 -222
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -12
- package/dist/index.d.ts +11 -12
- package/dist/index.js +38 -36
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +15 -13
- package/dist/indexes/index.d.cts +4 -4
- package/dist/indexes/index.d.ts +4 -4
- package/dist/indexes/index.js +8 -6
- package/dist/{ingestion-import-target-dNeL7iAv.d.ts → ingestion-import-target-CAs1OX-l.d.cts} +1 -1
- package/dist/{ingestion-import-target-XPxZYw89.d.cts → ingestion-import-target-DCQSPfNx.d.ts} +1 -1
- package/dist/interchange/index.cjs +57 -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 +21 -18
- package/dist/interchange/index.js.map +1 -1
- package/dist/local-store-impl-6DDTFM32.cjs +77 -0
- package/dist/local-store-impl-6DDTFM32.cjs.map +1 -0
- package/dist/local-store-impl-OXTOVU2J.js +75 -0
- package/dist/local-store-impl-OXTOVU2J.js.map +1 -0
- package/dist/{manager-CYaff3n3.d.cts → manager-B68OrPR2.d.ts} +29 -2
- package/dist/{manager-D9eRT_ns.d.ts → manager-D_t7oK69.d.cts} +29 -2
- package/dist/pglite-store-impl-6EMZGL7K.js +73 -0
- package/dist/pglite-store-impl-6EMZGL7K.js.map +1 -0
- package/dist/pglite-store-impl-GJG3Y7RP.cjs +75 -0
- package/dist/pglite-store-impl-GJG3Y7RP.cjs.map +1 -0
- package/dist/{postgres-CcL4bAHS.d.ts → postgres-BPLSVyHM.d.ts} +279 -2
- package/dist/{postgres-DMj39MEu.d.cts → postgres-CqvtFC2y.d.cts} +279 -2
- package/dist/profiler/index.d.cts +9 -9
- package/dist/profiler/index.d.ts +9 -9
- package/dist/provenance/index.cjs +59 -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 +28 -13
- package/dist/provenance/index.js.map +1 -1
- package/dist/{repair-validity-windows-BFNZvd_H.d.cts → repair-validity-windows-DEzCKAdy.d.cts} +7 -3
- package/dist/{repair-validity-windows-DlUSqwCg.d.ts → repair-validity-windows-GMdaS2AH.d.ts} +7 -3
- package/dist/resolve-D_H8MHtq.d.ts +1805 -0
- package/dist/resolve-WEW8gWws.d.cts +1805 -0
- package/dist/schema/index.cjs +48 -46
- package/dist/schema/index.d.cts +4 -6
- package/dist/schema/index.d.ts +4 -6
- package/dist/schema/index.js +21 -19
- package/dist/{searchable-bpE1bBfc.d.ts → searchable-C_UREI9K.d.ts} +1 -1
- package/dist/{searchable-DHJMh_nj.d.cts → searchable-ClgET_i7.d.cts} +1 -1
- package/dist/{sqlite-YppHrNFb.d.cts → sqlite-D1mXO9Kp.d.cts} +310 -2
- package/dist/{sqlite-D7Oz0SQh.d.ts → sqlite-MZA3oZNB.d.ts} +310 -2
- package/dist/{store-bphCSo7z.d.cts → store-CuFX7fCx.d.cts} +117 -31
- package/dist/{store-DRrFCx5x.d.ts → store-D-ZjXQpW.d.ts} +117 -31
- package/dist/{temporal-CbnLzTmM.d.ts → temporal-CpyEiRY8.d.cts} +1 -1
- package/dist/{temporal-5GqpYCk2.d.cts → temporal-y0Aep9Su.d.ts} +1 -1
- package/dist/{types-BqFZTQmV.d.cts → types-6yf0Vv-_.d.cts} +2016 -94
- package/dist/{types-BqFZTQmV.d.ts → types-6yf0Vv-_.d.ts} +2016 -94
- package/dist/{types-Bx74kaTt.d.ts → types-DzJ4dlzk.d.cts} +1 -1
- package/dist/{types-CXAhpW-c.d.cts → types-_vVSB9k-.d.ts} +1 -1
- package/dist/{where-O-k2wgYm.d.ts → where-DuG2LCLe.d.ts} +1 -1
- package/dist/{where-DI_Fqz-X.d.cts → where-Mhf_yyKX.d.cts} +1 -1
- package/package.json +7 -2
- package/dist/chunk-26YKDNUD.cjs.map +0 -1
- package/dist/chunk-2TYSSBU5.js.map +0 -1
- package/dist/chunk-3DMMGT6S.js.map +0 -1
- package/dist/chunk-3FPR224C.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 +0 -3502
- package/dist/chunk-3QNZ5SAJ.cjs.map +0 -1
- package/dist/chunk-3U5ABFDW.cjs +0 -259
- package/dist/chunk-3U5ABFDW.cjs.map +0 -1
- package/dist/chunk-5K2BKEBD.js.map +0 -1
- package/dist/chunk-5PRKMB24.cjs +0 -124
- package/dist/chunk-5PRKMB24.cjs.map +0 -1
- package/dist/chunk-6LN7FIVU.js +0 -107
- package/dist/chunk-6LN7FIVU.js.map +0 -1
- package/dist/chunk-6SWPJEYN.js +0 -1126
- package/dist/chunk-6SWPJEYN.js.map +0 -1
- package/dist/chunk-7LZJNLA5.js.map +0 -1
- package/dist/chunk-7UOLHNWC.cjs.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-EDN4Y4ZG.cjs.map +0 -1
- package/dist/chunk-EZEEWCFJ.cjs.map +0 -1
- 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 +0 -1156
- 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-L3LQNR34.cjs +0 -1254
- package/dist/chunk-L3LQNR34.cjs.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-NACVVDWB.js.map +0 -1
- package/dist/chunk-NVY5CJFP.js +0 -244
- 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-UMGZDVOA.cjs.map +0 -1
- package/dist/chunk-WIC7DRXW.js.map +0 -1
- 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-ZDKTPBGV.js.map +0 -1
- package/dist/chunk-ZFMCDJGB.js.map +0 -1
- package/dist/chunk-ZLONH2UD.js.map +0 -1
- package/dist/index-COs_z6nV.d.cts +0 -1132
- package/dist/index-D7d1u2gr.d.ts +0 -1132
- package/dist/materialize-indexes-DJ3ykH59.d.ts +0 -266
- package/dist/materialize-indexes-DTtAnvfY.d.cts +0 -266
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
3
|
+
var chunkNLX5OWK7_cjs = require('./chunk-NLX5OWK7.cjs');
|
|
4
|
+
var chunkZGVTNKTX_cjs = require('./chunk-ZGVTNKTX.cjs');
|
|
5
|
+
var chunkNUQ2YFFH_cjs = require('./chunk-NUQ2YFFH.cjs');
|
|
6
|
+
var chunkDWUDZ66O_cjs = require('./chunk-DWUDZ66O.cjs');
|
|
7
|
+
var chunkM5MSP3BI_cjs = require('./chunk-M5MSP3BI.cjs');
|
|
8
|
+
var chunkA4C4NJ5U_cjs = require('./chunk-A4C4NJ5U.cjs');
|
|
9
|
+
var chunkH5IJSROF_cjs = require('./chunk-H5IJSROF.cjs');
|
|
9
10
|
var chunkRT5ZY4XA_cjs = require('./chunk-RT5ZY4XA.cjs');
|
|
10
|
-
var
|
|
11
|
+
var chunkX4GDXBOP_cjs = require('./chunk-X4GDXBOP.cjs');
|
|
11
12
|
var chunkA7J2YDDI_cjs = require('./chunk-A7J2YDDI.cjs');
|
|
12
13
|
var chunkN66HCGCY_cjs = require('./chunk-N66HCGCY.cjs');
|
|
13
14
|
var nanoid = require('nanoid');
|
|
@@ -16,7 +17,7 @@ var nanoid = require('nanoid');
|
|
|
16
17
|
var pinnedReadInstant;
|
|
17
18
|
function withPinnedReadInstant(emit) {
|
|
18
19
|
if (pinnedReadInstant !== void 0) return emit();
|
|
19
|
-
pinnedReadInstant =
|
|
20
|
+
pinnedReadInstant = chunkM5MSP3BI_cjs.nowIso();
|
|
20
21
|
try {
|
|
21
22
|
return emit();
|
|
22
23
|
} finally {
|
|
@@ -24,27 +25,27 @@ function withPinnedReadInstant(emit) {
|
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
function currentReadInstant() {
|
|
27
|
-
return
|
|
28
|
+
return chunkH5IJSROF_cjs.sql`${pinnedReadInstant ?? chunkM5MSP3BI_cjs.nowIso()}`;
|
|
28
29
|
}
|
|
29
30
|
var CURRENT_READ_INSTANT_PLACEHOLDER = "__typegraph_current_read_instant__";
|
|
30
31
|
function currentReadInstantPlaceholder() {
|
|
31
|
-
return
|
|
32
|
+
return chunkH5IJSROF_cjs.sql`${chunkH5IJSROF_cjs.sql.placeholder(CURRENT_READ_INSTANT_PLACEHOLDER)}`;
|
|
32
33
|
}
|
|
33
34
|
function currentReadInstantFor(mode) {
|
|
34
35
|
return mode === "placeholder" ? currentReadInstantPlaceholder() : currentReadInstant();
|
|
35
36
|
}
|
|
36
37
|
function compileTemporalFilter(options) {
|
|
37
38
|
const { mode, asOf, tableAlias, currentTimestamp, recordedAsOf } = options;
|
|
38
|
-
const recorded =
|
|
39
|
-
const prefix = tableAlias ?
|
|
40
|
-
const deletedAt =
|
|
41
|
-
const validFrom =
|
|
42
|
-
const validTo =
|
|
39
|
+
const recorded = chunkDWUDZ66O_cjs.optionalRecordedInstantParts(recordedAsOf, "recordedAsOf");
|
|
40
|
+
const prefix = tableAlias ? chunkH5IJSROF_cjs.sql.raw(`${tableAlias}.`) : chunkH5IJSROF_cjs.sql.raw("");
|
|
41
|
+
const deletedAt = chunkH5IJSROF_cjs.sql`${prefix}deleted_at`;
|
|
42
|
+
const validFrom = chunkH5IJSROF_cjs.sql`${prefix}valid_from`;
|
|
43
|
+
const validTo = chunkH5IJSROF_cjs.sql`${prefix}valid_to`;
|
|
43
44
|
const validFilter = (() => {
|
|
44
45
|
switch (mode) {
|
|
45
46
|
case "current": {
|
|
46
|
-
const now = recorded === void 0 ? currentTimestamp ?? currentReadInstant() :
|
|
47
|
-
return
|
|
47
|
+
const now = recorded === void 0 ? currentTimestamp ?? currentReadInstant() : chunkH5IJSROF_cjs.sql`${recorded.recordedAt}`;
|
|
48
|
+
return chunkH5IJSROF_cjs.sql`${deletedAt} IS NULL AND (${validFrom} IS NULL OR ${validFrom} <= ${now}) AND (${validTo} IS NULL OR ${validTo} > ${now})`;
|
|
48
49
|
}
|
|
49
50
|
case "asOf": {
|
|
50
51
|
if (asOf === void 0) {
|
|
@@ -53,21 +54,21 @@ function compileTemporalFilter(options) {
|
|
|
53
54
|
);
|
|
54
55
|
}
|
|
55
56
|
const timestamp = asOf;
|
|
56
|
-
return
|
|
57
|
+
return chunkH5IJSROF_cjs.sql`${deletedAt} IS NULL AND (${validFrom} IS NULL OR ${validFrom} <= ${timestamp}) AND (${validTo} IS NULL OR ${validTo} > ${timestamp})`;
|
|
57
58
|
}
|
|
58
59
|
case "includeEnded": {
|
|
59
|
-
return
|
|
60
|
+
return chunkH5IJSROF_cjs.sql`${deletedAt} IS NULL`;
|
|
60
61
|
}
|
|
61
62
|
case "includeTombstones": {
|
|
62
|
-
return
|
|
63
|
+
return chunkH5IJSROF_cjs.sql.raw("1=1");
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
})();
|
|
66
67
|
if (recorded === void 0) return validFilter;
|
|
67
|
-
const recordedFrom =
|
|
68
|
-
const recordedTo =
|
|
68
|
+
const recordedFrom = chunkH5IJSROF_cjs.sql`${prefix}recorded_from`;
|
|
69
|
+
const recordedTo = chunkH5IJSROF_cjs.sql`${prefix}recorded_to`;
|
|
69
70
|
const { revision } = recorded;
|
|
70
|
-
return
|
|
71
|
+
return chunkH5IJSROF_cjs.sql`(${validFilter}) AND ${recordedFrom} <= ${revision} AND ${revision} < ${recordedTo}`;
|
|
71
72
|
}
|
|
72
73
|
function extractTemporalOptions(ast, tableAlias) {
|
|
73
74
|
return {
|
|
@@ -155,7 +156,7 @@ function predicate(expr) {
|
|
|
155
156
|
}
|
|
156
157
|
function param(name) {
|
|
157
158
|
if (name === CURRENT_READ_INSTANT_PLACEHOLDER) {
|
|
158
|
-
throw new
|
|
159
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
159
160
|
`Parameter name "${name}" is reserved for internal use`,
|
|
160
161
|
{ parameterName: name }
|
|
161
162
|
);
|
|
@@ -239,7 +240,7 @@ function inComparison(op, field, values) {
|
|
|
239
240
|
}
|
|
240
241
|
const literals = values.map((value) => {
|
|
241
242
|
if (isParameterRef(value)) {
|
|
242
|
-
throw new
|
|
243
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
243
244
|
`param("${value.name}") is not supported as an element of the ${op}() list`,
|
|
244
245
|
{ parameterName: value.name },
|
|
245
246
|
{
|
|
@@ -321,7 +322,7 @@ function createFulltextAccessor(alias, hasSearchableField) {
|
|
|
321
322
|
return {
|
|
322
323
|
matches: (query, k, options) => {
|
|
323
324
|
if (!hasSearchableField()) {
|
|
324
|
-
throw new
|
|
325
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
325
326
|
`Cannot call .$fulltext.matches() on alias "${alias}" \u2014 its node kind has no fields declared with searchable(). Add at least one: \`title: searchable({ language: "english" })\`.`
|
|
326
327
|
);
|
|
327
328
|
}
|
|
@@ -336,7 +337,7 @@ function createFulltextAccessor(alias, hasSearchableField) {
|
|
|
336
337
|
}
|
|
337
338
|
function fulltextMatch(field, query, limit, options) {
|
|
338
339
|
if (!Number.isFinite(limit) || limit <= 0) {
|
|
339
|
-
throw new
|
|
340
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
340
341
|
`matches() limit must be a positive finite number, got ${String(limit)}`
|
|
341
342
|
);
|
|
342
343
|
}
|
|
@@ -609,7 +610,7 @@ function notInSubquery(field, subquery) {
|
|
|
609
610
|
function assertSingleColumnSubquery(subquery) {
|
|
610
611
|
const columnCount = getSubqueryColumnCount(subquery);
|
|
611
612
|
if (columnCount === 1) return;
|
|
612
|
-
throw new
|
|
613
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
613
614
|
`IN/NOT IN subquery must project exactly 1 column, but got ${columnCount}`,
|
|
614
615
|
{ subqueryColumnCount: columnCount },
|
|
615
616
|
{
|
|
@@ -622,7 +623,7 @@ function assertCompatibleSubqueryValueTypes(field, subquery) {
|
|
|
622
623
|
const subqueryValueType = getSingleSubqueryColumnValueType(subquery);
|
|
623
624
|
const resolvedValueType = fieldValueType ?? subqueryValueType;
|
|
624
625
|
if (isUnsupportedInSubqueryValueType(resolvedValueType)) {
|
|
625
|
-
throw new
|
|
626
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
626
627
|
`IN/NOT IN subquery does not support ${String(resolvedValueType)} values`,
|
|
627
628
|
{ valueType: resolvedValueType },
|
|
628
629
|
{
|
|
@@ -633,7 +634,7 @@ function assertCompatibleSubqueryValueTypes(field, subquery) {
|
|
|
633
634
|
if (isInSubqueryTypeCompatible(fieldValueType, subqueryValueType)) {
|
|
634
635
|
return;
|
|
635
636
|
}
|
|
636
|
-
throw new
|
|
637
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
637
638
|
`IN/NOT IN type mismatch: field type "${String(fieldValueType)}" does not match subquery column type "${String(subqueryValueType)}"`,
|
|
638
639
|
{
|
|
639
640
|
fieldValueType,
|
|
@@ -652,7 +653,7 @@ var RECORDED_ISOLATION_REQUIRES_POSTGRES_CHECK = {
|
|
|
652
653
|
};
|
|
653
654
|
function requireRecordedSchema(target) {
|
|
654
655
|
if (target.tableNames === void 0) {
|
|
655
|
-
throw new
|
|
656
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
656
657
|
"Recorded-time capture requires the backend to expose tableNames.",
|
|
657
658
|
{ dialect: target.dialect },
|
|
658
659
|
{
|
|
@@ -660,11 +661,11 @@ function requireRecordedSchema(target) {
|
|
|
660
661
|
}
|
|
661
662
|
);
|
|
662
663
|
}
|
|
663
|
-
return
|
|
664
|
+
return chunkNUQ2YFFH_cjs.createSqlSchema(target.tableNames);
|
|
664
665
|
}
|
|
665
666
|
function requireCaptureStatements(target) {
|
|
666
667
|
if (target.executeStatement === void 0) {
|
|
667
|
-
throw new
|
|
668
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
668
669
|
"Recorded-time capture requires backend.executeStatement support on the transaction backend.",
|
|
669
670
|
{ dialect: target.dialect },
|
|
670
671
|
{
|
|
@@ -675,10 +676,10 @@ function requireCaptureStatements(target) {
|
|
|
675
676
|
}
|
|
676
677
|
async function executeStatement(target, query) {
|
|
677
678
|
requireCaptureStatements(target);
|
|
678
|
-
await target.executeStatement(
|
|
679
|
+
await target.executeStatement(chunkH5IJSROF_cjs.asCompiledStatementSql(query));
|
|
679
680
|
}
|
|
680
681
|
function unsupportedPostgresIsolationError(isolationLevel) {
|
|
681
|
-
return new
|
|
682
|
+
return new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
682
683
|
"Recorded-time capture on PostgreSQL requires read_committed isolation.",
|
|
683
684
|
{ isolationLevel: isolationLevel ?? "unknown" },
|
|
684
685
|
{
|
|
@@ -704,7 +705,7 @@ async function assertRecordedCaptureTransactionIsolation(target, options) {
|
|
|
704
705
|
if (!RECORDED_ISOLATION_REQUIRES_POSTGRES_CHECK[target.dialect]) return;
|
|
705
706
|
if (options?.accessMode === "read_only") return;
|
|
706
707
|
const rows = await target.execute(
|
|
707
|
-
|
|
708
|
+
chunkH5IJSROF_cjs.asCompiledRowsSql(chunkH5IJSROF_cjs.sql`
|
|
708
709
|
SELECT current_setting('transaction_isolation') AS transaction_isolation
|
|
709
710
|
`)
|
|
710
711
|
);
|
|
@@ -715,7 +716,7 @@ async function assertRecordedCaptureTransactionIsolation(target, options) {
|
|
|
715
716
|
throw unsupportedPostgresIsolationError(isolationLevel);
|
|
716
717
|
}
|
|
717
718
|
function recordedCaptureRequiresCallbackTransactionError(details = {}) {
|
|
718
|
-
return new
|
|
719
|
+
return new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
719
720
|
"withTransaction() has no recorded-time capture flush point when history is enabled.",
|
|
720
721
|
{
|
|
721
722
|
...details,
|
|
@@ -727,7 +728,7 @@ function recordedCaptureRequiresCallbackTransactionError(details = {}) {
|
|
|
727
728
|
);
|
|
728
729
|
}
|
|
729
730
|
function historyUnsafeRawWriteError(surface) {
|
|
730
|
-
return new
|
|
731
|
+
return new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
731
732
|
`${surface} is not available when history capture is enabled because raw SQL writes bypass recorded-time capture.`,
|
|
732
733
|
{
|
|
733
734
|
code: "RECORDED_CAPTURE_RAW_SQL_DISABLED"
|
|
@@ -738,7 +739,7 @@ function historyUnsafeRawWriteError(surface) {
|
|
|
738
739
|
);
|
|
739
740
|
}
|
|
740
741
|
function revisionTrackingUnsafeRawWriteError(surface) {
|
|
741
|
-
return new
|
|
742
|
+
return new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
742
743
|
`${surface} is not available when revision tracking is enabled because raw SQL writes bypass the revision anchor.`,
|
|
743
744
|
{
|
|
744
745
|
code: "REVISION_TRACKING_RAW_SQL_DISABLED"
|
|
@@ -774,7 +775,7 @@ function rawWriteGuards(target, prefix) {
|
|
|
774
775
|
}
|
|
775
776
|
function assertCapturableBackend(backend) {
|
|
776
777
|
if (!backend.capabilities.transactions) {
|
|
777
|
-
throw new
|
|
778
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
778
779
|
"history: true requires a backend with transaction support.",
|
|
779
780
|
{ dialect: backend.dialect },
|
|
780
781
|
{
|
|
@@ -782,8 +783,8 @@ function assertCapturableBackend(backend) {
|
|
|
782
783
|
}
|
|
783
784
|
);
|
|
784
785
|
}
|
|
785
|
-
if (backend.
|
|
786
|
-
throw new
|
|
786
|
+
if (!chunkZGVTNKTX_cjs.statementExecutionVerdict(backend).supported) {
|
|
787
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
787
788
|
"history: true requires a backend that supports executeStatement.",
|
|
788
789
|
{ dialect: backend.dialect },
|
|
789
790
|
{
|
|
@@ -792,7 +793,7 @@ function assertCapturableBackend(backend) {
|
|
|
792
793
|
);
|
|
793
794
|
}
|
|
794
795
|
if (backend.capabilities.returning === false) {
|
|
795
|
-
throw new
|
|
796
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
796
797
|
"history: true requires a backend that supports UPDATE \u2026 RETURNING.",
|
|
797
798
|
{ dialect: backend.dialect },
|
|
798
799
|
{
|
|
@@ -801,7 +802,7 @@ function assertCapturableBackend(backend) {
|
|
|
801
802
|
);
|
|
802
803
|
}
|
|
803
804
|
if (backend.tableNames === void 0) {
|
|
804
|
-
throw new
|
|
805
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
805
806
|
"history: true requires a backend that exposes tableNames.",
|
|
806
807
|
{ dialect: backend.dialect },
|
|
807
808
|
{
|
|
@@ -812,7 +813,7 @@ function assertCapturableBackend(backend) {
|
|
|
812
813
|
}
|
|
813
814
|
function assertRevisionTrackableBackend(backend) {
|
|
814
815
|
if (!backend.capabilities.transactions) {
|
|
815
|
-
throw new
|
|
816
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
816
817
|
"revisionTracking: true requires a backend with transaction support.",
|
|
817
818
|
{ dialect: backend.dialect },
|
|
818
819
|
{
|
|
@@ -820,8 +821,8 @@ function assertRevisionTrackableBackend(backend) {
|
|
|
820
821
|
}
|
|
821
822
|
);
|
|
822
823
|
}
|
|
823
|
-
if (backend.
|
|
824
|
-
throw new
|
|
824
|
+
if (!chunkZGVTNKTX_cjs.statementExecutionVerdict(backend).supported) {
|
|
825
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
825
826
|
"revisionTracking: true requires a backend that supports executeStatement.",
|
|
826
827
|
{ dialect: backend.dialect },
|
|
827
828
|
{
|
|
@@ -830,7 +831,7 @@ function assertRevisionTrackableBackend(backend) {
|
|
|
830
831
|
);
|
|
831
832
|
}
|
|
832
833
|
if (backend.tableNames === void 0) {
|
|
833
|
-
throw new
|
|
834
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
834
835
|
"revisionTracking: true requires a backend that exposes tableNames.",
|
|
835
836
|
{ dialect: backend.dialect },
|
|
836
837
|
{
|
|
@@ -838,8 +839,8 @@ function assertRevisionTrackableBackend(backend) {
|
|
|
838
839
|
}
|
|
839
840
|
);
|
|
840
841
|
}
|
|
841
|
-
if (backend.
|
|
842
|
-
throw new
|
|
842
|
+
if (!chunkZGVTNKTX_cjs.recordedRevisionOriginsVerdict(backend).supported) {
|
|
843
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
843
844
|
"revisionTracking: true requires a backend that can bootstrap revision origins.",
|
|
844
845
|
{ dialect: backend.dialect },
|
|
845
846
|
{
|
|
@@ -854,12 +855,8 @@ var RECORDED_MIN_REVISION = 0;
|
|
|
854
855
|
var RECORDED_MIN_TIME = "1970-01-01T00:00:00.000Z";
|
|
855
856
|
var RECORDED_CLOCK_ADVISORY_LOCK_NAMESPACE = "typegraph:recorded-clock";
|
|
856
857
|
var RECORDED_GRAPH_WRITE_ADVISORY_LOCK_NAMESPACE = "typegraph:recorded-graph-write";
|
|
857
|
-
var USES_RECORDED_GRAPH_ADVISORY_LOCK = {
|
|
858
|
-
postgres: true,
|
|
859
|
-
sqlite: false
|
|
860
|
-
};
|
|
861
858
|
function graphAdvisoryLockSql(namespace, graphId) {
|
|
862
|
-
return
|
|
859
|
+
return chunkH5IJSROF_cjs.sql`
|
|
863
860
|
SELECT pg_advisory_xact_lock(
|
|
864
861
|
hashtext(${namespace}),
|
|
865
862
|
hashtext(${graphId})
|
|
@@ -891,12 +888,20 @@ function registerRecordedGraphLockMemo(backend, memo) {
|
|
|
891
888
|
}
|
|
892
889
|
async function acquireRecordedGraphWriteLock(target, graphId) {
|
|
893
890
|
await target.execute(
|
|
894
|
-
|
|
891
|
+
chunkH5IJSROF_cjs.asCompiledRowsSql(recordedGraphWriteAdvisoryLockSql(graphId))
|
|
895
892
|
);
|
|
896
893
|
}
|
|
897
894
|
async function lockRecordedGraphWrite(target, graphId, memo) {
|
|
898
|
-
|
|
899
|
-
|
|
895
|
+
const plan = chunkNUQ2YFFH_cjs.resolveWriteFencePlan(target);
|
|
896
|
+
const fence = chunkNUQ2YFFH_cjs.requireWriteFence(
|
|
897
|
+
plan,
|
|
898
|
+
"recorded graph write",
|
|
899
|
+
"advisory-lock"
|
|
900
|
+
);
|
|
901
|
+
switch (fence.kind) {
|
|
902
|
+
case "engine-serialized": {
|
|
903
|
+
return graphWriteLockEvidence();
|
|
904
|
+
}
|
|
900
905
|
}
|
|
901
906
|
const effectiveMemo = memo ?? recordedGraphLockMemos.get(target);
|
|
902
907
|
if (effectiveMemo === void 0) {
|
|
@@ -917,7 +922,7 @@ async function lockRecordedGraphWrite(target, graphId, memo) {
|
|
|
917
922
|
return graphWriteLockEvidence();
|
|
918
923
|
}
|
|
919
924
|
function failInvalidClock(value, cause) {
|
|
920
|
-
throw new
|
|
925
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
921
926
|
"Recorded clock row contained an invalid revision or wall time",
|
|
922
927
|
{ value },
|
|
923
928
|
{
|
|
@@ -928,13 +933,13 @@ function failInvalidClock(value, cause) {
|
|
|
928
933
|
}
|
|
929
934
|
function recordedClockRevision(value) {
|
|
930
935
|
const revision = typeof value === "bigint" ? Number(value) : typeof value === "string" && /^\d+$/.test(value) ? Number(value) : value;
|
|
931
|
-
if (typeof revision !== "number" || !Number.isSafeInteger(revision) || revision < RECORDED_MIN_REVISION || revision >=
|
|
936
|
+
if (typeof revision !== "number" || !Number.isSafeInteger(revision) || revision < RECORDED_MIN_REVISION || revision >= chunkDWUDZ66O_cjs.RECORDED_MAX_REVISION) {
|
|
932
937
|
return failInvalidClock(value);
|
|
933
938
|
}
|
|
934
939
|
return revision;
|
|
935
940
|
}
|
|
936
941
|
function recordedClockWallTime(value) {
|
|
937
|
-
return
|
|
942
|
+
return chunkM5MSP3BI_cjs.canonicalizeDatabaseTimestamp(value) ?? failInvalidClock(value);
|
|
938
943
|
}
|
|
939
944
|
function recordedClockParts(row) {
|
|
940
945
|
const revision = recordedClockRevision(row.revision);
|
|
@@ -942,7 +947,7 @@ function recordedClockParts(row) {
|
|
|
942
947
|
return { revision, recordedAt: recordedClockWallTime(row.recorded_at) };
|
|
943
948
|
}
|
|
944
949
|
function nextRecordedCommitParts(previous) {
|
|
945
|
-
const wallTime =
|
|
950
|
+
const wallTime = chunkM5MSP3BI_cjs.nowIso();
|
|
946
951
|
if (previous === void 0) {
|
|
947
952
|
return { revision: 1, recordedAt: wallTime };
|
|
948
953
|
}
|
|
@@ -960,11 +965,11 @@ function nonDecreasingWallTime(current, previous) {
|
|
|
960
965
|
}
|
|
961
966
|
async function readRecordedClock(target, schema, graphId) {
|
|
962
967
|
const parts = await readRecordedClockParts(target, schema, graphId);
|
|
963
|
-
return parts === void 0 ? void 0 :
|
|
968
|
+
return parts === void 0 ? void 0 : chunkDWUDZ66O_cjs.createRecordedInstant(parts.revision, parts.recordedAt);
|
|
964
969
|
}
|
|
965
970
|
async function readRecordedClockParts(target, schema, graphId) {
|
|
966
971
|
const rows = await target.execute(
|
|
967
|
-
|
|
972
|
+
chunkH5IJSROF_cjs.asCompiledRowsSql(chunkH5IJSROF_cjs.sql`
|
|
968
973
|
SELECT revision, recorded_at
|
|
969
974
|
FROM ${schema.recordedClockTable}
|
|
970
975
|
WHERE graph_id = ${graphId}
|
|
@@ -975,7 +980,7 @@ async function readRecordedClockParts(target, schema, graphId) {
|
|
|
975
980
|
}
|
|
976
981
|
async function readRevisionOrigin(target, schema, graphId) {
|
|
977
982
|
const rows = await target.execute(
|
|
978
|
-
|
|
983
|
+
chunkH5IJSROF_cjs.asCompiledRowsSql(chunkH5IJSROF_cjs.sql`
|
|
979
984
|
SELECT origin
|
|
980
985
|
FROM ${schema.revisionOriginsTable}
|
|
981
986
|
WHERE graph_id = ${graphId}
|
|
@@ -984,17 +989,16 @@ async function readRevisionOrigin(target, schema, graphId) {
|
|
|
984
989
|
const first = rows[0];
|
|
985
990
|
if (first === void 0) return void 0;
|
|
986
991
|
if (typeof first.origin !== "string" || first.origin.length === 0) {
|
|
987
|
-
throw new
|
|
992
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
988
993
|
"Revision origin row contained an invalid origin",
|
|
989
994
|
{ graphId, origin: first.origin }
|
|
990
995
|
);
|
|
991
996
|
}
|
|
992
997
|
return first.origin;
|
|
993
998
|
}
|
|
994
|
-
async function ensureRevisionOrigin(target, schema, graphId) {
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
throw new chunkMRDBBHIZ_cjs.ConfigurationError(
|
|
999
|
+
async function ensureRevisionOrigin(target, verdict, schema, graphId) {
|
|
1000
|
+
if (!verdict.supported) {
|
|
1001
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
998
1002
|
"Revision tracking requires a backend that can bootstrap revision origins.",
|
|
999
1003
|
{ dialect: target.dialect },
|
|
1000
1004
|
{
|
|
@@ -1002,12 +1006,13 @@ async function ensureRevisionOrigin(target, schema, graphId) {
|
|
|
1002
1006
|
}
|
|
1003
1007
|
);
|
|
1004
1008
|
}
|
|
1009
|
+
const { ensureRevisionOriginsTable: ensureTable } = chunkNUQ2YFFH_cjs.recordedRevisionOriginsMembers(target, verdict);
|
|
1005
1010
|
await ensureTable();
|
|
1006
1011
|
const existing = await readRevisionOrigin(target, schema, graphId);
|
|
1007
1012
|
if (existing !== void 0) return existing;
|
|
1008
1013
|
await executeStatement(
|
|
1009
1014
|
target,
|
|
1010
|
-
|
|
1015
|
+
chunkH5IJSROF_cjs.sql`
|
|
1011
1016
|
INSERT INTO ${schema.revisionOriginsTable} (graph_id, origin)
|
|
1012
1017
|
VALUES (${graphId}, ${generateId()})
|
|
1013
1018
|
ON CONFLICT (graph_id) DO NOTHING
|
|
@@ -1015,7 +1020,7 @@ async function ensureRevisionOrigin(target, schema, graphId) {
|
|
|
1015
1020
|
);
|
|
1016
1021
|
const origin = await readRevisionOrigin(target, schema, graphId);
|
|
1017
1022
|
if (origin !== void 0) return origin;
|
|
1018
|
-
throw new
|
|
1023
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
1019
1024
|
"Revision origin was not persisted after initialization.",
|
|
1020
1025
|
{ graphId, dialect: target.dialect }
|
|
1021
1026
|
);
|
|
@@ -1023,7 +1028,7 @@ async function ensureRevisionOrigin(target, schema, graphId) {
|
|
|
1023
1028
|
async function writeRecordedClock(target, schema, graphId, parts) {
|
|
1024
1029
|
await executeStatement(
|
|
1025
1030
|
target,
|
|
1026
|
-
|
|
1031
|
+
chunkH5IJSROF_cjs.sql`
|
|
1027
1032
|
INSERT INTO ${schema.recordedClockTable} (graph_id, revision, recorded_at)
|
|
1028
1033
|
VALUES (${graphId}, ${parts.revision}, ${parts.recordedAt})
|
|
1029
1034
|
ON CONFLICT (graph_id) DO UPDATE
|
|
@@ -1035,7 +1040,7 @@ async function writeRecordedClock(target, schema, graphId, parts) {
|
|
|
1035
1040
|
async function assertRecordedClockAdvanced(target, schema, graphId, revision) {
|
|
1036
1041
|
const stored = await readRecordedClockParts(target, schema, graphId);
|
|
1037
1042
|
if (stored?.revision === revision) return;
|
|
1038
|
-
throw new
|
|
1043
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
1039
1044
|
"Recorded commit allocation was refused: the supplied previous revision was stale, so the write would have moved the graph's revision clock backward.",
|
|
1040
1045
|
{ graphId, allocatedRevision: revision, storedRevision: stored?.revision },
|
|
1041
1046
|
{
|
|
@@ -1044,18 +1049,24 @@ async function assertRecordedClockAdvanced(target, schema, graphId, revision) {
|
|
|
1044
1049
|
);
|
|
1045
1050
|
}
|
|
1046
1051
|
async function lockRecordedClock(target, schema, graphId, ownsWriteLock) {
|
|
1047
|
-
|
|
1048
|
-
|
|
1052
|
+
const plan = chunkNUQ2YFFH_cjs.resolveWriteFencePlan(target);
|
|
1053
|
+
const fence = chunkNUQ2YFFH_cjs.requireWriteFence(
|
|
1054
|
+
plan,
|
|
1055
|
+
"recorded clock allocation",
|
|
1056
|
+
"advisory-lock"
|
|
1057
|
+
);
|
|
1058
|
+
switch (fence.kind) {
|
|
1059
|
+
case "lock": {
|
|
1049
1060
|
await target.execute(
|
|
1050
|
-
|
|
1061
|
+
chunkH5IJSROF_cjs.asCompiledRowsSql(recordedClockAdvisoryLockSql(graphId))
|
|
1051
1062
|
);
|
|
1052
1063
|
return;
|
|
1053
1064
|
}
|
|
1054
|
-
case "
|
|
1065
|
+
case "engine-serialized": {
|
|
1055
1066
|
if (ownsWriteLock) return;
|
|
1056
1067
|
await executeStatement(
|
|
1057
1068
|
target,
|
|
1058
|
-
|
|
1069
|
+
chunkH5IJSROF_cjs.sql`
|
|
1059
1070
|
INSERT INTO ${schema.recordedClockTable} (graph_id, revision, recorded_at)
|
|
1060
1071
|
VALUES (${graphId}, ${RECORDED_MIN_REVISION}, ${RECORDED_MIN_TIME})
|
|
1061
1072
|
ON CONFLICT (graph_id) DO UPDATE SET revision = revision
|
|
@@ -1063,25 +1074,22 @@ async function lockRecordedClock(target, schema, graphId, ownsWriteLock) {
|
|
|
1063
1074
|
);
|
|
1064
1075
|
return;
|
|
1065
1076
|
}
|
|
1066
|
-
default: {
|
|
1067
|
-
target.dialect;
|
|
1068
|
-
}
|
|
1069
1077
|
}
|
|
1070
1078
|
}
|
|
1071
1079
|
async function allocateRecordedCommit(target, schema, graphId, ownsWriteLock, previousRevision) {
|
|
1072
1080
|
await lockRecordedClock(target, schema, graphId, ownsWriteLock);
|
|
1073
|
-
const previous = previousRevision === void 0 ? await readRecordedClockParts(target, schema, graphId) :
|
|
1081
|
+
const previous = previousRevision === void 0 ? await readRecordedClockParts(target, schema, graphId) : chunkDWUDZ66O_cjs.parseRecordedInstant(previousRevision, "previous recorded revision");
|
|
1074
1082
|
const { revision, recordedAt } = nextRecordedCommitParts(previous);
|
|
1075
|
-
if (revision >=
|
|
1076
|
-
throw new
|
|
1077
|
-
`Recorded commit clock reached the open revision sentinel ${
|
|
1083
|
+
if (revision >= chunkDWUDZ66O_cjs.RECORDED_MAX_REVISION) {
|
|
1084
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
1085
|
+
`Recorded commit clock reached the open revision sentinel ${chunkDWUDZ66O_cjs.RECORDED_MAX_REVISION}`,
|
|
1078
1086
|
{ graphId, revision },
|
|
1079
1087
|
{
|
|
1080
1088
|
suggestion: "Start a new graph before exhausting the per-graph recorded revision space."
|
|
1081
1089
|
}
|
|
1082
1090
|
);
|
|
1083
1091
|
}
|
|
1084
|
-
const instant =
|
|
1092
|
+
const instant = chunkDWUDZ66O_cjs.createRecordedInstant(revision, recordedAt);
|
|
1085
1093
|
await writeRecordedClock(target, schema, graphId, { revision, recordedAt });
|
|
1086
1094
|
if (previousRevision !== void 0) {
|
|
1087
1095
|
await assertRecordedClockAdvanced(target, schema, graphId, revision);
|
|
@@ -1146,7 +1154,7 @@ async function runInsertBatchReturning(dispatch, params) {
|
|
|
1146
1154
|
}
|
|
1147
1155
|
|
|
1148
1156
|
// src/identity/historical-sql.ts
|
|
1149
|
-
var IDENTITY_ASSERTION_COLUMNS =
|
|
1157
|
+
var IDENTITY_ASSERTION_COLUMNS = chunkH5IJSROF_cjs.sql.raw(
|
|
1150
1158
|
[
|
|
1151
1159
|
"graph_id",
|
|
1152
1160
|
"id",
|
|
@@ -1168,35 +1176,35 @@ function identitySqlCoordinate(coordinate, currentInstant) {
|
|
|
1168
1176
|
return {
|
|
1169
1177
|
validMode: coordinate?.valid.mode ?? "current",
|
|
1170
1178
|
validAsOf: coordinate?.valid.asOf,
|
|
1171
|
-
recorded:
|
|
1179
|
+
recorded: chunkDWUDZ66O_cjs.optionalRecordedInstantParts(
|
|
1172
1180
|
coordinate?.recorded?.asOf,
|
|
1173
1181
|
"recorded.asOf"
|
|
1174
1182
|
),
|
|
1175
|
-
currentInstant: typeof currentInstant === "string" ?
|
|
1183
|
+
currentInstant: typeof currentInstant === "string" ? chunkH5IJSROF_cjs.sql`${currentInstant}` : currentInstant
|
|
1176
1184
|
};
|
|
1177
1185
|
}
|
|
1178
1186
|
function validityInstant(coordinate) {
|
|
1179
1187
|
if (coordinate.validMode === "asOf" && coordinate.validAsOf !== void 0) {
|
|
1180
|
-
return
|
|
1188
|
+
return chunkH5IJSROF_cjs.sql`${coordinate.validAsOf}`;
|
|
1181
1189
|
}
|
|
1182
1190
|
if (coordinate.recorded !== void 0) {
|
|
1183
|
-
return
|
|
1191
|
+
return chunkH5IJSROF_cjs.sql`${coordinate.recorded.recordedAt}`;
|
|
1184
1192
|
}
|
|
1185
1193
|
return coordinate.currentInstant;
|
|
1186
1194
|
}
|
|
1187
1195
|
function qualifiedColumn(alias, column) {
|
|
1188
|
-
return
|
|
1196
|
+
return chunkH5IJSROF_cjs.sql`${chunkH5IJSROF_cjs.sql.identifier(alias)}.${chunkH5IJSROF_cjs.sql.identifier(column)}`;
|
|
1189
1197
|
}
|
|
1190
1198
|
function identityNodeVisibilitySql(coordinate, alias) {
|
|
1191
1199
|
const deletedAt = qualifiedColumn(alias, "deleted_at");
|
|
1192
|
-
if (coordinate.validMode === "includeTombstones") return
|
|
1200
|
+
if (coordinate.validMode === "includeTombstones") return chunkH5IJSROF_cjs.sql`1 = 1`;
|
|
1193
1201
|
if (coordinate.validMode === "includeEnded") {
|
|
1194
|
-
return
|
|
1202
|
+
return chunkH5IJSROF_cjs.sql`${deletedAt} IS NULL`;
|
|
1195
1203
|
}
|
|
1196
1204
|
const validFrom = qualifiedColumn(alias, "valid_from");
|
|
1197
1205
|
const validTo = qualifiedColumn(alias, "valid_to");
|
|
1198
1206
|
const instant = validityInstant(coordinate);
|
|
1199
|
-
return
|
|
1207
|
+
return chunkH5IJSROF_cjs.sql`
|
|
1200
1208
|
${deletedAt} IS NULL
|
|
1201
1209
|
AND (${validFrom} IS NULL OR ${validFrom} <= ${instant})
|
|
1202
1210
|
AND (${validTo} IS NULL OR ${validTo} > ${instant})
|
|
@@ -1204,19 +1212,19 @@ function identityNodeVisibilitySql(coordinate, alias) {
|
|
|
1204
1212
|
}
|
|
1205
1213
|
function structuralFoldVisibilitySql(coordinate, alias) {
|
|
1206
1214
|
const deletedAt = qualifiedColumn(alias, "deleted_at");
|
|
1207
|
-
if (coordinate.recorded !== void 0) return
|
|
1208
|
-
if (coordinate.validMode !== "asOf") return
|
|
1215
|
+
if (coordinate.recorded !== void 0) return chunkH5IJSROF_cjs.sql`${deletedAt} IS NULL`;
|
|
1216
|
+
if (coordinate.validMode !== "asOf") return chunkH5IJSROF_cjs.sql`${deletedAt} IS NULL`;
|
|
1209
1217
|
const createdAt = qualifiedColumn(alias, "created_at");
|
|
1210
1218
|
const instant = validityInstant(coordinate);
|
|
1211
|
-
return
|
|
1219
|
+
return chunkH5IJSROF_cjs.sql`${createdAt} <= ${instant} AND (${deletedAt} IS NULL OR ${deletedAt} > ${instant})`;
|
|
1212
1220
|
}
|
|
1213
1221
|
function identityNodeSnapshotSource(schema, graphId, coordinate) {
|
|
1214
1222
|
const table = coordinate.recorded === void 0 ? schema.nodesTable : schema.recordedNodesTable;
|
|
1215
|
-
const recordedFilter = coordinate.recorded === void 0 ?
|
|
1223
|
+
const recordedFilter = coordinate.recorded === void 0 ? chunkH5IJSROF_cjs.sql`` : chunkH5IJSROF_cjs.sql`
|
|
1216
1224
|
AND recorded_from <= ${coordinate.recorded.revision}
|
|
1217
1225
|
AND recorded_to > ${coordinate.recorded.revision}
|
|
1218
1226
|
`;
|
|
1219
|
-
return
|
|
1227
|
+
return chunkH5IJSROF_cjs.sql`
|
|
1220
1228
|
SELECT kind, id, valid_from, valid_to, created_at, deleted_at
|
|
1221
1229
|
FROM ${table}
|
|
1222
1230
|
WHERE graph_id = ${graphId}
|
|
@@ -1225,13 +1233,13 @@ function identityNodeSnapshotSource(schema, graphId, coordinate) {
|
|
|
1225
1233
|
}
|
|
1226
1234
|
function identityAssertionSnapshotSource(schema, graphId, coordinate, relation) {
|
|
1227
1235
|
const table = coordinate.recorded === void 0 ? schema.identityAssertionsTable : schema.recordedIdentityAssertionsTable;
|
|
1228
|
-
const recordedFilter = coordinate.recorded === void 0 ?
|
|
1236
|
+
const recordedFilter = coordinate.recorded === void 0 ? chunkH5IJSROF_cjs.sql`` : chunkH5IJSROF_cjs.sql`
|
|
1229
1237
|
AND recorded_from <= ${coordinate.recorded.revision}
|
|
1230
1238
|
AND recorded_to > ${coordinate.recorded.revision}
|
|
1231
1239
|
`;
|
|
1232
|
-
const relationFilter = relation === void 0 ?
|
|
1240
|
+
const relationFilter = relation === void 0 ? chunkH5IJSROF_cjs.sql`` : chunkH5IJSROF_cjs.sql`AND rel = ${relation}`;
|
|
1233
1241
|
const instant = validityInstant(coordinate);
|
|
1234
|
-
return
|
|
1242
|
+
return chunkH5IJSROF_cjs.sql`
|
|
1235
1243
|
SELECT ${IDENTITY_ASSERTION_COLUMNS}
|
|
1236
1244
|
FROM ${table}
|
|
1237
1245
|
WHERE graph_id = ${graphId}
|
|
@@ -1243,6 +1251,10 @@ function identityAssertionSnapshotSource(schema, graphId, coordinate, relation)
|
|
|
1243
1251
|
`;
|
|
1244
1252
|
}
|
|
1245
1253
|
function historicalIdentityReconstructionCtes(input) {
|
|
1254
|
+
chunkZGVTNKTX_cjs.assertRecursiveTraversal(
|
|
1255
|
+
input.recursiveTraversal,
|
|
1256
|
+
"historical identity class read"
|
|
1257
|
+
);
|
|
1246
1258
|
const nodes = identityNodeSnapshotSource(
|
|
1247
1259
|
input.schema,
|
|
1248
1260
|
input.graphId,
|
|
@@ -1254,7 +1266,7 @@ function historicalIdentityReconstructionCtes(input) {
|
|
|
1254
1266
|
input.coordinate,
|
|
1255
1267
|
"same"
|
|
1256
1268
|
);
|
|
1257
|
-
const sameIdEdges = input.sameIdAcrossKinds === "fold" ?
|
|
1269
|
+
const sameIdEdges = input.sameIdAcrossKinds === "fold" ? chunkH5IJSROF_cjs.sql`
|
|
1258
1270
|
UNION ALL
|
|
1259
1271
|
SELECT left_node.kind, left_node.id, right_node.kind, right_node.id
|
|
1260
1272
|
FROM node_snapshot left_node
|
|
@@ -1263,8 +1275,8 @@ function historicalIdentityReconstructionCtes(input) {
|
|
|
1263
1275
|
AND right_node.kind <> left_node.kind
|
|
1264
1276
|
WHERE ${structuralFoldVisibilitySql(input.coordinate, "left_node")}
|
|
1265
1277
|
AND ${structuralFoldVisibilitySql(input.coordinate, "right_node")}
|
|
1266
|
-
` :
|
|
1267
|
-
return
|
|
1278
|
+
` : chunkH5IJSROF_cjs.sql``;
|
|
1279
|
+
return chunkH5IJSROF_cjs.sql`
|
|
1268
1280
|
node_snapshot(kind, id, valid_from, valid_to, created_at, deleted_at) AS (
|
|
1269
1281
|
${nodes}
|
|
1270
1282
|
),
|
|
@@ -1295,15 +1307,19 @@ function historicalIdentityReconstructionCtes(input) {
|
|
|
1295
1307
|
)
|
|
1296
1308
|
`;
|
|
1297
1309
|
}
|
|
1298
|
-
var IDENTITY_PEER_CLASS_COLUMNS =
|
|
1310
|
+
var IDENTITY_PEER_CLASS_COLUMNS = chunkH5IJSROF_cjs.sql.raw(
|
|
1299
1311
|
["seed_kind", "seed_id", "kind", "id"].join(", ")
|
|
1300
1312
|
);
|
|
1301
1313
|
function historicalIdentityPeerClassQuery(input) {
|
|
1314
|
+
chunkZGVTNKTX_cjs.assertRecursiveTraversal(
|
|
1315
|
+
input.recursiveTraversal,
|
|
1316
|
+
"historical identity expansion"
|
|
1317
|
+
);
|
|
1302
1318
|
const reconstruction = historicalIdentityReconstructionCtes({
|
|
1303
1319
|
...input,
|
|
1304
|
-
seedSource:
|
|
1320
|
+
seedSource: chunkH5IJSROF_cjs.sql`SELECT DISTINCT a_kind, a_id FROM identity_edges`
|
|
1305
1321
|
});
|
|
1306
|
-
return
|
|
1322
|
+
return chunkH5IJSROF_cjs.sql`
|
|
1307
1323
|
WITH RECURSIVE
|
|
1308
1324
|
${reconstruction}
|
|
1309
1325
|
SELECT member.seed_kind, member.seed_id, member.kind, member.id
|
|
@@ -1326,28 +1342,28 @@ function compileFieldColumn(field, cteAlias, cteColumnPrefix) {
|
|
|
1326
1342
|
if (cteColumnPrefix !== void 0) {
|
|
1327
1343
|
const qualifier2 = cteColumnPrefix === "" ? "" : `${cteColumnPrefix}.`;
|
|
1328
1344
|
if (field.path.length === 1 && field.path[0] === "id") {
|
|
1329
|
-
return
|
|
1345
|
+
return chunkH5IJSROF_cjs.sql.raw(`${qualifier2}id`);
|
|
1330
1346
|
}
|
|
1331
1347
|
if (field.path.length === 1 && field.path[0] === "kind") {
|
|
1332
|
-
return
|
|
1348
|
+
return chunkH5IJSROF_cjs.sql.raw(`${qualifier2}kind`);
|
|
1333
1349
|
}
|
|
1334
1350
|
if (field.path.length > 0 && field.path[0] === "props") {
|
|
1335
|
-
return
|
|
1351
|
+
return chunkH5IJSROF_cjs.sql.raw(`${qualifier2}props`);
|
|
1336
1352
|
}
|
|
1337
|
-
return
|
|
1353
|
+
return chunkH5IJSROF_cjs.sql.raw(`${qualifier2}${field.path.join("_")}`);
|
|
1338
1354
|
}
|
|
1339
1355
|
const prefix = field.alias;
|
|
1340
1356
|
const qualifier = cteAlias ? `${cteAlias}.` : "";
|
|
1341
1357
|
if (field.path.length === 1 && field.path[0] === "id") {
|
|
1342
|
-
return
|
|
1358
|
+
return chunkH5IJSROF_cjs.sql.raw(`${qualifier}${prefix}_id`);
|
|
1343
1359
|
}
|
|
1344
1360
|
if (field.path.length === 1 && field.path[0] === "kind") {
|
|
1345
|
-
return
|
|
1361
|
+
return chunkH5IJSROF_cjs.sql.raw(`${qualifier}${prefix}_kind`);
|
|
1346
1362
|
}
|
|
1347
1363
|
if (field.path.length > 0 && field.path[0] === "props") {
|
|
1348
|
-
return
|
|
1364
|
+
return chunkH5IJSROF_cjs.sql.raw(`${qualifier}${prefix}_props`);
|
|
1349
1365
|
}
|
|
1350
|
-
return
|
|
1366
|
+
return chunkH5IJSROF_cjs.sql.raw(`${qualifier}${prefix}_${field.path.join("_")}`);
|
|
1351
1367
|
}
|
|
1352
1368
|
function getFieldPointer(field) {
|
|
1353
1369
|
if (field.jsonPointer !== void 0) {
|
|
@@ -1433,7 +1449,7 @@ function resolveLiteralValueTypes(literals) {
|
|
|
1433
1449
|
}
|
|
1434
1450
|
}
|
|
1435
1451
|
if (resolved.size > 1) {
|
|
1436
|
-
throw new
|
|
1452
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
1437
1453
|
"Mixed literal value types are not supported in predicates",
|
|
1438
1454
|
{ valueTypes: [...resolved] }
|
|
1439
1455
|
);
|
|
@@ -1467,9 +1483,9 @@ function convertValueForSql(value, dialect) {
|
|
|
1467
1483
|
}
|
|
1468
1484
|
function compileStringPattern(op, pattern) {
|
|
1469
1485
|
const escaped = pattern.replaceAll(
|
|
1470
|
-
|
|
1471
|
-
`${
|
|
1472
|
-
).replaceAll("%", `${
|
|
1486
|
+
chunkA4C4NJ5U_cjs.LIKE_ESCAPE_CHARACTER,
|
|
1487
|
+
`${chunkA4C4NJ5U_cjs.LIKE_ESCAPE_CHARACTER}${chunkA4C4NJ5U_cjs.LIKE_ESCAPE_CHARACTER}`
|
|
1488
|
+
).replaceAll("%", `${chunkA4C4NJ5U_cjs.LIKE_ESCAPE_CHARACTER}%`).replaceAll("_", `${chunkA4C4NJ5U_cjs.LIKE_ESCAPE_CHARACTER}_`);
|
|
1473
1489
|
switch (op) {
|
|
1474
1490
|
case "contains": {
|
|
1475
1491
|
return `%${escaped}%`;
|
|
@@ -1490,22 +1506,22 @@ function compileStringPattern(op, pattern) {
|
|
|
1490
1506
|
}
|
|
1491
1507
|
}
|
|
1492
1508
|
function escapeLikePatternParameter(parameter) {
|
|
1493
|
-
const doubledEscape = `${
|
|
1494
|
-
return
|
|
1509
|
+
const doubledEscape = `${chunkA4C4NJ5U_cjs.LIKE_ESCAPE_CHARACTER}${chunkA4C4NJ5U_cjs.LIKE_ESCAPE_CHARACTER}`;
|
|
1510
|
+
return chunkH5IJSROF_cjs.sql`REPLACE(REPLACE(REPLACE(${parameter}, ${chunkA4C4NJ5U_cjs.LIKE_ESCAPE_CHARACTER}, ${doubledEscape}), '%', ${`${chunkA4C4NJ5U_cjs.LIKE_ESCAPE_CHARACTER}%`}), '_', ${`${chunkA4C4NJ5U_cjs.LIKE_ESCAPE_CHARACTER}_`})`;
|
|
1495
1511
|
}
|
|
1496
1512
|
function compileParameterizedStringPattern(op, parameter) {
|
|
1497
1513
|
switch (op) {
|
|
1498
1514
|
case "contains": {
|
|
1499
1515
|
const escaped = escapeLikePatternParameter(parameter);
|
|
1500
|
-
return
|
|
1516
|
+
return chunkH5IJSROF_cjs.sql`'%' || ${escaped} || '%'`;
|
|
1501
1517
|
}
|
|
1502
1518
|
case "startsWith": {
|
|
1503
1519
|
const escaped = escapeLikePatternParameter(parameter);
|
|
1504
|
-
return
|
|
1520
|
+
return chunkH5IJSROF_cjs.sql`${escaped} || '%'`;
|
|
1505
1521
|
}
|
|
1506
1522
|
case "endsWith": {
|
|
1507
1523
|
const escaped = escapeLikePatternParameter(parameter);
|
|
1508
|
-
return
|
|
1524
|
+
return chunkH5IJSROF_cjs.sql`'%' || ${escaped}`;
|
|
1509
1525
|
}
|
|
1510
1526
|
case "like":
|
|
1511
1527
|
case "ilike": {
|
|
@@ -1516,6 +1532,22 @@ function compileParameterizedStringPattern(op, parameter) {
|
|
|
1516
1532
|
}
|
|
1517
1533
|
}
|
|
1518
1534
|
}
|
|
1535
|
+
function requireRecursiveTraversalVerdict(ctx, operation) {
|
|
1536
|
+
const verdict = ctx.recursiveTraversal;
|
|
1537
|
+
if (verdict === void 0) {
|
|
1538
|
+
throw new chunkX4GDXBOP_cjs.CompilerInvariantError(
|
|
1539
|
+
"recursive traversal verdict missing from compiler context",
|
|
1540
|
+
{ operation }
|
|
1541
|
+
);
|
|
1542
|
+
}
|
|
1543
|
+
return verdict;
|
|
1544
|
+
}
|
|
1545
|
+
function assertRecursiveTraversalSupported(ctx, operation) {
|
|
1546
|
+
chunkZGVTNKTX_cjs.assertRecursiveTraversal(
|
|
1547
|
+
requireRecursiveTraversalVerdict(ctx, operation),
|
|
1548
|
+
operation
|
|
1549
|
+
);
|
|
1550
|
+
}
|
|
1519
1551
|
function compilePredicateExpression(expr, ctx) {
|
|
1520
1552
|
const { dialect } = ctx;
|
|
1521
1553
|
const cteColumnPrefix = ctx.cteColumnPrefix;
|
|
@@ -1532,18 +1564,18 @@ function compilePredicateExpression(expr, ctx) {
|
|
|
1532
1564
|
cteColumnPrefix
|
|
1533
1565
|
);
|
|
1534
1566
|
if (isParameterRef(expr.pattern)) {
|
|
1535
|
-
const placeholder =
|
|
1567
|
+
const placeholder = chunkH5IJSROF_cjs.sql`${chunkH5IJSROF_cjs.sql.placeholder(expr.pattern.name)}`;
|
|
1536
1568
|
const pattern2 = compileParameterizedStringPattern(expr.op, placeholder);
|
|
1537
1569
|
if (expr.op === "ilike" || expr.op === "contains" || expr.op === "startsWith" || expr.op === "endsWith") {
|
|
1538
1570
|
return dialect.ilike(field, pattern2);
|
|
1539
1571
|
}
|
|
1540
|
-
return
|
|
1572
|
+
return chunkH5IJSROF_cjs.sql`${field} LIKE ${pattern2} ${chunkA4C4NJ5U_cjs.likeEscapeClause}`;
|
|
1541
1573
|
}
|
|
1542
1574
|
const pattern = compileStringPattern(expr.op, expr.pattern);
|
|
1543
1575
|
if (expr.op === "ilike" || expr.op === "contains" || expr.op === "startsWith" || expr.op === "endsWith") {
|
|
1544
1576
|
return dialect.ilike(field, pattern);
|
|
1545
1577
|
}
|
|
1546
|
-
return
|
|
1578
|
+
return chunkH5IJSROF_cjs.sql`${field} LIKE ${pattern} ${chunkA4C4NJ5U_cjs.likeEscapeClause}`;
|
|
1547
1579
|
}
|
|
1548
1580
|
case "null_check": {
|
|
1549
1581
|
const field = compileFieldTextValue(
|
|
@@ -1553,7 +1585,7 @@ function compilePredicateExpression(expr, ctx) {
|
|
|
1553
1585
|
void 0,
|
|
1554
1586
|
cteColumnPrefix
|
|
1555
1587
|
);
|
|
1556
|
-
return expr.op === "isNull" ?
|
|
1588
|
+
return expr.op === "isNull" ? chunkH5IJSROF_cjs.sql`${field} IS NULL` : chunkH5IJSROF_cjs.sql`${field} IS NOT NULL`;
|
|
1557
1589
|
}
|
|
1558
1590
|
case "between": {
|
|
1559
1591
|
const lowerIsParam = isParameterRef(expr.lower);
|
|
@@ -1563,7 +1595,7 @@ function compilePredicateExpression(expr, ctx) {
|
|
|
1563
1595
|
if (!upperIsParam) boundsForType.push(expr.upper);
|
|
1564
1596
|
const valueType = boundsForType.length > 0 ? resolveComparisonValueType(expr.field, boundsForType) : normalizeValueType2(expr.field.valueType);
|
|
1565
1597
|
if (valueType === "array" || valueType === "object") {
|
|
1566
|
-
throw new
|
|
1598
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
1567
1599
|
"Between comparisons are not supported for JSON arrays or objects"
|
|
1568
1600
|
);
|
|
1569
1601
|
}
|
|
@@ -1575,25 +1607,25 @@ function compilePredicateExpression(expr, ctx) {
|
|
|
1575
1607
|
void 0,
|
|
1576
1608
|
cteColumnPrefix
|
|
1577
1609
|
);
|
|
1578
|
-
const lower = lowerIsParam ?
|
|
1579
|
-
const upper = upperIsParam ?
|
|
1580
|
-
return
|
|
1610
|
+
const lower = lowerIsParam ? chunkH5IJSROF_cjs.sql.placeholder(expr.lower.name) : convertValueForSql(expr.lower.value, dialect);
|
|
1611
|
+
const upper = upperIsParam ? chunkH5IJSROF_cjs.sql.placeholder(expr.upper.name) : convertValueForSql(expr.upper.value, dialect);
|
|
1612
|
+
return chunkH5IJSROF_cjs.sql`${field} BETWEEN ${lower} AND ${upper}`;
|
|
1581
1613
|
}
|
|
1582
1614
|
case "and": {
|
|
1583
1615
|
const parts = expr.predicates.map(
|
|
1584
1616
|
(p) => compilePredicateExpression(p, ctx)
|
|
1585
1617
|
);
|
|
1586
|
-
return
|
|
1618
|
+
return chunkH5IJSROF_cjs.sql`(${chunkH5IJSROF_cjs.sql.join(parts, chunkH5IJSROF_cjs.sql` AND `)})`;
|
|
1587
1619
|
}
|
|
1588
1620
|
case "or": {
|
|
1589
1621
|
const parts = expr.predicates.map(
|
|
1590
1622
|
(p) => compilePredicateExpression(p, ctx)
|
|
1591
1623
|
);
|
|
1592
|
-
return
|
|
1624
|
+
return chunkH5IJSROF_cjs.sql`(${chunkH5IJSROF_cjs.sql.join(parts, chunkH5IJSROF_cjs.sql` OR `)})`;
|
|
1593
1625
|
}
|
|
1594
1626
|
case "not": {
|
|
1595
1627
|
const inner = compilePredicateExpression(expr.predicate, ctx);
|
|
1596
|
-
return
|
|
1628
|
+
return chunkH5IJSROF_cjs.sql`NOT (${inner})`;
|
|
1597
1629
|
}
|
|
1598
1630
|
case "array_op": {
|
|
1599
1631
|
return compileArrayPredicate(expr, dialect, cteColumnPrefix);
|
|
@@ -1616,7 +1648,7 @@ function compilePredicateExpression(expr, ctx) {
|
|
|
1616
1648
|
}
|
|
1617
1649
|
}
|
|
1618
1650
|
}
|
|
1619
|
-
var STRUCTURAL_PREDICATE_NOOP =
|
|
1651
|
+
var STRUCTURAL_PREDICATE_NOOP = chunkH5IJSROF_cjs.sql.raw("1=1");
|
|
1620
1652
|
function compileComparisonPredicate(expr, dialect, cteColumnPrefix) {
|
|
1621
1653
|
if (isParameterRef(expr.right)) {
|
|
1622
1654
|
const parameterValueType = resolveParameterValueType(expr.left, expr.right);
|
|
@@ -1639,15 +1671,15 @@ function compileComparisonPredicate(expr, dialect, cteColumnPrefix) {
|
|
|
1639
1671
|
}
|
|
1640
1672
|
const opSql2 = COMPARISON_OP_SQL[expr.op];
|
|
1641
1673
|
if (!opSql2) {
|
|
1642
|
-
throw new
|
|
1674
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
1643
1675
|
`Comparison operation "${expr.op}" is not supported for parameterized predicates`
|
|
1644
1676
|
);
|
|
1645
1677
|
}
|
|
1646
|
-
return
|
|
1678
|
+
return chunkH5IJSROF_cjs.sql`${left2} ${chunkH5IJSROF_cjs.sql.raw(opSql2)} ${chunkH5IJSROF_cjs.sql.placeholder(expr.right.name)}`;
|
|
1647
1679
|
}
|
|
1648
1680
|
const valueType = resolveComparisonValueType(expr.left, expr.right);
|
|
1649
1681
|
if (valueType === "array" || valueType === "object") {
|
|
1650
|
-
throw new
|
|
1682
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
1651
1683
|
`Comparison operation "${expr.op}" is not supported for ${valueType} values`
|
|
1652
1684
|
);
|
|
1653
1685
|
}
|
|
@@ -1662,7 +1694,7 @@ function compileComparisonPredicate(expr, dialect, cteColumnPrefix) {
|
|
|
1662
1694
|
if (expr.op === "in" || expr.op === "notIn") {
|
|
1663
1695
|
const values = Array.isArray(expr.right) ? expr.right : [expr.right];
|
|
1664
1696
|
if (values.length === 0) {
|
|
1665
|
-
return expr.op === "in" ?
|
|
1697
|
+
return expr.op === "in" ? chunkH5IJSROF_cjs.sql.raw("1=0") : chunkH5IJSROF_cjs.sql.raw("1=1");
|
|
1666
1698
|
}
|
|
1667
1699
|
const convertedValues = values.map(
|
|
1668
1700
|
(value) => convertValueForSql(value.value, dialect)
|
|
@@ -1674,15 +1706,15 @@ function compileComparisonPredicate(expr, dialect, cteColumnPrefix) {
|
|
|
1674
1706
|
const convertedRight = convertValueForSql(rightValue.value, dialect);
|
|
1675
1707
|
const opSql = COMPARISON_OP_SQL[expr.op];
|
|
1676
1708
|
if (!opSql) {
|
|
1677
|
-
throw new
|
|
1709
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
1678
1710
|
`Comparison operation "${expr.op}" is not supported`
|
|
1679
1711
|
);
|
|
1680
1712
|
}
|
|
1681
|
-
return
|
|
1713
|
+
return chunkH5IJSROF_cjs.sql`${left} ${chunkH5IJSROF_cjs.sql.raw(opSql)} ${convertedRight}`;
|
|
1682
1714
|
}
|
|
1683
1715
|
function compileListParameterPredicate(left, parameterName, elementType, negated, dialect) {
|
|
1684
1716
|
if (elementType === "array" || elementType === "object" || elementType === "embedding") {
|
|
1685
|
-
throw new
|
|
1717
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
1686
1718
|
`IN/NOT IN is not supported for ${elementType} values`,
|
|
1687
1719
|
{ valueType: elementType },
|
|
1688
1720
|
{
|
|
@@ -1690,7 +1722,7 @@ function compileListParameterPredicate(left, parameterName, elementType, negated
|
|
|
1690
1722
|
}
|
|
1691
1723
|
);
|
|
1692
1724
|
}
|
|
1693
|
-
return dialect.inListParameter(left,
|
|
1725
|
+
return dialect.inListParameter(left, chunkH5IJSROF_cjs.sql.placeholder(parameterName), {
|
|
1694
1726
|
negated,
|
|
1695
1727
|
elementType
|
|
1696
1728
|
});
|
|
@@ -1706,30 +1738,30 @@ function compileArrayPredicate(expr, dialect, cteColumnPrefix) {
|
|
|
1706
1738
|
const values = expr.values?.map((v) => convertValueForSql(v.value, dialect)) ?? [];
|
|
1707
1739
|
switch (expr.op) {
|
|
1708
1740
|
case "isEmpty": {
|
|
1709
|
-
return
|
|
1741
|
+
return chunkH5IJSROF_cjs.sql`(${field} IS NULL OR ${dialect.jsonArrayLength(field)} = 0)`;
|
|
1710
1742
|
}
|
|
1711
1743
|
case "isNotEmpty": {
|
|
1712
|
-
return
|
|
1744
|
+
return chunkH5IJSROF_cjs.sql`(${field} IS NOT NULL AND ${dialect.jsonArrayLength(field)} > 0)`;
|
|
1713
1745
|
}
|
|
1714
1746
|
case "lengthEq": {
|
|
1715
|
-
return
|
|
1747
|
+
return chunkH5IJSROF_cjs.sql`${dialect.jsonArrayLength(field)} = ${expr.length}`;
|
|
1716
1748
|
}
|
|
1717
1749
|
case "lengthGt": {
|
|
1718
|
-
return
|
|
1750
|
+
return chunkH5IJSROF_cjs.sql`${dialect.jsonArrayLength(field)} > ${expr.length}`;
|
|
1719
1751
|
}
|
|
1720
1752
|
case "lengthGte": {
|
|
1721
|
-
return
|
|
1753
|
+
return chunkH5IJSROF_cjs.sql`${dialect.jsonArrayLength(field)} >= ${expr.length}`;
|
|
1722
1754
|
}
|
|
1723
1755
|
case "lengthLt": {
|
|
1724
|
-
return
|
|
1756
|
+
return chunkH5IJSROF_cjs.sql`${dialect.jsonArrayLength(field)} < ${expr.length}`;
|
|
1725
1757
|
}
|
|
1726
1758
|
case "lengthLte": {
|
|
1727
|
-
return
|
|
1759
|
+
return chunkH5IJSROF_cjs.sql`${dialect.jsonArrayLength(field)} <= ${expr.length}`;
|
|
1728
1760
|
}
|
|
1729
1761
|
case "contains": {
|
|
1730
1762
|
const value = values[0];
|
|
1731
1763
|
if (value === void 0) {
|
|
1732
|
-
return
|
|
1764
|
+
return chunkH5IJSROF_cjs.sql.raw("1=0");
|
|
1733
1765
|
}
|
|
1734
1766
|
return dialect.jsonArrayContains(field, value);
|
|
1735
1767
|
}
|
|
@@ -1752,13 +1784,13 @@ function compileObjectPredicate(expr, dialect, cteColumnPrefix) {
|
|
|
1752
1784
|
}
|
|
1753
1785
|
case "pathEquals": {
|
|
1754
1786
|
if (!expr.value) {
|
|
1755
|
-
throw new
|
|
1787
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
1756
1788
|
"pathEquals requires a comparison value"
|
|
1757
1789
|
);
|
|
1758
1790
|
}
|
|
1759
1791
|
const valueType = resolvePredicateValueType(expr.valueType, expr.value);
|
|
1760
1792
|
if (valueType === "array" || valueType === "object") {
|
|
1761
|
-
throw new
|
|
1793
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
1762
1794
|
"pathEquals is not supported for JSON arrays or objects"
|
|
1763
1795
|
);
|
|
1764
1796
|
}
|
|
@@ -1770,11 +1802,11 @@ function compileObjectPredicate(expr, dialect, cteColumnPrefix) {
|
|
|
1770
1802
|
pointer,
|
|
1771
1803
|
cteColumnPrefix
|
|
1772
1804
|
);
|
|
1773
|
-
return
|
|
1805
|
+
return chunkH5IJSROF_cjs.sql`${left} = ${convertValueForSql(expr.value.value, dialect)}`;
|
|
1774
1806
|
}
|
|
1775
1807
|
case "pathContains": {
|
|
1776
1808
|
if (!expr.value) {
|
|
1777
|
-
throw new
|
|
1809
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
1778
1810
|
"pathContains requires a comparison value"
|
|
1779
1811
|
);
|
|
1780
1812
|
}
|
|
@@ -1802,12 +1834,12 @@ function compileAggregatePredicate(expr, dialect) {
|
|
|
1802
1834
|
const aggregate = compileAggregateExpr(expr.aggregate, dialect);
|
|
1803
1835
|
const op = COMPARISON_OP_SQL[expr.op];
|
|
1804
1836
|
if (!op) {
|
|
1805
|
-
throw new
|
|
1837
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
1806
1838
|
`Comparison operation "${expr.op}" is not supported for aggregate predicates`
|
|
1807
1839
|
);
|
|
1808
1840
|
}
|
|
1809
1841
|
const convertedValue = convertValueForSql(expr.value.value, dialect);
|
|
1810
|
-
return
|
|
1842
|
+
return chunkH5IJSROF_cjs.sql`${aggregate} ${chunkH5IJSROF_cjs.sql.raw(op)} ${convertedValue}`;
|
|
1811
1843
|
}
|
|
1812
1844
|
function compileAggregateExpr(expr, dialect) {
|
|
1813
1845
|
const cteAlias = `cte_${expr.field.alias}`;
|
|
@@ -1819,25 +1851,25 @@ function compileAggregateExpr(expr, dialect) {
|
|
|
1819
1851
|
);
|
|
1820
1852
|
switch (expr.function) {
|
|
1821
1853
|
case "count": {
|
|
1822
|
-
return
|
|
1854
|
+
return chunkH5IJSROF_cjs.sql`COUNT(${field})`;
|
|
1823
1855
|
}
|
|
1824
1856
|
case "countDistinct": {
|
|
1825
|
-
return
|
|
1857
|
+
return chunkH5IJSROF_cjs.sql`COUNT(DISTINCT ${field})`;
|
|
1826
1858
|
}
|
|
1827
1859
|
case "sum": {
|
|
1828
|
-
return
|
|
1860
|
+
return chunkH5IJSROF_cjs.sql`SUM(${field})`;
|
|
1829
1861
|
}
|
|
1830
1862
|
case "avg": {
|
|
1831
|
-
return
|
|
1863
|
+
return chunkH5IJSROF_cjs.sql`AVG(${field})`;
|
|
1832
1864
|
}
|
|
1833
1865
|
case "min": {
|
|
1834
|
-
return
|
|
1866
|
+
return chunkH5IJSROF_cjs.sql`MIN(${field})`;
|
|
1835
1867
|
}
|
|
1836
1868
|
case "max": {
|
|
1837
|
-
return
|
|
1869
|
+
return chunkH5IJSROF_cjs.sql`MAX(${field})`;
|
|
1838
1870
|
}
|
|
1839
1871
|
default: {
|
|
1840
|
-
throw new
|
|
1872
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
1841
1873
|
`Unknown aggregate function: ${expr.function}`
|
|
1842
1874
|
);
|
|
1843
1875
|
}
|
|
@@ -1845,15 +1877,15 @@ function compileAggregateExpr(expr, dialect) {
|
|
|
1845
1877
|
}
|
|
1846
1878
|
function compileExistsSubquery(expr, ctx) {
|
|
1847
1879
|
if (expr.subquery.graphId === void 0) {
|
|
1848
|
-
throw new
|
|
1880
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError("EXISTS subquery must have a graphId");
|
|
1849
1881
|
}
|
|
1850
1882
|
const subSql = ctx.compileQuery(expr.subquery, expr.subquery.graphId);
|
|
1851
|
-
return expr.negated ?
|
|
1883
|
+
return expr.negated ? chunkH5IJSROF_cjs.sql`NOT EXISTS (${subSql})` : chunkH5IJSROF_cjs.sql`EXISTS (${subSql})`;
|
|
1852
1884
|
}
|
|
1853
1885
|
function compileInSubquery(expr, ctx) {
|
|
1854
1886
|
const subqueryColumnCount = getSubqueryColumnCount(expr.subquery);
|
|
1855
1887
|
if (subqueryColumnCount !== 1) {
|
|
1856
|
-
throw new
|
|
1888
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
1857
1889
|
`IN/NOT IN subquery must project exactly 1 column, but got ${subqueryColumnCount}`,
|
|
1858
1890
|
{ subqueryColumnCount }
|
|
1859
1891
|
);
|
|
@@ -1862,13 +1894,13 @@ function compileInSubquery(expr, ctx) {
|
|
|
1862
1894
|
const subqueryValueType = getSingleSubqueryColumnValueType(expr.subquery);
|
|
1863
1895
|
const resolvedValueType = fieldValueType ?? subqueryValueType;
|
|
1864
1896
|
if (isUnsupportedInSubqueryValueType(resolvedValueType)) {
|
|
1865
|
-
throw new
|
|
1897
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
1866
1898
|
`IN/NOT IN subquery does not support ${String(resolvedValueType)} values`,
|
|
1867
1899
|
{ valueType: resolvedValueType }
|
|
1868
1900
|
);
|
|
1869
1901
|
}
|
|
1870
1902
|
if (!isInSubqueryTypeCompatible(fieldValueType, subqueryValueType)) {
|
|
1871
|
-
throw new
|
|
1903
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
1872
1904
|
`IN/NOT IN type mismatch: field type "${String(fieldValueType)}" does not match subquery column type "${String(subqueryValueType)}"`,
|
|
1873
1905
|
{
|
|
1874
1906
|
fieldValueType,
|
|
@@ -1878,7 +1910,7 @@ function compileInSubquery(expr, ctx) {
|
|
|
1878
1910
|
}
|
|
1879
1911
|
const valueType = fieldValueType ?? subqueryValueType;
|
|
1880
1912
|
if (expr.subquery.graphId === void 0) {
|
|
1881
|
-
throw new
|
|
1913
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(
|
|
1882
1914
|
"IN/NOT IN subquery must have a graphId"
|
|
1883
1915
|
);
|
|
1884
1916
|
}
|
|
@@ -1891,14 +1923,14 @@ function compileInSubquery(expr, ctx) {
|
|
|
1891
1923
|
ctx.cteColumnPrefix
|
|
1892
1924
|
);
|
|
1893
1925
|
const subSql = ctx.compileQuery(expr.subquery, expr.subquery.graphId);
|
|
1894
|
-
return expr.negated ?
|
|
1926
|
+
return expr.negated ? chunkH5IJSROF_cjs.sql`${fieldSql} NOT IN (${subSql})` : chunkH5IJSROF_cjs.sql`${fieldSql} IN (${subSql})`;
|
|
1895
1927
|
}
|
|
1896
1928
|
function extractStructuralPredicates(predicates, isMatch, rejectionMessage) {
|
|
1897
1929
|
const results = [];
|
|
1898
1930
|
function visit(expr, inDisallowedBranch) {
|
|
1899
1931
|
if (isMatch(expr)) {
|
|
1900
1932
|
if (inDisallowedBranch) {
|
|
1901
|
-
throw new
|
|
1933
|
+
throw new chunkX4GDXBOP_cjs.UnsupportedPredicateError(rejectionMessage);
|
|
1902
1934
|
}
|
|
1903
1935
|
results.push(expr);
|
|
1904
1936
|
return;
|
|
@@ -1952,9 +1984,9 @@ function extractFulltextMatchPredicates(predicates) {
|
|
|
1952
1984
|
// src/query/compiler/predicate-utils.ts
|
|
1953
1985
|
var EMPTY_PREDICATES = [];
|
|
1954
1986
|
function sqlValueList(values) {
|
|
1955
|
-
return
|
|
1956
|
-
values.map((value) =>
|
|
1957
|
-
|
|
1987
|
+
return chunkH5IJSROF_cjs.sql.join(
|
|
1988
|
+
values.map((value) => chunkH5IJSROF_cjs.sql`${value}`),
|
|
1989
|
+
chunkH5IJSROF_cjs.sql`, `
|
|
1958
1990
|
);
|
|
1959
1991
|
}
|
|
1960
1992
|
function buildPredicateIndexKey(alias, targetType) {
|
|
@@ -1991,12 +2023,12 @@ function compilePredicateClauses(predicates, predicateContext) {
|
|
|
1991
2023
|
}
|
|
1992
2024
|
function compileKindFilter(column, kinds) {
|
|
1993
2025
|
if (kinds.length === 0) {
|
|
1994
|
-
return
|
|
2026
|
+
return chunkH5IJSROF_cjs.sql`1 = 0`;
|
|
1995
2027
|
}
|
|
1996
2028
|
if (kinds.length === 1) {
|
|
1997
|
-
return
|
|
2029
|
+
return chunkH5IJSROF_cjs.sql`${column} = ${kinds[0]}`;
|
|
1998
2030
|
}
|
|
1999
|
-
return
|
|
2031
|
+
return chunkH5IJSROF_cjs.sql`${column} IN (${sqlValueList(kinds)})`;
|
|
2000
2032
|
}
|
|
2001
2033
|
function getNodeKindsForAlias(ast, alias) {
|
|
2002
2034
|
if (alias === ast.start.alias) {
|
|
@@ -2007,7 +2039,7 @@ function getNodeKindsForAlias(ast, alias) {
|
|
|
2007
2039
|
return traversal.nodeKinds;
|
|
2008
2040
|
}
|
|
2009
2041
|
}
|
|
2010
|
-
throw new
|
|
2042
|
+
throw new chunkX4GDXBOP_cjs.CompilerInvariantError(`Unknown traversal source alias: ${alias}`);
|
|
2011
2043
|
}
|
|
2012
2044
|
function getHybridTargetAlias(vectorPredicate, fulltextPredicate) {
|
|
2013
2045
|
if (!vectorPredicate || !fulltextPredicate) return void 0;
|
|
@@ -2034,17 +2066,27 @@ async function getRowsByIds(ids, policy) {
|
|
|
2034
2066
|
}
|
|
2035
2067
|
|
|
2036
2068
|
// src/store/edge-fetch.ts
|
|
2037
|
-
async function getEdgeRowsByIds(backend, graphId, ids) {
|
|
2069
|
+
async function getEdgeRowsByIds(backend, verdict, graphId, ids) {
|
|
2070
|
+
const bound = chunkNUQ2YFFH_cjs.bindExtraIfReachable(
|
|
2071
|
+
backend,
|
|
2072
|
+
verdict.extras.getEdges,
|
|
2073
|
+
chunkNUQ2YFFH_cjs.BATCH_POINT_READ.id
|
|
2074
|
+
);
|
|
2038
2075
|
return getRowsByIds(ids, {
|
|
2039
|
-
batch:
|
|
2076
|
+
batch: bound === void 0 ? void 0 : ((batchIds) => bound.getEdges(graphId, batchIds)),
|
|
2040
2077
|
one: (id) => backend.getEdge(graphId, id)
|
|
2041
2078
|
});
|
|
2042
2079
|
}
|
|
2043
2080
|
|
|
2044
2081
|
// src/store/node-fetch.ts
|
|
2045
|
-
async function getNodeRowsByIds(backend, graphId, kind, ids) {
|
|
2082
|
+
async function getNodeRowsByIds(backend, verdict, graphId, kind, ids) {
|
|
2083
|
+
const bound = chunkNUQ2YFFH_cjs.bindExtraIfReachable(
|
|
2084
|
+
backend,
|
|
2085
|
+
verdict.extras.getNodes,
|
|
2086
|
+
chunkNUQ2YFFH_cjs.BATCH_POINT_READ.id
|
|
2087
|
+
);
|
|
2046
2088
|
return getRowsByIds(ids, {
|
|
2047
|
-
batch:
|
|
2089
|
+
batch: bound === void 0 ? void 0 : ((batchIds) => bound.getNodes(graphId, kind, batchIds)),
|
|
2048
2090
|
one: (id) => backend.getNode(graphId, kind, id)
|
|
2049
2091
|
});
|
|
2050
2092
|
}
|
|
@@ -2112,16 +2154,16 @@ var RECORDED_IDENTITY_ASSERTION_COLUMNS = [
|
|
|
2112
2154
|
"recorded_to",
|
|
2113
2155
|
"op"
|
|
2114
2156
|
];
|
|
2115
|
-
var RECORDED_NODE_COLUMN_LIST =
|
|
2116
|
-
var RECORDED_EDGE_COLUMN_LIST =
|
|
2117
|
-
var RECORDED_IDENTITY_ASSERTION_COLUMN_LIST =
|
|
2157
|
+
var RECORDED_NODE_COLUMN_LIST = chunkH5IJSROF_cjs.sql.raw(RECORDED_NODE_COLUMNS.join(", "));
|
|
2158
|
+
var RECORDED_EDGE_COLUMN_LIST = chunkH5IJSROF_cjs.sql.raw(RECORDED_EDGE_COLUMNS.join(", "));
|
|
2159
|
+
var RECORDED_IDENTITY_ASSERTION_COLUMN_LIST = chunkH5IJSROF_cjs.sql.raw(
|
|
2118
2160
|
RECORDED_IDENTITY_ASSERTION_COLUMNS.join(", ")
|
|
2119
2161
|
);
|
|
2120
2162
|
var RECORDED_BIND_PARAM_BUDGET = 900;
|
|
2121
2163
|
function recordedBindParamBudget(target) {
|
|
2122
2164
|
const budget = target.capabilities.maxBindParameters ?? RECORDED_BIND_PARAM_BUDGET;
|
|
2123
2165
|
if (!Number.isSafeInteger(budget) || budget < 1) {
|
|
2124
|
-
throw new
|
|
2166
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
2125
2167
|
`backend capabilities.maxBindParameters must be a positive integer, got: ${String(budget)}`,
|
|
2126
2168
|
{
|
|
2127
2169
|
code: "INVALID_BACKEND_CAPABILITY",
|
|
@@ -2137,64 +2179,64 @@ function recordedChunkSize(target, columnCount) {
|
|
|
2137
2179
|
return Math.max(1, Math.floor(budget / columnCount));
|
|
2138
2180
|
}
|
|
2139
2181
|
function sqlNull(value) {
|
|
2140
|
-
return value === void 0 ?
|
|
2182
|
+
return value === void 0 ? chunkH5IJSROF_cjs.sql.raw("NULL") : chunkH5IJSROF_cjs.sql`${value}`;
|
|
2141
2183
|
}
|
|
2142
2184
|
function recordedCommonCells() {
|
|
2143
2185
|
return {
|
|
2144
|
-
history_id: () =>
|
|
2145
|
-
graph_id: (row) =>
|
|
2146
|
-
id: (row) =>
|
|
2147
|
-
kind: (row) =>
|
|
2148
|
-
props: (row) =>
|
|
2149
|
-
valid_from: (row) =>
|
|
2150
|
-
valid_to: (row) =>
|
|
2151
|
-
created_at: (row) =>
|
|
2152
|
-
updated_at: (row) =>
|
|
2153
|
-
deleted_at: (row) =>
|
|
2154
|
-
recorded_from: (_row, recordedRevision) =>
|
|
2155
|
-
recorded_to: () =>
|
|
2156
|
-
op: (_row, _recordedCommit, operation) =>
|
|
2157
|
-
schema_version: () =>
|
|
2158
|
-
tx_id: () =>
|
|
2159
|
-
meta: () =>
|
|
2186
|
+
history_id: () => chunkH5IJSROF_cjs.sql`${generateId()}`,
|
|
2187
|
+
graph_id: (row) => chunkH5IJSROF_cjs.sql`${row.graph_id}`,
|
|
2188
|
+
id: (row) => chunkH5IJSROF_cjs.sql`${row.id}`,
|
|
2189
|
+
kind: (row) => chunkH5IJSROF_cjs.sql`${row.kind}`,
|
|
2190
|
+
props: (row) => chunkH5IJSROF_cjs.sql`${chunkNUQ2YFFH_cjs.rowPropsToJsonText(row.props)}`,
|
|
2191
|
+
valid_from: (row) => chunkH5IJSROF_cjs.sql`${sqlNull(row.valid_from)}`,
|
|
2192
|
+
valid_to: (row) => chunkH5IJSROF_cjs.sql`${sqlNull(row.valid_to)}`,
|
|
2193
|
+
created_at: (row) => chunkH5IJSROF_cjs.sql`${row.created_at}`,
|
|
2194
|
+
updated_at: (row) => chunkH5IJSROF_cjs.sql`${row.updated_at}`,
|
|
2195
|
+
deleted_at: (row) => chunkH5IJSROF_cjs.sql`${sqlNull(row.deleted_at)}`,
|
|
2196
|
+
recorded_from: (_row, recordedRevision) => chunkH5IJSROF_cjs.sql`${recordedRevision}`,
|
|
2197
|
+
recorded_to: () => chunkH5IJSROF_cjs.sql`${chunkDWUDZ66O_cjs.RECORDED_MAX_REVISION}`,
|
|
2198
|
+
op: (_row, _recordedCommit, operation) => chunkH5IJSROF_cjs.sql`${operation}`,
|
|
2199
|
+
schema_version: () => chunkH5IJSROF_cjs.sql`NULL`,
|
|
2200
|
+
tx_id: () => chunkH5IJSROF_cjs.sql`NULL`,
|
|
2201
|
+
meta: () => chunkH5IJSROF_cjs.sql`${RECORDED_HISTORY_META}`
|
|
2160
2202
|
};
|
|
2161
2203
|
}
|
|
2162
2204
|
var recordedNodeCells = {
|
|
2163
2205
|
...recordedCommonCells(),
|
|
2164
|
-
version: (row) =>
|
|
2206
|
+
version: (row) => chunkH5IJSROF_cjs.sql`${row.version}`
|
|
2165
2207
|
};
|
|
2166
2208
|
var recordedEdgeCells = {
|
|
2167
2209
|
...recordedCommonCells(),
|
|
2168
|
-
from_kind: (row) =>
|
|
2169
|
-
from_id: (row) =>
|
|
2170
|
-
to_kind: (row) =>
|
|
2171
|
-
to_id: (row) =>
|
|
2210
|
+
from_kind: (row) => chunkH5IJSROF_cjs.sql`${row.from_kind}`,
|
|
2211
|
+
from_id: (row) => chunkH5IJSROF_cjs.sql`${row.from_id}`,
|
|
2212
|
+
to_kind: (row) => chunkH5IJSROF_cjs.sql`${row.to_kind}`,
|
|
2213
|
+
to_id: (row) => chunkH5IJSROF_cjs.sql`${row.to_id}`
|
|
2172
2214
|
};
|
|
2173
2215
|
var recordedIdentityAssertionCells = {
|
|
2174
|
-
history_id: () =>
|
|
2175
|
-
graph_id: (row) =>
|
|
2176
|
-
id: (row) =>
|
|
2177
|
-
rel: (row) =>
|
|
2178
|
-
a_kind: (row) =>
|
|
2179
|
-
a_id: (row) =>
|
|
2180
|
-
b_kind: (row) =>
|
|
2181
|
-
b_id: (row) =>
|
|
2182
|
-
valid_from: (row) =>
|
|
2183
|
-
valid_to: (row) =>
|
|
2184
|
-
created_at: (row) =>
|
|
2185
|
-
updated_at: (row) =>
|
|
2186
|
-
deleted_at: (row) =>
|
|
2187
|
-
ended_by_kind: (row) =>
|
|
2188
|
-
ended_by_id: (row) =>
|
|
2189
|
-
recorded_from: (_row, recordedRevision) =>
|
|
2190
|
-
recorded_to: () =>
|
|
2191
|
-
op: (_row, _recordedRevision, operation) =>
|
|
2216
|
+
history_id: () => chunkH5IJSROF_cjs.sql`${generateId()}`,
|
|
2217
|
+
graph_id: (row) => chunkH5IJSROF_cjs.sql`${row.graph_id}`,
|
|
2218
|
+
id: (row) => chunkH5IJSROF_cjs.sql`${row.id}`,
|
|
2219
|
+
rel: (row) => chunkH5IJSROF_cjs.sql`${row.rel}`,
|
|
2220
|
+
a_kind: (row) => chunkH5IJSROF_cjs.sql`${row.a_kind}`,
|
|
2221
|
+
a_id: (row) => chunkH5IJSROF_cjs.sql`${row.a_id}`,
|
|
2222
|
+
b_kind: (row) => chunkH5IJSROF_cjs.sql`${row.b_kind}`,
|
|
2223
|
+
b_id: (row) => chunkH5IJSROF_cjs.sql`${row.b_id}`,
|
|
2224
|
+
valid_from: (row) => chunkH5IJSROF_cjs.sql`${row.valid_from}`,
|
|
2225
|
+
valid_to: (row) => chunkH5IJSROF_cjs.sql`${row.valid_to ?? chunkH5IJSROF_cjs.sql.raw("NULL")}`,
|
|
2226
|
+
created_at: (row) => chunkH5IJSROF_cjs.sql`${row.created_at}`,
|
|
2227
|
+
updated_at: (row) => chunkH5IJSROF_cjs.sql`${row.updated_at}`,
|
|
2228
|
+
deleted_at: (row) => chunkH5IJSROF_cjs.sql`${row.deleted_at ?? chunkH5IJSROF_cjs.sql.raw("NULL")}`,
|
|
2229
|
+
ended_by_kind: (row) => chunkH5IJSROF_cjs.sql`${row.ended_by_kind ?? chunkH5IJSROF_cjs.sql.raw("NULL")}`,
|
|
2230
|
+
ended_by_id: (row) => chunkH5IJSROF_cjs.sql`${row.ended_by_id ?? chunkH5IJSROF_cjs.sql.raw("NULL")}`,
|
|
2231
|
+
recorded_from: (_row, recordedRevision) => chunkH5IJSROF_cjs.sql`${recordedRevision}`,
|
|
2232
|
+
recorded_to: () => chunkH5IJSROF_cjs.sql`${chunkDWUDZ66O_cjs.RECORDED_MAX_REVISION}`,
|
|
2233
|
+
op: (_row, _recordedRevision, operation) => chunkH5IJSROF_cjs.sql`${operation}`
|
|
2192
2234
|
};
|
|
2193
2235
|
function recordedValuesTuple(columns, cells, row, recordedRevision, operation) {
|
|
2194
2236
|
const tuple = columns.map(
|
|
2195
2237
|
(column) => cells[column](row, recordedRevision, operation)
|
|
2196
2238
|
);
|
|
2197
|
-
return
|
|
2239
|
+
return chunkH5IJSROF_cjs.sql`(${chunkH5IJSROF_cjs.sql.join(tuple, chunkH5IJSROF_cjs.sql`, `)})`;
|
|
2198
2240
|
}
|
|
2199
2241
|
async function insertRecordedRows(target, table, columnList, columns, cells, inserts, recordedRevision) {
|
|
2200
2242
|
if (inserts.length === 0) return;
|
|
@@ -2209,9 +2251,9 @@ async function insertRecordedRows(target, table, columnList, columns, cells, ins
|
|
|
2209
2251
|
);
|
|
2210
2252
|
await executeStatement(
|
|
2211
2253
|
target,
|
|
2212
|
-
|
|
2254
|
+
chunkH5IJSROF_cjs.sql`
|
|
2213
2255
|
INSERT INTO ${table} (${columnList})
|
|
2214
|
-
VALUES ${
|
|
2256
|
+
VALUES ${chunkH5IJSROF_cjs.sql.join(values, chunkH5IJSROF_cjs.sql`, `)}
|
|
2215
2257
|
`
|
|
2216
2258
|
);
|
|
2217
2259
|
}
|
|
@@ -2273,14 +2315,14 @@ function entityKey(entity) {
|
|
|
2273
2315
|
}
|
|
2274
2316
|
}
|
|
2275
2317
|
async function closeOpenReturning(target, table, graphId, ids, recordedRevision, kind) {
|
|
2276
|
-
const kindFilter = kind === void 0 ?
|
|
2318
|
+
const kindFilter = kind === void 0 ? chunkH5IJSROF_cjs.sql`` : chunkH5IJSROF_cjs.sql`AND kind = ${kind}`;
|
|
2277
2319
|
const rows = await target.execute(
|
|
2278
|
-
|
|
2320
|
+
chunkH5IJSROF_cjs.asCompiledRowsSql(chunkH5IJSROF_cjs.sql`
|
|
2279
2321
|
UPDATE ${table}
|
|
2280
2322
|
SET recorded_to = ${recordedRevision}
|
|
2281
2323
|
WHERE graph_id = ${graphId}
|
|
2282
2324
|
${kindFilter}
|
|
2283
|
-
AND recorded_to = ${
|
|
2325
|
+
AND recorded_to = ${chunkDWUDZ66O_cjs.RECORDED_MAX_REVISION}
|
|
2284
2326
|
AND id IN (${sqlValueList(ids)})
|
|
2285
2327
|
RETURNING id, deleted_at
|
|
2286
2328
|
`)
|
|
@@ -2322,10 +2364,10 @@ function recordedInsertsFor(afterById, closed) {
|
|
|
2322
2364
|
operation: recordedOp(closed.has(row.id), closed.get(row.id) ?? false, row)
|
|
2323
2365
|
}));
|
|
2324
2366
|
}
|
|
2325
|
-
async function flushNodes(target, schema, graphId, entities, recordedRevision) {
|
|
2367
|
+
async function flushNodes(target, batchPointRead, schema, graphId, entities, recordedRevision) {
|
|
2326
2368
|
const chunkSize = recordedNodeChunkSize(target);
|
|
2327
2369
|
for (const [kind, group] of groupNodesByKind(entities)) {
|
|
2328
|
-
for (const entityChunk of
|
|
2370
|
+
for (const entityChunk of chunkNLX5OWK7_cjs.chunk(group, chunkSize)) {
|
|
2329
2371
|
const ids = entityChunk.map((entity) => entity.id);
|
|
2330
2372
|
const closed = await closeOpenReturning(
|
|
2331
2373
|
target,
|
|
@@ -2337,7 +2379,7 @@ async function flushNodes(target, schema, graphId, entities, recordedRevision) {
|
|
|
2337
2379
|
);
|
|
2338
2380
|
const afterById = await resolveAfterImages(
|
|
2339
2381
|
entityChunk,
|
|
2340
|
-
(missing) => getNodeRowsByIds(target, graphId, kind, missing)
|
|
2382
|
+
(missing) => getNodeRowsByIds(target, batchPointRead, graphId, kind, missing)
|
|
2341
2383
|
);
|
|
2342
2384
|
await insertRecordedNodeRows(
|
|
2343
2385
|
target,
|
|
@@ -2348,9 +2390,9 @@ async function flushNodes(target, schema, graphId, entities, recordedRevision) {
|
|
|
2348
2390
|
}
|
|
2349
2391
|
}
|
|
2350
2392
|
}
|
|
2351
|
-
async function flushEdges(target, schema, graphId, entities, recordedRevision) {
|
|
2393
|
+
async function flushEdges(target, batchPointRead, schema, graphId, entities, recordedRevision) {
|
|
2352
2394
|
const chunkSize = recordedEdgeChunkSize(target);
|
|
2353
|
-
for (const entityChunk of
|
|
2395
|
+
for (const entityChunk of chunkNLX5OWK7_cjs.chunk(entities, chunkSize)) {
|
|
2354
2396
|
const ids = entityChunk.map((entity) => entity.id);
|
|
2355
2397
|
const closed = await closeOpenReturning(
|
|
2356
2398
|
target,
|
|
@@ -2361,7 +2403,7 @@ async function flushEdges(target, schema, graphId, entities, recordedRevision) {
|
|
|
2361
2403
|
);
|
|
2362
2404
|
const afterById = await resolveAfterImages(
|
|
2363
2405
|
entityChunk,
|
|
2364
|
-
(missing) => getEdgeRowsByIds(target, graphId, missing)
|
|
2406
|
+
(missing) => getEdgeRowsByIds(target, batchPointRead, graphId, missing)
|
|
2365
2407
|
);
|
|
2366
2408
|
await insertRecordedEdgeRows(
|
|
2367
2409
|
target,
|
|
@@ -2374,7 +2416,7 @@ async function flushEdges(target, schema, graphId, entities, recordedRevision) {
|
|
|
2374
2416
|
async function getIdentityAssertionRowsByIds(target, schema, graphId, ids) {
|
|
2375
2417
|
if (ids.length === 0) return /* @__PURE__ */ new Map();
|
|
2376
2418
|
const rows = await target.execute(
|
|
2377
|
-
|
|
2419
|
+
chunkH5IJSROF_cjs.asCompiledRowsSql(chunkH5IJSROF_cjs.sql`
|
|
2378
2420
|
SELECT ${IDENTITY_ASSERTION_COLUMNS}
|
|
2379
2421
|
FROM ${schema.identityAssertionsTable}
|
|
2380
2422
|
WHERE graph_id = ${graphId}
|
|
@@ -2386,7 +2428,7 @@ async function getIdentityAssertionRowsByIds(target, schema, graphId, ids) {
|
|
|
2386
2428
|
async function flushIdentityAssertions(target, schema, graphId, entities, recordedRevision) {
|
|
2387
2429
|
if (entities.length === 0) return;
|
|
2388
2430
|
const chunkSize = recordedIdentityAssertionChunkSize(target);
|
|
2389
|
-
for (const entityChunk of
|
|
2431
|
+
for (const entityChunk of chunkNLX5OWK7_cjs.chunk(entities, chunkSize)) {
|
|
2390
2432
|
const ids = entityChunk.map((entity) => entity.id);
|
|
2391
2433
|
const closed = await closeOpenReturning(
|
|
2392
2434
|
target,
|
|
@@ -2410,24 +2452,24 @@ async function flushIdentityAssertions(target, schema, graphId, entities, record
|
|
|
2410
2452
|
async function closeOpenByKind(target, table, graphId, kind, recordedRevision) {
|
|
2411
2453
|
await executeStatement(
|
|
2412
2454
|
target,
|
|
2413
|
-
|
|
2455
|
+
chunkH5IJSROF_cjs.sql`
|
|
2414
2456
|
UPDATE ${table}
|
|
2415
2457
|
SET recorded_to = ${recordedRevision}
|
|
2416
2458
|
WHERE graph_id = ${graphId}
|
|
2417
2459
|
AND kind = ${kind}
|
|
2418
|
-
AND recorded_to = ${
|
|
2460
|
+
AND recorded_to = ${chunkDWUDZ66O_cjs.RECORDED_MAX_REVISION}
|
|
2419
2461
|
`
|
|
2420
2462
|
);
|
|
2421
2463
|
}
|
|
2422
2464
|
async function closeOpenEdgesByNodeKind(target, schema, graphId, nodeKind, recordedRevision) {
|
|
2423
2465
|
await executeStatement(
|
|
2424
2466
|
target,
|
|
2425
|
-
|
|
2467
|
+
chunkH5IJSROF_cjs.sql`
|
|
2426
2468
|
UPDATE ${schema.recordedEdgesTable}
|
|
2427
2469
|
SET recorded_to = ${recordedRevision}
|
|
2428
2470
|
WHERE graph_id = ${graphId}
|
|
2429
2471
|
AND (from_kind = ${nodeKind} OR to_kind = ${nodeKind})
|
|
2430
|
-
AND recorded_to = ${
|
|
2472
|
+
AND recorded_to = ${chunkDWUDZ66O_cjs.RECORDED_MAX_REVISION}
|
|
2431
2473
|
`
|
|
2432
2474
|
);
|
|
2433
2475
|
}
|
|
@@ -2465,7 +2507,7 @@ async function closeRecordedHardDeletedKind(target, schema, graphId, removal, ow
|
|
|
2465
2507
|
}
|
|
2466
2508
|
async function queryConnectedEdgeIds(target, schema, params) {
|
|
2467
2509
|
const rows = await target.execute(
|
|
2468
|
-
|
|
2510
|
+
chunkH5IJSROF_cjs.asCompiledRowsSql(chunkH5IJSROF_cjs.sql`
|
|
2469
2511
|
SELECT id
|
|
2470
2512
|
FROM ${schema.edgesTable}
|
|
2471
2513
|
WHERE graph_id = ${params.graphId}
|
|
@@ -2486,9 +2528,9 @@ function normalizedColumnType(value) {
|
|
|
2486
2528
|
}
|
|
2487
2529
|
async function readColumnTypes(backend, table) {
|
|
2488
2530
|
const rows = backend.dialect === "sqlite" ? await backend.execute(
|
|
2489
|
-
|
|
2531
|
+
chunkH5IJSROF_cjs.asCompiledRowsSql(chunkH5IJSROF_cjs.sql`PRAGMA table_info(${chunkH5IJSROF_cjs.sql.identifier(table)})`)
|
|
2490
2532
|
) : await backend.execute(
|
|
2491
|
-
|
|
2533
|
+
chunkH5IJSROF_cjs.asCompiledRowsSql(chunkH5IJSROF_cjs.sql`
|
|
2492
2534
|
SELECT column_name AS name, data_type AS type
|
|
2493
2535
|
FROM information_schema.columns
|
|
2494
2536
|
WHERE table_schema = current_schema()
|
|
@@ -2570,7 +2612,7 @@ async function assertCurrentRecordedSchema(backend, schema, includeIdentity = fa
|
|
|
2570
2612
|
);
|
|
2571
2613
|
const recordedIdentityTable = schema.tables.recordedIdentityAssertions;
|
|
2572
2614
|
if (includeIdentity && (columnTypes.get(recordedIdentityTable)?.size ?? 0) === 0) {
|
|
2573
|
-
throw new
|
|
2615
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
2574
2616
|
"Recorded identity history is not provisioned for this database.",
|
|
2575
2617
|
{
|
|
2576
2618
|
code: "RECORDED_IDENTITY_SCHEMA_MISSING",
|
|
@@ -2590,7 +2632,7 @@ async function assertCurrentRecordedSchema(backend, schema, includeIdentity = fa
|
|
|
2590
2632
|
return [{ ...requirement, actual: actual ?? "missing" }];
|
|
2591
2633
|
});
|
|
2592
2634
|
if (incompatible.length === 0) return;
|
|
2593
|
-
throw new
|
|
2635
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
2594
2636
|
"Recorded-time schema is incompatible with history capture.",
|
|
2595
2637
|
{
|
|
2596
2638
|
code: "RECORDED_SCHEMA_INCOMPATIBLE",
|
|
@@ -2638,7 +2680,7 @@ function edgeRowIdentityKey(row) {
|
|
|
2638
2680
|
return edgeIdentityKey(row.graph_id, row.id);
|
|
2639
2681
|
}
|
|
2640
2682
|
function recordedCaptureSealedError(details) {
|
|
2641
|
-
return new
|
|
2683
|
+
return new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
2642
2684
|
"Recorded-time capture session is sealed: a graph write happened after the transaction's capture was flushed.",
|
|
2643
2685
|
details,
|
|
2644
2686
|
{
|
|
@@ -2677,9 +2719,9 @@ function createRecordedCaptureSession() {
|
|
|
2677
2719
|
if (sealed) throw recordedCaptureSealedError({ graphId });
|
|
2678
2720
|
forcedGraphRevisions.add(graphId);
|
|
2679
2721
|
},
|
|
2680
|
-
async flush(target, schema, ownsWriteLock) {
|
|
2722
|
+
async flush(target, batchPointRead, schema, ownsWriteLock) {
|
|
2681
2723
|
if (sealed) {
|
|
2682
|
-
throw new
|
|
2724
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
2683
2725
|
"Recorded-time capture session was already flushed.",
|
|
2684
2726
|
{},
|
|
2685
2727
|
{
|
|
@@ -2691,7 +2733,7 @@ function createRecordedCaptureSession() {
|
|
|
2691
2733
|
if (touched.size === 0 && forcedGraphRevisions.size === 0)
|
|
2692
2734
|
return /* @__PURE__ */ new Map();
|
|
2693
2735
|
const recordedByGraph = /* @__PURE__ */ new Map();
|
|
2694
|
-
const byGraph =
|
|
2736
|
+
const byGraph = chunkNLX5OWK7_cjs.groupBy(touched.values(), (entity) => entity.graphId);
|
|
2695
2737
|
for (const graphId of forcedGraphRevisions) {
|
|
2696
2738
|
if (!byGraph.has(graphId)) byGraph.set(graphId, []);
|
|
2697
2739
|
}
|
|
@@ -2714,6 +2756,7 @@ function createRecordedCaptureSession() {
|
|
|
2714
2756
|
);
|
|
2715
2757
|
await flushNodes(
|
|
2716
2758
|
target,
|
|
2759
|
+
batchPointRead,
|
|
2717
2760
|
schema,
|
|
2718
2761
|
graphId,
|
|
2719
2762
|
nodes,
|
|
@@ -2721,6 +2764,7 @@ function createRecordedCaptureSession() {
|
|
|
2721
2764
|
);
|
|
2722
2765
|
await flushEdges(
|
|
2723
2766
|
target,
|
|
2767
|
+
batchPointRead,
|
|
2724
2768
|
schema,
|
|
2725
2769
|
graphId,
|
|
2726
2770
|
edges,
|
|
@@ -2776,7 +2820,7 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
2776
2820
|
await lockRecordedGraphWrite(target, graphId, graphLocks);
|
|
2777
2821
|
}
|
|
2778
2822
|
}
|
|
2779
|
-
const overlay =
|
|
2823
|
+
const overlay = chunkNLX5OWK7_cjs.deriveBackend(target, {
|
|
2780
2824
|
...rawWriteGuards(target, "tx.backend"),
|
|
2781
2825
|
async insertNode(params) {
|
|
2782
2826
|
session.assertOpen();
|
|
@@ -2949,25 +2993,30 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
2949
2993
|
recordedRevisionBindings.set(overlay, session);
|
|
2950
2994
|
return overlay;
|
|
2951
2995
|
}
|
|
2952
|
-
function createRecordedTransactionScope(target, schema, ownsWriteLock = false) {
|
|
2996
|
+
function createRecordedTransactionScope(target, batchPointRead, schema, ownsWriteLock = false) {
|
|
2953
2997
|
requireCaptureStatements(target);
|
|
2954
2998
|
const session = createRecordedCaptureSession();
|
|
2955
2999
|
const resolvedSchema = schema ?? requireRecordedSchema(target);
|
|
2956
3000
|
return {
|
|
2957
3001
|
backend: createRecordedTransactionBackend(target, session, resolvedSchema),
|
|
2958
3002
|
async flush() {
|
|
2959
|
-
return
|
|
2960
|
-
session.flush(target, resolvedSchema, ownsWriteLock),
|
|
3003
|
+
return chunkNLX5OWK7_cjs.withRecordedRelationsPrecondition(
|
|
3004
|
+
session.flush(target, batchPointRead, resolvedSchema, ownsWriteLock),
|
|
2961
3005
|
{ dialect: target.dialect, surface: "capture-flush" }
|
|
2962
3006
|
);
|
|
2963
3007
|
}
|
|
2964
3008
|
};
|
|
2965
3009
|
}
|
|
2966
|
-
async function runCapturedAutocommit(backend, schema, fn, options) {
|
|
3010
|
+
async function runCapturedAutocommit(backend, schema, batchPointRead, fn, options) {
|
|
2967
3011
|
assertRequestedRecordedIsolation(backend, options);
|
|
2968
3012
|
return backend.transaction(async (target) => {
|
|
2969
3013
|
await assertRecordedCaptureTransactionIsolation(target);
|
|
2970
|
-
const scope = createRecordedTransactionScope(
|
|
3014
|
+
const scope = createRecordedTransactionScope(
|
|
3015
|
+
target,
|
|
3016
|
+
batchPointRead,
|
|
3017
|
+
schema,
|
|
3018
|
+
true
|
|
3019
|
+
);
|
|
2971
3020
|
const result = await fn(scope.backend);
|
|
2972
3021
|
await scope.flush();
|
|
2973
3022
|
return result;
|
|
@@ -2975,9 +3024,10 @@ async function runCapturedAutocommit(backend, schema, fn, options) {
|
|
|
2975
3024
|
}
|
|
2976
3025
|
function createRecordedBackend(backend, schema) {
|
|
2977
3026
|
assertCapturableBackend(backend);
|
|
2978
|
-
const
|
|
2979
|
-
const
|
|
2980
|
-
|
|
3027
|
+
const batchPointRead = chunkZGVTNKTX_cjs.batchPointReadVerdict(backend);
|
|
3028
|
+
const capture = (fn) => runCapturedAutocommit(backend, schema, batchPointRead, fn);
|
|
3029
|
+
const projectedBackend = chunkNLX5OWK7_cjs.projectGraphBackend(backend);
|
|
3030
|
+
return chunkNLX5OWK7_cjs.deriveBackend(projectedBackend, {
|
|
2981
3031
|
...rawWriteGuards(backend, "backend"),
|
|
2982
3032
|
async insertNode(params) {
|
|
2983
3033
|
return capture((target) => target.insertNode(params));
|
|
@@ -3011,7 +3061,7 @@ function createRecordedBackend(backend, schema) {
|
|
|
3011
3061
|
return capture((target) => {
|
|
3012
3062
|
const updateNodeSet = target.updateNodeSet;
|
|
3013
3063
|
if (updateNodeSet === void 0) {
|
|
3014
|
-
throw new
|
|
3064
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
3015
3065
|
"Recorded updateNodeSet capability disappeared inside a transaction",
|
|
3016
3066
|
{ operation: "updateNodeSet" }
|
|
3017
3067
|
);
|
|
@@ -3080,7 +3130,12 @@ function createRecordedBackend(backend, schema) {
|
|
|
3080
3130
|
return backend.transaction(async (target) => {
|
|
3081
3131
|
await assertRecordedCaptureTransactionIsolation(target, backendOptions);
|
|
3082
3132
|
const readOnly = backendOptions?.accessMode === "read_only";
|
|
3083
|
-
const scope = createRecordedTransactionScope(
|
|
3133
|
+
const scope = createRecordedTransactionScope(
|
|
3134
|
+
target,
|
|
3135
|
+
batchPointRead,
|
|
3136
|
+
schema,
|
|
3137
|
+
!readOnly
|
|
3138
|
+
);
|
|
3084
3139
|
const result = await fn(scope.backend);
|
|
3085
3140
|
const instants = await scope.flush();
|
|
3086
3141
|
observer?.(instants);
|
|
@@ -3090,31 +3145,194 @@ function createRecordedBackend(backend, schema) {
|
|
|
3090
3145
|
});
|
|
3091
3146
|
}
|
|
3092
3147
|
|
|
3093
|
-
// src/
|
|
3094
|
-
function
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3148
|
+
// src/errors/validation.ts
|
|
3149
|
+
function zodIssuesToValidationIssues(error) {
|
|
3150
|
+
return error.issues.map((issue) => ({
|
|
3151
|
+
path: issue.path.join("."),
|
|
3152
|
+
message: issue.message,
|
|
3153
|
+
code: issue.code
|
|
3154
|
+
}));
|
|
3155
|
+
}
|
|
3156
|
+
function buildLocationString(context) {
|
|
3157
|
+
if (context.id) {
|
|
3158
|
+
return `${context.kind}/${context.id}`;
|
|
3159
|
+
}
|
|
3160
|
+
return `new ${context.kind}`;
|
|
3161
|
+
}
|
|
3162
|
+
function validateProps(schema, props, context) {
|
|
3163
|
+
const result = schema.safeParse(props);
|
|
3164
|
+
if (result.success) {
|
|
3165
|
+
return result.data;
|
|
3166
|
+
}
|
|
3167
|
+
const issues = zodIssuesToValidationIssues(result.error);
|
|
3168
|
+
const location = buildLocationString(context);
|
|
3169
|
+
throw new chunkX4GDXBOP_cjs.ValidationError(
|
|
3170
|
+
`Invalid ${context.entityType} props for ${location}: ${result.error.message}`,
|
|
3171
|
+
{
|
|
3172
|
+
entityType: context.entityType,
|
|
3173
|
+
kind: context.kind,
|
|
3174
|
+
operation: context.operation,
|
|
3175
|
+
...context.id !== void 0 && { id: context.id },
|
|
3176
|
+
issues
|
|
3177
|
+
},
|
|
3178
|
+
{ cause: result.error }
|
|
3179
|
+
);
|
|
3180
|
+
}
|
|
3181
|
+
function validateNodeProps(schema, props, context) {
|
|
3182
|
+
return validateProps(schema, props, {
|
|
3183
|
+
entityType: "node",
|
|
3184
|
+
...context
|
|
3185
|
+
});
|
|
3186
|
+
}
|
|
3187
|
+
function validateEdgeProps(schema, props, context) {
|
|
3188
|
+
return validateProps(schema, props, {
|
|
3189
|
+
entityType: "edge",
|
|
3190
|
+
...context
|
|
3191
|
+
});
|
|
3192
|
+
}
|
|
3193
|
+
function wrapZodError(error, context) {
|
|
3194
|
+
const issues = zodIssuesToValidationIssues(error);
|
|
3195
|
+
const location = buildLocationString(context);
|
|
3196
|
+
return new chunkX4GDXBOP_cjs.ValidationError(
|
|
3197
|
+
`Validation failed for ${context.entityType} ${location}: ${error.message}`,
|
|
3198
|
+
{
|
|
3199
|
+
entityType: context.entityType,
|
|
3200
|
+
kind: context.kind,
|
|
3201
|
+
operation: context.operation,
|
|
3202
|
+
...context.id !== void 0 && { id: context.id },
|
|
3203
|
+
issues
|
|
3204
|
+
},
|
|
3205
|
+
{ cause: error }
|
|
3206
|
+
);
|
|
3207
|
+
}
|
|
3208
|
+
function createValidationError(message, issues, context) {
|
|
3209
|
+
return new chunkX4GDXBOP_cjs.ValidationError(message, {
|
|
3210
|
+
...context?.entityType !== void 0 && {
|
|
3211
|
+
entityType: context.entityType
|
|
3212
|
+
},
|
|
3213
|
+
...context?.kind !== void 0 && { kind: context.kind },
|
|
3214
|
+
...context?.operation !== void 0 && { operation: context.operation },
|
|
3215
|
+
...context?.id !== void 0 && { id: context.id },
|
|
3216
|
+
issues
|
|
3217
|
+
});
|
|
3113
3218
|
}
|
|
3114
3219
|
|
|
3115
|
-
// src/
|
|
3116
|
-
|
|
3117
|
-
|
|
3220
|
+
// src/store/operations/write-transaction.ts
|
|
3221
|
+
var writeTransactionSessions = /* @__PURE__ */ new WeakMap();
|
|
3222
|
+
function forceWriteTransactionRevision(target) {
|
|
3223
|
+
const session = writeTransactionSessions.get(target);
|
|
3224
|
+
if (session === void 0) return false;
|
|
3225
|
+
session.wrote = true;
|
|
3226
|
+
return true;
|
|
3227
|
+
}
|
|
3228
|
+
var heldGraphWriteLocks = /* @__PURE__ */ new WeakMap();
|
|
3229
|
+
async function withWriteTransactionSession(target, ctx, fn) {
|
|
3230
|
+
const session = {
|
|
3231
|
+
lock: void 0,
|
|
3232
|
+
wrote: false
|
|
3233
|
+
};
|
|
3234
|
+
writeTransactionSessions.set(target, session);
|
|
3235
|
+
try {
|
|
3236
|
+
const result = await fn();
|
|
3237
|
+
if (session.wrote && ctx.revisionTrackingEnabled && !ctx.historyEnabled) {
|
|
3238
|
+
await advanceRevisionClock(target, ctx.revisionSchema, ctx.graphId, true);
|
|
3239
|
+
}
|
|
3240
|
+
return result;
|
|
3241
|
+
} finally {
|
|
3242
|
+
writeTransactionSessions.delete(target);
|
|
3243
|
+
}
|
|
3244
|
+
}
|
|
3245
|
+
async function lockSchemaVersionForStoreWrite(ctx, backend) {
|
|
3246
|
+
const expectedVersion = ctx.schemaVersion;
|
|
3247
|
+
if (expectedVersion === void 0) return;
|
|
3248
|
+
if ("transaction" in backend && !backend.capabilities.transactions) {
|
|
3249
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
3250
|
+
"Schema-managed Store writes require a transactional backend so schema changes and entity writes can share one fence.",
|
|
3251
|
+
{
|
|
3252
|
+
code: "SCHEMA_WRITE_FENCE_UNSUPPORTED",
|
|
3253
|
+
graphId: ctx.graphId
|
|
3254
|
+
}
|
|
3255
|
+
);
|
|
3256
|
+
}
|
|
3257
|
+
const lockSchemaVersionForWrite = backend.lockSchemaVersionForWrite;
|
|
3258
|
+
if (lockSchemaVersionForWrite === void 0) {
|
|
3259
|
+
throw new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
3260
|
+
"This backend cannot fence schema-managed Store writes against a concurrent schema change.",
|
|
3261
|
+
{
|
|
3262
|
+
code: "SCHEMA_WRITE_FENCE_UNSUPPORTED",
|
|
3263
|
+
graphId: ctx.graphId
|
|
3264
|
+
}
|
|
3265
|
+
);
|
|
3266
|
+
}
|
|
3267
|
+
await lockSchemaVersionForWrite({
|
|
3268
|
+
graphId: ctx.graphId,
|
|
3269
|
+
expectedVersion
|
|
3270
|
+
});
|
|
3271
|
+
}
|
|
3272
|
+
var CONSTRAINT_FENCE_ADVICE = {
|
|
3273
|
+
edgeCardinality: 'declare the edge `cardinality: "many"` and enforce the limit in application code',
|
|
3274
|
+
edgeMatchKeyConvergence: "use `create` with a caller-chosen id, whose uniqueness the edges primary key enforces, instead of `getOrCreateByEndpoints`",
|
|
3275
|
+
nodeDisjointness: "drop the `disjointWith` axiom and keep ids distinct across those kinds yourself",
|
|
3276
|
+
nodeUniquenessClaim: "drop the unique constraint \u2014 its reservation row and the node row must commit or roll back together",
|
|
3277
|
+
nodeUniquenessScope: 'scope the unique constraint to `"kind"`, which the uniques primary key enforces on its own'
|
|
3278
|
+
};
|
|
3279
|
+
function constraintFenceRefusal(ctx, backend, reason) {
|
|
3280
|
+
if (!("transaction" in backend) || backend.capabilities.transactions) {
|
|
3281
|
+
return void 0;
|
|
3282
|
+
}
|
|
3283
|
+
return new chunkX4GDXBOP_cjs.ConfigurationError(
|
|
3284
|
+
"This backend cannot fence a constrained write: enforcing a declared constraint requires a transaction \u2014 to scope the per-graph write lock to, and to commit a reservation row together with the row it gates \u2014 and this backend has no transactions.",
|
|
3285
|
+
{
|
|
3286
|
+
code: "CONSTRAINT_WRITE_FENCE_UNSUPPORTED",
|
|
3287
|
+
graphId: ctx.graphId,
|
|
3288
|
+
constraint: reason
|
|
3289
|
+
},
|
|
3290
|
+
{
|
|
3291
|
+
suggestion: `Use a transactional backend, or ${CONSTRAINT_FENCE_ADVICE[reason]}. Unconstrained writes need no fence and keep working on this backend.`
|
|
3292
|
+
}
|
|
3293
|
+
);
|
|
3294
|
+
}
|
|
3295
|
+
function runInWriteTransaction(ctx, backend, fn, options) {
|
|
3296
|
+
const ownsWriteLock = "transaction" in backend && backend.capabilities.transactions;
|
|
3297
|
+
const fenceReason = options?.fencesConstraintProbe;
|
|
3298
|
+
const refusal = fenceReason === void 0 ? void 0 : constraintFenceRefusal(ctx, backend, fenceReason);
|
|
3299
|
+
if (refusal !== void 0) return Promise.reject(refusal);
|
|
3300
|
+
const needsGraphWriteLock = ctx.historyEnabled || ctx.revisionTrackingEnabled || fenceReason !== void 0;
|
|
3301
|
+
return chunkNUQ2YFFH_cjs.runOptionallyInTransaction(backend, async (target) => {
|
|
3302
|
+
await lockSchemaVersionForStoreWrite(ctx, target);
|
|
3303
|
+
const session = needsGraphWriteLock ? writeTransactionSessions.get(target) : void 0;
|
|
3304
|
+
const held = heldGraphWriteLocks.get(target) ?? /* @__PURE__ */ new Set();
|
|
3305
|
+
heldGraphWriteLocks.set(target, held);
|
|
3306
|
+
const acquiresLock = needsGraphWriteLock && session?.lock === void 0 && !held.has(ctx.graphId);
|
|
3307
|
+
if (acquiresLock) held.add(ctx.graphId);
|
|
3308
|
+
const lock = acquiresLock ? await lockRecordedGraphWrite(target, ctx.graphId).catch(
|
|
3309
|
+
(error) => {
|
|
3310
|
+
held.delete(ctx.graphId);
|
|
3311
|
+
throw error;
|
|
3312
|
+
}
|
|
3313
|
+
) : session?.lock ?? uncapturedGraphWriteLock();
|
|
3314
|
+
if (session !== void 0) session.lock = lock;
|
|
3315
|
+
const result = await (acquiresLock ? fn(target, lock).finally(() => held.delete(ctx.graphId)) : fn(target, lock));
|
|
3316
|
+
if (session !== void 0) {
|
|
3317
|
+
session.wrote ||= options?.didWrite?.(result) ?? true;
|
|
3318
|
+
return result;
|
|
3319
|
+
}
|
|
3320
|
+
if (ctx.revisionTrackingEnabled && !ctx.historyEnabled && (options?.didWrite?.(result) ?? true)) {
|
|
3321
|
+
await advanceRevisionClock(
|
|
3322
|
+
target,
|
|
3323
|
+
ctx.revisionSchema,
|
|
3324
|
+
ctx.graphId,
|
|
3325
|
+
ownsWriteLock
|
|
3326
|
+
);
|
|
3327
|
+
}
|
|
3328
|
+
return result;
|
|
3329
|
+
});
|
|
3330
|
+
}
|
|
3331
|
+
function runHookedWriteOperation(ctx, opContext, backend, body, options) {
|
|
3332
|
+
return ctx.withOperationHooks(
|
|
3333
|
+
opContext,
|
|
3334
|
+
() => runInWriteTransaction(ctx, backend, body, options)
|
|
3335
|
+
);
|
|
3118
3336
|
}
|
|
3119
3337
|
|
|
3120
3338
|
exports.CURRENT_READ_INSTANT_PLACEHOLDER = CURRENT_READ_INSTANT_PLACEHOLDER;
|
|
@@ -3124,26 +3342,26 @@ exports.advanceRevisionClock = advanceRevisionClock;
|
|
|
3124
3342
|
exports.arrayField = arrayField;
|
|
3125
3343
|
exports.assertCurrentRecordedSchema = assertCurrentRecordedSchema;
|
|
3126
3344
|
exports.assertRecordedCaptureTransactionIsolation = assertRecordedCaptureTransactionIsolation;
|
|
3345
|
+
exports.assertRecursiveTraversalSupported = assertRecursiveTraversalSupported;
|
|
3127
3346
|
exports.assertRevisionTrackableBackend = assertRevisionTrackableBackend;
|
|
3128
3347
|
exports.baseField = baseField;
|
|
3129
3348
|
exports.buildFieldBuilderForTypeInfo = buildFieldBuilderForTypeInfo;
|
|
3130
3349
|
exports.buildPredicateIndex = buildPredicateIndex;
|
|
3131
3350
|
exports.closeRecordedHardDeletedKind = closeRecordedHardDeletedKind;
|
|
3132
|
-
exports.compareCodePoints = compareCodePoints;
|
|
3133
|
-
exports.compareStrings = compareStrings;
|
|
3134
3351
|
exports.compileFieldValue = compileFieldValue;
|
|
3135
3352
|
exports.compileKindFilter = compileKindFilter;
|
|
3136
3353
|
exports.compilePredicateClauses = compilePredicateClauses;
|
|
3137
3354
|
exports.compilePredicateExpression = compilePredicateExpression;
|
|
3138
3355
|
exports.compileTemporalFilter = compileTemporalFilter;
|
|
3356
|
+
exports.constraintFenceRefusal = constraintFenceRefusal;
|
|
3139
3357
|
exports.createFulltextAccessor = createFulltextAccessor;
|
|
3140
3358
|
exports.createRecordedBackend = createRecordedBackend;
|
|
3141
3359
|
exports.createRecordedTransactionScope = createRecordedTransactionScope;
|
|
3360
|
+
exports.createValidationError = createValidationError;
|
|
3142
3361
|
exports.currentReadInstant = currentReadInstant;
|
|
3143
3362
|
exports.currentReadInstantFor = currentReadInstantFor;
|
|
3144
3363
|
exports.dateField = dateField;
|
|
3145
3364
|
exports.edgeInsertDispatch = edgeInsertDispatch;
|
|
3146
|
-
exports.encodeTupleKey = encodeTupleKey;
|
|
3147
3365
|
exports.ensureRevisionOrigin = ensureRevisionOrigin;
|
|
3148
3366
|
exports.exists = exists;
|
|
3149
3367
|
exports.extractFulltextMatchPredicates = extractFulltextMatchPredicates;
|
|
@@ -3151,6 +3369,7 @@ exports.extractTemporalOptions = extractTemporalOptions;
|
|
|
3151
3369
|
exports.extractVectorSimilarityPredicates = extractVectorSimilarityPredicates;
|
|
3152
3370
|
exports.fieldRef = fieldRef;
|
|
3153
3371
|
exports.forceRecordedGraphRevision = forceRecordedGraphRevision;
|
|
3372
|
+
exports.forceWriteTransactionRevision = forceWriteTransactionRevision;
|
|
3154
3373
|
exports.generateId = generateId;
|
|
3155
3374
|
exports.getEdgeRowsByIds = getEdgeRowsByIds;
|
|
3156
3375
|
exports.getFieldPointer = getFieldPointer;
|
|
@@ -3167,6 +3386,7 @@ exports.identitySqlCoordinate = identitySqlCoordinate;
|
|
|
3167
3386
|
exports.inSubquery = inSubquery;
|
|
3168
3387
|
exports.isParameterRef = isParameterRef;
|
|
3169
3388
|
exports.lockRecordedGraphWrite = lockRecordedGraphWrite;
|
|
3389
|
+
exports.lockSchemaVersionForStoreWrite = lockSchemaVersionForStoreWrite;
|
|
3170
3390
|
exports.nodeInsertDispatch = nodeInsertDispatch;
|
|
3171
3391
|
exports.notExists = notExists;
|
|
3172
3392
|
exports.notInSubquery = notInSubquery;
|
|
@@ -3177,7 +3397,10 @@ exports.readRecordedClock = readRecordedClock;
|
|
|
3177
3397
|
exports.readRevisionOrigin = readRevisionOrigin;
|
|
3178
3398
|
exports.recordedBindParamBudget = recordedBindParamBudget;
|
|
3179
3399
|
exports.recordedCaptureRequiresCallbackTransactionError = recordedCaptureRequiresCallbackTransactionError;
|
|
3400
|
+
exports.requireRecursiveTraversalVerdict = requireRecursiveTraversalVerdict;
|
|
3180
3401
|
exports.resolveParameterValueType = resolveParameterValueType;
|
|
3402
|
+
exports.runHookedWriteOperation = runHookedWriteOperation;
|
|
3403
|
+
exports.runInWriteTransaction = runInWriteTransaction;
|
|
3181
3404
|
exports.runInsertBatch = runInsertBatch;
|
|
3182
3405
|
exports.runInsertBatchReturning = runInsertBatchReturning;
|
|
3183
3406
|
exports.runInsertNoReturn = runInsertNoReturn;
|
|
@@ -3185,9 +3408,13 @@ exports.sqlValueList = sqlValueList;
|
|
|
3185
3408
|
exports.stringField = stringField;
|
|
3186
3409
|
exports.throwHistoryUnsafeSqlAccess = throwHistoryUnsafeSqlAccess;
|
|
3187
3410
|
exports.throwRevisionTrackingUnsafeSqlAccess = throwRevisionTrackingUnsafeSqlAccess;
|
|
3188
|
-
exports.
|
|
3411
|
+
exports.validateEdgeProps = validateEdgeProps;
|
|
3412
|
+
exports.validateNodeProps = validateNodeProps;
|
|
3413
|
+
exports.validateProps = validateProps;
|
|
3189
3414
|
exports.withPinnedReadInstant = withPinnedReadInstant;
|
|
3190
3415
|
exports.withRecordedFlushObserver = withRecordedFlushObserver;
|
|
3191
3416
|
exports.withRecordedIdentityMutationTarget = withRecordedIdentityMutationTarget;
|
|
3192
|
-
|
|
3193
|
-
|
|
3417
|
+
exports.withWriteTransactionSession = withWriteTransactionSession;
|
|
3418
|
+
exports.wrapZodError = wrapZodError;
|
|
3419
|
+
//# sourceMappingURL=chunk-JQKMEKKW.cjs.map
|
|
3420
|
+
//# sourceMappingURL=chunk-JQKMEKKW.cjs.map
|