@nicia-ai/typegraph 0.34.0 → 0.35.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-ZV5N4DBG.js → chunk-3TWF3SH4.js} +300 -58
- package/dist/chunk-3TWF3SH4.js.map +1 -0
- package/dist/chunk-4JEZZJ6S.cjs +1271 -0
- package/dist/chunk-4JEZZJ6S.cjs.map +1 -0
- package/dist/{chunk-UNNPKQUG.cjs → chunk-4TOD4LBZ.cjs} +246 -155
- package/dist/chunk-4TOD4LBZ.cjs.map +1 -0
- package/dist/{chunk-QV245VMN.js → chunk-55MZDDZV.js} +100 -6
- package/dist/chunk-55MZDDZV.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-BVTWD66D.js → chunk-5SEGFTZX.js} +3 -3
- package/dist/{chunk-BVTWD66D.js.map → chunk-5SEGFTZX.js.map} +1 -1
- package/dist/{chunk-6GNSY7AV.js → chunk-6FR2MMS6.js} +7 -7
- package/dist/chunk-6FR2MMS6.js.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-RHZWOJVA.cjs → chunk-BLZDPRXT.cjs} +52 -4
- package/dist/chunk-BLZDPRXT.cjs.map +1 -0
- package/dist/chunk-BYPOGQWK.js +25 -0
- package/dist/chunk-BYPOGQWK.js.map +1 -0
- package/dist/{chunk-6HVOHZHS.cjs → chunk-CK5BVQOW.cjs} +213 -168
- package/dist/chunk-CK5BVQOW.cjs.map +1 -0
- package/dist/{chunk-JJRCLAUN.cjs → chunk-CTTSDJLY.cjs} +116 -10
- package/dist/chunk-CTTSDJLY.cjs.map +1 -0
- package/dist/chunk-CUHM5CWJ.cjs +12 -0
- package/dist/chunk-CUHM5CWJ.cjs.map +1 -0
- package/dist/{chunk-A7SZZFAG.js → chunk-CZQ3FO2Q.js} +409 -99
- package/dist/chunk-CZQ3FO2Q.js.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-UJLOZYKT.cjs → chunk-EM3CWPND.cjs} +441 -115
- package/dist/chunk-EM3CWPND.cjs.map +1 -0
- package/dist/chunk-EMF62TZG.cjs +1176 -0
- package/dist/chunk-EMF62TZG.cjs.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-HK5SATYM.cjs → chunk-FL472AMI.cjs} +16 -109
- package/dist/chunk-FL472AMI.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-GSQ6NPH6.cjs +100 -0
- package/dist/chunk-GSQ6NPH6.cjs.map +1 -0
- package/dist/chunk-GUR2FNB5.cjs +12 -0
- package/dist/{chunk-HMFK4BXR.cjs.map → chunk-GUR2FNB5.cjs.map} +1 -1
- package/dist/{chunk-JQGIPGVL.cjs → chunk-H7YNSMA7.cjs} +43 -2
- package/dist/chunk-H7YNSMA7.cjs.map +1 -0
- package/dist/{chunk-2MRAX3UE.js → chunk-I7ZUZKFD.js} +47 -4
- package/dist/chunk-I7ZUZKFD.js.map +1 -0
- package/dist/{chunk-3BRVBQQD.cjs → chunk-J7WFGBJR.cjs} +2445 -2367
- package/dist/chunk-J7WFGBJR.cjs.map +1 -0
- package/dist/{chunk-V3QNTB7Z.js → chunk-JBTOYDMN.js} +194 -114
- package/dist/chunk-JBTOYDMN.js.map +1 -0
- package/dist/{chunk-K2TGS3EN.js → chunk-K3PPLHY7.js} +138 -89
- package/dist/chunk-K3PPLHY7.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-KMI7LYAF.js +1252 -0
- package/dist/chunk-KMI7LYAF.js.map +1 -0
- package/dist/{chunk-JIEJCTDS.cjs → chunk-LGEALRC6.cjs} +21 -4
- package/dist/chunk-LGEALRC6.cjs.map +1 -0
- package/dist/{chunk-TQOYM4LN.js → chunk-MP2JQKSG.js} +21 -5
- package/dist/chunk-MP2JQKSG.js.map +1 -0
- package/dist/{chunk-ZP5WHI4C.cjs → chunk-O7UN7OXA.cjs} +358 -116
- package/dist/chunk-O7UN7OXA.cjs.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-DEQFL35G.js → chunk-Q5TEXCTB.js} +61 -7
- package/dist/chunk-Q5TEXCTB.js.map +1 -0
- package/dist/chunk-QNKSQTKQ.js +1312 -0
- package/dist/chunk-QNKSQTKQ.js.map +1 -0
- package/dist/{chunk-ZURTTSCM.js → chunk-QOTI55H7.js} +6 -94
- package/dist/chunk-QOTI55H7.js.map +1 -0
- package/dist/{chunk-CHXTTSC6.js → chunk-QWEUYILR.js} +104 -5
- package/dist/chunk-QWEUYILR.js.map +1 -0
- package/dist/{chunk-LANHCOXB.js → chunk-RGP33ZJ5.js} +485 -83
- package/dist/chunk-RGP33ZJ5.js.map +1 -0
- package/dist/chunk-RGPG7EOJ.js +94 -0
- package/dist/chunk-RGPG7EOJ.js.map +1 -0
- package/dist/{chunk-G6SOJEDI.cjs → chunk-S55OV6PW.cjs} +15 -15
- package/dist/chunk-S55OV6PW.cjs.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-XLUNB2TZ.js → chunk-SNXVDZAJ.js} +3 -3
- package/dist/{chunk-XLUNB2TZ.js.map → chunk-SNXVDZAJ.js.map} +1 -1
- 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-WLRIWYHQ.js → chunk-UES55P7G.js} +1863 -1785
- package/dist/chunk-UES55P7G.js.map +1 -0
- 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-T6SPUYLX.cjs → chunk-VPYHY3LJ.cjs} +116 -10
- package/dist/chunk-VPYHY3LJ.cjs.map +1 -0
- package/dist/{chunk-T46GR2VY.js → chunk-VSPCZAXF.js} +3 -3
- package/dist/{chunk-T46GR2VY.js.map → chunk-VSPCZAXF.js.map} +1 -1
- 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-RY2VIWAM.js → chunk-WDBCBWC4.js} +355 -32
- package/dist/chunk-WDBCBWC4.js.map +1 -0
- package/dist/chunk-WJT7OU7E.cjs +1334 -0
- package/dist/chunk-WJT7OU7E.cjs.map +1 -0
- package/dist/{chunk-5IQIX7LU.cjs → chunk-XOX22WHL.cjs} +476 -163
- package/dist/chunk-XOX22WHL.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-6CSUAq-x.d.ts} +234 -93
- package/dist/{index-SEvUHDA6.d.cts → index-Bks_3HHK.d.cts} +234 -93
- package/dist/index.cjs +208 -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 +47 -26
- package/dist/interchange/index.d.cts +126 -12
- package/dist/interchange/index.d.ts +126 -12
- package/dist/interchange/index.js +14 -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-BSpqvAxK.d.cts} +415 -44
- package/dist/{store-view-BlgnhEYf.d.ts → store-view-CKbHFRnn.d.ts} +415 -44
- 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-JBTOYDMN.js';
|
|
3
|
+
import { validateCanonicalIsoDate, withRecordedRelationsPrecondition, nowIso } from './chunk-I7ZUZKFD.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-MP2JQKSG.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
|
}
|
|
@@ -378,44 +373,62 @@ function historyUnsafeRawWriteError(surface) {
|
|
|
378
373
|
}
|
|
379
374
|
);
|
|
380
375
|
}
|
|
376
|
+
function revisionTrackingUnsafeRawWriteError(surface) {
|
|
377
|
+
return new ConfigurationError(
|
|
378
|
+
`${surface} is not available when revision tracking is enabled because raw SQL writes bypass the revision anchor.`,
|
|
379
|
+
{ code: "REVISION_TRACKING_RAW_SQL_DISABLED" },
|
|
380
|
+
{
|
|
381
|
+
suggestion: "Run graph writes through store.nodes/store.edges (or tx.nodes/tx.edges inside a transaction), so TypeGraph can advance the revision anchor."
|
|
382
|
+
}
|
|
383
|
+
);
|
|
384
|
+
}
|
|
381
385
|
function failHistoryUnsafeSqlRef() {
|
|
382
386
|
throw historyUnsafeRawWriteError("tx.sql");
|
|
383
387
|
}
|
|
388
|
+
function failRevisionTrackingUnsafeSqlRef() {
|
|
389
|
+
throw revisionTrackingUnsafeRawWriteError("tx.sql");
|
|
390
|
+
}
|
|
384
391
|
function createHistoryUnsafeSqlRef() {
|
|
392
|
+
return createUnsafeSqlRef(failHistoryUnsafeSqlRef);
|
|
393
|
+
}
|
|
394
|
+
function createRevisionTrackingUnsafeSqlRef() {
|
|
395
|
+
return createUnsafeSqlRef(failRevisionTrackingUnsafeSqlRef);
|
|
396
|
+
}
|
|
397
|
+
function createUnsafeSqlRef(fail) {
|
|
385
398
|
return new Proxy(
|
|
386
|
-
function
|
|
387
|
-
return
|
|
399
|
+
function unsafeSqlRef() {
|
|
400
|
+
return fail();
|
|
388
401
|
},
|
|
389
402
|
{
|
|
390
403
|
get() {
|
|
391
|
-
return
|
|
404
|
+
return fail();
|
|
392
405
|
},
|
|
393
406
|
apply() {
|
|
394
|
-
return
|
|
407
|
+
return fail();
|
|
395
408
|
},
|
|
396
409
|
set() {
|
|
397
|
-
return
|
|
410
|
+
return fail();
|
|
398
411
|
},
|
|
399
412
|
defineProperty() {
|
|
400
|
-
return
|
|
413
|
+
return fail();
|
|
401
414
|
},
|
|
402
415
|
deleteProperty() {
|
|
403
|
-
return
|
|
416
|
+
return fail();
|
|
404
417
|
},
|
|
405
418
|
// Enumeration / inspection traps too, so spreading (`{...tx.sql}`),
|
|
406
419
|
// `Object.keys`, `in`, and prototype reads also fail loudly rather than
|
|
407
420
|
// silently yielding an empty object that reads as "no raw handle".
|
|
408
421
|
has() {
|
|
409
|
-
return
|
|
422
|
+
return fail();
|
|
410
423
|
},
|
|
411
424
|
ownKeys() {
|
|
412
|
-
return
|
|
425
|
+
return fail();
|
|
413
426
|
},
|
|
414
427
|
getOwnPropertyDescriptor() {
|
|
415
|
-
return
|
|
428
|
+
return fail();
|
|
416
429
|
},
|
|
417
430
|
getPrototypeOf() {
|
|
418
|
-
return
|
|
431
|
+
return fail();
|
|
419
432
|
}
|
|
420
433
|
}
|
|
421
434
|
);
|
|
@@ -476,6 +489,44 @@ function assertCapturableBackend(backend) {
|
|
|
476
489
|
);
|
|
477
490
|
}
|
|
478
491
|
}
|
|
492
|
+
function assertRevisionTrackableBackend(backend) {
|
|
493
|
+
if (!backend.capabilities.transactions) {
|
|
494
|
+
throw new ConfigurationError(
|
|
495
|
+
"revisionTracking: true requires a backend with transaction support.",
|
|
496
|
+
{ dialect: backend.dialect },
|
|
497
|
+
{
|
|
498
|
+
suggestion: "Use a transactional SQLite/PostgreSQL backend or leave revision tracking disabled."
|
|
499
|
+
}
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
if (backend.executeStatement === void 0) {
|
|
503
|
+
throw new ConfigurationError(
|
|
504
|
+
"revisionTracking: true requires a backend that supports executeStatement.",
|
|
505
|
+
{ dialect: backend.dialect },
|
|
506
|
+
{
|
|
507
|
+
suggestion: "Use a built-in SQLite/PostgreSQL backend, or implement executeStatement so TypeGraph can advance the revision clock."
|
|
508
|
+
}
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
if (backend.tableNames === void 0) {
|
|
512
|
+
throw new ConfigurationError(
|
|
513
|
+
"revisionTracking: true requires a backend that exposes tableNames.",
|
|
514
|
+
{ dialect: backend.dialect },
|
|
515
|
+
{
|
|
516
|
+
suggestion: "Use a built-in SQLite/PostgreSQL backend, or set tableNames so TypeGraph can address the revision clock relation."
|
|
517
|
+
}
|
|
518
|
+
);
|
|
519
|
+
}
|
|
520
|
+
if (backend.ensureRevisionOriginsTable === void 0) {
|
|
521
|
+
throw new ConfigurationError(
|
|
522
|
+
"revisionTracking: true requires a backend that can bootstrap revision origins.",
|
|
523
|
+
{ dialect: backend.dialect },
|
|
524
|
+
{
|
|
525
|
+
suggestion: "Use a built-in SQLite/PostgreSQL backend, or implement ensureRevisionOriginsTable so TypeGraph can durably namespace revision anchors."
|
|
526
|
+
}
|
|
527
|
+
);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
479
530
|
|
|
480
531
|
// src/store/recorded-capture/clock.ts
|
|
481
532
|
var RECORDED_MIN = "1970-01-01T00:00:00.000Z";
|
|
@@ -506,19 +557,37 @@ function graphWriteLockEvidence() {
|
|
|
506
557
|
function uncapturedGraphWriteLock() {
|
|
507
558
|
return graphWriteLockEvidence();
|
|
508
559
|
}
|
|
509
|
-
|
|
510
|
-
|
|
560
|
+
function createRecordedGraphLockMemo() {
|
|
561
|
+
return /* @__PURE__ */ new Map();
|
|
562
|
+
}
|
|
563
|
+
var recordedGraphLockMemos = /* @__PURE__ */ new WeakMap();
|
|
564
|
+
function registerRecordedGraphLockMemo(backend, memo) {
|
|
565
|
+
recordedGraphLockMemos.set(backend, memo);
|
|
566
|
+
}
|
|
567
|
+
async function acquireRecordedGraphWriteLock(target, graphId) {
|
|
511
568
|
await target.execute(
|
|
512
569
|
asCompiledRowsSql(recordedGraphWriteAdvisoryLockSql(graphId))
|
|
513
570
|
);
|
|
514
|
-
return graphWriteLockEvidence();
|
|
515
571
|
}
|
|
516
|
-
async function
|
|
517
|
-
if (target.dialect !== "postgres") return;
|
|
518
|
-
const
|
|
519
|
-
|
|
520
|
-
await
|
|
572
|
+
async function lockRecordedGraphWrite(target, graphId, memo) {
|
|
573
|
+
if (target.dialect !== "postgres") return graphWriteLockEvidence();
|
|
574
|
+
const effectiveMemo = memo ?? recordedGraphLockMemos.get(target);
|
|
575
|
+
if (effectiveMemo === void 0) {
|
|
576
|
+
await acquireRecordedGraphWriteLock(target, graphId);
|
|
577
|
+
return graphWriteLockEvidence();
|
|
578
|
+
}
|
|
579
|
+
let pending = effectiveMemo.get(graphId);
|
|
580
|
+
if (pending === void 0) {
|
|
581
|
+
pending = acquireRecordedGraphWriteLock(target, graphId).catch(
|
|
582
|
+
(error) => {
|
|
583
|
+
effectiveMemo.delete(graphId);
|
|
584
|
+
throw error;
|
|
585
|
+
}
|
|
586
|
+
);
|
|
587
|
+
effectiveMemo.set(graphId, pending);
|
|
521
588
|
}
|
|
589
|
+
await pending;
|
|
590
|
+
return graphWriteLockEvidence();
|
|
522
591
|
}
|
|
523
592
|
function failInvalidClockTimestamp(value) {
|
|
524
593
|
throw new ConfigurationError(
|
|
@@ -574,6 +643,53 @@ async function readRecordedClock(target, schema, graphId) {
|
|
|
574
643
|
const first = rows[0];
|
|
575
644
|
return first === void 0 ? void 0 : toCanonicalIso(first.recorded_at);
|
|
576
645
|
}
|
|
646
|
+
async function readRevisionOrigin(target, schema, graphId) {
|
|
647
|
+
const rows = await target.execute(
|
|
648
|
+
asCompiledRowsSql(sql`
|
|
649
|
+
SELECT origin
|
|
650
|
+
FROM ${schema.revisionOriginsTable}
|
|
651
|
+
WHERE graph_id = ${graphId}
|
|
652
|
+
`)
|
|
653
|
+
);
|
|
654
|
+
const first = rows[0];
|
|
655
|
+
if (first === void 0) return void 0;
|
|
656
|
+
if (typeof first.origin !== "string" || first.origin.length === 0) {
|
|
657
|
+
throw new ConfigurationError(
|
|
658
|
+
"Revision origin row contained an invalid origin",
|
|
659
|
+
{ graphId, origin: first.origin }
|
|
660
|
+
);
|
|
661
|
+
}
|
|
662
|
+
return first.origin;
|
|
663
|
+
}
|
|
664
|
+
async function ensureRevisionOrigin(target, schema, graphId) {
|
|
665
|
+
const ensureTable = target.ensureRevisionOriginsTable;
|
|
666
|
+
if (ensureTable === void 0) {
|
|
667
|
+
throw new ConfigurationError(
|
|
668
|
+
"Revision tracking requires a backend that can bootstrap revision origins.",
|
|
669
|
+
{ dialect: target.dialect },
|
|
670
|
+
{
|
|
671
|
+
suggestion: "Use a built-in SQLite/PostgreSQL backend, or implement ensureRevisionOriginsTable on the custom backend."
|
|
672
|
+
}
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
await ensureTable();
|
|
676
|
+
const existing = await readRevisionOrigin(target, schema, graphId);
|
|
677
|
+
if (existing !== void 0) return existing;
|
|
678
|
+
await executeStatement(
|
|
679
|
+
target,
|
|
680
|
+
sql`
|
|
681
|
+
INSERT INTO ${schema.revisionOriginsTable} (graph_id, origin)
|
|
682
|
+
VALUES (${graphId}, ${generateId()})
|
|
683
|
+
ON CONFLICT (graph_id) DO NOTHING
|
|
684
|
+
`
|
|
685
|
+
);
|
|
686
|
+
const origin = await readRevisionOrigin(target, schema, graphId);
|
|
687
|
+
if (origin !== void 0) return origin;
|
|
688
|
+
throw new ConfigurationError(
|
|
689
|
+
"Revision origin was not persisted after initialization.",
|
|
690
|
+
{ graphId, dialect: target.dialect }
|
|
691
|
+
);
|
|
692
|
+
}
|
|
577
693
|
async function writeRecordedClock(target, schema, graphId, recordedAt) {
|
|
578
694
|
await executeStatement(
|
|
579
695
|
target,
|
|
@@ -601,9 +717,9 @@ async function lockRecordedClock(target, schema, graphId, ownsWriteLock) {
|
|
|
601
717
|
`
|
|
602
718
|
);
|
|
603
719
|
}
|
|
604
|
-
async function allocateRecordedCommit(target, schema, graphId, ownsWriteLock) {
|
|
720
|
+
async function allocateRecordedCommit(target, schema, graphId, ownsWriteLock, previousRevision) {
|
|
605
721
|
await lockRecordedClock(target, schema, graphId, ownsWriteLock);
|
|
606
|
-
const previous = await readRecordedClock(target, schema, graphId);
|
|
722
|
+
const previous = previousRevision ?? await readRecordedClock(target, schema, graphId);
|
|
607
723
|
const recordedCommitTime = nextRecordedCommitTime(previous);
|
|
608
724
|
if (!Number.isFinite(recordedCommitTime) || recordedCommitTime >= RECORDED_MAX_TIME) {
|
|
609
725
|
throw new ConfigurationError(
|
|
@@ -618,6 +734,15 @@ async function allocateRecordedCommit(target, schema, graphId, ownsWriteLock) {
|
|
|
618
734
|
await writeRecordedClock(target, schema, graphId, recordedCommit);
|
|
619
735
|
return recordedCommit;
|
|
620
736
|
}
|
|
737
|
+
async function advanceRevisionClock(target, schema, graphId, ownsWriteLock, previousRevision) {
|
|
738
|
+
return allocateRecordedCommit(
|
|
739
|
+
target,
|
|
740
|
+
schema,
|
|
741
|
+
graphId,
|
|
742
|
+
ownsWriteLock,
|
|
743
|
+
previousRevision
|
|
744
|
+
);
|
|
745
|
+
}
|
|
621
746
|
|
|
622
747
|
// src/store/insert-dispatch.ts
|
|
623
748
|
function nodeInsertDispatch(backend) {
|
|
@@ -767,7 +892,7 @@ function recordedCommonCells() {
|
|
|
767
892
|
graph_id: (row) => sql`${row.graph_id}`,
|
|
768
893
|
id: (row) => sql`${row.id}`,
|
|
769
894
|
kind: (row) => sql`${row.kind}`,
|
|
770
|
-
props: (row) => sql`${row.props}`,
|
|
895
|
+
props: (row) => sql`${rowPropsToJsonText(row.props)}`,
|
|
771
896
|
valid_from: (row) => sql`${sqlNull(row.valid_from)}`,
|
|
772
897
|
valid_to: (row) => sql`${sqlNull(row.valid_to)}`,
|
|
773
898
|
created_at: (row) => sql`${row.created_at}`,
|
|
@@ -1028,6 +1153,21 @@ async function queryConnectedEdgeIds(target, schema, params) {
|
|
|
1028
1153
|
}
|
|
1029
1154
|
|
|
1030
1155
|
// src/store/recorded-capture.ts
|
|
1156
|
+
var RECORDED_FLUSH_OBSERVER = /* @__PURE__ */ Symbol("typegraph.recordedFlushObserver");
|
|
1157
|
+
function readRecordedFlushObserver(options) {
|
|
1158
|
+
return options?.[RECORDED_FLUSH_OBSERVER];
|
|
1159
|
+
}
|
|
1160
|
+
function stripRecordedFlushObserver(options) {
|
|
1161
|
+
if (options === void 0) return void 0;
|
|
1162
|
+
const { [RECORDED_FLUSH_OBSERVER]: _observer, ...backendOptions } = options;
|
|
1163
|
+
return backendOptions;
|
|
1164
|
+
}
|
|
1165
|
+
function withRecordedFlushObserver(options, observer) {
|
|
1166
|
+
return {
|
|
1167
|
+
...stripRecordedFlushObserver(options),
|
|
1168
|
+
[RECORDED_FLUSH_OBSERVER]: observer
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1031
1171
|
function nodeIdentityKey(graphId, kind, id) {
|
|
1032
1172
|
return `${graphId}\0${kind}\0${id}`;
|
|
1033
1173
|
}
|
|
@@ -1079,7 +1219,8 @@ function createRecordedCaptureSession() {
|
|
|
1079
1219
|
);
|
|
1080
1220
|
}
|
|
1081
1221
|
sealed = true;
|
|
1082
|
-
if (touched.size === 0) return;
|
|
1222
|
+
if (touched.size === 0) return /* @__PURE__ */ new Map();
|
|
1223
|
+
const recordedByGraph = /* @__PURE__ */ new Map();
|
|
1083
1224
|
const byGraph = groupBy(touched.values(), (entity) => entity.graphId);
|
|
1084
1225
|
for (const [graphId, entities] of byGraph) {
|
|
1085
1226
|
const recordedCommit = await allocateRecordedCommit(
|
|
@@ -1088,6 +1229,7 @@ function createRecordedCaptureSession() {
|
|
|
1088
1229
|
graphId,
|
|
1089
1230
|
ownsWriteLock
|
|
1090
1231
|
);
|
|
1232
|
+
recordedByGraph.set(graphId, recordedCommit);
|
|
1091
1233
|
const nodes = entities.filter(
|
|
1092
1234
|
(entity) => entity.entity === "node"
|
|
1093
1235
|
);
|
|
@@ -1098,22 +1240,26 @@ function createRecordedCaptureSession() {
|
|
|
1098
1240
|
await flushEdges(target, schema, graphId, edges, recordedCommit);
|
|
1099
1241
|
}
|
|
1100
1242
|
touched.clear();
|
|
1243
|
+
return recordedByGraph;
|
|
1101
1244
|
}
|
|
1102
1245
|
};
|
|
1103
1246
|
}
|
|
1104
1247
|
function createRecordedTransactionBackend(target, session, schema) {
|
|
1105
1248
|
const nodeDispatch = nodeInsertDispatch(target);
|
|
1106
1249
|
const edgeDispatch = edgeInsertDispatch(target);
|
|
1250
|
+
const graphLocks = createRecordedGraphLockMemo();
|
|
1107
1251
|
async function lockGraph(graphId) {
|
|
1108
|
-
await lockRecordedGraphWrite(target, graphId);
|
|
1252
|
+
await lockRecordedGraphWrite(target, graphId, graphLocks);
|
|
1109
1253
|
}
|
|
1110
1254
|
async function lockGraphs(params) {
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
)
|
|
1255
|
+
const graphIds = [
|
|
1256
|
+
...new Set(params.map((parameter) => parameter.graphId))
|
|
1257
|
+
].toSorted();
|
|
1258
|
+
for (const graphId of graphIds) {
|
|
1259
|
+
await lockRecordedGraphWrite(target, graphId, graphLocks);
|
|
1260
|
+
}
|
|
1115
1261
|
}
|
|
1116
|
-
|
|
1262
|
+
const overlay = createBackendOverlay(target, {
|
|
1117
1263
|
...rawWriteGuards(target, "tx.backend"),
|
|
1118
1264
|
async insertNode(params) {
|
|
1119
1265
|
await lockGraph(params.graphId);
|
|
@@ -1233,8 +1379,28 @@ function createRecordedTransactionBackend(target, session, schema) {
|
|
|
1233
1379
|
await lockGraph(params.graphId);
|
|
1234
1380
|
await target.hardDeleteEdge(params);
|
|
1235
1381
|
session.touchEdge(params.graphId, params.id);
|
|
1382
|
+
},
|
|
1383
|
+
...target.deleteEdgesBatch === void 0 ? {} : {
|
|
1384
|
+
async deleteEdgesBatch(params) {
|
|
1385
|
+
await lockGraph(params.graphId);
|
|
1386
|
+
await target.deleteEdgesBatch(params);
|
|
1387
|
+
for (const id of params.ids) {
|
|
1388
|
+
session.touchEdge(params.graphId, id);
|
|
1389
|
+
}
|
|
1390
|
+
}
|
|
1391
|
+
},
|
|
1392
|
+
...target.hardDeleteEdgesBatch === void 0 ? {} : {
|
|
1393
|
+
async hardDeleteEdgesBatch(params) {
|
|
1394
|
+
await lockGraph(params.graphId);
|
|
1395
|
+
await target.hardDeleteEdgesBatch(params);
|
|
1396
|
+
for (const id of params.ids) {
|
|
1397
|
+
session.touchEdge(params.graphId, id);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1236
1400
|
}
|
|
1237
1401
|
});
|
|
1402
|
+
registerRecordedGraphLockMemo(overlay, graphLocks);
|
|
1403
|
+
return overlay;
|
|
1238
1404
|
}
|
|
1239
1405
|
function createRecordedTransactionScope(target, schema, ownsWriteLock = false) {
|
|
1240
1406
|
requireCaptureStatements(target);
|
|
@@ -1243,7 +1409,7 @@ function createRecordedTransactionScope(target, schema, ownsWriteLock = false) {
|
|
|
1243
1409
|
return {
|
|
1244
1410
|
backend: createRecordedTransactionBackend(target, session, resolvedSchema),
|
|
1245
1411
|
async flush() {
|
|
1246
|
-
|
|
1412
|
+
return withRecordedRelationsPrecondition(
|
|
1247
1413
|
session.flush(target, resolvedSchema, ownsWriteLock),
|
|
1248
1414
|
{ dialect: target.dialect, surface: "capture-flush" }
|
|
1249
1415
|
);
|
|
@@ -1331,15 +1497,28 @@ function createRecordedBackend(backend, schema) {
|
|
|
1331
1497
|
async hardDeleteEdge(params) {
|
|
1332
1498
|
await capture((target) => target.hardDeleteEdge(params));
|
|
1333
1499
|
},
|
|
1500
|
+
...backend.deleteEdgesBatch === void 0 ? {} : {
|
|
1501
|
+
async deleteEdgesBatch(params) {
|
|
1502
|
+
await capture((target) => target.deleteEdgesBatch(params));
|
|
1503
|
+
}
|
|
1504
|
+
},
|
|
1505
|
+
...backend.hardDeleteEdgesBatch === void 0 ? {} : {
|
|
1506
|
+
async hardDeleteEdgesBatch(params) {
|
|
1507
|
+
await capture((target) => target.hardDeleteEdgesBatch(params));
|
|
1508
|
+
}
|
|
1509
|
+
},
|
|
1334
1510
|
async transaction(fn, options) {
|
|
1335
|
-
|
|
1511
|
+
const observer = readRecordedFlushObserver(options);
|
|
1512
|
+
const backendOptions = stripRecordedFlushObserver(options);
|
|
1513
|
+
assertRequestedRecordedIsolation(backend, backendOptions);
|
|
1336
1514
|
return backend.transaction(async (target) => {
|
|
1337
1515
|
await assertRecordedCaptureTransactionIsolation(target);
|
|
1338
1516
|
const scope = createRecordedTransactionScope(target, schema, true);
|
|
1339
1517
|
const result = await fn(scope.backend, createHistoryUnsafeSqlRef());
|
|
1340
|
-
await scope.flush();
|
|
1518
|
+
const instants = await scope.flush();
|
|
1519
|
+
observer?.(instants);
|
|
1341
1520
|
return result;
|
|
1342
|
-
},
|
|
1521
|
+
}, backendOptions);
|
|
1343
1522
|
},
|
|
1344
1523
|
...backend.adoptTransaction === void 0 ? {} : {
|
|
1345
1524
|
adoptTransaction(externalTx) {
|
|
@@ -1395,6 +1574,65 @@ async function syncEmbeddings(ctx, schema, props) {
|
|
|
1395
1574
|
}
|
|
1396
1575
|
}
|
|
1397
1576
|
}
|
|
1577
|
+
async function syncEmbeddingsBatchForKind(args, schema, items) {
|
|
1578
|
+
const { graphId, nodeKind, backend } = args;
|
|
1579
|
+
if (!backend.upsertEmbedding || !backend.deleteEmbedding) {
|
|
1580
|
+
return;
|
|
1581
|
+
}
|
|
1582
|
+
const embeddingFields = getEmbeddingFields(schema);
|
|
1583
|
+
if (embeddingFields.length === 0) {
|
|
1584
|
+
return;
|
|
1585
|
+
}
|
|
1586
|
+
for (const field of embeddingFields) {
|
|
1587
|
+
const rows = [];
|
|
1588
|
+
const deletionIds = [];
|
|
1589
|
+
for (const item of items) {
|
|
1590
|
+
const value = item.props[field.fieldPath];
|
|
1591
|
+
if (isValidEmbeddingValue(value)) {
|
|
1592
|
+
rows.push({ nodeId: item.nodeId, embedding: value });
|
|
1593
|
+
} else if (value === void 0) {
|
|
1594
|
+
deletionIds.push(item.nodeId);
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
if (rows.length > 0) {
|
|
1598
|
+
if (backend.upsertEmbeddingBatch === void 0) {
|
|
1599
|
+
for (const row of rows) {
|
|
1600
|
+
await backend.upsertEmbedding({
|
|
1601
|
+
graphId,
|
|
1602
|
+
nodeKind,
|
|
1603
|
+
nodeId: row.nodeId,
|
|
1604
|
+
fieldPath: field.fieldPath,
|
|
1605
|
+
embedding: row.embedding,
|
|
1606
|
+
dimensions: field.dimensions,
|
|
1607
|
+
metric: field.metric,
|
|
1608
|
+
indexType: field.indexType
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1611
|
+
} else {
|
|
1612
|
+
await backend.upsertEmbeddingBatch({
|
|
1613
|
+
graphId,
|
|
1614
|
+
nodeKind,
|
|
1615
|
+
fieldPath: field.fieldPath,
|
|
1616
|
+
dimensions: field.dimensions,
|
|
1617
|
+
metric: field.metric,
|
|
1618
|
+
indexType: field.indexType,
|
|
1619
|
+
rows
|
|
1620
|
+
});
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
for (const nodeId of deletionIds) {
|
|
1624
|
+
await backend.deleteEmbedding({
|
|
1625
|
+
graphId,
|
|
1626
|
+
nodeKind,
|
|
1627
|
+
nodeId,
|
|
1628
|
+
fieldPath: field.fieldPath,
|
|
1629
|
+
dimensions: field.dimensions,
|
|
1630
|
+
metric: field.metric,
|
|
1631
|
+
indexType: field.indexType
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1398
1636
|
async function deleteNodeEmbeddings(ctx, schema) {
|
|
1399
1637
|
const { backend } = ctx;
|
|
1400
1638
|
if (!backend.deleteEmbedding) {
|
|
@@ -1424,42 +1662,6 @@ function isValidEmbeddingValue(value) {
|
|
|
1424
1662
|
}
|
|
1425
1663
|
|
|
1426
1664
|
// 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
1665
|
var FIELD_SEPARATOR = "\n";
|
|
1464
1666
|
function resolveCombinedLanguage(fields) {
|
|
1465
1667
|
return fields[0]?.metadata.language ?? DEFAULT_SEARCHABLE_LANGUAGE;
|
|
@@ -1503,6 +1705,55 @@ async function syncFulltext(ctx, schema, props) {
|
|
|
1503
1705
|
nodeId: ctx.nodeId
|
|
1504
1706
|
});
|
|
1505
1707
|
}
|
|
1708
|
+
async function syncFulltextBatchForKind(args, schema, items) {
|
|
1709
|
+
const { graphId, nodeKind, backend } = args;
|
|
1710
|
+
if (!backend.upsertFulltext || !backend.deleteFulltext) {
|
|
1711
|
+
return;
|
|
1712
|
+
}
|
|
1713
|
+
const rows = [];
|
|
1714
|
+
const emptyContentIds = [];
|
|
1715
|
+
const hasSearchableFields = getSearchableFields(schema).length > 0;
|
|
1716
|
+
for (const item of items) {
|
|
1717
|
+
const computed = computeFulltextContent(schema, item.props);
|
|
1718
|
+
if (computed !== void 0) {
|
|
1719
|
+
rows.push({
|
|
1720
|
+
nodeId: item.nodeId,
|
|
1721
|
+
content: computed.content,
|
|
1722
|
+
language: computed.language
|
|
1723
|
+
});
|
|
1724
|
+
} else if (hasSearchableFields) {
|
|
1725
|
+
emptyContentIds.push(item.nodeId);
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
if (rows.length > 0) {
|
|
1729
|
+
if (backend.upsertFulltextBatch === void 0) {
|
|
1730
|
+
for (const row of rows) {
|
|
1731
|
+
await backend.upsertFulltext({
|
|
1732
|
+
graphId,
|
|
1733
|
+
nodeKind,
|
|
1734
|
+
nodeId: row.nodeId,
|
|
1735
|
+
content: row.content,
|
|
1736
|
+
language: row.language
|
|
1737
|
+
});
|
|
1738
|
+
}
|
|
1739
|
+
} else {
|
|
1740
|
+
await backend.upsertFulltextBatch({ graphId, nodeKind, rows });
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
if (emptyContentIds.length > 0) {
|
|
1744
|
+
if (backend.deleteFulltextBatch === void 0) {
|
|
1745
|
+
for (const nodeId of emptyContentIds) {
|
|
1746
|
+
await backend.deleteFulltext({ graphId, nodeKind, nodeId });
|
|
1747
|
+
}
|
|
1748
|
+
} else {
|
|
1749
|
+
await backend.deleteFulltextBatch({
|
|
1750
|
+
graphId,
|
|
1751
|
+
nodeKind,
|
|
1752
|
+
nodeIds: emptyContentIds
|
|
1753
|
+
});
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1506
1757
|
async function deleteNodeFulltext(ctx, schema) {
|
|
1507
1758
|
const { backend } = ctx;
|
|
1508
1759
|
if (!backend.deleteFulltext) {
|
|
@@ -1640,10 +1891,7 @@ function checkUniqueEdge(edgeKind, fromKind, fromId, _toKind, _toId, existingCou
|
|
|
1640
1891
|
}
|
|
1641
1892
|
function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registry) {
|
|
1642
1893
|
const validFromKinds = registration.from.map((node) => node.kind);
|
|
1643
|
-
|
|
1644
|
-
(validKind) => registry.isAssignableTo(fromKind, validKind)
|
|
1645
|
-
);
|
|
1646
|
-
if (!fromValid) {
|
|
1894
|
+
if (!registry.isAssignableToAny(fromKind, validFromKinds)) {
|
|
1647
1895
|
return new EndpointError({
|
|
1648
1896
|
edgeKind,
|
|
1649
1897
|
endpoint: "from",
|
|
@@ -1652,10 +1900,7 @@ function validateEdgeEndpoints(edgeKind, fromKind, toKind, registration, registr
|
|
|
1652
1900
|
});
|
|
1653
1901
|
}
|
|
1654
1902
|
const validToKinds = registration.to.map((node) => node.kind);
|
|
1655
|
-
|
|
1656
|
-
(validKind) => registry.isAssignableTo(toKind, validKind)
|
|
1657
|
-
);
|
|
1658
|
-
if (!toValid) {
|
|
1903
|
+
if (!registry.isAssignableToAny(toKind, validToKinds)) {
|
|
1659
1904
|
return new EndpointError({
|
|
1660
1905
|
edgeKind,
|
|
1661
1906
|
endpoint: "to",
|
|
@@ -1736,6 +1981,36 @@ async function insertUniquenessEntries(ctx, kind, id, props, constraints) {
|
|
|
1736
1981
|
});
|
|
1737
1982
|
}
|
|
1738
1983
|
}
|
|
1984
|
+
async function insertUniquenessEntriesBatch(ctx, items) {
|
|
1985
|
+
const entries = [];
|
|
1986
|
+
for (const item of items) {
|
|
1987
|
+
for (const constraint of item.constraints) {
|
|
1988
|
+
if (!checkWherePredicate(constraint, item.props)) {
|
|
1989
|
+
continue;
|
|
1990
|
+
}
|
|
1991
|
+
entries.push({
|
|
1992
|
+
graphId: ctx.graphId,
|
|
1993
|
+
nodeKind: item.kind,
|
|
1994
|
+
constraintName: constraint.name,
|
|
1995
|
+
key: computeUniqueKey(
|
|
1996
|
+
item.props,
|
|
1997
|
+
constraint.fields,
|
|
1998
|
+
constraint.collation
|
|
1999
|
+
),
|
|
2000
|
+
nodeId: item.id,
|
|
2001
|
+
concreteKind: item.kind
|
|
2002
|
+
});
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
if (entries.length === 0) return;
|
|
2006
|
+
if (ctx.backend.insertUniqueBatch !== void 0) {
|
|
2007
|
+
await ctx.backend.insertUniqueBatch(entries);
|
|
2008
|
+
return;
|
|
2009
|
+
}
|
|
2010
|
+
for (const entry of entries) {
|
|
2011
|
+
await ctx.backend.insertUnique(entry);
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
1739
2014
|
async function deleteUniquenessEntries(ctx, kind, props, constraints) {
|
|
1740
2015
|
for (const constraint of constraints) {
|
|
1741
2016
|
if (!checkWherePredicate(constraint, props)) {
|
|
@@ -1847,6 +2122,14 @@ async function enforceNodeDeleteBehavior(ctx, args, backend, policy) {
|
|
|
1847
2122
|
}
|
|
1848
2123
|
case "cascade":
|
|
1849
2124
|
case "disconnect": {
|
|
2125
|
+
const batchDelete = args.mode === "hard" ? backend.hardDeleteEdgesBatch : backend.deleteEdgesBatch;
|
|
2126
|
+
if (batchDelete !== void 0) {
|
|
2127
|
+
await batchDelete.call(backend, {
|
|
2128
|
+
graphId: ctx.graphId,
|
|
2129
|
+
ids: connectedEdges.map((edge) => edge.id)
|
|
2130
|
+
});
|
|
2131
|
+
break;
|
|
2132
|
+
}
|
|
1850
2133
|
for (const edge of connectedEdges) {
|
|
1851
2134
|
await (args.mode === "hard" ? backend.hardDeleteEdge({ graphId: ctx.graphId, id: edge.id }) : backend.deleteEdge({ graphId: ctx.graphId, id: edge.id }));
|
|
1852
2135
|
}
|
|
@@ -1875,8 +2158,35 @@ async function applyNodeInsertSideEffects(ctx, args, backend) {
|
|
|
1875
2158
|
)
|
|
1876
2159
|
]);
|
|
1877
2160
|
}
|
|
2161
|
+
async function applyNodeInsertSideEffectsBatch(ctx, items, backend) {
|
|
2162
|
+
if (items.length === 0) return;
|
|
2163
|
+
await insertUniquenessEntriesBatch(
|
|
2164
|
+
uniquenessContext(ctx, backend),
|
|
2165
|
+
items.map((item) => ({
|
|
2166
|
+
kind: item.kind,
|
|
2167
|
+
id: item.id,
|
|
2168
|
+
props: item.props,
|
|
2169
|
+
constraints: item.uniqueConstraints
|
|
2170
|
+
}))
|
|
2171
|
+
);
|
|
2172
|
+
const byKind = /* @__PURE__ */ new Map();
|
|
2173
|
+
for (const item of items) {
|
|
2174
|
+
const group = byKind.get(item.kind) ?? { schema: item.schema, rows: [] };
|
|
2175
|
+
group.rows.push({ nodeId: item.id, props: item.props });
|
|
2176
|
+
byKind.set(item.kind, group);
|
|
2177
|
+
}
|
|
2178
|
+
await Promise.all(
|
|
2179
|
+
[...byKind.entries()].flatMap(([kind, group]) => {
|
|
2180
|
+
const syncArguments = { graphId: ctx.graphId, nodeKind: kind, backend };
|
|
2181
|
+
return [
|
|
2182
|
+
syncEmbeddingsBatchForKind(syncArguments, group.schema, group.rows),
|
|
2183
|
+
syncFulltextBatchForKind(syncArguments, group.schema, group.rows)
|
|
2184
|
+
];
|
|
2185
|
+
})
|
|
2186
|
+
);
|
|
2187
|
+
}
|
|
1878
2188
|
function parseRowProps(row) {
|
|
1879
|
-
return
|
|
2189
|
+
return rowPropsToObject(row.props);
|
|
1880
2190
|
}
|
|
1881
2191
|
async function applyNodeUpdate(ctx, args, backend) {
|
|
1882
2192
|
const { kind, id } = args.existing;
|
|
@@ -2005,6 +2315,6 @@ async function applyNodeResurrect(ctx, args, backend) {
|
|
|
2005
2315
|
return row;
|
|
2006
2316
|
}
|
|
2007
2317
|
|
|
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-
|
|
2318
|
+
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 };
|
|
2319
|
+
//# sourceMappingURL=chunk-CZQ3FO2Q.js.map
|
|
2320
|
+
//# sourceMappingURL=chunk-CZQ3FO2Q.js.map
|