@nicia-ai/typegraph 0.24.1 → 0.25.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 +178 -55
- package/dist/backend/postgres/index.cjs.map +1 -1
- package/dist/backend/postgres/index.d.cts +6 -7
- package/dist/backend/postgres/index.d.ts +6 -7
- package/dist/backend/postgres/index.js +151 -28
- package/dist/backend/postgres/index.js.map +1 -1
- package/dist/backend/sqlite/index.cjs +19 -17
- package/dist/backend/sqlite/index.d.cts +6 -7
- package/dist/backend/sqlite/index.d.ts +6 -7
- package/dist/backend/sqlite/index.js +9 -7
- package/dist/backend/sqlite/libsql.cjs +12 -10
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +4 -5
- package/dist/backend/sqlite/libsql.d.ts +4 -5
- package/dist/backend/sqlite/libsql.js +9 -7
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +14 -12
- package/dist/backend/sqlite/local.cjs.map +1 -1
- package/dist/backend/sqlite/local.d.cts +4 -5
- package/dist/backend/sqlite/local.d.ts +4 -5
- package/dist/backend/sqlite/local.js +9 -7
- package/dist/backend/sqlite/local.js.map +1 -1
- package/dist/chunk-4BOWVUGQ.js +2029 -0
- package/dist/chunk-4BOWVUGQ.js.map +1 -0
- package/dist/{chunk-SUHW2UYL.cjs → chunk-7CDXX3QZ.cjs} +2 -2
- package/dist/chunk-7CDXX3QZ.cjs.map +1 -0
- package/dist/chunk-7V335GHG.cjs +112 -0
- package/dist/chunk-7V335GHG.cjs.map +1 -0
- package/dist/chunk-7W3KAMVQ.cjs +2678 -0
- package/dist/chunk-7W3KAMVQ.cjs.map +1 -0
- package/dist/chunk-CTHNVU6K.cjs +551 -0
- package/dist/chunk-CTHNVU6K.cjs.map +1 -0
- package/dist/chunk-D2GO3RBL.cjs +12 -0
- package/dist/chunk-D2GO3RBL.cjs.map +1 -0
- package/dist/{chunk-WFMTAEEN.js → chunk-DOTEN2FG.js} +81 -7
- package/dist/chunk-DOTEN2FG.js.map +1 -0
- package/dist/chunk-E5JZSEGJ.cjs +301 -0
- package/dist/chunk-E5JZSEGJ.cjs.map +1 -0
- package/dist/chunk-EG6TJ3I5.js +286 -0
- package/dist/chunk-EG6TJ3I5.js.map +1 -0
- package/dist/chunk-EJCDOA37.js +537 -0
- package/dist/chunk-EJCDOA37.js.map +1 -0
- package/dist/{chunk-UVZHTBZ5.cjs → chunk-EK6RJ373.cjs} +7 -150
- package/dist/chunk-EK6RJ373.cjs.map +1 -0
- package/dist/{chunk-GUTQTMOV.js → chunk-FPCOUJSL.js} +2 -2
- package/dist/chunk-FPCOUJSL.js.map +1 -0
- package/dist/{chunk-3JK66E3I.cjs → chunk-JTI5WT4P.cjs} +630 -59
- package/dist/chunk-JTI5WT4P.cjs.map +1 -0
- package/dist/chunk-LVCSL6A3.js +2626 -0
- package/dist/chunk-LVCSL6A3.js.map +1 -0
- package/dist/chunk-NHQWXSTS.js +10 -0
- package/dist/chunk-NHQWXSTS.js.map +1 -0
- package/dist/chunk-NZ5PMBTG.js +105 -0
- package/dist/chunk-NZ5PMBTG.js.map +1 -0
- package/dist/{chunk-5HVDOPZU.cjs → chunk-O2P3KAUT.cjs} +416 -93
- package/dist/chunk-O2P3KAUT.cjs.map +1 -0
- package/dist/{chunk-QOLTW7OZ.js → chunk-OJ6IQVZG.js} +151 -13
- package/dist/chunk-OJ6IQVZG.js.map +1 -0
- package/dist/{chunk-EYELZHKY.js → chunk-OOS2RKRH.js} +5 -140
- package/dist/chunk-OOS2RKRH.js.map +1 -0
- package/dist/chunk-RCAJZG67.cjs +2069 -0
- package/dist/chunk-RCAJZG67.cjs.map +1 -0
- package/dist/{chunk-O5PST6TB.cjs → chunk-W5MTHMTE.cjs} +83 -6
- package/dist/chunk-W5MTHMTE.cjs.map +1 -0
- package/dist/{chunk-EY4LBX3F.js → chunk-WI5VRP3X.js} +337 -26
- package/dist/chunk-WI5VRP3X.js.map +1 -0
- package/dist/chunk-WVQXAFP3.js +79 -0
- package/dist/chunk-WVQXAFP3.js.map +1 -0
- package/dist/chunk-X3244EKP.cjs +84 -0
- package/dist/chunk-X3244EKP.cjs.map +1 -0
- package/dist/{chunk-753F33CV.js → chunk-YZZBDCLV.js} +617 -44
- package/dist/chunk-YZZBDCLV.js.map +1 -0
- package/dist/{chunk-OVJ2BE5Q.cjs → chunk-ZEMNF3QK.cjs} +171 -33
- package/dist/chunk-ZEMNF3QK.cjs.map +1 -0
- package/dist/{ddl-B_H8JM-E.d.cts → ddl-B2jjLjpR.d.cts} +762 -99
- package/dist/{ddl-1tFIvt9V.d.ts → ddl-DpaeAKPp.d.ts} +762 -99
- package/dist/extension-types-D07e_NTw.d.cts +543 -0
- package/dist/extension-types-D07e_NTw.d.ts +543 -0
- package/dist/graph-extension/index.cjs +71 -0
- package/dist/graph-extension/index.cjs.map +1 -0
- package/dist/graph-extension/index.d.cts +278 -0
- package/dist/graph-extension/index.d.ts +278 -0
- package/dist/graph-extension/index.js +6 -0
- package/dist/graph-extension/index.js.map +1 -0
- package/dist/{index-DXkEXpNz.d.ts → index-CT6nvtxL.d.cts} +114 -5
- package/dist/{index-DXkEXpNz.d.cts → index-DQheiVQV.d.ts} +114 -5
- package/dist/index.cjs +2672 -901
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -10
- package/dist/index.d.ts +29 -10
- package/dist/index.js +2248 -598
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +25 -23
- package/dist/indexes/index.d.cts +40 -22
- package/dist/indexes/index.d.ts +40 -22
- package/dist/indexes/index.js +5 -3
- package/dist/interchange/index.cjs +8 -7
- package/dist/interchange/index.cjs.map +1 -1
- package/dist/interchange/index.d.cts +5 -4
- package/dist/interchange/index.d.ts +5 -4
- package/dist/interchange/index.js +3 -2
- package/dist/interchange/index.js.map +1 -1
- package/dist/{manager-nIhmttD-.d.ts → manager-BKaPQbns.d.ts} +189 -6
- package/dist/{manager-Vkz28eAC.d.cts → manager-BpjBW1JK.d.cts} +189 -6
- package/dist/materialize-indexes-BB9N5uQl.d.cts +68 -0
- package/dist/materialize-indexes-BYpU2RKh.d.ts +68 -0
- package/dist/profiler/index.cjs +10 -8
- package/dist/profiler/index.cjs.map +1 -1
- package/dist/profiler/index.d.cts +8 -7
- package/dist/profiler/index.d.ts +8 -7
- package/dist/profiler/index.js +3 -1
- package/dist/profiler/index.js.map +1 -1
- package/dist/schema/index.cjs +43 -22
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +17 -8
- package/dist/schema/index.d.ts +17 -8
- package/dist/schema/index.js +9 -4
- package/dist/schema/index.js.map +1 -1
- package/dist/{sqlite-D0aceIe0.d.cts → sqlite-CU3j6rc7.d.ts} +837 -120
- package/dist/{sqlite-SUxbZqfy.d.ts → sqlite-Myo8e3Lr.d.cts} +837 -120
- package/dist/{store-U3i2tUch.d.ts → store-BAGuOHDh.d.cts} +659 -23
- package/dist/{store-CpvwTMxV.d.cts → store-De98Lod4.d.ts} +659 -23
- package/dist/types--0EslBx5.d.cts +2123 -0
- package/dist/{types-qYFZ9SqD.d.ts → types-BLmJq4wI.d.ts} +3 -2
- package/dist/types-BNWYZ-0-.d.ts +2123 -0
- package/dist/{types-yH4_p0XB.d.cts → types-CYga3lZp.d.cts} +3 -2
- package/dist/where-CluR73rs.d.ts +11 -0
- package/dist/where-m1uWsdua.d.cts +11 -0
- package/package.json +33 -73
- package/dist/ast-C8S37w1A.d.ts +0 -497
- package/dist/ast-dgLhLOg0.d.cts +0 -497
- package/dist/chunk-3JK66E3I.cjs.map +0 -1
- package/dist/chunk-3PPEHLGK.js +0 -1116
- package/dist/chunk-3PPEHLGK.js.map +0 -1
- package/dist/chunk-5HVDOPZU.cjs.map +0 -1
- package/dist/chunk-753F33CV.js.map +0 -1
- package/dist/chunk-EY4LBX3F.js.map +0 -1
- package/dist/chunk-EYELZHKY.js.map +0 -1
- package/dist/chunk-GFGVREHH.js +0 -1381
- package/dist/chunk-GFGVREHH.js.map +0 -1
- package/dist/chunk-GUTQTMOV.js.map +0 -1
- package/dist/chunk-LBORRUNJ.js +0 -135
- package/dist/chunk-LBORRUNJ.js.map +0 -1
- package/dist/chunk-O5PST6TB.cjs.map +0 -1
- package/dist/chunk-OLROXS2S.cjs +0 -147
- package/dist/chunk-OLROXS2S.cjs.map +0 -1
- package/dist/chunk-OVJ2BE5Q.cjs.map +0 -1
- package/dist/chunk-PAUN562Y.cjs +0 -1417
- package/dist/chunk-PAUN562Y.cjs.map +0 -1
- package/dist/chunk-PEE4EWXZ.cjs +0 -1131
- package/dist/chunk-PEE4EWXZ.cjs.map +0 -1
- package/dist/chunk-QOLTW7OZ.js.map +0 -1
- package/dist/chunk-SUHW2UYL.cjs.map +0 -1
- package/dist/chunk-UVZHTBZ5.cjs.map +0 -1
- package/dist/chunk-WFMTAEEN.js.map +0 -1
- package/dist/types-C-zfYDJB.d.ts +0 -159
- package/dist/types-CQx4iW5Y.d.cts +0 -159
- package/dist/types-Qk2l3IkQ.d.cts +0 -1254
- package/dist/types-Qk2l3IkQ.d.ts +0 -1254
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkJTI5WT4P_cjs = require('./chunk-JTI5WT4P.cjs');
|
|
4
|
+
var chunkCTHNVU6K_cjs = require('./chunk-CTHNVU6K.cjs');
|
|
5
|
+
var chunkW5MTHMTE_cjs = require('./chunk-W5MTHMTE.cjs');
|
|
6
|
+
var drizzleOrm = require('drizzle-orm');
|
|
6
7
|
var pgCore = require('drizzle-orm/pg-core');
|
|
7
8
|
var sqliteCore = require('drizzle-orm/sqlite-core');
|
|
8
|
-
var drizzleOrm = require('drizzle-orm');
|
|
9
9
|
|
|
10
10
|
var vector = pgCore.customType({
|
|
11
11
|
dataType(config) {
|
|
@@ -33,7 +33,10 @@ var DEFAULT_TABLE_NAMES = {
|
|
|
33
33
|
uniques: "typegraph_node_uniques",
|
|
34
34
|
schemaVersions: "typegraph_schema_versions",
|
|
35
35
|
embeddings: "typegraph_node_embeddings",
|
|
36
|
-
fulltext: "typegraph_node_fulltext"
|
|
36
|
+
fulltext: "typegraph_node_fulltext",
|
|
37
|
+
indexMaterializations: "typegraph_index_materializations",
|
|
38
|
+
kindRemovals: "typegraph_kind_removals",
|
|
39
|
+
reconciliationMarkers: "typegraph_reconciliation_markers"
|
|
37
40
|
};
|
|
38
41
|
function createPostgresTables(names = {}, options = {}) {
|
|
39
42
|
const n = { ...DEFAULT_TABLE_NAMES, ...names };
|
|
@@ -63,7 +66,7 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
63
66
|
),
|
|
64
67
|
pgCore.index(`${n.nodes}_deleted_idx`).on(t.graphId, t.deletedAt),
|
|
65
68
|
pgCore.index(`${n.nodes}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),
|
|
66
|
-
...
|
|
69
|
+
...chunkJTI5WT4P_cjs.buildPostgresNodeIndexBuilders(t, indexes)
|
|
67
70
|
]
|
|
68
71
|
);
|
|
69
72
|
const edges3 = pgCore.pgTable(
|
|
@@ -122,7 +125,7 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
122
125
|
t.fromId,
|
|
123
126
|
t.validTo
|
|
124
127
|
),
|
|
125
|
-
...
|
|
128
|
+
...chunkJTI5WT4P_cjs.buildPostgresEdgeIndexBuilders(t, indexes)
|
|
126
129
|
]
|
|
127
130
|
);
|
|
128
131
|
const uniques3 = pgCore.pgTable(
|
|
@@ -155,7 +158,13 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
155
158
|
},
|
|
156
159
|
(t) => [
|
|
157
160
|
pgCore.primaryKey({ columns: [t.graphId, t.version] }),
|
|
158
|
-
pgCore.index(`${n.schemaVersions}_active_idx`).on(t.graphId, t.isActive)
|
|
161
|
+
pgCore.index(`${n.schemaVersions}_active_idx`).on(t.graphId, t.isActive),
|
|
162
|
+
// Partial unique index enforcing the "at most one active version
|
|
163
|
+
// per graph" invariant at the storage layer. Defense in depth
|
|
164
|
+
// against buggy backend implementations or out-of-band writes.
|
|
165
|
+
// Forces the deactivate-then-activate ordering used by
|
|
166
|
+
// `commitSchemaVersion` and `setActiveVersion`.
|
|
167
|
+
pgCore.uniqueIndex(`${n.schemaVersions}_one_active_per_graph_idx`).on(t.graphId).where(drizzleOrm.sql`${t.isActive} = TRUE`)
|
|
159
168
|
]
|
|
160
169
|
);
|
|
161
170
|
const embeddings3 = pgCore.pgTable(
|
|
@@ -190,12 +199,59 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
190
199
|
)
|
|
191
200
|
]
|
|
192
201
|
);
|
|
202
|
+
const indexMaterializations = pgCore.pgTable(
|
|
203
|
+
n.indexMaterializations,
|
|
204
|
+
{
|
|
205
|
+
indexName: pgCore.text("index_name").notNull(),
|
|
206
|
+
graphId: pgCore.text("graph_id").notNull(),
|
|
207
|
+
entity: pgCore.text("entity").notNull(),
|
|
208
|
+
kind: pgCore.text("kind").notNull(),
|
|
209
|
+
signature: pgCore.text("signature").notNull(),
|
|
210
|
+
schemaVersion: pgCore.integer("schema_version").notNull(),
|
|
211
|
+
materializedAt: pgCore.timestamp("materialized_at", { withTimezone: true }),
|
|
212
|
+
lastAttemptedAt: pgCore.timestamp("last_attempted_at", {
|
|
213
|
+
withTimezone: true
|
|
214
|
+
}).notNull(),
|
|
215
|
+
lastError: pgCore.text("last_error")
|
|
216
|
+
},
|
|
217
|
+
(t) => [pgCore.primaryKey({ columns: [t.indexName] })]
|
|
218
|
+
);
|
|
219
|
+
const kindRemovals = pgCore.pgTable(
|
|
220
|
+
n.kindRemovals,
|
|
221
|
+
{
|
|
222
|
+
graphId: pgCore.text("graph_id").notNull(),
|
|
223
|
+
kindName: pgCore.text("kind_name").notNull(),
|
|
224
|
+
entity: pgCore.text("entity").notNull(),
|
|
225
|
+
schemaVersion: pgCore.integer("schema_version").notNull(),
|
|
226
|
+
removedAt: pgCore.timestamp("removed_at", { withTimezone: true }),
|
|
227
|
+
lastAttemptedAt: pgCore.timestamp("last_attempted_at", {
|
|
228
|
+
withTimezone: true
|
|
229
|
+
}).notNull(),
|
|
230
|
+
lastError: pgCore.text("last_error")
|
|
231
|
+
},
|
|
232
|
+
(t) => [
|
|
233
|
+
pgCore.primaryKey({
|
|
234
|
+
columns: [t.graphId, t.kindName, t.entity, t.schemaVersion]
|
|
235
|
+
})
|
|
236
|
+
]
|
|
237
|
+
);
|
|
238
|
+
const reconciliationMarkers = pgCore.pgTable(
|
|
239
|
+
n.reconciliationMarkers,
|
|
240
|
+
{
|
|
241
|
+
graphId: pgCore.text("graph_id").notNull(),
|
|
242
|
+
reconciledToVersion: pgCore.integer("reconciled_to_version").notNull()
|
|
243
|
+
},
|
|
244
|
+
(t) => [pgCore.primaryKey({ columns: [t.graphId] })]
|
|
245
|
+
);
|
|
193
246
|
return {
|
|
194
247
|
nodes: nodes3,
|
|
195
248
|
edges: edges3,
|
|
196
249
|
uniques: uniques3,
|
|
197
250
|
schemaVersions: schemaVersions3,
|
|
198
251
|
embeddings: embeddings3,
|
|
252
|
+
indexMaterializations,
|
|
253
|
+
kindRemovals,
|
|
254
|
+
reconciliationMarkers,
|
|
199
255
|
/**
|
|
200
256
|
* The fulltext storage table is owned by the active `FulltextStrategy`,
|
|
201
257
|
* not Drizzle. Shapes vary across strategies — the default `tsvectorStrategy`
|
|
@@ -216,7 +272,10 @@ var DEFAULT_TABLE_NAMES2 = {
|
|
|
216
272
|
uniques: "typegraph_node_uniques",
|
|
217
273
|
schemaVersions: "typegraph_schema_versions",
|
|
218
274
|
embeddings: "typegraph_node_embeddings",
|
|
219
|
-
fulltext: "typegraph_node_fulltext"
|
|
275
|
+
fulltext: "typegraph_node_fulltext",
|
|
276
|
+
indexMaterializations: "typegraph_index_materializations",
|
|
277
|
+
kindRemovals: "typegraph_kind_removals",
|
|
278
|
+
reconciliationMarkers: "typegraph_reconciliation_markers"
|
|
220
279
|
};
|
|
221
280
|
function createSqliteTables(names = {}, options = {}) {
|
|
222
281
|
const n = { ...DEFAULT_TABLE_NAMES2, ...names };
|
|
@@ -246,7 +305,7 @@ function createSqliteTables(names = {}, options = {}) {
|
|
|
246
305
|
),
|
|
247
306
|
sqliteCore.index(`${n.nodes}_deleted_idx`).on(t.graphId, t.deletedAt),
|
|
248
307
|
sqliteCore.index(`${n.nodes}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),
|
|
249
|
-
...
|
|
308
|
+
...chunkJTI5WT4P_cjs.buildSqliteNodeIndexBuilders(t, indexes)
|
|
250
309
|
]
|
|
251
310
|
);
|
|
252
311
|
const edges3 = sqliteCore.sqliteTable(
|
|
@@ -305,7 +364,7 @@ function createSqliteTables(names = {}, options = {}) {
|
|
|
305
364
|
t.fromId,
|
|
306
365
|
t.validTo
|
|
307
366
|
),
|
|
308
|
-
...
|
|
367
|
+
...chunkJTI5WT4P_cjs.buildSqliteEdgeIndexBuilders(t, indexes)
|
|
309
368
|
]
|
|
310
369
|
);
|
|
311
370
|
const uniques3 = sqliteCore.sqliteTable(
|
|
@@ -338,7 +397,13 @@ function createSqliteTables(names = {}, options = {}) {
|
|
|
338
397
|
},
|
|
339
398
|
(t) => [
|
|
340
399
|
sqliteCore.primaryKey({ columns: [t.graphId, t.version] }),
|
|
341
|
-
sqliteCore.index(`${n.schemaVersions}_active_idx`).on(t.graphId, t.isActive)
|
|
400
|
+
sqliteCore.index(`${n.schemaVersions}_active_idx`).on(t.graphId, t.isActive),
|
|
401
|
+
// Partial unique index enforcing the "at most one active version
|
|
402
|
+
// per graph" invariant at the storage layer. Defense in depth
|
|
403
|
+
// against buggy backend implementations or out-of-band writes.
|
|
404
|
+
// Forces the deactivate-then-activate ordering used by
|
|
405
|
+
// `commitSchemaVersion` and `setActiveVersion`.
|
|
406
|
+
sqliteCore.uniqueIndex(`${n.schemaVersions}_one_active_per_graph_idx`).on(t.graphId).where(drizzleOrm.sql`${t.isActive} = 1`)
|
|
342
407
|
]
|
|
343
408
|
);
|
|
344
409
|
const embeddings3 = sqliteCore.sqliteTable(
|
|
@@ -377,12 +442,55 @@ function createSqliteTables(names = {}, options = {}) {
|
|
|
377
442
|
)
|
|
378
443
|
]
|
|
379
444
|
);
|
|
445
|
+
const indexMaterializations = sqliteCore.sqliteTable(
|
|
446
|
+
n.indexMaterializations,
|
|
447
|
+
{
|
|
448
|
+
indexName: sqliteCore.text("index_name").notNull(),
|
|
449
|
+
graphId: sqliteCore.text("graph_id").notNull(),
|
|
450
|
+
entity: sqliteCore.text("entity").notNull(),
|
|
451
|
+
kind: sqliteCore.text("kind").notNull(),
|
|
452
|
+
signature: sqliteCore.text("signature").notNull(),
|
|
453
|
+
schemaVersion: sqliteCore.integer("schema_version").notNull(),
|
|
454
|
+
materializedAt: sqliteCore.text("materialized_at"),
|
|
455
|
+
lastAttemptedAt: sqliteCore.text("last_attempted_at").notNull(),
|
|
456
|
+
lastError: sqliteCore.text("last_error")
|
|
457
|
+
},
|
|
458
|
+
(t) => [sqliteCore.primaryKey({ columns: [t.indexName] })]
|
|
459
|
+
);
|
|
460
|
+
const kindRemovals = sqliteCore.sqliteTable(
|
|
461
|
+
n.kindRemovals,
|
|
462
|
+
{
|
|
463
|
+
graphId: sqliteCore.text("graph_id").notNull(),
|
|
464
|
+
kindName: sqliteCore.text("kind_name").notNull(),
|
|
465
|
+
entity: sqliteCore.text("entity").notNull(),
|
|
466
|
+
schemaVersion: sqliteCore.integer("schema_version").notNull(),
|
|
467
|
+
removedAt: sqliteCore.text("removed_at"),
|
|
468
|
+
lastAttemptedAt: sqliteCore.text("last_attempted_at").notNull(),
|
|
469
|
+
lastError: sqliteCore.text("last_error")
|
|
470
|
+
},
|
|
471
|
+
(t) => [
|
|
472
|
+
sqliteCore.primaryKey({
|
|
473
|
+
columns: [t.graphId, t.kindName, t.entity, t.schemaVersion]
|
|
474
|
+
})
|
|
475
|
+
]
|
|
476
|
+
);
|
|
477
|
+
const reconciliationMarkers = sqliteCore.sqliteTable(
|
|
478
|
+
n.reconciliationMarkers,
|
|
479
|
+
{
|
|
480
|
+
graphId: sqliteCore.text("graph_id").notNull(),
|
|
481
|
+
reconciledToVersion: sqliteCore.integer("reconciled_to_version").notNull()
|
|
482
|
+
},
|
|
483
|
+
(t) => [sqliteCore.primaryKey({ columns: [t.graphId] })]
|
|
484
|
+
);
|
|
380
485
|
return {
|
|
381
486
|
nodes: nodes3,
|
|
382
487
|
edges: edges3,
|
|
383
488
|
uniques: uniques3,
|
|
384
489
|
schemaVersions: schemaVersions3,
|
|
385
490
|
embeddings: embeddings3,
|
|
491
|
+
indexMaterializations,
|
|
492
|
+
kindRemovals,
|
|
493
|
+
reconciliationMarkers,
|
|
386
494
|
/**
|
|
387
495
|
* The fulltext storage is a FTS5 virtual table which Drizzle cannot
|
|
388
496
|
* represent. DDL is emitted as raw SQL and operations query it via
|
|
@@ -448,9 +556,9 @@ function renderIndexColumn(col) {
|
|
|
448
556
|
if (col && typeof col === "object" && "name" in col) {
|
|
449
557
|
return `"${col.name}"`;
|
|
450
558
|
}
|
|
451
|
-
const
|
|
452
|
-
if (
|
|
453
|
-
return
|
|
559
|
+
const sql14 = tryInlineSql(col);
|
|
560
|
+
if (sql14 !== void 0) {
|
|
561
|
+
return sql14;
|
|
454
562
|
}
|
|
455
563
|
return "unknown";
|
|
456
564
|
}
|
|
@@ -524,7 +632,7 @@ function isSqliteTable(value) {
|
|
|
524
632
|
return typeof value === "object" && value !== null && // Drizzle tables are always objects; strings are our escape hatch.
|
|
525
633
|
typeof value !== "string";
|
|
526
634
|
}
|
|
527
|
-
function generateSqliteDDL(tables3 = tables2, fulltextStrategy =
|
|
635
|
+
function generateSqliteDDL(tables3 = tables2, fulltextStrategy = chunkJTI5WT4P_cjs.fts5Strategy) {
|
|
528
636
|
const statements = [];
|
|
529
637
|
for (const table of Object.values(tables3)) {
|
|
530
638
|
if (!isSqliteTable(table)) continue;
|
|
@@ -537,7 +645,7 @@ function generateSqliteDDL(tables3 = tables2, fulltextStrategy = chunk3JK66E3I_c
|
|
|
537
645
|
statements.push(...fulltextStrategy.generateDdl(tables3.fulltextTableName));
|
|
538
646
|
return statements;
|
|
539
647
|
}
|
|
540
|
-
function generateSqliteMigrationSQL(tables3 = tables2, fulltextStrategy =
|
|
648
|
+
function generateSqliteMigrationSQL(tables3 = tables2, fulltextStrategy = chunkJTI5WT4P_cjs.fts5Strategy) {
|
|
541
649
|
return generateSqliteDDL(tables3, fulltextStrategy).join("\n\n");
|
|
542
650
|
}
|
|
543
651
|
function getPgColumnType(column) {
|
|
@@ -622,7 +730,7 @@ function generatePgCreateIndexSQL(table) {
|
|
|
622
730
|
function isPgTable(value) {
|
|
623
731
|
return typeof value === "object" && value !== null && typeof value !== "string";
|
|
624
732
|
}
|
|
625
|
-
function generatePostgresDDL(tables3 = tables, fulltextStrategy =
|
|
733
|
+
function generatePostgresDDL(tables3 = tables, fulltextStrategy = chunkJTI5WT4P_cjs.tsvectorStrategy) {
|
|
626
734
|
const statements = [];
|
|
627
735
|
for (const table of Object.values(tables3)) {
|
|
628
736
|
if (!isPgTable(table)) continue;
|
|
@@ -635,7 +743,7 @@ function generatePostgresDDL(tables3 = tables, fulltextStrategy = chunk3JK66E3I_
|
|
|
635
743
|
statements.push(...fulltextStrategy.generateDdl(tables3.fulltextTableName));
|
|
636
744
|
return statements;
|
|
637
745
|
}
|
|
638
|
-
function generatePostgresMigrationSQL(tables3 = tables, fulltextStrategy =
|
|
746
|
+
function generatePostgresMigrationSQL(tables3 = tables, fulltextStrategy = chunkJTI5WT4P_cjs.tsvectorStrategy) {
|
|
639
747
|
const extensionSql = "-- Enable pgvector extension for vector similarity search\nCREATE EXTENSION IF NOT EXISTS vector;";
|
|
640
748
|
const ddlSql = generatePostgresDDL(tables3, fulltextStrategy).join("\n\n");
|
|
641
749
|
return `${extensionSql}
|
|
@@ -646,7 +754,7 @@ ${ddlSql}`;
|
|
|
646
754
|
// src/backend/drizzle/row-mappers.ts
|
|
647
755
|
function requireTimestamp(value, field) {
|
|
648
756
|
if (value === void 0) {
|
|
649
|
-
throw new
|
|
757
|
+
throw new chunkW5MTHMTE_cjs.DatabaseOperationError(
|
|
650
758
|
`Expected non-null ${field} timestamp`,
|
|
651
759
|
{ operation: "select", entity: "row" }
|
|
652
760
|
);
|
|
@@ -655,7 +763,7 @@ function requireTimestamp(value, field) {
|
|
|
655
763
|
}
|
|
656
764
|
function asString(value, field) {
|
|
657
765
|
if (typeof value !== "string") {
|
|
658
|
-
throw new
|
|
766
|
+
throw new chunkW5MTHMTE_cjs.DatabaseOperationError(
|
|
659
767
|
`Expected ${field} to be string, got ${typeof value}`,
|
|
660
768
|
{ operation: "select", entity: "row" }
|
|
661
769
|
);
|
|
@@ -664,7 +772,7 @@ function asString(value, field) {
|
|
|
664
772
|
}
|
|
665
773
|
function asNumber(value, field) {
|
|
666
774
|
if (typeof value !== "number") {
|
|
667
|
-
throw new
|
|
775
|
+
throw new chunkW5MTHMTE_cjs.DatabaseOperationError(
|
|
668
776
|
`Expected ${field} to be number, got ${typeof value}`,
|
|
669
777
|
{ operation: "select", entity: "row" }
|
|
670
778
|
);
|
|
@@ -695,7 +803,7 @@ var SQLITE_ROW_MAPPER_CONFIG = {
|
|
|
695
803
|
formatTimestamp: (value) => {
|
|
696
804
|
if (value === null || value === void 0) return;
|
|
697
805
|
if (typeof value !== "string") {
|
|
698
|
-
throw new
|
|
806
|
+
throw new chunkW5MTHMTE_cjs.DatabaseOperationError(
|
|
699
807
|
`Expected timestamp to be string, got ${typeof value}`,
|
|
700
808
|
{ operation: "select", entity: "row" }
|
|
701
809
|
);
|
|
@@ -704,7 +812,7 @@ var SQLITE_ROW_MAPPER_CONFIG = {
|
|
|
704
812
|
},
|
|
705
813
|
normalizeJson: (value) => {
|
|
706
814
|
if (typeof value !== "string") {
|
|
707
|
-
throw new
|
|
815
|
+
throw new chunkW5MTHMTE_cjs.DatabaseOperationError(
|
|
708
816
|
`Expected JSON column to be string, got ${typeof value}`,
|
|
709
817
|
{ operation: "select", entity: "row" }
|
|
710
818
|
);
|
|
@@ -772,6 +880,105 @@ function createSchemaVersionRowMapper(config) {
|
|
|
772
880
|
};
|
|
773
881
|
};
|
|
774
882
|
}
|
|
883
|
+
var SQLITE_INDEX_MAT_TIMESTAMPS = {
|
|
884
|
+
decode: (value) => typeof value === "string" ? value : void 0,
|
|
885
|
+
encode: (value) => value
|
|
886
|
+
};
|
|
887
|
+
var POSTGRES_INDEX_MAT_TIMESTAMPS = {
|
|
888
|
+
decode: formatPostgresTimestamp,
|
|
889
|
+
encode: (value) => new Date(value)
|
|
890
|
+
};
|
|
891
|
+
function mapMaterializationRow(row, decode) {
|
|
892
|
+
const lastAttemptedAt = decode(row.lastAttemptedAt);
|
|
893
|
+
if (lastAttemptedAt === void 0) {
|
|
894
|
+
throw new Error(
|
|
895
|
+
`materialization row missing required last_attempted_at: ${row.indexName}`
|
|
896
|
+
);
|
|
897
|
+
}
|
|
898
|
+
return {
|
|
899
|
+
indexName: row.indexName,
|
|
900
|
+
graphId: row.graphId,
|
|
901
|
+
entity: row.entity,
|
|
902
|
+
kind: row.kind,
|
|
903
|
+
signature: row.signature,
|
|
904
|
+
schemaVersion: row.schemaVersion,
|
|
905
|
+
materializedAt: decode(row.materializedAt),
|
|
906
|
+
lastAttemptedAt,
|
|
907
|
+
lastError: row.lastError ?? void 0
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
function buildMaterializationInsertValues(params, encode) {
|
|
911
|
+
return {
|
|
912
|
+
indexName: params.indexName,
|
|
913
|
+
graphId: params.graphId,
|
|
914
|
+
entity: params.entity,
|
|
915
|
+
kind: params.kind,
|
|
916
|
+
signature: params.signature,
|
|
917
|
+
schemaVersion: params.schemaVersion,
|
|
918
|
+
materializedAt: params.materializedAt === void 0 ? void 0 : encode(params.materializedAt),
|
|
919
|
+
lastAttemptedAt: encode(params.attemptedAt),
|
|
920
|
+
lastError: params.error
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
function buildMaterializationOnConflictSet(materializedAtColumn, paramsMaterializedAt) {
|
|
924
|
+
const materializedAtSet = paramsMaterializedAt === void 0 ? drizzleOrm.sql`COALESCE(excluded.${drizzleOrm.sql.identifier("materialized_at")}, ${materializedAtColumn})` : drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("materialized_at")}`;
|
|
925
|
+
return {
|
|
926
|
+
graphId: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("graph_id")}`,
|
|
927
|
+
entity: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("entity")}`,
|
|
928
|
+
kind: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("kind")}`,
|
|
929
|
+
signature: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("signature")}`,
|
|
930
|
+
schemaVersion: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("schema_version")}`,
|
|
931
|
+
materializedAt: materializedAtSet,
|
|
932
|
+
lastAttemptedAt: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("last_attempted_at")}`,
|
|
933
|
+
lastError: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("last_error")}`
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
var SQLITE_KIND_REMOVAL_TIMESTAMPS = {
|
|
937
|
+
decode: (value) => typeof value === "string" ? value : void 0,
|
|
938
|
+
encode: (value) => value
|
|
939
|
+
};
|
|
940
|
+
var POSTGRES_KIND_REMOVAL_TIMESTAMPS = {
|
|
941
|
+
decode: formatPostgresTimestamp,
|
|
942
|
+
encode: (value) => new Date(value)
|
|
943
|
+
};
|
|
944
|
+
function mapKindRemovalRow(row, decode) {
|
|
945
|
+
const lastAttemptedAt = decode(row.lastAttemptedAt);
|
|
946
|
+
if (lastAttemptedAt === void 0) {
|
|
947
|
+
throw new Error(
|
|
948
|
+
`kind removal row missing required last_attempted_at: ${row.kindName}`
|
|
949
|
+
);
|
|
950
|
+
}
|
|
951
|
+
return {
|
|
952
|
+
graphId: row.graphId,
|
|
953
|
+
kindName: row.kindName,
|
|
954
|
+
entity: row.entity,
|
|
955
|
+
schemaVersion: row.schemaVersion,
|
|
956
|
+
removedAt: decode(row.removedAt),
|
|
957
|
+
lastAttemptedAt,
|
|
958
|
+
lastError: row.lastError ?? void 0
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
function buildKindRemovalInsertValues(params, encode) {
|
|
962
|
+
return {
|
|
963
|
+
graphId: params.graphId,
|
|
964
|
+
kindName: params.kindName,
|
|
965
|
+
entity: params.entity,
|
|
966
|
+
schemaVersion: params.schemaVersion,
|
|
967
|
+
removedAt: params.removedAt === void 0 ? void 0 : encode(params.removedAt),
|
|
968
|
+
lastAttemptedAt: encode(params.attemptedAt),
|
|
969
|
+
lastError: params.error
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
function buildKindRemovalOnConflictSet(removedAtColumn, paramsRemovedAt) {
|
|
973
|
+
const removedAtSet = paramsRemovedAt === void 0 ? drizzleOrm.sql`COALESCE(excluded.${drizzleOrm.sql.identifier("removed_at")}, ${removedAtColumn})` : drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("removed_at")}`;
|
|
974
|
+
return {
|
|
975
|
+
entity: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("entity")}`,
|
|
976
|
+
schemaVersion: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("schema_version")}`,
|
|
977
|
+
removedAt: removedAtSet,
|
|
978
|
+
lastAttemptedAt: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("last_attempted_at")}`,
|
|
979
|
+
lastError: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("last_error")}`
|
|
980
|
+
};
|
|
981
|
+
}
|
|
775
982
|
|
|
776
983
|
// src/backend/drizzle/operation-backend-core.ts
|
|
777
984
|
function chunkArray(values, size) {
|
|
@@ -784,15 +991,31 @@ function chunkArray(values, size) {
|
|
|
784
991
|
}
|
|
785
992
|
return chunks;
|
|
786
993
|
}
|
|
994
|
+
function verifyExpectedActiveVersion(graphId, expected, actualActiveVersion) {
|
|
995
|
+
const expectedVersion = expected.kind === "active" ? expected.version : 0;
|
|
996
|
+
if (actualActiveVersion !== expectedVersion) {
|
|
997
|
+
throw new chunkW5MTHMTE_cjs.StaleVersionError({
|
|
998
|
+
graphId,
|
|
999
|
+
expected: expectedVersion,
|
|
1000
|
+
actual: actualActiveVersion
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
}
|
|
787
1004
|
function createCommonOperationBackend(options) {
|
|
788
1005
|
const { batchConfig, execution, operationStrategy, rowMappers } = options;
|
|
789
1006
|
const nowIso2 = options.nowIso ?? nowIso;
|
|
1007
|
+
async function readActiveVersion(graphId) {
|
|
1008
|
+
const row = await execution.execGet(
|
|
1009
|
+
operationStrategy.buildGetActiveSchema(graphId)
|
|
1010
|
+
);
|
|
1011
|
+
return row === void 0 ? 0 : rowMappers.toSchemaVersionRow(row).version;
|
|
1012
|
+
}
|
|
790
1013
|
return {
|
|
791
1014
|
async insertNode(params) {
|
|
792
1015
|
const timestamp2 = nowIso2();
|
|
793
1016
|
const query = operationStrategy.buildInsertNode(params, timestamp2);
|
|
794
1017
|
const row = await execution.execGet(query);
|
|
795
|
-
if (!row) throw new
|
|
1018
|
+
if (!row) throw new chunkW5MTHMTE_cjs.DatabaseOperationError("Insert node failed: no row returned", { operation: "insert", entity: "node" });
|
|
796
1019
|
return rowMappers.toNodeRow(row);
|
|
797
1020
|
},
|
|
798
1021
|
async insertNodeNoReturn(params) {
|
|
@@ -842,7 +1065,7 @@ function createCommonOperationBackend(options) {
|
|
|
842
1065
|
const timestamp2 = nowIso2();
|
|
843
1066
|
const query = operationStrategy.buildUpdateNode(params, timestamp2);
|
|
844
1067
|
const row = await execution.execGet(query);
|
|
845
|
-
if (!row) throw new
|
|
1068
|
+
if (!row) throw new chunkW5MTHMTE_cjs.DatabaseOperationError("Update node failed: no row returned", { operation: "update", entity: "node" });
|
|
846
1069
|
return rowMappers.toNodeRow(row);
|
|
847
1070
|
},
|
|
848
1071
|
async deleteNode(params) {
|
|
@@ -885,7 +1108,7 @@ function createCommonOperationBackend(options) {
|
|
|
885
1108
|
const timestamp2 = nowIso2();
|
|
886
1109
|
const query = operationStrategy.buildInsertEdge(params, timestamp2);
|
|
887
1110
|
const row = await execution.execGet(query);
|
|
888
|
-
if (!row) throw new
|
|
1111
|
+
if (!row) throw new chunkW5MTHMTE_cjs.DatabaseOperationError("Insert edge failed: no row returned", { operation: "insert", entity: "edge" });
|
|
889
1112
|
return rowMappers.toEdgeRow(row);
|
|
890
1113
|
},
|
|
891
1114
|
async insertEdgeNoReturn(params) {
|
|
@@ -935,7 +1158,7 @@ function createCommonOperationBackend(options) {
|
|
|
935
1158
|
const timestamp2 = nowIso2();
|
|
936
1159
|
const query = operationStrategy.buildUpdateEdge(params, timestamp2);
|
|
937
1160
|
const row = await execution.execGet(query);
|
|
938
|
-
if (!row) throw new
|
|
1161
|
+
if (!row) throw new chunkW5MTHMTE_cjs.DatabaseOperationError("Update edge failed: no row returned", { operation: "update", entity: "edge" });
|
|
939
1162
|
return rowMappers.toEdgeRow(row);
|
|
940
1163
|
},
|
|
941
1164
|
async deleteEdge(params) {
|
|
@@ -986,7 +1209,7 @@ function createCommonOperationBackend(options) {
|
|
|
986
1209
|
const query = operationStrategy.buildInsertUnique(params);
|
|
987
1210
|
const result = await execution.execGet(query);
|
|
988
1211
|
if (result && result.node_id !== params.nodeId) {
|
|
989
|
-
throw new
|
|
1212
|
+
throw new chunkW5MTHMTE_cjs.UniquenessError({
|
|
990
1213
|
constraintName: params.constraintName,
|
|
991
1214
|
kind: params.nodeKind,
|
|
992
1215
|
existingId: result.node_id,
|
|
@@ -1020,20 +1243,104 @@ function createCommonOperationBackend(options) {
|
|
|
1020
1243
|
const row = await execution.execGet(query);
|
|
1021
1244
|
return row ? rowMappers.toSchemaVersionRow(row) : void 0;
|
|
1022
1245
|
},
|
|
1023
|
-
async insertSchema(params) {
|
|
1024
|
-
const timestamp2 = nowIso2();
|
|
1025
|
-
const query = operationStrategy.buildInsertSchema(params, timestamp2);
|
|
1026
|
-
const row = await execution.execGet(query);
|
|
1027
|
-
if (!row) throw new chunkO5PST6TB_cjs.DatabaseOperationError("Insert schema failed: no row returned", { operation: "insert", entity: "schema" });
|
|
1028
|
-
return rowMappers.toSchemaVersionRow(row);
|
|
1029
|
-
},
|
|
1030
1246
|
async getSchemaVersion(graphId, version) {
|
|
1031
1247
|
const query = operationStrategy.buildGetSchemaVersion(graphId, version);
|
|
1032
1248
|
const row = await execution.execGet(query);
|
|
1033
1249
|
return row ? rowMappers.toSchemaVersionRow(row) : void 0;
|
|
1034
1250
|
},
|
|
1035
|
-
async
|
|
1036
|
-
const
|
|
1251
|
+
async commitSchemaVersion(params) {
|
|
1252
|
+
const existingRaw = await execution.execGet(
|
|
1253
|
+
operationStrategy.buildGetSchemaVersion(
|
|
1254
|
+
params.graphId,
|
|
1255
|
+
params.version
|
|
1256
|
+
)
|
|
1257
|
+
);
|
|
1258
|
+
const actualActiveVersion = await readActiveVersion(params.graphId);
|
|
1259
|
+
if (existingRaw !== void 0) {
|
|
1260
|
+
const existing = rowMappers.toSchemaVersionRow(existingRaw);
|
|
1261
|
+
if (existing.schema_hash !== params.schemaHash) {
|
|
1262
|
+
throw new chunkW5MTHMTE_cjs.SchemaContentConflictError({
|
|
1263
|
+
graphId: params.graphId,
|
|
1264
|
+
version: params.version,
|
|
1265
|
+
existingHash: existing.schema_hash,
|
|
1266
|
+
incomingHash: params.schemaHash
|
|
1267
|
+
});
|
|
1268
|
+
}
|
|
1269
|
+
if (existing.is_active) {
|
|
1270
|
+
return existing;
|
|
1271
|
+
}
|
|
1272
|
+
verifyExpectedActiveVersion(
|
|
1273
|
+
params.graphId,
|
|
1274
|
+
params.expected,
|
|
1275
|
+
actualActiveVersion
|
|
1276
|
+
);
|
|
1277
|
+
const reactivate = operationStrategy.buildSetActiveSchema(
|
|
1278
|
+
params.graphId,
|
|
1279
|
+
params.version
|
|
1280
|
+
);
|
|
1281
|
+
await execution.execRun(reactivate.deactivateAll);
|
|
1282
|
+
await execution.execRun(reactivate.activateVersion);
|
|
1283
|
+
return { ...existing, is_active: true };
|
|
1284
|
+
}
|
|
1285
|
+
verifyExpectedActiveVersion(
|
|
1286
|
+
params.graphId,
|
|
1287
|
+
params.expected,
|
|
1288
|
+
actualActiveVersion
|
|
1289
|
+
);
|
|
1290
|
+
if (params.expected.kind === "active") {
|
|
1291
|
+
const flip = operationStrategy.buildSetActiveSchema(
|
|
1292
|
+
params.graphId,
|
|
1293
|
+
params.version
|
|
1294
|
+
);
|
|
1295
|
+
await execution.execRun(flip.deactivateAll);
|
|
1296
|
+
}
|
|
1297
|
+
const timestamp2 = nowIso2();
|
|
1298
|
+
const insertQuery = operationStrategy.buildInsertSchema(
|
|
1299
|
+
{
|
|
1300
|
+
graphId: params.graphId,
|
|
1301
|
+
version: params.version,
|
|
1302
|
+
schemaHash: params.schemaHash,
|
|
1303
|
+
schemaDoc: params.schemaDoc,
|
|
1304
|
+
isActive: true
|
|
1305
|
+
},
|
|
1306
|
+
timestamp2
|
|
1307
|
+
);
|
|
1308
|
+
const insertedRaw = await execution.execGet(insertQuery);
|
|
1309
|
+
if (!insertedRaw) {
|
|
1310
|
+
throw new chunkW5MTHMTE_cjs.DatabaseOperationError(
|
|
1311
|
+
"Insert schema failed: no row returned",
|
|
1312
|
+
{ operation: "insert", entity: "schema" }
|
|
1313
|
+
);
|
|
1314
|
+
}
|
|
1315
|
+
return rowMappers.toSchemaVersionRow(insertedRaw);
|
|
1316
|
+
},
|
|
1317
|
+
async setActiveVersion(params) {
|
|
1318
|
+
const actualActiveVersion = await readActiveVersion(params.graphId);
|
|
1319
|
+
verifyExpectedActiveVersion(
|
|
1320
|
+
params.graphId,
|
|
1321
|
+
params.expected,
|
|
1322
|
+
actualActiveVersion
|
|
1323
|
+
);
|
|
1324
|
+
const targetRaw = await execution.execGet(
|
|
1325
|
+
operationStrategy.buildGetSchemaVersion(
|
|
1326
|
+
params.graphId,
|
|
1327
|
+
params.version
|
|
1328
|
+
)
|
|
1329
|
+
);
|
|
1330
|
+
if (!targetRaw) {
|
|
1331
|
+
throw new chunkW5MTHMTE_cjs.MigrationError(
|
|
1332
|
+
`Cannot activate version ${params.version}: version does not exist for graph "${params.graphId}".`,
|
|
1333
|
+
{
|
|
1334
|
+
graphId: params.graphId,
|
|
1335
|
+
fromVersion: actualActiveVersion,
|
|
1336
|
+
toVersion: params.version
|
|
1337
|
+
}
|
|
1338
|
+
);
|
|
1339
|
+
}
|
|
1340
|
+
const queries = operationStrategy.buildSetActiveSchema(
|
|
1341
|
+
params.graphId,
|
|
1342
|
+
params.version
|
|
1343
|
+
);
|
|
1037
1344
|
await execution.execRun(queries.deactivateAll);
|
|
1038
1345
|
await execution.execRun(queries.activateVersion);
|
|
1039
1346
|
},
|
|
@@ -1046,13 +1353,16 @@ function createCommonOperationBackend(options) {
|
|
|
1046
1353
|
};
|
|
1047
1354
|
}
|
|
1048
1355
|
function buildClearGraph(tables3, graphId) {
|
|
1049
|
-
const fulltext =
|
|
1356
|
+
const fulltext = chunkJTI5WT4P_cjs.quotedTableName(tables3.fulltextTableName);
|
|
1050
1357
|
return [
|
|
1051
1358
|
drizzleOrm.sql`DELETE FROM ${fulltext} WHERE "graph_id" = ${graphId}`,
|
|
1052
1359
|
drizzleOrm.sql`DELETE FROM ${tables3.embeddings} WHERE ${tables3.embeddings.graphId} = ${graphId}`,
|
|
1053
1360
|
drizzleOrm.sql`DELETE FROM ${tables3.uniques} WHERE ${tables3.uniques.graphId} = ${graphId}`,
|
|
1054
1361
|
drizzleOrm.sql`DELETE FROM ${tables3.edges} WHERE ${tables3.edges.graphId} = ${graphId}`,
|
|
1055
1362
|
drizzleOrm.sql`DELETE FROM ${tables3.nodes} WHERE ${tables3.nodes.graphId} = ${graphId}`,
|
|
1363
|
+
drizzleOrm.sql`DELETE FROM ${tables3.indexMaterializations} WHERE ${tables3.indexMaterializations.graphId} = ${graphId}`,
|
|
1364
|
+
drizzleOrm.sql`DELETE FROM ${tables3.kindRemovals} WHERE ${tables3.kindRemovals.graphId} = ${graphId}`,
|
|
1365
|
+
drizzleOrm.sql`DELETE FROM ${tables3.reconciliationMarkers} WHERE ${tables3.reconciliationMarkers.graphId} = ${graphId}`,
|
|
1056
1366
|
drizzleOrm.sql`DELETE FROM ${tables3.schemaVersions} WHERE ${tables3.schemaVersions.graphId} = ${graphId}`
|
|
1057
1367
|
];
|
|
1058
1368
|
}
|
|
@@ -1193,13 +1503,13 @@ function buildCountEdgesByKind(tables3, params) {
|
|
|
1193
1503
|
function buildInsertEdge(tables3, params, timestamp2) {
|
|
1194
1504
|
const { edges: edges3 } = tables3;
|
|
1195
1505
|
const propsJson = JSON.stringify(params.props);
|
|
1196
|
-
const columns =
|
|
1506
|
+
const columns = chunkJTI5WT4P_cjs.edgeColumnList(edges3);
|
|
1197
1507
|
return drizzleOrm.sql`
|
|
1198
1508
|
INSERT INTO ${edges3} (${columns})
|
|
1199
1509
|
VALUES (
|
|
1200
1510
|
${params.graphId}, ${params.id}, ${params.kind},
|
|
1201
1511
|
${params.fromKind}, ${params.fromId}, ${params.toKind}, ${params.toId},
|
|
1202
|
-
${propsJson}, ${
|
|
1512
|
+
${propsJson}, ${chunkJTI5WT4P_cjs.sqlNull(params.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(params.validTo)},
|
|
1203
1513
|
${timestamp2}, ${timestamp2}
|
|
1204
1514
|
)
|
|
1205
1515
|
RETURNING *
|
|
@@ -1208,23 +1518,23 @@ function buildInsertEdge(tables3, params, timestamp2) {
|
|
|
1208
1518
|
function buildInsertEdgeNoReturn(tables3, params, timestamp2) {
|
|
1209
1519
|
const { edges: edges3 } = tables3;
|
|
1210
1520
|
const propsJson = JSON.stringify(params.props);
|
|
1211
|
-
const columns =
|
|
1521
|
+
const columns = chunkJTI5WT4P_cjs.edgeColumnList(edges3);
|
|
1212
1522
|
return drizzleOrm.sql`
|
|
1213
1523
|
INSERT INTO ${edges3} (${columns})
|
|
1214
1524
|
VALUES (
|
|
1215
1525
|
${params.graphId}, ${params.id}, ${params.kind},
|
|
1216
1526
|
${params.fromKind}, ${params.fromId}, ${params.toKind}, ${params.toId},
|
|
1217
|
-
${propsJson}, ${
|
|
1527
|
+
${propsJson}, ${chunkJTI5WT4P_cjs.sqlNull(params.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(params.validTo)},
|
|
1218
1528
|
${timestamp2}, ${timestamp2}
|
|
1219
1529
|
)
|
|
1220
1530
|
`;
|
|
1221
1531
|
}
|
|
1222
1532
|
function buildInsertEdgesBatch(tables3, params, timestamp2) {
|
|
1223
1533
|
const { edges: edges3 } = tables3;
|
|
1224
|
-
const columns =
|
|
1534
|
+
const columns = chunkJTI5WT4P_cjs.edgeColumnList(edges3);
|
|
1225
1535
|
const values = params.map((edgeParams) => {
|
|
1226
1536
|
const propsJson = JSON.stringify(edgeParams.props);
|
|
1227
|
-
return drizzleOrm.sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${
|
|
1537
|
+
return drizzleOrm.sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${chunkJTI5WT4P_cjs.sqlNull(edgeParams.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(edgeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1228
1538
|
});
|
|
1229
1539
|
return drizzleOrm.sql`
|
|
1230
1540
|
INSERT INTO ${edges3} (${columns})
|
|
@@ -1233,10 +1543,10 @@ function buildInsertEdgesBatch(tables3, params, timestamp2) {
|
|
|
1233
1543
|
}
|
|
1234
1544
|
function buildInsertEdgesBatchReturning(tables3, params, timestamp2) {
|
|
1235
1545
|
const { edges: edges3 } = tables3;
|
|
1236
|
-
const columns =
|
|
1546
|
+
const columns = chunkJTI5WT4P_cjs.edgeColumnList(edges3);
|
|
1237
1547
|
const values = params.map((edgeParams) => {
|
|
1238
1548
|
const propsJson = JSON.stringify(edgeParams.props);
|
|
1239
|
-
return drizzleOrm.sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${
|
|
1549
|
+
return drizzleOrm.sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${chunkJTI5WT4P_cjs.sqlNull(edgeParams.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(edgeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1240
1550
|
});
|
|
1241
1551
|
return drizzleOrm.sql`
|
|
1242
1552
|
INSERT INTO ${edges3} (${columns})
|
|
@@ -1268,14 +1578,14 @@ function buildUpdateEdge(tables3, params, timestamp2) {
|
|
|
1268
1578
|
const { edges: edges3 } = tables3;
|
|
1269
1579
|
const propsJson = JSON.stringify(params.props);
|
|
1270
1580
|
const setParts = [
|
|
1271
|
-
drizzleOrm.sql`${
|
|
1272
|
-
drizzleOrm.sql`${
|
|
1581
|
+
drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(edges3.props)} = ${propsJson}`,
|
|
1582
|
+
drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(edges3.updatedAt)} = ${timestamp2}`
|
|
1273
1583
|
];
|
|
1274
1584
|
if (params.validTo !== void 0) {
|
|
1275
|
-
setParts.push(drizzleOrm.sql`${
|
|
1585
|
+
setParts.push(drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(edges3.validTo)} = ${params.validTo}`);
|
|
1276
1586
|
}
|
|
1277
1587
|
if (params.clearDeleted) {
|
|
1278
|
-
setParts.push(drizzleOrm.sql`${
|
|
1588
|
+
setParts.push(drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(edges3.deletedAt)} = NULL`);
|
|
1279
1589
|
}
|
|
1280
1590
|
const setClause = drizzleOrm.sql.join(setParts, drizzleOrm.sql`, `);
|
|
1281
1591
|
if (params.clearDeleted) {
|
|
@@ -1300,7 +1610,7 @@ function buildDeleteEdge(tables3, params, timestamp2) {
|
|
|
1300
1610
|
const { edges: edges3 } = tables3;
|
|
1301
1611
|
return drizzleOrm.sql`
|
|
1302
1612
|
UPDATE ${edges3}
|
|
1303
|
-
SET ${
|
|
1613
|
+
SET ${chunkJTI5WT4P_cjs.quotedColumn(edges3.deletedAt)} = ${timestamp2}
|
|
1304
1614
|
WHERE ${edges3.graphId} = ${params.graphId}
|
|
1305
1615
|
AND ${edges3.id} = ${params.id}
|
|
1306
1616
|
AND ${edges3.deletedAt} IS NULL
|
|
@@ -1387,7 +1697,7 @@ function resolveMode(mode) {
|
|
|
1387
1697
|
function buildFulltextSearch(tableName, params, strategy) {
|
|
1388
1698
|
assertValidSearchParams(params);
|
|
1389
1699
|
const mode = resolveMode(params.mode);
|
|
1390
|
-
const table =
|
|
1700
|
+
const table = chunkJTI5WT4P_cjs.quotedTableName(tableName);
|
|
1391
1701
|
const matchCondition = strategy.matchCondition(
|
|
1392
1702
|
tableName,
|
|
1393
1703
|
params.query,
|
|
@@ -1438,12 +1748,12 @@ function assertValidSearchParams(params) {
|
|
|
1438
1748
|
function buildInsertNode(tables3, params, timestamp2) {
|
|
1439
1749
|
const { nodes: nodes3 } = tables3;
|
|
1440
1750
|
const propsJson = JSON.stringify(params.props);
|
|
1441
|
-
const columns =
|
|
1751
|
+
const columns = chunkJTI5WT4P_cjs.nodeColumnList(nodes3);
|
|
1442
1752
|
return drizzleOrm.sql`
|
|
1443
1753
|
INSERT INTO ${nodes3} (${columns})
|
|
1444
1754
|
VALUES (
|
|
1445
1755
|
${params.graphId}, ${params.kind}, ${params.id}, ${propsJson},
|
|
1446
|
-
1, ${
|
|
1756
|
+
1, ${chunkJTI5WT4P_cjs.sqlNull(params.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(params.validTo)},
|
|
1447
1757
|
${timestamp2}, ${timestamp2}
|
|
1448
1758
|
)
|
|
1449
1759
|
RETURNING *
|
|
@@ -1452,22 +1762,22 @@ function buildInsertNode(tables3, params, timestamp2) {
|
|
|
1452
1762
|
function buildInsertNodeNoReturn(tables3, params, timestamp2) {
|
|
1453
1763
|
const { nodes: nodes3 } = tables3;
|
|
1454
1764
|
const propsJson = JSON.stringify(params.props);
|
|
1455
|
-
const columns =
|
|
1765
|
+
const columns = chunkJTI5WT4P_cjs.nodeColumnList(nodes3);
|
|
1456
1766
|
return drizzleOrm.sql`
|
|
1457
1767
|
INSERT INTO ${nodes3} (${columns})
|
|
1458
1768
|
VALUES (
|
|
1459
1769
|
${params.graphId}, ${params.kind}, ${params.id}, ${propsJson},
|
|
1460
|
-
1, ${
|
|
1770
|
+
1, ${chunkJTI5WT4P_cjs.sqlNull(params.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(params.validTo)},
|
|
1461
1771
|
${timestamp2}, ${timestamp2}
|
|
1462
1772
|
)
|
|
1463
1773
|
`;
|
|
1464
1774
|
}
|
|
1465
1775
|
function buildInsertNodesBatch(tables3, params, timestamp2) {
|
|
1466
1776
|
const { nodes: nodes3 } = tables3;
|
|
1467
|
-
const columns =
|
|
1777
|
+
const columns = chunkJTI5WT4P_cjs.nodeColumnList(nodes3);
|
|
1468
1778
|
const values = params.map((nodeParams) => {
|
|
1469
1779
|
const propsJson = JSON.stringify(nodeParams.props);
|
|
1470
|
-
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${
|
|
1780
|
+
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${chunkJTI5WT4P_cjs.sqlNull(nodeParams.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1471
1781
|
});
|
|
1472
1782
|
return drizzleOrm.sql`
|
|
1473
1783
|
INSERT INTO ${nodes3} (${columns})
|
|
@@ -1476,10 +1786,10 @@ function buildInsertNodesBatch(tables3, params, timestamp2) {
|
|
|
1476
1786
|
}
|
|
1477
1787
|
function buildInsertNodesBatchReturning(tables3, params, timestamp2) {
|
|
1478
1788
|
const { nodes: nodes3 } = tables3;
|
|
1479
|
-
const columns =
|
|
1789
|
+
const columns = chunkJTI5WT4P_cjs.nodeColumnList(nodes3);
|
|
1480
1790
|
const values = params.map((nodeParams) => {
|
|
1481
1791
|
const propsJson = JSON.stringify(nodeParams.props);
|
|
1482
|
-
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${
|
|
1792
|
+
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${chunkJTI5WT4P_cjs.sqlNull(nodeParams.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1483
1793
|
});
|
|
1484
1794
|
return drizzleOrm.sql`
|
|
1485
1795
|
INSERT INTO ${nodes3} (${columns})
|
|
@@ -1513,19 +1823,19 @@ function buildUpdateNode(tables3, params, timestamp2) {
|
|
|
1513
1823
|
const { nodes: nodes3 } = tables3;
|
|
1514
1824
|
const propsJson = JSON.stringify(params.props);
|
|
1515
1825
|
const setParts = [
|
|
1516
|
-
drizzleOrm.sql`${
|
|
1517
|
-
drizzleOrm.sql`${
|
|
1826
|
+
drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(nodes3.props)} = ${propsJson}`,
|
|
1827
|
+
drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(nodes3.updatedAt)} = ${timestamp2}`
|
|
1518
1828
|
];
|
|
1519
1829
|
if (params.incrementVersion) {
|
|
1520
1830
|
setParts.push(
|
|
1521
|
-
drizzleOrm.sql`${
|
|
1831
|
+
drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(nodes3.version)} = ${chunkJTI5WT4P_cjs.quotedColumn(nodes3.version)} + 1`
|
|
1522
1832
|
);
|
|
1523
1833
|
}
|
|
1524
1834
|
if (params.validTo !== void 0) {
|
|
1525
|
-
setParts.push(drizzleOrm.sql`${
|
|
1835
|
+
setParts.push(drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(nodes3.validTo)} = ${params.validTo}`);
|
|
1526
1836
|
}
|
|
1527
1837
|
if (params.clearDeleted) {
|
|
1528
|
-
setParts.push(drizzleOrm.sql`${
|
|
1838
|
+
setParts.push(drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(nodes3.deletedAt)} = NULL`);
|
|
1529
1839
|
}
|
|
1530
1840
|
const setClause = drizzleOrm.sql.join(setParts, drizzleOrm.sql`, `);
|
|
1531
1841
|
if (params.clearDeleted) {
|
|
@@ -1552,7 +1862,7 @@ function buildDeleteNode(tables3, params, timestamp2) {
|
|
|
1552
1862
|
const { nodes: nodes3 } = tables3;
|
|
1553
1863
|
return drizzleOrm.sql`
|
|
1554
1864
|
UPDATE ${nodes3}
|
|
1555
|
-
SET ${
|
|
1865
|
+
SET ${chunkJTI5WT4P_cjs.quotedColumn(nodes3.deletedAt)} = ${timestamp2}
|
|
1556
1866
|
WHERE ${nodes3.graphId} = ${params.graphId}
|
|
1557
1867
|
AND ${nodes3.kind} = ${params.kind}
|
|
1558
1868
|
AND ${nodes3.id} = ${params.id}
|
|
@@ -1619,12 +1929,12 @@ function buildSetActiveSchema(tables3, graphId, version, dialect = "sqlite") {
|
|
|
1619
1929
|
const strategy = SCHEMA_DIALECT_STRATEGIES[dialect];
|
|
1620
1930
|
const deactivateAll = drizzleOrm.sql`
|
|
1621
1931
|
UPDATE ${schemaVersions3}
|
|
1622
|
-
SET ${
|
|
1932
|
+
SET ${chunkJTI5WT4P_cjs.quotedColumn(schemaVersions3.isActive)} = ${strategy.booleanLiteral(false)}
|
|
1623
1933
|
WHERE ${schemaVersions3.graphId} = ${graphId}
|
|
1624
1934
|
`;
|
|
1625
1935
|
const activateVersion = drizzleOrm.sql`
|
|
1626
1936
|
UPDATE ${schemaVersions3}
|
|
1627
|
-
SET ${
|
|
1937
|
+
SET ${chunkJTI5WT4P_cjs.quotedColumn(schemaVersions3.isActive)} = ${strategy.booleanLiteral(true)}
|
|
1628
1938
|
WHERE ${schemaVersions3.graphId} = ${graphId}
|
|
1629
1939
|
AND ${schemaVersions3.version} = ${version}
|
|
1630
1940
|
`;
|
|
@@ -1642,22 +1952,22 @@ function buildInsertUniqueSqlite(tables3, params) {
|
|
|
1642
1952
|
)
|
|
1643
1953
|
ON CONFLICT (${conflictColumns})
|
|
1644
1954
|
DO UPDATE SET
|
|
1645
|
-
${
|
|
1646
|
-
WHEN ${
|
|
1647
|
-
WHEN ${
|
|
1648
|
-
ELSE ${
|
|
1955
|
+
${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} = CASE
|
|
1956
|
+
WHEN ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.nodeId}
|
|
1957
|
+
WHEN ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.nodeId}
|
|
1958
|
+
ELSE ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)}
|
|
1649
1959
|
END,
|
|
1650
|
-
${
|
|
1651
|
-
WHEN ${
|
|
1652
|
-
WHEN ${
|
|
1653
|
-
ELSE ${
|
|
1960
|
+
${chunkJTI5WT4P_cjs.quotedColumn(uniques3.concreteKind)} = CASE
|
|
1961
|
+
WHEN ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.concreteKind}
|
|
1962
|
+
WHEN ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.concreteKind}
|
|
1963
|
+
ELSE ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.concreteKind)}
|
|
1654
1964
|
END,
|
|
1655
|
-
${
|
|
1656
|
-
WHEN ${
|
|
1657
|
-
WHEN ${
|
|
1658
|
-
ELSE ${
|
|
1965
|
+
${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)} = CASE
|
|
1966
|
+
WHEN ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN NULL
|
|
1967
|
+
WHEN ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN NULL
|
|
1968
|
+
ELSE ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)}
|
|
1659
1969
|
END
|
|
1660
|
-
RETURNING ${
|
|
1970
|
+
RETURNING ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} as node_id
|
|
1661
1971
|
`;
|
|
1662
1972
|
}
|
|
1663
1973
|
function buildInsertUniquePostgres(tables3, params) {
|
|
@@ -1674,22 +1984,22 @@ function buildInsertUniquePostgres(tables3, params) {
|
|
|
1674
1984
|
)
|
|
1675
1985
|
ON CONFLICT (${conflictColumns})
|
|
1676
1986
|
DO UPDATE SET
|
|
1677
|
-
${
|
|
1987
|
+
${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} = CASE
|
|
1678
1988
|
WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.nodeId}
|
|
1679
1989
|
WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.nodeId}
|
|
1680
1990
|
ELSE ${existingColumn(uniques3.nodeId)}
|
|
1681
1991
|
END,
|
|
1682
|
-
${
|
|
1992
|
+
${chunkJTI5WT4P_cjs.quotedColumn(uniques3.concreteKind)} = CASE
|
|
1683
1993
|
WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.concreteKind}
|
|
1684
1994
|
WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.concreteKind}
|
|
1685
1995
|
ELSE ${existingColumn(uniques3.concreteKind)}
|
|
1686
1996
|
END,
|
|
1687
|
-
${
|
|
1997
|
+
${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)} = CASE
|
|
1688
1998
|
WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN NULL
|
|
1689
1999
|
WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN NULL
|
|
1690
2000
|
ELSE ${existingColumn(uniques3.deletedAt)}
|
|
1691
2001
|
END
|
|
1692
|
-
RETURNING ${
|
|
2002
|
+
RETURNING ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} as node_id
|
|
1693
2003
|
`;
|
|
1694
2004
|
}
|
|
1695
2005
|
var UNIQUE_INSERT_BUILDERS = {
|
|
@@ -1704,7 +2014,7 @@ function buildDeleteUnique(tables3, params, timestamp2) {
|
|
|
1704
2014
|
const { uniques: uniques3 } = tables3;
|
|
1705
2015
|
return drizzleOrm.sql`
|
|
1706
2016
|
UPDATE ${uniques3}
|
|
1707
|
-
SET ${
|
|
2017
|
+
SET ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)} = ${timestamp2}
|
|
1708
2018
|
WHERE ${uniques3.graphId} = ${params.graphId}
|
|
1709
2019
|
AND ${uniques3.nodeKind} = ${params.nodeKind}
|
|
1710
2020
|
AND ${uniques3.constraintName} = ${params.constraintName}
|
|
@@ -2178,11 +2488,11 @@ function generateVectorIndexName(graphId, nodeKind, fieldPath, metric = "cosine"
|
|
|
2178
2488
|
metric
|
|
2179
2489
|
];
|
|
2180
2490
|
const name = parts.join("_");
|
|
2181
|
-
if (name.length <=
|
|
2491
|
+
if (name.length <= chunkCTHNVU6K_cjs.MAX_PG_IDENTIFIER_LENGTH) {
|
|
2182
2492
|
return name;
|
|
2183
2493
|
}
|
|
2184
2494
|
const hash = shortHash(name);
|
|
2185
|
-
const truncated = name.slice(0,
|
|
2495
|
+
const truncated = name.slice(0, chunkCTHNVU6K_cjs.MAX_PG_IDENTIFIER_LENGTH - 1 - hash.length);
|
|
2186
2496
|
return `${truncated}_${hash}`;
|
|
2187
2497
|
}
|
|
2188
2498
|
function getOperatorClass(metric) {
|
|
@@ -2231,9 +2541,10 @@ async function createPostgresVectorIndex(db, options) {
|
|
|
2231
2541
|
const safeNodeKind = escapeSqlString(nodeKind);
|
|
2232
2542
|
const safeFieldPath = escapeSqlString(fieldPath);
|
|
2233
2543
|
let indexSql;
|
|
2544
|
+
const concurrentClause = options.concurrent === true ? "CONCURRENTLY " : "";
|
|
2234
2545
|
if (indexType === "hnsw") {
|
|
2235
2546
|
indexSql = drizzleOrm.sql.raw(`
|
|
2236
|
-
CREATE INDEX IF NOT EXISTS ${indexName}
|
|
2547
|
+
CREATE INDEX ${concurrentClause}IF NOT EXISTS ${indexName}
|
|
2237
2548
|
ON ${quotedEmbeddingsTableName}
|
|
2238
2549
|
USING hnsw ((embedding::vector(${dimensions})) ${operatorClass})
|
|
2239
2550
|
WITH (m = ${hnswM}, ef_construction = ${hnswEfConstruction})
|
|
@@ -2243,7 +2554,7 @@ async function createPostgresVectorIndex(db, options) {
|
|
|
2243
2554
|
`);
|
|
2244
2555
|
} else if (indexType === "ivfflat") {
|
|
2245
2556
|
indexSql = drizzleOrm.sql.raw(`
|
|
2246
|
-
CREATE INDEX IF NOT EXISTS ${indexName}
|
|
2557
|
+
CREATE INDEX ${concurrentClause}IF NOT EXISTS ${indexName}
|
|
2247
2558
|
ON ${quotedEmbeddingsTableName}
|
|
2248
2559
|
USING ivfflat ((embedding::vector(${dimensions})) ${operatorClass})
|
|
2249
2560
|
WITH (lists = ${ivfflatLists})
|
|
@@ -2340,8 +2651,16 @@ function compileQueryWithDialect(db, query, backendName) {
|
|
|
2340
2651
|
return compiler.sqlToQuery(query);
|
|
2341
2652
|
}
|
|
2342
2653
|
|
|
2654
|
+
exports.POSTGRES_INDEX_MAT_TIMESTAMPS = POSTGRES_INDEX_MAT_TIMESTAMPS;
|
|
2655
|
+
exports.POSTGRES_KIND_REMOVAL_TIMESTAMPS = POSTGRES_KIND_REMOVAL_TIMESTAMPS;
|
|
2343
2656
|
exports.POSTGRES_ROW_MAPPER_CONFIG = POSTGRES_ROW_MAPPER_CONFIG;
|
|
2657
|
+
exports.SQLITE_INDEX_MAT_TIMESTAMPS = SQLITE_INDEX_MAT_TIMESTAMPS;
|
|
2658
|
+
exports.SQLITE_KIND_REMOVAL_TIMESTAMPS = SQLITE_KIND_REMOVAL_TIMESTAMPS;
|
|
2344
2659
|
exports.SQLITE_ROW_MAPPER_CONFIG = SQLITE_ROW_MAPPER_CONFIG;
|
|
2660
|
+
exports.buildKindRemovalInsertValues = buildKindRemovalInsertValues;
|
|
2661
|
+
exports.buildKindRemovalOnConflictSet = buildKindRemovalOnConflictSet;
|
|
2662
|
+
exports.buildMaterializationInsertValues = buildMaterializationInsertValues;
|
|
2663
|
+
exports.buildMaterializationOnConflictSet = buildMaterializationOnConflictSet;
|
|
2345
2664
|
exports.compileQueryWithDialect = compileQueryWithDialect;
|
|
2346
2665
|
exports.createCommonOperationBackend = createCommonOperationBackend;
|
|
2347
2666
|
exports.createEdgeRowMapper = createEdgeRowMapper;
|
|
@@ -2361,12 +2680,16 @@ exports.edges2 = edges2;
|
|
|
2361
2680
|
exports.embeddings = embeddings;
|
|
2362
2681
|
exports.embeddings2 = embeddings2;
|
|
2363
2682
|
exports.formatPostgresTimestamp = formatPostgresTimestamp;
|
|
2683
|
+
exports.generatePgCreateTableSQL = generatePgCreateTableSQL;
|
|
2364
2684
|
exports.generatePostgresDDL = generatePostgresDDL;
|
|
2365
2685
|
exports.generatePostgresMigrationSQL = generatePostgresMigrationSQL;
|
|
2686
|
+
exports.generateSqliteCreateTableSQL = generateSqliteCreateTableSQL;
|
|
2366
2687
|
exports.generateSqliteDDL = generateSqliteDDL;
|
|
2367
2688
|
exports.generateSqliteMigrationSQL = generateSqliteMigrationSQL;
|
|
2368
2689
|
exports.generateVectorIndexName = generateVectorIndexName;
|
|
2369
2690
|
exports.getOrCreateLru = getOrCreateLru;
|
|
2691
|
+
exports.mapKindRemovalRow = mapKindRemovalRow;
|
|
2692
|
+
exports.mapMaterializationRow = mapMaterializationRow;
|
|
2370
2693
|
exports.nodes = nodes;
|
|
2371
2694
|
exports.nodes2 = nodes2;
|
|
2372
2695
|
exports.nowIso = nowIso;
|
|
@@ -2376,5 +2699,5 @@ exports.tables = tables;
|
|
|
2376
2699
|
exports.tables2 = tables2;
|
|
2377
2700
|
exports.uniques = uniques;
|
|
2378
2701
|
exports.uniques2 = uniques2;
|
|
2379
|
-
//# sourceMappingURL=chunk-
|
|
2380
|
-
//# sourceMappingURL=chunk-
|
|
2702
|
+
//# sourceMappingURL=chunk-O2P3KAUT.cjs.map
|
|
2703
|
+
//# sourceMappingURL=chunk-O2P3KAUT.cjs.map
|