@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,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { withRecordedRelationsPrecondition } from './chunk-
|
|
4
|
-
import { sqlNull } from './chunk-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { ConfigurationError, ValidationError, CardinalityError, EndpointError, DisjointError, UniquenessError, RestrictedDeleteError } from './chunk-TQOYM4LN.js';
|
|
1
|
+
import { asCompiledRowsSql, asCompiledStatementSql } from './chunk-UT3S4SEN.js';
|
|
2
|
+
import { createBackendOverlay, isPresent, rowPropsToObject, groupBy, chunk, sqlValueList, rowPropsToJsonText } from './chunk-IU46OHVW.js';
|
|
3
|
+
import { validateCanonicalIsoDate, withRecordedRelationsPrecondition, nowIso } from './chunk-JFUPDJXD.js';
|
|
4
|
+
import { MAX_PG_IDENTIFIER_LENGTH, sqlNull } from './chunk-OHMP6N2J.js';
|
|
5
|
+
import { resolveEmbeddingFields, getSearchableFields, DEFAULT_SEARCHABLE_LANGUAGE } from './chunk-KBGQIPRQ.js';
|
|
6
|
+
import { ConfigurationError, ValidationError, CardinalityError, EndpointError, DisjointError, UniquenessError, RestrictedDeleteError } from './chunk-WI7ISNQF.js';
|
|
8
7
|
import { sql } from 'drizzle-orm';
|
|
9
8
|
import { nanoid } from 'nanoid';
|
|
10
9
|
|
|
@@ -95,17 +94,6 @@ function coordinateContext(coordinate) {
|
|
|
95
94
|
...coordinate.recorded === void 0 ? {} : { recordedAsOf: coordinate.recorded.asOf }
|
|
96
95
|
};
|
|
97
96
|
}
|
|
98
|
-
|
|
99
|
-
// src/query/sql-intent.ts
|
|
100
|
-
function asCompiledRowsSql(query) {
|
|
101
|
-
return query;
|
|
102
|
-
}
|
|
103
|
-
function asCompiledSelectSql(query) {
|
|
104
|
-
return asCompiledRowsSql(query);
|
|
105
|
-
}
|
|
106
|
-
function asCompiledStatementSql(query) {
|
|
107
|
-
return query;
|
|
108
|
-
}
|
|
109
97
|
var SqlSchemaDescriptor = class {
|
|
110
98
|
// Private field gives SqlSchema nominal identity; runtime checks use instanceof.
|
|
111
99
|
#brand = true;
|
|
@@ -115,6 +103,7 @@ var SqlSchemaDescriptor = class {
|
|
|
115
103
|
recordedNodesTable;
|
|
116
104
|
recordedEdgesTable;
|
|
117
105
|
recordedClockTable;
|
|
106
|
+
revisionOriginsTable;
|
|
118
107
|
fulltextTable;
|
|
119
108
|
constructor(fields) {
|
|
120
109
|
this.tables = fields.tables;
|
|
@@ -123,6 +112,7 @@ var SqlSchemaDescriptor = class {
|
|
|
123
112
|
this.recordedNodesTable = fields.recordedNodesTable;
|
|
124
113
|
this.recordedEdgesTable = fields.recordedEdgesTable;
|
|
125
114
|
this.recordedClockTable = fields.recordedClockTable;
|
|
115
|
+
this.revisionOriginsTable = fields.revisionOriginsTable;
|
|
126
116
|
this.fulltextTable = fields.fulltextTable;
|
|
127
117
|
void this.#brand;
|
|
128
118
|
Object.freeze(this);
|
|
@@ -134,6 +124,7 @@ var DEFAULT_TABLE_NAMES = {
|
|
|
134
124
|
recordedNodes: "typegraph_recorded_nodes",
|
|
135
125
|
recordedEdges: "typegraph_recorded_edges",
|
|
136
126
|
recordedClock: "typegraph_recorded_clock",
|
|
127
|
+
revisionOrigins: "typegraph_revision_origins",
|
|
137
128
|
fulltext: "typegraph_node_fulltext",
|
|
138
129
|
uniques: "typegraph_node_uniques"
|
|
139
130
|
};
|
|
@@ -144,6 +135,7 @@ function resolveTableNames(names) {
|
|
|
144
135
|
recordedNodes: names.recordedNodes ?? DEFAULT_TABLE_NAMES.recordedNodes,
|
|
145
136
|
recordedEdges: names.recordedEdges ?? DEFAULT_TABLE_NAMES.recordedEdges,
|
|
146
137
|
recordedClock: names.recordedClock ?? DEFAULT_TABLE_NAMES.recordedClock,
|
|
138
|
+
revisionOrigins: names.revisionOrigins ?? DEFAULT_TABLE_NAMES.revisionOrigins,
|
|
147
139
|
fulltext: names.fulltext ?? DEFAULT_TABLE_NAMES.fulltext,
|
|
148
140
|
uniques: names.uniques ?? DEFAULT_TABLE_NAMES.uniques
|
|
149
141
|
};
|
|
@@ -190,6 +182,7 @@ function createSqlSchema(names = {}) {
|
|
|
190
182
|
validateTableName(tables.recordedNodes, "recordedNodes");
|
|
191
183
|
validateTableName(tables.recordedEdges, "recordedEdges");
|
|
192
184
|
validateTableName(tables.recordedClock, "recordedClock");
|
|
185
|
+
validateTableName(tables.revisionOrigins, "revisionOrigins");
|
|
193
186
|
validateTableName(tables.fulltext, "fulltext");
|
|
194
187
|
validateTableName(tables.uniques, "uniques");
|
|
195
188
|
return freezeSqlSchema({
|
|
@@ -199,6 +192,7 @@ function createSqlSchema(names = {}) {
|
|
|
199
192
|
recordedNodesTable: sql.raw(quoteIdentifier(tables.recordedNodes)),
|
|
200
193
|
recordedEdgesTable: sql.raw(quoteIdentifier(tables.recordedEdges)),
|
|
201
194
|
recordedClockTable: sql.raw(quoteIdentifier(tables.recordedClock)),
|
|
195
|
+
revisionOriginsTable: sql.raw(quoteIdentifier(tables.revisionOrigins)),
|
|
202
196
|
fulltextTable: sql.raw(quoteIdentifier(tables.fulltext))
|
|
203
197
|
});
|
|
204
198
|
}
|
|
@@ -279,6 +273,7 @@ function recordedReadSqlSchema(binding) {
|
|
|
279
273
|
recordedNodesTable: schema.recordedNodesTable,
|
|
280
274
|
recordedEdgesTable: schema.recordedEdgesTable,
|
|
281
275
|
recordedClockTable: schema.recordedClockTable,
|
|
276
|
+
revisionOriginsTable: schema.revisionOriginsTable,
|
|
282
277
|
fulltextTable: schema.fulltextTable
|
|
283
278
|
});
|
|
284
279
|
}
|
|
@@ -360,10 +355,13 @@ async function assertRecordedCaptureTransactionIsolation(target) {
|
|
|
360
355
|
if (isSupportedRecordedIsolationLevel(isolationLevel)) return;
|
|
361
356
|
throw unsupportedPostgresIsolationError(isolationLevel);
|
|
362
357
|
}
|
|
363
|
-
function recordedCaptureRequiresCallbackTransactionError(details) {
|
|
358
|
+
function recordedCaptureRequiresCallbackTransactionError(details = {}) {
|
|
364
359
|
return new ConfigurationError(
|
|
365
360
|
"withTransaction() has no recorded-time capture flush point when history is enabled.",
|
|
366
|
-
|
|
361
|
+
{
|
|
362
|
+
...details,
|
|
363
|
+
code: "RECORDED_CAPTURE_REQUIRES_CALLBACK_TRANSACTION"
|
|
364
|
+
},
|
|
367
365
|
{
|
|
368
366
|
suggestion: "Use store.withRecordedTransaction(externalTx, async (tx) => ...) so TypeGraph can flush capture before the caller commits."
|
|
369
367
|
}
|
|
@@ -372,50 +370,72 @@ function recordedCaptureRequiresCallbackTransactionError(details) {
|
|
|
372
370
|
function historyUnsafeRawWriteError(surface) {
|
|
373
371
|
return new ConfigurationError(
|
|
374
372
|
`${surface} is not available when history capture is enabled because raw SQL writes bypass recorded-time capture.`,
|
|
375
|
-
{
|
|
373
|
+
{
|
|
374
|
+
code: "RECORDED_CAPTURE_RAW_SQL_DISABLED"
|
|
375
|
+
},
|
|
376
376
|
{
|
|
377
377
|
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."
|
|
378
378
|
}
|
|
379
379
|
);
|
|
380
380
|
}
|
|
381
|
+
function revisionTrackingUnsafeRawWriteError(surface) {
|
|
382
|
+
return new ConfigurationError(
|
|
383
|
+
`${surface} is not available when revision tracking is enabled because raw SQL writes bypass the revision anchor.`,
|
|
384
|
+
{
|
|
385
|
+
code: "REVISION_TRACKING_RAW_SQL_DISABLED"
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
suggestion: "Run graph writes through store.nodes/store.edges (or tx.nodes/tx.edges inside a transaction), so TypeGraph can advance the revision anchor."
|
|
389
|
+
}
|
|
390
|
+
);
|
|
391
|
+
}
|
|
381
392
|
function failHistoryUnsafeSqlRef() {
|
|
382
393
|
throw historyUnsafeRawWriteError("tx.sql");
|
|
383
394
|
}
|
|
395
|
+
function failRevisionTrackingUnsafeSqlRef() {
|
|
396
|
+
throw revisionTrackingUnsafeRawWriteError("tx.sql");
|
|
397
|
+
}
|
|
384
398
|
function createHistoryUnsafeSqlRef() {
|
|
399
|
+
return createUnsafeSqlRef(failHistoryUnsafeSqlRef);
|
|
400
|
+
}
|
|
401
|
+
function createRevisionTrackingUnsafeSqlRef() {
|
|
402
|
+
return createUnsafeSqlRef(failRevisionTrackingUnsafeSqlRef);
|
|
403
|
+
}
|
|
404
|
+
function createUnsafeSqlRef(fail) {
|
|
385
405
|
return new Proxy(
|
|
386
|
-
function
|
|
387
|
-
return
|
|
406
|
+
function unsafeSqlRef() {
|
|
407
|
+
return fail();
|
|
388
408
|
},
|
|
389
409
|
{
|
|
390
410
|
get() {
|
|
391
|
-
return
|
|
411
|
+
return fail();
|
|
392
412
|
},
|
|
393
413
|
apply() {
|
|
394
|
-
return
|
|
414
|
+
return fail();
|
|
395
415
|
},
|
|
396
416
|
set() {
|
|
397
|
-
return
|
|
417
|
+
return fail();
|
|
398
418
|
},
|
|
399
419
|
defineProperty() {
|
|
400
|
-
return
|
|
420
|
+
return fail();
|
|
401
421
|
},
|
|
402
422
|
deleteProperty() {
|
|
403
|
-
return
|
|
423
|
+
return fail();
|
|
404
424
|
},
|
|
405
425
|
// Enumeration / inspection traps too, so spreading (`{...tx.sql}`),
|
|
406
426
|
// `Object.keys`, `in`, and prototype reads also fail loudly rather than
|
|
407
427
|
// silently yielding an empty object that reads as "no raw handle".
|
|
408
428
|
has() {
|
|
409
|
-
return
|
|
429
|
+
return fail();
|
|
410
430
|
},
|
|
411
431
|
ownKeys() {
|
|
412
|
-
return
|
|
432
|
+
return fail();
|
|
413
433
|
},
|
|
414
434
|
getOwnPropertyDescriptor() {
|
|
415
|
-
return
|
|
435
|
+
return fail();
|
|
416
436
|
},
|
|
417
437
|
getPrototypeOf() {
|
|
418
|
-
return
|
|
438
|
+
return fail();
|
|
419
439
|
}
|
|
420
440
|
}
|
|
421
441
|
);
|
|
@@ -476,6 +496,44 @@ function assertCapturableBackend(backend) {
|
|
|
476
496
|
);
|
|
477
497
|
}
|
|
478
498
|
}
|
|
499
|
+
function assertRevisionTrackableBackend(backend) {
|
|
500
|
+
if (!backend.capabilities.transactions) {
|
|
501
|
+
throw new ConfigurationError(
|
|
502
|
+
"revisionTracking: true requires a backend with transaction support.",
|
|
503
|
+
{ dialect: backend.dialect },
|
|
504
|
+
{
|
|
505
|
+
suggestion: "Use a transactional SQLite/PostgreSQL backend or leave revision tracking disabled."
|
|
506
|
+
}
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
if (backend.executeStatement === void 0) {
|
|
510
|
+
throw new ConfigurationError(
|
|
511
|
+
"revisionTracking: true requires a backend that supports executeStatement.",
|
|
512
|
+
{ dialect: backend.dialect },
|
|
513
|
+
{
|
|
514
|
+
suggestion: "Use a built-in SQLite/PostgreSQL backend, or implement executeStatement so TypeGraph can advance the revision clock."
|
|
515
|
+
}
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
if (backend.tableNames === void 0) {
|
|
519
|
+
throw new ConfigurationError(
|
|
520
|
+
"revisionTracking: true requires a backend that exposes tableNames.",
|
|
521
|
+
{ dialect: backend.dialect },
|
|
522
|
+
{
|
|
523
|
+
suggestion: "Use a built-in SQLite/PostgreSQL backend, or set tableNames so TypeGraph can address the revision clock relation."
|
|
524
|
+
}
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
if (backend.ensureRevisionOriginsTable === void 0) {
|
|
528
|
+
throw new ConfigurationError(
|
|
529
|
+
"revisionTracking: true requires a backend that can bootstrap revision origins.",
|
|
530
|
+
{ dialect: backend.dialect },
|
|
531
|
+
{
|
|
532
|
+
suggestion: "Use a built-in SQLite/PostgreSQL backend, or implement ensureRevisionOriginsTable so TypeGraph can durably namespace revision anchors."
|
|
533
|
+
}
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
479
537
|
|
|
480
538
|
// src/store/recorded-capture/clock.ts
|
|
481
539
|
var RECORDED_MIN = "1970-01-01T00:00:00.000Z";
|
|
@@ -506,19 +564,37 @@ function graphWriteLockEvidence() {
|
|
|
506
564
|
function uncapturedGraphWriteLock() {
|
|
507
565
|
return graphWriteLockEvidence();
|
|
508
566
|
}
|
|
509
|
-
|
|
510
|
-
|
|
567
|
+
function createRecordedGraphLockMemo() {
|
|
568
|
+
return /* @__PURE__ */ new Map();
|
|
569
|
+
}
|
|
570
|
+
var recordedGraphLockMemos = /* @__PURE__ */ new WeakMap();
|
|
571
|
+
function registerRecordedGraphLockMemo(backend, memo) {
|
|
572
|
+
recordedGraphLockMemos.set(backend, memo);
|
|
573
|
+
}
|
|
574
|
+
async function acquireRecordedGraphWriteLock(target, graphId) {
|
|
511
575
|
await target.execute(
|
|
512
576
|
asCompiledRowsSql(recordedGraphWriteAdvisoryLockSql(graphId))
|
|
513
577
|
);
|
|
514
|
-
return graphWriteLockEvidence();
|
|
515
578
|
}
|
|
516
|
-
async function
|
|
517
|
-
if (target.dialect !== "postgres") return;
|
|
518
|
-
const
|
|
519
|
-
|
|
520
|
-
await
|
|
579
|
+
async function lockRecordedGraphWrite(target, graphId, memo) {
|
|
580
|
+
if (target.dialect !== "postgres") return graphWriteLockEvidence();
|
|
581
|
+
const effectiveMemo = memo ?? recordedGraphLockMemos.get(target);
|
|
582
|
+
if (effectiveMemo === void 0) {
|
|
583
|
+
await acquireRecordedGraphWriteLock(target, graphId);
|
|
584
|
+
return graphWriteLockEvidence();
|
|
585
|
+
}
|
|
586
|
+
let pending = effectiveMemo.get(graphId);
|
|
587
|
+
if (pending === void 0) {
|
|
588
|
+
pending = acquireRecordedGraphWriteLock(target, graphId).catch(
|
|
589
|
+
(error) => {
|
|
590
|
+
effectiveMemo.delete(graphId);
|
|
591
|
+
throw error;
|
|
592
|
+
}
|
|
593
|
+
);
|
|
594
|
+
effectiveMemo.set(graphId, pending);
|
|
521
595
|
}
|
|
596
|
+
await pending;
|
|
597
|
+
return graphWriteLockEvidence();
|
|
522
598
|
}
|
|
523
599
|
function failInvalidClockTimestamp(value) {
|
|
524
600
|
throw new ConfigurationError(
|
|
@@ -574,6 +650,53 @@ async function readRecordedClock(target, schema, graphId) {
|
|
|
574
650
|
const first = rows[0];
|
|
575
651
|
return first === void 0 ? void 0 : toCanonicalIso(first.recorded_at);
|
|
576
652
|
}
|
|
653
|
+
async function readRevisionOrigin(target, schema, graphId) {
|
|
654
|
+
const rows = await target.execute(
|
|
655
|
+
asCompiledRowsSql(sql`
|
|
656
|
+
SELECT origin
|
|
657
|
+
FROM ${schema.revisionOriginsTable}
|
|
658
|
+
WHERE graph_id = ${graphId}
|
|
659
|
+
`)
|
|
660
|
+
);
|
|
661
|
+
const first = rows[0];
|
|
662
|
+
if (first === void 0) return void 0;
|
|
663
|
+
if (typeof first.origin !== "string" || first.origin.length === 0) {
|
|
664
|
+
throw new ConfigurationError(
|
|
665
|
+
"Revision origin row contained an invalid origin",
|
|
666
|
+
{ graphId, origin: first.origin }
|
|
667
|
+
);
|
|
668
|
+
}
|
|
669
|
+
return first.origin;
|
|
670
|
+
}
|
|
671
|
+
async function ensureRevisionOrigin(target, schema, graphId) {
|
|
672
|
+
const ensureTable = target.ensureRevisionOriginsTable;
|
|
673
|
+
if (ensureTable === void 0) {
|
|
674
|
+
throw new ConfigurationError(
|
|
675
|
+
"Revision tracking requires a backend that can bootstrap revision origins.",
|
|
676
|
+
{ dialect: target.dialect },
|
|
677
|
+
{
|
|
678
|
+
suggestion: "Use a built-in SQLite/PostgreSQL backend, or implement ensureRevisionOriginsTable on the custom backend."
|
|
679
|
+
}
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
await ensureTable();
|
|
683
|
+
const existing = await readRevisionOrigin(target, schema, graphId);
|
|
684
|
+
if (existing !== void 0) return existing;
|
|
685
|
+
await executeStatement(
|
|
686
|
+
target,
|
|
687
|
+
sql`
|
|
688
|
+
INSERT INTO ${schema.revisionOriginsTable} (graph_id, origin)
|
|
689
|
+
VALUES (${graphId}, ${generateId()})
|
|
690
|
+
ON CONFLICT (graph_id) DO NOTHING
|
|
691
|
+
`
|
|
692
|
+
);
|
|
693
|
+
const origin = await readRevisionOrigin(target, schema, graphId);
|
|
694
|
+
if (origin !== void 0) return origin;
|
|
695
|
+
throw new ConfigurationError(
|
|
696
|
+
"Revision origin was not persisted after initialization.",
|
|
697
|
+
{ graphId, dialect: target.dialect }
|
|
698
|
+
);
|
|
699
|
+
}
|
|
577
700
|
async function writeRecordedClock(target, schema, graphId, recordedAt) {
|
|
578
701
|
await executeStatement(
|
|
579
702
|
target,
|
|
@@ -601,9 +724,9 @@ async function lockRecordedClock(target, schema, graphId, ownsWriteLock) {
|
|
|
601
724
|
`
|
|
602
725
|
);
|
|
603
726
|
}
|
|
604
|
-
async function allocateRecordedCommit(target, schema, graphId, ownsWriteLock) {
|
|
727
|
+
async function allocateRecordedCommit(target, schema, graphId, ownsWriteLock, previousRevision) {
|
|
605
728
|
await lockRecordedClock(target, schema, graphId, ownsWriteLock);
|
|
606
|
-
const previous = await readRecordedClock(target, schema, graphId);
|
|
729
|
+
const previous = previousRevision ?? await readRecordedClock(target, schema, graphId);
|
|
607
730
|
const recordedCommitTime = nextRecordedCommitTime(previous);
|
|
608
731
|
if (!Number.isFinite(recordedCommitTime) || recordedCommitTime >= RECORDED_MAX_TIME) {
|
|
609
732
|
throw new ConfigurationError(
|
|
@@ -618,6 +741,15 @@ async function allocateRecordedCommit(target, schema, graphId, ownsWriteLock) {
|
|
|
618
741
|
await writeRecordedClock(target, schema, graphId, recordedCommit);
|
|
619
742
|
return recordedCommit;
|
|
620
743
|
}
|
|
744
|
+
async function advanceRevisionClock(target, schema, graphId, ownsWriteLock, previousRevision) {
|
|
745
|
+
return allocateRecordedCommit(
|
|
746
|
+
target,
|
|
747
|
+
schema,
|
|
748
|
+
graphId,
|
|
749
|
+
ownsWriteLock,
|
|
750
|
+
previousRevision
|
|
751
|
+
);
|
|
752
|
+
}
|
|
621
753
|
|
|
622
754
|
// src/store/insert-dispatch.ts
|
|
623
755
|
function nodeInsertDispatch(backend) {
|
|
@@ -767,7 +899,7 @@ function recordedCommonCells() {
|
|
|
767
899
|
graph_id: (row) => sql`${row.graph_id}`,
|
|
768
900
|
id: (row) => sql`${row.id}`,
|
|
769
901
|
kind: (row) => sql`${row.kind}`,
|
|
770
|
-
props: (row) => sql`${row.props}`,
|
|
902
|
+
props: (row) => sql`${rowPropsToJsonText(row.props)}`,
|
|
771
903
|
valid_from: (row) => sql`${sqlNull(row.valid_from)}`,
|
|
772
904
|
valid_to: (row) => sql`${sqlNull(row.valid_to)}`,
|
|
773
905
|
created_at: (row) => sql`${row.created_at}`,
|
|
@@ -1028,6 +1160,21 @@ async function queryConnectedEdgeIds(target, schema, params) {
|
|
|
1028
1160
|
}
|
|
1029
1161
|
|
|
1030
1162
|
// src/store/recorded-capture.ts
|
|
1163
|
+
var RECORDED_FLUSH_OBSERVER = /* @__PURE__ */ Symbol("typegraph.recordedFlushObserver");
|
|
1164
|
+
function readRecordedFlushObserver(options) {
|
|
1165
|
+
return options?.[RECORDED_FLUSH_OBSERVER];
|
|
1166
|
+
}
|
|
1167
|
+
function stripRecordedFlushObserver(options) {
|
|
1168
|
+
if (options === void 0) return void 0;
|
|
1169
|
+
const { [RECORDED_FLUSH_OBSERVER]: _observer, ...backendOptions } = options;
|
|
1170
|
+
return backendOptions;
|
|
1171
|
+
}
|
|
1172
|
+
function withRecordedFlushObserver(options, observer) {
|
|
1173
|
+
return {
|
|
1174
|
+
...stripRecordedFlushObserver(options),
|
|
1175
|
+
[RECORDED_FLUSH_OBSERVER]: observer
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1031
1178
|
function nodeIdentityKey(graphId, kind, id) {
|
|
1032
1179
|
return `${graphId}\0${kind}\0${id}`;
|
|
1033
1180
|
}
|
|
@@ -1046,22 +1193,32 @@ function edgeParamsIdentityKey(params) {
|
|
|
1046
1193
|
function edgeRowIdentityKey(row) {
|
|
1047
1194
|
return edgeIdentityKey(row.graph_id, row.id);
|
|
1048
1195
|
}
|
|
1196
|
+
function recordedCaptureSealedError(details) {
|
|
1197
|
+
return new ConfigurationError(
|
|
1198
|
+
"Recorded-time capture session is sealed: a graph write happened after the transaction's capture was flushed.",
|
|
1199
|
+
details,
|
|
1200
|
+
{
|
|
1201
|
+
suggestion: "Perform all writes inside the withRecordedTransaction callback; do not reuse the transaction context after it returns."
|
|
1202
|
+
}
|
|
1203
|
+
);
|
|
1204
|
+
}
|
|
1049
1205
|
function createRecordedCaptureSession() {
|
|
1050
1206
|
const touched = /* @__PURE__ */ new Map();
|
|
1051
1207
|
let sealed = false;
|
|
1052
1208
|
function touch(entity) {
|
|
1053
1209
|
if (sealed) {
|
|
1054
|
-
throw
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
}
|
|
1060
|
-
);
|
|
1210
|
+
throw recordedCaptureSealedError({
|
|
1211
|
+
entity: entity.entity,
|
|
1212
|
+
graphId: entity.graphId,
|
|
1213
|
+
id: entity.id
|
|
1214
|
+
});
|
|
1061
1215
|
}
|
|
1062
1216
|
touched.set(entityKey(entity), entity);
|
|
1063
1217
|
}
|
|
1064
1218
|
return {
|
|
1219
|
+
assertOpen() {
|
|
1220
|
+
if (sealed) throw recordedCaptureSealedError({});
|
|
1221
|
+
},
|
|
1065
1222
|
touchNode(graphId, kind, id, afterImage) {
|
|
1066
1223
|
touch({ entity: "node", graphId, kind, id, afterImage });
|
|
1067
1224
|
},
|
|
@@ -1079,7 +1236,8 @@ function createRecordedCaptureSession() {
|
|
|
1079
1236
|
);
|
|
1080
1237
|
}
|
|
1081
1238
|
sealed = true;
|
|
1082
|
-
if (touched.size === 0) return;
|
|
1239
|
+
if (touched.size === 0) return /* @__PURE__ */ new Map();
|
|
1240
|
+
const recordedByGraph = /* @__PURE__ */ new Map();
|
|
1083
1241
|
const byGraph = groupBy(touched.values(), (entity) => entity.graphId);
|
|
1084
1242
|
for (const [graphId, entities] of byGraph) {
|
|
1085
1243
|
const recordedCommit = await allocateRecordedCommit(
|
|
@@ -1088,6 +1246,7 @@ function createRecordedCaptureSession() {
|
|
|
1088
1246
|
graphId,
|
|
1089
1247
|
ownsWriteLock
|
|
1090
1248
|
);
|
|
1249
|
+
recordedByGraph.set(graphId, recordedCommit);
|
|
1091
1250
|
const nodes = entities.filter(
|
|
1092
1251
|
(entity) => entity.entity === "node"
|
|
1093
1252
|
);
|
|
@@ -1098,24 +1257,29 @@ function createRecordedCaptureSession() {
|
|
|
1098
1257
|
await flushEdges(target, schema, graphId, edges, recordedCommit);
|
|
1099
1258
|
}
|
|
1100
1259
|
touched.clear();
|
|
1260
|
+
return recordedByGraph;
|
|
1101
1261
|
}
|
|
1102
1262
|
};
|
|
1103
1263
|
}
|
|
1104
1264
|
function createRecordedTransactionBackend(target, session, schema) {
|
|
1105
1265
|
const nodeDispatch = nodeInsertDispatch(target);
|
|
1106
1266
|
const edgeDispatch = edgeInsertDispatch(target);
|
|
1267
|
+
const graphLocks = createRecordedGraphLockMemo();
|
|
1107
1268
|
async function lockGraph(graphId) {
|
|
1108
|
-
await lockRecordedGraphWrite(target, graphId);
|
|
1269
|
+
await lockRecordedGraphWrite(target, graphId, graphLocks);
|
|
1109
1270
|
}
|
|
1110
1271
|
async function lockGraphs(params) {
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
)
|
|
1272
|
+
const graphIds = [
|
|
1273
|
+
...new Set(params.map((parameter) => parameter.graphId))
|
|
1274
|
+
].toSorted();
|
|
1275
|
+
for (const graphId of graphIds) {
|
|
1276
|
+
await lockRecordedGraphWrite(target, graphId, graphLocks);
|
|
1277
|
+
}
|
|
1115
1278
|
}
|
|
1116
|
-
|
|
1279
|
+
const overlay = createBackendOverlay(target, {
|
|
1117
1280
|
...rawWriteGuards(target, "tx.backend"),
|
|
1118
1281
|
async insertNode(params) {
|
|
1282
|
+
session.assertOpen();
|
|
1119
1283
|
await lockGraph(params.graphId);
|
|
1120
1284
|
const row = await target.insertNode(params);
|
|
1121
1285
|
session.touchNode(params.graphId, params.kind, params.id, row);
|
|
@@ -1123,6 +1287,7 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
1123
1287
|
},
|
|
1124
1288
|
...target.insertNodeNoReturn === void 0 ? {} : {
|
|
1125
1289
|
async insertNodeNoReturn(params) {
|
|
1290
|
+
session.assertOpen();
|
|
1126
1291
|
await lockGraph(params.graphId);
|
|
1127
1292
|
await runInsertNoReturn(nodeDispatch, params);
|
|
1128
1293
|
session.touchNode(params.graphId, params.kind, params.id);
|
|
@@ -1130,6 +1295,7 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
1130
1295
|
},
|
|
1131
1296
|
...target.insertNodesBatch === void 0 ? {} : {
|
|
1132
1297
|
async insertNodesBatch(params) {
|
|
1298
|
+
session.assertOpen();
|
|
1133
1299
|
await lockGraphs(params);
|
|
1134
1300
|
await runInsertBatch(nodeDispatch, params);
|
|
1135
1301
|
for (const node of params) {
|
|
@@ -1139,6 +1305,7 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
1139
1305
|
},
|
|
1140
1306
|
...target.insertNodesBatchReturning === void 0 ? {} : {
|
|
1141
1307
|
async insertNodesBatchReturning(params) {
|
|
1308
|
+
session.assertOpen();
|
|
1142
1309
|
await lockGraphs(params);
|
|
1143
1310
|
const rows = await runInsertBatchReturning(nodeDispatch, params);
|
|
1144
1311
|
const rowsByIdentity = new Map(
|
|
@@ -1156,17 +1323,20 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
1156
1323
|
}
|
|
1157
1324
|
},
|
|
1158
1325
|
async updateNode(params) {
|
|
1326
|
+
session.assertOpen();
|
|
1159
1327
|
await lockGraph(params.graphId);
|
|
1160
1328
|
const row = await target.updateNode(params);
|
|
1161
1329
|
session.touchNode(params.graphId, params.kind, params.id, row);
|
|
1162
1330
|
return row;
|
|
1163
1331
|
},
|
|
1164
1332
|
async deleteNode(params) {
|
|
1333
|
+
session.assertOpen();
|
|
1165
1334
|
await lockGraph(params.graphId);
|
|
1166
1335
|
await target.deleteNode(params);
|
|
1167
1336
|
session.touchNode(params.graphId, params.kind, params.id);
|
|
1168
1337
|
},
|
|
1169
1338
|
async hardDeleteNode(params) {
|
|
1339
|
+
session.assertOpen();
|
|
1170
1340
|
await lockGraph(params.graphId);
|
|
1171
1341
|
const connectedEdgeIds = await queryConnectedEdgeIds(
|
|
1172
1342
|
target,
|
|
@@ -1180,6 +1350,7 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
1180
1350
|
}
|
|
1181
1351
|
},
|
|
1182
1352
|
async insertEdge(params) {
|
|
1353
|
+
session.assertOpen();
|
|
1183
1354
|
await lockGraph(params.graphId);
|
|
1184
1355
|
const row = await target.insertEdge(params);
|
|
1185
1356
|
session.touchEdge(params.graphId, params.id, row);
|
|
@@ -1187,6 +1358,7 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
1187
1358
|
},
|
|
1188
1359
|
...target.insertEdgeNoReturn === void 0 ? {} : {
|
|
1189
1360
|
async insertEdgeNoReturn(params) {
|
|
1361
|
+
session.assertOpen();
|
|
1190
1362
|
await lockGraph(params.graphId);
|
|
1191
1363
|
await runInsertNoReturn(edgeDispatch, params);
|
|
1192
1364
|
session.touchEdge(params.graphId, params.id);
|
|
@@ -1194,6 +1366,7 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
1194
1366
|
},
|
|
1195
1367
|
...target.insertEdgesBatch === void 0 ? {} : {
|
|
1196
1368
|
async insertEdgesBatch(params) {
|
|
1369
|
+
session.assertOpen();
|
|
1197
1370
|
await lockGraphs(params);
|
|
1198
1371
|
await runInsertBatch(edgeDispatch, params);
|
|
1199
1372
|
for (const edge of params) {
|
|
@@ -1203,6 +1376,7 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
1203
1376
|
},
|
|
1204
1377
|
...target.insertEdgesBatchReturning === void 0 ? {} : {
|
|
1205
1378
|
async insertEdgesBatchReturning(params) {
|
|
1379
|
+
session.assertOpen();
|
|
1206
1380
|
await lockGraphs(params);
|
|
1207
1381
|
const rows = await runInsertBatchReturning(edgeDispatch, params);
|
|
1208
1382
|
const rowsByIdentity = new Map(
|
|
@@ -1219,22 +1393,47 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
1219
1393
|
}
|
|
1220
1394
|
},
|
|
1221
1395
|
async updateEdge(params) {
|
|
1396
|
+
session.assertOpen();
|
|
1222
1397
|
await lockGraph(params.graphId);
|
|
1223
1398
|
const row = await target.updateEdge(params);
|
|
1224
1399
|
session.touchEdge(params.graphId, params.id, row);
|
|
1225
1400
|
return row;
|
|
1226
1401
|
},
|
|
1227
1402
|
async deleteEdge(params) {
|
|
1403
|
+
session.assertOpen();
|
|
1228
1404
|
await lockGraph(params.graphId);
|
|
1229
1405
|
await target.deleteEdge(params);
|
|
1230
1406
|
session.touchEdge(params.graphId, params.id);
|
|
1231
1407
|
},
|
|
1232
1408
|
async hardDeleteEdge(params) {
|
|
1409
|
+
session.assertOpen();
|
|
1233
1410
|
await lockGraph(params.graphId);
|
|
1234
1411
|
await target.hardDeleteEdge(params);
|
|
1235
1412
|
session.touchEdge(params.graphId, params.id);
|
|
1413
|
+
},
|
|
1414
|
+
...target.deleteEdgesBatch === void 0 ? {} : {
|
|
1415
|
+
async deleteEdgesBatch(params) {
|
|
1416
|
+
session.assertOpen();
|
|
1417
|
+
await lockGraph(params.graphId);
|
|
1418
|
+
await target.deleteEdgesBatch(params);
|
|
1419
|
+
for (const id of params.ids) {
|
|
1420
|
+
session.touchEdge(params.graphId, id);
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
},
|
|
1424
|
+
...target.hardDeleteEdgesBatch === void 0 ? {} : {
|
|
1425
|
+
async hardDeleteEdgesBatch(params) {
|
|
1426
|
+
session.assertOpen();
|
|
1427
|
+
await lockGraph(params.graphId);
|
|
1428
|
+
await target.hardDeleteEdgesBatch(params);
|
|
1429
|
+
for (const id of params.ids) {
|
|
1430
|
+
session.touchEdge(params.graphId, id);
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1236
1433
|
}
|
|
1237
1434
|
});
|
|
1435
|
+
registerRecordedGraphLockMemo(overlay, graphLocks);
|
|
1436
|
+
return overlay;
|
|
1238
1437
|
}
|
|
1239
1438
|
function createRecordedTransactionScope(target, schema, ownsWriteLock = false) {
|
|
1240
1439
|
requireCaptureStatements(target);
|
|
@@ -1243,7 +1442,7 @@ function createRecordedTransactionScope(target, schema, ownsWriteLock = false) {
|
|
|
1243
1442
|
return {
|
|
1244
1443
|
backend: createRecordedTransactionBackend(target, session, resolvedSchema),
|
|
1245
1444
|
async flush() {
|
|
1246
|
-
|
|
1445
|
+
return withRecordedRelationsPrecondition(
|
|
1247
1446
|
session.flush(target, resolvedSchema, ownsWriteLock),
|
|
1248
1447
|
{ dialect: target.dialect, surface: "capture-flush" }
|
|
1249
1448
|
);
|
|
@@ -1331,15 +1530,28 @@ function createRecordedBackend(backend, schema) {
|
|
|
1331
1530
|
async hardDeleteEdge(params) {
|
|
1332
1531
|
await capture((target) => target.hardDeleteEdge(params));
|
|
1333
1532
|
},
|
|
1533
|
+
...backend.deleteEdgesBatch === void 0 ? {} : {
|
|
1534
|
+
async deleteEdgesBatch(params) {
|
|
1535
|
+
await capture((target) => target.deleteEdgesBatch(params));
|
|
1536
|
+
}
|
|
1537
|
+
},
|
|
1538
|
+
...backend.hardDeleteEdgesBatch === void 0 ? {} : {
|
|
1539
|
+
async hardDeleteEdgesBatch(params) {
|
|
1540
|
+
await capture((target) => target.hardDeleteEdgesBatch(params));
|
|
1541
|
+
}
|
|
1542
|
+
},
|
|
1334
1543
|
async transaction(fn, options) {
|
|
1335
|
-
|
|
1544
|
+
const observer = readRecordedFlushObserver(options);
|
|
1545
|
+
const backendOptions = stripRecordedFlushObserver(options);
|
|
1546
|
+
assertRequestedRecordedIsolation(backend, backendOptions);
|
|
1336
1547
|
return backend.transaction(async (target) => {
|
|
1337
1548
|
await assertRecordedCaptureTransactionIsolation(target);
|
|
1338
1549
|
const scope = createRecordedTransactionScope(target, schema, true);
|
|
1339
1550
|
const result = await fn(scope.backend, createHistoryUnsafeSqlRef());
|
|
1340
|
-
await scope.flush();
|
|
1551
|
+
const instants = await scope.flush();
|
|
1552
|
+
observer?.(instants);
|
|
1341
1553
|
return result;
|
|
1342
|
-
},
|
|
1554
|
+
}, backendOptions);
|
|
1343
1555
|
},
|
|
1344
1556
|
...backend.adoptTransaction === void 0 ? {} : {
|
|
1345
1557
|
adoptTransaction(externalTx) {
|
|
@@ -1395,6 +1607,65 @@ async function syncEmbeddings(ctx, schema, props) {
|
|
|
1395
1607
|
}
|
|
1396
1608
|
}
|
|
1397
1609
|
}
|
|
1610
|
+
async function syncEmbeddingsBatchForKind(args, schema, items) {
|
|
1611
|
+
const { graphId, nodeKind, backend } = args;
|
|
1612
|
+
if (!backend.upsertEmbedding || !backend.deleteEmbedding) {
|
|
1613
|
+
return;
|
|
1614
|
+
}
|
|
1615
|
+
const embeddingFields = getEmbeddingFields(schema);
|
|
1616
|
+
if (embeddingFields.length === 0) {
|
|
1617
|
+
return;
|
|
1618
|
+
}
|
|
1619
|
+
for (const field of embeddingFields) {
|
|
1620
|
+
const rows = [];
|
|
1621
|
+
const deletionIds = [];
|
|
1622
|
+
for (const item of items) {
|
|
1623
|
+
const value = item.props[field.fieldPath];
|
|
1624
|
+
if (isValidEmbeddingValue(value)) {
|
|
1625
|
+
rows.push({ nodeId: item.nodeId, embedding: value });
|
|
1626
|
+
} else if (value === void 0) {
|
|
1627
|
+
deletionIds.push(item.nodeId);
|
|
1628
|
+
}
|
|
1629
|
+
}
|
|
1630
|
+
if (rows.length > 0) {
|
|
1631
|
+
if (backend.upsertEmbeddingBatch === void 0) {
|
|
1632
|
+
for (const row of rows) {
|
|
1633
|
+
await backend.upsertEmbedding({
|
|
1634
|
+
graphId,
|
|
1635
|
+
nodeKind,
|
|
1636
|
+
nodeId: row.nodeId,
|
|
1637
|
+
fieldPath: field.fieldPath,
|
|
1638
|
+
embedding: row.embedding,
|
|
1639
|
+
dimensions: field.dimensions,
|
|
1640
|
+
metric: field.metric,
|
|
1641
|
+
indexType: field.indexType
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
} else {
|
|
1645
|
+
await backend.upsertEmbeddingBatch({
|
|
1646
|
+
graphId,
|
|
1647
|
+
nodeKind,
|
|
1648
|
+
fieldPath: field.fieldPath,
|
|
1649
|
+
dimensions: field.dimensions,
|
|
1650
|
+
metric: field.metric,
|
|
1651
|
+
indexType: field.indexType,
|
|
1652
|
+
rows
|
|
1653
|
+
});
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
for (const nodeId of deletionIds) {
|
|
1657
|
+
await backend.deleteEmbedding({
|
|
1658
|
+
graphId,
|
|
1659
|
+
nodeKind,
|
|
1660
|
+
nodeId,
|
|
1661
|
+
fieldPath: field.fieldPath,
|
|
1662
|
+
dimensions: field.dimensions,
|
|
1663
|
+
metric: field.metric,
|
|
1664
|
+
indexType: field.indexType
|
|
1665
|
+
});
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1398
1669
|
async function deleteNodeEmbeddings(ctx, schema) {
|
|
1399
1670
|
const { backend } = ctx;
|
|
1400
1671
|
if (!backend.deleteEmbedding) {
|
|
@@ -1424,42 +1695,6 @@ function isValidEmbeddingValue(value) {
|
|
|
1424
1695
|
}
|
|
1425
1696
|
|
|
1426
1697
|
// src/store/fulltext-sync.ts
|
|
1427
|
-
var searchableFieldsCache = /* @__PURE__ */ new WeakMap();
|
|
1428
|
-
function getSearchableFields(schema) {
|
|
1429
|
-
const cached = searchableFieldsCache.get(schema);
|
|
1430
|
-
if (cached) return cached;
|
|
1431
|
-
const fields = computeSearchableFields(schema);
|
|
1432
|
-
searchableFieldsCache.set(schema, fields);
|
|
1433
|
-
return fields;
|
|
1434
|
-
}
|
|
1435
|
-
function computeSearchableFields(schema) {
|
|
1436
|
-
if (schema.type !== "object") return [];
|
|
1437
|
-
const def = schema.def;
|
|
1438
|
-
const shape = def.shape;
|
|
1439
|
-
if (!shape) return [];
|
|
1440
|
-
const fields = [];
|
|
1441
|
-
for (const [fieldPath, fieldSchema] of Object.entries(shape)) {
|
|
1442
|
-
const metadata = getSearchableMetadata(fieldSchema);
|
|
1443
|
-
if (metadata !== void 0) {
|
|
1444
|
-
fields.push({ fieldPath, metadata });
|
|
1445
|
-
}
|
|
1446
|
-
}
|
|
1447
|
-
warnIfConflictingLanguages(fields);
|
|
1448
|
-
return fields;
|
|
1449
|
-
}
|
|
1450
|
-
function warnIfConflictingLanguages(fields) {
|
|
1451
|
-
if (fields.length < 2) return;
|
|
1452
|
-
const languages = new Set(fields.map((field) => field.metadata.language));
|
|
1453
|
-
if (languages.size < 2) return;
|
|
1454
|
-
if (typeof console === "undefined" || typeof console.warn !== "function") {
|
|
1455
|
-
return;
|
|
1456
|
-
}
|
|
1457
|
-
const fieldSummary = fields.map((field) => `${field.fieldPath}=${field.metadata.language}`).join(", ");
|
|
1458
|
-
const winning = fields[0]?.metadata.language ?? DEFAULT_SEARCHABLE_LANGUAGE;
|
|
1459
|
-
console.warn(
|
|
1460
|
-
`[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.`
|
|
1461
|
-
);
|
|
1462
|
-
}
|
|
1463
1698
|
var FIELD_SEPARATOR = "\n";
|
|
1464
1699
|
function resolveCombinedLanguage(fields) {
|
|
1465
1700
|
return fields[0]?.metadata.language ?? DEFAULT_SEARCHABLE_LANGUAGE;
|
|
@@ -1503,6 +1738,55 @@ async function syncFulltext(ctx, schema, props) {
|
|
|
1503
1738
|
nodeId: ctx.nodeId
|
|
1504
1739
|
});
|
|
1505
1740
|
}
|
|
1741
|
+
async function syncFulltextBatchForKind(args, schema, items) {
|
|
1742
|
+
const { graphId, nodeKind, backend } = args;
|
|
1743
|
+
if (!backend.upsertFulltext || !backend.deleteFulltext) {
|
|
1744
|
+
return;
|
|
1745
|
+
}
|
|
1746
|
+
const rows = [];
|
|
1747
|
+
const emptyContentIds = [];
|
|
1748
|
+
const hasSearchableFields = getSearchableFields(schema).length > 0;
|
|
1749
|
+
for (const item of items) {
|
|
1750
|
+
const computed = computeFulltextContent(schema, item.props);
|
|
1751
|
+
if (computed !== void 0) {
|
|
1752
|
+
rows.push({
|
|
1753
|
+
nodeId: item.nodeId,
|
|
1754
|
+
content: computed.content,
|
|
1755
|
+
language: computed.language
|
|
1756
|
+
});
|
|
1757
|
+
} else if (hasSearchableFields) {
|
|
1758
|
+
emptyContentIds.push(item.nodeId);
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
if (rows.length > 0) {
|
|
1762
|
+
if (backend.upsertFulltextBatch === void 0) {
|
|
1763
|
+
for (const row of rows) {
|
|
1764
|
+
await backend.upsertFulltext({
|
|
1765
|
+
graphId,
|
|
1766
|
+
nodeKind,
|
|
1767
|
+
nodeId: row.nodeId,
|
|
1768
|
+
content: row.content,
|
|
1769
|
+
language: row.language
|
|
1770
|
+
});
|
|
1771
|
+
}
|
|
1772
|
+
} else {
|
|
1773
|
+
await backend.upsertFulltextBatch({ graphId, nodeKind, rows });
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
if (emptyContentIds.length > 0) {
|
|
1777
|
+
if (backend.deleteFulltextBatch === void 0) {
|
|
1778
|
+
for (const nodeId of emptyContentIds) {
|
|
1779
|
+
await backend.deleteFulltext({ graphId, nodeKind, nodeId });
|
|
1780
|
+
}
|
|
1781
|
+
} else {
|
|
1782
|
+
await backend.deleteFulltextBatch({
|
|
1783
|
+
graphId,
|
|
1784
|
+
nodeKind,
|
|
1785
|
+
nodeIds: emptyContentIds
|
|
1786
|
+
});
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1506
1790
|
async function deleteNodeFulltext(ctx, schema) {
|
|
1507
1791
|
const { backend } = ctx;
|
|
1508
1792
|
if (!backend.deleteFulltext) {
|
|
@@ -1640,10 +1924,7 @@ function checkUniqueEdge(edgeKind, fromKind, fromId, _toKind, _toId, existingCou
|
|
|
1640
1924
|
}
|
|
1641
1925
|
function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registry) {
|
|
1642
1926
|
const validFromKinds = registration.from.map((node) => node.kind);
|
|
1643
|
-
|
|
1644
|
-
(validKind) => registry.isAssignableTo(fromKind, validKind)
|
|
1645
|
-
);
|
|
1646
|
-
if (!fromValid) {
|
|
1927
|
+
if (!registry.isAssignableToAny(fromKind, validFromKinds)) {
|
|
1647
1928
|
return new EndpointError({
|
|
1648
1929
|
edgeKind,
|
|
1649
1930
|
endpoint: "from",
|
|
@@ -1652,10 +1933,7 @@ function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registr
|
|
|
1652
1933
|
});
|
|
1653
1934
|
}
|
|
1654
1935
|
const validToKinds = registration.to.map((node) => node.kind);
|
|
1655
|
-
|
|
1656
|
-
(validKind) => registry.isAssignableTo(toKind, validKind)
|
|
1657
|
-
);
|
|
1658
|
-
if (!toValid) {
|
|
1936
|
+
if (!registry.isAssignableToAny(toKind, validToKinds)) {
|
|
1659
1937
|
return new EndpointError({
|
|
1660
1938
|
edgeKind,
|
|
1661
1939
|
endpoint: "to",
|
|
@@ -1736,6 +2014,36 @@ async function insertUniquenessEntries(ctx, kind, id, props, constraints) {
|
|
|
1736
2014
|
});
|
|
1737
2015
|
}
|
|
1738
2016
|
}
|
|
2017
|
+
async function insertUniquenessEntriesBatch(ctx, items) {
|
|
2018
|
+
const entries = [];
|
|
2019
|
+
for (const item of items) {
|
|
2020
|
+
for (const constraint of item.constraints) {
|
|
2021
|
+
if (!checkWherePredicate(constraint, item.props)) {
|
|
2022
|
+
continue;
|
|
2023
|
+
}
|
|
2024
|
+
entries.push({
|
|
2025
|
+
graphId: ctx.graphId,
|
|
2026
|
+
nodeKind: item.kind,
|
|
2027
|
+
constraintName: constraint.name,
|
|
2028
|
+
key: computeUniqueKey(
|
|
2029
|
+
item.props,
|
|
2030
|
+
constraint.fields,
|
|
2031
|
+
constraint.collation
|
|
2032
|
+
),
|
|
2033
|
+
nodeId: item.id,
|
|
2034
|
+
concreteKind: item.kind
|
|
2035
|
+
});
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
if (entries.length === 0) return;
|
|
2039
|
+
if (ctx.backend.insertUniqueBatch !== void 0) {
|
|
2040
|
+
await ctx.backend.insertUniqueBatch(entries);
|
|
2041
|
+
return;
|
|
2042
|
+
}
|
|
2043
|
+
for (const entry of entries) {
|
|
2044
|
+
await ctx.backend.insertUnique(entry);
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
1739
2047
|
async function deleteUniquenessEntries(ctx, kind, props, constraints) {
|
|
1740
2048
|
for (const constraint of constraints) {
|
|
1741
2049
|
if (!checkWherePredicate(constraint, props)) {
|
|
@@ -1847,6 +2155,14 @@ async function enforceNodeDeleteBehavior(ctx, args, backend, policy) {
|
|
|
1847
2155
|
}
|
|
1848
2156
|
case "cascade":
|
|
1849
2157
|
case "disconnect": {
|
|
2158
|
+
const batchDelete = args.mode === "hard" ? backend.hardDeleteEdgesBatch : backend.deleteEdgesBatch;
|
|
2159
|
+
if (batchDelete !== void 0) {
|
|
2160
|
+
await batchDelete.call(backend, {
|
|
2161
|
+
graphId: ctx.graphId,
|
|
2162
|
+
ids: connectedEdges.map((edge) => edge.id)
|
|
2163
|
+
});
|
|
2164
|
+
break;
|
|
2165
|
+
}
|
|
1850
2166
|
for (const edge of connectedEdges) {
|
|
1851
2167
|
await (args.mode === "hard" ? backend.hardDeleteEdge({ graphId: ctx.graphId, id: edge.id }) : backend.deleteEdge({ graphId: ctx.graphId, id: edge.id }));
|
|
1852
2168
|
}
|
|
@@ -1875,8 +2191,35 @@ async function applyNodeInsertSideEffects(ctx, args, backend) {
|
|
|
1875
2191
|
)
|
|
1876
2192
|
]);
|
|
1877
2193
|
}
|
|
2194
|
+
async function applyNodeInsertSideEffectsBatch(ctx, items, backend) {
|
|
2195
|
+
if (items.length === 0) return;
|
|
2196
|
+
await insertUniquenessEntriesBatch(
|
|
2197
|
+
uniquenessContext(ctx, backend),
|
|
2198
|
+
items.map((item) => ({
|
|
2199
|
+
kind: item.kind,
|
|
2200
|
+
id: item.id,
|
|
2201
|
+
props: item.props,
|
|
2202
|
+
constraints: item.uniqueConstraints
|
|
2203
|
+
}))
|
|
2204
|
+
);
|
|
2205
|
+
const byKind = /* @__PURE__ */ new Map();
|
|
2206
|
+
for (const item of items) {
|
|
2207
|
+
const group = byKind.get(item.kind) ?? { schema: item.schema, rows: [] };
|
|
2208
|
+
group.rows.push({ nodeId: item.id, props: item.props });
|
|
2209
|
+
byKind.set(item.kind, group);
|
|
2210
|
+
}
|
|
2211
|
+
await Promise.all(
|
|
2212
|
+
[...byKind.entries()].flatMap(([kind, group]) => {
|
|
2213
|
+
const syncArguments = { graphId: ctx.graphId, nodeKind: kind, backend };
|
|
2214
|
+
return [
|
|
2215
|
+
syncEmbeddingsBatchForKind(syncArguments, group.schema, group.rows),
|
|
2216
|
+
syncFulltextBatchForKind(syncArguments, group.schema, group.rows)
|
|
2217
|
+
];
|
|
2218
|
+
})
|
|
2219
|
+
);
|
|
2220
|
+
}
|
|
1878
2221
|
function parseRowProps(row) {
|
|
1879
|
-
return
|
|
2222
|
+
return rowPropsToObject(row.props);
|
|
1880
2223
|
}
|
|
1881
2224
|
async function applyNodeUpdate(ctx, args, backend) {
|
|
1882
2225
|
const { kind, id } = args.existing;
|
|
@@ -2005,6 +2348,6 @@ async function applyNodeResurrect(ctx, args, backend) {
|
|
|
2005
2348
|
return row;
|
|
2006
2349
|
}
|
|
2007
2350
|
|
|
2008
|
-
export { ALIAS_CTE_PREFIX, DEFAULT_SQL_SCHEMA, EMBEDDINGS_CTE_ALIAS, FULLTEXT_CTE_ALIAS, HYBRID_CANDIDATES_CTE_ALIAS, applyNodeHardDelete, applyNodeInsertSideEffects, applyNodeResurrect, applyNodeSoftDelete, applyNodeUpdate,
|
|
2009
|
-
//# sourceMappingURL=chunk-
|
|
2010
|
-
//# sourceMappingURL=chunk-
|
|
2351
|
+
export { ALIAS_CTE_PREFIX, DEFAULT_SQL_SCHEMA, EMBEDDINGS_CTE_ALIAS, FULLTEXT_CTE_ALIAS, HYBRID_CANDIDATES_CTE_ALIAS, advanceRevisionClock, applyNodeHardDelete, applyNodeInsertSideEffects, applyNodeInsertSideEffectsBatch, applyNodeResurrect, applyNodeSoftDelete, applyNodeUpdate, asRecordedInstant, assertRecordedCaptureTransactionIsolation, assertRevisionTrackableBackend, assertValidRecordedInstant, checkCardinality, checkDisjointness, checkUniqueEdge, checkUniquenessConstraints, checkWherePredicate, closeRecordedHardDeletedKind, computeFulltextContent, computeUniqueKey, coordinateContext, createHistoryUnsafeSqlRef, createNodeWriteContext, createRecordedBackend, createRecordedReadBinding, createRecordedTransactionScope, createRevisionTrackingUnsafeSqlRef, createSqlSchema, createUniquenessContext, describeCoordinate, edgeInsertDispatch, ensureRevisionOrigin, generateId, getEdgeRowsByIds, getEmbeddingFields, getKindsForUniquenessCheck, getNodeRowsByIds, lockRecordedGraphWrite, nodeInsertDispatch, readRecordedClock, readRevisionOrigin, recordedBindParamBudget, recordedCaptureRequiresCallbackTransactionError, recordedReadSchemaFor, recordedReadSqlSchema, recordedRelation, requireExternalRecordedReadSource, requireRecordedReadBinding, requireSqlSchema, resolveReadCoordinate, runInsertBatch, runInsertBatchReturning, runInsertNoReturn, uncapturedGraphWriteLock, validateEdgeEndpoints, vectorSlotKey, withRecordedCoordinate, withRecordedFlushObserver };
|
|
2352
|
+
//# sourceMappingURL=chunk-5VTR2F2K.js.map
|
|
2353
|
+
//# sourceMappingURL=chunk-5VTR2F2K.js.map
|