@nicia-ai/typegraph 0.34.0 → 0.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend/postgres/index.cjs +29 -29
- package/dist/backend/postgres/index.d.cts +39 -7
- package/dist/backend/postgres/index.d.ts +39 -7
- package/dist/backend/postgres/index.js +16 -16
- package/dist/backend/postgres/pglite.cjs +21 -21
- package/dist/backend/postgres/pglite.d.cts +4 -4
- package/dist/backend/postgres/pglite.d.ts +4 -4
- package/dist/backend/postgres/pglite.js +16 -16
- package/dist/backend/sqlite/index.cjs +25 -26
- package/dist/backend/sqlite/index.d.cts +8 -8
- package/dist/backend/sqlite/index.d.ts +8 -8
- package/dist/backend/sqlite/index.js +13 -14
- package/dist/backend/sqlite/libsql.cjs +19 -19
- package/dist/backend/sqlite/libsql.d.cts +4 -4
- package/dist/backend/sqlite/libsql.d.ts +4 -4
- package/dist/backend/sqlite/libsql.js +15 -15
- package/dist/backend/sqlite/local.cjs +101 -21
- package/dist/backend/sqlite/local.cjs.map +1 -1
- package/dist/backend/sqlite/local.d.cts +95 -5
- package/dist/backend/sqlite/local.d.ts +95 -5
- package/dist/backend/sqlite/local.js +95 -16
- package/dist/backend/sqlite/local.js.map +1 -1
- package/dist/{chunk-T6SPUYLX.cjs → chunk-2THZ3TQI.cjs} +116 -10
- package/dist/chunk-2THZ3TQI.cjs.map +1 -0
- package/dist/{chunk-UJLOZYKT.cjs → chunk-456Z2U7Y.cjs} +441 -115
- package/dist/chunk-456Z2U7Y.cjs.map +1 -0
- package/dist/chunk-4BCU6VFZ.cjs +100 -0
- package/dist/chunk-4BCU6VFZ.cjs.map +1 -0
- package/dist/chunk-4BMPGT35.cjs +12 -0
- package/dist/{chunk-HMFK4BXR.cjs.map → chunk-4BMPGT35.cjs.map} +1 -1
- package/dist/chunk-4CAXEB2F.cjs +1366 -0
- package/dist/chunk-4CAXEB2F.cjs.map +1 -0
- package/dist/{chunk-RY2VIWAM.js → chunk-4GX2JJXS.js} +355 -32
- package/dist/chunk-4GX2JJXS.js.map +1 -0
- package/dist/{chunk-GQANNXXT.cjs → chunk-5A6FNS6N.cjs} +75 -20
- package/dist/chunk-5A6FNS6N.cjs.map +1 -0
- package/dist/{chunk-3Z6TW3CT.cjs → chunk-5AQIKK56.cjs} +65 -25
- package/dist/chunk-5AQIKK56.cjs.map +1 -0
- package/dist/{chunk-WLRIWYHQ.js → chunk-5DIPR3L3.js} +2145 -1937
- package/dist/chunk-5DIPR3L3.js.map +1 -0
- package/dist/{chunk-BVTWD66D.js → chunk-5SEGFTZX.js} +3 -3
- package/dist/{chunk-BVTWD66D.js.map → chunk-5SEGFTZX.js.map} +1 -1
- package/dist/{chunk-A7SZZFAG.js → chunk-5VTR2F2K.js} +452 -109
- package/dist/chunk-5VTR2F2K.js.map +1 -0
- package/dist/{chunk-JJRCLAUN.cjs → chunk-5W4L6DLF.cjs} +116 -10
- package/dist/chunk-5W4L6DLF.cjs.map +1 -0
- package/dist/{chunk-6GNSY7AV.js → chunk-6FR2MMS6.js} +7 -7
- package/dist/chunk-6FR2MMS6.js.map +1 -0
- package/dist/{chunk-3BRVBQQD.cjs → chunk-7BQLPXK6.cjs} +2648 -2440
- package/dist/chunk-7BQLPXK6.cjs.map +1 -0
- package/dist/chunk-7YSP4V4R.cjs +69 -0
- package/dist/chunk-7YSP4V4R.cjs.map +1 -0
- package/dist/chunk-A42GCBGX.cjs +28 -0
- package/dist/chunk-A42GCBGX.cjs.map +1 -0
- package/dist/{chunk-ZV5N4DBG.js → chunk-BJVEU3ZL.js} +300 -58
- package/dist/chunk-BJVEU3ZL.js.map +1 -0
- package/dist/chunk-BYPOGQWK.js +25 -0
- package/dist/chunk-BYPOGQWK.js.map +1 -0
- package/dist/chunk-CUHM5CWJ.cjs +12 -0
- package/dist/chunk-CUHM5CWJ.cjs.map +1 -0
- package/dist/{chunk-2JXB3NYJ.cjs → chunk-D7ZEOS56.cjs} +25 -32
- package/dist/chunk-D7ZEOS56.cjs.map +1 -0
- package/dist/chunk-DFVLCOP6.js +10 -0
- package/dist/chunk-DFVLCOP6.js.map +1 -0
- package/dist/{chunk-JIEJCTDS.cjs → chunk-DIK74MXX.cjs} +37 -4
- package/dist/chunk-DIK74MXX.cjs.map +1 -0
- package/dist/chunk-DN5VP4JC.js +1343 -0
- package/dist/chunk-DN5VP4JC.js.map +1 -0
- package/dist/chunk-EOLERH7Y.cjs +40 -0
- package/dist/chunk-EOLERH7Y.cjs.map +1 -0
- package/dist/{chunk-TGJE22RM.cjs → chunk-FACJJWGF.cjs} +24 -6
- package/dist/chunk-FACJJWGF.cjs.map +1 -0
- package/dist/{chunk-WVC2Q2FD.cjs → chunk-FN35DLCN.cjs} +31 -9
- package/dist/chunk-FN35DLCN.cjs.map +1 -0
- package/dist/{chunk-KUTNI6SI.js → chunk-FPIZFYHE.js} +10 -18
- package/dist/chunk-FPIZFYHE.js.map +1 -0
- package/dist/{chunk-VCGO4V26.js → chunk-FRV5Q5IO.js} +64 -9
- package/dist/chunk-FRV5Q5IO.js.map +1 -0
- package/dist/{chunk-K5P5OZXS.js → chunk-G6Q5UM7U.js} +2 -2
- package/dist/{chunk-K5P5OZXS.js.map → chunk-G6Q5UM7U.js.map} +1 -1
- package/dist/{chunk-JQGIPGVL.cjs → chunk-H7YNSMA7.cjs} +43 -2
- package/dist/chunk-H7YNSMA7.cjs.map +1 -0
- package/dist/chunk-HW3LW7DH.cjs +1271 -0
- package/dist/chunk-HW3LW7DH.cjs.map +1 -0
- package/dist/{chunk-V3QNTB7Z.js → chunk-IU46OHVW.js} +194 -114
- package/dist/chunk-IU46OHVW.js.map +1 -0
- package/dist/{chunk-HK5SATYM.cjs → chunk-J3LEGNQB.cjs} +16 -109
- package/dist/chunk-J3LEGNQB.cjs.map +1 -0
- package/dist/{chunk-ZP5WHI4C.cjs → chunk-JFMEONLG.cjs} +358 -116
- package/dist/chunk-JFMEONLG.cjs.map +1 -0
- package/dist/{chunk-2MRAX3UE.js → chunk-JFUPDJXD.js} +47 -4
- package/dist/chunk-JFUPDJXD.js.map +1 -0
- package/dist/{chunk-Z5XBMDXU.js → chunk-KBGQIPRQ.js} +42 -3
- package/dist/chunk-KBGQIPRQ.js.map +1 -0
- package/dist/{chunk-K2TGS3EN.js → chunk-M75SUBFG.js} +138 -89
- package/dist/chunk-M75SUBFG.js.map +1 -0
- package/dist/chunk-OHMP6N2J.js +47 -0
- package/dist/chunk-OHMP6N2J.js.map +1 -0
- package/dist/{chunk-4DIBPQNJ.js → chunk-OR5ZA5WP.js} +135 -25
- package/dist/chunk-OR5ZA5WP.js.map +1 -0
- package/dist/{chunk-6HVOHZHS.cjs → chunk-PWGX5DF5.cjs} +213 -168
- package/dist/chunk-PWGX5DF5.cjs.map +1 -0
- package/dist/chunk-PZKNKG5M.js +1252 -0
- package/dist/chunk-PZKNKG5M.js.map +1 -0
- package/dist/{chunk-DEQFL35G.js → chunk-Q5TEXCTB.js} +61 -7
- package/dist/chunk-Q5TEXCTB.js.map +1 -0
- package/dist/{chunk-QV245VMN.js → chunk-RAXU3RMB.js} +100 -6
- package/dist/chunk-RAXU3RMB.js.map +1 -0
- package/dist/{chunk-RHZWOJVA.cjs → chunk-RSSQKPSZ.cjs} +52 -4
- package/dist/chunk-RSSQKPSZ.cjs.map +1 -0
- package/dist/{chunk-G6SOJEDI.cjs → chunk-S55OV6PW.cjs} +15 -15
- package/dist/chunk-S55OV6PW.cjs.map +1 -0
- package/dist/chunk-S5F7ZLP2.js +94 -0
- package/dist/chunk-S5F7ZLP2.js.map +1 -0
- package/dist/{chunk-3E7SNSIA.cjs → chunk-SJDMVITW.cjs} +4 -4
- package/dist/{chunk-3E7SNSIA.cjs.map → chunk-SJDMVITW.cjs.map} +1 -1
- package/dist/{chunk-CHXTTSC6.js → chunk-SKCOUWAX.js} +104 -5
- package/dist/chunk-SKCOUWAX.js.map +1 -0
- package/dist/{chunk-XLUNB2TZ.js → chunk-SNXVDZAJ.js} +3 -3
- package/dist/{chunk-XLUNB2TZ.js.map → chunk-SNXVDZAJ.js.map} +1 -1
- package/dist/{chunk-ZURTTSCM.js → chunk-SXGE7ITL.js} +6 -94
- package/dist/chunk-SXGE7ITL.js.map +1 -0
- package/dist/{chunk-RBV7YCQD.js → chunk-T2WUSPDA.js} +49 -9
- package/dist/chunk-T2WUSPDA.js.map +1 -0
- package/dist/{chunk-KGC4LY5T.cjs → chunk-TCOCYN2P.cjs} +75 -21
- package/dist/chunk-TCOCYN2P.cjs.map +1 -0
- package/dist/{chunk-FLRCVI2G.cjs → chunk-TDXIBCGY.cjs} +2 -2
- package/dist/{chunk-FLRCVI2G.cjs.map → chunk-TDXIBCGY.cjs.map} +1 -1
- package/dist/{chunk-ZY4GXIVN.cjs → chunk-TEDRJXOG.cjs} +5 -5
- package/dist/{chunk-ZY4GXIVN.cjs.map → chunk-TEDRJXOG.cjs.map} +1 -1
- package/dist/{chunk-WL2SG7ZV.cjs → chunk-UMDVATGY.cjs} +6 -6
- package/dist/{chunk-WL2SG7ZV.cjs.map → chunk-UMDVATGY.cjs.map} +1 -1
- package/dist/chunk-UT3S4SEN.js +31 -0
- package/dist/chunk-UT3S4SEN.js.map +1 -0
- package/dist/{chunk-RRKQAKD6.cjs → chunk-UUT7UN2N.cjs} +149 -39
- package/dist/chunk-UUT7UN2N.cjs.map +1 -0
- package/dist/{chunk-SHLY4MCM.js → chunk-UZV3AZKF.js} +21 -3
- package/dist/chunk-UZV3AZKF.js.map +1 -0
- package/dist/{chunk-CYX2JTDG.js → chunk-VHMPG6UL.js} +29 -7
- package/dist/chunk-VHMPG6UL.js.map +1 -0
- package/dist/{chunk-LANHCOXB.js → chunk-VQEXF5D4.js} +485 -83
- package/dist/chunk-VQEXF5D4.js.map +1 -0
- package/dist/{chunk-K34OPSJK.js → chunk-W63OVYY4.js} +3 -3
- package/dist/{chunk-K34OPSJK.js.map → chunk-W63OVYY4.js.map} +1 -1
- package/dist/{chunk-TQOYM4LN.js → chunk-WI7ISNQF.js} +35 -5
- package/dist/chunk-WI7ISNQF.js.map +1 -0
- package/dist/{chunk-UNNPKQUG.cjs → chunk-X4JBT642.cjs} +246 -155
- package/dist/chunk-X4JBT642.cjs.map +1 -0
- package/dist/chunk-ZAMFOJ5P.cjs +1176 -0
- package/dist/chunk-ZAMFOJ5P.cjs.map +1 -0
- package/dist/{chunk-T46GR2VY.js → chunk-ZIGXMKQQ.js} +3 -3
- package/dist/{chunk-T46GR2VY.js.map → chunk-ZIGXMKQQ.js.map} +1 -1
- package/dist/{chunk-5IQIX7LU.cjs → chunk-ZUNQ5BEP.cjs} +518 -172
- package/dist/chunk-ZUNQ5BEP.cjs.map +1 -0
- package/dist/{ddl-BrmPg61z.d.ts → ddl-C2rZ-Aen.d.ts} +4 -4
- package/dist/{ddl-j1-sH6lE.d.cts → ddl-CZz7a0E8.d.cts} +4 -4
- package/dist/{extension-types-YGFJPrzK.d.cts → extension-types-ixRpJVUp.d.cts} +24 -1
- package/dist/{extension-types-YGFJPrzK.d.ts → extension-types-ixRpJVUp.d.ts} +24 -1
- package/dist/{types-DkNnF-7K.d.cts → fulltext-strategy-B57yvC5Q.d.ts} +2562 -2133
- package/dist/{types-D1Sqeyxy.d.ts → fulltext-strategy-CDkSSYhq.d.cts} +2562 -2133
- package/dist/graph-extension/index.cjs +20 -19
- package/dist/graph-extension/index.d.cts +4 -4
- package/dist/graph-extension/index.d.ts +4 -4
- package/dist/graph-extension/index.js +5 -4
- package/dist/graph-merge/index.cjs +255 -164
- package/dist/graph-merge/index.cjs.map +1 -1
- package/dist/graph-merge/index.d.cts +63 -33
- package/dist/graph-merge/index.d.ts +63 -33
- package/dist/graph-merge/index.js +135 -44
- package/dist/graph-merge/index.js.map +1 -1
- package/dist/{index-DGX6D9j1.d.ts → index-BFvdmBPV.d.ts} +301 -93
- package/dist/{index-SEvUHDA6.d.cts → index-BLtQWKRj.d.cts} +301 -93
- package/dist/index.cjs +216 -188
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +33 -33
- package/dist/indexes/index.cjs +19 -20
- package/dist/indexes/index.d.cts +5 -5
- package/dist/indexes/index.d.ts +5 -5
- package/dist/indexes/index.js +10 -11
- package/dist/interchange/index.cjs +48 -26
- package/dist/interchange/index.d.cts +126 -12
- package/dist/interchange/index.d.ts +126 -12
- package/dist/interchange/index.js +15 -13
- package/dist/{manager-ms9cKdc6.d.cts → manager-DwQi8eV0.d.cts} +9 -2
- package/dist/{manager-BZUeN_BU.d.ts → manager-ejUCB52T.d.ts} +9 -2
- package/dist/{materialize-indexes-D20xNluI.d.cts → materialize-indexes-B4e9360H.d.cts} +20 -4
- package/dist/{materialize-indexes-CAkIYFV-.d.ts → materialize-indexes-te9TPMMJ.d.ts} +20 -4
- package/dist/{postgres-BhpxGMC5.d.cts → postgres-CfEqsRMp.d.cts} +152 -1
- package/dist/{postgres-CWHLwNl1.d.ts → postgres-DQ5R6rzV.d.ts} +152 -1
- package/dist/profiler/index.cjs +11 -11
- package/dist/profiler/index.d.cts +7 -7
- package/dist/profiler/index.d.ts +7 -7
- package/dist/profiler/index.js +4 -4
- package/dist/provenance/index.cjs +40 -41
- package/dist/provenance/index.cjs.map +1 -1
- package/dist/provenance/index.d.cts +5 -5
- package/dist/provenance/index.d.ts +5 -5
- package/dist/provenance/index.js +11 -12
- package/dist/provenance/index.js.map +1 -1
- package/dist/schema/index.cjs +53 -40
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +57 -57
- package/dist/schema/index.d.ts +57 -57
- package/dist/schema/index.js +28 -15
- package/dist/schema/index.js.map +1 -1
- package/dist/{sqlite-XrDxNaa7.d.cts → sqlite-D7zBinNR.d.cts} +92 -1
- package/dist/{sqlite-CGu5SLsw.d.ts → sqlite-DvQndLky.d.ts} +92 -1
- package/dist/{store-view-D09po4H6.d.cts → store-view-9KDOpZzF.d.cts} +643 -58
- package/dist/{store-view-BlgnhEYf.d.ts → store-view-DplHC3Nt.d.ts} +643 -58
- package/dist/{types-DiE1AO7p.d.cts → types-Bv9DcS_E.d.cts} +2 -2
- package/dist/{types-B1TbZJYS.d.ts → types-CoxuV7EJ.d.ts} +2 -2
- package/dist/{where-DKjuofPr.d.cts → where-7RKFOsXt.d.ts} +2 -2
- package/dist/{where-DrUIIWHb.d.ts → where-DdMIXOtH.d.cts} +2 -2
- package/package.json +14 -13
- package/dist/chunk-2EBMPJBO.js +0 -16
- package/dist/chunk-2EBMPJBO.js.map +0 -1
- package/dist/chunk-2JXB3NYJ.cjs.map +0 -1
- package/dist/chunk-2MRAX3UE.js.map +0 -1
- package/dist/chunk-3BRVBQQD.cjs.map +0 -1
- package/dist/chunk-3EUKJEQ3.js +0 -77
- package/dist/chunk-3EUKJEQ3.js.map +0 -1
- package/dist/chunk-3Z6TW3CT.cjs.map +0 -1
- package/dist/chunk-4DIBPQNJ.js.map +0 -1
- package/dist/chunk-4S2FXGBJ.js +0 -9
- package/dist/chunk-4S2FXGBJ.js.map +0 -1
- package/dist/chunk-5IQIX7LU.cjs.map +0 -1
- package/dist/chunk-6GNSY7AV.js.map +0 -1
- package/dist/chunk-6HVOHZHS.cjs.map +0 -1
- package/dist/chunk-6SCVW4AS.js +0 -20
- package/dist/chunk-6SCVW4AS.js.map +0 -1
- package/dist/chunk-A7SZZFAG.js.map +0 -1
- package/dist/chunk-CHXTTSC6.js.map +0 -1
- package/dist/chunk-CYX2JTDG.js.map +0 -1
- package/dist/chunk-DEQFL35G.js.map +0 -1
- package/dist/chunk-G6SOJEDI.cjs.map +0 -1
- package/dist/chunk-GQANNXXT.cjs.map +0 -1
- package/dist/chunk-GZCNZ7QW.js +0 -24
- package/dist/chunk-GZCNZ7QW.js.map +0 -1
- package/dist/chunk-HK5SATYM.cjs.map +0 -1
- package/dist/chunk-HMFK4BXR.cjs +0 -12
- package/dist/chunk-HTGDWIDE.cjs +0 -89
- package/dist/chunk-HTGDWIDE.cjs.map +0 -1
- package/dist/chunk-JIEJCTDS.cjs.map +0 -1
- package/dist/chunk-JJRCLAUN.cjs.map +0 -1
- package/dist/chunk-JQGIPGVL.cjs.map +0 -1
- package/dist/chunk-K2TGS3EN.js.map +0 -1
- package/dist/chunk-KGC4LY5T.cjs.map +0 -1
- package/dist/chunk-KNHYNQQ3.cjs +0 -663
- package/dist/chunk-KNHYNQQ3.cjs.map +0 -1
- package/dist/chunk-KUTNI6SI.js.map +0 -1
- package/dist/chunk-LANHCOXB.js.map +0 -1
- package/dist/chunk-N6WTUSBV.cjs +0 -23
- package/dist/chunk-N6WTUSBV.cjs.map +0 -1
- package/dist/chunk-NAUA4PW5.cjs +0 -28
- package/dist/chunk-NAUA4PW5.cjs.map +0 -1
- package/dist/chunk-QV245VMN.js.map +0 -1
- package/dist/chunk-RBV7YCQD.js.map +0 -1
- package/dist/chunk-RHZWOJVA.cjs.map +0 -1
- package/dist/chunk-RRKQAKD6.cjs.map +0 -1
- package/dist/chunk-RY2VIWAM.js.map +0 -1
- package/dist/chunk-SHLY4MCM.js.map +0 -1
- package/dist/chunk-T2DWPQNE.js +0 -649
- package/dist/chunk-T2DWPQNE.js.map +0 -1
- package/dist/chunk-T6SPUYLX.cjs.map +0 -1
- package/dist/chunk-TGJE22RM.cjs.map +0 -1
- package/dist/chunk-TOTPVGOG.cjs +0 -774
- package/dist/chunk-TOTPVGOG.cjs.map +0 -1
- package/dist/chunk-TQOYM4LN.js.map +0 -1
- package/dist/chunk-UJLOZYKT.cjs.map +0 -1
- package/dist/chunk-UNNPKQUG.cjs.map +0 -1
- package/dist/chunk-V3QNTB7Z.js.map +0 -1
- package/dist/chunk-VCGO4V26.js.map +0 -1
- package/dist/chunk-WLRIWYHQ.js.map +0 -1
- package/dist/chunk-WVC2Q2FD.cjs.map +0 -1
- package/dist/chunk-XXVEULWX.js +0 -39
- package/dist/chunk-XXVEULWX.js.map +0 -1
- package/dist/chunk-YAZE7QZR.cjs +0 -32
- package/dist/chunk-YAZE7QZR.cjs.map +0 -1
- package/dist/chunk-YC6PWTHY.cjs +0 -44
- package/dist/chunk-YC6PWTHY.cjs.map +0 -1
- package/dist/chunk-Z5HBYM7U.cjs +0 -11
- package/dist/chunk-Z5HBYM7U.cjs.map +0 -1
- package/dist/chunk-Z5XBMDXU.js.map +0 -1
- package/dist/chunk-ZP5WHI4C.cjs.map +0 -1
- package/dist/chunk-ZURTTSCM.js.map +0 -1
- package/dist/chunk-ZV5N4DBG.js.map +0 -1
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var chunkJIEJCTDS_cjs = require('./chunk-JIEJCTDS.cjs');
|
|
3
|
+
var chunkEOLERH7Y_cjs = require('./chunk-EOLERH7Y.cjs');
|
|
4
|
+
var chunkX4JBT642_cjs = require('./chunk-X4JBT642.cjs');
|
|
5
|
+
var chunkRSSQKPSZ_cjs = require('./chunk-RSSQKPSZ.cjs');
|
|
6
|
+
var chunk7YSP4V4R_cjs = require('./chunk-7YSP4V4R.cjs');
|
|
7
|
+
var chunkH7YNSMA7_cjs = require('./chunk-H7YNSMA7.cjs');
|
|
8
|
+
var chunkDIK74MXX_cjs = require('./chunk-DIK74MXX.cjs');
|
|
10
9
|
var drizzleOrm = require('drizzle-orm');
|
|
11
10
|
var nanoid = require('nanoid');
|
|
12
11
|
|
|
13
12
|
// src/core/temporal.ts
|
|
14
13
|
var RECORDED_MAX = "9999-12-31T23:59:59.999Z";
|
|
15
14
|
function assertValidRecordedInstant(value, path) {
|
|
16
|
-
|
|
15
|
+
chunkRSSQKPSZ_cjs.validateCanonicalIsoDate(value, path);
|
|
17
16
|
if (value >= RECORDED_MAX) {
|
|
18
|
-
throw new
|
|
17
|
+
throw new chunkDIK74MXX_cjs.ValidationError(
|
|
19
18
|
`${path} must be before the recorded-time open sentinel ${RECORDED_MAX}.`,
|
|
20
19
|
{
|
|
21
20
|
issues: [
|
|
@@ -37,7 +36,7 @@ function asRecordedInstant(value) {
|
|
|
37
36
|
}
|
|
38
37
|
function resolveReadCoordinate(mode, asOf, suggestion) {
|
|
39
38
|
if (mode !== "asOf" && asOf !== void 0) {
|
|
40
|
-
throw new
|
|
39
|
+
throw new chunkDIK74MXX_cjs.ValidationError(
|
|
41
40
|
`Temporal mode "${mode}" does not take an asOf timestamp.`,
|
|
42
41
|
{
|
|
43
42
|
issues: [
|
|
@@ -68,7 +67,7 @@ function withRecordedCoordinate(coordinate, recordedAsOf) {
|
|
|
68
67
|
}
|
|
69
68
|
function assertValidAsOf(mode, asOf, options) {
|
|
70
69
|
if (mode === "asOf" && asOf === void 0) {
|
|
71
|
-
throw new
|
|
70
|
+
throw new chunkDIK74MXX_cjs.ValidationError(
|
|
72
71
|
'Temporal mode "asOf" requires a timestamp',
|
|
73
72
|
{
|
|
74
73
|
issues: [
|
|
@@ -81,7 +80,7 @@ function assertValidAsOf(mode, asOf, options) {
|
|
|
81
80
|
);
|
|
82
81
|
}
|
|
83
82
|
if (asOf !== void 0) {
|
|
84
|
-
|
|
83
|
+
chunkRSSQKPSZ_cjs.validateCanonicalIsoDate(asOf, "asOf");
|
|
85
84
|
}
|
|
86
85
|
}
|
|
87
86
|
function describeCoordinate(coordinate) {
|
|
@@ -97,17 +96,6 @@ function coordinateContext(coordinate) {
|
|
|
97
96
|
...coordinate.recorded === void 0 ? {} : { recordedAsOf: coordinate.recorded.asOf }
|
|
98
97
|
};
|
|
99
98
|
}
|
|
100
|
-
|
|
101
|
-
// src/query/sql-intent.ts
|
|
102
|
-
function asCompiledRowsSql(query) {
|
|
103
|
-
return query;
|
|
104
|
-
}
|
|
105
|
-
function asCompiledSelectSql(query) {
|
|
106
|
-
return asCompiledRowsSql(query);
|
|
107
|
-
}
|
|
108
|
-
function asCompiledStatementSql(query) {
|
|
109
|
-
return query;
|
|
110
|
-
}
|
|
111
99
|
var SqlSchemaDescriptor = class {
|
|
112
100
|
// Private field gives SqlSchema nominal identity; runtime checks use instanceof.
|
|
113
101
|
#brand = true;
|
|
@@ -117,6 +105,7 @@ var SqlSchemaDescriptor = class {
|
|
|
117
105
|
recordedNodesTable;
|
|
118
106
|
recordedEdgesTable;
|
|
119
107
|
recordedClockTable;
|
|
108
|
+
revisionOriginsTable;
|
|
120
109
|
fulltextTable;
|
|
121
110
|
constructor(fields) {
|
|
122
111
|
this.tables = fields.tables;
|
|
@@ -125,6 +114,7 @@ var SqlSchemaDescriptor = class {
|
|
|
125
114
|
this.recordedNodesTable = fields.recordedNodesTable;
|
|
126
115
|
this.recordedEdgesTable = fields.recordedEdgesTable;
|
|
127
116
|
this.recordedClockTable = fields.recordedClockTable;
|
|
117
|
+
this.revisionOriginsTable = fields.revisionOriginsTable;
|
|
128
118
|
this.fulltextTable = fields.fulltextTable;
|
|
129
119
|
void this.#brand;
|
|
130
120
|
Object.freeze(this);
|
|
@@ -136,6 +126,7 @@ var DEFAULT_TABLE_NAMES = {
|
|
|
136
126
|
recordedNodes: "typegraph_recorded_nodes",
|
|
137
127
|
recordedEdges: "typegraph_recorded_edges",
|
|
138
128
|
recordedClock: "typegraph_recorded_clock",
|
|
129
|
+
revisionOrigins: "typegraph_revision_origins",
|
|
139
130
|
fulltext: "typegraph_node_fulltext",
|
|
140
131
|
uniques: "typegraph_node_uniques"
|
|
141
132
|
};
|
|
@@ -146,6 +137,7 @@ function resolveTableNames(names) {
|
|
|
146
137
|
recordedNodes: names.recordedNodes ?? DEFAULT_TABLE_NAMES.recordedNodes,
|
|
147
138
|
recordedEdges: names.recordedEdges ?? DEFAULT_TABLE_NAMES.recordedEdges,
|
|
148
139
|
recordedClock: names.recordedClock ?? DEFAULT_TABLE_NAMES.recordedClock,
|
|
140
|
+
revisionOrigins: names.revisionOrigins ?? DEFAULT_TABLE_NAMES.revisionOrigins,
|
|
149
141
|
fulltext: names.fulltext ?? DEFAULT_TABLE_NAMES.fulltext,
|
|
150
142
|
uniques: names.uniques ?? DEFAULT_TABLE_NAMES.uniques
|
|
151
143
|
};
|
|
@@ -153,15 +145,15 @@ function resolveTableNames(names) {
|
|
|
153
145
|
var VALID_IDENTIFIER_PATTERN = /^[a-z_][a-z0-9_$]*$/i;
|
|
154
146
|
function validateTableName(name, label) {
|
|
155
147
|
if (!name || name.length === 0) {
|
|
156
|
-
throw new
|
|
148
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(`${label} table name cannot be empty`);
|
|
157
149
|
}
|
|
158
|
-
if (name.length >
|
|
159
|
-
throw new
|
|
160
|
-
`${label} table name exceeds maximum length of ${
|
|
150
|
+
if (name.length > chunk7YSP4V4R_cjs.MAX_PG_IDENTIFIER_LENGTH) {
|
|
151
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
152
|
+
`${label} table name exceeds maximum length of ${chunk7YSP4V4R_cjs.MAX_PG_IDENTIFIER_LENGTH} characters`
|
|
161
153
|
);
|
|
162
154
|
}
|
|
163
155
|
if (!VALID_IDENTIFIER_PATTERN.test(name)) {
|
|
164
|
-
throw new
|
|
156
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
165
157
|
`${label} table name "${name}" is not a valid SQL identifier. Table names must start with a letter or underscore and contain only letters, digits, underscores, or dollar signs.`
|
|
166
158
|
);
|
|
167
159
|
}
|
|
@@ -177,7 +169,7 @@ function isSqlSchema(schema) {
|
|
|
177
169
|
}
|
|
178
170
|
function requireSqlSchema(schema, surface = "SqlSchema") {
|
|
179
171
|
if (isSqlSchema(schema)) return schema;
|
|
180
|
-
throw new
|
|
172
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
181
173
|
`${surface} must be created with createSqlSchema(...).`,
|
|
182
174
|
{ code: "INVALID_SQL_SCHEMA", surface },
|
|
183
175
|
{
|
|
@@ -192,6 +184,7 @@ function createSqlSchema(names = {}) {
|
|
|
192
184
|
validateTableName(tables.recordedNodes, "recordedNodes");
|
|
193
185
|
validateTableName(tables.recordedEdges, "recordedEdges");
|
|
194
186
|
validateTableName(tables.recordedClock, "recordedClock");
|
|
187
|
+
validateTableName(tables.revisionOrigins, "revisionOrigins");
|
|
195
188
|
validateTableName(tables.fulltext, "fulltext");
|
|
196
189
|
validateTableName(tables.uniques, "uniques");
|
|
197
190
|
return freezeSqlSchema({
|
|
@@ -201,6 +194,7 @@ function createSqlSchema(names = {}) {
|
|
|
201
194
|
recordedNodesTable: drizzleOrm.sql.raw(quoteIdentifier(tables.recordedNodes)),
|
|
202
195
|
recordedEdgesTable: drizzleOrm.sql.raw(quoteIdentifier(tables.recordedEdges)),
|
|
203
196
|
recordedClockTable: drizzleOrm.sql.raw(quoteIdentifier(tables.recordedClock)),
|
|
197
|
+
revisionOriginsTable: drizzleOrm.sql.raw(quoteIdentifier(tables.revisionOrigins)),
|
|
204
198
|
fulltextTable: drizzleOrm.sql.raw(quoteIdentifier(tables.fulltext))
|
|
205
199
|
});
|
|
206
200
|
}
|
|
@@ -221,7 +215,7 @@ function recordedRelation(options) {
|
|
|
221
215
|
function requireExternalRecordedReadSource(source) {
|
|
222
216
|
if (source === void 0) return void 0;
|
|
223
217
|
if (isExternalRecordedReadSource(source)) return source;
|
|
224
|
-
throw new
|
|
218
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
225
219
|
"recordedRead must be created with recordedRelation({ schema }).",
|
|
226
220
|
{ code: "INVALID_RECORDED_READ_SOURCE" },
|
|
227
221
|
{
|
|
@@ -245,7 +239,7 @@ function createRecordedReadBinding(schema) {
|
|
|
245
239
|
function requireRecordedReadBinding(binding, surface) {
|
|
246
240
|
if (isRecordedReadBinding(binding)) return binding;
|
|
247
241
|
if (binding !== void 0) {
|
|
248
|
-
throw new
|
|
242
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
249
243
|
"Recorded-time reads require a recorded read relation created by TypeGraph.",
|
|
250
244
|
{ code: "INVALID_RECORDED_READ_BINDING", surface },
|
|
251
245
|
{
|
|
@@ -253,7 +247,7 @@ function requireRecordedReadBinding(binding, surface) {
|
|
|
253
247
|
}
|
|
254
248
|
);
|
|
255
249
|
}
|
|
256
|
-
throw new
|
|
250
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
257
251
|
"Recorded-time reads require a recorded read relation.",
|
|
258
252
|
{ code: "RECORDED_READ_REQUIRES_BINDING", surface },
|
|
259
253
|
{
|
|
@@ -281,6 +275,7 @@ function recordedReadSqlSchema(binding) {
|
|
|
281
275
|
recordedNodesTable: schema.recordedNodesTable,
|
|
282
276
|
recordedEdgesTable: schema.recordedEdgesTable,
|
|
283
277
|
recordedClockTable: schema.recordedClockTable,
|
|
278
|
+
revisionOriginsTable: schema.revisionOriginsTable,
|
|
284
279
|
fulltextTable: schema.fulltextTable
|
|
285
280
|
});
|
|
286
281
|
}
|
|
@@ -302,7 +297,7 @@ function generateId() {
|
|
|
302
297
|
}
|
|
303
298
|
function requireRecordedSchema(target) {
|
|
304
299
|
if (target.tableNames === void 0) {
|
|
305
|
-
throw new
|
|
300
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
306
301
|
"Recorded-time capture requires the backend to expose tableNames.",
|
|
307
302
|
{ dialect: target.dialect },
|
|
308
303
|
{
|
|
@@ -314,7 +309,7 @@ function requireRecordedSchema(target) {
|
|
|
314
309
|
}
|
|
315
310
|
function requireCaptureStatements(target) {
|
|
316
311
|
if (target.executeStatement === void 0) {
|
|
317
|
-
throw new
|
|
312
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
318
313
|
"Recorded-time capture requires backend.executeStatement support on the transaction backend.",
|
|
319
314
|
{ dialect: target.dialect },
|
|
320
315
|
{
|
|
@@ -325,10 +320,10 @@ function requireCaptureStatements(target) {
|
|
|
325
320
|
}
|
|
326
321
|
async function executeStatement(target, query) {
|
|
327
322
|
requireCaptureStatements(target);
|
|
328
|
-
await target.executeStatement(asCompiledStatementSql(query));
|
|
323
|
+
await target.executeStatement(chunkEOLERH7Y_cjs.asCompiledStatementSql(query));
|
|
329
324
|
}
|
|
330
325
|
function unsupportedPostgresIsolationError(isolationLevel) {
|
|
331
|
-
return new
|
|
326
|
+
return new chunkDIK74MXX_cjs.ConfigurationError(
|
|
332
327
|
"Recorded-time capture on PostgreSQL requires read_committed isolation.",
|
|
333
328
|
{ isolationLevel: isolationLevel ?? "unknown" },
|
|
334
329
|
{
|
|
@@ -352,7 +347,7 @@ function normalizeIsolationLevel(value) {
|
|
|
352
347
|
async function assertRecordedCaptureTransactionIsolation(target) {
|
|
353
348
|
if (target.dialect !== "postgres") return;
|
|
354
349
|
const rows = await target.execute(
|
|
355
|
-
asCompiledRowsSql(drizzleOrm.sql`
|
|
350
|
+
chunkEOLERH7Y_cjs.asCompiledRowsSql(drizzleOrm.sql`
|
|
356
351
|
SELECT current_setting('transaction_isolation') AS transaction_isolation
|
|
357
352
|
`)
|
|
358
353
|
);
|
|
@@ -362,62 +357,87 @@ async function assertRecordedCaptureTransactionIsolation(target) {
|
|
|
362
357
|
if (isSupportedRecordedIsolationLevel(isolationLevel)) return;
|
|
363
358
|
throw unsupportedPostgresIsolationError(isolationLevel);
|
|
364
359
|
}
|
|
365
|
-
function recordedCaptureRequiresCallbackTransactionError(details) {
|
|
366
|
-
return new
|
|
360
|
+
function recordedCaptureRequiresCallbackTransactionError(details = {}) {
|
|
361
|
+
return new chunkDIK74MXX_cjs.ConfigurationError(
|
|
367
362
|
"withTransaction() has no recorded-time capture flush point when history is enabled.",
|
|
368
|
-
|
|
363
|
+
{
|
|
364
|
+
...details,
|
|
365
|
+
code: "RECORDED_CAPTURE_REQUIRES_CALLBACK_TRANSACTION"
|
|
366
|
+
},
|
|
369
367
|
{
|
|
370
368
|
suggestion: "Use store.withRecordedTransaction(externalTx, async (tx) => ...) so TypeGraph can flush capture before the caller commits."
|
|
371
369
|
}
|
|
372
370
|
);
|
|
373
371
|
}
|
|
374
372
|
function historyUnsafeRawWriteError(surface) {
|
|
375
|
-
return new
|
|
373
|
+
return new chunkDIK74MXX_cjs.ConfigurationError(
|
|
376
374
|
`${surface} is not available when history capture is enabled because raw SQL writes bypass recorded-time capture.`,
|
|
377
|
-
{
|
|
375
|
+
{
|
|
376
|
+
code: "RECORDED_CAPTURE_RAW_SQL_DISABLED"
|
|
377
|
+
},
|
|
378
378
|
{
|
|
379
379
|
suggestion: "Run graph writes through store.nodes/store.edges (or tx.nodes/tx.edges inside a transaction), or perform raw relational writes outside a history-enabled TypeGraph store."
|
|
380
380
|
}
|
|
381
381
|
);
|
|
382
382
|
}
|
|
383
|
+
function revisionTrackingUnsafeRawWriteError(surface) {
|
|
384
|
+
return new chunkDIK74MXX_cjs.ConfigurationError(
|
|
385
|
+
`${surface} is not available when revision tracking is enabled because raw SQL writes bypass the revision anchor.`,
|
|
386
|
+
{
|
|
387
|
+
code: "REVISION_TRACKING_RAW_SQL_DISABLED"
|
|
388
|
+
},
|
|
389
|
+
{
|
|
390
|
+
suggestion: "Run graph writes through store.nodes/store.edges (or tx.nodes/tx.edges inside a transaction), so TypeGraph can advance the revision anchor."
|
|
391
|
+
}
|
|
392
|
+
);
|
|
393
|
+
}
|
|
383
394
|
function failHistoryUnsafeSqlRef() {
|
|
384
395
|
throw historyUnsafeRawWriteError("tx.sql");
|
|
385
396
|
}
|
|
397
|
+
function failRevisionTrackingUnsafeSqlRef() {
|
|
398
|
+
throw revisionTrackingUnsafeRawWriteError("tx.sql");
|
|
399
|
+
}
|
|
386
400
|
function createHistoryUnsafeSqlRef() {
|
|
401
|
+
return createUnsafeSqlRef(failHistoryUnsafeSqlRef);
|
|
402
|
+
}
|
|
403
|
+
function createRevisionTrackingUnsafeSqlRef() {
|
|
404
|
+
return createUnsafeSqlRef(failRevisionTrackingUnsafeSqlRef);
|
|
405
|
+
}
|
|
406
|
+
function createUnsafeSqlRef(fail) {
|
|
387
407
|
return new Proxy(
|
|
388
|
-
function
|
|
389
|
-
return
|
|
408
|
+
function unsafeSqlRef() {
|
|
409
|
+
return fail();
|
|
390
410
|
},
|
|
391
411
|
{
|
|
392
412
|
get() {
|
|
393
|
-
return
|
|
413
|
+
return fail();
|
|
394
414
|
},
|
|
395
415
|
apply() {
|
|
396
|
-
return
|
|
416
|
+
return fail();
|
|
397
417
|
},
|
|
398
418
|
set() {
|
|
399
|
-
return
|
|
419
|
+
return fail();
|
|
400
420
|
},
|
|
401
421
|
defineProperty() {
|
|
402
|
-
return
|
|
422
|
+
return fail();
|
|
403
423
|
},
|
|
404
424
|
deleteProperty() {
|
|
405
|
-
return
|
|
425
|
+
return fail();
|
|
406
426
|
},
|
|
407
427
|
// Enumeration / inspection traps too, so spreading (`{...tx.sql}`),
|
|
408
428
|
// `Object.keys`, `in`, and prototype reads also fail loudly rather than
|
|
409
429
|
// silently yielding an empty object that reads as "no raw handle".
|
|
410
430
|
has() {
|
|
411
|
-
return
|
|
431
|
+
return fail();
|
|
412
432
|
},
|
|
413
433
|
ownKeys() {
|
|
414
|
-
return
|
|
434
|
+
return fail();
|
|
415
435
|
},
|
|
416
436
|
getOwnPropertyDescriptor() {
|
|
417
|
-
return
|
|
437
|
+
return fail();
|
|
418
438
|
},
|
|
419
439
|
getPrototypeOf() {
|
|
420
|
-
return
|
|
440
|
+
return fail();
|
|
421
441
|
}
|
|
422
442
|
}
|
|
423
443
|
);
|
|
@@ -442,7 +462,7 @@ function rawWriteGuards(target, prefix) {
|
|
|
442
462
|
}
|
|
443
463
|
function assertCapturableBackend(backend) {
|
|
444
464
|
if (!backend.capabilities.transactions) {
|
|
445
|
-
throw new
|
|
465
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
446
466
|
"history: true requires a backend with transaction support.",
|
|
447
467
|
{ dialect: backend.dialect },
|
|
448
468
|
{
|
|
@@ -451,7 +471,7 @@ function assertCapturableBackend(backend) {
|
|
|
451
471
|
);
|
|
452
472
|
}
|
|
453
473
|
if (backend.executeStatement === void 0) {
|
|
454
|
-
throw new
|
|
474
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
455
475
|
"history: true requires a backend that supports executeStatement.",
|
|
456
476
|
{ dialect: backend.dialect },
|
|
457
477
|
{
|
|
@@ -460,7 +480,7 @@ function assertCapturableBackend(backend) {
|
|
|
460
480
|
);
|
|
461
481
|
}
|
|
462
482
|
if (backend.capabilities.returning === false) {
|
|
463
|
-
throw new
|
|
483
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
464
484
|
"history: true requires a backend that supports UPDATE \u2026 RETURNING.",
|
|
465
485
|
{ dialect: backend.dialect },
|
|
466
486
|
{
|
|
@@ -469,7 +489,7 @@ function assertCapturableBackend(backend) {
|
|
|
469
489
|
);
|
|
470
490
|
}
|
|
471
491
|
if (backend.tableNames === void 0) {
|
|
472
|
-
throw new
|
|
492
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
473
493
|
"history: true requires a backend that exposes tableNames.",
|
|
474
494
|
{ dialect: backend.dialect },
|
|
475
495
|
{
|
|
@@ -478,6 +498,44 @@ function assertCapturableBackend(backend) {
|
|
|
478
498
|
);
|
|
479
499
|
}
|
|
480
500
|
}
|
|
501
|
+
function assertRevisionTrackableBackend(backend) {
|
|
502
|
+
if (!backend.capabilities.transactions) {
|
|
503
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
504
|
+
"revisionTracking: true requires a backend with transaction support.",
|
|
505
|
+
{ dialect: backend.dialect },
|
|
506
|
+
{
|
|
507
|
+
suggestion: "Use a transactional SQLite/PostgreSQL backend or leave revision tracking disabled."
|
|
508
|
+
}
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
if (backend.executeStatement === void 0) {
|
|
512
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
513
|
+
"revisionTracking: true requires a backend that supports executeStatement.",
|
|
514
|
+
{ dialect: backend.dialect },
|
|
515
|
+
{
|
|
516
|
+
suggestion: "Use a built-in SQLite/PostgreSQL backend, or implement executeStatement so TypeGraph can advance the revision clock."
|
|
517
|
+
}
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
if (backend.tableNames === void 0) {
|
|
521
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
522
|
+
"revisionTracking: true requires a backend that exposes tableNames.",
|
|
523
|
+
{ dialect: backend.dialect },
|
|
524
|
+
{
|
|
525
|
+
suggestion: "Use a built-in SQLite/PostgreSQL backend, or set tableNames so TypeGraph can address the revision clock relation."
|
|
526
|
+
}
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
if (backend.ensureRevisionOriginsTable === void 0) {
|
|
530
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
531
|
+
"revisionTracking: true requires a backend that can bootstrap revision origins.",
|
|
532
|
+
{ dialect: backend.dialect },
|
|
533
|
+
{
|
|
534
|
+
suggestion: "Use a built-in SQLite/PostgreSQL backend, or implement ensureRevisionOriginsTable so TypeGraph can durably namespace revision anchors."
|
|
535
|
+
}
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
481
539
|
|
|
482
540
|
// src/store/recorded-capture/clock.ts
|
|
483
541
|
var RECORDED_MIN = "1970-01-01T00:00:00.000Z";
|
|
@@ -508,22 +566,40 @@ function graphWriteLockEvidence() {
|
|
|
508
566
|
function uncapturedGraphWriteLock() {
|
|
509
567
|
return graphWriteLockEvidence();
|
|
510
568
|
}
|
|
511
|
-
|
|
512
|
-
|
|
569
|
+
function createRecordedGraphLockMemo() {
|
|
570
|
+
return /* @__PURE__ */ new Map();
|
|
571
|
+
}
|
|
572
|
+
var recordedGraphLockMemos = /* @__PURE__ */ new WeakMap();
|
|
573
|
+
function registerRecordedGraphLockMemo(backend, memo) {
|
|
574
|
+
recordedGraphLockMemos.set(backend, memo);
|
|
575
|
+
}
|
|
576
|
+
async function acquireRecordedGraphWriteLock(target, graphId) {
|
|
513
577
|
await target.execute(
|
|
514
|
-
asCompiledRowsSql(recordedGraphWriteAdvisoryLockSql(graphId))
|
|
578
|
+
chunkEOLERH7Y_cjs.asCompiledRowsSql(recordedGraphWriteAdvisoryLockSql(graphId))
|
|
515
579
|
);
|
|
516
|
-
return graphWriteLockEvidence();
|
|
517
580
|
}
|
|
518
|
-
async function
|
|
519
|
-
if (target.dialect !== "postgres") return;
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
await
|
|
581
|
+
async function lockRecordedGraphWrite(target, graphId, memo) {
|
|
582
|
+
if (target.dialect !== "postgres") return graphWriteLockEvidence();
|
|
583
|
+
const effectiveMemo = memo ?? recordedGraphLockMemos.get(target);
|
|
584
|
+
if (effectiveMemo === void 0) {
|
|
585
|
+
await acquireRecordedGraphWriteLock(target, graphId);
|
|
586
|
+
return graphWriteLockEvidence();
|
|
587
|
+
}
|
|
588
|
+
let pending = effectiveMemo.get(graphId);
|
|
589
|
+
if (pending === void 0) {
|
|
590
|
+
pending = acquireRecordedGraphWriteLock(target, graphId).catch(
|
|
591
|
+
(error) => {
|
|
592
|
+
effectiveMemo.delete(graphId);
|
|
593
|
+
throw error;
|
|
594
|
+
}
|
|
595
|
+
);
|
|
596
|
+
effectiveMemo.set(graphId, pending);
|
|
523
597
|
}
|
|
598
|
+
await pending;
|
|
599
|
+
return graphWriteLockEvidence();
|
|
524
600
|
}
|
|
525
601
|
function failInvalidClockTimestamp(value) {
|
|
526
|
-
throw new
|
|
602
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
527
603
|
"Recorded clock row contained an invalid timestamp",
|
|
528
604
|
{ value }
|
|
529
605
|
);
|
|
@@ -562,12 +638,12 @@ function toCanonicalIso(value) {
|
|
|
562
638
|
return failInvalidClockTimestamp(value);
|
|
563
639
|
}
|
|
564
640
|
function nextRecordedCommitTime(previous) {
|
|
565
|
-
const wallTime = Date.parse(
|
|
641
|
+
const wallTime = Date.parse(chunkRSSQKPSZ_cjs.nowIso());
|
|
566
642
|
return previous === void 0 ? wallTime : Math.max(wallTime, Date.parse(previous) + 1);
|
|
567
643
|
}
|
|
568
644
|
async function readRecordedClock(target, schema, graphId) {
|
|
569
645
|
const rows = await target.execute(
|
|
570
|
-
asCompiledRowsSql(drizzleOrm.sql`
|
|
646
|
+
chunkEOLERH7Y_cjs.asCompiledRowsSql(drizzleOrm.sql`
|
|
571
647
|
SELECT recorded_at
|
|
572
648
|
FROM ${schema.recordedClockTable}
|
|
573
649
|
WHERE graph_id = ${graphId}
|
|
@@ -576,6 +652,53 @@ async function readRecordedClock(target, schema, graphId) {
|
|
|
576
652
|
const first = rows[0];
|
|
577
653
|
return first === void 0 ? void 0 : toCanonicalIso(first.recorded_at);
|
|
578
654
|
}
|
|
655
|
+
async function readRevisionOrigin(target, schema, graphId) {
|
|
656
|
+
const rows = await target.execute(
|
|
657
|
+
chunkEOLERH7Y_cjs.asCompiledRowsSql(drizzleOrm.sql`
|
|
658
|
+
SELECT origin
|
|
659
|
+
FROM ${schema.revisionOriginsTable}
|
|
660
|
+
WHERE graph_id = ${graphId}
|
|
661
|
+
`)
|
|
662
|
+
);
|
|
663
|
+
const first = rows[0];
|
|
664
|
+
if (first === void 0) return void 0;
|
|
665
|
+
if (typeof first.origin !== "string" || first.origin.length === 0) {
|
|
666
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
667
|
+
"Revision origin row contained an invalid origin",
|
|
668
|
+
{ graphId, origin: first.origin }
|
|
669
|
+
);
|
|
670
|
+
}
|
|
671
|
+
return first.origin;
|
|
672
|
+
}
|
|
673
|
+
async function ensureRevisionOrigin(target, schema, graphId) {
|
|
674
|
+
const ensureTable = target.ensureRevisionOriginsTable;
|
|
675
|
+
if (ensureTable === void 0) {
|
|
676
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
677
|
+
"Revision tracking requires a backend that can bootstrap revision origins.",
|
|
678
|
+
{ dialect: target.dialect },
|
|
679
|
+
{
|
|
680
|
+
suggestion: "Use a built-in SQLite/PostgreSQL backend, or implement ensureRevisionOriginsTable on the custom backend."
|
|
681
|
+
}
|
|
682
|
+
);
|
|
683
|
+
}
|
|
684
|
+
await ensureTable();
|
|
685
|
+
const existing = await readRevisionOrigin(target, schema, graphId);
|
|
686
|
+
if (existing !== void 0) return existing;
|
|
687
|
+
await executeStatement(
|
|
688
|
+
target,
|
|
689
|
+
drizzleOrm.sql`
|
|
690
|
+
INSERT INTO ${schema.revisionOriginsTable} (graph_id, origin)
|
|
691
|
+
VALUES (${graphId}, ${generateId()})
|
|
692
|
+
ON CONFLICT (graph_id) DO NOTHING
|
|
693
|
+
`
|
|
694
|
+
);
|
|
695
|
+
const origin = await readRevisionOrigin(target, schema, graphId);
|
|
696
|
+
if (origin !== void 0) return origin;
|
|
697
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
698
|
+
"Revision origin was not persisted after initialization.",
|
|
699
|
+
{ graphId, dialect: target.dialect }
|
|
700
|
+
);
|
|
701
|
+
}
|
|
579
702
|
async function writeRecordedClock(target, schema, graphId, recordedAt) {
|
|
580
703
|
await executeStatement(
|
|
581
704
|
target,
|
|
@@ -589,7 +712,7 @@ async function writeRecordedClock(target, schema, graphId, recordedAt) {
|
|
|
589
712
|
async function lockRecordedClock(target, schema, graphId, ownsWriteLock) {
|
|
590
713
|
if (target.dialect === "postgres") {
|
|
591
714
|
await target.execute(
|
|
592
|
-
asCompiledRowsSql(recordedClockAdvisoryLockSql(graphId))
|
|
715
|
+
chunkEOLERH7Y_cjs.asCompiledRowsSql(recordedClockAdvisoryLockSql(graphId))
|
|
593
716
|
);
|
|
594
717
|
return;
|
|
595
718
|
}
|
|
@@ -603,12 +726,12 @@ async function lockRecordedClock(target, schema, graphId, ownsWriteLock) {
|
|
|
603
726
|
`
|
|
604
727
|
);
|
|
605
728
|
}
|
|
606
|
-
async function allocateRecordedCommit(target, schema, graphId, ownsWriteLock) {
|
|
729
|
+
async function allocateRecordedCommit(target, schema, graphId, ownsWriteLock, previousRevision) {
|
|
607
730
|
await lockRecordedClock(target, schema, graphId, ownsWriteLock);
|
|
608
|
-
const previous = await readRecordedClock(target, schema, graphId);
|
|
731
|
+
const previous = previousRevision ?? await readRecordedClock(target, schema, graphId);
|
|
609
732
|
const recordedCommitTime = nextRecordedCommitTime(previous);
|
|
610
733
|
if (!Number.isFinite(recordedCommitTime) || recordedCommitTime >= RECORDED_MAX_TIME) {
|
|
611
|
-
throw new
|
|
734
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
612
735
|
`Recorded commit clock reached the open sentinel ${RECORDED_MAX}`,
|
|
613
736
|
{ graphId, recordedCommitTime },
|
|
614
737
|
{
|
|
@@ -620,6 +743,15 @@ async function allocateRecordedCommit(target, schema, graphId, ownsWriteLock) {
|
|
|
620
743
|
await writeRecordedClock(target, schema, graphId, recordedCommit);
|
|
621
744
|
return recordedCommit;
|
|
622
745
|
}
|
|
746
|
+
async function advanceRevisionClock(target, schema, graphId, ownsWriteLock, previousRevision) {
|
|
747
|
+
return allocateRecordedCommit(
|
|
748
|
+
target,
|
|
749
|
+
schema,
|
|
750
|
+
graphId,
|
|
751
|
+
ownsWriteLock,
|
|
752
|
+
previousRevision
|
|
753
|
+
);
|
|
754
|
+
}
|
|
623
755
|
|
|
624
756
|
// src/store/insert-dispatch.ts
|
|
625
757
|
function nodeInsertDispatch(backend) {
|
|
@@ -748,7 +880,7 @@ var RECORDED_BIND_PARAM_BUDGET = 900;
|
|
|
748
880
|
function recordedBindParamBudget(target) {
|
|
749
881
|
const budget = target.capabilities.maxBindParameters ?? RECORDED_BIND_PARAM_BUDGET;
|
|
750
882
|
if (!Number.isSafeInteger(budget) || budget < 1) {
|
|
751
|
-
throw new
|
|
883
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
752
884
|
`backend capabilities.maxBindParameters must be a positive integer, got: ${String(budget)}`,
|
|
753
885
|
{
|
|
754
886
|
code: "INVALID_BACKEND_CAPABILITY",
|
|
@@ -769,12 +901,12 @@ function recordedCommonCells() {
|
|
|
769
901
|
graph_id: (row) => drizzleOrm.sql`${row.graph_id}`,
|
|
770
902
|
id: (row) => drizzleOrm.sql`${row.id}`,
|
|
771
903
|
kind: (row) => drizzleOrm.sql`${row.kind}`,
|
|
772
|
-
props: (row) => drizzleOrm.sql`${row.props}`,
|
|
773
|
-
valid_from: (row) => drizzleOrm.sql`${
|
|
774
|
-
valid_to: (row) => drizzleOrm.sql`${
|
|
904
|
+
props: (row) => drizzleOrm.sql`${chunkX4JBT642_cjs.rowPropsToJsonText(row.props)}`,
|
|
905
|
+
valid_from: (row) => drizzleOrm.sql`${chunk7YSP4V4R_cjs.sqlNull(row.valid_from)}`,
|
|
906
|
+
valid_to: (row) => drizzleOrm.sql`${chunk7YSP4V4R_cjs.sqlNull(row.valid_to)}`,
|
|
775
907
|
created_at: (row) => drizzleOrm.sql`${row.created_at}`,
|
|
776
908
|
updated_at: (row) => drizzleOrm.sql`${row.updated_at}`,
|
|
777
|
-
deleted_at: (row) => drizzleOrm.sql`${
|
|
909
|
+
deleted_at: (row) => drizzleOrm.sql`${chunk7YSP4V4R_cjs.sqlNull(row.deleted_at)}`,
|
|
778
910
|
recorded_from: (_row, recordedCommit) => drizzleOrm.sql`${recordedCommit}`,
|
|
779
911
|
recorded_to: () => drizzleOrm.sql`${RECORDED_MAX}`,
|
|
780
912
|
op: (_row, _recordedCommit, operation) => drizzleOrm.sql`${operation}`,
|
|
@@ -862,20 +994,20 @@ function entityKey(entity) {
|
|
|
862
994
|
async function closeOpenReturning(target, table, graphId, ids, recordedCommit, kind) {
|
|
863
995
|
const kindFilter = kind === void 0 ? drizzleOrm.sql`` : drizzleOrm.sql`AND kind = ${kind}`;
|
|
864
996
|
const rows = await target.execute(
|
|
865
|
-
asCompiledRowsSql(drizzleOrm.sql`
|
|
997
|
+
chunkEOLERH7Y_cjs.asCompiledRowsSql(drizzleOrm.sql`
|
|
866
998
|
UPDATE ${table}
|
|
867
999
|
SET recorded_to = ${recordedCommit}
|
|
868
1000
|
WHERE graph_id = ${graphId}
|
|
869
1001
|
${kindFilter}
|
|
870
1002
|
AND recorded_to = ${RECORDED_MAX}
|
|
871
|
-
AND id IN (${
|
|
1003
|
+
AND id IN (${chunkX4JBT642_cjs.sqlValueList(ids)})
|
|
872
1004
|
RETURNING id, deleted_at
|
|
873
1005
|
`)
|
|
874
1006
|
);
|
|
875
|
-
return new Map(rows.map((row) => [row.id,
|
|
1007
|
+
return new Map(rows.map((row) => [row.id, chunkX4JBT642_cjs.isPresent(row.deleted_at)]));
|
|
876
1008
|
}
|
|
877
1009
|
function recordedOp(hadOpenRow, priorRowWasTombstone, after) {
|
|
878
|
-
if (
|
|
1010
|
+
if (chunkX4JBT642_cjs.isPresent(after.deleted_at)) return "delete";
|
|
879
1011
|
if (!hadOpenRow || priorRowWasTombstone) return "create";
|
|
880
1012
|
return "update";
|
|
881
1013
|
}
|
|
@@ -912,7 +1044,7 @@ function recordedInsertsFor(afterById, closed) {
|
|
|
912
1044
|
async function flushNodes(target, schema, graphId, entities, recordedCommit) {
|
|
913
1045
|
const chunkSize = recordedNodeChunkSize(target);
|
|
914
1046
|
for (const [kind, group] of groupNodesByKind(entities)) {
|
|
915
|
-
for (const entityChunk of
|
|
1047
|
+
for (const entityChunk of chunkX4JBT642_cjs.chunk(group, chunkSize)) {
|
|
916
1048
|
const ids = entityChunk.map((entity) => entity.id);
|
|
917
1049
|
const closed = await closeOpenReturning(
|
|
918
1050
|
target,
|
|
@@ -937,7 +1069,7 @@ async function flushNodes(target, schema, graphId, entities, recordedCommit) {
|
|
|
937
1069
|
}
|
|
938
1070
|
async function flushEdges(target, schema, graphId, entities, recordedCommit) {
|
|
939
1071
|
const chunkSize = recordedEdgeChunkSize(target);
|
|
940
|
-
for (const entityChunk of
|
|
1072
|
+
for (const entityChunk of chunkX4JBT642_cjs.chunk(entities, chunkSize)) {
|
|
941
1073
|
const ids = entityChunk.map((entity) => entity.id);
|
|
942
1074
|
const closed = await closeOpenReturning(
|
|
943
1075
|
target,
|
|
@@ -1016,7 +1148,7 @@ async function closeRecordedHardDeletedKind(target, schema, graphId, removal, ow
|
|
|
1016
1148
|
}
|
|
1017
1149
|
async function queryConnectedEdgeIds(target, schema, params) {
|
|
1018
1150
|
const rows = await target.execute(
|
|
1019
|
-
asCompiledRowsSql(drizzleOrm.sql`
|
|
1151
|
+
chunkEOLERH7Y_cjs.asCompiledRowsSql(drizzleOrm.sql`
|
|
1020
1152
|
SELECT id
|
|
1021
1153
|
FROM ${schema.edgesTable}
|
|
1022
1154
|
WHERE graph_id = ${params.graphId}
|
|
@@ -1030,6 +1162,21 @@ async function queryConnectedEdgeIds(target, schema, params) {
|
|
|
1030
1162
|
}
|
|
1031
1163
|
|
|
1032
1164
|
// src/store/recorded-capture.ts
|
|
1165
|
+
var RECORDED_FLUSH_OBSERVER = /* @__PURE__ */ Symbol("typegraph.recordedFlushObserver");
|
|
1166
|
+
function readRecordedFlushObserver(options) {
|
|
1167
|
+
return options?.[RECORDED_FLUSH_OBSERVER];
|
|
1168
|
+
}
|
|
1169
|
+
function stripRecordedFlushObserver(options) {
|
|
1170
|
+
if (options === void 0) return void 0;
|
|
1171
|
+
const { [RECORDED_FLUSH_OBSERVER]: _observer, ...backendOptions } = options;
|
|
1172
|
+
return backendOptions;
|
|
1173
|
+
}
|
|
1174
|
+
function withRecordedFlushObserver(options, observer) {
|
|
1175
|
+
return {
|
|
1176
|
+
...stripRecordedFlushObserver(options),
|
|
1177
|
+
[RECORDED_FLUSH_OBSERVER]: observer
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1033
1180
|
function nodeIdentityKey(graphId, kind, id) {
|
|
1034
1181
|
return `${graphId}\0${kind}\0${id}`;
|
|
1035
1182
|
}
|
|
@@ -1048,22 +1195,32 @@ function edgeParamsIdentityKey(params) {
|
|
|
1048
1195
|
function edgeRowIdentityKey(row) {
|
|
1049
1196
|
return edgeIdentityKey(row.graph_id, row.id);
|
|
1050
1197
|
}
|
|
1198
|
+
function recordedCaptureSealedError(details) {
|
|
1199
|
+
return new chunkDIK74MXX_cjs.ConfigurationError(
|
|
1200
|
+
"Recorded-time capture session is sealed: a graph write happened after the transaction's capture was flushed.",
|
|
1201
|
+
details,
|
|
1202
|
+
{
|
|
1203
|
+
suggestion: "Perform all writes inside the withRecordedTransaction callback; do not reuse the transaction context after it returns."
|
|
1204
|
+
}
|
|
1205
|
+
);
|
|
1206
|
+
}
|
|
1051
1207
|
function createRecordedCaptureSession() {
|
|
1052
1208
|
const touched = /* @__PURE__ */ new Map();
|
|
1053
1209
|
let sealed = false;
|
|
1054
1210
|
function touch(entity) {
|
|
1055
1211
|
if (sealed) {
|
|
1056
|
-
throw
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
}
|
|
1062
|
-
);
|
|
1212
|
+
throw recordedCaptureSealedError({
|
|
1213
|
+
entity: entity.entity,
|
|
1214
|
+
graphId: entity.graphId,
|
|
1215
|
+
id: entity.id
|
|
1216
|
+
});
|
|
1063
1217
|
}
|
|
1064
1218
|
touched.set(entityKey(entity), entity);
|
|
1065
1219
|
}
|
|
1066
1220
|
return {
|
|
1221
|
+
assertOpen() {
|
|
1222
|
+
if (sealed) throw recordedCaptureSealedError({});
|
|
1223
|
+
},
|
|
1067
1224
|
touchNode(graphId, kind, id, afterImage) {
|
|
1068
1225
|
touch({ entity: "node", graphId, kind, id, afterImage });
|
|
1069
1226
|
},
|
|
@@ -1072,7 +1229,7 @@ function createRecordedCaptureSession() {
|
|
|
1072
1229
|
},
|
|
1073
1230
|
async flush(target, schema, ownsWriteLock) {
|
|
1074
1231
|
if (sealed) {
|
|
1075
|
-
throw new
|
|
1232
|
+
throw new chunkDIK74MXX_cjs.ConfigurationError(
|
|
1076
1233
|
"Recorded-time capture session was already flushed.",
|
|
1077
1234
|
{},
|
|
1078
1235
|
{
|
|
@@ -1081,8 +1238,9 @@ function createRecordedCaptureSession() {
|
|
|
1081
1238
|
);
|
|
1082
1239
|
}
|
|
1083
1240
|
sealed = true;
|
|
1084
|
-
if (touched.size === 0) return;
|
|
1085
|
-
const
|
|
1241
|
+
if (touched.size === 0) return /* @__PURE__ */ new Map();
|
|
1242
|
+
const recordedByGraph = /* @__PURE__ */ new Map();
|
|
1243
|
+
const byGraph = chunkX4JBT642_cjs.groupBy(touched.values(), (entity) => entity.graphId);
|
|
1086
1244
|
for (const [graphId, entities] of byGraph) {
|
|
1087
1245
|
const recordedCommit = await allocateRecordedCommit(
|
|
1088
1246
|
target,
|
|
@@ -1090,6 +1248,7 @@ function createRecordedCaptureSession() {
|
|
|
1090
1248
|
graphId,
|
|
1091
1249
|
ownsWriteLock
|
|
1092
1250
|
);
|
|
1251
|
+
recordedByGraph.set(graphId, recordedCommit);
|
|
1093
1252
|
const nodes = entities.filter(
|
|
1094
1253
|
(entity) => entity.entity === "node"
|
|
1095
1254
|
);
|
|
@@ -1100,24 +1259,29 @@ function createRecordedCaptureSession() {
|
|
|
1100
1259
|
await flushEdges(target, schema, graphId, edges, recordedCommit);
|
|
1101
1260
|
}
|
|
1102
1261
|
touched.clear();
|
|
1262
|
+
return recordedByGraph;
|
|
1103
1263
|
}
|
|
1104
1264
|
};
|
|
1105
1265
|
}
|
|
1106
1266
|
function createRecordedTransactionBackend(target, session, schema) {
|
|
1107
1267
|
const nodeDispatch = nodeInsertDispatch(target);
|
|
1108
1268
|
const edgeDispatch = edgeInsertDispatch(target);
|
|
1269
|
+
const graphLocks = createRecordedGraphLockMemo();
|
|
1109
1270
|
async function lockGraph(graphId) {
|
|
1110
|
-
await lockRecordedGraphWrite(target, graphId);
|
|
1271
|
+
await lockRecordedGraphWrite(target, graphId, graphLocks);
|
|
1111
1272
|
}
|
|
1112
1273
|
async function lockGraphs(params) {
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
)
|
|
1274
|
+
const graphIds = [
|
|
1275
|
+
...new Set(params.map((parameter) => parameter.graphId))
|
|
1276
|
+
].toSorted();
|
|
1277
|
+
for (const graphId of graphIds) {
|
|
1278
|
+
await lockRecordedGraphWrite(target, graphId, graphLocks);
|
|
1279
|
+
}
|
|
1117
1280
|
}
|
|
1118
|
-
|
|
1281
|
+
const overlay = chunkX4JBT642_cjs.createBackendOverlay(target, {
|
|
1119
1282
|
...rawWriteGuards(target, "tx.backend"),
|
|
1120
1283
|
async insertNode(params) {
|
|
1284
|
+
session.assertOpen();
|
|
1121
1285
|
await lockGraph(params.graphId);
|
|
1122
1286
|
const row = await target.insertNode(params);
|
|
1123
1287
|
session.touchNode(params.graphId, params.kind, params.id, row);
|
|
@@ -1125,6 +1289,7 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
1125
1289
|
},
|
|
1126
1290
|
...target.insertNodeNoReturn === void 0 ? {} : {
|
|
1127
1291
|
async insertNodeNoReturn(params) {
|
|
1292
|
+
session.assertOpen();
|
|
1128
1293
|
await lockGraph(params.graphId);
|
|
1129
1294
|
await runInsertNoReturn(nodeDispatch, params);
|
|
1130
1295
|
session.touchNode(params.graphId, params.kind, params.id);
|
|
@@ -1132,6 +1297,7 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
1132
1297
|
},
|
|
1133
1298
|
...target.insertNodesBatch === void 0 ? {} : {
|
|
1134
1299
|
async insertNodesBatch(params) {
|
|
1300
|
+
session.assertOpen();
|
|
1135
1301
|
await lockGraphs(params);
|
|
1136
1302
|
await runInsertBatch(nodeDispatch, params);
|
|
1137
1303
|
for (const node of params) {
|
|
@@ -1141,6 +1307,7 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
1141
1307
|
},
|
|
1142
1308
|
...target.insertNodesBatchReturning === void 0 ? {} : {
|
|
1143
1309
|
async insertNodesBatchReturning(params) {
|
|
1310
|
+
session.assertOpen();
|
|
1144
1311
|
await lockGraphs(params);
|
|
1145
1312
|
const rows = await runInsertBatchReturning(nodeDispatch, params);
|
|
1146
1313
|
const rowsByIdentity = new Map(
|
|
@@ -1158,17 +1325,20 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
1158
1325
|
}
|
|
1159
1326
|
},
|
|
1160
1327
|
async updateNode(params) {
|
|
1328
|
+
session.assertOpen();
|
|
1161
1329
|
await lockGraph(params.graphId);
|
|
1162
1330
|
const row = await target.updateNode(params);
|
|
1163
1331
|
session.touchNode(params.graphId, params.kind, params.id, row);
|
|
1164
1332
|
return row;
|
|
1165
1333
|
},
|
|
1166
1334
|
async deleteNode(params) {
|
|
1335
|
+
session.assertOpen();
|
|
1167
1336
|
await lockGraph(params.graphId);
|
|
1168
1337
|
await target.deleteNode(params);
|
|
1169
1338
|
session.touchNode(params.graphId, params.kind, params.id);
|
|
1170
1339
|
},
|
|
1171
1340
|
async hardDeleteNode(params) {
|
|
1341
|
+
session.assertOpen();
|
|
1172
1342
|
await lockGraph(params.graphId);
|
|
1173
1343
|
const connectedEdgeIds = await queryConnectedEdgeIds(
|
|
1174
1344
|
target,
|
|
@@ -1182,6 +1352,7 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
1182
1352
|
}
|
|
1183
1353
|
},
|
|
1184
1354
|
async insertEdge(params) {
|
|
1355
|
+
session.assertOpen();
|
|
1185
1356
|
await lockGraph(params.graphId);
|
|
1186
1357
|
const row = await target.insertEdge(params);
|
|
1187
1358
|
session.touchEdge(params.graphId, params.id, row);
|
|
@@ -1189,6 +1360,7 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
1189
1360
|
},
|
|
1190
1361
|
...target.insertEdgeNoReturn === void 0 ? {} : {
|
|
1191
1362
|
async insertEdgeNoReturn(params) {
|
|
1363
|
+
session.assertOpen();
|
|
1192
1364
|
await lockGraph(params.graphId);
|
|
1193
1365
|
await runInsertNoReturn(edgeDispatch, params);
|
|
1194
1366
|
session.touchEdge(params.graphId, params.id);
|
|
@@ -1196,6 +1368,7 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
1196
1368
|
},
|
|
1197
1369
|
...target.insertEdgesBatch === void 0 ? {} : {
|
|
1198
1370
|
async insertEdgesBatch(params) {
|
|
1371
|
+
session.assertOpen();
|
|
1199
1372
|
await lockGraphs(params);
|
|
1200
1373
|
await runInsertBatch(edgeDispatch, params);
|
|
1201
1374
|
for (const edge of params) {
|
|
@@ -1205,6 +1378,7 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
1205
1378
|
},
|
|
1206
1379
|
...target.insertEdgesBatchReturning === void 0 ? {} : {
|
|
1207
1380
|
async insertEdgesBatchReturning(params) {
|
|
1381
|
+
session.assertOpen();
|
|
1208
1382
|
await lockGraphs(params);
|
|
1209
1383
|
const rows = await runInsertBatchReturning(edgeDispatch, params);
|
|
1210
1384
|
const rowsByIdentity = new Map(
|
|
@@ -1221,22 +1395,47 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
1221
1395
|
}
|
|
1222
1396
|
},
|
|
1223
1397
|
async updateEdge(params) {
|
|
1398
|
+
session.assertOpen();
|
|
1224
1399
|
await lockGraph(params.graphId);
|
|
1225
1400
|
const row = await target.updateEdge(params);
|
|
1226
1401
|
session.touchEdge(params.graphId, params.id, row);
|
|
1227
1402
|
return row;
|
|
1228
1403
|
},
|
|
1229
1404
|
async deleteEdge(params) {
|
|
1405
|
+
session.assertOpen();
|
|
1230
1406
|
await lockGraph(params.graphId);
|
|
1231
1407
|
await target.deleteEdge(params);
|
|
1232
1408
|
session.touchEdge(params.graphId, params.id);
|
|
1233
1409
|
},
|
|
1234
1410
|
async hardDeleteEdge(params) {
|
|
1411
|
+
session.assertOpen();
|
|
1235
1412
|
await lockGraph(params.graphId);
|
|
1236
1413
|
await target.hardDeleteEdge(params);
|
|
1237
1414
|
session.touchEdge(params.graphId, params.id);
|
|
1415
|
+
},
|
|
1416
|
+
...target.deleteEdgesBatch === void 0 ? {} : {
|
|
1417
|
+
async deleteEdgesBatch(params) {
|
|
1418
|
+
session.assertOpen();
|
|
1419
|
+
await lockGraph(params.graphId);
|
|
1420
|
+
await target.deleteEdgesBatch(params);
|
|
1421
|
+
for (const id of params.ids) {
|
|
1422
|
+
session.touchEdge(params.graphId, id);
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
},
|
|
1426
|
+
...target.hardDeleteEdgesBatch === void 0 ? {} : {
|
|
1427
|
+
async hardDeleteEdgesBatch(params) {
|
|
1428
|
+
session.assertOpen();
|
|
1429
|
+
await lockGraph(params.graphId);
|
|
1430
|
+
await target.hardDeleteEdgesBatch(params);
|
|
1431
|
+
for (const id of params.ids) {
|
|
1432
|
+
session.touchEdge(params.graphId, id);
|
|
1433
|
+
}
|
|
1434
|
+
}
|
|
1238
1435
|
}
|
|
1239
1436
|
});
|
|
1437
|
+
registerRecordedGraphLockMemo(overlay, graphLocks);
|
|
1438
|
+
return overlay;
|
|
1240
1439
|
}
|
|
1241
1440
|
function createRecordedTransactionScope(target, schema, ownsWriteLock = false) {
|
|
1242
1441
|
requireCaptureStatements(target);
|
|
@@ -1245,7 +1444,7 @@ function createRecordedTransactionScope(target, schema, ownsWriteLock = false) {
|
|
|
1245
1444
|
return {
|
|
1246
1445
|
backend: createRecordedTransactionBackend(target, session, resolvedSchema),
|
|
1247
1446
|
async flush() {
|
|
1248
|
-
|
|
1447
|
+
return chunkRSSQKPSZ_cjs.withRecordedRelationsPrecondition(
|
|
1249
1448
|
session.flush(target, resolvedSchema, ownsWriteLock),
|
|
1250
1449
|
{ dialect: target.dialect, surface: "capture-flush" }
|
|
1251
1450
|
);
|
|
@@ -1265,7 +1464,7 @@ async function runCapturedAutocommit(backend, schema, fn, options) {
|
|
|
1265
1464
|
function createRecordedBackend(backend, schema) {
|
|
1266
1465
|
assertCapturableBackend(backend);
|
|
1267
1466
|
const capture = (fn) => runCapturedAutocommit(backend, schema, fn);
|
|
1268
|
-
return
|
|
1467
|
+
return chunkX4JBT642_cjs.createBackendOverlay(backend, {
|
|
1269
1468
|
...rawWriteGuards(backend, "backend"),
|
|
1270
1469
|
async insertNode(params) {
|
|
1271
1470
|
return capture((target) => target.insertNode(params));
|
|
@@ -1333,15 +1532,28 @@ function createRecordedBackend(backend, schema) {
|
|
|
1333
1532
|
async hardDeleteEdge(params) {
|
|
1334
1533
|
await capture((target) => target.hardDeleteEdge(params));
|
|
1335
1534
|
},
|
|
1535
|
+
...backend.deleteEdgesBatch === void 0 ? {} : {
|
|
1536
|
+
async deleteEdgesBatch(params) {
|
|
1537
|
+
await capture((target) => target.deleteEdgesBatch(params));
|
|
1538
|
+
}
|
|
1539
|
+
},
|
|
1540
|
+
...backend.hardDeleteEdgesBatch === void 0 ? {} : {
|
|
1541
|
+
async hardDeleteEdgesBatch(params) {
|
|
1542
|
+
await capture((target) => target.hardDeleteEdgesBatch(params));
|
|
1543
|
+
}
|
|
1544
|
+
},
|
|
1336
1545
|
async transaction(fn, options) {
|
|
1337
|
-
|
|
1546
|
+
const observer = readRecordedFlushObserver(options);
|
|
1547
|
+
const backendOptions = stripRecordedFlushObserver(options);
|
|
1548
|
+
assertRequestedRecordedIsolation(backend, backendOptions);
|
|
1338
1549
|
return backend.transaction(async (target) => {
|
|
1339
1550
|
await assertRecordedCaptureTransactionIsolation(target);
|
|
1340
1551
|
const scope = createRecordedTransactionScope(target, schema, true);
|
|
1341
1552
|
const result = await fn(scope.backend, createHistoryUnsafeSqlRef());
|
|
1342
|
-
await scope.flush();
|
|
1553
|
+
const instants = await scope.flush();
|
|
1554
|
+
observer?.(instants);
|
|
1343
1555
|
return result;
|
|
1344
|
-
},
|
|
1556
|
+
}, backendOptions);
|
|
1345
1557
|
},
|
|
1346
1558
|
...backend.adoptTransaction === void 0 ? {} : {
|
|
1347
1559
|
adoptTransaction(externalTx) {
|
|
@@ -1358,7 +1570,7 @@ var embeddingFieldsCache = /* @__PURE__ */ new WeakMap();
|
|
|
1358
1570
|
function getEmbeddingFields(schema) {
|
|
1359
1571
|
const cached = embeddingFieldsCache.get(schema);
|
|
1360
1572
|
if (cached) return cached;
|
|
1361
|
-
const fields =
|
|
1573
|
+
const fields = chunkH7YNSMA7_cjs.resolveEmbeddingFields(schema);
|
|
1362
1574
|
embeddingFieldsCache.set(schema, fields);
|
|
1363
1575
|
return fields;
|
|
1364
1576
|
}
|
|
@@ -1397,6 +1609,65 @@ async function syncEmbeddings(ctx, schema, props) {
|
|
|
1397
1609
|
}
|
|
1398
1610
|
}
|
|
1399
1611
|
}
|
|
1612
|
+
async function syncEmbeddingsBatchForKind(args, schema, items) {
|
|
1613
|
+
const { graphId, nodeKind, backend } = args;
|
|
1614
|
+
if (!backend.upsertEmbedding || !backend.deleteEmbedding) {
|
|
1615
|
+
return;
|
|
1616
|
+
}
|
|
1617
|
+
const embeddingFields = getEmbeddingFields(schema);
|
|
1618
|
+
if (embeddingFields.length === 0) {
|
|
1619
|
+
return;
|
|
1620
|
+
}
|
|
1621
|
+
for (const field of embeddingFields) {
|
|
1622
|
+
const rows = [];
|
|
1623
|
+
const deletionIds = [];
|
|
1624
|
+
for (const item of items) {
|
|
1625
|
+
const value = item.props[field.fieldPath];
|
|
1626
|
+
if (isValidEmbeddingValue(value)) {
|
|
1627
|
+
rows.push({ nodeId: item.nodeId, embedding: value });
|
|
1628
|
+
} else if (value === void 0) {
|
|
1629
|
+
deletionIds.push(item.nodeId);
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
if (rows.length > 0) {
|
|
1633
|
+
if (backend.upsertEmbeddingBatch === void 0) {
|
|
1634
|
+
for (const row of rows) {
|
|
1635
|
+
await backend.upsertEmbedding({
|
|
1636
|
+
graphId,
|
|
1637
|
+
nodeKind,
|
|
1638
|
+
nodeId: row.nodeId,
|
|
1639
|
+
fieldPath: field.fieldPath,
|
|
1640
|
+
embedding: row.embedding,
|
|
1641
|
+
dimensions: field.dimensions,
|
|
1642
|
+
metric: field.metric,
|
|
1643
|
+
indexType: field.indexType
|
|
1644
|
+
});
|
|
1645
|
+
}
|
|
1646
|
+
} else {
|
|
1647
|
+
await backend.upsertEmbeddingBatch({
|
|
1648
|
+
graphId,
|
|
1649
|
+
nodeKind,
|
|
1650
|
+
fieldPath: field.fieldPath,
|
|
1651
|
+
dimensions: field.dimensions,
|
|
1652
|
+
metric: field.metric,
|
|
1653
|
+
indexType: field.indexType,
|
|
1654
|
+
rows
|
|
1655
|
+
});
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
for (const nodeId of deletionIds) {
|
|
1659
|
+
await backend.deleteEmbedding({
|
|
1660
|
+
graphId,
|
|
1661
|
+
nodeKind,
|
|
1662
|
+
nodeId,
|
|
1663
|
+
fieldPath: field.fieldPath,
|
|
1664
|
+
dimensions: field.dimensions,
|
|
1665
|
+
metric: field.metric,
|
|
1666
|
+
indexType: field.indexType
|
|
1667
|
+
});
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
}
|
|
1400
1671
|
async function deleteNodeEmbeddings(ctx, schema) {
|
|
1401
1672
|
const { backend } = ctx;
|
|
1402
1673
|
if (!backend.deleteEmbedding) {
|
|
@@ -1426,48 +1697,12 @@ function isValidEmbeddingValue(value) {
|
|
|
1426
1697
|
}
|
|
1427
1698
|
|
|
1428
1699
|
// src/store/fulltext-sync.ts
|
|
1429
|
-
var searchableFieldsCache = /* @__PURE__ */ new WeakMap();
|
|
1430
|
-
function getSearchableFields(schema) {
|
|
1431
|
-
const cached = searchableFieldsCache.get(schema);
|
|
1432
|
-
if (cached) return cached;
|
|
1433
|
-
const fields = computeSearchableFields(schema);
|
|
1434
|
-
searchableFieldsCache.set(schema, fields);
|
|
1435
|
-
return fields;
|
|
1436
|
-
}
|
|
1437
|
-
function computeSearchableFields(schema) {
|
|
1438
|
-
if (schema.type !== "object") return [];
|
|
1439
|
-
const def = schema.def;
|
|
1440
|
-
const shape = def.shape;
|
|
1441
|
-
if (!shape) return [];
|
|
1442
|
-
const fields = [];
|
|
1443
|
-
for (const [fieldPath, fieldSchema] of Object.entries(shape)) {
|
|
1444
|
-
const metadata = chunkJQGIPGVL_cjs.getSearchableMetadata(fieldSchema);
|
|
1445
|
-
if (metadata !== void 0) {
|
|
1446
|
-
fields.push({ fieldPath, metadata });
|
|
1447
|
-
}
|
|
1448
|
-
}
|
|
1449
|
-
warnIfConflictingLanguages(fields);
|
|
1450
|
-
return fields;
|
|
1451
|
-
}
|
|
1452
|
-
function warnIfConflictingLanguages(fields) {
|
|
1453
|
-
if (fields.length < 2) return;
|
|
1454
|
-
const languages = new Set(fields.map((field) => field.metadata.language));
|
|
1455
|
-
if (languages.size < 2) return;
|
|
1456
|
-
if (typeof console === "undefined" || typeof console.warn !== "function") {
|
|
1457
|
-
return;
|
|
1458
|
-
}
|
|
1459
|
-
const fieldSummary = fields.map((field) => `${field.fieldPath}=${field.metadata.language}`).join(", ");
|
|
1460
|
-
const winning = fields[0]?.metadata.language ?? chunkJQGIPGVL_cjs.DEFAULT_SEARCHABLE_LANGUAGE;
|
|
1461
|
-
console.warn(
|
|
1462
|
-
`[typegraph] searchable() fields declare conflicting languages (${fieldSummary}). The first field's language ("${winning}") is recorded on the fulltext row; true multilingual indexing requires a dedicated node kind per language.`
|
|
1463
|
-
);
|
|
1464
|
-
}
|
|
1465
1700
|
var FIELD_SEPARATOR = "\n";
|
|
1466
1701
|
function resolveCombinedLanguage(fields) {
|
|
1467
|
-
return fields[0]?.metadata.language ??
|
|
1702
|
+
return fields[0]?.metadata.language ?? chunkH7YNSMA7_cjs.DEFAULT_SEARCHABLE_LANGUAGE;
|
|
1468
1703
|
}
|
|
1469
1704
|
function computeFulltextContent(schema, props) {
|
|
1470
|
-
const searchableFields = getSearchableFields(schema);
|
|
1705
|
+
const searchableFields = chunkH7YNSMA7_cjs.getSearchableFields(schema);
|
|
1471
1706
|
if (searchableFields.length === 0) return void 0;
|
|
1472
1707
|
const parts = [];
|
|
1473
1708
|
for (const field of searchableFields) {
|
|
@@ -1498,19 +1733,68 @@ async function syncFulltext(ctx, schema, props) {
|
|
|
1498
1733
|
});
|
|
1499
1734
|
return;
|
|
1500
1735
|
}
|
|
1501
|
-
if (getSearchableFields(schema).length === 0) return;
|
|
1736
|
+
if (chunkH7YNSMA7_cjs.getSearchableFields(schema).length === 0) return;
|
|
1502
1737
|
await backend.deleteFulltext({
|
|
1503
1738
|
graphId: ctx.graphId,
|
|
1504
1739
|
nodeKind: ctx.nodeKind,
|
|
1505
1740
|
nodeId: ctx.nodeId
|
|
1506
1741
|
});
|
|
1507
1742
|
}
|
|
1743
|
+
async function syncFulltextBatchForKind(args, schema, items) {
|
|
1744
|
+
const { graphId, nodeKind, backend } = args;
|
|
1745
|
+
if (!backend.upsertFulltext || !backend.deleteFulltext) {
|
|
1746
|
+
return;
|
|
1747
|
+
}
|
|
1748
|
+
const rows = [];
|
|
1749
|
+
const emptyContentIds = [];
|
|
1750
|
+
const hasSearchableFields = chunkH7YNSMA7_cjs.getSearchableFields(schema).length > 0;
|
|
1751
|
+
for (const item of items) {
|
|
1752
|
+
const computed = computeFulltextContent(schema, item.props);
|
|
1753
|
+
if (computed !== void 0) {
|
|
1754
|
+
rows.push({
|
|
1755
|
+
nodeId: item.nodeId,
|
|
1756
|
+
content: computed.content,
|
|
1757
|
+
language: computed.language
|
|
1758
|
+
});
|
|
1759
|
+
} else if (hasSearchableFields) {
|
|
1760
|
+
emptyContentIds.push(item.nodeId);
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
if (rows.length > 0) {
|
|
1764
|
+
if (backend.upsertFulltextBatch === void 0) {
|
|
1765
|
+
for (const row of rows) {
|
|
1766
|
+
await backend.upsertFulltext({
|
|
1767
|
+
graphId,
|
|
1768
|
+
nodeKind,
|
|
1769
|
+
nodeId: row.nodeId,
|
|
1770
|
+
content: row.content,
|
|
1771
|
+
language: row.language
|
|
1772
|
+
});
|
|
1773
|
+
}
|
|
1774
|
+
} else {
|
|
1775
|
+
await backend.upsertFulltextBatch({ graphId, nodeKind, rows });
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
if (emptyContentIds.length > 0) {
|
|
1779
|
+
if (backend.deleteFulltextBatch === void 0) {
|
|
1780
|
+
for (const nodeId of emptyContentIds) {
|
|
1781
|
+
await backend.deleteFulltext({ graphId, nodeKind, nodeId });
|
|
1782
|
+
}
|
|
1783
|
+
} else {
|
|
1784
|
+
await backend.deleteFulltextBatch({
|
|
1785
|
+
graphId,
|
|
1786
|
+
nodeKind,
|
|
1787
|
+
nodeIds: emptyContentIds
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1508
1792
|
async function deleteNodeFulltext(ctx, schema) {
|
|
1509
1793
|
const { backend } = ctx;
|
|
1510
1794
|
if (!backend.deleteFulltext) {
|
|
1511
1795
|
return;
|
|
1512
1796
|
}
|
|
1513
|
-
if (getSearchableFields(schema).length === 0) {
|
|
1797
|
+
if (chunkH7YNSMA7_cjs.getSearchableFields(schema).length === 0) {
|
|
1514
1798
|
return;
|
|
1515
1799
|
}
|
|
1516
1800
|
await backend.deleteFulltext({
|
|
@@ -1572,7 +1856,7 @@ function evaluatePredicate(predicate, props) {
|
|
|
1572
1856
|
if (pred.op === "isNull") {
|
|
1573
1857
|
return value === null || value === void 0;
|
|
1574
1858
|
}
|
|
1575
|
-
return
|
|
1859
|
+
return chunkX4JBT642_cjs.isPresent(value);
|
|
1576
1860
|
}
|
|
1577
1861
|
function getKindsForUniquenessCheck(baseKind, scope, registry) {
|
|
1578
1862
|
if (scope === "kind") {
|
|
@@ -1601,7 +1885,7 @@ function checkCardinality(edgeKind, fromKind, fromId, cardinality, existingEdgeC
|
|
|
1601
1885
|
}
|
|
1602
1886
|
case "one": {
|
|
1603
1887
|
if (existingEdgeCount > 0) {
|
|
1604
|
-
return new
|
|
1888
|
+
return new chunkDIK74MXX_cjs.CardinalityError({
|
|
1605
1889
|
edgeKind,
|
|
1606
1890
|
fromKind,
|
|
1607
1891
|
fromId,
|
|
@@ -1616,7 +1900,7 @@ function checkCardinality(edgeKind, fromKind, fromId, cardinality, existingEdgeC
|
|
|
1616
1900
|
}
|
|
1617
1901
|
case "oneActive": {
|
|
1618
1902
|
if (hasActiveEdge) {
|
|
1619
|
-
return new
|
|
1903
|
+
return new chunkDIK74MXX_cjs.CardinalityError({
|
|
1620
1904
|
edgeKind,
|
|
1621
1905
|
fromKind,
|
|
1622
1906
|
fromId,
|
|
@@ -1630,7 +1914,7 @@ function checkCardinality(edgeKind, fromKind, fromId, cardinality, existingEdgeC
|
|
|
1630
1914
|
}
|
|
1631
1915
|
function checkUniqueEdge(edgeKind, fromKind, fromId, _toKind, _toId, existingCount) {
|
|
1632
1916
|
if (existingCount > 0) {
|
|
1633
|
-
return new
|
|
1917
|
+
return new chunkDIK74MXX_cjs.CardinalityError({
|
|
1634
1918
|
edgeKind,
|
|
1635
1919
|
fromKind,
|
|
1636
1920
|
fromId,
|
|
@@ -1642,11 +1926,8 @@ function checkUniqueEdge(edgeKind, fromKind, fromId, _toKind, _toId, existingCou
|
|
|
1642
1926
|
}
|
|
1643
1927
|
function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registry) {
|
|
1644
1928
|
const validFromKinds = registration.from.map((node) => node.kind);
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
);
|
|
1648
|
-
if (!fromValid) {
|
|
1649
|
-
return new chunkJIEJCTDS_cjs.EndpointError({
|
|
1929
|
+
if (!registry.isAssignableToAny(fromKind, validFromKinds)) {
|
|
1930
|
+
return new chunkDIK74MXX_cjs.EndpointError({
|
|
1650
1931
|
edgeKind,
|
|
1651
1932
|
endpoint: "from",
|
|
1652
1933
|
actualKind: fromKind,
|
|
@@ -1654,11 +1935,8 @@ function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registr
|
|
|
1654
1935
|
});
|
|
1655
1936
|
}
|
|
1656
1937
|
const validToKinds = registration.to.map((node) => node.kind);
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
);
|
|
1660
|
-
if (!toValid) {
|
|
1661
|
-
return new chunkJIEJCTDS_cjs.EndpointError({
|
|
1938
|
+
if (!registry.isAssignableToAny(toKind, validToKinds)) {
|
|
1939
|
+
return new chunkDIK74MXX_cjs.EndpointError({
|
|
1662
1940
|
edgeKind,
|
|
1663
1941
|
endpoint: "to",
|
|
1664
1942
|
actualKind: toKind,
|
|
@@ -1670,7 +1948,7 @@ function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registr
|
|
|
1670
1948
|
function checkDisjointness(nodeId, nodeKind, existingKinds, registry) {
|
|
1671
1949
|
for (const existingKind of existingKinds) {
|
|
1672
1950
|
if (registry.areDisjoint(nodeKind, existingKind)) {
|
|
1673
|
-
return new
|
|
1951
|
+
return new chunkDIK74MXX_cjs.DisjointError({
|
|
1674
1952
|
nodeId,
|
|
1675
1953
|
attemptedKind: nodeKind,
|
|
1676
1954
|
conflictingKind: existingKind
|
|
@@ -1707,7 +1985,7 @@ async function checkUniquenessConstraints(ctx, kind, id, props, constraints) {
|
|
|
1707
1985
|
key
|
|
1708
1986
|
});
|
|
1709
1987
|
if (existing && existing.node_id !== id) {
|
|
1710
|
-
throw new
|
|
1988
|
+
throw new chunkDIK74MXX_cjs.UniquenessError({
|
|
1711
1989
|
constraintName: constraint.name,
|
|
1712
1990
|
kind: kindToCheck,
|
|
1713
1991
|
existingId: existing.node_id,
|
|
@@ -1738,6 +2016,36 @@ async function insertUniquenessEntries(ctx, kind, id, props, constraints) {
|
|
|
1738
2016
|
});
|
|
1739
2017
|
}
|
|
1740
2018
|
}
|
|
2019
|
+
async function insertUniquenessEntriesBatch(ctx, items) {
|
|
2020
|
+
const entries = [];
|
|
2021
|
+
for (const item of items) {
|
|
2022
|
+
for (const constraint of item.constraints) {
|
|
2023
|
+
if (!checkWherePredicate(constraint, item.props)) {
|
|
2024
|
+
continue;
|
|
2025
|
+
}
|
|
2026
|
+
entries.push({
|
|
2027
|
+
graphId: ctx.graphId,
|
|
2028
|
+
nodeKind: item.kind,
|
|
2029
|
+
constraintName: constraint.name,
|
|
2030
|
+
key: computeUniqueKey(
|
|
2031
|
+
item.props,
|
|
2032
|
+
constraint.fields,
|
|
2033
|
+
constraint.collation
|
|
2034
|
+
),
|
|
2035
|
+
nodeId: item.id,
|
|
2036
|
+
concreteKind: item.kind
|
|
2037
|
+
});
|
|
2038
|
+
}
|
|
2039
|
+
}
|
|
2040
|
+
if (entries.length === 0) return;
|
|
2041
|
+
if (ctx.backend.insertUniqueBatch !== void 0) {
|
|
2042
|
+
await ctx.backend.insertUniqueBatch(entries);
|
|
2043
|
+
return;
|
|
2044
|
+
}
|
|
2045
|
+
for (const entry of entries) {
|
|
2046
|
+
await ctx.backend.insertUnique(entry);
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
1741
2049
|
async function deleteUniquenessEntries(ctx, kind, props, constraints) {
|
|
1742
2050
|
for (const constraint of constraints) {
|
|
1743
2051
|
if (!checkWherePredicate(constraint, props)) {
|
|
@@ -1783,7 +2091,7 @@ async function updateUniquenessEntries(ctx, kind, id, oldProps, newProps, constr
|
|
|
1783
2091
|
key: newKey
|
|
1784
2092
|
});
|
|
1785
2093
|
if (existing && existing.node_id !== id) {
|
|
1786
|
-
throw new
|
|
2094
|
+
throw new chunkDIK74MXX_cjs.UniquenessError({
|
|
1787
2095
|
constraintName: constraint.name,
|
|
1788
2096
|
kind: kindToCheck,
|
|
1789
2097
|
existingId: existing.node_id,
|
|
@@ -1840,7 +2148,7 @@ async function enforceNodeDeleteBehavior(ctx, args, backend, policy) {
|
|
|
1840
2148
|
if (connectedEdges.length === 0) return;
|
|
1841
2149
|
switch (behavior) {
|
|
1842
2150
|
case "restrict": {
|
|
1843
|
-
throw new
|
|
2151
|
+
throw new chunkDIK74MXX_cjs.RestrictedDeleteError({
|
|
1844
2152
|
nodeKind: args.kind,
|
|
1845
2153
|
nodeId: args.id,
|
|
1846
2154
|
edgeCount: connectedEdges.length,
|
|
@@ -1849,6 +2157,14 @@ async function enforceNodeDeleteBehavior(ctx, args, backend, policy) {
|
|
|
1849
2157
|
}
|
|
1850
2158
|
case "cascade":
|
|
1851
2159
|
case "disconnect": {
|
|
2160
|
+
const batchDelete = args.mode === "hard" ? backend.hardDeleteEdgesBatch : backend.deleteEdgesBatch;
|
|
2161
|
+
if (batchDelete !== void 0) {
|
|
2162
|
+
await batchDelete.call(backend, {
|
|
2163
|
+
graphId: ctx.graphId,
|
|
2164
|
+
ids: connectedEdges.map((edge) => edge.id)
|
|
2165
|
+
});
|
|
2166
|
+
break;
|
|
2167
|
+
}
|
|
1852
2168
|
for (const edge of connectedEdges) {
|
|
1853
2169
|
await (args.mode === "hard" ? backend.hardDeleteEdge({ graphId: ctx.graphId, id: edge.id }) : backend.deleteEdge({ graphId: ctx.graphId, id: edge.id }));
|
|
1854
2170
|
}
|
|
@@ -1877,8 +2193,35 @@ async function applyNodeInsertSideEffects(ctx, args, backend) {
|
|
|
1877
2193
|
)
|
|
1878
2194
|
]);
|
|
1879
2195
|
}
|
|
2196
|
+
async function applyNodeInsertSideEffectsBatch(ctx, items, backend) {
|
|
2197
|
+
if (items.length === 0) return;
|
|
2198
|
+
await insertUniquenessEntriesBatch(
|
|
2199
|
+
uniquenessContext(ctx, backend),
|
|
2200
|
+
items.map((item) => ({
|
|
2201
|
+
kind: item.kind,
|
|
2202
|
+
id: item.id,
|
|
2203
|
+
props: item.props,
|
|
2204
|
+
constraints: item.uniqueConstraints
|
|
2205
|
+
}))
|
|
2206
|
+
);
|
|
2207
|
+
const byKind = /* @__PURE__ */ new Map();
|
|
2208
|
+
for (const item of items) {
|
|
2209
|
+
const group = byKind.get(item.kind) ?? { schema: item.schema, rows: [] };
|
|
2210
|
+
group.rows.push({ nodeId: item.id, props: item.props });
|
|
2211
|
+
byKind.set(item.kind, group);
|
|
2212
|
+
}
|
|
2213
|
+
await Promise.all(
|
|
2214
|
+
[...byKind.entries()].flatMap(([kind, group]) => {
|
|
2215
|
+
const syncArguments = { graphId: ctx.graphId, nodeKind: kind, backend };
|
|
2216
|
+
return [
|
|
2217
|
+
syncEmbeddingsBatchForKind(syncArguments, group.schema, group.rows),
|
|
2218
|
+
syncFulltextBatchForKind(syncArguments, group.schema, group.rows)
|
|
2219
|
+
];
|
|
2220
|
+
})
|
|
2221
|
+
);
|
|
2222
|
+
}
|
|
1880
2223
|
function parseRowProps(row) {
|
|
1881
|
-
return
|
|
2224
|
+
return chunkX4JBT642_cjs.rowPropsToObject(row.props);
|
|
1882
2225
|
}
|
|
1883
2226
|
async function applyNodeUpdate(ctx, args, backend) {
|
|
1884
2227
|
const { kind, id } = args.existing;
|
|
@@ -2012,16 +2355,16 @@ exports.DEFAULT_SQL_SCHEMA = DEFAULT_SQL_SCHEMA;
|
|
|
2012
2355
|
exports.EMBEDDINGS_CTE_ALIAS = EMBEDDINGS_CTE_ALIAS;
|
|
2013
2356
|
exports.FULLTEXT_CTE_ALIAS = FULLTEXT_CTE_ALIAS;
|
|
2014
2357
|
exports.HYBRID_CANDIDATES_CTE_ALIAS = HYBRID_CANDIDATES_CTE_ALIAS;
|
|
2358
|
+
exports.advanceRevisionClock = advanceRevisionClock;
|
|
2015
2359
|
exports.applyNodeHardDelete = applyNodeHardDelete;
|
|
2016
2360
|
exports.applyNodeInsertSideEffects = applyNodeInsertSideEffects;
|
|
2361
|
+
exports.applyNodeInsertSideEffectsBatch = applyNodeInsertSideEffectsBatch;
|
|
2017
2362
|
exports.applyNodeResurrect = applyNodeResurrect;
|
|
2018
2363
|
exports.applyNodeSoftDelete = applyNodeSoftDelete;
|
|
2019
2364
|
exports.applyNodeUpdate = applyNodeUpdate;
|
|
2020
|
-
exports.asCompiledRowsSql = asCompiledRowsSql;
|
|
2021
|
-
exports.asCompiledSelectSql = asCompiledSelectSql;
|
|
2022
|
-
exports.asCompiledStatementSql = asCompiledStatementSql;
|
|
2023
2365
|
exports.asRecordedInstant = asRecordedInstant;
|
|
2024
2366
|
exports.assertRecordedCaptureTransactionIsolation = assertRecordedCaptureTransactionIsolation;
|
|
2367
|
+
exports.assertRevisionTrackableBackend = assertRevisionTrackableBackend;
|
|
2025
2368
|
exports.assertValidRecordedInstant = assertValidRecordedInstant;
|
|
2026
2369
|
exports.checkCardinality = checkCardinality;
|
|
2027
2370
|
exports.checkDisjointness = checkDisjointness;
|
|
@@ -2037,19 +2380,21 @@ exports.createNodeWriteContext = createNodeWriteContext;
|
|
|
2037
2380
|
exports.createRecordedBackend = createRecordedBackend;
|
|
2038
2381
|
exports.createRecordedReadBinding = createRecordedReadBinding;
|
|
2039
2382
|
exports.createRecordedTransactionScope = createRecordedTransactionScope;
|
|
2383
|
+
exports.createRevisionTrackingUnsafeSqlRef = createRevisionTrackingUnsafeSqlRef;
|
|
2040
2384
|
exports.createSqlSchema = createSqlSchema;
|
|
2041
2385
|
exports.createUniquenessContext = createUniquenessContext;
|
|
2042
2386
|
exports.describeCoordinate = describeCoordinate;
|
|
2043
2387
|
exports.edgeInsertDispatch = edgeInsertDispatch;
|
|
2388
|
+
exports.ensureRevisionOrigin = ensureRevisionOrigin;
|
|
2044
2389
|
exports.generateId = generateId;
|
|
2045
2390
|
exports.getEdgeRowsByIds = getEdgeRowsByIds;
|
|
2046
2391
|
exports.getEmbeddingFields = getEmbeddingFields;
|
|
2047
2392
|
exports.getKindsForUniquenessCheck = getKindsForUniquenessCheck;
|
|
2048
2393
|
exports.getNodeRowsByIds = getNodeRowsByIds;
|
|
2049
|
-
exports.getSearchableFields = getSearchableFields;
|
|
2050
2394
|
exports.lockRecordedGraphWrite = lockRecordedGraphWrite;
|
|
2051
2395
|
exports.nodeInsertDispatch = nodeInsertDispatch;
|
|
2052
2396
|
exports.readRecordedClock = readRecordedClock;
|
|
2397
|
+
exports.readRevisionOrigin = readRevisionOrigin;
|
|
2053
2398
|
exports.recordedBindParamBudget = recordedBindParamBudget;
|
|
2054
2399
|
exports.recordedCaptureRequiresCallbackTransactionError = recordedCaptureRequiresCallbackTransactionError;
|
|
2055
2400
|
exports.recordedReadSchemaFor = recordedReadSchemaFor;
|
|
@@ -2066,5 +2411,6 @@ exports.uncapturedGraphWriteLock = uncapturedGraphWriteLock;
|
|
|
2066
2411
|
exports.validateEdgeEndpoints = validateEdgeEndpoints;
|
|
2067
2412
|
exports.vectorSlotKey = vectorSlotKey;
|
|
2068
2413
|
exports.withRecordedCoordinate = withRecordedCoordinate;
|
|
2069
|
-
|
|
2070
|
-
//# sourceMappingURL=chunk-
|
|
2414
|
+
exports.withRecordedFlushObserver = withRecordedFlushObserver;
|
|
2415
|
+
//# sourceMappingURL=chunk-ZUNQ5BEP.cjs.map
|
|
2416
|
+
//# sourceMappingURL=chunk-ZUNQ5BEP.cjs.map
|