@nicia-ai/typegraph 0.32.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -0
- package/dist/backend/postgres/index.cjs +36 -19
- package/dist/backend/postgres/index.d.cts +6 -6
- package/dist/backend/postgres/index.d.ts +6 -6
- package/dist/backend/postgres/index.js +14 -9
- package/dist/backend/postgres/pglite.cjs +18 -13
- package/dist/backend/postgres/pglite.cjs.map +1 -1
- package/dist/backend/postgres/pglite.d.cts +3 -3
- package/dist/backend/postgres/pglite.d.ts +3 -3
- package/dist/backend/postgres/pglite.js +14 -9
- package/dist/backend/postgres/pglite.js.map +1 -1
- package/dist/backend/sqlite/index.cjs +34 -17
- package/dist/backend/sqlite/index.d.cts +7 -7
- package/dist/backend/sqlite/index.d.ts +7 -7
- package/dist/backend/sqlite/index.js +13 -8
- package/dist/backend/sqlite/libsql.cjs +19 -14
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +12 -5
- package/dist/backend/sqlite/libsql.d.ts +12 -5
- package/dist/backend/sqlite/libsql.js +15 -10
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +19 -14
- package/dist/backend/sqlite/local.cjs.map +1 -1
- package/dist/backend/sqlite/local.d.cts +3 -3
- package/dist/backend/sqlite/local.d.ts +3 -3
- package/dist/backend/sqlite/local.js +14 -9
- package/dist/backend/sqlite/local.js.map +1 -1
- package/dist/chunk-2EBMPJBO.js +16 -0
- package/dist/chunk-2EBMPJBO.js.map +1 -0
- package/dist/{chunk-CFNT3ITG.cjs → chunk-2JXB3NYJ.cjs} +15 -35
- package/dist/chunk-2JXB3NYJ.cjs.map +1 -0
- package/dist/chunk-2MRAX3UE.js +105 -0
- package/dist/chunk-2MRAX3UE.js.map +1 -0
- package/dist/{chunk-2LAT5BIK.cjs → chunk-3BRVBQQD.cjs} +2328 -3131
- package/dist/chunk-3BRVBQQD.cjs.map +1 -0
- package/dist/chunk-3E7SNSIA.cjs +55 -0
- package/dist/chunk-3E7SNSIA.cjs.map +1 -0
- package/dist/{chunk-FDN43KXV.cjs → chunk-3Z6TW3CT.cjs} +20 -19
- package/dist/chunk-3Z6TW3CT.cjs.map +1 -0
- package/dist/{chunk-IJORSAC3.js → chunk-4DIBPQNJ.js} +6 -4
- package/dist/chunk-4DIBPQNJ.js.map +1 -0
- package/dist/chunk-4S2FXGBJ.js +9 -0
- package/dist/chunk-4S2FXGBJ.js.map +1 -0
- package/dist/chunk-5IQIX7LU.cjs +2070 -0
- package/dist/chunk-5IQIX7LU.cjs.map +1 -0
- package/dist/{chunk-CWFPJ3RC.js → chunk-6GNSY7AV.js} +3 -3
- package/dist/{chunk-CWFPJ3RC.js.map → chunk-6GNSY7AV.js.map} +1 -1
- package/dist/{chunk-LAZGHOZW.cjs → chunk-6HVOHZHS.cjs} +184 -117
- package/dist/chunk-6HVOHZHS.cjs.map +1 -0
- package/dist/chunk-6SCVW4AS.js +20 -0
- package/dist/chunk-6SCVW4AS.js.map +1 -0
- package/dist/chunk-A7SZZFAG.js +2010 -0
- package/dist/chunk-A7SZZFAG.js.map +1 -0
- package/dist/chunk-ACSVZPK7.cjs +21 -0
- package/dist/chunk-ACSVZPK7.cjs.map +1 -0
- package/dist/{chunk-MXE2U3EX.js → chunk-BVTWD66D.js} +4 -115
- package/dist/chunk-BVTWD66D.js.map +1 -0
- package/dist/{chunk-W4ZX2GCP.js → chunk-CHXTTSC6.js} +5 -39
- package/dist/chunk-CHXTTSC6.js.map +1 -0
- package/dist/{chunk-XQFAJVYW.js → chunk-CYX2JTDG.js} +124 -5
- package/dist/chunk-CYX2JTDG.js.map +1 -0
- package/dist/{chunk-PRMKPFN5.js → chunk-DEQFL35G.js} +4 -3
- package/dist/chunk-DEQFL35G.js.map +1 -0
- package/dist/chunk-DI74SMXS.cjs +29 -0
- package/dist/chunk-DI74SMXS.cjs.map +1 -0
- package/dist/{chunk-WWVV44DY.cjs → chunk-G6SOJEDI.cjs} +11 -11
- package/dist/{chunk-WWVV44DY.cjs.map → chunk-G6SOJEDI.cjs.map} +1 -1
- package/dist/{chunk-LM2IC4ZJ.cjs → chunk-GQANNXXT.cjs} +15 -14
- package/dist/chunk-GQANNXXT.cjs.map +1 -0
- package/dist/chunk-GZCNZ7QW.js +24 -0
- package/dist/chunk-GZCNZ7QW.js.map +1 -0
- package/dist/{chunk-KTIEB7VH.cjs → chunk-HK5SATYM.cjs} +35 -58
- package/dist/chunk-HK5SATYM.cjs.map +1 -0
- package/dist/chunk-HMFK4BXR.cjs +12 -0
- package/dist/{chunk-6ZR4QC3O.cjs.map → chunk-HMFK4BXR.cjs.map} +1 -1
- package/dist/chunk-ITE4IXAK.js +25 -0
- package/dist/chunk-ITE4IXAK.js.map +1 -0
- package/dist/chunk-JJRCLAUN.cjs +155 -0
- package/dist/chunk-JJRCLAUN.cjs.map +1 -0
- package/dist/{chunk-ZFWNO3GE.cjs → chunk-JQGIPGVL.cjs} +66 -2
- package/dist/chunk-JQGIPGVL.cjs.map +1 -0
- package/dist/{chunk-2BVHPOIG.js → chunk-K2TGS3EN.js} +105 -38
- package/dist/chunk-K2TGS3EN.js.map +1 -0
- package/dist/chunk-K34OPSJK.js +29 -0
- package/dist/chunk-K34OPSJK.js.map +1 -0
- package/dist/{chunk-YW7GHMF4.cjs → chunk-KGC4LY5T.cjs} +18 -17
- package/dist/chunk-KGC4LY5T.cjs.map +1 -0
- package/dist/{chunk-SB65GJNY.cjs → chunk-KNHYNQQ3.cjs} +111 -72
- package/dist/chunk-KNHYNQQ3.cjs.map +1 -0
- package/dist/{chunk-C4C4Q7A6.js → chunk-KUTNI6SI.js} +6 -21
- package/dist/chunk-KUTNI6SI.js.map +1 -0
- package/dist/{chunk-NDM5PXEH.js → chunk-LANHCOXB.js} +44 -11
- package/dist/chunk-LANHCOXB.js.map +1 -0
- package/dist/chunk-N6WTUSBV.cjs +23 -0
- package/dist/chunk-N6WTUSBV.cjs.map +1 -0
- package/dist/{chunk-73KASJGO.cjs → chunk-NAUA4PW5.cjs} +4 -28
- package/dist/chunk-NAUA4PW5.cjs.map +1 -0
- package/dist/chunk-QV245VMN.js +145 -0
- package/dist/chunk-QV245VMN.js.map +1 -0
- package/dist/{chunk-CEF2QOTO.js → chunk-RBV7YCQD.js} +4 -3
- package/dist/chunk-RBV7YCQD.js.map +1 -0
- package/dist/chunk-RHZWOJVA.cjs +109 -0
- package/dist/chunk-RHZWOJVA.cjs.map +1 -0
- package/dist/{chunk-6RMLO5O4.cjs → chunk-RRKQAKD6.cjs} +13 -11
- package/dist/chunk-RRKQAKD6.cjs.map +1 -0
- package/dist/{chunk-TUA3MEJJ.js → chunk-RY2VIWAM.js} +612 -564
- package/dist/chunk-RY2VIWAM.js.map +1 -0
- package/dist/{chunk-PIHXFF73.js → chunk-SHLY4MCM.js} +3 -3
- package/dist/{chunk-PIHXFF73.js.map → chunk-SHLY4MCM.js.map} +1 -1
- package/dist/{chunk-HFBRAOF7.js → chunk-T2DWPQNE.js} +103 -64
- package/dist/chunk-T2DWPQNE.js.map +1 -0
- package/dist/{chunk-WYTUF3QO.js → chunk-T46GR2VY.js} +3 -3
- package/dist/{chunk-WYTUF3QO.js.map → chunk-T46GR2VY.js.map} +1 -1
- package/dist/{chunk-EEYV6UOE.cjs → chunk-T6SPUYLX.cjs} +5 -43
- package/dist/chunk-T6SPUYLX.cjs.map +1 -0
- package/dist/{chunk-3QRBXYT5.cjs → chunk-TGJE22RM.cjs} +6 -6
- package/dist/{chunk-3QRBXYT5.cjs.map → chunk-TGJE22RM.cjs.map} +1 -1
- package/dist/{chunk-YL4F3CMD.cjs → chunk-TOTPVGOG.cjs} +105 -72
- package/dist/chunk-TOTPVGOG.cjs.map +1 -0
- package/dist/{chunk-3HQDMOBK.cjs → chunk-UJLOZYKT.cjs} +680 -636
- package/dist/chunk-UJLOZYKT.cjs.map +1 -0
- package/dist/chunk-UNNPKQUG.cjs +1390 -0
- package/dist/chunk-UNNPKQUG.cjs.map +1 -0
- package/dist/chunk-UR7W5YQK.js +18 -0
- package/dist/chunk-UR7W5YQK.js.map +1 -0
- package/dist/chunk-V3QNTB7Z.js +1351 -0
- package/dist/chunk-V3QNTB7Z.js.map +1 -0
- package/dist/{chunk-XKNAK27R.js → chunk-VCGO4V26.js} +4 -3
- package/dist/chunk-VCGO4V26.js.map +1 -0
- package/dist/{chunk-YQGLVWB2.cjs → chunk-WL2SG7ZV.cjs} +6 -122
- package/dist/chunk-WL2SG7ZV.cjs.map +1 -0
- package/dist/{chunk-WNORITK6.js → chunk-WLRIWYHQ.js} +2041 -2834
- package/dist/chunk-WLRIWYHQ.js.map +1 -0
- package/dist/{chunk-JKRKIEVA.cjs → chunk-WVC2Q2FD.cjs} +128 -6
- package/dist/chunk-WVC2Q2FD.cjs.map +1 -0
- package/dist/chunk-XLUNB2TZ.js +53 -0
- package/dist/chunk-XLUNB2TZ.js.map +1 -0
- package/dist/chunk-XXVEULWX.js +39 -0
- package/dist/chunk-XXVEULWX.js.map +1 -0
- package/dist/chunk-YAZE7QZR.cjs +32 -0
- package/dist/chunk-YAZE7QZR.cjs.map +1 -0
- package/dist/chunk-YC6PWTHY.cjs +44 -0
- package/dist/chunk-YC6PWTHY.cjs.map +1 -0
- package/dist/chunk-Z5HBYM7U.cjs +11 -0
- package/dist/chunk-Z5HBYM7U.cjs.map +1 -0
- package/dist/{chunk-454I6GDF.js → chunk-Z5XBMDXU.js} +63 -3
- package/dist/chunk-Z5XBMDXU.js.map +1 -0
- package/dist/{chunk-CAMMC3E4.cjs → chunk-ZP5WHI4C.cjs} +109 -81
- package/dist/chunk-ZP5WHI4C.cjs.map +1 -0
- package/dist/{chunk-YCV72E6L.js → chunk-ZURTTSCM.js} +4 -25
- package/dist/chunk-ZURTTSCM.js.map +1 -0
- package/dist/{chunk-7WW3WL6E.js → chunk-ZV5N4DBG.js} +49 -21
- package/dist/chunk-ZV5N4DBG.js.map +1 -0
- package/dist/chunk-ZY4GXIVN.cjs +32 -0
- package/dist/chunk-ZY4GXIVN.cjs.map +1 -0
- package/dist/{ddl-C8e8zDAE.d.ts → ddl-BrmPg61z.d.ts} +3 -3
- package/dist/{ddl-CwyG4HoQ.d.cts → ddl-j1-sH6lE.d.cts} +3 -3
- package/dist/{extension-types-D1k0inWU.d.cts → extension-types-YGFJPrzK.d.cts} +1 -1
- package/dist/{extension-types-D1k0inWU.d.ts → extension-types-YGFJPrzK.d.ts} +1 -1
- package/dist/graph-extension/index.cjs +18 -17
- package/dist/graph-extension/index.d.cts +4 -4
- package/dist/graph-extension/index.d.ts +4 -4
- package/dist/graph-extension/index.js +3 -2
- package/dist/graph-merge/index.cjs +295 -146
- package/dist/graph-merge/index.cjs.map +1 -1
- package/dist/graph-merge/index.d.cts +6 -6
- package/dist/graph-merge/index.d.ts +6 -6
- package/dist/graph-merge/index.js +173 -24
- package/dist/graph-merge/index.js.map +1 -1
- package/dist/{index-BEK0VtNB.d.ts → index-DGX6D9j1.d.ts} +2 -2
- package/dist/{index-C8sSTErx.d.cts → index-SEvUHDA6.d.cts} +2 -2
- package/dist/index.cjs +206 -172
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -55
- package/dist/index.d.ts +25 -55
- package/dist/index.js +32 -22
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +28 -25
- package/dist/indexes/index.d.cts +5 -5
- package/dist/indexes/index.d.ts +5 -5
- package/dist/indexes/index.js +10 -7
- package/dist/interchange/index.cjs +25 -16
- package/dist/interchange/index.d.cts +5 -5
- package/dist/interchange/index.d.ts +5 -5
- package/dist/interchange/index.js +12 -3
- package/dist/{manager-8htmuGr-.d.ts → manager-BZUeN_BU.d.ts} +2 -2
- package/dist/{manager-aVgxbGt-.d.cts → manager-ms9cKdc6.d.cts} +2 -2
- package/dist/{materialize-indexes-CAGhqPHQ.d.ts → materialize-indexes-CAkIYFV-.d.ts} +1 -1
- package/dist/{materialize-indexes-DEYkU-wr.d.cts → materialize-indexes-D20xNluI.d.cts} +1 -1
- package/dist/{postgres-Dhom7iiX.d.ts → postgres-BhpxGMC5.d.cts} +2651 -596
- package/dist/{postgres-jgXmD45C.d.cts → postgres-CWHLwNl1.d.ts} +2651 -596
- package/dist/profiler/index.cjs +5 -4
- package/dist/profiler/index.cjs.map +1 -1
- package/dist/profiler/index.d.cts +7 -7
- package/dist/profiler/index.d.ts +7 -7
- package/dist/profiler/index.js +3 -2
- package/dist/profiler/index.js.map +1 -1
- package/dist/provenance/index.cjs +591 -0
- package/dist/provenance/index.cjs.map +1 -0
- package/dist/provenance/index.d.cts +73 -0
- package/dist/provenance/index.d.ts +73 -0
- package/dist/provenance/index.js +589 -0
- package/dist/provenance/index.js.map +1 -0
- package/dist/schema/index.cjs +37 -32
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +7 -7
- package/dist/schema/index.d.ts +7 -7
- package/dist/schema/index.js +14 -9
- package/dist/schema/index.js.map +1 -1
- package/dist/{sqlite-DcQ_BCUW.d.cts → sqlite-CGu5SLsw.d.ts} +2726 -455
- package/dist/{sqlite-BfLsCEqO.d.ts → sqlite-XrDxNaa7.d.cts} +2726 -455
- package/dist/{store-view-pBOUrQte.d.ts → store-view-BlgnhEYf.d.ts} +467 -131
- package/dist/{store-view-lTcb_cnp.d.cts → store-view-D09po4H6.d.cts} +467 -131
- package/dist/{types-DGDiXAYc.d.ts → types-B1TbZJYS.d.ts} +2 -2
- package/dist/{types-Dk8r09KY.d.ts → types-D1Sqeyxy.d.ts} +161 -26
- package/dist/{types-5RQwzWXx.d.cts → types-DiE1AO7p.d.cts} +2 -2
- package/dist/{types-Dvmn-eal.d.cts → types-DkNnF-7K.d.cts} +161 -26
- package/dist/{where-Cx_glEEB.d.cts → where-DKjuofPr.d.cts} +2 -2
- package/dist/{where-CHZFELX0.d.ts → where-DrUIIWHb.d.ts} +2 -2
- package/package.json +8 -2
- package/dist/chunk-2BVHPOIG.js.map +0 -1
- package/dist/chunk-2LAT5BIK.cjs.map +0 -1
- package/dist/chunk-2YMGNYXY.js +0 -40
- package/dist/chunk-2YMGNYXY.js.map +0 -1
- package/dist/chunk-3HQDMOBK.cjs.map +0 -1
- package/dist/chunk-454I6GDF.js.map +0 -1
- package/dist/chunk-6G35I3VW.cjs +0 -40
- package/dist/chunk-6G35I3VW.cjs.map +0 -1
- package/dist/chunk-6RMLO5O4.cjs.map +0 -1
- package/dist/chunk-6ZR4QC3O.cjs +0 -12
- package/dist/chunk-73KASJGO.cjs.map +0 -1
- package/dist/chunk-7WW3WL6E.js.map +0 -1
- package/dist/chunk-C4C4Q7A6.js.map +0 -1
- package/dist/chunk-CAMMC3E4.cjs.map +0 -1
- package/dist/chunk-CEF2QOTO.js.map +0 -1
- package/dist/chunk-CFNT3ITG.cjs.map +0 -1
- package/dist/chunk-EEYV6UOE.cjs.map +0 -1
- package/dist/chunk-FDN43KXV.cjs.map +0 -1
- package/dist/chunk-HFBRAOF7.js.map +0 -1
- package/dist/chunk-IJORSAC3.js.map +0 -1
- package/dist/chunk-JKRKIEVA.cjs.map +0 -1
- package/dist/chunk-KTIEB7VH.cjs.map +0 -1
- package/dist/chunk-LAZGHOZW.cjs.map +0 -1
- package/dist/chunk-LM2IC4ZJ.cjs.map +0 -1
- package/dist/chunk-M6OC455F.js +0 -65
- package/dist/chunk-M6OC455F.js.map +0 -1
- package/dist/chunk-MXE2U3EX.js.map +0 -1
- package/dist/chunk-NDM5PXEH.js.map +0 -1
- package/dist/chunk-PRMKPFN5.js.map +0 -1
- package/dist/chunk-RP7YITHX.cjs +0 -70
- package/dist/chunk-RP7YITHX.cjs.map +0 -1
- package/dist/chunk-SAJSMR2B.js +0 -35
- package/dist/chunk-SAJSMR2B.js.map +0 -1
- package/dist/chunk-SB65GJNY.cjs.map +0 -1
- package/dist/chunk-TUA3MEJJ.js.map +0 -1
- package/dist/chunk-W4ZX2GCP.js.map +0 -1
- package/dist/chunk-WNORITK6.js.map +0 -1
- package/dist/chunk-XKNAK27R.js.map +0 -1
- package/dist/chunk-XQFAJVYW.js.map +0 -1
- package/dist/chunk-YCV72E6L.js.map +0 -1
- package/dist/chunk-YL4F3CMD.cjs.map +0 -1
- package/dist/chunk-YQGLVWB2.cjs.map +0 -1
- package/dist/chunk-YW7GHMF4.cjs.map +0 -1
- package/dist/chunk-ZFWNO3GE.cjs.map +0 -1
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
3
|
+
var chunkWVC2Q2FD_cjs = require('./chunk-WVC2Q2FD.cjs');
|
|
4
|
+
var chunkG6SOJEDI_cjs = require('./chunk-G6SOJEDI.cjs');
|
|
5
|
+
var chunkJJRCLAUN_cjs = require('./chunk-JJRCLAUN.cjs');
|
|
6
|
+
var chunkACSVZPK7_cjs = require('./chunk-ACSVZPK7.cjs');
|
|
7
|
+
var chunk2JXB3NYJ_cjs = require('./chunk-2JXB3NYJ.cjs');
|
|
8
|
+
var chunkZY4GXIVN_cjs = require('./chunk-ZY4GXIVN.cjs');
|
|
9
|
+
var chunkUNNPKQUG_cjs = require('./chunk-UNNPKQUG.cjs');
|
|
10
|
+
var chunkRHZWOJVA_cjs = require('./chunk-RHZWOJVA.cjs');
|
|
11
|
+
var chunkYAZE7QZR_cjs = require('./chunk-YAZE7QZR.cjs');
|
|
8
12
|
var chunkJIEJCTDS_cjs = require('./chunk-JIEJCTDS.cjs');
|
|
9
13
|
var drizzleOrm = require('drizzle-orm');
|
|
10
14
|
var pgCore = require('drizzle-orm/pg-core');
|
|
@@ -21,6 +25,9 @@ var tsvector = pgCore.customType({
|
|
|
21
25
|
var DEFAULT_TABLE_NAMES = {
|
|
22
26
|
nodes: "typegraph_nodes",
|
|
23
27
|
edges: "typegraph_edges",
|
|
28
|
+
recordedNodes: "typegraph_recorded_nodes",
|
|
29
|
+
recordedEdges: "typegraph_recorded_edges",
|
|
30
|
+
recordedClock: "typegraph_recorded_clock",
|
|
24
31
|
uniques: "typegraph_node_uniques",
|
|
25
32
|
schemaVersions: "typegraph_schema_versions",
|
|
26
33
|
fulltext: "typegraph_node_fulltext",
|
|
@@ -57,7 +64,7 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
57
64
|
),
|
|
58
65
|
pgCore.index(`${n.nodes}_deleted_idx`).on(t.graphId, t.deletedAt),
|
|
59
66
|
pgCore.index(`${n.nodes}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),
|
|
60
|
-
...
|
|
67
|
+
...chunkG6SOJEDI_cjs.buildPostgresNodeIndexBuilders(t, indexes)
|
|
61
68
|
]
|
|
62
69
|
);
|
|
63
70
|
const edges2 = pgCore.pgTable(
|
|
@@ -116,9 +123,114 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
116
123
|
t.fromId,
|
|
117
124
|
t.validTo
|
|
118
125
|
),
|
|
119
|
-
...
|
|
126
|
+
...chunkG6SOJEDI_cjs.buildPostgresEdgeIndexBuilders(t, indexes)
|
|
120
127
|
]
|
|
121
128
|
);
|
|
129
|
+
const recordedNodes2 = pgCore.pgTable(
|
|
130
|
+
n.recordedNodes,
|
|
131
|
+
{
|
|
132
|
+
historyId: pgCore.text("history_id").notNull(),
|
|
133
|
+
graphId: pgCore.text("graph_id").notNull(),
|
|
134
|
+
kind: pgCore.text("kind").notNull(),
|
|
135
|
+
id: pgCore.text("id").notNull(),
|
|
136
|
+
props: pgCore.jsonb("props").notNull(),
|
|
137
|
+
version: pgCore.integer("version").notNull(),
|
|
138
|
+
validFrom: pgCore.timestamp("valid_from", { withTimezone: true }),
|
|
139
|
+
validTo: pgCore.timestamp("valid_to", { withTimezone: true }),
|
|
140
|
+
createdAt: pgCore.timestamp("created_at", { withTimezone: true }).notNull(),
|
|
141
|
+
updatedAt: pgCore.timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
142
|
+
deletedAt: pgCore.timestamp("deleted_at", { withTimezone: true }),
|
|
143
|
+
recordedFrom: pgCore.timestamp("recorded_from", { withTimezone: true }).notNull(),
|
|
144
|
+
recordedTo: pgCore.timestamp("recorded_to", { withTimezone: true }).notNull(),
|
|
145
|
+
op: pgCore.text("op").notNull(),
|
|
146
|
+
schemaVersion: pgCore.integer("schema_version"),
|
|
147
|
+
txId: pgCore.text("tx_id"),
|
|
148
|
+
meta: pgCore.jsonb("meta")
|
|
149
|
+
},
|
|
150
|
+
(t) => [
|
|
151
|
+
pgCore.primaryKey({ columns: [t.historyId] }),
|
|
152
|
+
pgCore.index(`${n.recordedNodes}_entity_idx`).on(
|
|
153
|
+
t.graphId,
|
|
154
|
+
t.kind,
|
|
155
|
+
t.id,
|
|
156
|
+
t.recordedFrom,
|
|
157
|
+
t.recordedTo
|
|
158
|
+
),
|
|
159
|
+
pgCore.index(`${n.recordedNodes}_open_idx`).on(t.graphId, t.recordedTo),
|
|
160
|
+
pgCore.index(`${n.recordedNodes}_valid_idx`).on(
|
|
161
|
+
t.graphId,
|
|
162
|
+
t.validFrom,
|
|
163
|
+
t.validTo
|
|
164
|
+
)
|
|
165
|
+
]
|
|
166
|
+
);
|
|
167
|
+
const recordedEdges2 = pgCore.pgTable(
|
|
168
|
+
n.recordedEdges,
|
|
169
|
+
{
|
|
170
|
+
historyId: pgCore.text("history_id").notNull(),
|
|
171
|
+
graphId: pgCore.text("graph_id").notNull(),
|
|
172
|
+
id: pgCore.text("id").notNull(),
|
|
173
|
+
kind: pgCore.text("kind").notNull(),
|
|
174
|
+
fromKind: pgCore.text("from_kind").notNull(),
|
|
175
|
+
fromId: pgCore.text("from_id").notNull(),
|
|
176
|
+
toKind: pgCore.text("to_kind").notNull(),
|
|
177
|
+
toId: pgCore.text("to_id").notNull(),
|
|
178
|
+
props: pgCore.jsonb("props").notNull(),
|
|
179
|
+
validFrom: pgCore.timestamp("valid_from", { withTimezone: true }),
|
|
180
|
+
validTo: pgCore.timestamp("valid_to", { withTimezone: true }),
|
|
181
|
+
createdAt: pgCore.timestamp("created_at", { withTimezone: true }).notNull(),
|
|
182
|
+
updatedAt: pgCore.timestamp("updated_at", { withTimezone: true }).notNull(),
|
|
183
|
+
deletedAt: pgCore.timestamp("deleted_at", { withTimezone: true }),
|
|
184
|
+
recordedFrom: pgCore.timestamp("recorded_from", { withTimezone: true }).notNull(),
|
|
185
|
+
recordedTo: pgCore.timestamp("recorded_to", { withTimezone: true }).notNull(),
|
|
186
|
+
op: pgCore.text("op").notNull(),
|
|
187
|
+
schemaVersion: pgCore.integer("schema_version"),
|
|
188
|
+
txId: pgCore.text("tx_id"),
|
|
189
|
+
meta: pgCore.jsonb("meta")
|
|
190
|
+
},
|
|
191
|
+
(t) => [
|
|
192
|
+
pgCore.primaryKey({ columns: [t.historyId] }),
|
|
193
|
+
pgCore.index(`${n.recordedEdges}_entity_idx`).on(
|
|
194
|
+
t.graphId,
|
|
195
|
+
t.kind,
|
|
196
|
+
t.id,
|
|
197
|
+
t.recordedFrom,
|
|
198
|
+
t.recordedTo
|
|
199
|
+
),
|
|
200
|
+
pgCore.index(`${n.recordedEdges}_open_idx`).on(t.graphId, t.recordedTo),
|
|
201
|
+
pgCore.index(`${n.recordedEdges}_from_idx`).on(
|
|
202
|
+
t.graphId,
|
|
203
|
+
t.fromKind,
|
|
204
|
+
t.fromId,
|
|
205
|
+
t.kind,
|
|
206
|
+
t.toKind,
|
|
207
|
+
t.recordedFrom,
|
|
208
|
+
t.recordedTo
|
|
209
|
+
),
|
|
210
|
+
pgCore.index(`${n.recordedEdges}_to_idx`).on(
|
|
211
|
+
t.graphId,
|
|
212
|
+
t.toKind,
|
|
213
|
+
t.toId,
|
|
214
|
+
t.kind,
|
|
215
|
+
t.fromKind,
|
|
216
|
+
t.recordedFrom,
|
|
217
|
+
t.recordedTo
|
|
218
|
+
),
|
|
219
|
+
pgCore.index(`${n.recordedEdges}_valid_idx`).on(
|
|
220
|
+
t.graphId,
|
|
221
|
+
t.validFrom,
|
|
222
|
+
t.validTo
|
|
223
|
+
)
|
|
224
|
+
]
|
|
225
|
+
);
|
|
226
|
+
const recordedClock2 = pgCore.pgTable(
|
|
227
|
+
n.recordedClock,
|
|
228
|
+
{
|
|
229
|
+
graphId: pgCore.text("graph_id").notNull(),
|
|
230
|
+
recordedAt: pgCore.timestamp("recorded_at", { withTimezone: true }).notNull()
|
|
231
|
+
},
|
|
232
|
+
(t) => [pgCore.primaryKey({ columns: [t.graphId] })]
|
|
233
|
+
);
|
|
122
234
|
const uniques2 = pgCore.pgTable(
|
|
123
235
|
n.uniques,
|
|
124
236
|
{
|
|
@@ -242,6 +354,9 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
242
354
|
return {
|
|
243
355
|
nodes: nodes2,
|
|
244
356
|
edges: edges2,
|
|
357
|
+
recordedNodes: recordedNodes2,
|
|
358
|
+
recordedEdges: recordedEdges2,
|
|
359
|
+
recordedClock: recordedClock2,
|
|
245
360
|
uniques: uniques2,
|
|
246
361
|
schemaVersions: schemaVersions2,
|
|
247
362
|
indexMaterializations,
|
|
@@ -253,7 +368,16 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
253
368
|
};
|
|
254
369
|
}
|
|
255
370
|
var tables2 = createPostgresTables();
|
|
256
|
-
var {
|
|
371
|
+
var {
|
|
372
|
+
nodes,
|
|
373
|
+
edges,
|
|
374
|
+
recordedNodes,
|
|
375
|
+
recordedEdges,
|
|
376
|
+
recordedClock,
|
|
377
|
+
uniques,
|
|
378
|
+
schemaVersions,
|
|
379
|
+
fulltext
|
|
380
|
+
} = tables2;
|
|
257
381
|
function getSqliteColumnType(column) {
|
|
258
382
|
switch (column.columnType) {
|
|
259
383
|
case "SQLiteText": {
|
|
@@ -309,9 +433,9 @@ function renderIndexColumn(col) {
|
|
|
309
433
|
if (col && typeof col === "object" && "name" in col) {
|
|
310
434
|
return `"${col.name}"`;
|
|
311
435
|
}
|
|
312
|
-
const
|
|
313
|
-
if (
|
|
314
|
-
return
|
|
436
|
+
const sql13 = tryInlineSql(col);
|
|
437
|
+
if (sql13 !== void 0) {
|
|
438
|
+
return sql13;
|
|
315
439
|
}
|
|
316
440
|
return "unknown";
|
|
317
441
|
}
|
|
@@ -324,16 +448,16 @@ function tryInlineSql(value) {
|
|
|
324
448
|
}
|
|
325
449
|
return inlineSql(value);
|
|
326
450
|
}
|
|
327
|
-
function flattenSqlChunk(
|
|
328
|
-
if (typeof
|
|
329
|
-
return
|
|
451
|
+
function flattenSqlChunk(chunk2) {
|
|
452
|
+
if (typeof chunk2 === "string") {
|
|
453
|
+
return chunk2;
|
|
330
454
|
}
|
|
331
|
-
if (typeof
|
|
332
|
-
if ("name" in
|
|
333
|
-
return `"${
|
|
455
|
+
if (typeof chunk2 === "object" && chunk2 !== null) {
|
|
456
|
+
if ("name" in chunk2 && typeof chunk2.name === "string") {
|
|
457
|
+
return `"${chunk2.name}"`;
|
|
334
458
|
}
|
|
335
|
-
if ("value" in
|
|
336
|
-
const value =
|
|
459
|
+
if ("value" in chunk2) {
|
|
460
|
+
const value = chunk2.value;
|
|
337
461
|
if (typeof value === "string") {
|
|
338
462
|
return value;
|
|
339
463
|
}
|
|
@@ -341,17 +465,17 @@ function flattenSqlChunk(chunk) {
|
|
|
341
465
|
return value.map((part) => flattenSqlChunk(part)).join("");
|
|
342
466
|
}
|
|
343
467
|
}
|
|
344
|
-
if ("queryChunks" in
|
|
345
|
-
return
|
|
468
|
+
if ("queryChunks" in chunk2 && Array.isArray(chunk2.queryChunks)) {
|
|
469
|
+
return chunk2.queryChunks.map((part) => flattenSqlChunk(part)).join("");
|
|
346
470
|
}
|
|
347
|
-
if ("getSQL" in
|
|
348
|
-
const maybe =
|
|
471
|
+
if ("getSQL" in chunk2) {
|
|
472
|
+
const maybe = chunk2;
|
|
349
473
|
if (typeof maybe.getSQL === "function") {
|
|
350
474
|
return flattenSqlChunk(maybe.getSQL());
|
|
351
475
|
}
|
|
352
476
|
}
|
|
353
477
|
}
|
|
354
|
-
throw new Error(`Unable to inline SQL chunk: ${String(
|
|
478
|
+
throw new Error(`Unable to inline SQL chunk: ${String(chunk2)}`);
|
|
355
479
|
}
|
|
356
480
|
function inlineSql(value) {
|
|
357
481
|
try {
|
|
@@ -387,13 +511,13 @@ function isSqliteTable(value) {
|
|
|
387
511
|
function runtimeStrategyContributions(fulltextStrategy, fulltextTableName) {
|
|
388
512
|
return fulltextStrategy.ownedTables(fulltextTableName).filter((contribution) => contribution.runtimeEnsure);
|
|
389
513
|
}
|
|
390
|
-
function sqliteContributions(tables3 =
|
|
514
|
+
function sqliteContributions(tables3 = chunkWVC2Q2FD_cjs.tables, fulltextStrategy = chunk2JXB3NYJ_cjs.fts5Strategy) {
|
|
391
515
|
const contributions = [];
|
|
392
516
|
for (const [key, table] of Object.entries(tables3)) {
|
|
393
517
|
if (!isSqliteTable(table)) continue;
|
|
394
518
|
contributions.push({
|
|
395
519
|
logicalName: key,
|
|
396
|
-
owner:
|
|
520
|
+
owner: chunk2JXB3NYJ_cjs.BASE_CONTRIBUTION_OWNER,
|
|
397
521
|
tableName: sqliteCore.getTableConfig(table).name,
|
|
398
522
|
createDdl: [
|
|
399
523
|
generateSqliteCreateTableSQL(table),
|
|
@@ -409,12 +533,12 @@ function sqliteContributions(tables3 = chunkJKRKIEVA_cjs.tables, fulltextStrateg
|
|
|
409
533
|
}
|
|
410
534
|
return contributions;
|
|
411
535
|
}
|
|
412
|
-
function generateSqliteDDL(tables3 =
|
|
536
|
+
function generateSqliteDDL(tables3 = chunkWVC2Q2FD_cjs.tables, fulltextStrategy = chunk2JXB3NYJ_cjs.fts5Strategy) {
|
|
413
537
|
return sqliteContributions(tables3, fulltextStrategy).flatMap(
|
|
414
538
|
(contribution) => [...contribution.createDdl]
|
|
415
539
|
);
|
|
416
540
|
}
|
|
417
|
-
function generateSqliteMigrationSQL(tables3 =
|
|
541
|
+
function generateSqliteMigrationSQL(tables3 = chunkWVC2Q2FD_cjs.tables, fulltextStrategy = chunk2JXB3NYJ_cjs.fts5Strategy) {
|
|
418
542
|
return generateSqliteDDL(tables3, fulltextStrategy).join("\n\n");
|
|
419
543
|
}
|
|
420
544
|
function getPgColumnType(column) {
|
|
@@ -496,14 +620,14 @@ function generatePgCreateIndexSQL(table) {
|
|
|
496
620
|
function isPgTable(value) {
|
|
497
621
|
return drizzleOrm.is(value, pgCore.PgTable);
|
|
498
622
|
}
|
|
499
|
-
function postgresContributions(tables3 = tables2, fulltextStrategy =
|
|
623
|
+
function postgresContributions(tables3 = tables2, fulltextStrategy = chunk2JXB3NYJ_cjs.tsvectorStrategy) {
|
|
500
624
|
const contributions = [];
|
|
501
625
|
for (const [key, table] of Object.entries(tables3)) {
|
|
502
626
|
if (!isPgTable(table)) continue;
|
|
503
627
|
if (table === tables3.fulltext) continue;
|
|
504
628
|
contributions.push({
|
|
505
629
|
logicalName: key,
|
|
506
|
-
owner:
|
|
630
|
+
owner: chunk2JXB3NYJ_cjs.BASE_CONTRIBUTION_OWNER,
|
|
507
631
|
tableName: pgCore.getTableConfig(table).name,
|
|
508
632
|
createDdl: [
|
|
509
633
|
generatePgCreateTableSQL(table),
|
|
@@ -519,12 +643,12 @@ function postgresContributions(tables3 = tables2, fulltextStrategy = chunkCFNT3I
|
|
|
519
643
|
}
|
|
520
644
|
return contributions;
|
|
521
645
|
}
|
|
522
|
-
function generatePostgresDDL(tables3 = tables2, fulltextStrategy =
|
|
646
|
+
function generatePostgresDDL(tables3 = tables2, fulltextStrategy = chunk2JXB3NYJ_cjs.tsvectorStrategy) {
|
|
523
647
|
return postgresContributions(tables3, fulltextStrategy).flatMap(
|
|
524
648
|
(contribution) => [...contribution.createDdl]
|
|
525
649
|
);
|
|
526
650
|
}
|
|
527
|
-
function generatePostgresMigrationSQL(tables3 = tables2, fulltextStrategy =
|
|
651
|
+
function generatePostgresMigrationSQL(tables3 = tables2, fulltextStrategy = chunk2JXB3NYJ_cjs.tsvectorStrategy) {
|
|
528
652
|
const extensionSql = "-- Enable pgvector extension for vector similarity search\nCREATE EXTENSION IF NOT EXISTS vector;";
|
|
529
653
|
const ddlSql = generatePostgresDDL(tables3, fulltextStrategy).join("\n\n");
|
|
530
654
|
return `${extensionSql}
|
|
@@ -594,7 +718,7 @@ function vectorSlotFromDropIndexParams(params) {
|
|
|
594
718
|
};
|
|
595
719
|
}
|
|
596
720
|
function mapVectorWriteError(error, params) {
|
|
597
|
-
const mismatch =
|
|
721
|
+
const mismatch = chunkRHZWOJVA_cjs.parseDimensionMismatch(error);
|
|
598
722
|
if (mismatch === void 0) return error;
|
|
599
723
|
const attempted = mismatch.actual ?? "a different number of";
|
|
600
724
|
return new chunkJIEJCTDS_cjs.EmbeddingDimensionChangedError(
|
|
@@ -608,152 +732,12 @@ function mapVectorWriteError(error, params) {
|
|
|
608
732
|
{ cause: error }
|
|
609
733
|
);
|
|
610
734
|
}
|
|
611
|
-
|
|
612
|
-
// src/backend/drizzle/row-mappers.ts
|
|
613
|
-
function requireTimestamp(value, field) {
|
|
614
|
-
if (value === void 0) {
|
|
615
|
-
throw new chunkJIEJCTDS_cjs.DatabaseOperationError(
|
|
616
|
-
`Expected non-null ${field} timestamp`,
|
|
617
|
-
{ operation: "select", entity: "row" }
|
|
618
|
-
);
|
|
619
|
-
}
|
|
620
|
-
return value;
|
|
621
|
-
}
|
|
622
|
-
function asString(value, field) {
|
|
623
|
-
if (typeof value !== "string") {
|
|
624
|
-
throw new chunkJIEJCTDS_cjs.DatabaseOperationError(
|
|
625
|
-
`Expected ${field} to be string, got ${typeof value}`,
|
|
626
|
-
{ operation: "select", entity: "row" }
|
|
627
|
-
);
|
|
628
|
-
}
|
|
629
|
-
return value;
|
|
630
|
-
}
|
|
631
|
-
function asNumber(value, field) {
|
|
632
|
-
if (typeof value !== "number") {
|
|
633
|
-
throw new chunkJIEJCTDS_cjs.DatabaseOperationError(
|
|
634
|
-
`Expected ${field} to be number, got ${typeof value}`,
|
|
635
|
-
{ operation: "select", entity: "row" }
|
|
636
|
-
);
|
|
637
|
-
}
|
|
638
|
-
return value;
|
|
639
|
-
}
|
|
640
|
-
function nowIso() {
|
|
641
|
-
return (/* @__PURE__ */ new Date()).toISOString();
|
|
642
|
-
}
|
|
643
|
-
function nullToUndefined(value) {
|
|
644
|
-
return value ?? void 0;
|
|
645
|
-
}
|
|
646
|
-
function formatPostgresTimestamp(value) {
|
|
647
|
-
if (value === null || value === void 0) return void 0;
|
|
648
|
-
if (value instanceof Date) return value.toISOString();
|
|
649
|
-
if (typeof value === "string") {
|
|
650
|
-
if (value.includes("T")) return value;
|
|
651
|
-
const date = new Date(value);
|
|
652
|
-
if (!Number.isNaN(date.getTime())) return date.toISOString();
|
|
653
|
-
return value;
|
|
654
|
-
}
|
|
655
|
-
return void 0;
|
|
656
|
-
}
|
|
657
|
-
function coerceNumericScore(value) {
|
|
658
|
-
if (typeof value === "number") return value;
|
|
659
|
-
const parsed = Number.parseFloat(value);
|
|
660
|
-
if (Number.isNaN(parsed)) {
|
|
661
|
-
throw new TypeError(
|
|
662
|
-
`Backend returned non-numeric fulltext score: ${JSON.stringify(value)}`
|
|
663
|
-
);
|
|
664
|
-
}
|
|
665
|
-
return parsed;
|
|
666
|
-
}
|
|
667
|
-
function normalizeJsonColumn(value) {
|
|
668
|
-
return typeof value === "string" ? value : JSON.stringify(value ?? {});
|
|
669
|
-
}
|
|
670
|
-
var SQLITE_ROW_MAPPER_CONFIG = {
|
|
671
|
-
formatTimestamp: (value) => {
|
|
672
|
-
if (value === null || value === void 0) return;
|
|
673
|
-
if (typeof value !== "string") {
|
|
674
|
-
throw new chunkJIEJCTDS_cjs.DatabaseOperationError(
|
|
675
|
-
`Expected timestamp to be string, got ${typeof value}`,
|
|
676
|
-
{ operation: "select", entity: "row" }
|
|
677
|
-
);
|
|
678
|
-
}
|
|
679
|
-
return value;
|
|
680
|
-
},
|
|
681
|
-
normalizeJson: (value) => {
|
|
682
|
-
if (typeof value !== "string") {
|
|
683
|
-
throw new chunkJIEJCTDS_cjs.DatabaseOperationError(
|
|
684
|
-
`Expected JSON column to be string, got ${typeof value}`,
|
|
685
|
-
{ operation: "select", entity: "row" }
|
|
686
|
-
);
|
|
687
|
-
}
|
|
688
|
-
return value;
|
|
689
|
-
}
|
|
690
|
-
};
|
|
691
|
-
var POSTGRES_ROW_MAPPER_CONFIG = {
|
|
692
|
-
formatTimestamp: formatPostgresTimestamp,
|
|
693
|
-
normalizeJson: normalizeJsonColumn
|
|
694
|
-
};
|
|
695
|
-
function createNodeRowMapper(config) {
|
|
696
|
-
return (row) => ({
|
|
697
|
-
graph_id: asString(row.graph_id, "graph_id"),
|
|
698
|
-
kind: asString(row.kind, "kind"),
|
|
699
|
-
id: asString(row.id, "id"),
|
|
700
|
-
props: config.normalizeJson(row.props),
|
|
701
|
-
version: asNumber(row.version, "version"),
|
|
702
|
-
valid_from: nullToUndefined(config.formatTimestamp(row.valid_from)),
|
|
703
|
-
valid_to: nullToUndefined(config.formatTimestamp(row.valid_to)),
|
|
704
|
-
created_at: requireTimestamp(config.formatTimestamp(row.created_at), "created_at"),
|
|
705
|
-
updated_at: requireTimestamp(config.formatTimestamp(row.updated_at), "updated_at"),
|
|
706
|
-
deleted_at: nullToUndefined(config.formatTimestamp(row.deleted_at))
|
|
707
|
-
});
|
|
708
|
-
}
|
|
709
|
-
function createEdgeRowMapper(config) {
|
|
710
|
-
return (row) => ({
|
|
711
|
-
graph_id: asString(row.graph_id, "graph_id"),
|
|
712
|
-
id: asString(row.id, "id"),
|
|
713
|
-
kind: asString(row.kind, "kind"),
|
|
714
|
-
from_kind: asString(row.from_kind, "from_kind"),
|
|
715
|
-
from_id: asString(row.from_id, "from_id"),
|
|
716
|
-
to_kind: asString(row.to_kind, "to_kind"),
|
|
717
|
-
to_id: asString(row.to_id, "to_id"),
|
|
718
|
-
props: config.normalizeJson(row.props),
|
|
719
|
-
valid_from: nullToUndefined(config.formatTimestamp(row.valid_from)),
|
|
720
|
-
valid_to: nullToUndefined(config.formatTimestamp(row.valid_to)),
|
|
721
|
-
created_at: requireTimestamp(config.formatTimestamp(row.created_at), "created_at"),
|
|
722
|
-
updated_at: requireTimestamp(config.formatTimestamp(row.updated_at), "updated_at"),
|
|
723
|
-
deleted_at: nullToUndefined(config.formatTimestamp(row.deleted_at))
|
|
724
|
-
});
|
|
725
|
-
}
|
|
726
|
-
function createUniqueRowMapper(config) {
|
|
727
|
-
return (row) => ({
|
|
728
|
-
graph_id: asString(row.graph_id, "graph_id"),
|
|
729
|
-
node_kind: asString(row.node_kind, "node_kind"),
|
|
730
|
-
constraint_name: asString(row.constraint_name, "constraint_name"),
|
|
731
|
-
key: asString(row.key, "key"),
|
|
732
|
-
node_id: asString(row.node_id, "node_id"),
|
|
733
|
-
concrete_kind: asString(row.concrete_kind, "concrete_kind"),
|
|
734
|
-
deleted_at: nullToUndefined(config.formatTimestamp(row.deleted_at))
|
|
735
|
-
});
|
|
736
|
-
}
|
|
737
|
-
function createSchemaVersionRowMapper(config) {
|
|
738
|
-
return (row) => {
|
|
739
|
-
const isActiveValue = row.is_active;
|
|
740
|
-
const isActive = isActiveValue === true || isActiveValue === 1 || isActiveValue === "1";
|
|
741
|
-
return {
|
|
742
|
-
graph_id: asString(row.graph_id, "graph_id"),
|
|
743
|
-
version: asNumber(row.version, "version"),
|
|
744
|
-
schema_hash: asString(row.schema_hash, "schema_hash"),
|
|
745
|
-
schema_doc: config.normalizeJson(row.schema_doc),
|
|
746
|
-
created_at: requireTimestamp(config.formatTimestamp(row.created_at), "created_at"),
|
|
747
|
-
is_active: isActive
|
|
748
|
-
};
|
|
749
|
-
};
|
|
750
|
-
}
|
|
751
735
|
var SQLITE_CONTRIBUTION_MAT_TIMESTAMPS = {
|
|
752
736
|
decode: (value) => typeof value === "string" ? value : void 0,
|
|
753
737
|
encode: (value) => value
|
|
754
738
|
};
|
|
755
739
|
var POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS = {
|
|
756
|
-
decode: formatPostgresTimestamp,
|
|
740
|
+
decode: chunkJJRCLAUN_cjs.formatPostgresTimestamp,
|
|
757
741
|
encode: (value) => new Date(value)
|
|
758
742
|
};
|
|
759
743
|
function mapContributionMaterializationRow(row, decode) {
|
|
@@ -803,7 +787,7 @@ async function computeContributionSignature(dialect, identity, createDdl) {
|
|
|
803
787
|
tableName: identity.tableName,
|
|
804
788
|
createDdl
|
|
805
789
|
};
|
|
806
|
-
return
|
|
790
|
+
return chunkZY4GXIVN_cjs.sha256Hex(JSON.stringify(hashable, chunkACSVZPK7_cjs.sortedReplacer), 16);
|
|
807
791
|
}
|
|
808
792
|
function evaluateContributionState(row, signature) {
|
|
809
793
|
if (row === void 0) return "missing";
|
|
@@ -823,21 +807,21 @@ function identityOf(graphId, contribution) {
|
|
|
823
807
|
function gateFulltextMethods(source, assert) {
|
|
824
808
|
const gated = {};
|
|
825
809
|
if (source.upsertFulltext) {
|
|
826
|
-
const raw = source.upsertFulltext;
|
|
810
|
+
const raw = source.upsertFulltext.bind(source);
|
|
827
811
|
gated.upsertFulltext = async (params) => {
|
|
828
812
|
await assert(params.graphId);
|
|
829
813
|
await raw(params);
|
|
830
814
|
};
|
|
831
815
|
}
|
|
832
816
|
if (source.deleteFulltext) {
|
|
833
|
-
const raw = source.deleteFulltext;
|
|
817
|
+
const raw = source.deleteFulltext.bind(source);
|
|
834
818
|
gated.deleteFulltext = async (params) => {
|
|
835
819
|
await assert(params.graphId);
|
|
836
820
|
await raw(params);
|
|
837
821
|
};
|
|
838
822
|
}
|
|
839
823
|
if (source.upsertFulltextBatch) {
|
|
840
|
-
const raw = source.upsertFulltextBatch;
|
|
824
|
+
const raw = source.upsertFulltextBatch.bind(source);
|
|
841
825
|
gated.upsertFulltextBatch = async (params) => {
|
|
842
826
|
if (params.rows.length === 0) return;
|
|
843
827
|
await assert(params.graphId);
|
|
@@ -845,7 +829,7 @@ function gateFulltextMethods(source, assert) {
|
|
|
845
829
|
};
|
|
846
830
|
}
|
|
847
831
|
if (source.deleteFulltextBatch) {
|
|
848
|
-
const raw = source.deleteFulltextBatch;
|
|
832
|
+
const raw = source.deleteFulltextBatch.bind(source);
|
|
849
833
|
gated.deleteFulltextBatch = async (params) => {
|
|
850
834
|
if (params.nodeIds.length === 0) return;
|
|
851
835
|
await assert(params.graphId);
|
|
@@ -853,13 +837,13 @@ function gateFulltextMethods(source, assert) {
|
|
|
853
837
|
};
|
|
854
838
|
}
|
|
855
839
|
if (source.fulltextSearch) {
|
|
856
|
-
const raw = source.fulltextSearch;
|
|
840
|
+
const raw = source.fulltextSearch.bind(source);
|
|
857
841
|
gated.fulltextSearch = async (params) => {
|
|
858
842
|
await assert(params.graphId);
|
|
859
843
|
return raw(params);
|
|
860
844
|
};
|
|
861
845
|
}
|
|
862
|
-
const rawHardDelete = source.hardDeleteNode;
|
|
846
|
+
const rawHardDelete = source.hardDeleteNode.bind(source);
|
|
863
847
|
gated.hardDeleteNode = async (params) => {
|
|
864
848
|
await assert(params.graphId);
|
|
865
849
|
await rawHardDelete(params);
|
|
@@ -867,7 +851,10 @@ function gateFulltextMethods(source, assert) {
|
|
|
867
851
|
return gated;
|
|
868
852
|
}
|
|
869
853
|
function gateFulltext(tx, assert) {
|
|
870
|
-
return
|
|
854
|
+
return chunkUNNPKQUG_cjs.createBackendOverlay(
|
|
855
|
+
tx,
|
|
856
|
+
gateFulltextMethods(tx, assert)
|
|
857
|
+
);
|
|
871
858
|
}
|
|
872
859
|
function createContributionMaterializer(deps) {
|
|
873
860
|
const { dialect, fulltextStrategy, fulltextTableName } = deps;
|
|
@@ -894,13 +881,13 @@ function createContributionMaterializer(deps) {
|
|
|
894
881
|
await deps.recordMarker({
|
|
895
882
|
...identity,
|
|
896
883
|
signature,
|
|
897
|
-
attemptedAt: nowIso(),
|
|
884
|
+
attemptedAt: chunkJJRCLAUN_cjs.nowIso(),
|
|
898
885
|
materializedAt: void 0,
|
|
899
886
|
error: error.message
|
|
900
887
|
});
|
|
901
888
|
throw error;
|
|
902
889
|
}
|
|
903
|
-
const attemptedAt = nowIso();
|
|
890
|
+
const attemptedAt = chunkJJRCLAUN_cjs.nowIso();
|
|
904
891
|
try {
|
|
905
892
|
for (const statement of contribution.createDdl) {
|
|
906
893
|
await deps.execDdl(statement);
|
|
@@ -937,7 +924,7 @@ function createContributionMaterializer(deps) {
|
|
|
937
924
|
state: evaluateContributionState(existing, signature)
|
|
938
925
|
};
|
|
939
926
|
} catch (error) {
|
|
940
|
-
if (!
|
|
927
|
+
if (!chunkRHZWOJVA_cjs.isMissingTableError(error)) throw error;
|
|
941
928
|
return { kind: "missing-table", error };
|
|
942
929
|
}
|
|
943
930
|
}
|
|
@@ -986,7 +973,7 @@ var SQLITE_INDEX_MAT_TIMESTAMPS = {
|
|
|
986
973
|
encode: (value) => value
|
|
987
974
|
};
|
|
988
975
|
var POSTGRES_INDEX_MAT_TIMESTAMPS = {
|
|
989
|
-
decode: formatPostgresTimestamp,
|
|
976
|
+
decode: chunkJJRCLAUN_cjs.formatPostgresTimestamp,
|
|
990
977
|
encode: (value) => new Date(value)
|
|
991
978
|
};
|
|
992
979
|
function mapMaterializationRow(row, decode) {
|
|
@@ -1039,7 +1026,7 @@ var SQLITE_KIND_REMOVAL_TIMESTAMPS = {
|
|
|
1039
1026
|
encode: (value) => value
|
|
1040
1027
|
};
|
|
1041
1028
|
var POSTGRES_KIND_REMOVAL_TIMESTAMPS = {
|
|
1042
|
-
decode: formatPostgresTimestamp,
|
|
1029
|
+
decode: chunkJJRCLAUN_cjs.formatPostgresTimestamp,
|
|
1043
1030
|
encode: (value) => new Date(value)
|
|
1044
1031
|
};
|
|
1045
1032
|
function mapKindRemovalRow(row, decode) {
|
|
@@ -1080,397 +1067,46 @@ function buildKindRemovalOnConflictSet(removedAtColumn, paramsRemovedAt) {
|
|
|
1080
1067
|
lastError: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("last_error")}`
|
|
1081
1068
|
};
|
|
1082
1069
|
}
|
|
1083
|
-
function
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
function chunkArray(values, size) {
|
|
1092
|
-
if (values.length <= size) {
|
|
1093
|
-
return [values];
|
|
1094
|
-
}
|
|
1095
|
-
const chunks = [];
|
|
1096
|
-
for (let index2 = 0; index2 < values.length; index2 += size) {
|
|
1097
|
-
chunks.push(values.slice(index2, index2 + size));
|
|
1098
|
-
}
|
|
1099
|
-
return chunks;
|
|
1100
|
-
}
|
|
1101
|
-
function verifyExpectedActiveVersion(graphId, expected, actualActiveVersion) {
|
|
1102
|
-
const expectedVersion = expected.kind === "active" ? expected.version : 0;
|
|
1103
|
-
if (actualActiveVersion !== expectedVersion) {
|
|
1104
|
-
throw new chunkJIEJCTDS_cjs.StaleVersionError({
|
|
1105
|
-
graphId,
|
|
1106
|
-
expected: expectedVersion,
|
|
1107
|
-
actual: actualActiveVersion
|
|
1108
|
-
});
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
function createCommonOperationBackend(options) {
|
|
1112
|
-
const { batchConfig, execution, operationStrategy, rowMappers } = options;
|
|
1113
|
-
const nowIso2 = options.nowIso ?? nowIso;
|
|
1114
|
-
async function readActiveVersion(graphId) {
|
|
1115
|
-
const row = await execution.execGet(
|
|
1116
|
-
operationStrategy.buildGetActiveSchema(graphId)
|
|
1117
|
-
);
|
|
1118
|
-
return row === void 0 ? 0 : rowMappers.toSchemaVersionRow(row).version;
|
|
1119
|
-
}
|
|
1120
|
-
return {
|
|
1121
|
-
async insertNode(params) {
|
|
1122
|
-
const timestamp2 = nowIso2();
|
|
1123
|
-
const query = operationStrategy.buildInsertNode(params, timestamp2);
|
|
1124
|
-
const row = await execution.execGet(query);
|
|
1125
|
-
if (!row) throw new chunkJIEJCTDS_cjs.DatabaseOperationError("Insert node failed: no row returned", { operation: "insert", entity: "node" });
|
|
1126
|
-
return rowMappers.toNodeRow(row);
|
|
1127
|
-
},
|
|
1128
|
-
async insertNodeNoReturn(params) {
|
|
1129
|
-
const timestamp2 = nowIso2();
|
|
1130
|
-
const query = operationStrategy.buildInsertNodeNoReturn(params, timestamp2);
|
|
1131
|
-
await execution.execRun(query);
|
|
1132
|
-
},
|
|
1133
|
-
async insertNodesBatch(params) {
|
|
1134
|
-
if (params.length === 0) {
|
|
1135
|
-
return;
|
|
1136
|
-
}
|
|
1137
|
-
const timestamp2 = nowIso2();
|
|
1138
|
-
for (const chunk of chunkArray(params, batchConfig.nodeInsertBatchSize)) {
|
|
1139
|
-
const query = operationStrategy.buildInsertNodesBatch(chunk, timestamp2);
|
|
1140
|
-
await execution.execRun(query);
|
|
1141
|
-
}
|
|
1142
|
-
},
|
|
1143
|
-
async insertNodesBatchReturning(params) {
|
|
1144
|
-
if (params.length === 0) {
|
|
1145
|
-
return [];
|
|
1146
|
-
}
|
|
1147
|
-
const timestamp2 = nowIso2();
|
|
1148
|
-
const allRows = [];
|
|
1149
|
-
for (const chunk of chunkArray(params, batchConfig.nodeInsertBatchSize)) {
|
|
1150
|
-
const query = operationStrategy.buildInsertNodesBatchReturning(chunk, timestamp2);
|
|
1151
|
-
const rows = await execution.execAll(query);
|
|
1152
|
-
allRows.push(...rows.map((row) => rowMappers.toNodeRow(row)));
|
|
1153
|
-
}
|
|
1154
|
-
return allRows;
|
|
1155
|
-
},
|
|
1156
|
-
async getNode(graphId, kind, id) {
|
|
1157
|
-
const query = operationStrategy.buildGetNode(graphId, kind, id);
|
|
1158
|
-
const row = await execution.execGet(query);
|
|
1159
|
-
return row ? rowMappers.toNodeRow(row) : void 0;
|
|
1160
|
-
},
|
|
1161
|
-
async getNodes(graphId, kind, ids) {
|
|
1162
|
-
if (ids.length === 0) return [];
|
|
1163
|
-
const allRows = [];
|
|
1164
|
-
for (const chunk of chunkArray(ids, batchConfig.getNodesChunkSize)) {
|
|
1165
|
-
const query = operationStrategy.buildGetNodes(graphId, kind, chunk);
|
|
1166
|
-
const rows = await execution.execAll(query);
|
|
1167
|
-
allRows.push(...rows.map((row) => rowMappers.toNodeRow(row)));
|
|
1168
|
-
}
|
|
1169
|
-
return allRows;
|
|
1070
|
+
function buildClearGraph(tables3, graphId) {
|
|
1071
|
+
const fulltext2 = chunkYAZE7QZR_cjs.quotedTableName(tables3.fulltextTableName);
|
|
1072
|
+
return [
|
|
1073
|
+
{ query: drizzleOrm.sql`DELETE FROM ${fulltext2} WHERE "graph_id" = ${graphId}` },
|
|
1074
|
+
{
|
|
1075
|
+
query: drizzleOrm.sql`DELETE FROM ${tables3.recordedEdges} WHERE ${tables3.recordedEdges.graphId} = ${graphId}`,
|
|
1076
|
+
ignoreMissingTable: true,
|
|
1077
|
+
requiredTableName: drizzleOrm.getTableName(tables3.recordedEdges)
|
|
1170
1078
|
},
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
if (!row) throw new chunkJIEJCTDS_cjs.DatabaseOperationError("Update node failed: no row returned", { operation: "update", entity: "node" });
|
|
1176
|
-
return rowMappers.toNodeRow(row);
|
|
1079
|
+
{
|
|
1080
|
+
query: drizzleOrm.sql`DELETE FROM ${tables3.recordedNodes} WHERE ${tables3.recordedNodes.graphId} = ${graphId}`,
|
|
1081
|
+
ignoreMissingTable: true,
|
|
1082
|
+
requiredTableName: drizzleOrm.getTableName(tables3.recordedNodes)
|
|
1177
1083
|
},
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1084
|
+
{
|
|
1085
|
+
query: drizzleOrm.sql`DELETE FROM ${tables3.recordedClock} WHERE ${tables3.recordedClock.graphId} = ${graphId}`,
|
|
1086
|
+
ignoreMissingTable: true,
|
|
1087
|
+
requiredTableName: drizzleOrm.getTableName(tables3.recordedClock)
|
|
1182
1088
|
},
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
//
|
|
1186
|
-
// Embeddings are NOT cleaned up here: they live in per-`(nodeKind,
|
|
1187
|
-
// fieldPath)` strategy-owned tables addressable only with the slot
|
|
1188
|
-
// context the graph-agnostic backend lacks. The store's hard-delete
|
|
1189
|
-
// path (`executeNodeHardDelete`) drives `deleteNodeEmbeddings`, which
|
|
1190
|
-
// resolves each embedding field and routes a per-field
|
|
1191
|
-
// `backend.deleteEmbedding` through the active vector strategy.
|
|
1192
|
-
async hardDeleteNode(params) {
|
|
1193
|
-
const deleteUniquesQuery = operationStrategy.buildHardDeleteUniquesByNode(
|
|
1194
|
-
params.graphId,
|
|
1195
|
-
params.id
|
|
1196
|
-
);
|
|
1197
|
-
await execution.execRun(deleteUniquesQuery);
|
|
1198
|
-
const deleteFulltextStatements = operationStrategy.buildDeleteFulltextByNode(
|
|
1199
|
-
params.graphId,
|
|
1200
|
-
params.kind,
|
|
1201
|
-
params.id
|
|
1202
|
-
);
|
|
1203
|
-
for (const stmt of deleteFulltextStatements) {
|
|
1204
|
-
await execution.execRun(stmt);
|
|
1205
|
-
}
|
|
1206
|
-
const deleteEdgesQuery = operationStrategy.buildHardDeleteEdgesByNode(
|
|
1207
|
-
params.graphId,
|
|
1208
|
-
params.kind,
|
|
1209
|
-
params.id
|
|
1210
|
-
);
|
|
1211
|
-
await execution.execRun(deleteEdgesQuery);
|
|
1212
|
-
const query = operationStrategy.buildHardDeleteNode(params);
|
|
1213
|
-
await execution.execRun(query);
|
|
1089
|
+
{
|
|
1090
|
+
query: drizzleOrm.sql`DELETE FROM ${tables3.uniques} WHERE ${tables3.uniques.graphId} = ${graphId}`
|
|
1214
1091
|
},
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
const query = operationStrategy.buildInsertEdge(params, timestamp2);
|
|
1218
|
-
const row = await execution.execGet(query);
|
|
1219
|
-
if (!row) throw new chunkJIEJCTDS_cjs.DatabaseOperationError("Insert edge failed: no row returned", { operation: "insert", entity: "edge" });
|
|
1220
|
-
return rowMappers.toEdgeRow(row);
|
|
1092
|
+
{
|
|
1093
|
+
query: drizzleOrm.sql`DELETE FROM ${tables3.edges} WHERE ${tables3.edges.graphId} = ${graphId}`
|
|
1221
1094
|
},
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
const query = operationStrategy.buildInsertEdgeNoReturn(params, timestamp2);
|
|
1225
|
-
await execution.execRun(query);
|
|
1095
|
+
{
|
|
1096
|
+
query: drizzleOrm.sql`DELETE FROM ${tables3.nodes} WHERE ${tables3.nodes.graphId} = ${graphId}`
|
|
1226
1097
|
},
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
return;
|
|
1230
|
-
}
|
|
1231
|
-
const timestamp2 = nowIso2();
|
|
1232
|
-
for (const chunk of chunkArray(params, batchConfig.edgeInsertBatchSize)) {
|
|
1233
|
-
const query = operationStrategy.buildInsertEdgesBatch(chunk, timestamp2);
|
|
1234
|
-
await execution.execRun(query);
|
|
1235
|
-
}
|
|
1098
|
+
{
|
|
1099
|
+
query: drizzleOrm.sql`DELETE FROM ${tables3.indexMaterializations} WHERE ${tables3.indexMaterializations.graphId} = ${graphId}`
|
|
1236
1100
|
},
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
return [];
|
|
1240
|
-
}
|
|
1241
|
-
const timestamp2 = nowIso2();
|
|
1242
|
-
const allRows = [];
|
|
1243
|
-
for (const chunk of chunkArray(params, batchConfig.edgeInsertBatchSize)) {
|
|
1244
|
-
const query = operationStrategy.buildInsertEdgesBatchReturning(chunk, timestamp2);
|
|
1245
|
-
const rows = await execution.execAll(query);
|
|
1246
|
-
allRows.push(...rows.map((row) => rowMappers.toEdgeRow(row)));
|
|
1247
|
-
}
|
|
1248
|
-
return allRows;
|
|
1101
|
+
{
|
|
1102
|
+
query: drizzleOrm.sql`DELETE FROM ${tables3.kindRemovals} WHERE ${tables3.kindRemovals.graphId} = ${graphId}`
|
|
1249
1103
|
},
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
const row = await execution.execGet(query);
|
|
1253
|
-
return row ? rowMappers.toEdgeRow(row) : void 0;
|
|
1104
|
+
{
|
|
1105
|
+
query: drizzleOrm.sql`DELETE FROM ${tables3.reconciliationMarkers} WHERE ${tables3.reconciliationMarkers.graphId} = ${graphId}`
|
|
1254
1106
|
},
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
const allRows = [];
|
|
1258
|
-
for (const chunk of chunkArray(ids, batchConfig.getEdgesChunkSize)) {
|
|
1259
|
-
const query = operationStrategy.buildGetEdges(graphId, chunk);
|
|
1260
|
-
const rows = await execution.execAll(query);
|
|
1261
|
-
allRows.push(...rows.map((row) => rowMappers.toEdgeRow(row)));
|
|
1262
|
-
}
|
|
1263
|
-
return allRows;
|
|
1264
|
-
},
|
|
1265
|
-
async updateEdge(params) {
|
|
1266
|
-
const timestamp2 = nowIso2();
|
|
1267
|
-
const query = operationStrategy.buildUpdateEdge(params, timestamp2);
|
|
1268
|
-
const row = await execution.execGet(query);
|
|
1269
|
-
if (!row) throw new chunkJIEJCTDS_cjs.DatabaseOperationError("Update edge failed: no row returned", { operation: "update", entity: "edge" });
|
|
1270
|
-
return rowMappers.toEdgeRow(row);
|
|
1271
|
-
},
|
|
1272
|
-
async deleteEdge(params) {
|
|
1273
|
-
const timestamp2 = nowIso2();
|
|
1274
|
-
const query = operationStrategy.buildDeleteEdge(params, timestamp2);
|
|
1275
|
-
await execution.execRun(query);
|
|
1276
|
-
},
|
|
1277
|
-
async hardDeleteEdge(params) {
|
|
1278
|
-
const query = operationStrategy.buildHardDeleteEdge(params);
|
|
1279
|
-
await execution.execRun(query);
|
|
1280
|
-
},
|
|
1281
|
-
async countEdgesFrom(params) {
|
|
1282
|
-
const query = operationStrategy.buildCountEdgesFrom(params);
|
|
1283
|
-
const row = await execution.execGet(query);
|
|
1284
|
-
return Number(row?.count ?? 0);
|
|
1285
|
-
},
|
|
1286
|
-
async edgeExistsBetween(params) {
|
|
1287
|
-
const query = operationStrategy.buildEdgeExistsBetween(params);
|
|
1288
|
-
const row = await execution.execGet(query);
|
|
1289
|
-
return row !== void 0;
|
|
1290
|
-
},
|
|
1291
|
-
async findEdgesConnectedTo(params) {
|
|
1292
|
-
const query = operationStrategy.buildFindEdgesConnectedTo(params);
|
|
1293
|
-
const rows = await execution.execAll(query);
|
|
1294
|
-
return rows.map((row) => rowMappers.toEdgeRow(row));
|
|
1295
|
-
},
|
|
1296
|
-
async findNodesByKind(params) {
|
|
1297
|
-
const query = operationStrategy.buildFindNodesByKind(params);
|
|
1298
|
-
const rows = await execution.execAll(query);
|
|
1299
|
-
return rows.map((row) => rowMappers.toNodeRow(row));
|
|
1300
|
-
},
|
|
1301
|
-
async countNodesByKind(params) {
|
|
1302
|
-
const query = operationStrategy.buildCountNodesByKind(params);
|
|
1303
|
-
const row = await execution.execGet(query);
|
|
1304
|
-
return Number(row?.count ?? 0);
|
|
1305
|
-
},
|
|
1306
|
-
async findEdgesByKind(params) {
|
|
1307
|
-
const query = operationStrategy.buildFindEdgesByKind(params);
|
|
1308
|
-
const rows = await execution.execAll(query);
|
|
1309
|
-
return rows.map((row) => rowMappers.toEdgeRow(row));
|
|
1310
|
-
},
|
|
1311
|
-
async countEdgesByKind(params) {
|
|
1312
|
-
const query = operationStrategy.buildCountEdgesByKind(params);
|
|
1313
|
-
const row = await execution.execGet(query);
|
|
1314
|
-
return Number(row?.count ?? 0);
|
|
1315
|
-
},
|
|
1316
|
-
async insertUnique(params) {
|
|
1317
|
-
const query = operationStrategy.buildInsertUnique(params);
|
|
1318
|
-
const result = await execution.execGet(query);
|
|
1319
|
-
if (result && result.node_id !== params.nodeId) {
|
|
1320
|
-
throw new chunkJIEJCTDS_cjs.UniquenessError({
|
|
1321
|
-
constraintName: params.constraintName,
|
|
1322
|
-
kind: params.nodeKind,
|
|
1323
|
-
existingId: result.node_id,
|
|
1324
|
-
newId: params.nodeId,
|
|
1325
|
-
fields: []
|
|
1326
|
-
});
|
|
1327
|
-
}
|
|
1328
|
-
},
|
|
1329
|
-
async deleteUnique(params) {
|
|
1330
|
-
const timestamp2 = nowIso2();
|
|
1331
|
-
const query = operationStrategy.buildDeleteUnique(params, timestamp2);
|
|
1332
|
-
await execution.execRun(query);
|
|
1333
|
-
},
|
|
1334
|
-
async checkUnique(params) {
|
|
1335
|
-
const query = operationStrategy.buildCheckUnique(params);
|
|
1336
|
-
const row = await execution.execGet(query);
|
|
1337
|
-
return row ? rowMappers.toUniqueRow(row) : void 0;
|
|
1338
|
-
},
|
|
1339
|
-
async checkUniqueBatch(params) {
|
|
1340
|
-
if (params.keys.length === 0) return [];
|
|
1341
|
-
const allRows = [];
|
|
1342
|
-
for (const chunk of chunkArray(params.keys, batchConfig.checkUniqueBatchChunkSize)) {
|
|
1343
|
-
const query = operationStrategy.buildCheckUniqueBatch({ ...params, keys: chunk });
|
|
1344
|
-
const rows = await execution.execAll(query);
|
|
1345
|
-
allRows.push(...rows.map((row) => rowMappers.toUniqueRow(row)));
|
|
1346
|
-
}
|
|
1347
|
-
return allRows;
|
|
1348
|
-
},
|
|
1349
|
-
async getActiveSchema(graphId) {
|
|
1350
|
-
const query = operationStrategy.buildGetActiveSchema(graphId);
|
|
1351
|
-
const row = await execution.execGet(query);
|
|
1352
|
-
return row ? rowMappers.toSchemaVersionRow(row) : void 0;
|
|
1353
|
-
},
|
|
1354
|
-
async getSchemaVersion(graphId, version) {
|
|
1355
|
-
const query = operationStrategy.buildGetSchemaVersion(graphId, version);
|
|
1356
|
-
const row = await execution.execGet(query);
|
|
1357
|
-
return row ? rowMappers.toSchemaVersionRow(row) : void 0;
|
|
1358
|
-
},
|
|
1359
|
-
async commitSchemaVersion(params) {
|
|
1360
|
-
const existingRaw = await execution.execGet(
|
|
1361
|
-
operationStrategy.buildGetSchemaVersion(
|
|
1362
|
-
params.graphId,
|
|
1363
|
-
params.version
|
|
1364
|
-
)
|
|
1365
|
-
);
|
|
1366
|
-
const actualActiveVersion = await readActiveVersion(params.graphId);
|
|
1367
|
-
if (existingRaw !== void 0) {
|
|
1368
|
-
const existing = rowMappers.toSchemaVersionRow(existingRaw);
|
|
1369
|
-
if (existing.schema_hash !== params.schemaHash) {
|
|
1370
|
-
throw new chunkJIEJCTDS_cjs.SchemaContentConflictError({
|
|
1371
|
-
graphId: params.graphId,
|
|
1372
|
-
version: params.version,
|
|
1373
|
-
existingHash: existing.schema_hash,
|
|
1374
|
-
incomingHash: params.schemaHash
|
|
1375
|
-
});
|
|
1376
|
-
}
|
|
1377
|
-
if (existing.is_active) {
|
|
1378
|
-
return existing;
|
|
1379
|
-
}
|
|
1380
|
-
verifyExpectedActiveVersion(
|
|
1381
|
-
params.graphId,
|
|
1382
|
-
params.expected,
|
|
1383
|
-
actualActiveVersion
|
|
1384
|
-
);
|
|
1385
|
-
const reactivate = operationStrategy.buildSetActiveSchema(
|
|
1386
|
-
params.graphId,
|
|
1387
|
-
params.version
|
|
1388
|
-
);
|
|
1389
|
-
await execution.execRun(reactivate.deactivateAll);
|
|
1390
|
-
await execution.execRun(reactivate.activateVersion);
|
|
1391
|
-
return { ...existing, is_active: true };
|
|
1392
|
-
}
|
|
1393
|
-
verifyExpectedActiveVersion(
|
|
1394
|
-
params.graphId,
|
|
1395
|
-
params.expected,
|
|
1396
|
-
actualActiveVersion
|
|
1397
|
-
);
|
|
1398
|
-
if (params.expected.kind === "active") {
|
|
1399
|
-
const flip = operationStrategy.buildSetActiveSchema(
|
|
1400
|
-
params.graphId,
|
|
1401
|
-
params.version
|
|
1402
|
-
);
|
|
1403
|
-
await execution.execRun(flip.deactivateAll);
|
|
1404
|
-
}
|
|
1405
|
-
const timestamp2 = nowIso2();
|
|
1406
|
-
const insertQuery = operationStrategy.buildInsertSchema(
|
|
1407
|
-
{
|
|
1408
|
-
graphId: params.graphId,
|
|
1409
|
-
version: params.version,
|
|
1410
|
-
schemaHash: params.schemaHash,
|
|
1411
|
-
schemaDoc: params.schemaDoc,
|
|
1412
|
-
isActive: true
|
|
1413
|
-
},
|
|
1414
|
-
timestamp2
|
|
1415
|
-
);
|
|
1416
|
-
const insertedRaw = await execution.execGet(insertQuery);
|
|
1417
|
-
if (!insertedRaw) {
|
|
1418
|
-
throw new chunkJIEJCTDS_cjs.DatabaseOperationError(
|
|
1419
|
-
"Insert schema failed: no row returned",
|
|
1420
|
-
{ operation: "insert", entity: "schema" }
|
|
1421
|
-
);
|
|
1422
|
-
}
|
|
1423
|
-
return rowMappers.toSchemaVersionRow(insertedRaw);
|
|
1424
|
-
},
|
|
1425
|
-
async setActiveVersion(params) {
|
|
1426
|
-
const actualActiveVersion = await readActiveVersion(params.graphId);
|
|
1427
|
-
verifyExpectedActiveVersion(
|
|
1428
|
-
params.graphId,
|
|
1429
|
-
params.expected,
|
|
1430
|
-
actualActiveVersion
|
|
1431
|
-
);
|
|
1432
|
-
const targetRaw = await execution.execGet(
|
|
1433
|
-
operationStrategy.buildGetSchemaVersion(
|
|
1434
|
-
params.graphId,
|
|
1435
|
-
params.version
|
|
1436
|
-
)
|
|
1437
|
-
);
|
|
1438
|
-
if (!targetRaw) {
|
|
1439
|
-
throw new chunkJIEJCTDS_cjs.MigrationError(
|
|
1440
|
-
`Cannot activate version ${params.version}: version does not exist for graph "${params.graphId}".`,
|
|
1441
|
-
{
|
|
1442
|
-
graphId: params.graphId,
|
|
1443
|
-
fromVersion: actualActiveVersion,
|
|
1444
|
-
toVersion: params.version
|
|
1445
|
-
}
|
|
1446
|
-
);
|
|
1447
|
-
}
|
|
1448
|
-
const queries = operationStrategy.buildSetActiveSchema(
|
|
1449
|
-
params.graphId,
|
|
1450
|
-
params.version
|
|
1451
|
-
);
|
|
1452
|
-
await execution.execRun(queries.deactivateAll);
|
|
1453
|
-
await execution.execRun(queries.activateVersion);
|
|
1454
|
-
},
|
|
1455
|
-
async clearGraph(graphId) {
|
|
1456
|
-
const statements = operationStrategy.buildClearGraph(graphId);
|
|
1457
|
-
for (const statement of statements) {
|
|
1458
|
-
await execution.execRun(statement);
|
|
1459
|
-
}
|
|
1107
|
+
{
|
|
1108
|
+
query: drizzleOrm.sql`DELETE FROM ${tables3.schemaVersions} WHERE ${tables3.schemaVersions.graphId} = ${graphId}`
|
|
1460
1109
|
}
|
|
1461
|
-
};
|
|
1462
|
-
}
|
|
1463
|
-
function buildClearGraph(tables3, graphId) {
|
|
1464
|
-
const fulltext2 = chunkCFNT3ITG_cjs.quotedTableName(tables3.fulltextTableName);
|
|
1465
|
-
return [
|
|
1466
|
-
drizzleOrm.sql`DELETE FROM ${fulltext2} WHERE "graph_id" = ${graphId}`,
|
|
1467
|
-
drizzleOrm.sql`DELETE FROM ${tables3.uniques} WHERE ${tables3.uniques.graphId} = ${graphId}`,
|
|
1468
|
-
drizzleOrm.sql`DELETE FROM ${tables3.edges} WHERE ${tables3.edges.graphId} = ${graphId}`,
|
|
1469
|
-
drizzleOrm.sql`DELETE FROM ${tables3.nodes} WHERE ${tables3.nodes.graphId} = ${graphId}`,
|
|
1470
|
-
drizzleOrm.sql`DELETE FROM ${tables3.indexMaterializations} WHERE ${tables3.indexMaterializations.graphId} = ${graphId}`,
|
|
1471
|
-
drizzleOrm.sql`DELETE FROM ${tables3.kindRemovals} WHERE ${tables3.kindRemovals.graphId} = ${graphId}`,
|
|
1472
|
-
drizzleOrm.sql`DELETE FROM ${tables3.reconciliationMarkers} WHERE ${tables3.reconciliationMarkers.graphId} = ${graphId}`,
|
|
1473
|
-
drizzleOrm.sql`DELETE FROM ${tables3.schemaVersions} WHERE ${tables3.schemaVersions.graphId} = ${graphId}`
|
|
1474
1110
|
];
|
|
1475
1111
|
}
|
|
1476
1112
|
function buildTemporalConditions(table, params) {
|
|
@@ -1614,13 +1250,13 @@ function buildCountEdgesByKind(tables3, params) {
|
|
|
1614
1250
|
function buildInsertEdge(tables3, params, timestamp2) {
|
|
1615
1251
|
const { edges: edges2 } = tables3;
|
|
1616
1252
|
const propsJson = JSON.stringify(params.props);
|
|
1617
|
-
const columns =
|
|
1253
|
+
const columns = chunkYAZE7QZR_cjs.edgeColumnList(edges2);
|
|
1618
1254
|
return drizzleOrm.sql`
|
|
1619
1255
|
INSERT INTO ${edges2} (${columns})
|
|
1620
1256
|
VALUES (
|
|
1621
1257
|
${params.graphId}, ${params.id}, ${params.kind},
|
|
1622
1258
|
${params.fromKind}, ${params.fromId}, ${params.toKind}, ${params.toId},
|
|
1623
|
-
${propsJson}, ${
|
|
1259
|
+
${propsJson}, ${chunkYAZE7QZR_cjs.sqlNull(params.validFrom)}, ${chunkYAZE7QZR_cjs.sqlNull(params.validTo)},
|
|
1624
1260
|
${timestamp2}, ${timestamp2}
|
|
1625
1261
|
)
|
|
1626
1262
|
RETURNING *
|
|
@@ -1629,23 +1265,23 @@ function buildInsertEdge(tables3, params, timestamp2) {
|
|
|
1629
1265
|
function buildInsertEdgeNoReturn(tables3, params, timestamp2) {
|
|
1630
1266
|
const { edges: edges2 } = tables3;
|
|
1631
1267
|
const propsJson = JSON.stringify(params.props);
|
|
1632
|
-
const columns =
|
|
1268
|
+
const columns = chunkYAZE7QZR_cjs.edgeColumnList(edges2);
|
|
1633
1269
|
return drizzleOrm.sql`
|
|
1634
1270
|
INSERT INTO ${edges2} (${columns})
|
|
1635
1271
|
VALUES (
|
|
1636
1272
|
${params.graphId}, ${params.id}, ${params.kind},
|
|
1637
1273
|
${params.fromKind}, ${params.fromId}, ${params.toKind}, ${params.toId},
|
|
1638
|
-
${propsJson}, ${
|
|
1274
|
+
${propsJson}, ${chunkYAZE7QZR_cjs.sqlNull(params.validFrom)}, ${chunkYAZE7QZR_cjs.sqlNull(params.validTo)},
|
|
1639
1275
|
${timestamp2}, ${timestamp2}
|
|
1640
1276
|
)
|
|
1641
1277
|
`;
|
|
1642
1278
|
}
|
|
1643
1279
|
function buildInsertEdgesBatch(tables3, params, timestamp2) {
|
|
1644
1280
|
const { edges: edges2 } = tables3;
|
|
1645
|
-
const columns =
|
|
1281
|
+
const columns = chunkYAZE7QZR_cjs.edgeColumnList(edges2);
|
|
1646
1282
|
const values = params.map((edgeParams) => {
|
|
1647
1283
|
const propsJson = JSON.stringify(edgeParams.props);
|
|
1648
|
-
return drizzleOrm.sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${
|
|
1284
|
+
return drizzleOrm.sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${chunkYAZE7QZR_cjs.sqlNull(edgeParams.validFrom)}, ${chunkYAZE7QZR_cjs.sqlNull(edgeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1649
1285
|
});
|
|
1650
1286
|
return drizzleOrm.sql`
|
|
1651
1287
|
INSERT INTO ${edges2} (${columns})
|
|
@@ -1654,10 +1290,10 @@ function buildInsertEdgesBatch(tables3, params, timestamp2) {
|
|
|
1654
1290
|
}
|
|
1655
1291
|
function buildInsertEdgesBatchReturning(tables3, params, timestamp2) {
|
|
1656
1292
|
const { edges: edges2 } = tables3;
|
|
1657
|
-
const columns =
|
|
1293
|
+
const columns = chunkYAZE7QZR_cjs.edgeColumnList(edges2);
|
|
1658
1294
|
const values = params.map((edgeParams) => {
|
|
1659
1295
|
const propsJson = JSON.stringify(edgeParams.props);
|
|
1660
|
-
return drizzleOrm.sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${
|
|
1296
|
+
return drizzleOrm.sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${chunkYAZE7QZR_cjs.sqlNull(edgeParams.validFrom)}, ${chunkYAZE7QZR_cjs.sqlNull(edgeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1661
1297
|
});
|
|
1662
1298
|
return drizzleOrm.sql`
|
|
1663
1299
|
INSERT INTO ${edges2} (${columns})
|
|
@@ -1675,28 +1311,24 @@ function buildGetEdge(tables3, graphId, id) {
|
|
|
1675
1311
|
}
|
|
1676
1312
|
function buildGetEdges(tables3, graphId, ids) {
|
|
1677
1313
|
const { edges: edges2 } = tables3;
|
|
1678
|
-
const idPlaceholders = drizzleOrm.sql.join(
|
|
1679
|
-
ids.map((edgeId) => drizzleOrm.sql`${edgeId}`),
|
|
1680
|
-
drizzleOrm.sql`, `
|
|
1681
|
-
);
|
|
1682
1314
|
return drizzleOrm.sql`
|
|
1683
1315
|
SELECT * FROM ${edges2}
|
|
1684
1316
|
WHERE ${edges2.graphId} = ${graphId}
|
|
1685
|
-
AND ${edges2.id} IN (${
|
|
1317
|
+
AND ${edges2.id} IN (${chunkUNNPKQUG_cjs.sqlValueList(ids)})
|
|
1686
1318
|
`;
|
|
1687
1319
|
}
|
|
1688
1320
|
function buildUpdateEdge(tables3, params, timestamp2) {
|
|
1689
1321
|
const { edges: edges2 } = tables3;
|
|
1690
1322
|
const propsJson = JSON.stringify(params.props);
|
|
1691
1323
|
const setParts = [
|
|
1692
|
-
drizzleOrm.sql`${
|
|
1693
|
-
drizzleOrm.sql`${
|
|
1324
|
+
drizzleOrm.sql`${chunkYAZE7QZR_cjs.quotedColumn(edges2.props)} = ${propsJson}`,
|
|
1325
|
+
drizzleOrm.sql`${chunkYAZE7QZR_cjs.quotedColumn(edges2.updatedAt)} = ${timestamp2}`
|
|
1694
1326
|
];
|
|
1695
1327
|
if (params.validTo !== void 0) {
|
|
1696
|
-
setParts.push(drizzleOrm.sql`${
|
|
1328
|
+
setParts.push(drizzleOrm.sql`${chunkYAZE7QZR_cjs.quotedColumn(edges2.validTo)} = ${params.validTo}`);
|
|
1697
1329
|
}
|
|
1698
1330
|
if (params.clearDeleted) {
|
|
1699
|
-
setParts.push(drizzleOrm.sql`${
|
|
1331
|
+
setParts.push(drizzleOrm.sql`${chunkYAZE7QZR_cjs.quotedColumn(edges2.deletedAt)} = NULL`);
|
|
1700
1332
|
}
|
|
1701
1333
|
const setClause = drizzleOrm.sql.join(setParts, drizzleOrm.sql`, `);
|
|
1702
1334
|
if (params.clearDeleted) {
|
|
@@ -1721,7 +1353,7 @@ function buildDeleteEdge(tables3, params, timestamp2) {
|
|
|
1721
1353
|
const { edges: edges2 } = tables3;
|
|
1722
1354
|
return drizzleOrm.sql`
|
|
1723
1355
|
UPDATE ${edges2}
|
|
1724
|
-
SET ${
|
|
1356
|
+
SET ${chunkYAZE7QZR_cjs.quotedColumn(edges2.deletedAt)} = ${timestamp2}
|
|
1725
1357
|
WHERE ${edges2.graphId} = ${params.graphId}
|
|
1726
1358
|
AND ${edges2.id} = ${params.id}
|
|
1727
1359
|
AND ${edges2.deletedAt} IS NULL
|
|
@@ -1808,7 +1440,7 @@ function resolveMode(mode) {
|
|
|
1808
1440
|
function buildFulltextSearch(tableName, params, strategy) {
|
|
1809
1441
|
assertValidSearchParams(params);
|
|
1810
1442
|
const mode = resolveMode(params.mode);
|
|
1811
|
-
const table =
|
|
1443
|
+
const table = chunkYAZE7QZR_cjs.quotedTableName(tableName);
|
|
1812
1444
|
const matchCondition = strategy.matchCondition(
|
|
1813
1445
|
tableName,
|
|
1814
1446
|
params.query,
|
|
@@ -1859,12 +1491,12 @@ function assertValidSearchParams(params) {
|
|
|
1859
1491
|
function buildInsertNode(tables3, params, timestamp2) {
|
|
1860
1492
|
const { nodes: nodes2 } = tables3;
|
|
1861
1493
|
const propsJson = JSON.stringify(params.props);
|
|
1862
|
-
const columns =
|
|
1494
|
+
const columns = chunkYAZE7QZR_cjs.nodeColumnList(nodes2);
|
|
1863
1495
|
return drizzleOrm.sql`
|
|
1864
1496
|
INSERT INTO ${nodes2} (${columns})
|
|
1865
1497
|
VALUES (
|
|
1866
1498
|
${params.graphId}, ${params.kind}, ${params.id}, ${propsJson},
|
|
1867
|
-
1, ${
|
|
1499
|
+
1, ${chunkYAZE7QZR_cjs.sqlNull(params.validFrom)}, ${chunkYAZE7QZR_cjs.sqlNull(params.validTo)},
|
|
1868
1500
|
${timestamp2}, ${timestamp2}
|
|
1869
1501
|
)
|
|
1870
1502
|
RETURNING *
|
|
@@ -1873,22 +1505,22 @@ function buildInsertNode(tables3, params, timestamp2) {
|
|
|
1873
1505
|
function buildInsertNodeNoReturn(tables3, params, timestamp2) {
|
|
1874
1506
|
const { nodes: nodes2 } = tables3;
|
|
1875
1507
|
const propsJson = JSON.stringify(params.props);
|
|
1876
|
-
const columns =
|
|
1508
|
+
const columns = chunkYAZE7QZR_cjs.nodeColumnList(nodes2);
|
|
1877
1509
|
return drizzleOrm.sql`
|
|
1878
1510
|
INSERT INTO ${nodes2} (${columns})
|
|
1879
1511
|
VALUES (
|
|
1880
1512
|
${params.graphId}, ${params.kind}, ${params.id}, ${propsJson},
|
|
1881
|
-
1, ${
|
|
1513
|
+
1, ${chunkYAZE7QZR_cjs.sqlNull(params.validFrom)}, ${chunkYAZE7QZR_cjs.sqlNull(params.validTo)},
|
|
1882
1514
|
${timestamp2}, ${timestamp2}
|
|
1883
1515
|
)
|
|
1884
1516
|
`;
|
|
1885
1517
|
}
|
|
1886
1518
|
function buildInsertNodesBatch(tables3, params, timestamp2) {
|
|
1887
1519
|
const { nodes: nodes2 } = tables3;
|
|
1888
|
-
const columns =
|
|
1520
|
+
const columns = chunkYAZE7QZR_cjs.nodeColumnList(nodes2);
|
|
1889
1521
|
const values = params.map((nodeParams) => {
|
|
1890
1522
|
const propsJson = JSON.stringify(nodeParams.props);
|
|
1891
|
-
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${
|
|
1523
|
+
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${chunkYAZE7QZR_cjs.sqlNull(nodeParams.validFrom)}, ${chunkYAZE7QZR_cjs.sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1892
1524
|
});
|
|
1893
1525
|
return drizzleOrm.sql`
|
|
1894
1526
|
INSERT INTO ${nodes2} (${columns})
|
|
@@ -1897,10 +1529,10 @@ function buildInsertNodesBatch(tables3, params, timestamp2) {
|
|
|
1897
1529
|
}
|
|
1898
1530
|
function buildInsertNodesBatchReturning(tables3, params, timestamp2) {
|
|
1899
1531
|
const { nodes: nodes2 } = tables3;
|
|
1900
|
-
const columns =
|
|
1532
|
+
const columns = chunkYAZE7QZR_cjs.nodeColumnList(nodes2);
|
|
1901
1533
|
const values = params.map((nodeParams) => {
|
|
1902
1534
|
const propsJson = JSON.stringify(nodeParams.props);
|
|
1903
|
-
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${
|
|
1535
|
+
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${chunkYAZE7QZR_cjs.sqlNull(nodeParams.validFrom)}, ${chunkYAZE7QZR_cjs.sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1904
1536
|
});
|
|
1905
1537
|
return drizzleOrm.sql`
|
|
1906
1538
|
INSERT INTO ${nodes2} (${columns})
|
|
@@ -1919,34 +1551,30 @@ function buildGetNode(tables3, graphId, kind, id) {
|
|
|
1919
1551
|
}
|
|
1920
1552
|
function buildGetNodes(tables3, graphId, kind, ids) {
|
|
1921
1553
|
const { nodes: nodes2 } = tables3;
|
|
1922
|
-
const idPlaceholders = drizzleOrm.sql.join(
|
|
1923
|
-
ids.map((nodeId) => drizzleOrm.sql`${nodeId}`),
|
|
1924
|
-
drizzleOrm.sql`, `
|
|
1925
|
-
);
|
|
1926
1554
|
return drizzleOrm.sql`
|
|
1927
1555
|
SELECT * FROM ${nodes2}
|
|
1928
1556
|
WHERE ${nodes2.graphId} = ${graphId}
|
|
1929
1557
|
AND ${nodes2.kind} = ${kind}
|
|
1930
|
-
AND ${nodes2.id} IN (${
|
|
1558
|
+
AND ${nodes2.id} IN (${chunkUNNPKQUG_cjs.sqlValueList(ids)})
|
|
1931
1559
|
`;
|
|
1932
1560
|
}
|
|
1933
1561
|
function buildUpdateNode(tables3, params, timestamp2) {
|
|
1934
1562
|
const { nodes: nodes2 } = tables3;
|
|
1935
1563
|
const propsJson = JSON.stringify(params.props);
|
|
1936
1564
|
const setParts = [
|
|
1937
|
-
drizzleOrm.sql`${
|
|
1938
|
-
drizzleOrm.sql`${
|
|
1565
|
+
drizzleOrm.sql`${chunkYAZE7QZR_cjs.quotedColumn(nodes2.props)} = ${propsJson}`,
|
|
1566
|
+
drizzleOrm.sql`${chunkYAZE7QZR_cjs.quotedColumn(nodes2.updatedAt)} = ${timestamp2}`
|
|
1939
1567
|
];
|
|
1940
1568
|
if (params.incrementVersion) {
|
|
1941
1569
|
setParts.push(
|
|
1942
|
-
drizzleOrm.sql`${
|
|
1570
|
+
drizzleOrm.sql`${chunkYAZE7QZR_cjs.quotedColumn(nodes2.version)} = ${chunkYAZE7QZR_cjs.quotedColumn(nodes2.version)} + 1`
|
|
1943
1571
|
);
|
|
1944
1572
|
}
|
|
1945
1573
|
if (params.validTo !== void 0) {
|
|
1946
|
-
setParts.push(drizzleOrm.sql`${
|
|
1574
|
+
setParts.push(drizzleOrm.sql`${chunkYAZE7QZR_cjs.quotedColumn(nodes2.validTo)} = ${params.validTo}`);
|
|
1947
1575
|
}
|
|
1948
1576
|
if (params.clearDeleted) {
|
|
1949
|
-
setParts.push(drizzleOrm.sql`${
|
|
1577
|
+
setParts.push(drizzleOrm.sql`${chunkYAZE7QZR_cjs.quotedColumn(nodes2.deletedAt)} = NULL`);
|
|
1950
1578
|
}
|
|
1951
1579
|
const setClause = drizzleOrm.sql.join(setParts, drizzleOrm.sql`, `);
|
|
1952
1580
|
if (params.clearDeleted) {
|
|
@@ -1973,7 +1601,7 @@ function buildDeleteNode(tables3, params, timestamp2) {
|
|
|
1973
1601
|
const { nodes: nodes2 } = tables3;
|
|
1974
1602
|
return drizzleOrm.sql`
|
|
1975
1603
|
UPDATE ${nodes2}
|
|
1976
|
-
SET ${
|
|
1604
|
+
SET ${chunkYAZE7QZR_cjs.quotedColumn(nodes2.deletedAt)} = ${timestamp2}
|
|
1977
1605
|
WHERE ${nodes2.graphId} = ${params.graphId}
|
|
1978
1606
|
AND ${nodes2.kind} = ${params.kind}
|
|
1979
1607
|
AND ${nodes2.id} = ${params.id}
|
|
@@ -2040,12 +1668,12 @@ function buildSetActiveSchema(tables3, graphId, version, dialect = "sqlite") {
|
|
|
2040
1668
|
const strategy = SCHEMA_DIALECT_STRATEGIES[dialect];
|
|
2041
1669
|
const deactivateAll = drizzleOrm.sql`
|
|
2042
1670
|
UPDATE ${schemaVersions2}
|
|
2043
|
-
SET ${
|
|
1671
|
+
SET ${chunkYAZE7QZR_cjs.quotedColumn(schemaVersions2.isActive)} = ${strategy.booleanLiteral(false)}
|
|
2044
1672
|
WHERE ${schemaVersions2.graphId} = ${graphId}
|
|
2045
1673
|
`;
|
|
2046
1674
|
const activateVersion = drizzleOrm.sql`
|
|
2047
1675
|
UPDATE ${schemaVersions2}
|
|
2048
|
-
SET ${
|
|
1676
|
+
SET ${chunkYAZE7QZR_cjs.quotedColumn(schemaVersions2.isActive)} = ${strategy.booleanLiteral(true)}
|
|
2049
1677
|
WHERE ${schemaVersions2.graphId} = ${graphId}
|
|
2050
1678
|
AND ${schemaVersions2.version} = ${version}
|
|
2051
1679
|
`;
|
|
@@ -2063,22 +1691,22 @@ function buildInsertUniqueSqlite(tables3, params) {
|
|
|
2063
1691
|
)
|
|
2064
1692
|
ON CONFLICT (${conflictColumns})
|
|
2065
1693
|
DO UPDATE SET
|
|
2066
|
-
${
|
|
2067
|
-
WHEN ${
|
|
2068
|
-
WHEN ${
|
|
2069
|
-
ELSE ${
|
|
1694
|
+
${chunkYAZE7QZR_cjs.quotedColumn(uniques2.nodeId)} = CASE
|
|
1695
|
+
WHEN ${chunkYAZE7QZR_cjs.quotedColumn(uniques2.nodeId)} = ${params.nodeId} THEN ${params.nodeId}
|
|
1696
|
+
WHEN ${chunkYAZE7QZR_cjs.quotedColumn(uniques2.deletedAt)} IS NOT NULL THEN ${params.nodeId}
|
|
1697
|
+
ELSE ${chunkYAZE7QZR_cjs.quotedColumn(uniques2.nodeId)}
|
|
2070
1698
|
END,
|
|
2071
|
-
${
|
|
2072
|
-
WHEN ${
|
|
2073
|
-
WHEN ${
|
|
2074
|
-
ELSE ${
|
|
1699
|
+
${chunkYAZE7QZR_cjs.quotedColumn(uniques2.concreteKind)} = CASE
|
|
1700
|
+
WHEN ${chunkYAZE7QZR_cjs.quotedColumn(uniques2.nodeId)} = ${params.nodeId} THEN ${params.concreteKind}
|
|
1701
|
+
WHEN ${chunkYAZE7QZR_cjs.quotedColumn(uniques2.deletedAt)} IS NOT NULL THEN ${params.concreteKind}
|
|
1702
|
+
ELSE ${chunkYAZE7QZR_cjs.quotedColumn(uniques2.concreteKind)}
|
|
2075
1703
|
END,
|
|
2076
|
-
${
|
|
2077
|
-
WHEN ${
|
|
2078
|
-
WHEN ${
|
|
2079
|
-
ELSE ${
|
|
1704
|
+
${chunkYAZE7QZR_cjs.quotedColumn(uniques2.deletedAt)} = CASE
|
|
1705
|
+
WHEN ${chunkYAZE7QZR_cjs.quotedColumn(uniques2.nodeId)} = ${params.nodeId} THEN NULL
|
|
1706
|
+
WHEN ${chunkYAZE7QZR_cjs.quotedColumn(uniques2.deletedAt)} IS NOT NULL THEN NULL
|
|
1707
|
+
ELSE ${chunkYAZE7QZR_cjs.quotedColumn(uniques2.deletedAt)}
|
|
2080
1708
|
END
|
|
2081
|
-
RETURNING ${
|
|
1709
|
+
RETURNING ${chunkYAZE7QZR_cjs.quotedColumn(uniques2.nodeId)} as node_id
|
|
2082
1710
|
`;
|
|
2083
1711
|
}
|
|
2084
1712
|
function buildInsertUniquePostgres(tables3, params) {
|
|
@@ -2095,22 +1723,22 @@ function buildInsertUniquePostgres(tables3, params) {
|
|
|
2095
1723
|
)
|
|
2096
1724
|
ON CONFLICT (${conflictColumns})
|
|
2097
1725
|
DO UPDATE SET
|
|
2098
|
-
${
|
|
1726
|
+
${chunkYAZE7QZR_cjs.quotedColumn(uniques2.nodeId)} = CASE
|
|
2099
1727
|
WHEN ${existingColumn(uniques2.nodeId)} = ${params.nodeId} THEN ${params.nodeId}
|
|
2100
1728
|
WHEN ${existingColumn(uniques2.deletedAt)} IS NOT NULL THEN ${params.nodeId}
|
|
2101
1729
|
ELSE ${existingColumn(uniques2.nodeId)}
|
|
2102
1730
|
END,
|
|
2103
|
-
${
|
|
1731
|
+
${chunkYAZE7QZR_cjs.quotedColumn(uniques2.concreteKind)} = CASE
|
|
2104
1732
|
WHEN ${existingColumn(uniques2.nodeId)} = ${params.nodeId} THEN ${params.concreteKind}
|
|
2105
1733
|
WHEN ${existingColumn(uniques2.deletedAt)} IS NOT NULL THEN ${params.concreteKind}
|
|
2106
1734
|
ELSE ${existingColumn(uniques2.concreteKind)}
|
|
2107
1735
|
END,
|
|
2108
|
-
${
|
|
1736
|
+
${chunkYAZE7QZR_cjs.quotedColumn(uniques2.deletedAt)} = CASE
|
|
2109
1737
|
WHEN ${existingColumn(uniques2.nodeId)} = ${params.nodeId} THEN NULL
|
|
2110
1738
|
WHEN ${existingColumn(uniques2.deletedAt)} IS NOT NULL THEN NULL
|
|
2111
1739
|
ELSE ${existingColumn(uniques2.deletedAt)}
|
|
2112
1740
|
END
|
|
2113
|
-
RETURNING ${
|
|
1741
|
+
RETURNING ${chunkYAZE7QZR_cjs.quotedColumn(uniques2.nodeId)} as node_id
|
|
2114
1742
|
`;
|
|
2115
1743
|
}
|
|
2116
1744
|
var UNIQUE_INSERT_BUILDERS = {
|
|
@@ -2125,7 +1753,7 @@ function buildDeleteUnique(tables3, params, timestamp2) {
|
|
|
2125
1753
|
const { uniques: uniques2 } = tables3;
|
|
2126
1754
|
return drizzleOrm.sql`
|
|
2127
1755
|
UPDATE ${uniques2}
|
|
2128
|
-
SET ${
|
|
1756
|
+
SET ${chunkYAZE7QZR_cjs.quotedColumn(uniques2.deletedAt)} = ${timestamp2}
|
|
2129
1757
|
WHERE ${uniques2.graphId} = ${params.graphId}
|
|
2130
1758
|
AND ${uniques2.nodeKind} = ${params.nodeKind}
|
|
2131
1759
|
AND ${uniques2.constraintName} = ${params.constraintName}
|
|
@@ -2262,17 +1890,437 @@ function createCommonOperationStrategy(tables3, dialect, fulltextStrategy) {
|
|
|
2262
1890
|
buildSetActiveSchema(graphId, version) {
|
|
2263
1891
|
return buildSetActiveSchema(tables3, graphId, version, dialect);
|
|
2264
1892
|
},
|
|
1893
|
+
buildTableExists(tableName) {
|
|
1894
|
+
if (dialect === "postgres") {
|
|
1895
|
+
return drizzleOrm.sql`
|
|
1896
|
+
SELECT c.relname AS table_name
|
|
1897
|
+
FROM pg_catalog.pg_class AS c
|
|
1898
|
+
WHERE c.relname = ${tableName}
|
|
1899
|
+
AND c.relkind IN ('r', 'p', 'v', 'm', 'f')
|
|
1900
|
+
AND pg_catalog.pg_table_is_visible(c.oid)
|
|
1901
|
+
LIMIT 1
|
|
1902
|
+
`;
|
|
1903
|
+
}
|
|
1904
|
+
return drizzleOrm.sql`SELECT name AS table_name FROM sqlite_master WHERE type IN ('table', 'view') AND name = ${tableName}`;
|
|
1905
|
+
},
|
|
2265
1906
|
buildClearGraph(graphId) {
|
|
2266
1907
|
return buildClearGraph(tables3, graphId);
|
|
2267
1908
|
}
|
|
2268
1909
|
};
|
|
2269
1910
|
}
|
|
1911
|
+
function tableExistsFromRow(row) {
|
|
1912
|
+
if (row === void 0) return false;
|
|
1913
|
+
return Object.values(row).some((value) => chunkUNNPKQUG_cjs.isPresent(value));
|
|
1914
|
+
}
|
|
1915
|
+
function createCachedTableExistence(probe, options) {
|
|
1916
|
+
const cacheExisting = options?.cacheExisting !== false;
|
|
1917
|
+
const cacheMissing = options?.cacheMissing === true;
|
|
1918
|
+
const confirmedExisting = /* @__PURE__ */ new Set();
|
|
1919
|
+
const confirmedMissing = /* @__PURE__ */ new Set();
|
|
1920
|
+
return async function tableExists(tableName) {
|
|
1921
|
+
if (confirmedExisting.has(tableName)) return true;
|
|
1922
|
+
if (confirmedMissing.has(tableName)) return false;
|
|
1923
|
+
const exists = tableExistsFromRow(await probe(tableName));
|
|
1924
|
+
if (exists && cacheExisting) {
|
|
1925
|
+
confirmedExisting.add(tableName);
|
|
1926
|
+
}
|
|
1927
|
+
if (!exists && cacheMissing) {
|
|
1928
|
+
confirmedMissing.add(tableName);
|
|
1929
|
+
}
|
|
1930
|
+
return exists;
|
|
1931
|
+
};
|
|
1932
|
+
}
|
|
2270
1933
|
function createSqliteOperationStrategy(tables3, fulltextStrategy) {
|
|
2271
1934
|
return createCommonOperationStrategy(tables3, "sqlite", fulltextStrategy);
|
|
2272
1935
|
}
|
|
2273
1936
|
function createPostgresOperationStrategy(tables3, fulltextStrategy) {
|
|
2274
1937
|
return createCommonOperationStrategy(tables3, "postgres", fulltextStrategy);
|
|
2275
1938
|
}
|
|
1939
|
+
function assertAdoptedDialect(externalTx, brand, backend) {
|
|
1940
|
+
if (drizzleOrm.is(externalTx, brand)) return;
|
|
1941
|
+
const label = backend === "postgres" ? "Postgres" : "SQLite";
|
|
1942
|
+
throw new chunkJIEJCTDS_cjs.ConfigurationError(
|
|
1943
|
+
`adoptTransaction received a handle that is not a ${label} Drizzle transaction. Pass the \`tx\` from a ${label} \`db.transaction(...)\` opened on this backend's connection.`,
|
|
1944
|
+
{ backend, capability: "adoptTransaction" }
|
|
1945
|
+
);
|
|
1946
|
+
}
|
|
1947
|
+
function verifyExpectedActiveVersion(graphId, expected, actualActiveVersion) {
|
|
1948
|
+
const expectedVersion = expected.kind === "active" ? expected.version : 0;
|
|
1949
|
+
if (actualActiveVersion !== expectedVersion) {
|
|
1950
|
+
throw new chunkJIEJCTDS_cjs.StaleVersionError({
|
|
1951
|
+
graphId,
|
|
1952
|
+
expected: expectedVersion,
|
|
1953
|
+
actual: actualActiveVersion
|
|
1954
|
+
});
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
function createCommonOperationBackend(options) {
|
|
1958
|
+
const { batchConfig, execution, operationStrategy, rowMappers } = options;
|
|
1959
|
+
const nowIso2 = options.nowIso ?? chunkJJRCLAUN_cjs.nowIso;
|
|
1960
|
+
const requiredClearTableExists = createCachedTableExistence(
|
|
1961
|
+
(tableName) => execution.execGet(
|
|
1962
|
+
operationStrategy.buildTableExists(tableName)
|
|
1963
|
+
),
|
|
1964
|
+
options.tableExistenceCache
|
|
1965
|
+
);
|
|
1966
|
+
async function runIgnorableClearStatement(statement) {
|
|
1967
|
+
if (statement.ignoreMissingTable === true && statement.requiredTableName !== void 0 && !await requiredClearTableExists(statement.requiredTableName)) {
|
|
1968
|
+
return;
|
|
1969
|
+
}
|
|
1970
|
+
await execution.execRun(statement.query);
|
|
1971
|
+
}
|
|
1972
|
+
async function readActiveVersion(graphId) {
|
|
1973
|
+
const row = await execution.execGet(
|
|
1974
|
+
operationStrategy.buildGetActiveSchema(graphId)
|
|
1975
|
+
);
|
|
1976
|
+
return row === void 0 ? 0 : rowMappers.toSchemaVersionRow(row).version;
|
|
1977
|
+
}
|
|
1978
|
+
return {
|
|
1979
|
+
async executeStatement(query) {
|
|
1980
|
+
await execution.execRun(query);
|
|
1981
|
+
},
|
|
1982
|
+
async insertNode(params) {
|
|
1983
|
+
const timestamp2 = nowIso2();
|
|
1984
|
+
const query = operationStrategy.buildInsertNode(params, timestamp2);
|
|
1985
|
+
const row = await execution.execGet(query);
|
|
1986
|
+
if (!row) throw new chunkJIEJCTDS_cjs.DatabaseOperationError("Insert node failed: no row returned", { operation: "insert", entity: "node" });
|
|
1987
|
+
return rowMappers.toNodeRow(row);
|
|
1988
|
+
},
|
|
1989
|
+
async insertNodeNoReturn(params) {
|
|
1990
|
+
const timestamp2 = nowIso2();
|
|
1991
|
+
const query = operationStrategy.buildInsertNodeNoReturn(params, timestamp2);
|
|
1992
|
+
await execution.execRun(query);
|
|
1993
|
+
},
|
|
1994
|
+
async insertNodesBatch(params) {
|
|
1995
|
+
if (params.length === 0) {
|
|
1996
|
+
return;
|
|
1997
|
+
}
|
|
1998
|
+
const timestamp2 = nowIso2();
|
|
1999
|
+
for (const chunk2 of chunkUNNPKQUG_cjs.chunk(params, batchConfig.nodeInsertBatchSize)) {
|
|
2000
|
+
const query = operationStrategy.buildInsertNodesBatch(chunk2, timestamp2);
|
|
2001
|
+
await execution.execRun(query);
|
|
2002
|
+
}
|
|
2003
|
+
},
|
|
2004
|
+
async insertNodesBatchReturning(params) {
|
|
2005
|
+
if (params.length === 0) {
|
|
2006
|
+
return [];
|
|
2007
|
+
}
|
|
2008
|
+
const timestamp2 = nowIso2();
|
|
2009
|
+
const allRows = [];
|
|
2010
|
+
for (const chunk2 of chunkUNNPKQUG_cjs.chunk(params, batchConfig.nodeInsertBatchSize)) {
|
|
2011
|
+
const query = operationStrategy.buildInsertNodesBatchReturning(chunk2, timestamp2);
|
|
2012
|
+
const rows = await execution.execAll(query);
|
|
2013
|
+
allRows.push(...rows.map((row) => rowMappers.toNodeRow(row)));
|
|
2014
|
+
}
|
|
2015
|
+
return allRows;
|
|
2016
|
+
},
|
|
2017
|
+
async getNode(graphId, kind, id) {
|
|
2018
|
+
const query = operationStrategy.buildGetNode(graphId, kind, id);
|
|
2019
|
+
const row = await execution.execGet(query);
|
|
2020
|
+
return row ? rowMappers.toNodeRow(row) : void 0;
|
|
2021
|
+
},
|
|
2022
|
+
async getNodes(graphId, kind, ids) {
|
|
2023
|
+
if (ids.length === 0) return [];
|
|
2024
|
+
const allRows = [];
|
|
2025
|
+
for (const chunk2 of chunkUNNPKQUG_cjs.chunk(ids, batchConfig.getNodesChunkSize)) {
|
|
2026
|
+
const query = operationStrategy.buildGetNodes(graphId, kind, chunk2);
|
|
2027
|
+
const rows = await execution.execAll(query);
|
|
2028
|
+
allRows.push(...rows.map((row) => rowMappers.toNodeRow(row)));
|
|
2029
|
+
}
|
|
2030
|
+
return allRows;
|
|
2031
|
+
},
|
|
2032
|
+
async updateNode(params) {
|
|
2033
|
+
const timestamp2 = nowIso2();
|
|
2034
|
+
const query = operationStrategy.buildUpdateNode(params, timestamp2);
|
|
2035
|
+
const row = await execution.execGet(query);
|
|
2036
|
+
if (!row) throw new chunkJIEJCTDS_cjs.DatabaseOperationError("Update node failed: no row returned", { operation: "update", entity: "node" });
|
|
2037
|
+
return rowMappers.toNodeRow(row);
|
|
2038
|
+
},
|
|
2039
|
+
async deleteNode(params) {
|
|
2040
|
+
const timestamp2 = nowIso2();
|
|
2041
|
+
const query = operationStrategy.buildDeleteNode(params, timestamp2);
|
|
2042
|
+
await execution.execRun(query);
|
|
2043
|
+
},
|
|
2044
|
+
// IMPORTANT: This cascade is not atomic. Callers must ensure this runs
|
|
2045
|
+
// within a transaction to prevent partial deletion on intermediate failure.
|
|
2046
|
+
//
|
|
2047
|
+
// Embeddings are NOT cleaned up here: they live in per-`(nodeKind,
|
|
2048
|
+
// fieldPath)` strategy-owned tables addressable only with the slot
|
|
2049
|
+
// context the graph-agnostic backend lacks. The store's hard-delete
|
|
2050
|
+
// path (`executeNodeHardDelete`) drives `deleteNodeEmbeddings`, which
|
|
2051
|
+
// resolves each embedding field and routes a per-field
|
|
2052
|
+
// `backend.deleteEmbedding` through the active vector strategy.
|
|
2053
|
+
async hardDeleteNode(params) {
|
|
2054
|
+
const deleteUniquesQuery = operationStrategy.buildHardDeleteUniquesByNode(
|
|
2055
|
+
params.graphId,
|
|
2056
|
+
params.id
|
|
2057
|
+
);
|
|
2058
|
+
await execution.execRun(deleteUniquesQuery);
|
|
2059
|
+
const deleteFulltextStatements = operationStrategy.buildDeleteFulltextByNode(
|
|
2060
|
+
params.graphId,
|
|
2061
|
+
params.kind,
|
|
2062
|
+
params.id
|
|
2063
|
+
);
|
|
2064
|
+
for (const stmt of deleteFulltextStatements) {
|
|
2065
|
+
await execution.execRun(stmt);
|
|
2066
|
+
}
|
|
2067
|
+
const deleteEdgesQuery = operationStrategy.buildHardDeleteEdgesByNode(
|
|
2068
|
+
params.graphId,
|
|
2069
|
+
params.kind,
|
|
2070
|
+
params.id
|
|
2071
|
+
);
|
|
2072
|
+
await execution.execRun(deleteEdgesQuery);
|
|
2073
|
+
const query = operationStrategy.buildHardDeleteNode(params);
|
|
2074
|
+
await execution.execRun(query);
|
|
2075
|
+
},
|
|
2076
|
+
async insertEdge(params) {
|
|
2077
|
+
const timestamp2 = nowIso2();
|
|
2078
|
+
const query = operationStrategy.buildInsertEdge(params, timestamp2);
|
|
2079
|
+
const row = await execution.execGet(query);
|
|
2080
|
+
if (!row) throw new chunkJIEJCTDS_cjs.DatabaseOperationError("Insert edge failed: no row returned", { operation: "insert", entity: "edge" });
|
|
2081
|
+
return rowMappers.toEdgeRow(row);
|
|
2082
|
+
},
|
|
2083
|
+
async insertEdgeNoReturn(params) {
|
|
2084
|
+
const timestamp2 = nowIso2();
|
|
2085
|
+
const query = operationStrategy.buildInsertEdgeNoReturn(params, timestamp2);
|
|
2086
|
+
await execution.execRun(query);
|
|
2087
|
+
},
|
|
2088
|
+
async insertEdgesBatch(params) {
|
|
2089
|
+
if (params.length === 0) {
|
|
2090
|
+
return;
|
|
2091
|
+
}
|
|
2092
|
+
const timestamp2 = nowIso2();
|
|
2093
|
+
for (const chunk2 of chunkUNNPKQUG_cjs.chunk(params, batchConfig.edgeInsertBatchSize)) {
|
|
2094
|
+
const query = operationStrategy.buildInsertEdgesBatch(chunk2, timestamp2);
|
|
2095
|
+
await execution.execRun(query);
|
|
2096
|
+
}
|
|
2097
|
+
},
|
|
2098
|
+
async insertEdgesBatchReturning(params) {
|
|
2099
|
+
if (params.length === 0) {
|
|
2100
|
+
return [];
|
|
2101
|
+
}
|
|
2102
|
+
const timestamp2 = nowIso2();
|
|
2103
|
+
const allRows = [];
|
|
2104
|
+
for (const chunk2 of chunkUNNPKQUG_cjs.chunk(params, batchConfig.edgeInsertBatchSize)) {
|
|
2105
|
+
const query = operationStrategy.buildInsertEdgesBatchReturning(chunk2, timestamp2);
|
|
2106
|
+
const rows = await execution.execAll(query);
|
|
2107
|
+
allRows.push(...rows.map((row) => rowMappers.toEdgeRow(row)));
|
|
2108
|
+
}
|
|
2109
|
+
return allRows;
|
|
2110
|
+
},
|
|
2111
|
+
async getEdge(graphId, id) {
|
|
2112
|
+
const query = operationStrategy.buildGetEdge(graphId, id);
|
|
2113
|
+
const row = await execution.execGet(query);
|
|
2114
|
+
return row ? rowMappers.toEdgeRow(row) : void 0;
|
|
2115
|
+
},
|
|
2116
|
+
async getEdges(graphId, ids) {
|
|
2117
|
+
if (ids.length === 0) return [];
|
|
2118
|
+
const allRows = [];
|
|
2119
|
+
for (const chunk2 of chunkUNNPKQUG_cjs.chunk(ids, batchConfig.getEdgesChunkSize)) {
|
|
2120
|
+
const query = operationStrategy.buildGetEdges(graphId, chunk2);
|
|
2121
|
+
const rows = await execution.execAll(query);
|
|
2122
|
+
allRows.push(...rows.map((row) => rowMappers.toEdgeRow(row)));
|
|
2123
|
+
}
|
|
2124
|
+
return allRows;
|
|
2125
|
+
},
|
|
2126
|
+
async updateEdge(params) {
|
|
2127
|
+
const timestamp2 = nowIso2();
|
|
2128
|
+
const query = operationStrategy.buildUpdateEdge(params, timestamp2);
|
|
2129
|
+
const row = await execution.execGet(query);
|
|
2130
|
+
if (!row) throw new chunkJIEJCTDS_cjs.DatabaseOperationError("Update edge failed: no row returned", { operation: "update", entity: "edge" });
|
|
2131
|
+
return rowMappers.toEdgeRow(row);
|
|
2132
|
+
},
|
|
2133
|
+
async deleteEdge(params) {
|
|
2134
|
+
const timestamp2 = nowIso2();
|
|
2135
|
+
const query = operationStrategy.buildDeleteEdge(params, timestamp2);
|
|
2136
|
+
await execution.execRun(query);
|
|
2137
|
+
},
|
|
2138
|
+
async hardDeleteEdge(params) {
|
|
2139
|
+
const query = operationStrategy.buildHardDeleteEdge(params);
|
|
2140
|
+
await execution.execRun(query);
|
|
2141
|
+
},
|
|
2142
|
+
async countEdgesFrom(params) {
|
|
2143
|
+
const query = operationStrategy.buildCountEdgesFrom(params);
|
|
2144
|
+
const row = await execution.execGet(query);
|
|
2145
|
+
return Number(row?.count ?? 0);
|
|
2146
|
+
},
|
|
2147
|
+
async edgeExistsBetween(params) {
|
|
2148
|
+
const query = operationStrategy.buildEdgeExistsBetween(params);
|
|
2149
|
+
const row = await execution.execGet(query);
|
|
2150
|
+
return row !== void 0;
|
|
2151
|
+
},
|
|
2152
|
+
async findEdgesConnectedTo(params) {
|
|
2153
|
+
const query = operationStrategy.buildFindEdgesConnectedTo(params);
|
|
2154
|
+
const rows = await execution.execAll(query);
|
|
2155
|
+
return rows.map((row) => rowMappers.toEdgeRow(row));
|
|
2156
|
+
},
|
|
2157
|
+
async findNodesByKind(params) {
|
|
2158
|
+
const query = operationStrategy.buildFindNodesByKind(params);
|
|
2159
|
+
const rows = await execution.execAll(query);
|
|
2160
|
+
return rows.map((row) => rowMappers.toNodeRow(row));
|
|
2161
|
+
},
|
|
2162
|
+
async countNodesByKind(params) {
|
|
2163
|
+
const query = operationStrategy.buildCountNodesByKind(params);
|
|
2164
|
+
const row = await execution.execGet(query);
|
|
2165
|
+
return Number(row?.count ?? 0);
|
|
2166
|
+
},
|
|
2167
|
+
async findEdgesByKind(params) {
|
|
2168
|
+
const query = operationStrategy.buildFindEdgesByKind(params);
|
|
2169
|
+
const rows = await execution.execAll(query);
|
|
2170
|
+
return rows.map((row) => rowMappers.toEdgeRow(row));
|
|
2171
|
+
},
|
|
2172
|
+
async countEdgesByKind(params) {
|
|
2173
|
+
const query = operationStrategy.buildCountEdgesByKind(params);
|
|
2174
|
+
const row = await execution.execGet(query);
|
|
2175
|
+
return Number(row?.count ?? 0);
|
|
2176
|
+
},
|
|
2177
|
+
async insertUnique(params) {
|
|
2178
|
+
const query = operationStrategy.buildInsertUnique(params);
|
|
2179
|
+
const result = await execution.execGet(query);
|
|
2180
|
+
if (result && result.node_id !== params.nodeId) {
|
|
2181
|
+
throw new chunkJIEJCTDS_cjs.UniquenessError({
|
|
2182
|
+
constraintName: params.constraintName,
|
|
2183
|
+
kind: params.nodeKind,
|
|
2184
|
+
existingId: result.node_id,
|
|
2185
|
+
newId: params.nodeId,
|
|
2186
|
+
fields: []
|
|
2187
|
+
});
|
|
2188
|
+
}
|
|
2189
|
+
},
|
|
2190
|
+
async deleteUnique(params) {
|
|
2191
|
+
const timestamp2 = nowIso2();
|
|
2192
|
+
const query = operationStrategy.buildDeleteUnique(params, timestamp2);
|
|
2193
|
+
await execution.execRun(query);
|
|
2194
|
+
},
|
|
2195
|
+
async checkUnique(params) {
|
|
2196
|
+
const query = operationStrategy.buildCheckUnique(params);
|
|
2197
|
+
const row = await execution.execGet(query);
|
|
2198
|
+
return row ? rowMappers.toUniqueRow(row) : void 0;
|
|
2199
|
+
},
|
|
2200
|
+
async checkUniqueBatch(params) {
|
|
2201
|
+
if (params.keys.length === 0) return [];
|
|
2202
|
+
const allRows = [];
|
|
2203
|
+
for (const chunk2 of chunkUNNPKQUG_cjs.chunk(params.keys, batchConfig.checkUniqueBatchChunkSize)) {
|
|
2204
|
+
const query = operationStrategy.buildCheckUniqueBatch({ ...params, keys: chunk2 });
|
|
2205
|
+
const rows = await execution.execAll(query);
|
|
2206
|
+
allRows.push(...rows.map((row) => rowMappers.toUniqueRow(row)));
|
|
2207
|
+
}
|
|
2208
|
+
return allRows;
|
|
2209
|
+
},
|
|
2210
|
+
async getActiveSchema(graphId) {
|
|
2211
|
+
const query = operationStrategy.buildGetActiveSchema(graphId);
|
|
2212
|
+
const row = await execution.execGet(query);
|
|
2213
|
+
return row ? rowMappers.toSchemaVersionRow(row) : void 0;
|
|
2214
|
+
},
|
|
2215
|
+
async getSchemaVersion(graphId, version) {
|
|
2216
|
+
const query = operationStrategy.buildGetSchemaVersion(graphId, version);
|
|
2217
|
+
const row = await execution.execGet(query);
|
|
2218
|
+
return row ? rowMappers.toSchemaVersionRow(row) : void 0;
|
|
2219
|
+
},
|
|
2220
|
+
async commitSchemaVersion(params) {
|
|
2221
|
+
const existingRaw = await execution.execGet(
|
|
2222
|
+
operationStrategy.buildGetSchemaVersion(
|
|
2223
|
+
params.graphId,
|
|
2224
|
+
params.version
|
|
2225
|
+
)
|
|
2226
|
+
);
|
|
2227
|
+
const actualActiveVersion = await readActiveVersion(params.graphId);
|
|
2228
|
+
if (existingRaw !== void 0) {
|
|
2229
|
+
const existing = rowMappers.toSchemaVersionRow(existingRaw);
|
|
2230
|
+
if (existing.schema_hash !== params.schemaHash) {
|
|
2231
|
+
throw new chunkJIEJCTDS_cjs.SchemaContentConflictError({
|
|
2232
|
+
graphId: params.graphId,
|
|
2233
|
+
version: params.version,
|
|
2234
|
+
existingHash: existing.schema_hash,
|
|
2235
|
+
incomingHash: params.schemaHash
|
|
2236
|
+
});
|
|
2237
|
+
}
|
|
2238
|
+
if (existing.is_active) {
|
|
2239
|
+
return existing;
|
|
2240
|
+
}
|
|
2241
|
+
verifyExpectedActiveVersion(
|
|
2242
|
+
params.graphId,
|
|
2243
|
+
params.expected,
|
|
2244
|
+
actualActiveVersion
|
|
2245
|
+
);
|
|
2246
|
+
const reactivate = operationStrategy.buildSetActiveSchema(
|
|
2247
|
+
params.graphId,
|
|
2248
|
+
params.version
|
|
2249
|
+
);
|
|
2250
|
+
await execution.execRun(reactivate.deactivateAll);
|
|
2251
|
+
await execution.execRun(reactivate.activateVersion);
|
|
2252
|
+
return { ...existing, is_active: true };
|
|
2253
|
+
}
|
|
2254
|
+
verifyExpectedActiveVersion(
|
|
2255
|
+
params.graphId,
|
|
2256
|
+
params.expected,
|
|
2257
|
+
actualActiveVersion
|
|
2258
|
+
);
|
|
2259
|
+
if (params.expected.kind === "active") {
|
|
2260
|
+
const flip = operationStrategy.buildSetActiveSchema(
|
|
2261
|
+
params.graphId,
|
|
2262
|
+
params.version
|
|
2263
|
+
);
|
|
2264
|
+
await execution.execRun(flip.deactivateAll);
|
|
2265
|
+
}
|
|
2266
|
+
const timestamp2 = nowIso2();
|
|
2267
|
+
const insertQuery = operationStrategy.buildInsertSchema(
|
|
2268
|
+
{
|
|
2269
|
+
graphId: params.graphId,
|
|
2270
|
+
version: params.version,
|
|
2271
|
+
schemaHash: params.schemaHash,
|
|
2272
|
+
schemaDoc: params.schemaDoc,
|
|
2273
|
+
isActive: true
|
|
2274
|
+
},
|
|
2275
|
+
timestamp2
|
|
2276
|
+
);
|
|
2277
|
+
const insertedRaw = await execution.execGet(insertQuery);
|
|
2278
|
+
if (!insertedRaw) {
|
|
2279
|
+
throw new chunkJIEJCTDS_cjs.DatabaseOperationError(
|
|
2280
|
+
"Insert schema failed: no row returned",
|
|
2281
|
+
{ operation: "insert", entity: "schema" }
|
|
2282
|
+
);
|
|
2283
|
+
}
|
|
2284
|
+
return rowMappers.toSchemaVersionRow(insertedRaw);
|
|
2285
|
+
},
|
|
2286
|
+
async setActiveVersion(params) {
|
|
2287
|
+
const actualActiveVersion = await readActiveVersion(params.graphId);
|
|
2288
|
+
verifyExpectedActiveVersion(
|
|
2289
|
+
params.graphId,
|
|
2290
|
+
params.expected,
|
|
2291
|
+
actualActiveVersion
|
|
2292
|
+
);
|
|
2293
|
+
const targetRaw = await execution.execGet(
|
|
2294
|
+
operationStrategy.buildGetSchemaVersion(
|
|
2295
|
+
params.graphId,
|
|
2296
|
+
params.version
|
|
2297
|
+
)
|
|
2298
|
+
);
|
|
2299
|
+
if (!targetRaw) {
|
|
2300
|
+
throw new chunkJIEJCTDS_cjs.MigrationError(
|
|
2301
|
+
`Cannot activate version ${params.version}: version does not exist for graph "${params.graphId}".`,
|
|
2302
|
+
{
|
|
2303
|
+
graphId: params.graphId,
|
|
2304
|
+
fromVersion: actualActiveVersion,
|
|
2305
|
+
toVersion: params.version
|
|
2306
|
+
}
|
|
2307
|
+
);
|
|
2308
|
+
}
|
|
2309
|
+
const queries = operationStrategy.buildSetActiveSchema(
|
|
2310
|
+
params.graphId,
|
|
2311
|
+
params.version
|
|
2312
|
+
);
|
|
2313
|
+
await execution.execRun(queries.deactivateAll);
|
|
2314
|
+
await execution.execRun(queries.activateVersion);
|
|
2315
|
+
},
|
|
2316
|
+
async clearGraph(graphId) {
|
|
2317
|
+
const statements = operationStrategy.buildClearGraph(graphId);
|
|
2318
|
+
for (const statement of statements) {
|
|
2319
|
+
await runIgnorableClearStatement(statement);
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
};
|
|
2323
|
+
}
|
|
2276
2324
|
|
|
2277
2325
|
// src/backend/drizzle/execution/lru.ts
|
|
2278
2326
|
function getOrCreateLru(cache, key, cacheMax, create) {
|
|
@@ -2304,11 +2352,9 @@ function compileQueryWithDialect(db, query, backendName) {
|
|
|
2304
2352
|
exports.POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS = POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS;
|
|
2305
2353
|
exports.POSTGRES_INDEX_MAT_TIMESTAMPS = POSTGRES_INDEX_MAT_TIMESTAMPS;
|
|
2306
2354
|
exports.POSTGRES_KIND_REMOVAL_TIMESTAMPS = POSTGRES_KIND_REMOVAL_TIMESTAMPS;
|
|
2307
|
-
exports.POSTGRES_ROW_MAPPER_CONFIG = POSTGRES_ROW_MAPPER_CONFIG;
|
|
2308
2355
|
exports.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS = SQLITE_CONTRIBUTION_MAT_TIMESTAMPS;
|
|
2309
2356
|
exports.SQLITE_INDEX_MAT_TIMESTAMPS = SQLITE_INDEX_MAT_TIMESTAMPS;
|
|
2310
2357
|
exports.SQLITE_KIND_REMOVAL_TIMESTAMPS = SQLITE_KIND_REMOVAL_TIMESTAMPS;
|
|
2311
|
-
exports.SQLITE_ROW_MAPPER_CONFIG = SQLITE_ROW_MAPPER_CONFIG;
|
|
2312
2358
|
exports.assertAdoptedDialect = assertAdoptedDialect;
|
|
2313
2359
|
exports.buildContributionInsertValues = buildContributionInsertValues;
|
|
2314
2360
|
exports.buildContributionOnConflictSet = buildContributionOnConflictSet;
|
|
@@ -2316,17 +2362,13 @@ exports.buildKindRemovalInsertValues = buildKindRemovalInsertValues;
|
|
|
2316
2362
|
exports.buildKindRemovalOnConflictSet = buildKindRemovalOnConflictSet;
|
|
2317
2363
|
exports.buildMaterializationInsertValues = buildMaterializationInsertValues;
|
|
2318
2364
|
exports.buildMaterializationOnConflictSet = buildMaterializationOnConflictSet;
|
|
2319
|
-
exports.coerceNumericScore = coerceNumericScore;
|
|
2320
2365
|
exports.compileQueryWithDialect = compileQueryWithDialect;
|
|
2366
|
+
exports.createCachedTableExistence = createCachedTableExistence;
|
|
2321
2367
|
exports.createCommonOperationBackend = createCommonOperationBackend;
|
|
2322
2368
|
exports.createContributionMaterializer = createContributionMaterializer;
|
|
2323
|
-
exports.createEdgeRowMapper = createEdgeRowMapper;
|
|
2324
|
-
exports.createNodeRowMapper = createNodeRowMapper;
|
|
2325
2369
|
exports.createPostgresOperationStrategy = createPostgresOperationStrategy;
|
|
2326
2370
|
exports.createPostgresTables = createPostgresTables;
|
|
2327
|
-
exports.createSchemaVersionRowMapper = createSchemaVersionRowMapper;
|
|
2328
2371
|
exports.createSqliteOperationStrategy = createSqliteOperationStrategy;
|
|
2329
|
-
exports.createUniqueRowMapper = createUniqueRowMapper;
|
|
2330
2372
|
exports.createVectorSlotLatch = createVectorSlotLatch;
|
|
2331
2373
|
exports.edges = edges;
|
|
2332
2374
|
exports.fulltext = fulltext;
|
|
@@ -2344,12 +2386,14 @@ exports.mapKindRemovalRow = mapKindRemovalRow;
|
|
|
2344
2386
|
exports.mapMaterializationRow = mapMaterializationRow;
|
|
2345
2387
|
exports.mapVectorWriteError = mapVectorWriteError;
|
|
2346
2388
|
exports.nodes = nodes;
|
|
2347
|
-
exports.
|
|
2389
|
+
exports.recordedClock = recordedClock;
|
|
2390
|
+
exports.recordedEdges = recordedEdges;
|
|
2391
|
+
exports.recordedNodes = recordedNodes;
|
|
2348
2392
|
exports.schemaVersions = schemaVersions;
|
|
2349
2393
|
exports.tables = tables2;
|
|
2350
2394
|
exports.uniques = uniques;
|
|
2351
2395
|
exports.vectorSlotFromCreateIndexParams = vectorSlotFromCreateIndexParams;
|
|
2352
2396
|
exports.vectorSlotFromDropIndexParams = vectorSlotFromDropIndexParams;
|
|
2353
2397
|
exports.vectorSlotFromParams = vectorSlotFromParams;
|
|
2354
|
-
//# sourceMappingURL=chunk-
|
|
2355
|
-
//# sourceMappingURL=chunk-
|
|
2398
|
+
//# sourceMappingURL=chunk-UJLOZYKT.cjs.map
|
|
2399
|
+
//# sourceMappingURL=chunk-UJLOZYKT.cjs.map
|