@nicia-ai/typegraph 0.35.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend/postgres/index.cjs +24 -24
- package/dist/backend/postgres/index.d.cts +6 -6
- package/dist/backend/postgres/index.d.ts +6 -6
- package/dist/backend/postgres/index.js +11 -11
- package/dist/backend/postgres/pglite.cjs +16 -16
- package/dist/backend/postgres/pglite.d.cts +3 -3
- package/dist/backend/postgres/pglite.d.ts +3 -3
- package/dist/backend/postgres/pglite.js +11 -11
- package/dist/backend/sqlite/index.cjs +22 -21
- package/dist/backend/sqlite/index.d.cts +11 -9
- package/dist/backend/sqlite/index.d.ts +11 -9
- package/dist/backend/sqlite/index.js +10 -9
- package/dist/backend/sqlite/libsql.cjs +15 -14
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +3 -3
- package/dist/backend/sqlite/libsql.d.ts +3 -3
- package/dist/backend/sqlite/libsql.js +11 -10
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +30 -23
- 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 +18 -11
- package/dist/backend/sqlite/local.js.map +1 -1
- package/dist/{chunk-TCOCYN2P.cjs → chunk-27SSDCEP.cjs} +14 -14
- package/dist/{chunk-TCOCYN2P.cjs.map → chunk-27SSDCEP.cjs.map} +1 -1
- package/dist/{chunk-5AQIKK56.cjs → chunk-2N6EOBTH.cjs} +16 -16
- package/dist/{chunk-5AQIKK56.cjs.map → chunk-2N6EOBTH.cjs.map} +1 -1
- package/dist/{chunk-FN35DLCN.cjs → chunk-3C2RYI6L.cjs} +13 -107
- package/dist/chunk-3C2RYI6L.cjs.map +1 -0
- package/dist/{chunk-4JEZZJ6S.cjs → chunk-3DS7Z4T4.cjs} +39 -39
- package/dist/{chunk-4JEZZJ6S.cjs.map → chunk-3DS7Z4T4.cjs.map} +1 -1
- package/dist/{chunk-BLZDPRXT.cjs → chunk-3GH67G4Z.cjs} +5 -5
- package/dist/{chunk-BLZDPRXT.cjs.map → chunk-3GH67G4Z.cjs.map} +1 -1
- package/dist/{chunk-K3PPLHY7.js → chunk-3RWZPJKV.js} +24 -9
- package/dist/chunk-3RWZPJKV.js.map +1 -0
- package/dist/{chunk-QWEUYILR.js → chunk-3SLPDKHQ.js} +4 -4
- package/dist/chunk-3SLPDKHQ.js.map +1 -0
- package/dist/{chunk-5A6FNS6N.cjs → chunk-3XXGYU62.cjs} +11 -11
- package/dist/{chunk-5A6FNS6N.cjs.map → chunk-3XXGYU62.cjs.map} +1 -1
- package/dist/{chunk-JBTOYDMN.js → chunk-44TA22QT.js} +58 -11
- package/dist/chunk-44TA22QT.js.map +1 -0
- package/dist/{chunk-UES55P7G.js → chunk-552KNYQJ.js} +2652 -409
- package/dist/chunk-552KNYQJ.js.map +1 -0
- package/dist/{chunk-VPYHY3LJ.cjs → chunk-5KEQ74YU.cjs} +14 -14
- package/dist/chunk-5KEQ74YU.cjs.map +1 -0
- package/dist/{chunk-Q5TEXCTB.js → chunk-5KPNWT6X.js} +3 -3
- package/dist/{chunk-Q5TEXCTB.js.map → chunk-5KPNWT6X.js.map} +1 -1
- package/dist/{chunk-MP2JQKSG.js → chunk-5PNMDJ7J.js} +108 -5
- package/dist/chunk-5PNMDJ7J.js.map +1 -0
- package/dist/{chunk-AW4A3P5A.cjs → chunk-5VQM6VWP.cjs} +2 -2
- package/dist/{chunk-AW4A3P5A.cjs.map → chunk-5VQM6VWP.cjs.map} +1 -1
- package/dist/{chunk-A3W7QG7K.js → chunk-5WWVZMVX.js} +2 -2
- package/dist/{chunk-A3W7QG7K.js.map → chunk-5WWVZMVX.js.map} +1 -1
- package/dist/{chunk-FACJJWGF.cjs → chunk-6EEO3OVU.cjs} +7 -7
- package/dist/{chunk-FACJJWGF.cjs.map → chunk-6EEO3OVU.cjs.map} +1 -1
- package/dist/{chunk-LGEALRC6.cjs → chunk-BVRDGYXQ.cjs} +113 -4
- package/dist/chunk-BVRDGYXQ.cjs.map +1 -0
- package/dist/{chunk-GSQ6NPH6.cjs → chunk-DEFQM7JU.cjs} +7 -7
- package/dist/{chunk-GSQ6NPH6.cjs.map → chunk-DEFQM7JU.cjs.map} +1 -1
- package/dist/{chunk-EM3CWPND.cjs → chunk-DIQ3AV5W.cjs} +574 -268
- package/dist/chunk-DIQ3AV5W.cjs.map +1 -0
- package/dist/{chunk-FPIZFYHE.js → chunk-EXU3RASM.js} +74 -15
- package/dist/chunk-EXU3RASM.js.map +1 -0
- package/dist/{chunk-H7YNSMA7.cjs → chunk-HAHNRASW.cjs} +20 -2
- package/dist/chunk-HAHNRASW.cjs.map +1 -0
- package/dist/{chunk-FL472AMI.cjs → chunk-IP3CGGPA.cjs} +8 -8
- package/dist/{chunk-FL472AMI.cjs.map → chunk-IP3CGGPA.cjs.map} +1 -1
- package/dist/{chunk-4TOD4LBZ.cjs → chunk-IPSVVTWT.cjs} +94 -35
- package/dist/chunk-IPSVVTWT.cjs.map +1 -0
- package/dist/{chunk-RGP33ZJ5.js → chunk-IXGYRP2P.js} +184 -92
- package/dist/chunk-IXGYRP2P.js.map +1 -0
- package/dist/{chunk-3TWF3SH4.js → chunk-J4IUSYFF.js} +251 -121
- package/dist/chunk-J4IUSYFF.js.map +1 -0
- package/dist/{chunk-O7UN7OXA.cjs → chunk-JBNOGRKW.cjs} +318 -188
- package/dist/chunk-JBNOGRKW.cjs.map +1 -0
- package/dist/{chunk-WDBCBWC4.js → chunk-K3Q3LJY3.js} +520 -221
- package/dist/chunk-K3Q3LJY3.js.map +1 -0
- package/dist/{chunk-OR5ZA5WP.js → chunk-K5UBVGJN.js} +4 -4
- package/dist/{chunk-OR5ZA5WP.js.map → chunk-K5UBVGJN.js.map} +1 -1
- package/dist/{chunk-UZV3AZKF.js → chunk-KQJ54OG5.js} +3 -3
- package/dist/{chunk-UZV3AZKF.js.map → chunk-KQJ54OG5.js.map} +1 -1
- package/dist/{chunk-QOTI55H7.js → chunk-L7HQ2OSI.js} +4 -4
- package/dist/{chunk-QOTI55H7.js.map → chunk-L7HQ2OSI.js.map} +1 -1
- package/dist/{chunk-55MZDDZV.js → chunk-M6VES7V6.js} +4 -4
- package/dist/{chunk-55MZDDZV.js.map → chunk-M6VES7V6.js.map} +1 -1
- package/dist/{chunk-J7WFGBJR.cjs → chunk-NBP2WTJW.cjs} +3249 -1006
- package/dist/chunk-NBP2WTJW.cjs.map +1 -0
- package/dist/{chunk-CK5BVQOW.cjs → chunk-NUIG3BCV.cjs} +100 -85
- package/dist/chunk-NUIG3BCV.cjs.map +1 -0
- package/dist/{chunk-EMF62TZG.cjs → chunk-NXQFATMF.cjs} +269 -177
- package/dist/chunk-NXQFATMF.cjs.map +1 -0
- package/dist/{chunk-KBGQIPRQ.js → chunk-PC2UBAUB.js} +20 -3
- package/dist/chunk-PC2UBAUB.js.map +1 -0
- package/dist/chunk-QARBLBXT.cjs +219 -0
- package/dist/chunk-QARBLBXT.cjs.map +1 -0
- package/dist/{chunk-6FR2MMS6.js → chunk-QERAIDRJ.js} +45 -4
- package/dist/chunk-QERAIDRJ.js.map +1 -0
- package/dist/chunk-QSXTWU4U.cjs +12 -0
- package/dist/{chunk-GUR2FNB5.cjs.map → chunk-QSXTWU4U.cjs.map} +1 -1
- package/dist/{chunk-QNKSQTKQ.js → chunk-RCVLFTCT.js} +49 -19
- package/dist/chunk-RCVLFTCT.js.map +1 -0
- package/dist/{chunk-VSPCZAXF.js → chunk-RRSNR3TP.js} +3 -3
- package/dist/{chunk-VSPCZAXF.js.map → chunk-RRSNR3TP.js.map} +1 -1
- package/dist/{chunk-WJT7OU7E.cjs → chunk-TGOMW4MB.cjs} +129 -98
- package/dist/chunk-TGOMW4MB.cjs.map +1 -0
- package/dist/{chunk-KMI7LYAF.js → chunk-TKT2XHED.js} +8 -8
- package/dist/{chunk-KMI7LYAF.js.map → chunk-TKT2XHED.js.map} +1 -1
- package/dist/{chunk-RGPG7EOJ.js → chunk-TPF25IG6.js} +3 -3
- package/dist/{chunk-RGPG7EOJ.js.map → chunk-TPF25IG6.js.map} +1 -1
- package/dist/{chunk-5SEGFTZX.js → chunk-UGZUAYAR.js} +3 -3
- package/dist/{chunk-5SEGFTZX.js.map → chunk-UGZUAYAR.js.map} +1 -1
- package/dist/{chunk-VHMPG6UL.js → chunk-UXLSNRYL.js} +11 -105
- package/dist/chunk-UXLSNRYL.js.map +1 -0
- package/dist/{chunk-FRV5Q5IO.js → chunk-UYQMBBWJ.js} +3 -3
- package/dist/{chunk-FRV5Q5IO.js.map → chunk-UYQMBBWJ.js.map} +1 -1
- package/dist/{chunk-UUT7UN2N.cjs → chunk-VGDDG3XJ.cjs} +7 -7
- package/dist/{chunk-UUT7UN2N.cjs.map → chunk-VGDDG3XJ.cjs.map} +1 -1
- package/dist/{chunk-CZQ3FO2Q.js → chunk-VKGKDOKR.js} +56 -21
- package/dist/chunk-VKGKDOKR.js.map +1 -0
- package/dist/{chunk-CTTSDJLY.cjs → chunk-VL2V6PEN.cjs} +11 -11
- package/dist/{chunk-CTTSDJLY.cjs.map → chunk-VL2V6PEN.cjs.map} +1 -1
- package/dist/{chunk-XOX22WHL.cjs → chunk-WOJMKB3N.cjs} +125 -90
- package/dist/chunk-WOJMKB3N.cjs.map +1 -0
- package/dist/{chunk-UMDVATGY.cjs → chunk-WWFHO375.cjs} +6 -6
- package/dist/{chunk-UMDVATGY.cjs.map → chunk-WWFHO375.cjs.map} +1 -1
- package/dist/{chunk-I7ZUZKFD.js → chunk-XGPUQ56G.js} +3 -3
- package/dist/{chunk-I7ZUZKFD.js.map → chunk-XGPUQ56G.js.map} +1 -1
- package/dist/{chunk-D7ZEOS56.cjs → chunk-XGU7DZDA.cjs} +74 -14
- package/dist/chunk-XGU7DZDA.cjs.map +1 -0
- package/dist/{chunk-S55OV6PW.cjs → chunk-XPCZADMT.cjs} +54 -11
- package/dist/chunk-XPCZADMT.cjs.map +1 -0
- package/dist/{chunk-T2WUSPDA.js → chunk-XWV4JT34.js} +3 -3
- package/dist/{chunk-T2WUSPDA.js.map → chunk-XWV4JT34.js.map} +1 -1
- package/dist/chunk-YTSN73ND.js +212 -0
- package/dist/chunk-YTSN73ND.js.map +1 -0
- package/dist/{ddl-CZz7a0E8.d.cts → ddl-BD-ZfKeX.d.cts} +3 -3
- package/dist/{ddl-C2rZ-Aen.d.ts → ddl-CS0KUVwB.d.ts} +3 -3
- package/dist/{extension-types-ixRpJVUp.d.cts → extension-types-BM2ACfYO.d.cts} +6 -1
- package/dist/{extension-types-ixRpJVUp.d.ts → extension-types-BM2ACfYO.d.ts} +6 -1
- package/dist/{fulltext-strategy-CDkSSYhq.d.cts → fulltext-strategy-C27vXaeB.d.cts} +127 -8
- package/dist/{fulltext-strategy-B57yvC5Q.d.ts → fulltext-strategy-DebsMrqg.d.ts} +127 -8
- package/dist/graph-extension/index.cjs +19 -19
- package/dist/graph-extension/index.d.cts +4 -4
- package/dist/graph-extension/index.d.ts +4 -4
- package/dist/graph-extension/index.js +4 -4
- package/dist/graph-merge/index.cjs +88 -88
- 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 +19 -19
- package/dist/graph-merge/index.js.map +1 -1
- package/dist/{index-Bks_3HHK.d.cts → index-BPM59vsg.d.cts} +119 -7
- package/dist/{index-6CSUAq-x.d.ts → index-BeacbPoe.d.ts} +119 -7
- package/dist/index.cjs +230 -185
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +53 -40
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +30 -21
- package/dist/indexes/index.d.cts +5 -5
- package/dist/indexes/index.d.ts +5 -5
- package/dist/indexes/index.js +8 -7
- package/dist/interchange/index.cjs +208 -30
- package/dist/interchange/index.cjs.map +1 -1
- package/dist/interchange/index.d.cts +25 -8
- package/dist/interchange/index.d.ts +25 -8
- package/dist/interchange/index.js +191 -11
- package/dist/interchange/index.js.map +1 -1
- package/dist/{manager-DwQi8eV0.d.cts → manager-D00_NXvT.d.ts} +11 -2
- package/dist/{manager-ejUCB52T.d.ts → manager-nU1vTJLy.d.cts} +11 -2
- package/dist/{materialize-indexes-B4e9360H.d.cts → materialize-indexes-CuR3gAZb.d.cts} +8 -2
- package/dist/{materialize-indexes-te9TPMMJ.d.ts → materialize-indexes-zK2J_flP.d.ts} +8 -2
- package/dist/{postgres-DQ5R6rzV.d.ts → postgres-IaBA4RgE.d.ts} +1 -1
- package/dist/{postgres-CfEqsRMp.d.cts → postgres-YrYmPlaU.d.cts} +1 -1
- package/dist/profiler/index.cjs +3 -3
- package/dist/profiler/index.d.cts +7 -7
- package/dist/profiler/index.d.ts +7 -7
- package/dist/profiler/index.js +2 -2
- package/dist/provenance/index.cjs +32 -33
- package/dist/provenance/index.cjs.map +1 -1
- package/dist/provenance/index.d.cts +5 -5
- package/dist/provenance/index.d.ts +5 -5
- package/dist/provenance/index.js +5 -6
- package/dist/provenance/index.js.map +1 -1
- package/dist/schema/index.cjs +35 -35
- package/dist/schema/index.d.cts +7 -7
- package/dist/schema/index.d.ts +7 -7
- package/dist/schema/index.js +11 -11
- package/dist/{sqlite-DvQndLky.d.ts → sqlite-BUOHPx7p.d.ts} +1 -1
- package/dist/{sqlite-D7zBinNR.d.cts → sqlite-Pp8O19WE.d.cts} +1 -1
- package/dist/{store-view-CKbHFRnn.d.ts → store-view-ANL6mTph.d.ts} +457 -57
- package/dist/{store-view-BSpqvAxK.d.cts → store-view-X96Rd00T.d.cts} +457 -57
- package/dist/{types-Bv9DcS_E.d.cts → types-r-Zyq2Hz.d.cts} +2 -2
- package/dist/{types-CoxuV7EJ.d.ts → types-wsvuBgPK.d.ts} +2 -2
- package/dist/where-CJOpJj3a.d.ts +36 -0
- package/dist/where-K3uBP33l.d.cts +36 -0
- package/package.json +1 -1
- package/dist/chunk-3TWF3SH4.js.map +0 -1
- package/dist/chunk-4TOD4LBZ.cjs.map +0 -1
- package/dist/chunk-6FR2MMS6.js.map +0 -1
- package/dist/chunk-CK5BVQOW.cjs.map +0 -1
- package/dist/chunk-CZQ3FO2Q.js.map +0 -1
- package/dist/chunk-D7ZEOS56.cjs.map +0 -1
- package/dist/chunk-EM3CWPND.cjs.map +0 -1
- package/dist/chunk-EMF62TZG.cjs.map +0 -1
- package/dist/chunk-EOLERH7Y.cjs +0 -40
- package/dist/chunk-EOLERH7Y.cjs.map +0 -1
- package/dist/chunk-FN35DLCN.cjs.map +0 -1
- package/dist/chunk-FPIZFYHE.js.map +0 -1
- package/dist/chunk-GUR2FNB5.cjs +0 -12
- package/dist/chunk-H7YNSMA7.cjs.map +0 -1
- package/dist/chunk-J7WFGBJR.cjs.map +0 -1
- package/dist/chunk-JBTOYDMN.js.map +0 -1
- package/dist/chunk-K3PPLHY7.js.map +0 -1
- package/dist/chunk-KBGQIPRQ.js.map +0 -1
- package/dist/chunk-LGEALRC6.cjs.map +0 -1
- package/dist/chunk-MP2JQKSG.js.map +0 -1
- package/dist/chunk-O7UN7OXA.cjs.map +0 -1
- package/dist/chunk-QNKSQTKQ.js.map +0 -1
- package/dist/chunk-QWEUYILR.js.map +0 -1
- package/dist/chunk-RGP33ZJ5.js.map +0 -1
- package/dist/chunk-S55OV6PW.cjs.map +0 -1
- package/dist/chunk-UES55P7G.js.map +0 -1
- package/dist/chunk-UT3S4SEN.js +0 -31
- package/dist/chunk-UT3S4SEN.js.map +0 -1
- package/dist/chunk-VHMPG6UL.js.map +0 -1
- package/dist/chunk-VPYHY3LJ.cjs.map +0 -1
- package/dist/chunk-WDBCBWC4.js.map +0 -1
- package/dist/chunk-WJT7OU7E.cjs.map +0 -1
- package/dist/chunk-XOX22WHL.cjs.map +0 -1
- package/dist/where-7RKFOsXt.d.ts +0 -11
- package/dist/where-DdMIXOtH.d.cts +0 -11
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunk3C2RYI6L_cjs = require('./chunk-3C2RYI6L.cjs');
|
|
4
|
+
var chunkXPCZADMT_cjs = require('./chunk-XPCZADMT.cjs');
|
|
5
|
+
var chunkVL2V6PEN_cjs = require('./chunk-VL2V6PEN.cjs');
|
|
6
6
|
var chunkACSVZPK7_cjs = require('./chunk-ACSVZPK7.cjs');
|
|
7
|
+
var chunkQARBLBXT_cjs = require('./chunk-QARBLBXT.cjs');
|
|
7
8
|
var chunkTEDRJXOG_cjs = require('./chunk-TEDRJXOG.cjs');
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
9
|
+
var chunkXGU7DZDA_cjs = require('./chunk-XGU7DZDA.cjs');
|
|
10
|
+
var chunkIPSVVTWT_cjs = require('./chunk-IPSVVTWT.cjs');
|
|
11
|
+
var chunk3GH67G4Z_cjs = require('./chunk-3GH67G4Z.cjs');
|
|
11
12
|
var chunk7YSP4V4R_cjs = require('./chunk-7YSP4V4R.cjs');
|
|
12
|
-
var
|
|
13
|
+
var chunkBVRDGYXQ_cjs = require('./chunk-BVRDGYXQ.cjs');
|
|
13
14
|
var drizzleOrm = require('drizzle-orm');
|
|
14
15
|
var pgCore = require('drizzle-orm/pg-core');
|
|
15
16
|
var sqliteCore = require('drizzle-orm/sqlite-core');
|
|
@@ -40,6 +41,7 @@ var DEFAULT_TABLE_NAMES = {
|
|
|
40
41
|
function createPostgresTables(names = {}, options = {}) {
|
|
41
42
|
const n = { ...DEFAULT_TABLE_NAMES, ...names };
|
|
42
43
|
const indexes = options.indexes ?? [];
|
|
44
|
+
chunkQARBLBXT_cjs.assertNoSystemIndexNameCollision(indexes, n);
|
|
43
45
|
const nodes2 = pgCore.pgTable(
|
|
44
46
|
n.nodes,
|
|
45
47
|
{
|
|
@@ -56,16 +58,10 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
56
58
|
},
|
|
57
59
|
(t) => [
|
|
58
60
|
pgCore.primaryKey({ columns: [t.graphId, t.kind, t.id] }),
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
t.deletedAt,
|
|
64
|
-
t.createdAt
|
|
65
|
-
),
|
|
66
|
-
pgCore.index(`${n.nodes}_deleted_idx`).on(t.graphId, t.deletedAt),
|
|
67
|
-
pgCore.index(`${n.nodes}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),
|
|
68
|
-
...chunkS55OV6PW_cjs.buildPostgresNodeIndexBuilders(t, indexes)
|
|
61
|
+
// System indexes come from SYSTEM_INDEX_DECLARATIONS (single source
|
|
62
|
+
// for both dialects + the runtime materializer).
|
|
63
|
+
...chunkXPCZADMT_cjs.buildPostgresSystemIndexBuilders("nodes", n.nodes, t),
|
|
64
|
+
...chunkXPCZADMT_cjs.buildPostgresNodeIndexBuilders(t, indexes)
|
|
69
65
|
]
|
|
70
66
|
);
|
|
71
67
|
const edges2 = pgCore.pgTable(
|
|
@@ -87,56 +83,8 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
87
83
|
},
|
|
88
84
|
(t) => [
|
|
89
85
|
pgCore.primaryKey({ columns: [t.graphId, t.id] }),
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// and extra filtering by edge kind / target kind. Includes every
|
|
93
|
-
// system column the compiled query's soft-delete/temporal-validity
|
|
94
|
-
// predicate touches (deleted_at, valid_from, valid_to), trailed by
|
|
95
|
-
// to_id — the compiled traversal join reads `n.id = e.to_id` for an
|
|
96
|
-
// outgoing traversal (standard-builders.ts), so without to_id here
|
|
97
|
-
// the join still fetches the edge's heap row for that one column
|
|
98
|
-
// even with the seek/predicate columns covered.
|
|
99
|
-
pgCore.index(`${n.edges}_from_idx`).on(
|
|
100
|
-
t.graphId,
|
|
101
|
-
t.fromKind,
|
|
102
|
-
t.fromId,
|
|
103
|
-
t.kind,
|
|
104
|
-
t.toKind,
|
|
105
|
-
t.deletedAt,
|
|
106
|
-
t.validFrom,
|
|
107
|
-
t.validTo,
|
|
108
|
-
t.toId
|
|
109
|
-
),
|
|
110
|
-
// Directional traversal index (incoming): mirrors from_idx for
|
|
111
|
-
// reverse traversals, trailed by from_id for the same reason
|
|
112
|
-
// (`n.id = e.from_id` for an incoming traversal).
|
|
113
|
-
pgCore.index(`${n.edges}_to_idx`).on(
|
|
114
|
-
t.graphId,
|
|
115
|
-
t.toKind,
|
|
116
|
-
t.toId,
|
|
117
|
-
t.kind,
|
|
118
|
-
t.fromKind,
|
|
119
|
-
t.deletedAt,
|
|
120
|
-
t.validFrom,
|
|
121
|
-
t.validTo,
|
|
122
|
-
t.fromId
|
|
123
|
-
),
|
|
124
|
-
pgCore.index(`${n.edges}_kind_created_idx`).on(
|
|
125
|
-
t.graphId,
|
|
126
|
-
t.kind,
|
|
127
|
-
t.deletedAt,
|
|
128
|
-
t.createdAt
|
|
129
|
-
),
|
|
130
|
-
pgCore.index(`${n.edges}_deleted_idx`).on(t.graphId, t.deletedAt),
|
|
131
|
-
pgCore.index(`${n.edges}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),
|
|
132
|
-
pgCore.index(`${n.edges}_cardinality_idx`).on(
|
|
133
|
-
t.graphId,
|
|
134
|
-
t.kind,
|
|
135
|
-
t.fromKind,
|
|
136
|
-
t.fromId,
|
|
137
|
-
t.validTo
|
|
138
|
-
),
|
|
139
|
-
...chunkS55OV6PW_cjs.buildPostgresEdgeIndexBuilders(t, indexes)
|
|
86
|
+
...chunkXPCZADMT_cjs.buildPostgresSystemIndexBuilders("edges", n.edges, t),
|
|
87
|
+
...chunkXPCZADMT_cjs.buildPostgresEdgeIndexBuilders(t, indexes)
|
|
140
88
|
]
|
|
141
89
|
);
|
|
142
90
|
const recordedNodes2 = pgCore.pgTable(
|
|
@@ -162,19 +110,7 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
162
110
|
},
|
|
163
111
|
(t) => [
|
|
164
112
|
pgCore.primaryKey({ columns: [t.historyId] }),
|
|
165
|
-
|
|
166
|
-
t.graphId,
|
|
167
|
-
t.kind,
|
|
168
|
-
t.id,
|
|
169
|
-
t.recordedFrom,
|
|
170
|
-
t.recordedTo
|
|
171
|
-
),
|
|
172
|
-
pgCore.index(`${n.recordedNodes}_open_idx`).on(t.graphId, t.recordedTo),
|
|
173
|
-
pgCore.index(`${n.recordedNodes}_valid_idx`).on(
|
|
174
|
-
t.graphId,
|
|
175
|
-
t.validFrom,
|
|
176
|
-
t.validTo
|
|
177
|
-
)
|
|
113
|
+
...chunkXPCZADMT_cjs.buildPostgresSystemIndexBuilders("recordedNodes", n.recordedNodes, t)
|
|
178
114
|
]
|
|
179
115
|
);
|
|
180
116
|
const recordedEdges2 = pgCore.pgTable(
|
|
@@ -203,37 +139,7 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
203
139
|
},
|
|
204
140
|
(t) => [
|
|
205
141
|
pgCore.primaryKey({ columns: [t.historyId] }),
|
|
206
|
-
|
|
207
|
-
t.graphId,
|
|
208
|
-
t.kind,
|
|
209
|
-
t.id,
|
|
210
|
-
t.recordedFrom,
|
|
211
|
-
t.recordedTo
|
|
212
|
-
),
|
|
213
|
-
pgCore.index(`${n.recordedEdges}_open_idx`).on(t.graphId, t.recordedTo),
|
|
214
|
-
pgCore.index(`${n.recordedEdges}_from_idx`).on(
|
|
215
|
-
t.graphId,
|
|
216
|
-
t.fromKind,
|
|
217
|
-
t.fromId,
|
|
218
|
-
t.kind,
|
|
219
|
-
t.toKind,
|
|
220
|
-
t.recordedFrom,
|
|
221
|
-
t.recordedTo
|
|
222
|
-
),
|
|
223
|
-
pgCore.index(`${n.recordedEdges}_to_idx`).on(
|
|
224
|
-
t.graphId,
|
|
225
|
-
t.toKind,
|
|
226
|
-
t.toId,
|
|
227
|
-
t.kind,
|
|
228
|
-
t.fromKind,
|
|
229
|
-
t.recordedFrom,
|
|
230
|
-
t.recordedTo
|
|
231
|
-
),
|
|
232
|
-
pgCore.index(`${n.recordedEdges}_valid_idx`).on(
|
|
233
|
-
t.graphId,
|
|
234
|
-
t.validFrom,
|
|
235
|
-
t.validTo
|
|
236
|
-
)
|
|
142
|
+
...chunkXPCZADMT_cjs.buildPostgresSystemIndexBuilders("recordedEdges", n.recordedEdges, t)
|
|
237
143
|
]
|
|
238
144
|
);
|
|
239
145
|
const recordedClock2 = pgCore.pgTable(
|
|
@@ -462,9 +368,9 @@ function renderIndexColumn(col) {
|
|
|
462
368
|
if (col && typeof col === "object" && "name" in col) {
|
|
463
369
|
return `"${col.name}"`;
|
|
464
370
|
}
|
|
465
|
-
const
|
|
466
|
-
if (
|
|
467
|
-
return
|
|
371
|
+
const sql15 = tryInlineSql(col);
|
|
372
|
+
if (sql15 !== void 0) {
|
|
373
|
+
return sql15;
|
|
468
374
|
}
|
|
469
375
|
return "unknown";
|
|
470
376
|
}
|
|
@@ -540,13 +446,13 @@ function isSqliteTable(value) {
|
|
|
540
446
|
function runtimeStrategyContributions(fulltextStrategy, fulltextTableName) {
|
|
541
447
|
return fulltextStrategy.ownedTables(fulltextTableName).filter((contribution) => contribution.runtimeEnsure);
|
|
542
448
|
}
|
|
543
|
-
function sqliteContributions(tables3 =
|
|
449
|
+
function sqliteContributions(tables3 = chunk3C2RYI6L_cjs.tables, fulltextStrategy = chunkXGU7DZDA_cjs.fts5Strategy) {
|
|
544
450
|
const contributions = [];
|
|
545
451
|
for (const [key, table] of Object.entries(tables3)) {
|
|
546
452
|
if (!isSqliteTable(table)) continue;
|
|
547
453
|
contributions.push({
|
|
548
454
|
logicalName: key,
|
|
549
|
-
owner:
|
|
455
|
+
owner: chunkXGU7DZDA_cjs.BASE_CONTRIBUTION_OWNER,
|
|
550
456
|
tableName: sqliteCore.getTableConfig(table).name,
|
|
551
457
|
createDdl: [
|
|
552
458
|
generateSqliteCreateTableSQL(table),
|
|
@@ -562,12 +468,12 @@ function sqliteContributions(tables3 = chunkFN35DLCN_cjs.tables, fulltextStrateg
|
|
|
562
468
|
}
|
|
563
469
|
return contributions;
|
|
564
470
|
}
|
|
565
|
-
function generateSqliteDDL(tables3 =
|
|
471
|
+
function generateSqliteDDL(tables3 = chunk3C2RYI6L_cjs.tables, fulltextStrategy = chunkXGU7DZDA_cjs.fts5Strategy) {
|
|
566
472
|
return sqliteContributions(tables3, fulltextStrategy).flatMap(
|
|
567
473
|
(contribution) => [...contribution.createDdl]
|
|
568
474
|
);
|
|
569
475
|
}
|
|
570
|
-
function generateSqliteMigrationSQL(tables3 =
|
|
476
|
+
function generateSqliteMigrationSQL(tables3 = chunk3C2RYI6L_cjs.tables, fulltextStrategy = chunkXGU7DZDA_cjs.fts5Strategy) {
|
|
571
477
|
return generateSqliteDDL(tables3, fulltextStrategy).join("\n\n");
|
|
572
478
|
}
|
|
573
479
|
function getPgColumnType(column) {
|
|
@@ -649,14 +555,14 @@ function generatePgCreateIndexSQL(table) {
|
|
|
649
555
|
function isPgTable(value) {
|
|
650
556
|
return drizzleOrm.is(value, pgCore.PgTable);
|
|
651
557
|
}
|
|
652
|
-
function postgresContributions(tables3 = tables2, fulltextStrategy =
|
|
558
|
+
function postgresContributions(tables3 = tables2, fulltextStrategy = chunkXGU7DZDA_cjs.tsvectorStrategy) {
|
|
653
559
|
const contributions = [];
|
|
654
560
|
for (const [key, table] of Object.entries(tables3)) {
|
|
655
561
|
if (!isPgTable(table)) continue;
|
|
656
562
|
if (table === tables3.fulltext) continue;
|
|
657
563
|
contributions.push({
|
|
658
564
|
logicalName: key,
|
|
659
|
-
owner:
|
|
565
|
+
owner: chunkXGU7DZDA_cjs.BASE_CONTRIBUTION_OWNER,
|
|
660
566
|
tableName: pgCore.getTableConfig(table).name,
|
|
661
567
|
createDdl: [
|
|
662
568
|
generatePgCreateTableSQL(table),
|
|
@@ -672,12 +578,12 @@ function postgresContributions(tables3 = tables2, fulltextStrategy = chunkD7ZEOS
|
|
|
672
578
|
}
|
|
673
579
|
return contributions;
|
|
674
580
|
}
|
|
675
|
-
function generatePostgresDDL(tables3 = tables2, fulltextStrategy =
|
|
581
|
+
function generatePostgresDDL(tables3 = tables2, fulltextStrategy = chunkXGU7DZDA_cjs.tsvectorStrategy) {
|
|
676
582
|
return postgresContributions(tables3, fulltextStrategy).flatMap(
|
|
677
583
|
(contribution) => [...contribution.createDdl]
|
|
678
584
|
);
|
|
679
585
|
}
|
|
680
|
-
function generatePostgresMigrationSQL(tables3 = tables2, fulltextStrategy =
|
|
586
|
+
function generatePostgresMigrationSQL(tables3 = tables2, fulltextStrategy = chunkXGU7DZDA_cjs.tsvectorStrategy) {
|
|
681
587
|
const extensionSql = "-- Enable pgvector extension for vector similarity search\nCREATE EXTENSION IF NOT EXISTS vector;";
|
|
682
588
|
const ddlSql = generatePostgresDDL(tables3, fulltextStrategy).join("\n\n");
|
|
683
589
|
return `${extensionSql}
|
|
@@ -686,39 +592,6 @@ ${ddlSql}`;
|
|
|
686
592
|
}
|
|
687
593
|
|
|
688
594
|
// src/backend/drizzle/vector-runtime.ts
|
|
689
|
-
function vectorSlotKey(slot) {
|
|
690
|
-
return JSON.stringify([
|
|
691
|
-
slot.graphId,
|
|
692
|
-
slot.nodeKind,
|
|
693
|
-
slot.fieldPath,
|
|
694
|
-
slot.dimensions,
|
|
695
|
-
slot.metric,
|
|
696
|
-
slot.indexType
|
|
697
|
-
]);
|
|
698
|
-
}
|
|
699
|
-
function createVectorSlotLatch() {
|
|
700
|
-
const inFlight = /* @__PURE__ */ new Map();
|
|
701
|
-
return {
|
|
702
|
-
ensure(strategy, slot, execDdl) {
|
|
703
|
-
const key = vectorSlotKey(slot);
|
|
704
|
-
const existing = inFlight.get(key);
|
|
705
|
-
if (existing !== void 0) return existing;
|
|
706
|
-
const run = (async () => {
|
|
707
|
-
for (const contribution of strategy.ownedTables(slot)) {
|
|
708
|
-
for (const statement of contribution.createDdl) {
|
|
709
|
-
await execDdl(statement);
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
})();
|
|
713
|
-
const cached = run.catch((error) => {
|
|
714
|
-
inFlight.delete(key);
|
|
715
|
-
throw error;
|
|
716
|
-
});
|
|
717
|
-
inFlight.set(key, cached);
|
|
718
|
-
return cached;
|
|
719
|
-
}
|
|
720
|
-
};
|
|
721
|
-
}
|
|
722
595
|
var VECTOR_SLOT_PLACEHOLDER_DIMENSIONS = 1;
|
|
723
596
|
var EMBEDDING_UPSERT_PARAM_COUNT = 5;
|
|
724
597
|
function vectorSlotFromParams(params) {
|
|
@@ -748,10 +621,10 @@ function vectorSlotFromDropIndexParams(params) {
|
|
|
748
621
|
};
|
|
749
622
|
}
|
|
750
623
|
function mapVectorWriteError(error, params) {
|
|
751
|
-
const mismatch =
|
|
624
|
+
const mismatch = chunk3GH67G4Z_cjs.parseDimensionMismatch(error);
|
|
752
625
|
if (mismatch === void 0) return error;
|
|
753
626
|
const attempted = mismatch.actual ?? "a different number of";
|
|
754
|
-
return new
|
|
627
|
+
return new chunkBVRDGYXQ_cjs.EmbeddingDimensionChangedError(
|
|
755
628
|
`Embedding "${params.nodeKind}.${params.fieldPath}" was written with ${attempted} dimensions, but its per-field storage expects ${mismatch.expected}. The field's embedding dimension changed; existing vectors must be recreated and re-embedded.`,
|
|
756
629
|
{
|
|
757
630
|
kind: params.nodeKind,
|
|
@@ -767,7 +640,7 @@ var SQLITE_CONTRIBUTION_MAT_TIMESTAMPS = {
|
|
|
767
640
|
encode: (value) => value
|
|
768
641
|
};
|
|
769
642
|
var POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS = {
|
|
770
|
-
decode:
|
|
643
|
+
decode: chunkVL2V6PEN_cjs.formatPostgresTimestamp,
|
|
771
644
|
encode: (value) => new Date(value)
|
|
772
645
|
};
|
|
773
646
|
function mapContributionMaterializationRow(row, decode) {
|
|
@@ -809,7 +682,7 @@ function buildContributionOnConflictSet(materializedAtColumn, paramsMaterialized
|
|
|
809
682
|
lastError: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("last_error")}`
|
|
810
683
|
};
|
|
811
684
|
}
|
|
812
|
-
|
|
685
|
+
function contributionSignatureInput(dialect, identity, createDdl) {
|
|
813
686
|
const hashable = {
|
|
814
687
|
dialect,
|
|
815
688
|
owner: identity.owner,
|
|
@@ -817,7 +690,7 @@ async function computeContributionSignature(dialect, identity, createDdl) {
|
|
|
817
690
|
tableName: identity.tableName,
|
|
818
691
|
createDdl
|
|
819
692
|
};
|
|
820
|
-
return
|
|
693
|
+
return JSON.stringify(hashable, chunkACSVZPK7_cjs.sortedReplacer);
|
|
821
694
|
}
|
|
822
695
|
function evaluateContributionState(row, signature) {
|
|
823
696
|
if (row === void 0) return "missing";
|
|
@@ -881,43 +754,82 @@ function gateFulltextMethods(source, assert) {
|
|
|
881
754
|
return gated;
|
|
882
755
|
}
|
|
883
756
|
function gateFulltext(tx, assert) {
|
|
884
|
-
return
|
|
757
|
+
return chunkIPSVVTWT_cjs.createBackendOverlay(
|
|
885
758
|
tx,
|
|
886
759
|
gateFulltextMethods(tx, assert)
|
|
887
760
|
);
|
|
888
761
|
}
|
|
762
|
+
var CONTRIBUTION_KEY_SEPARATOR = String.fromCodePoint(0);
|
|
763
|
+
function contributionKey(graphId, contribution) {
|
|
764
|
+
return [
|
|
765
|
+
graphId,
|
|
766
|
+
contribution.owner,
|
|
767
|
+
contribution.logicalName,
|
|
768
|
+
contribution.tableName
|
|
769
|
+
].join(CONTRIBUTION_KEY_SEPARATOR);
|
|
770
|
+
}
|
|
889
771
|
function createContributionMaterializer(deps) {
|
|
890
772
|
const { dialect, fulltextStrategy, fulltextTableName } = deps;
|
|
891
|
-
const
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
const
|
|
773
|
+
const initializedSignatures = /* @__PURE__ */ new Map();
|
|
774
|
+
const computedSignatures = /* @__PURE__ */ new Map();
|
|
775
|
+
async function resolveContributionSignature(key, contribution) {
|
|
776
|
+
const cached = computedSignatures.get(key);
|
|
777
|
+
const cachedCreateDdl = cached?.createDdl;
|
|
778
|
+
const cachedSignature = cached?.signature;
|
|
779
|
+
if (cachedCreateDdl?.length === contribution.createDdl.length && cachedSignature !== void 0 && contribution.createDdl.every(
|
|
780
|
+
(statement, index2) => cachedCreateDdl[index2] === statement
|
|
781
|
+
)) {
|
|
782
|
+
return cachedSignature;
|
|
783
|
+
}
|
|
784
|
+
const input = contributionSignatureInput(
|
|
897
785
|
dialect,
|
|
898
786
|
contribution,
|
|
899
787
|
contribution.createDdl
|
|
900
788
|
);
|
|
789
|
+
const entry = {
|
|
790
|
+
createDdl: [...contribution.createDdl],
|
|
791
|
+
signature: chunkTEDRJXOG_cjs.sha256Hex(input, 16)
|
|
792
|
+
};
|
|
793
|
+
computedSignatures.set(key, entry);
|
|
794
|
+
try {
|
|
795
|
+
return await entry.signature;
|
|
796
|
+
} catch (error) {
|
|
797
|
+
if (computedSignatures.get(key) === entry) {
|
|
798
|
+
computedSignatures.delete(key);
|
|
799
|
+
}
|
|
800
|
+
throw error;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
function runtimeContributions() {
|
|
804
|
+
return runtimeStrategyContributions(fulltextStrategy, fulltextTableName);
|
|
805
|
+
}
|
|
806
|
+
async function materializeOne(graphId, contribution, signature, existing, options) {
|
|
807
|
+
const force = options?.force === true;
|
|
901
808
|
const identity = identityOf(graphId, contribution);
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
return;
|
|
809
|
+
if (!force && evaluateContributionState(existing, signature) === "initialized") {
|
|
810
|
+
return "materialized";
|
|
905
811
|
}
|
|
906
812
|
const priorSuccess = existing?.materializedAt !== void 0;
|
|
907
|
-
if (priorSuccess && existing.signature !== signature) {
|
|
813
|
+
if (!force && priorSuccess && existing.signature !== signature) {
|
|
814
|
+
if (options?.onDrift === "skip") {
|
|
815
|
+
console.warn(
|
|
816
|
+
`[typegraph] contribution "${contribution.logicalName}" (table "${contribution.tableName}") is provisioned at a different shape than the current declaration \u2014 left untouched. Writes to it will fail until store.reembedVectorField(kind, fieldPath) recreates the storage at the new shape.`
|
|
817
|
+
);
|
|
818
|
+
return "drift-skipped";
|
|
819
|
+
}
|
|
908
820
|
const error = new Error(
|
|
909
821
|
`Contribution "${contribution.logicalName}" (owner "${contribution.owner}", table "${contribution.tableName}") was already materialized with a different signature. The recorded physical shape is stale relative to the current strategy/DDL \u2014 migrate or drop the table and retry, or restore the original strategy.`
|
|
910
822
|
);
|
|
911
823
|
await deps.recordMarker({
|
|
912
824
|
...identity,
|
|
913
825
|
signature,
|
|
914
|
-
attemptedAt:
|
|
826
|
+
attemptedAt: chunkVL2V6PEN_cjs.nowIso(),
|
|
915
827
|
materializedAt: void 0,
|
|
916
828
|
error: error.message
|
|
917
829
|
});
|
|
918
830
|
throw error;
|
|
919
831
|
}
|
|
920
|
-
const attemptedAt =
|
|
832
|
+
const attemptedAt = chunkVL2V6PEN_cjs.nowIso();
|
|
921
833
|
try {
|
|
922
834
|
for (const statement of contribution.createDdl) {
|
|
923
835
|
await deps.execDdl(statement);
|
|
@@ -939,71 +851,166 @@ function createContributionMaterializer(deps) {
|
|
|
939
851
|
materializedAt: attemptedAt,
|
|
940
852
|
error: void 0
|
|
941
853
|
});
|
|
854
|
+
return "materialized";
|
|
942
855
|
}
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
contribution,
|
|
947
|
-
contribution.createDdl
|
|
856
|
+
function indexMarkerRows(graphId, rows) {
|
|
857
|
+
return new Map(
|
|
858
|
+
rows.map((row) => [contributionKey(graphId, row), row])
|
|
948
859
|
);
|
|
949
|
-
|
|
860
|
+
}
|
|
861
|
+
async function readMarkerRows(graphId) {
|
|
950
862
|
try {
|
|
951
|
-
const existing = await deps.getMarker(identity);
|
|
952
863
|
return {
|
|
953
|
-
kind: "
|
|
954
|
-
|
|
864
|
+
kind: "rows",
|
|
865
|
+
rows: indexMarkerRows(graphId, await deps.getMarkers(graphId))
|
|
955
866
|
};
|
|
956
867
|
} catch (error) {
|
|
957
|
-
if (!
|
|
868
|
+
if (!chunk3GH67G4Z_cjs.isMissingTableError(error)) throw error;
|
|
958
869
|
return { kind: "missing-table", error };
|
|
959
870
|
}
|
|
960
871
|
}
|
|
961
|
-
async function
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
872
|
+
async function ensureContributions(graphId, contributions, options) {
|
|
873
|
+
const force = options?.force === true;
|
|
874
|
+
const entries = await Promise.all(
|
|
875
|
+
contributions.map(async (contribution) => {
|
|
876
|
+
const key = contributionKey(graphId, contribution);
|
|
877
|
+
return {
|
|
878
|
+
contribution,
|
|
879
|
+
key,
|
|
880
|
+
signature: await resolveContributionSignature(key, contribution)
|
|
881
|
+
};
|
|
882
|
+
})
|
|
883
|
+
);
|
|
884
|
+
const pending = force ? entries : entries.filter(
|
|
885
|
+
(entry) => initializedSignatures.get(entry.key) !== entry.signature
|
|
886
|
+
);
|
|
887
|
+
if (pending.length === 0) return;
|
|
888
|
+
const initialRead = force ? void 0 : await readMarkerRows(graphId);
|
|
889
|
+
if (!force && initialRead?.kind === "rows" && pending.every(
|
|
890
|
+
(entry) => evaluateContributionState(
|
|
891
|
+
initialRead.rows.get(entry.key),
|
|
892
|
+
entry.signature
|
|
893
|
+
) === "initialized"
|
|
894
|
+
)) {
|
|
895
|
+
for (const entry of pending) {
|
|
896
|
+
initializedSignatures.set(entry.key, entry.signature);
|
|
897
|
+
}
|
|
973
898
|
return;
|
|
974
899
|
}
|
|
975
900
|
await deps.ensureMarkerTable();
|
|
976
|
-
|
|
977
|
-
|
|
901
|
+
const existingRows = indexMarkerRows(
|
|
902
|
+
graphId,
|
|
903
|
+
await deps.getMarkers(graphId)
|
|
904
|
+
);
|
|
905
|
+
for (const entry of pending) {
|
|
906
|
+
const outcome = await materializeOne(
|
|
907
|
+
graphId,
|
|
908
|
+
entry.contribution,
|
|
909
|
+
entry.signature,
|
|
910
|
+
existingRows.get(entry.key),
|
|
911
|
+
{
|
|
912
|
+
force,
|
|
913
|
+
...options?.onDrift === void 0 ? {} : { onDrift: options.onDrift }
|
|
914
|
+
}
|
|
915
|
+
);
|
|
916
|
+
if (outcome === "materialized") {
|
|
917
|
+
initializedSignatures.set(entry.key, entry.signature);
|
|
918
|
+
}
|
|
978
919
|
}
|
|
979
|
-
initializedGraphIds.add(graphId);
|
|
980
920
|
}
|
|
981
|
-
async function
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
}
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
|
|
921
|
+
async function assertContributions(graphId, contributions) {
|
|
922
|
+
const entries = await Promise.all(
|
|
923
|
+
contributions.map(async (contribution) => {
|
|
924
|
+
const key = contributionKey(graphId, contribution);
|
|
925
|
+
return {
|
|
926
|
+
contribution,
|
|
927
|
+
key,
|
|
928
|
+
signature: await resolveContributionSignature(key, contribution)
|
|
929
|
+
};
|
|
930
|
+
})
|
|
931
|
+
);
|
|
932
|
+
const pending = entries.filter(
|
|
933
|
+
(entry) => initializedSignatures.get(entry.key) !== entry.signature
|
|
934
|
+
);
|
|
935
|
+
if (pending.length === 0) return;
|
|
936
|
+
const read = await readMarkerRows(graphId);
|
|
937
|
+
if (read.kind === "missing-table") {
|
|
938
|
+
const first = pending[0];
|
|
939
|
+
if (first === void 0) return;
|
|
940
|
+
throw new chunkBVRDGYXQ_cjs.StoreNotInitializedError(graphId, "missing", {
|
|
941
|
+
cause: read.error,
|
|
942
|
+
details: { logicalName: first.contribution.logicalName }
|
|
943
|
+
});
|
|
944
|
+
}
|
|
945
|
+
for (const entry of pending) {
|
|
946
|
+
const { contribution, key, signature } = entry;
|
|
947
|
+
const state = evaluateContributionState(read.rows.get(key), signature);
|
|
948
|
+
if (state !== "initialized") {
|
|
949
|
+
throw new chunkBVRDGYXQ_cjs.StoreNotInitializedError(graphId, state, {
|
|
993
950
|
details: { logicalName: contribution.logicalName }
|
|
994
951
|
});
|
|
995
952
|
}
|
|
953
|
+
initializedSignatures.set(key, signature);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
async function ensureRuntimeContributions(graphId) {
|
|
957
|
+
await ensureContributions(graphId, runtimeContributions());
|
|
958
|
+
}
|
|
959
|
+
async function assertInitialized(graphId) {
|
|
960
|
+
await assertContributions(graphId, runtimeContributions());
|
|
961
|
+
}
|
|
962
|
+
async function ensureVectorSlot(slot, options) {
|
|
963
|
+
await ensureVectorSlots([slot], options);
|
|
964
|
+
}
|
|
965
|
+
async function assertVectorSlot(slot) {
|
|
966
|
+
await assertVectorSlots([slot]);
|
|
967
|
+
}
|
|
968
|
+
function groupVectorContributions(slots) {
|
|
969
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
970
|
+
if (deps.vectorStrategy === void 0) return grouped;
|
|
971
|
+
for (const slot of slots) {
|
|
972
|
+
grouped.set(slot.graphId, [
|
|
973
|
+
...grouped.get(slot.graphId) ?? [],
|
|
974
|
+
...deps.vectorStrategy.ownedTables(slot)
|
|
975
|
+
]);
|
|
976
|
+
}
|
|
977
|
+
return grouped;
|
|
978
|
+
}
|
|
979
|
+
async function ensureVectorSlots(slots, options) {
|
|
980
|
+
for (const [graphId, contributions] of groupVectorContributions(slots)) {
|
|
981
|
+
await ensureContributions(graphId, contributions, options);
|
|
996
982
|
}
|
|
997
|
-
initializedGraphIds.add(graphId);
|
|
998
983
|
}
|
|
999
|
-
|
|
984
|
+
async function assertVectorSlots(slots) {
|
|
985
|
+
for (const [graphId, contributions] of groupVectorContributions(slots)) {
|
|
986
|
+
await assertContributions(graphId, contributions);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
async function dropVectorSlot(slot) {
|
|
990
|
+
if (deps.vectorStrategy === void 0) return;
|
|
991
|
+
for (const contribution of deps.vectorStrategy.ownedTables(slot)) {
|
|
992
|
+
await deps.deleteMarker(identityOf(slot.graphId, contribution));
|
|
993
|
+
const key = contributionKey(slot.graphId, contribution);
|
|
994
|
+
initializedSignatures.delete(key);
|
|
995
|
+
computedSignatures.delete(key);
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
return {
|
|
999
|
+
ensureRuntimeContributions,
|
|
1000
|
+
assertInitialized,
|
|
1001
|
+
ensureVectorSlot,
|
|
1002
|
+
ensureVectorSlots,
|
|
1003
|
+
assertVectorSlot,
|
|
1004
|
+
assertVectorSlots,
|
|
1005
|
+
dropVectorSlot
|
|
1006
|
+
};
|
|
1000
1007
|
}
|
|
1001
1008
|
var SQLITE_INDEX_MAT_TIMESTAMPS = {
|
|
1002
1009
|
decode: (value) => typeof value === "string" ? value : void 0,
|
|
1003
1010
|
encode: (value) => value
|
|
1004
1011
|
};
|
|
1005
1012
|
var POSTGRES_INDEX_MAT_TIMESTAMPS = {
|
|
1006
|
-
decode:
|
|
1013
|
+
decode: chunkVL2V6PEN_cjs.formatPostgresTimestamp,
|
|
1007
1014
|
encode: (value) => new Date(value)
|
|
1008
1015
|
};
|
|
1009
1016
|
function mapMaterializationRow(row, decode) {
|
|
@@ -1038,15 +1045,20 @@ function buildMaterializationInsertValues(params, encode) {
|
|
|
1038
1045
|
lastError: params.error
|
|
1039
1046
|
};
|
|
1040
1047
|
}
|
|
1041
|
-
function buildMaterializationOnConflictSet(
|
|
1042
|
-
|
|
1048
|
+
function buildMaterializationOnConflictSet(paramsMaterializedAt) {
|
|
1049
|
+
if (paramsMaterializedAt === void 0) {
|
|
1050
|
+
return {
|
|
1051
|
+
lastAttemptedAt: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("last_attempted_at")}`,
|
|
1052
|
+
lastError: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("last_error")}`
|
|
1053
|
+
};
|
|
1054
|
+
}
|
|
1043
1055
|
return {
|
|
1044
1056
|
graphId: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("graph_id")}`,
|
|
1045
1057
|
entity: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("entity")}`,
|
|
1046
1058
|
kind: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("kind")}`,
|
|
1047
1059
|
signature: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("signature")}`,
|
|
1048
1060
|
schemaVersion: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("schema_version")}`,
|
|
1049
|
-
materializedAt:
|
|
1061
|
+
materializedAt: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("materialized_at")}`,
|
|
1050
1062
|
lastAttemptedAt: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("last_attempted_at")}`,
|
|
1051
1063
|
lastError: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("last_error")}`
|
|
1052
1064
|
};
|
|
@@ -1056,7 +1068,7 @@ var SQLITE_KIND_REMOVAL_TIMESTAMPS = {
|
|
|
1056
1068
|
encode: (value) => value
|
|
1057
1069
|
};
|
|
1058
1070
|
var POSTGRES_KIND_REMOVAL_TIMESTAMPS = {
|
|
1059
|
-
decode:
|
|
1071
|
+
decode: chunkVL2V6PEN_cjs.formatPostgresTimestamp,
|
|
1060
1072
|
encode: (value) => new Date(value)
|
|
1061
1073
|
};
|
|
1062
1074
|
function mapKindRemovalRow(row, decode) {
|
|
@@ -1188,12 +1200,12 @@ function present(value) {
|
|
|
1188
1200
|
function mapHybridSearchRow(row, toNodeRow) {
|
|
1189
1201
|
return {
|
|
1190
1202
|
node: toNodeRow(row),
|
|
1191
|
-
fusedScore:
|
|
1203
|
+
fusedScore: chunkVL2V6PEN_cjs.coerceNumericScore(row.fused_score),
|
|
1192
1204
|
...present(row.vector_rank) ? { vectorRank: Number(row.vector_rank) } : {},
|
|
1193
|
-
...present(row.vector_score) ? { vectorScore:
|
|
1205
|
+
...present(row.vector_score) ? { vectorScore: chunkVL2V6PEN_cjs.coerceNumericScore(row.vector_score) } : {},
|
|
1194
1206
|
...present(row.fulltext_rank) ? { fulltextRank: Number(row.fulltext_rank) } : {},
|
|
1195
1207
|
...present(row.fulltext_score) ? {
|
|
1196
|
-
fulltextScore:
|
|
1208
|
+
fulltextScore: chunkVL2V6PEN_cjs.coerceNumericScore(
|
|
1197
1209
|
row.fulltext_score
|
|
1198
1210
|
)
|
|
1199
1211
|
} : {},
|
|
@@ -1447,7 +1459,7 @@ function buildGetEdges(tables3, graphId, ids) {
|
|
|
1447
1459
|
return drizzleOrm.sql`
|
|
1448
1460
|
SELECT * FROM ${edges2}
|
|
1449
1461
|
WHERE ${edges2.graphId} = ${graphId}
|
|
1450
|
-
AND ${edges2.id} IN (${
|
|
1462
|
+
AND ${edges2.id} IN (${chunkIPSVVTWT_cjs.sqlValueList(ids)})
|
|
1451
1463
|
`;
|
|
1452
1464
|
}
|
|
1453
1465
|
function buildUpdateEdge(tables3, params, timestamp2) {
|
|
@@ -1498,7 +1510,7 @@ function buildDeleteEdgesBatch(tables3, params, timestamp2) {
|
|
|
1498
1510
|
UPDATE ${edges2}
|
|
1499
1511
|
SET ${chunk7YSP4V4R_cjs.quotedColumn(edges2.deletedAt)} = ${timestamp2}
|
|
1500
1512
|
WHERE ${edges2.graphId} = ${params.graphId}
|
|
1501
|
-
AND ${edges2.id} IN (${
|
|
1513
|
+
AND ${edges2.id} IN (${chunkIPSVVTWT_cjs.sqlValueList(params.ids)})
|
|
1502
1514
|
AND ${edges2.deletedAt} IS NULL
|
|
1503
1515
|
`;
|
|
1504
1516
|
}
|
|
@@ -1507,7 +1519,7 @@ function buildHardDeleteEdgesBatch(tables3, params) {
|
|
|
1507
1519
|
return drizzleOrm.sql`
|
|
1508
1520
|
DELETE FROM ${edges2}
|
|
1509
1521
|
WHERE ${edges2.graphId} = ${params.graphId}
|
|
1510
|
-
AND ${edges2.id} IN (${
|
|
1522
|
+
AND ${edges2.id} IN (${chunkIPSVVTWT_cjs.sqlValueList(params.ids)})
|
|
1511
1523
|
`;
|
|
1512
1524
|
}
|
|
1513
1525
|
function buildHardDeleteEdge(tables3, params) {
|
|
@@ -1710,7 +1722,7 @@ function buildGetNodes(tables3, graphId, kind, ids) {
|
|
|
1710
1722
|
SELECT * FROM ${nodes2}
|
|
1711
1723
|
WHERE ${nodes2.graphId} = ${graphId}
|
|
1712
1724
|
AND ${nodes2.kind} = ${kind}
|
|
1713
|
-
AND ${nodes2.id} IN (${
|
|
1725
|
+
AND ${nodes2.id} IN (${chunkIPSVVTWT_cjs.sqlValueList(ids)})
|
|
1714
1726
|
`;
|
|
1715
1727
|
}
|
|
1716
1728
|
function buildUpdateNode(tables3, params, timestamp2) {
|
|
@@ -2081,15 +2093,15 @@ function createCommonOperationStrategy(tables3, dialect, fulltextStrategy) {
|
|
|
2081
2093
|
dialect,
|
|
2082
2094
|
// Store-compiled candidates (predicates + subclass + currency)
|
|
2083
2095
|
// take precedence; the live-node default covers direct backend use.
|
|
2084
|
-
params.candidates ?? chunk7YSP4V4R_cjs.liveNodeIdsSubquery(tables3.nodes, params.graphId, params.nodeKind,
|
|
2096
|
+
params.candidates ?? chunk7YSP4V4R_cjs.liveNodeIdsSubquery(tables3.nodes, params.graphId, params.nodeKind, chunkVL2V6PEN_cjs.nowIso())
|
|
2085
2097
|
),
|
|
2086
|
-
buildLiveNodeIds: (graphId, nodeKind) => chunk7YSP4V4R_cjs.liveNodeIdsSubquery(tables3.nodes, graphId, nodeKind,
|
|
2098
|
+
buildLiveNodeIds: (graphId, nodeKind) => chunk7YSP4V4R_cjs.liveNodeIdsSubquery(tables3.nodes, graphId, nodeKind, chunkVL2V6PEN_cjs.nowIso()),
|
|
2087
2099
|
buildHybridSearch: (params, vectorSql, vectorScoreDescending) => {
|
|
2088
2100
|
const candidates = params.candidates ?? chunk7YSP4V4R_cjs.liveNodeIdsSubquery(
|
|
2089
2101
|
tables3.nodes,
|
|
2090
2102
|
params.graphId,
|
|
2091
2103
|
params.nodeKind,
|
|
2092
|
-
|
|
2104
|
+
chunkVL2V6PEN_cjs.nowIso()
|
|
2093
2105
|
);
|
|
2094
2106
|
const fulltextSql = buildFulltextSearch(
|
|
2095
2107
|
fulltextTable,
|
|
@@ -2164,7 +2176,7 @@ function createCommonOperationStrategy(tables3, dialect, fulltextStrategy) {
|
|
|
2164
2176
|
}
|
|
2165
2177
|
function tableExistsFromRow(row) {
|
|
2166
2178
|
if (row === void 0) return false;
|
|
2167
|
-
return Object.values(row).some((value) =>
|
|
2179
|
+
return Object.values(row).some((value) => chunkIPSVVTWT_cjs.isPresent(value));
|
|
2168
2180
|
}
|
|
2169
2181
|
function createCachedTableExistence(probe, options) {
|
|
2170
2182
|
const cacheExisting = options?.cacheExisting !== false;
|
|
@@ -2193,7 +2205,7 @@ function createPostgresOperationStrategy(tables3, fulltextStrategy) {
|
|
|
2193
2205
|
function assertAdoptedDialect(externalTx, brand, backend) {
|
|
2194
2206
|
if (drizzleOrm.is(externalTx, brand)) return;
|
|
2195
2207
|
const label = backend === "postgres" ? "Postgres" : "SQLite";
|
|
2196
|
-
throw new
|
|
2208
|
+
throw new chunkBVRDGYXQ_cjs.ConfigurationError(
|
|
2197
2209
|
`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.`,
|
|
2198
2210
|
{ backend, capability: "adoptTransaction" }
|
|
2199
2211
|
);
|
|
@@ -2201,7 +2213,7 @@ function assertAdoptedDialect(externalTx, brand, backend) {
|
|
|
2201
2213
|
function verifyExpectedActiveVersion(graphId, expected, actualActiveVersion) {
|
|
2202
2214
|
const expectedVersion = expected.kind === "active" ? expected.version : 0;
|
|
2203
2215
|
if (actualActiveVersion !== expectedVersion) {
|
|
2204
|
-
throw new
|
|
2216
|
+
throw new chunkBVRDGYXQ_cjs.StaleVersionError({
|
|
2205
2217
|
graphId,
|
|
2206
2218
|
expected: expectedVersion,
|
|
2207
2219
|
actual: actualActiveVersion
|
|
@@ -2210,7 +2222,7 @@ function verifyExpectedActiveVersion(graphId, expected, actualActiveVersion) {
|
|
|
2210
2222
|
}
|
|
2211
2223
|
function createCommonOperationBackend(options) {
|
|
2212
2224
|
const { batchConfig, execution, operationStrategy, rowMappers } = options;
|
|
2213
|
-
const nowIso2 = options.nowIso ??
|
|
2225
|
+
const nowIso2 = options.nowIso ?? chunkVL2V6PEN_cjs.nowIso;
|
|
2214
2226
|
const requiredClearTableExists = createCachedTableExistence(
|
|
2215
2227
|
(tableName) => execution.execGet(
|
|
2216
2228
|
operationStrategy.buildTableExists(tableName)
|
|
@@ -2233,16 +2245,26 @@ function createCommonOperationBackend(options) {
|
|
|
2233
2245
|
async executeStatement(query) {
|
|
2234
2246
|
await execution.execRun(query);
|
|
2235
2247
|
},
|
|
2248
|
+
async executeTemporaryStatement(query) {
|
|
2249
|
+
await execution.execRun(query);
|
|
2250
|
+
},
|
|
2236
2251
|
async insertNode(params) {
|
|
2237
2252
|
const timestamp2 = nowIso2();
|
|
2238
2253
|
const query = operationStrategy.buildInsertNode(params, timestamp2);
|
|
2239
2254
|
const row = await execution.execGet(query);
|
|
2240
|
-
if (!row)
|
|
2255
|
+
if (!row)
|
|
2256
|
+
throw new chunkBVRDGYXQ_cjs.DatabaseOperationError(
|
|
2257
|
+
"Insert node failed: no row returned",
|
|
2258
|
+
{ operation: "insert", entity: "node" }
|
|
2259
|
+
);
|
|
2241
2260
|
return rowMappers.toNodeRow(row);
|
|
2242
2261
|
},
|
|
2243
2262
|
async insertNodeNoReturn(params) {
|
|
2244
2263
|
const timestamp2 = nowIso2();
|
|
2245
|
-
const query = operationStrategy.buildInsertNodeNoReturn(
|
|
2264
|
+
const query = operationStrategy.buildInsertNodeNoReturn(
|
|
2265
|
+
params,
|
|
2266
|
+
timestamp2
|
|
2267
|
+
);
|
|
2246
2268
|
await execution.execRun(query);
|
|
2247
2269
|
},
|
|
2248
2270
|
async insertNodesBatch(params) {
|
|
@@ -2250,7 +2272,7 @@ function createCommonOperationBackend(options) {
|
|
|
2250
2272
|
return;
|
|
2251
2273
|
}
|
|
2252
2274
|
const timestamp2 = nowIso2();
|
|
2253
|
-
for (const chunk2 of
|
|
2275
|
+
for (const chunk2 of chunkIPSVVTWT_cjs.chunk(params, batchConfig.nodeInsertBatchSize)) {
|
|
2254
2276
|
const query = operationStrategy.buildInsertNodesBatch(chunk2, timestamp2);
|
|
2255
2277
|
await execution.execRun(query);
|
|
2256
2278
|
}
|
|
@@ -2261,8 +2283,11 @@ function createCommonOperationBackend(options) {
|
|
|
2261
2283
|
}
|
|
2262
2284
|
const timestamp2 = nowIso2();
|
|
2263
2285
|
const allRows = [];
|
|
2264
|
-
for (const chunk2 of
|
|
2265
|
-
const query = operationStrategy.buildInsertNodesBatchReturning(
|
|
2286
|
+
for (const chunk2 of chunkIPSVVTWT_cjs.chunk(params, batchConfig.nodeInsertBatchSize)) {
|
|
2287
|
+
const query = operationStrategy.buildInsertNodesBatchReturning(
|
|
2288
|
+
chunk2,
|
|
2289
|
+
timestamp2
|
|
2290
|
+
);
|
|
2266
2291
|
const rows = await execution.execAll(query);
|
|
2267
2292
|
allRows.push(...rows.map((row) => rowMappers.toNodeRow(row)));
|
|
2268
2293
|
}
|
|
@@ -2276,7 +2301,7 @@ function createCommonOperationBackend(options) {
|
|
|
2276
2301
|
async getNodes(graphId, kind, ids) {
|
|
2277
2302
|
if (ids.length === 0) return [];
|
|
2278
2303
|
const allRows = [];
|
|
2279
|
-
for (const chunk2 of
|
|
2304
|
+
for (const chunk2 of chunkIPSVVTWT_cjs.chunk(ids, batchConfig.getNodesChunkSize)) {
|
|
2280
2305
|
const query = operationStrategy.buildGetNodes(graphId, kind, chunk2);
|
|
2281
2306
|
const rows = await execution.execAll(query);
|
|
2282
2307
|
allRows.push(...rows.map((row) => rowMappers.toNodeRow(row)));
|
|
@@ -2287,7 +2312,11 @@ function createCommonOperationBackend(options) {
|
|
|
2287
2312
|
const timestamp2 = nowIso2();
|
|
2288
2313
|
const query = operationStrategy.buildUpdateNode(params, timestamp2);
|
|
2289
2314
|
const row = await execution.execGet(query);
|
|
2290
|
-
if (!row)
|
|
2315
|
+
if (!row)
|
|
2316
|
+
throw new chunkBVRDGYXQ_cjs.DatabaseOperationError(
|
|
2317
|
+
"Update node failed: no row returned",
|
|
2318
|
+
{ operation: "update", entity: "node" }
|
|
2319
|
+
);
|
|
2291
2320
|
return rowMappers.toNodeRow(row);
|
|
2292
2321
|
},
|
|
2293
2322
|
async deleteNode(params) {
|
|
@@ -2331,12 +2360,19 @@ function createCommonOperationBackend(options) {
|
|
|
2331
2360
|
const timestamp2 = nowIso2();
|
|
2332
2361
|
const query = operationStrategy.buildInsertEdge(params, timestamp2);
|
|
2333
2362
|
const row = await execution.execGet(query);
|
|
2334
|
-
if (!row)
|
|
2363
|
+
if (!row)
|
|
2364
|
+
throw new chunkBVRDGYXQ_cjs.DatabaseOperationError(
|
|
2365
|
+
"Insert edge failed: no row returned",
|
|
2366
|
+
{ operation: "insert", entity: "edge" }
|
|
2367
|
+
);
|
|
2335
2368
|
return rowMappers.toEdgeRow(row);
|
|
2336
2369
|
},
|
|
2337
2370
|
async insertEdgeNoReturn(params) {
|
|
2338
2371
|
const timestamp2 = nowIso2();
|
|
2339
|
-
const query = operationStrategy.buildInsertEdgeNoReturn(
|
|
2372
|
+
const query = operationStrategy.buildInsertEdgeNoReturn(
|
|
2373
|
+
params,
|
|
2374
|
+
timestamp2
|
|
2375
|
+
);
|
|
2340
2376
|
await execution.execRun(query);
|
|
2341
2377
|
},
|
|
2342
2378
|
async insertEdgesBatch(params) {
|
|
@@ -2344,7 +2380,7 @@ function createCommonOperationBackend(options) {
|
|
|
2344
2380
|
return;
|
|
2345
2381
|
}
|
|
2346
2382
|
const timestamp2 = nowIso2();
|
|
2347
|
-
for (const chunk2 of
|
|
2383
|
+
for (const chunk2 of chunkIPSVVTWT_cjs.chunk(params, batchConfig.edgeInsertBatchSize)) {
|
|
2348
2384
|
const query = operationStrategy.buildInsertEdgesBatch(chunk2, timestamp2);
|
|
2349
2385
|
await execution.execRun(query);
|
|
2350
2386
|
}
|
|
@@ -2355,8 +2391,11 @@ function createCommonOperationBackend(options) {
|
|
|
2355
2391
|
}
|
|
2356
2392
|
const timestamp2 = nowIso2();
|
|
2357
2393
|
const allRows = [];
|
|
2358
|
-
for (const chunk2 of
|
|
2359
|
-
const query = operationStrategy.buildInsertEdgesBatchReturning(
|
|
2394
|
+
for (const chunk2 of chunkIPSVVTWT_cjs.chunk(params, batchConfig.edgeInsertBatchSize)) {
|
|
2395
|
+
const query = operationStrategy.buildInsertEdgesBatchReturning(
|
|
2396
|
+
chunk2,
|
|
2397
|
+
timestamp2
|
|
2398
|
+
);
|
|
2360
2399
|
const rows = await execution.execAll(query);
|
|
2361
2400
|
allRows.push(...rows.map((row) => rowMappers.toEdgeRow(row)));
|
|
2362
2401
|
}
|
|
@@ -2370,7 +2409,7 @@ function createCommonOperationBackend(options) {
|
|
|
2370
2409
|
async getEdges(graphId, ids) {
|
|
2371
2410
|
if (ids.length === 0) return [];
|
|
2372
2411
|
const allRows = [];
|
|
2373
|
-
for (const chunk2 of
|
|
2412
|
+
for (const chunk2 of chunkIPSVVTWT_cjs.chunk(ids, batchConfig.getEdgesChunkSize)) {
|
|
2374
2413
|
const query = operationStrategy.buildGetEdges(graphId, chunk2);
|
|
2375
2414
|
const rows = await execution.execAll(query);
|
|
2376
2415
|
allRows.push(...rows.map((row) => rowMappers.toEdgeRow(row)));
|
|
@@ -2381,7 +2420,11 @@ function createCommonOperationBackend(options) {
|
|
|
2381
2420
|
const timestamp2 = nowIso2();
|
|
2382
2421
|
const query = operationStrategy.buildUpdateEdge(params, timestamp2);
|
|
2383
2422
|
const row = await execution.execGet(query);
|
|
2384
|
-
if (!row)
|
|
2423
|
+
if (!row)
|
|
2424
|
+
throw new chunkBVRDGYXQ_cjs.DatabaseOperationError(
|
|
2425
|
+
"Update edge failed: no row returned",
|
|
2426
|
+
{ operation: "update", entity: "edge" }
|
|
2427
|
+
);
|
|
2385
2428
|
return rowMappers.toEdgeRow(row);
|
|
2386
2429
|
},
|
|
2387
2430
|
async deleteEdge(params) {
|
|
@@ -2396,8 +2439,11 @@ function createCommonOperationBackend(options) {
|
|
|
2396
2439
|
async deleteEdgesBatch(params) {
|
|
2397
2440
|
if (params.ids.length === 0) return;
|
|
2398
2441
|
const timestamp2 = nowIso2();
|
|
2399
|
-
const softDeleteChunkSize = Math.max(
|
|
2400
|
-
|
|
2442
|
+
const softDeleteChunkSize = Math.max(
|
|
2443
|
+
1,
|
|
2444
|
+
batchConfig.getEdgesChunkSize - 1
|
|
2445
|
+
);
|
|
2446
|
+
for (const chunk2 of chunkIPSVVTWT_cjs.chunk(params.ids, softDeleteChunkSize)) {
|
|
2401
2447
|
const query = operationStrategy.buildDeleteEdgesBatch(
|
|
2402
2448
|
{ graphId: params.graphId, ids: chunk2 },
|
|
2403
2449
|
timestamp2
|
|
@@ -2407,7 +2453,10 @@ function createCommonOperationBackend(options) {
|
|
|
2407
2453
|
},
|
|
2408
2454
|
async hardDeleteEdgesBatch(params) {
|
|
2409
2455
|
if (params.ids.length === 0) return;
|
|
2410
|
-
for (const chunk2 of
|
|
2456
|
+
for (const chunk2 of chunkIPSVVTWT_cjs.chunk(
|
|
2457
|
+
params.ids,
|
|
2458
|
+
batchConfig.getEdgesChunkSize
|
|
2459
|
+
)) {
|
|
2411
2460
|
const query = operationStrategy.buildHardDeleteEdgesBatch({
|
|
2412
2461
|
graphId: params.graphId,
|
|
2413
2462
|
ids: chunk2
|
|
@@ -2454,7 +2503,7 @@ function createCommonOperationBackend(options) {
|
|
|
2454
2503
|
const query = operationStrategy.buildInsertUnique(params);
|
|
2455
2504
|
const result = await execution.execGet(query);
|
|
2456
2505
|
if (result && result.node_id !== params.nodeId) {
|
|
2457
|
-
throw new
|
|
2506
|
+
throw new chunkBVRDGYXQ_cjs.UniquenessError({
|
|
2458
2507
|
constraintName: params.constraintName,
|
|
2459
2508
|
kind: params.nodeKind,
|
|
2460
2509
|
existingId: result.node_id,
|
|
@@ -2474,7 +2523,7 @@ function createCommonOperationBackend(options) {
|
|
|
2474
2523
|
continue;
|
|
2475
2524
|
}
|
|
2476
2525
|
if (existing.nodeId !== entry.nodeId) {
|
|
2477
|
-
throw new
|
|
2526
|
+
throw new chunkBVRDGYXQ_cjs.UniquenessError({
|
|
2478
2527
|
constraintName: entry.constraintName,
|
|
2479
2528
|
kind: entry.nodeKind,
|
|
2480
2529
|
existingId: existing.nodeId,
|
|
@@ -2484,7 +2533,7 @@ function createCommonOperationBackend(options) {
|
|
|
2484
2533
|
}
|
|
2485
2534
|
}
|
|
2486
2535
|
const deduped = [...byTarget.values()];
|
|
2487
|
-
for (const chunk2 of
|
|
2536
|
+
for (const chunk2 of chunkIPSVVTWT_cjs.chunk(
|
|
2488
2537
|
deduped,
|
|
2489
2538
|
batchConfig.uniqueInsertBatchSize
|
|
2490
2539
|
)) {
|
|
@@ -2499,7 +2548,7 @@ function createCommonOperationBackend(options) {
|
|
|
2499
2548
|
for (const entry of chunk2) {
|
|
2500
2549
|
const owner = ownerByTarget.get(targetKey(entry));
|
|
2501
2550
|
if (owner !== void 0 && owner !== entry.nodeId) {
|
|
2502
|
-
throw new
|
|
2551
|
+
throw new chunkBVRDGYXQ_cjs.UniquenessError({
|
|
2503
2552
|
constraintName: entry.constraintName,
|
|
2504
2553
|
kind: entry.nodeKind,
|
|
2505
2554
|
existingId: owner,
|
|
@@ -2523,8 +2572,14 @@ function createCommonOperationBackend(options) {
|
|
|
2523
2572
|
async checkUniqueBatch(params) {
|
|
2524
2573
|
if (params.keys.length === 0) return [];
|
|
2525
2574
|
const allRows = [];
|
|
2526
|
-
for (const chunk2 of
|
|
2527
|
-
|
|
2575
|
+
for (const chunk2 of chunkIPSVVTWT_cjs.chunk(
|
|
2576
|
+
params.keys,
|
|
2577
|
+
batchConfig.checkUniqueBatchChunkSize
|
|
2578
|
+
)) {
|
|
2579
|
+
const query = operationStrategy.buildCheckUniqueBatch({
|
|
2580
|
+
...params,
|
|
2581
|
+
keys: chunk2
|
|
2582
|
+
});
|
|
2528
2583
|
const rows = await execution.execAll(query);
|
|
2529
2584
|
allRows.push(...rows.map((row) => rowMappers.toUniqueRow(row)));
|
|
2530
2585
|
}
|
|
@@ -2542,16 +2597,13 @@ function createCommonOperationBackend(options) {
|
|
|
2542
2597
|
},
|
|
2543
2598
|
async commitSchemaVersion(params) {
|
|
2544
2599
|
const existingRaw = await execution.execGet(
|
|
2545
|
-
operationStrategy.buildGetSchemaVersion(
|
|
2546
|
-
params.graphId,
|
|
2547
|
-
params.version
|
|
2548
|
-
)
|
|
2600
|
+
operationStrategy.buildGetSchemaVersion(params.graphId, params.version)
|
|
2549
2601
|
);
|
|
2550
2602
|
const actualActiveVersion = await readActiveVersion(params.graphId);
|
|
2551
2603
|
if (existingRaw !== void 0) {
|
|
2552
2604
|
const existing = rowMappers.toSchemaVersionRow(existingRaw);
|
|
2553
2605
|
if (existing.schema_hash !== params.schemaHash) {
|
|
2554
|
-
throw new
|
|
2606
|
+
throw new chunkBVRDGYXQ_cjs.SchemaContentConflictError({
|
|
2555
2607
|
graphId: params.graphId,
|
|
2556
2608
|
version: params.version,
|
|
2557
2609
|
existingHash: existing.schema_hash,
|
|
@@ -2599,7 +2651,7 @@ function createCommonOperationBackend(options) {
|
|
|
2599
2651
|
);
|
|
2600
2652
|
const insertedRaw = await execution.execGet(insertQuery);
|
|
2601
2653
|
if (!insertedRaw) {
|
|
2602
|
-
throw new
|
|
2654
|
+
throw new chunkBVRDGYXQ_cjs.DatabaseOperationError(
|
|
2603
2655
|
"Insert schema failed: no row returned",
|
|
2604
2656
|
{ operation: "insert", entity: "schema" }
|
|
2605
2657
|
);
|
|
@@ -2614,13 +2666,10 @@ function createCommonOperationBackend(options) {
|
|
|
2614
2666
|
actualActiveVersion
|
|
2615
2667
|
);
|
|
2616
2668
|
const targetRaw = await execution.execGet(
|
|
2617
|
-
operationStrategy.buildGetSchemaVersion(
|
|
2618
|
-
params.graphId,
|
|
2619
|
-
params.version
|
|
2620
|
-
)
|
|
2669
|
+
operationStrategy.buildGetSchemaVersion(params.graphId, params.version)
|
|
2621
2670
|
);
|
|
2622
2671
|
if (!targetRaw) {
|
|
2623
|
-
throw new
|
|
2672
|
+
throw new chunkBVRDGYXQ_cjs.MigrationError(
|
|
2624
2673
|
`Cannot activate version ${params.version}: version does not exist for graph "${params.graphId}".`,
|
|
2625
2674
|
{
|
|
2626
2675
|
graphId: params.graphId,
|
|
@@ -2644,6 +2693,256 @@ function createCommonOperationBackend(options) {
|
|
|
2644
2693
|
}
|
|
2645
2694
|
};
|
|
2646
2695
|
}
|
|
2696
|
+
var DATABASE_NULL = null;
|
|
2697
|
+
function quoteSqlIdentifier(identifier) {
|
|
2698
|
+
return `"${identifier.replaceAll('"', '""')}"`;
|
|
2699
|
+
}
|
|
2700
|
+
function requireRawExecution(backend) {
|
|
2701
|
+
if (backend.executeRaw === void 0) {
|
|
2702
|
+
throw new chunkBVRDGYXQ_cjs.TrustedImportError(
|
|
2703
|
+
"This backend cannot execute the raw statements required by trusted import.",
|
|
2704
|
+
"backend_unsupported"
|
|
2705
|
+
);
|
|
2706
|
+
}
|
|
2707
|
+
return backend.executeRaw;
|
|
2708
|
+
}
|
|
2709
|
+
function requireStatementExecution(backend) {
|
|
2710
|
+
if (backend.executeStatement === void 0) {
|
|
2711
|
+
throw new chunkBVRDGYXQ_cjs.TrustedImportError(
|
|
2712
|
+
"This backend cannot execute the index lifecycle required by trusted import.",
|
|
2713
|
+
"backend_unsupported"
|
|
2714
|
+
);
|
|
2715
|
+
}
|
|
2716
|
+
return backend.executeStatement;
|
|
2717
|
+
}
|
|
2718
|
+
function rowIndicatesExistingData(row) {
|
|
2719
|
+
if (typeof row !== "object" || row === null) return false;
|
|
2720
|
+
const value = row.has_rows;
|
|
2721
|
+
return value === true || value === 1 || value === "1";
|
|
2722
|
+
}
|
|
2723
|
+
async function assertTrustedImportDatabaseEmpty(backend, tableNames) {
|
|
2724
|
+
const executeRaw = requireRawExecution(backend);
|
|
2725
|
+
const rows = await executeRaw(
|
|
2726
|
+
`SELECT (
|
|
2727
|
+
EXISTS (SELECT 1 FROM ${quoteSqlIdentifier(tableNames.nodes)} LIMIT 1)
|
|
2728
|
+
OR EXISTS (SELECT 1 FROM ${quoteSqlIdentifier(tableNames.edges)} LIMIT 1)
|
|
2729
|
+
) AS has_rows`,
|
|
2730
|
+
[]
|
|
2731
|
+
);
|
|
2732
|
+
if (!rowIndicatesExistingData(rows[0])) return;
|
|
2733
|
+
throw new chunkBVRDGYXQ_cjs.TrustedImportError(
|
|
2734
|
+
"Trusted import requires globally empty TypeGraph node and edge tables.",
|
|
2735
|
+
"database_not_empty",
|
|
2736
|
+
{ tables: [tableNames.nodes, tableNames.edges] },
|
|
2737
|
+
{
|
|
2738
|
+
suggestion: "Run trusted import only against a fresh, dedicated database. Use importGraph or the collection bulk APIs to add data to an existing database."
|
|
2739
|
+
}
|
|
2740
|
+
);
|
|
2741
|
+
}
|
|
2742
|
+
async function lockPostgresTrustedImportTables(backend, tableNames) {
|
|
2743
|
+
const executeStatement = requireStatementExecution(backend);
|
|
2744
|
+
await executeStatement(
|
|
2745
|
+
chunkIPSVVTWT_cjs.asCompiledStatementSql(
|
|
2746
|
+
drizzleOrm.sql.raw(
|
|
2747
|
+
`LOCK TABLE ${quoteSqlIdentifier(tableNames.nodes)}, ${quoteSqlIdentifier(tableNames.edges)} IN ACCESS EXCLUSIVE MODE`
|
|
2748
|
+
)
|
|
2749
|
+
)
|
|
2750
|
+
);
|
|
2751
|
+
}
|
|
2752
|
+
async function suspendSqliteSecondaryIndexes(backend, tableNames) {
|
|
2753
|
+
const executeRaw = requireRawExecution(backend);
|
|
2754
|
+
const executeStatement = requireStatementExecution(backend);
|
|
2755
|
+
const definitions = await executeRaw(
|
|
2756
|
+
`SELECT name AS index_name, sql AS index_definition
|
|
2757
|
+
FROM sqlite_schema
|
|
2758
|
+
WHERE type = 'index'
|
|
2759
|
+
AND tbl_name IN (?, ?)
|
|
2760
|
+
AND sql IS NOT NULL
|
|
2761
|
+
ORDER BY name`,
|
|
2762
|
+
[tableNames.nodes, tableNames.edges]
|
|
2763
|
+
);
|
|
2764
|
+
for (const definition of definitions) {
|
|
2765
|
+
await executeStatement(
|
|
2766
|
+
chunkIPSVVTWT_cjs.asCompiledStatementSql(
|
|
2767
|
+
drizzleOrm.sql.raw(`DROP INDEX ${quoteSqlIdentifier(definition.index_name)}`)
|
|
2768
|
+
)
|
|
2769
|
+
);
|
|
2770
|
+
}
|
|
2771
|
+
return definitions;
|
|
2772
|
+
}
|
|
2773
|
+
async function suspendPostgresSecondaryIndexes(backend, tableNames) {
|
|
2774
|
+
const executeRaw = requireRawExecution(backend);
|
|
2775
|
+
const executeStatement = requireStatementExecution(backend);
|
|
2776
|
+
const definitions = await executeRaw(
|
|
2777
|
+
`SELECT index_class.relname AS index_name,
|
|
2778
|
+
pg_get_indexdef(index_class.oid) AS index_definition
|
|
2779
|
+
FROM pg_class AS table_class
|
|
2780
|
+
JOIN pg_namespace AS namespace
|
|
2781
|
+
ON namespace.oid = table_class.relnamespace
|
|
2782
|
+
JOIN pg_index AS index_metadata
|
|
2783
|
+
ON index_metadata.indrelid = table_class.oid
|
|
2784
|
+
JOIN pg_class AS index_class
|
|
2785
|
+
ON index_class.oid = index_metadata.indexrelid
|
|
2786
|
+
LEFT JOIN pg_constraint AS table_constraint
|
|
2787
|
+
ON table_constraint.conindid = index_class.oid
|
|
2788
|
+
WHERE namespace.nspname = current_schema()
|
|
2789
|
+
AND table_class.relname IN ($1, $2)
|
|
2790
|
+
AND table_constraint.oid IS NULL
|
|
2791
|
+
AND NOT index_metadata.indisprimary
|
|
2792
|
+
ORDER BY index_class.relname`,
|
|
2793
|
+
[tableNames.nodes, tableNames.edges]
|
|
2794
|
+
);
|
|
2795
|
+
for (const definition of definitions) {
|
|
2796
|
+
await executeStatement(
|
|
2797
|
+
chunkIPSVVTWT_cjs.asCompiledStatementSql(
|
|
2798
|
+
drizzleOrm.sql.raw(`DROP INDEX ${quoteSqlIdentifier(definition.index_name)}`)
|
|
2799
|
+
)
|
|
2800
|
+
);
|
|
2801
|
+
}
|
|
2802
|
+
return definitions;
|
|
2803
|
+
}
|
|
2804
|
+
async function restoreSecondaryIndexes(backend, definitions) {
|
|
2805
|
+
const executeStatement = requireStatementExecution(backend);
|
|
2806
|
+
for (const definition of definitions) {
|
|
2807
|
+
await executeStatement(
|
|
2808
|
+
chunkIPSVVTWT_cjs.asCompiledStatementSql(drizzleOrm.sql.raw(definition.index_definition))
|
|
2809
|
+
);
|
|
2810
|
+
}
|
|
2811
|
+
}
|
|
2812
|
+
async function analyzeImportedTables(backend, tableNames) {
|
|
2813
|
+
const executeStatement = requireStatementExecution(backend);
|
|
2814
|
+
await executeStatement(
|
|
2815
|
+
chunkIPSVVTWT_cjs.asCompiledStatementSql(
|
|
2816
|
+
drizzleOrm.sql.raw(`ANALYZE ${quoteSqlIdentifier(tableNames.nodes)}`)
|
|
2817
|
+
)
|
|
2818
|
+
);
|
|
2819
|
+
await executeStatement(
|
|
2820
|
+
chunkIPSVVTWT_cjs.asCompiledStatementSql(
|
|
2821
|
+
drizzleOrm.sql.raw(`ANALYZE ${quoteSqlIdentifier(tableNames.edges)}`)
|
|
2822
|
+
)
|
|
2823
|
+
);
|
|
2824
|
+
}
|
|
2825
|
+
function resolvedValidFrom(validFrom, timestamp2) {
|
|
2826
|
+
return validFrom === void 0 ? timestamp2 : validFrom;
|
|
2827
|
+
}
|
|
2828
|
+
function postgresArray(values) {
|
|
2829
|
+
return `{${values.map(
|
|
2830
|
+
(value) => value === DATABASE_NULL ? "NULL" : `"${value.replaceAll("\\", "\\\\").replaceAll('"', String.raw`\"`)}"`
|
|
2831
|
+
).join(",")}}`;
|
|
2832
|
+
}
|
|
2833
|
+
function createSqliteTrustedImportSession(executionAdapter, tableNames) {
|
|
2834
|
+
const executePreparedRunBatch = executionAdapter.executePreparedRunBatch;
|
|
2835
|
+
if (executePreparedRunBatch === void 0) {
|
|
2836
|
+
throw new chunkBVRDGYXQ_cjs.TrustedImportError(
|
|
2837
|
+
"Trusted import requires a synchronous SQLite driver with prepared statement support.",
|
|
2838
|
+
"backend_unsupported"
|
|
2839
|
+
);
|
|
2840
|
+
}
|
|
2841
|
+
const nodeSql = `INSERT INTO ${quoteSqlIdentifier(tableNames.nodes)}
|
|
2842
|
+
(graph_id, kind, id, props, version, valid_from, valid_to, created_at, updated_at)
|
|
2843
|
+
VALUES (?, ?, ?, ?, 1, ?, ?, ?, ?)`;
|
|
2844
|
+
const edgeSql = `INSERT INTO ${quoteSqlIdentifier(tableNames.edges)}
|
|
2845
|
+
(graph_id, id, kind, from_kind, from_id, to_kind, to_id, props, valid_from, valid_to, created_at, updated_at)
|
|
2846
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`;
|
|
2847
|
+
return {
|
|
2848
|
+
async insertNodes(params) {
|
|
2849
|
+
if (params.length === 0) return;
|
|
2850
|
+
const timestamp2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
2851
|
+
await executePreparedRunBatch(
|
|
2852
|
+
nodeSql,
|
|
2853
|
+
params.map((item) => [
|
|
2854
|
+
item.graphId,
|
|
2855
|
+
item.kind,
|
|
2856
|
+
item.id,
|
|
2857
|
+
JSON.stringify(item.props),
|
|
2858
|
+
resolvedValidFrom(item.validFrom, timestamp2),
|
|
2859
|
+
item.validTo ?? DATABASE_NULL,
|
|
2860
|
+
timestamp2,
|
|
2861
|
+
timestamp2
|
|
2862
|
+
])
|
|
2863
|
+
);
|
|
2864
|
+
},
|
|
2865
|
+
async insertEdges(params) {
|
|
2866
|
+
if (params.length === 0) return;
|
|
2867
|
+
const timestamp2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
2868
|
+
await executePreparedRunBatch(
|
|
2869
|
+
edgeSql,
|
|
2870
|
+
params.map((item) => [
|
|
2871
|
+
item.graphId,
|
|
2872
|
+
item.id,
|
|
2873
|
+
item.kind,
|
|
2874
|
+
item.fromKind,
|
|
2875
|
+
item.fromId,
|
|
2876
|
+
item.toKind,
|
|
2877
|
+
item.toId,
|
|
2878
|
+
JSON.stringify(item.props),
|
|
2879
|
+
resolvedValidFrom(item.validFrom, timestamp2),
|
|
2880
|
+
item.validTo ?? DATABASE_NULL,
|
|
2881
|
+
timestamp2,
|
|
2882
|
+
timestamp2
|
|
2883
|
+
])
|
|
2884
|
+
);
|
|
2885
|
+
}
|
|
2886
|
+
};
|
|
2887
|
+
}
|
|
2888
|
+
function createPostgresTrustedImportSession(backend, tableNames) {
|
|
2889
|
+
const executeRaw = requireRawExecution(backend);
|
|
2890
|
+
const nodeSql = `INSERT INTO ${quoteSqlIdentifier(tableNames.nodes)}
|
|
2891
|
+
(graph_id, kind, id, props, version, valid_from, valid_to, created_at, updated_at)
|
|
2892
|
+
SELECT graph_id, kind, id, props::jsonb, 1, valid_from, valid_to, created_at, created_at
|
|
2893
|
+
FROM UNNEST(
|
|
2894
|
+
$1::text[], $2::text[], $3::text[], $4::text[],
|
|
2895
|
+
$5::timestamptz[], $6::timestamptz[], $7::timestamptz[]
|
|
2896
|
+
) AS imported(graph_id, kind, id, props, valid_from, valid_to, created_at)`;
|
|
2897
|
+
const edgeSql = `INSERT INTO ${quoteSqlIdentifier(tableNames.edges)}
|
|
2898
|
+
(graph_id, id, kind, from_kind, from_id, to_kind, to_id, props, valid_from, valid_to, created_at, updated_at)
|
|
2899
|
+
SELECT graph_id, id, kind, from_kind, from_id, to_kind, to_id, props::jsonb,
|
|
2900
|
+
valid_from, valid_to, created_at, created_at
|
|
2901
|
+
FROM UNNEST(
|
|
2902
|
+
$1::text[], $2::text[], $3::text[], $4::text[], $5::text[],
|
|
2903
|
+
$6::text[], $7::text[], $8::text[], $9::timestamptz[],
|
|
2904
|
+
$10::timestamptz[], $11::timestamptz[]
|
|
2905
|
+
) AS imported(
|
|
2906
|
+
graph_id, id, kind, from_kind, from_id, to_kind, to_id, props,
|
|
2907
|
+
valid_from, valid_to, created_at
|
|
2908
|
+
)`;
|
|
2909
|
+
return {
|
|
2910
|
+
async insertNodes(params) {
|
|
2911
|
+
if (params.length === 0) return;
|
|
2912
|
+
const timestamp2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
2913
|
+
await executeRaw(nodeSql, [
|
|
2914
|
+
postgresArray(params.map((item) => item.graphId)),
|
|
2915
|
+
postgresArray(params.map((item) => item.kind)),
|
|
2916
|
+
postgresArray(params.map((item) => item.id)),
|
|
2917
|
+
postgresArray(params.map((item) => JSON.stringify(item.props))),
|
|
2918
|
+
postgresArray(
|
|
2919
|
+
params.map((item) => resolvedValidFrom(item.validFrom, timestamp2))
|
|
2920
|
+
),
|
|
2921
|
+
postgresArray(params.map((item) => item.validTo ?? DATABASE_NULL)),
|
|
2922
|
+
postgresArray(params.map(() => timestamp2))
|
|
2923
|
+
]);
|
|
2924
|
+
},
|
|
2925
|
+
async insertEdges(params) {
|
|
2926
|
+
if (params.length === 0) return;
|
|
2927
|
+
const timestamp2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
2928
|
+
await executeRaw(edgeSql, [
|
|
2929
|
+
postgresArray(params.map((item) => item.graphId)),
|
|
2930
|
+
postgresArray(params.map((item) => item.id)),
|
|
2931
|
+
postgresArray(params.map((item) => item.kind)),
|
|
2932
|
+
postgresArray(params.map((item) => item.fromKind)),
|
|
2933
|
+
postgresArray(params.map((item) => item.fromId)),
|
|
2934
|
+
postgresArray(params.map((item) => item.toKind)),
|
|
2935
|
+
postgresArray(params.map((item) => item.toId)),
|
|
2936
|
+
postgresArray(params.map((item) => JSON.stringify(item.props))),
|
|
2937
|
+
postgresArray(
|
|
2938
|
+
params.map((item) => resolvedValidFrom(item.validFrom, timestamp2))
|
|
2939
|
+
),
|
|
2940
|
+
postgresArray(params.map((item) => item.validTo ?? DATABASE_NULL)),
|
|
2941
|
+
postgresArray(params.map(() => timestamp2))
|
|
2942
|
+
]);
|
|
2943
|
+
}
|
|
2944
|
+
};
|
|
2945
|
+
}
|
|
2647
2946
|
|
|
2648
2947
|
// src/backend/drizzle/execution/lru.ts
|
|
2649
2948
|
function getOrCreateLru(cache, key, cacheMax, create) {
|
|
@@ -2679,7 +2978,9 @@ exports.POSTGRES_KIND_REMOVAL_TIMESTAMPS = POSTGRES_KIND_REMOVAL_TIMESTAMPS;
|
|
|
2679
2978
|
exports.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS = SQLITE_CONTRIBUTION_MAT_TIMESTAMPS;
|
|
2680
2979
|
exports.SQLITE_INDEX_MAT_TIMESTAMPS = SQLITE_INDEX_MAT_TIMESTAMPS;
|
|
2681
2980
|
exports.SQLITE_KIND_REMOVAL_TIMESTAMPS = SQLITE_KIND_REMOVAL_TIMESTAMPS;
|
|
2981
|
+
exports.analyzeImportedTables = analyzeImportedTables;
|
|
2682
2982
|
exports.assertAdoptedDialect = assertAdoptedDialect;
|
|
2983
|
+
exports.assertTrustedImportDatabaseEmpty = assertTrustedImportDatabaseEmpty;
|
|
2683
2984
|
exports.buildContributionInsertValues = buildContributionInsertValues;
|
|
2684
2985
|
exports.buildContributionOnConflictSet = buildContributionOnConflictSet;
|
|
2685
2986
|
exports.buildKindRemovalInsertValues = buildKindRemovalInsertValues;
|
|
@@ -2692,8 +2993,9 @@ exports.createCommonOperationBackend = createCommonOperationBackend;
|
|
|
2692
2993
|
exports.createContributionMaterializer = createContributionMaterializer;
|
|
2693
2994
|
exports.createPostgresOperationStrategy = createPostgresOperationStrategy;
|
|
2694
2995
|
exports.createPostgresTables = createPostgresTables;
|
|
2996
|
+
exports.createPostgresTrustedImportSession = createPostgresTrustedImportSession;
|
|
2695
2997
|
exports.createSqliteOperationStrategy = createSqliteOperationStrategy;
|
|
2696
|
-
exports.
|
|
2998
|
+
exports.createSqliteTrustedImportSession = createSqliteTrustedImportSession;
|
|
2697
2999
|
exports.edges = edges;
|
|
2698
3000
|
exports.fulltext = fulltext;
|
|
2699
3001
|
exports.gateFulltext = gateFulltext;
|
|
@@ -2706,6 +3008,7 @@ exports.generateSqliteDDL = generateSqliteDDL;
|
|
|
2706
3008
|
exports.generateSqliteMigrationSQL = generateSqliteMigrationSQL;
|
|
2707
3009
|
exports.getOrCreateLru = getOrCreateLru;
|
|
2708
3010
|
exports.hybridCandidatesRef = hybridCandidatesRef;
|
|
3011
|
+
exports.lockPostgresTrustedImportTables = lockPostgresTrustedImportTables;
|
|
2709
3012
|
exports.mapContributionMaterializationRow = mapContributionMaterializationRow;
|
|
2710
3013
|
exports.mapHybridSearchRow = mapHybridSearchRow;
|
|
2711
3014
|
exports.mapKindRemovalRow = mapKindRemovalRow;
|
|
@@ -2715,11 +3018,14 @@ exports.nodes = nodes;
|
|
|
2715
3018
|
exports.recordedClock = recordedClock;
|
|
2716
3019
|
exports.recordedEdges = recordedEdges;
|
|
2717
3020
|
exports.recordedNodes = recordedNodes;
|
|
3021
|
+
exports.restoreSecondaryIndexes = restoreSecondaryIndexes;
|
|
2718
3022
|
exports.schemaVersions = schemaVersions;
|
|
3023
|
+
exports.suspendPostgresSecondaryIndexes = suspendPostgresSecondaryIndexes;
|
|
3024
|
+
exports.suspendSqliteSecondaryIndexes = suspendSqliteSecondaryIndexes;
|
|
2719
3025
|
exports.tables = tables2;
|
|
2720
3026
|
exports.uniques = uniques;
|
|
2721
3027
|
exports.vectorSlotFromCreateIndexParams = vectorSlotFromCreateIndexParams;
|
|
2722
3028
|
exports.vectorSlotFromDropIndexParams = vectorSlotFromDropIndexParams;
|
|
2723
3029
|
exports.vectorSlotFromParams = vectorSlotFromParams;
|
|
2724
|
-
//# sourceMappingURL=chunk-
|
|
2725
|
-
//# sourceMappingURL=chunk-
|
|
3030
|
+
//# sourceMappingURL=chunk-DIQ3AV5W.cjs.map
|
|
3031
|
+
//# sourceMappingURL=chunk-DIQ3AV5W.cjs.map
|