@nicia-ai/typegraph 0.24.1 → 0.25.1
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 +226 -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 +195 -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-7V335GHG.cjs +112 -0
- package/dist/chunk-7V335GHG.cjs.map +1 -0
- package/dist/chunk-AAA2CR3P.js +2628 -0
- package/dist/chunk-AAA2CR3P.js.map +1 -0
- package/dist/{chunk-QOLTW7OZ.js → chunk-CLEUFN2K.js} +195 -13
- package/dist/chunk-CLEUFN2K.js.map +1 -0
- package/dist/{chunk-OVJ2BE5Q.cjs → chunk-CLGC7AQ2.cjs} +215 -33
- package/dist/chunk-CLGC7AQ2.cjs.map +1 -0
- package/dist/{chunk-GUTQTMOV.js → chunk-CPFR3O7L.js} +2 -2
- package/dist/chunk-CPFR3O7L.js.map +1 -0
- package/dist/{chunk-5HVDOPZU.cjs → chunk-CQVNGKU7.cjs} +452 -104
- package/dist/chunk-CQVNGKU7.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-3JK66E3I.cjs → chunk-JTI5WT4P.cjs} +630 -59
- package/dist/chunk-JTI5WT4P.cjs.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-SUHW2UYL.cjs → chunk-OECDVACY.cjs} +2 -2
- package/dist/chunk-OECDVACY.cjs.map +1 -0
- package/dist/{chunk-EYELZHKY.js → chunk-OOS2RKRH.js} +5 -140
- package/dist/chunk-OOS2RKRH.js.map +1 -0
- package/dist/{chunk-EY4LBX3F.js → chunk-PSKUWVCB.js} +373 -38
- package/dist/chunk-PSKUWVCB.js.map +1 -0
- package/dist/chunk-QMQYK3IF.cjs +2680 -0
- package/dist/chunk-QMQYK3IF.cjs.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-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/{ddl-B_H8JM-E.d.cts → ddl-BqMmpNor.d.ts} +1328 -283
- package/dist/{ddl-1tFIvt9V.d.ts → ddl-Bwjh8Hff.d.cts} +1328 -283
- 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-Vkz28eAC.d.cts → manager-Cy3dhwYO.d.cts} +194 -6
- package/dist/{manager-nIhmttD-.d.ts → manager-sZkU2VPC.d.ts} +194 -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-BhFswiAR.d.cts} +837 -120
- package/dist/{sqlite-SUxbZqfy.d.ts → sqlite-h6dta1IJ.d.ts} +837 -120
- package/dist/{store-CpvwTMxV.d.cts → store-BS_hehiz.d.ts} +659 -23
- package/dist/{store-U3i2tUch.d.ts → store-CkCvqRUf.d.cts} +659 -23
- package/dist/{types-yH4_p0XB.d.cts → types-BpgACExN.d.cts} +3 -2
- package/dist/{types-qYFZ9SqD.d.ts → types-Bz-Pi681.d.ts} +3 -2
- package/dist/types-DptZHe-l.d.ts +2132 -0
- package/dist/types-WF5ItKQu.d.cts +2132 -0
- package/dist/where-C40InMIp.d.ts +11 -0
- package/dist/where-DZYMiXVq.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,12 +1,18 @@
|
|
|
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
|
+
var regconfig = pgCore.customType({
|
|
11
|
+
dataType: () => "regconfig"
|
|
12
|
+
});
|
|
13
|
+
var tsvector = pgCore.customType({
|
|
14
|
+
dataType: () => "tsvector"
|
|
15
|
+
});
|
|
10
16
|
var vector = pgCore.customType({
|
|
11
17
|
dataType(config) {
|
|
12
18
|
return config?.dimensions ? `vector(${config.dimensions})` : "vector";
|
|
@@ -33,7 +39,10 @@ var DEFAULT_TABLE_NAMES = {
|
|
|
33
39
|
uniques: "typegraph_node_uniques",
|
|
34
40
|
schemaVersions: "typegraph_schema_versions",
|
|
35
41
|
embeddings: "typegraph_node_embeddings",
|
|
36
|
-
fulltext: "typegraph_node_fulltext"
|
|
42
|
+
fulltext: "typegraph_node_fulltext",
|
|
43
|
+
indexMaterializations: "typegraph_index_materializations",
|
|
44
|
+
kindRemovals: "typegraph_kind_removals",
|
|
45
|
+
reconciliationMarkers: "typegraph_reconciliation_markers"
|
|
37
46
|
};
|
|
38
47
|
function createPostgresTables(names = {}, options = {}) {
|
|
39
48
|
const n = { ...DEFAULT_TABLE_NAMES, ...names };
|
|
@@ -63,7 +72,7 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
63
72
|
),
|
|
64
73
|
pgCore.index(`${n.nodes}_deleted_idx`).on(t.graphId, t.deletedAt),
|
|
65
74
|
pgCore.index(`${n.nodes}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),
|
|
66
|
-
...
|
|
75
|
+
...chunkJTI5WT4P_cjs.buildPostgresNodeIndexBuilders(t, indexes)
|
|
67
76
|
]
|
|
68
77
|
);
|
|
69
78
|
const edges3 = pgCore.pgTable(
|
|
@@ -122,7 +131,7 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
122
131
|
t.fromId,
|
|
123
132
|
t.validTo
|
|
124
133
|
),
|
|
125
|
-
...
|
|
134
|
+
...chunkJTI5WT4P_cjs.buildPostgresEdgeIndexBuilders(t, indexes)
|
|
126
135
|
]
|
|
127
136
|
);
|
|
128
137
|
const uniques3 = pgCore.pgTable(
|
|
@@ -155,7 +164,13 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
155
164
|
},
|
|
156
165
|
(t) => [
|
|
157
166
|
pgCore.primaryKey({ columns: [t.graphId, t.version] }),
|
|
158
|
-
pgCore.index(`${n.schemaVersions}_active_idx`).on(t.graphId, t.isActive)
|
|
167
|
+
pgCore.index(`${n.schemaVersions}_active_idx`).on(t.graphId, t.isActive),
|
|
168
|
+
// Partial unique index enforcing the "at most one active version
|
|
169
|
+
// per graph" invariant at the storage layer. Defense in depth
|
|
170
|
+
// against buggy backend implementations or out-of-band writes.
|
|
171
|
+
// Forces the deactivate-then-activate ordering used by
|
|
172
|
+
// `commitSchemaVersion` and `setActiveVersion`.
|
|
173
|
+
pgCore.uniqueIndex(`${n.schemaVersions}_one_active_per_graph_idx`).on(t.graphId).where(drizzleOrm.sql`${t.isActive} = TRUE`)
|
|
159
174
|
]
|
|
160
175
|
);
|
|
161
176
|
const embeddings3 = pgCore.pgTable(
|
|
@@ -190,33 +205,99 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
190
205
|
)
|
|
191
206
|
]
|
|
192
207
|
);
|
|
208
|
+
const indexMaterializations = pgCore.pgTable(
|
|
209
|
+
n.indexMaterializations,
|
|
210
|
+
{
|
|
211
|
+
indexName: pgCore.text("index_name").notNull(),
|
|
212
|
+
graphId: pgCore.text("graph_id").notNull(),
|
|
213
|
+
entity: pgCore.text("entity").notNull(),
|
|
214
|
+
kind: pgCore.text("kind").notNull(),
|
|
215
|
+
signature: pgCore.text("signature").notNull(),
|
|
216
|
+
schemaVersion: pgCore.integer("schema_version").notNull(),
|
|
217
|
+
materializedAt: pgCore.timestamp("materialized_at", { withTimezone: true }),
|
|
218
|
+
lastAttemptedAt: pgCore.timestamp("last_attempted_at", {
|
|
219
|
+
withTimezone: true
|
|
220
|
+
}).notNull(),
|
|
221
|
+
lastError: pgCore.text("last_error")
|
|
222
|
+
},
|
|
223
|
+
(t) => [pgCore.primaryKey({ columns: [t.indexName] })]
|
|
224
|
+
);
|
|
225
|
+
const kindRemovals = pgCore.pgTable(
|
|
226
|
+
n.kindRemovals,
|
|
227
|
+
{
|
|
228
|
+
graphId: pgCore.text("graph_id").notNull(),
|
|
229
|
+
kindName: pgCore.text("kind_name").notNull(),
|
|
230
|
+
entity: pgCore.text("entity").notNull(),
|
|
231
|
+
schemaVersion: pgCore.integer("schema_version").notNull(),
|
|
232
|
+
removedAt: pgCore.timestamp("removed_at", { withTimezone: true }),
|
|
233
|
+
lastAttemptedAt: pgCore.timestamp("last_attempted_at", {
|
|
234
|
+
withTimezone: true
|
|
235
|
+
}).notNull(),
|
|
236
|
+
lastError: pgCore.text("last_error")
|
|
237
|
+
},
|
|
238
|
+
(t) => [
|
|
239
|
+
pgCore.primaryKey({
|
|
240
|
+
columns: [t.graphId, t.kindName, t.entity, t.schemaVersion]
|
|
241
|
+
})
|
|
242
|
+
]
|
|
243
|
+
);
|
|
244
|
+
const reconciliationMarkers = pgCore.pgTable(
|
|
245
|
+
n.reconciliationMarkers,
|
|
246
|
+
{
|
|
247
|
+
graphId: pgCore.text("graph_id").notNull(),
|
|
248
|
+
reconciledToVersion: pgCore.integer("reconciled_to_version").notNull()
|
|
249
|
+
},
|
|
250
|
+
(t) => [pgCore.primaryKey({ columns: [t.graphId] })]
|
|
251
|
+
);
|
|
252
|
+
const fulltext2 = pgCore.pgTable(
|
|
253
|
+
n.fulltext,
|
|
254
|
+
{
|
|
255
|
+
graphId: pgCore.text("graph_id").notNull(),
|
|
256
|
+
nodeKind: pgCore.text("node_kind").notNull(),
|
|
257
|
+
nodeId: pgCore.text("node_id").notNull(),
|
|
258
|
+
content: pgCore.text("content").notNull(),
|
|
259
|
+
language: regconfig("language").notNull(),
|
|
260
|
+
tsv: tsvector("tsv").generatedAlwaysAs(drizzleOrm.sql`to_tsvector("language", "content")`).notNull(),
|
|
261
|
+
updatedAt: pgCore.timestamp("updated_at", { withTimezone: true }).notNull()
|
|
262
|
+
},
|
|
263
|
+
(t) => [
|
|
264
|
+
pgCore.primaryKey({ columns: [t.graphId, t.nodeKind, t.nodeId] }),
|
|
265
|
+
pgCore.index(`${n.fulltext}_tsv_idx`).using("gin", t.tsv),
|
|
266
|
+
pgCore.index(`${n.fulltext}_kind_idx`).on(t.graphId, t.nodeKind)
|
|
267
|
+
]
|
|
268
|
+
);
|
|
193
269
|
return {
|
|
194
270
|
nodes: nodes3,
|
|
195
271
|
edges: edges3,
|
|
196
272
|
uniques: uniques3,
|
|
197
273
|
schemaVersions: schemaVersions3,
|
|
198
274
|
embeddings: embeddings3,
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
* and a GIN index; alternate strategies (ParadeDB, pg_trgm, pgroonga)
|
|
204
|
-
* pick their own column types and index methods. DDL is emitted as
|
|
205
|
-
* raw SQL via `strategy.generateDdl()`; reads and writes are composed
|
|
206
|
-
* from the strategy's fragment helpers.
|
|
207
|
-
*/
|
|
275
|
+
indexMaterializations,
|
|
276
|
+
kindRemovals,
|
|
277
|
+
reconciliationMarkers,
|
|
278
|
+
fulltext: fulltext2,
|
|
208
279
|
fulltextTableName: n.fulltext
|
|
209
280
|
};
|
|
210
281
|
}
|
|
211
282
|
var tables = createPostgresTables();
|
|
212
|
-
var {
|
|
283
|
+
var {
|
|
284
|
+
nodes,
|
|
285
|
+
edges,
|
|
286
|
+
uniques,
|
|
287
|
+
schemaVersions,
|
|
288
|
+
embeddings,
|
|
289
|
+
fulltext
|
|
290
|
+
} = tables;
|
|
213
291
|
var DEFAULT_TABLE_NAMES2 = {
|
|
214
292
|
nodes: "typegraph_nodes",
|
|
215
293
|
edges: "typegraph_edges",
|
|
216
294
|
uniques: "typegraph_node_uniques",
|
|
217
295
|
schemaVersions: "typegraph_schema_versions",
|
|
218
296
|
embeddings: "typegraph_node_embeddings",
|
|
219
|
-
fulltext: "typegraph_node_fulltext"
|
|
297
|
+
fulltext: "typegraph_node_fulltext",
|
|
298
|
+
indexMaterializations: "typegraph_index_materializations",
|
|
299
|
+
kindRemovals: "typegraph_kind_removals",
|
|
300
|
+
reconciliationMarkers: "typegraph_reconciliation_markers"
|
|
220
301
|
};
|
|
221
302
|
function createSqliteTables(names = {}, options = {}) {
|
|
222
303
|
const n = { ...DEFAULT_TABLE_NAMES2, ...names };
|
|
@@ -246,7 +327,7 @@ function createSqliteTables(names = {}, options = {}) {
|
|
|
246
327
|
),
|
|
247
328
|
sqliteCore.index(`${n.nodes}_deleted_idx`).on(t.graphId, t.deletedAt),
|
|
248
329
|
sqliteCore.index(`${n.nodes}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),
|
|
249
|
-
...
|
|
330
|
+
...chunkJTI5WT4P_cjs.buildSqliteNodeIndexBuilders(t, indexes)
|
|
250
331
|
]
|
|
251
332
|
);
|
|
252
333
|
const edges3 = sqliteCore.sqliteTable(
|
|
@@ -305,7 +386,7 @@ function createSqliteTables(names = {}, options = {}) {
|
|
|
305
386
|
t.fromId,
|
|
306
387
|
t.validTo
|
|
307
388
|
),
|
|
308
|
-
...
|
|
389
|
+
...chunkJTI5WT4P_cjs.buildSqliteEdgeIndexBuilders(t, indexes)
|
|
309
390
|
]
|
|
310
391
|
);
|
|
311
392
|
const uniques3 = sqliteCore.sqliteTable(
|
|
@@ -338,7 +419,13 @@ function createSqliteTables(names = {}, options = {}) {
|
|
|
338
419
|
},
|
|
339
420
|
(t) => [
|
|
340
421
|
sqliteCore.primaryKey({ columns: [t.graphId, t.version] }),
|
|
341
|
-
sqliteCore.index(`${n.schemaVersions}_active_idx`).on(t.graphId, t.isActive)
|
|
422
|
+
sqliteCore.index(`${n.schemaVersions}_active_idx`).on(t.graphId, t.isActive),
|
|
423
|
+
// Partial unique index enforcing the "at most one active version
|
|
424
|
+
// per graph" invariant at the storage layer. Defense in depth
|
|
425
|
+
// against buggy backend implementations or out-of-band writes.
|
|
426
|
+
// Forces the deactivate-then-activate ordering used by
|
|
427
|
+
// `commitSchemaVersion` and `setActiveVersion`.
|
|
428
|
+
sqliteCore.uniqueIndex(`${n.schemaVersions}_one_active_per_graph_idx`).on(t.graphId).where(drizzleOrm.sql`${t.isActive} = 1`)
|
|
342
429
|
]
|
|
343
430
|
);
|
|
344
431
|
const embeddings3 = sqliteCore.sqliteTable(
|
|
@@ -377,12 +464,55 @@ function createSqliteTables(names = {}, options = {}) {
|
|
|
377
464
|
)
|
|
378
465
|
]
|
|
379
466
|
);
|
|
467
|
+
const indexMaterializations = sqliteCore.sqliteTable(
|
|
468
|
+
n.indexMaterializations,
|
|
469
|
+
{
|
|
470
|
+
indexName: sqliteCore.text("index_name").notNull(),
|
|
471
|
+
graphId: sqliteCore.text("graph_id").notNull(),
|
|
472
|
+
entity: sqliteCore.text("entity").notNull(),
|
|
473
|
+
kind: sqliteCore.text("kind").notNull(),
|
|
474
|
+
signature: sqliteCore.text("signature").notNull(),
|
|
475
|
+
schemaVersion: sqliteCore.integer("schema_version").notNull(),
|
|
476
|
+
materializedAt: sqliteCore.text("materialized_at"),
|
|
477
|
+
lastAttemptedAt: sqliteCore.text("last_attempted_at").notNull(),
|
|
478
|
+
lastError: sqliteCore.text("last_error")
|
|
479
|
+
},
|
|
480
|
+
(t) => [sqliteCore.primaryKey({ columns: [t.indexName] })]
|
|
481
|
+
);
|
|
482
|
+
const kindRemovals = sqliteCore.sqliteTable(
|
|
483
|
+
n.kindRemovals,
|
|
484
|
+
{
|
|
485
|
+
graphId: sqliteCore.text("graph_id").notNull(),
|
|
486
|
+
kindName: sqliteCore.text("kind_name").notNull(),
|
|
487
|
+
entity: sqliteCore.text("entity").notNull(),
|
|
488
|
+
schemaVersion: sqliteCore.integer("schema_version").notNull(),
|
|
489
|
+
removedAt: sqliteCore.text("removed_at"),
|
|
490
|
+
lastAttemptedAt: sqliteCore.text("last_attempted_at").notNull(),
|
|
491
|
+
lastError: sqliteCore.text("last_error")
|
|
492
|
+
},
|
|
493
|
+
(t) => [
|
|
494
|
+
sqliteCore.primaryKey({
|
|
495
|
+
columns: [t.graphId, t.kindName, t.entity, t.schemaVersion]
|
|
496
|
+
})
|
|
497
|
+
]
|
|
498
|
+
);
|
|
499
|
+
const reconciliationMarkers = sqliteCore.sqliteTable(
|
|
500
|
+
n.reconciliationMarkers,
|
|
501
|
+
{
|
|
502
|
+
graphId: sqliteCore.text("graph_id").notNull(),
|
|
503
|
+
reconciledToVersion: sqliteCore.integer("reconciled_to_version").notNull()
|
|
504
|
+
},
|
|
505
|
+
(t) => [sqliteCore.primaryKey({ columns: [t.graphId] })]
|
|
506
|
+
);
|
|
380
507
|
return {
|
|
381
508
|
nodes: nodes3,
|
|
382
509
|
edges: edges3,
|
|
383
510
|
uniques: uniques3,
|
|
384
511
|
schemaVersions: schemaVersions3,
|
|
385
512
|
embeddings: embeddings3,
|
|
513
|
+
indexMaterializations,
|
|
514
|
+
kindRemovals,
|
|
515
|
+
reconciliationMarkers,
|
|
386
516
|
/**
|
|
387
517
|
* The fulltext storage is a FTS5 virtual table which Drizzle cannot
|
|
388
518
|
* represent. DDL is emitted as raw SQL and operations query it via
|
|
@@ -448,9 +578,9 @@ function renderIndexColumn(col) {
|
|
|
448
578
|
if (col && typeof col === "object" && "name" in col) {
|
|
449
579
|
return `"${col.name}"`;
|
|
450
580
|
}
|
|
451
|
-
const
|
|
452
|
-
if (
|
|
453
|
-
return
|
|
581
|
+
const sql14 = tryInlineSql(col);
|
|
582
|
+
if (sql14 !== void 0) {
|
|
583
|
+
return sql14;
|
|
454
584
|
}
|
|
455
585
|
return "unknown";
|
|
456
586
|
}
|
|
@@ -524,7 +654,7 @@ function isSqliteTable(value) {
|
|
|
524
654
|
return typeof value === "object" && value !== null && // Drizzle tables are always objects; strings are our escape hatch.
|
|
525
655
|
typeof value !== "string";
|
|
526
656
|
}
|
|
527
|
-
function generateSqliteDDL(tables3 = tables2, fulltextStrategy =
|
|
657
|
+
function generateSqliteDDL(tables3 = tables2, fulltextStrategy = chunkJTI5WT4P_cjs.fts5Strategy) {
|
|
528
658
|
const statements = [];
|
|
529
659
|
for (const table of Object.values(tables3)) {
|
|
530
660
|
if (!isSqliteTable(table)) continue;
|
|
@@ -537,7 +667,7 @@ function generateSqliteDDL(tables3 = tables2, fulltextStrategy = chunk3JK66E3I_c
|
|
|
537
667
|
statements.push(...fulltextStrategy.generateDdl(tables3.fulltextTableName));
|
|
538
668
|
return statements;
|
|
539
669
|
}
|
|
540
|
-
function generateSqliteMigrationSQL(tables3 = tables2, fulltextStrategy =
|
|
670
|
+
function generateSqliteMigrationSQL(tables3 = tables2, fulltextStrategy = chunkJTI5WT4P_cjs.fts5Strategy) {
|
|
541
671
|
return generateSqliteDDL(tables3, fulltextStrategy).join("\n\n");
|
|
542
672
|
}
|
|
543
673
|
function getPgColumnType(column) {
|
|
@@ -622,20 +752,22 @@ function generatePgCreateIndexSQL(table) {
|
|
|
622
752
|
function isPgTable(value) {
|
|
623
753
|
return typeof value === "object" && value !== null && typeof value !== "string";
|
|
624
754
|
}
|
|
625
|
-
function generatePostgresDDL(tables3 = tables, fulltextStrategy =
|
|
755
|
+
function generatePostgresDDL(tables3 = tables, fulltextStrategy = chunkJTI5WT4P_cjs.tsvectorStrategy) {
|
|
626
756
|
const statements = [];
|
|
627
757
|
for (const table of Object.values(tables3)) {
|
|
628
758
|
if (!isPgTable(table)) continue;
|
|
759
|
+
if (table === tables3.fulltext) continue;
|
|
629
760
|
statements.push(generatePgCreateTableSQL(table));
|
|
630
761
|
}
|
|
631
762
|
for (const table of Object.values(tables3)) {
|
|
632
763
|
if (!isPgTable(table)) continue;
|
|
764
|
+
if (table === tables3.fulltext) continue;
|
|
633
765
|
statements.push(...generatePgCreateIndexSQL(table));
|
|
634
766
|
}
|
|
635
767
|
statements.push(...fulltextStrategy.generateDdl(tables3.fulltextTableName));
|
|
636
768
|
return statements;
|
|
637
769
|
}
|
|
638
|
-
function generatePostgresMigrationSQL(tables3 = tables, fulltextStrategy =
|
|
770
|
+
function generatePostgresMigrationSQL(tables3 = tables, fulltextStrategy = chunkJTI5WT4P_cjs.tsvectorStrategy) {
|
|
639
771
|
const extensionSql = "-- Enable pgvector extension for vector similarity search\nCREATE EXTENSION IF NOT EXISTS vector;";
|
|
640
772
|
const ddlSql = generatePostgresDDL(tables3, fulltextStrategy).join("\n\n");
|
|
641
773
|
return `${extensionSql}
|
|
@@ -646,7 +778,7 @@ ${ddlSql}`;
|
|
|
646
778
|
// src/backend/drizzle/row-mappers.ts
|
|
647
779
|
function requireTimestamp(value, field) {
|
|
648
780
|
if (value === void 0) {
|
|
649
|
-
throw new
|
|
781
|
+
throw new chunkW5MTHMTE_cjs.DatabaseOperationError(
|
|
650
782
|
`Expected non-null ${field} timestamp`,
|
|
651
783
|
{ operation: "select", entity: "row" }
|
|
652
784
|
);
|
|
@@ -655,7 +787,7 @@ function requireTimestamp(value, field) {
|
|
|
655
787
|
}
|
|
656
788
|
function asString(value, field) {
|
|
657
789
|
if (typeof value !== "string") {
|
|
658
|
-
throw new
|
|
790
|
+
throw new chunkW5MTHMTE_cjs.DatabaseOperationError(
|
|
659
791
|
`Expected ${field} to be string, got ${typeof value}`,
|
|
660
792
|
{ operation: "select", entity: "row" }
|
|
661
793
|
);
|
|
@@ -664,7 +796,7 @@ function asString(value, field) {
|
|
|
664
796
|
}
|
|
665
797
|
function asNumber(value, field) {
|
|
666
798
|
if (typeof value !== "number") {
|
|
667
|
-
throw new
|
|
799
|
+
throw new chunkW5MTHMTE_cjs.DatabaseOperationError(
|
|
668
800
|
`Expected ${field} to be number, got ${typeof value}`,
|
|
669
801
|
{ operation: "select", entity: "row" }
|
|
670
802
|
);
|
|
@@ -695,7 +827,7 @@ var SQLITE_ROW_MAPPER_CONFIG = {
|
|
|
695
827
|
formatTimestamp: (value) => {
|
|
696
828
|
if (value === null || value === void 0) return;
|
|
697
829
|
if (typeof value !== "string") {
|
|
698
|
-
throw new
|
|
830
|
+
throw new chunkW5MTHMTE_cjs.DatabaseOperationError(
|
|
699
831
|
`Expected timestamp to be string, got ${typeof value}`,
|
|
700
832
|
{ operation: "select", entity: "row" }
|
|
701
833
|
);
|
|
@@ -704,7 +836,7 @@ var SQLITE_ROW_MAPPER_CONFIG = {
|
|
|
704
836
|
},
|
|
705
837
|
normalizeJson: (value) => {
|
|
706
838
|
if (typeof value !== "string") {
|
|
707
|
-
throw new
|
|
839
|
+
throw new chunkW5MTHMTE_cjs.DatabaseOperationError(
|
|
708
840
|
`Expected JSON column to be string, got ${typeof value}`,
|
|
709
841
|
{ operation: "select", entity: "row" }
|
|
710
842
|
);
|
|
@@ -772,6 +904,105 @@ function createSchemaVersionRowMapper(config) {
|
|
|
772
904
|
};
|
|
773
905
|
};
|
|
774
906
|
}
|
|
907
|
+
var SQLITE_INDEX_MAT_TIMESTAMPS = {
|
|
908
|
+
decode: (value) => typeof value === "string" ? value : void 0,
|
|
909
|
+
encode: (value) => value
|
|
910
|
+
};
|
|
911
|
+
var POSTGRES_INDEX_MAT_TIMESTAMPS = {
|
|
912
|
+
decode: formatPostgresTimestamp,
|
|
913
|
+
encode: (value) => new Date(value)
|
|
914
|
+
};
|
|
915
|
+
function mapMaterializationRow(row, decode) {
|
|
916
|
+
const lastAttemptedAt = decode(row.lastAttemptedAt);
|
|
917
|
+
if (lastAttemptedAt === void 0) {
|
|
918
|
+
throw new Error(
|
|
919
|
+
`materialization row missing required last_attempted_at: ${row.indexName}`
|
|
920
|
+
);
|
|
921
|
+
}
|
|
922
|
+
return {
|
|
923
|
+
indexName: row.indexName,
|
|
924
|
+
graphId: row.graphId,
|
|
925
|
+
entity: row.entity,
|
|
926
|
+
kind: row.kind,
|
|
927
|
+
signature: row.signature,
|
|
928
|
+
schemaVersion: row.schemaVersion,
|
|
929
|
+
materializedAt: decode(row.materializedAt),
|
|
930
|
+
lastAttemptedAt,
|
|
931
|
+
lastError: row.lastError ?? void 0
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
function buildMaterializationInsertValues(params, encode) {
|
|
935
|
+
return {
|
|
936
|
+
indexName: params.indexName,
|
|
937
|
+
graphId: params.graphId,
|
|
938
|
+
entity: params.entity,
|
|
939
|
+
kind: params.kind,
|
|
940
|
+
signature: params.signature,
|
|
941
|
+
schemaVersion: params.schemaVersion,
|
|
942
|
+
materializedAt: params.materializedAt === void 0 ? void 0 : encode(params.materializedAt),
|
|
943
|
+
lastAttemptedAt: encode(params.attemptedAt),
|
|
944
|
+
lastError: params.error
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
function buildMaterializationOnConflictSet(materializedAtColumn, paramsMaterializedAt) {
|
|
948
|
+
const materializedAtSet = paramsMaterializedAt === void 0 ? drizzleOrm.sql`COALESCE(excluded.${drizzleOrm.sql.identifier("materialized_at")}, ${materializedAtColumn})` : drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("materialized_at")}`;
|
|
949
|
+
return {
|
|
950
|
+
graphId: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("graph_id")}`,
|
|
951
|
+
entity: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("entity")}`,
|
|
952
|
+
kind: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("kind")}`,
|
|
953
|
+
signature: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("signature")}`,
|
|
954
|
+
schemaVersion: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("schema_version")}`,
|
|
955
|
+
materializedAt: materializedAtSet,
|
|
956
|
+
lastAttemptedAt: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("last_attempted_at")}`,
|
|
957
|
+
lastError: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("last_error")}`
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
var SQLITE_KIND_REMOVAL_TIMESTAMPS = {
|
|
961
|
+
decode: (value) => typeof value === "string" ? value : void 0,
|
|
962
|
+
encode: (value) => value
|
|
963
|
+
};
|
|
964
|
+
var POSTGRES_KIND_REMOVAL_TIMESTAMPS = {
|
|
965
|
+
decode: formatPostgresTimestamp,
|
|
966
|
+
encode: (value) => new Date(value)
|
|
967
|
+
};
|
|
968
|
+
function mapKindRemovalRow(row, decode) {
|
|
969
|
+
const lastAttemptedAt = decode(row.lastAttemptedAt);
|
|
970
|
+
if (lastAttemptedAt === void 0) {
|
|
971
|
+
throw new Error(
|
|
972
|
+
`kind removal row missing required last_attempted_at: ${row.kindName}`
|
|
973
|
+
);
|
|
974
|
+
}
|
|
975
|
+
return {
|
|
976
|
+
graphId: row.graphId,
|
|
977
|
+
kindName: row.kindName,
|
|
978
|
+
entity: row.entity,
|
|
979
|
+
schemaVersion: row.schemaVersion,
|
|
980
|
+
removedAt: decode(row.removedAt),
|
|
981
|
+
lastAttemptedAt,
|
|
982
|
+
lastError: row.lastError ?? void 0
|
|
983
|
+
};
|
|
984
|
+
}
|
|
985
|
+
function buildKindRemovalInsertValues(params, encode) {
|
|
986
|
+
return {
|
|
987
|
+
graphId: params.graphId,
|
|
988
|
+
kindName: params.kindName,
|
|
989
|
+
entity: params.entity,
|
|
990
|
+
schemaVersion: params.schemaVersion,
|
|
991
|
+
removedAt: params.removedAt === void 0 ? void 0 : encode(params.removedAt),
|
|
992
|
+
lastAttemptedAt: encode(params.attemptedAt),
|
|
993
|
+
lastError: params.error
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
function buildKindRemovalOnConflictSet(removedAtColumn, paramsRemovedAt) {
|
|
997
|
+
const removedAtSet = paramsRemovedAt === void 0 ? drizzleOrm.sql`COALESCE(excluded.${drizzleOrm.sql.identifier("removed_at")}, ${removedAtColumn})` : drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("removed_at")}`;
|
|
998
|
+
return {
|
|
999
|
+
entity: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("entity")}`,
|
|
1000
|
+
schemaVersion: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("schema_version")}`,
|
|
1001
|
+
removedAt: removedAtSet,
|
|
1002
|
+
lastAttemptedAt: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("last_attempted_at")}`,
|
|
1003
|
+
lastError: drizzleOrm.sql`excluded.${drizzleOrm.sql.identifier("last_error")}`
|
|
1004
|
+
};
|
|
1005
|
+
}
|
|
775
1006
|
|
|
776
1007
|
// src/backend/drizzle/operation-backend-core.ts
|
|
777
1008
|
function chunkArray(values, size) {
|
|
@@ -784,15 +1015,31 @@ function chunkArray(values, size) {
|
|
|
784
1015
|
}
|
|
785
1016
|
return chunks;
|
|
786
1017
|
}
|
|
1018
|
+
function verifyExpectedActiveVersion(graphId, expected, actualActiveVersion) {
|
|
1019
|
+
const expectedVersion = expected.kind === "active" ? expected.version : 0;
|
|
1020
|
+
if (actualActiveVersion !== expectedVersion) {
|
|
1021
|
+
throw new chunkW5MTHMTE_cjs.StaleVersionError({
|
|
1022
|
+
graphId,
|
|
1023
|
+
expected: expectedVersion,
|
|
1024
|
+
actual: actualActiveVersion
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
787
1028
|
function createCommonOperationBackend(options) {
|
|
788
1029
|
const { batchConfig, execution, operationStrategy, rowMappers } = options;
|
|
789
1030
|
const nowIso2 = options.nowIso ?? nowIso;
|
|
1031
|
+
async function readActiveVersion(graphId) {
|
|
1032
|
+
const row = await execution.execGet(
|
|
1033
|
+
operationStrategy.buildGetActiveSchema(graphId)
|
|
1034
|
+
);
|
|
1035
|
+
return row === void 0 ? 0 : rowMappers.toSchemaVersionRow(row).version;
|
|
1036
|
+
}
|
|
790
1037
|
return {
|
|
791
1038
|
async insertNode(params) {
|
|
792
1039
|
const timestamp2 = nowIso2();
|
|
793
1040
|
const query = operationStrategy.buildInsertNode(params, timestamp2);
|
|
794
1041
|
const row = await execution.execGet(query);
|
|
795
|
-
if (!row) throw new
|
|
1042
|
+
if (!row) throw new chunkW5MTHMTE_cjs.DatabaseOperationError("Insert node failed: no row returned", { operation: "insert", entity: "node" });
|
|
796
1043
|
return rowMappers.toNodeRow(row);
|
|
797
1044
|
},
|
|
798
1045
|
async insertNodeNoReturn(params) {
|
|
@@ -842,7 +1089,7 @@ function createCommonOperationBackend(options) {
|
|
|
842
1089
|
const timestamp2 = nowIso2();
|
|
843
1090
|
const query = operationStrategy.buildUpdateNode(params, timestamp2);
|
|
844
1091
|
const row = await execution.execGet(query);
|
|
845
|
-
if (!row) throw new
|
|
1092
|
+
if (!row) throw new chunkW5MTHMTE_cjs.DatabaseOperationError("Update node failed: no row returned", { operation: "update", entity: "node" });
|
|
846
1093
|
return rowMappers.toNodeRow(row);
|
|
847
1094
|
},
|
|
848
1095
|
async deleteNode(params) {
|
|
@@ -885,7 +1132,7 @@ function createCommonOperationBackend(options) {
|
|
|
885
1132
|
const timestamp2 = nowIso2();
|
|
886
1133
|
const query = operationStrategy.buildInsertEdge(params, timestamp2);
|
|
887
1134
|
const row = await execution.execGet(query);
|
|
888
|
-
if (!row) throw new
|
|
1135
|
+
if (!row) throw new chunkW5MTHMTE_cjs.DatabaseOperationError("Insert edge failed: no row returned", { operation: "insert", entity: "edge" });
|
|
889
1136
|
return rowMappers.toEdgeRow(row);
|
|
890
1137
|
},
|
|
891
1138
|
async insertEdgeNoReturn(params) {
|
|
@@ -935,7 +1182,7 @@ function createCommonOperationBackend(options) {
|
|
|
935
1182
|
const timestamp2 = nowIso2();
|
|
936
1183
|
const query = operationStrategy.buildUpdateEdge(params, timestamp2);
|
|
937
1184
|
const row = await execution.execGet(query);
|
|
938
|
-
if (!row) throw new
|
|
1185
|
+
if (!row) throw new chunkW5MTHMTE_cjs.DatabaseOperationError("Update edge failed: no row returned", { operation: "update", entity: "edge" });
|
|
939
1186
|
return rowMappers.toEdgeRow(row);
|
|
940
1187
|
},
|
|
941
1188
|
async deleteEdge(params) {
|
|
@@ -986,7 +1233,7 @@ function createCommonOperationBackend(options) {
|
|
|
986
1233
|
const query = operationStrategy.buildInsertUnique(params);
|
|
987
1234
|
const result = await execution.execGet(query);
|
|
988
1235
|
if (result && result.node_id !== params.nodeId) {
|
|
989
|
-
throw new
|
|
1236
|
+
throw new chunkW5MTHMTE_cjs.UniquenessError({
|
|
990
1237
|
constraintName: params.constraintName,
|
|
991
1238
|
kind: params.nodeKind,
|
|
992
1239
|
existingId: result.node_id,
|
|
@@ -1020,20 +1267,104 @@ function createCommonOperationBackend(options) {
|
|
|
1020
1267
|
const row = await execution.execGet(query);
|
|
1021
1268
|
return row ? rowMappers.toSchemaVersionRow(row) : void 0;
|
|
1022
1269
|
},
|
|
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
1270
|
async getSchemaVersion(graphId, version) {
|
|
1031
1271
|
const query = operationStrategy.buildGetSchemaVersion(graphId, version);
|
|
1032
1272
|
const row = await execution.execGet(query);
|
|
1033
1273
|
return row ? rowMappers.toSchemaVersionRow(row) : void 0;
|
|
1034
1274
|
},
|
|
1035
|
-
async
|
|
1036
|
-
const
|
|
1275
|
+
async commitSchemaVersion(params) {
|
|
1276
|
+
const existingRaw = await execution.execGet(
|
|
1277
|
+
operationStrategy.buildGetSchemaVersion(
|
|
1278
|
+
params.graphId,
|
|
1279
|
+
params.version
|
|
1280
|
+
)
|
|
1281
|
+
);
|
|
1282
|
+
const actualActiveVersion = await readActiveVersion(params.graphId);
|
|
1283
|
+
if (existingRaw !== void 0) {
|
|
1284
|
+
const existing = rowMappers.toSchemaVersionRow(existingRaw);
|
|
1285
|
+
if (existing.schema_hash !== params.schemaHash) {
|
|
1286
|
+
throw new chunkW5MTHMTE_cjs.SchemaContentConflictError({
|
|
1287
|
+
graphId: params.graphId,
|
|
1288
|
+
version: params.version,
|
|
1289
|
+
existingHash: existing.schema_hash,
|
|
1290
|
+
incomingHash: params.schemaHash
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
if (existing.is_active) {
|
|
1294
|
+
return existing;
|
|
1295
|
+
}
|
|
1296
|
+
verifyExpectedActiveVersion(
|
|
1297
|
+
params.graphId,
|
|
1298
|
+
params.expected,
|
|
1299
|
+
actualActiveVersion
|
|
1300
|
+
);
|
|
1301
|
+
const reactivate = operationStrategy.buildSetActiveSchema(
|
|
1302
|
+
params.graphId,
|
|
1303
|
+
params.version
|
|
1304
|
+
);
|
|
1305
|
+
await execution.execRun(reactivate.deactivateAll);
|
|
1306
|
+
await execution.execRun(reactivate.activateVersion);
|
|
1307
|
+
return { ...existing, is_active: true };
|
|
1308
|
+
}
|
|
1309
|
+
verifyExpectedActiveVersion(
|
|
1310
|
+
params.graphId,
|
|
1311
|
+
params.expected,
|
|
1312
|
+
actualActiveVersion
|
|
1313
|
+
);
|
|
1314
|
+
if (params.expected.kind === "active") {
|
|
1315
|
+
const flip = operationStrategy.buildSetActiveSchema(
|
|
1316
|
+
params.graphId,
|
|
1317
|
+
params.version
|
|
1318
|
+
);
|
|
1319
|
+
await execution.execRun(flip.deactivateAll);
|
|
1320
|
+
}
|
|
1321
|
+
const timestamp2 = nowIso2();
|
|
1322
|
+
const insertQuery = operationStrategy.buildInsertSchema(
|
|
1323
|
+
{
|
|
1324
|
+
graphId: params.graphId,
|
|
1325
|
+
version: params.version,
|
|
1326
|
+
schemaHash: params.schemaHash,
|
|
1327
|
+
schemaDoc: params.schemaDoc,
|
|
1328
|
+
isActive: true
|
|
1329
|
+
},
|
|
1330
|
+
timestamp2
|
|
1331
|
+
);
|
|
1332
|
+
const insertedRaw = await execution.execGet(insertQuery);
|
|
1333
|
+
if (!insertedRaw) {
|
|
1334
|
+
throw new chunkW5MTHMTE_cjs.DatabaseOperationError(
|
|
1335
|
+
"Insert schema failed: no row returned",
|
|
1336
|
+
{ operation: "insert", entity: "schema" }
|
|
1337
|
+
);
|
|
1338
|
+
}
|
|
1339
|
+
return rowMappers.toSchemaVersionRow(insertedRaw);
|
|
1340
|
+
},
|
|
1341
|
+
async setActiveVersion(params) {
|
|
1342
|
+
const actualActiveVersion = await readActiveVersion(params.graphId);
|
|
1343
|
+
verifyExpectedActiveVersion(
|
|
1344
|
+
params.graphId,
|
|
1345
|
+
params.expected,
|
|
1346
|
+
actualActiveVersion
|
|
1347
|
+
);
|
|
1348
|
+
const targetRaw = await execution.execGet(
|
|
1349
|
+
operationStrategy.buildGetSchemaVersion(
|
|
1350
|
+
params.graphId,
|
|
1351
|
+
params.version
|
|
1352
|
+
)
|
|
1353
|
+
);
|
|
1354
|
+
if (!targetRaw) {
|
|
1355
|
+
throw new chunkW5MTHMTE_cjs.MigrationError(
|
|
1356
|
+
`Cannot activate version ${params.version}: version does not exist for graph "${params.graphId}".`,
|
|
1357
|
+
{
|
|
1358
|
+
graphId: params.graphId,
|
|
1359
|
+
fromVersion: actualActiveVersion,
|
|
1360
|
+
toVersion: params.version
|
|
1361
|
+
}
|
|
1362
|
+
);
|
|
1363
|
+
}
|
|
1364
|
+
const queries = operationStrategy.buildSetActiveSchema(
|
|
1365
|
+
params.graphId,
|
|
1366
|
+
params.version
|
|
1367
|
+
);
|
|
1037
1368
|
await execution.execRun(queries.deactivateAll);
|
|
1038
1369
|
await execution.execRun(queries.activateVersion);
|
|
1039
1370
|
},
|
|
@@ -1046,13 +1377,16 @@ function createCommonOperationBackend(options) {
|
|
|
1046
1377
|
};
|
|
1047
1378
|
}
|
|
1048
1379
|
function buildClearGraph(tables3, graphId) {
|
|
1049
|
-
const
|
|
1380
|
+
const fulltext2 = chunkJTI5WT4P_cjs.quotedTableName(tables3.fulltextTableName);
|
|
1050
1381
|
return [
|
|
1051
|
-
drizzleOrm.sql`DELETE FROM ${
|
|
1382
|
+
drizzleOrm.sql`DELETE FROM ${fulltext2} WHERE "graph_id" = ${graphId}`,
|
|
1052
1383
|
drizzleOrm.sql`DELETE FROM ${tables3.embeddings} WHERE ${tables3.embeddings.graphId} = ${graphId}`,
|
|
1053
1384
|
drizzleOrm.sql`DELETE FROM ${tables3.uniques} WHERE ${tables3.uniques.graphId} = ${graphId}`,
|
|
1054
1385
|
drizzleOrm.sql`DELETE FROM ${tables3.edges} WHERE ${tables3.edges.graphId} = ${graphId}`,
|
|
1055
1386
|
drizzleOrm.sql`DELETE FROM ${tables3.nodes} WHERE ${tables3.nodes.graphId} = ${graphId}`,
|
|
1387
|
+
drizzleOrm.sql`DELETE FROM ${tables3.indexMaterializations} WHERE ${tables3.indexMaterializations.graphId} = ${graphId}`,
|
|
1388
|
+
drizzleOrm.sql`DELETE FROM ${tables3.kindRemovals} WHERE ${tables3.kindRemovals.graphId} = ${graphId}`,
|
|
1389
|
+
drizzleOrm.sql`DELETE FROM ${tables3.reconciliationMarkers} WHERE ${tables3.reconciliationMarkers.graphId} = ${graphId}`,
|
|
1056
1390
|
drizzleOrm.sql`DELETE FROM ${tables3.schemaVersions} WHERE ${tables3.schemaVersions.graphId} = ${graphId}`
|
|
1057
1391
|
];
|
|
1058
1392
|
}
|
|
@@ -1193,13 +1527,13 @@ function buildCountEdgesByKind(tables3, params) {
|
|
|
1193
1527
|
function buildInsertEdge(tables3, params, timestamp2) {
|
|
1194
1528
|
const { edges: edges3 } = tables3;
|
|
1195
1529
|
const propsJson = JSON.stringify(params.props);
|
|
1196
|
-
const columns =
|
|
1530
|
+
const columns = chunkJTI5WT4P_cjs.edgeColumnList(edges3);
|
|
1197
1531
|
return drizzleOrm.sql`
|
|
1198
1532
|
INSERT INTO ${edges3} (${columns})
|
|
1199
1533
|
VALUES (
|
|
1200
1534
|
${params.graphId}, ${params.id}, ${params.kind},
|
|
1201
1535
|
${params.fromKind}, ${params.fromId}, ${params.toKind}, ${params.toId},
|
|
1202
|
-
${propsJson}, ${
|
|
1536
|
+
${propsJson}, ${chunkJTI5WT4P_cjs.sqlNull(params.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(params.validTo)},
|
|
1203
1537
|
${timestamp2}, ${timestamp2}
|
|
1204
1538
|
)
|
|
1205
1539
|
RETURNING *
|
|
@@ -1208,23 +1542,23 @@ function buildInsertEdge(tables3, params, timestamp2) {
|
|
|
1208
1542
|
function buildInsertEdgeNoReturn(tables3, params, timestamp2) {
|
|
1209
1543
|
const { edges: edges3 } = tables3;
|
|
1210
1544
|
const propsJson = JSON.stringify(params.props);
|
|
1211
|
-
const columns =
|
|
1545
|
+
const columns = chunkJTI5WT4P_cjs.edgeColumnList(edges3);
|
|
1212
1546
|
return drizzleOrm.sql`
|
|
1213
1547
|
INSERT INTO ${edges3} (${columns})
|
|
1214
1548
|
VALUES (
|
|
1215
1549
|
${params.graphId}, ${params.id}, ${params.kind},
|
|
1216
1550
|
${params.fromKind}, ${params.fromId}, ${params.toKind}, ${params.toId},
|
|
1217
|
-
${propsJson}, ${
|
|
1551
|
+
${propsJson}, ${chunkJTI5WT4P_cjs.sqlNull(params.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(params.validTo)},
|
|
1218
1552
|
${timestamp2}, ${timestamp2}
|
|
1219
1553
|
)
|
|
1220
1554
|
`;
|
|
1221
1555
|
}
|
|
1222
1556
|
function buildInsertEdgesBatch(tables3, params, timestamp2) {
|
|
1223
1557
|
const { edges: edges3 } = tables3;
|
|
1224
|
-
const columns =
|
|
1558
|
+
const columns = chunkJTI5WT4P_cjs.edgeColumnList(edges3);
|
|
1225
1559
|
const values = params.map((edgeParams) => {
|
|
1226
1560
|
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}, ${
|
|
1561
|
+
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
1562
|
});
|
|
1229
1563
|
return drizzleOrm.sql`
|
|
1230
1564
|
INSERT INTO ${edges3} (${columns})
|
|
@@ -1233,10 +1567,10 @@ function buildInsertEdgesBatch(tables3, params, timestamp2) {
|
|
|
1233
1567
|
}
|
|
1234
1568
|
function buildInsertEdgesBatchReturning(tables3, params, timestamp2) {
|
|
1235
1569
|
const { edges: edges3 } = tables3;
|
|
1236
|
-
const columns =
|
|
1570
|
+
const columns = chunkJTI5WT4P_cjs.edgeColumnList(edges3);
|
|
1237
1571
|
const values = params.map((edgeParams) => {
|
|
1238
1572
|
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}, ${
|
|
1573
|
+
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
1574
|
});
|
|
1241
1575
|
return drizzleOrm.sql`
|
|
1242
1576
|
INSERT INTO ${edges3} (${columns})
|
|
@@ -1268,14 +1602,14 @@ function buildUpdateEdge(tables3, params, timestamp2) {
|
|
|
1268
1602
|
const { edges: edges3 } = tables3;
|
|
1269
1603
|
const propsJson = JSON.stringify(params.props);
|
|
1270
1604
|
const setParts = [
|
|
1271
|
-
drizzleOrm.sql`${
|
|
1272
|
-
drizzleOrm.sql`${
|
|
1605
|
+
drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(edges3.props)} = ${propsJson}`,
|
|
1606
|
+
drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(edges3.updatedAt)} = ${timestamp2}`
|
|
1273
1607
|
];
|
|
1274
1608
|
if (params.validTo !== void 0) {
|
|
1275
|
-
setParts.push(drizzleOrm.sql`${
|
|
1609
|
+
setParts.push(drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(edges3.validTo)} = ${params.validTo}`);
|
|
1276
1610
|
}
|
|
1277
1611
|
if (params.clearDeleted) {
|
|
1278
|
-
setParts.push(drizzleOrm.sql`${
|
|
1612
|
+
setParts.push(drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(edges3.deletedAt)} = NULL`);
|
|
1279
1613
|
}
|
|
1280
1614
|
const setClause = drizzleOrm.sql.join(setParts, drizzleOrm.sql`, `);
|
|
1281
1615
|
if (params.clearDeleted) {
|
|
@@ -1300,7 +1634,7 @@ function buildDeleteEdge(tables3, params, timestamp2) {
|
|
|
1300
1634
|
const { edges: edges3 } = tables3;
|
|
1301
1635
|
return drizzleOrm.sql`
|
|
1302
1636
|
UPDATE ${edges3}
|
|
1303
|
-
SET ${
|
|
1637
|
+
SET ${chunkJTI5WT4P_cjs.quotedColumn(edges3.deletedAt)} = ${timestamp2}
|
|
1304
1638
|
WHERE ${edges3.graphId} = ${params.graphId}
|
|
1305
1639
|
AND ${edges3.id} = ${params.id}
|
|
1306
1640
|
AND ${edges3.deletedAt} IS NULL
|
|
@@ -1387,7 +1721,7 @@ function resolveMode(mode) {
|
|
|
1387
1721
|
function buildFulltextSearch(tableName, params, strategy) {
|
|
1388
1722
|
assertValidSearchParams(params);
|
|
1389
1723
|
const mode = resolveMode(params.mode);
|
|
1390
|
-
const table =
|
|
1724
|
+
const table = chunkJTI5WT4P_cjs.quotedTableName(tableName);
|
|
1391
1725
|
const matchCondition = strategy.matchCondition(
|
|
1392
1726
|
tableName,
|
|
1393
1727
|
params.query,
|
|
@@ -1438,12 +1772,12 @@ function assertValidSearchParams(params) {
|
|
|
1438
1772
|
function buildInsertNode(tables3, params, timestamp2) {
|
|
1439
1773
|
const { nodes: nodes3 } = tables3;
|
|
1440
1774
|
const propsJson = JSON.stringify(params.props);
|
|
1441
|
-
const columns =
|
|
1775
|
+
const columns = chunkJTI5WT4P_cjs.nodeColumnList(nodes3);
|
|
1442
1776
|
return drizzleOrm.sql`
|
|
1443
1777
|
INSERT INTO ${nodes3} (${columns})
|
|
1444
1778
|
VALUES (
|
|
1445
1779
|
${params.graphId}, ${params.kind}, ${params.id}, ${propsJson},
|
|
1446
|
-
1, ${
|
|
1780
|
+
1, ${chunkJTI5WT4P_cjs.sqlNull(params.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(params.validTo)},
|
|
1447
1781
|
${timestamp2}, ${timestamp2}
|
|
1448
1782
|
)
|
|
1449
1783
|
RETURNING *
|
|
@@ -1452,22 +1786,22 @@ function buildInsertNode(tables3, params, timestamp2) {
|
|
|
1452
1786
|
function buildInsertNodeNoReturn(tables3, params, timestamp2) {
|
|
1453
1787
|
const { nodes: nodes3 } = tables3;
|
|
1454
1788
|
const propsJson = JSON.stringify(params.props);
|
|
1455
|
-
const columns =
|
|
1789
|
+
const columns = chunkJTI5WT4P_cjs.nodeColumnList(nodes3);
|
|
1456
1790
|
return drizzleOrm.sql`
|
|
1457
1791
|
INSERT INTO ${nodes3} (${columns})
|
|
1458
1792
|
VALUES (
|
|
1459
1793
|
${params.graphId}, ${params.kind}, ${params.id}, ${propsJson},
|
|
1460
|
-
1, ${
|
|
1794
|
+
1, ${chunkJTI5WT4P_cjs.sqlNull(params.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(params.validTo)},
|
|
1461
1795
|
${timestamp2}, ${timestamp2}
|
|
1462
1796
|
)
|
|
1463
1797
|
`;
|
|
1464
1798
|
}
|
|
1465
1799
|
function buildInsertNodesBatch(tables3, params, timestamp2) {
|
|
1466
1800
|
const { nodes: nodes3 } = tables3;
|
|
1467
|
-
const columns =
|
|
1801
|
+
const columns = chunkJTI5WT4P_cjs.nodeColumnList(nodes3);
|
|
1468
1802
|
const values = params.map((nodeParams) => {
|
|
1469
1803
|
const propsJson = JSON.stringify(nodeParams.props);
|
|
1470
|
-
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${
|
|
1804
|
+
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${chunkJTI5WT4P_cjs.sqlNull(nodeParams.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1471
1805
|
});
|
|
1472
1806
|
return drizzleOrm.sql`
|
|
1473
1807
|
INSERT INTO ${nodes3} (${columns})
|
|
@@ -1476,10 +1810,10 @@ function buildInsertNodesBatch(tables3, params, timestamp2) {
|
|
|
1476
1810
|
}
|
|
1477
1811
|
function buildInsertNodesBatchReturning(tables3, params, timestamp2) {
|
|
1478
1812
|
const { nodes: nodes3 } = tables3;
|
|
1479
|
-
const columns =
|
|
1813
|
+
const columns = chunkJTI5WT4P_cjs.nodeColumnList(nodes3);
|
|
1480
1814
|
const values = params.map((nodeParams) => {
|
|
1481
1815
|
const propsJson = JSON.stringify(nodeParams.props);
|
|
1482
|
-
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${
|
|
1816
|
+
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${chunkJTI5WT4P_cjs.sqlNull(nodeParams.validFrom)}, ${chunkJTI5WT4P_cjs.sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1483
1817
|
});
|
|
1484
1818
|
return drizzleOrm.sql`
|
|
1485
1819
|
INSERT INTO ${nodes3} (${columns})
|
|
@@ -1513,19 +1847,19 @@ function buildUpdateNode(tables3, params, timestamp2) {
|
|
|
1513
1847
|
const { nodes: nodes3 } = tables3;
|
|
1514
1848
|
const propsJson = JSON.stringify(params.props);
|
|
1515
1849
|
const setParts = [
|
|
1516
|
-
drizzleOrm.sql`${
|
|
1517
|
-
drizzleOrm.sql`${
|
|
1850
|
+
drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(nodes3.props)} = ${propsJson}`,
|
|
1851
|
+
drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(nodes3.updatedAt)} = ${timestamp2}`
|
|
1518
1852
|
];
|
|
1519
1853
|
if (params.incrementVersion) {
|
|
1520
1854
|
setParts.push(
|
|
1521
|
-
drizzleOrm.sql`${
|
|
1855
|
+
drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(nodes3.version)} = ${chunkJTI5WT4P_cjs.quotedColumn(nodes3.version)} + 1`
|
|
1522
1856
|
);
|
|
1523
1857
|
}
|
|
1524
1858
|
if (params.validTo !== void 0) {
|
|
1525
|
-
setParts.push(drizzleOrm.sql`${
|
|
1859
|
+
setParts.push(drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(nodes3.validTo)} = ${params.validTo}`);
|
|
1526
1860
|
}
|
|
1527
1861
|
if (params.clearDeleted) {
|
|
1528
|
-
setParts.push(drizzleOrm.sql`${
|
|
1862
|
+
setParts.push(drizzleOrm.sql`${chunkJTI5WT4P_cjs.quotedColumn(nodes3.deletedAt)} = NULL`);
|
|
1529
1863
|
}
|
|
1530
1864
|
const setClause = drizzleOrm.sql.join(setParts, drizzleOrm.sql`, `);
|
|
1531
1865
|
if (params.clearDeleted) {
|
|
@@ -1552,7 +1886,7 @@ function buildDeleteNode(tables3, params, timestamp2) {
|
|
|
1552
1886
|
const { nodes: nodes3 } = tables3;
|
|
1553
1887
|
return drizzleOrm.sql`
|
|
1554
1888
|
UPDATE ${nodes3}
|
|
1555
|
-
SET ${
|
|
1889
|
+
SET ${chunkJTI5WT4P_cjs.quotedColumn(nodes3.deletedAt)} = ${timestamp2}
|
|
1556
1890
|
WHERE ${nodes3.graphId} = ${params.graphId}
|
|
1557
1891
|
AND ${nodes3.kind} = ${params.kind}
|
|
1558
1892
|
AND ${nodes3.id} = ${params.id}
|
|
@@ -1619,12 +1953,12 @@ function buildSetActiveSchema(tables3, graphId, version, dialect = "sqlite") {
|
|
|
1619
1953
|
const strategy = SCHEMA_DIALECT_STRATEGIES[dialect];
|
|
1620
1954
|
const deactivateAll = drizzleOrm.sql`
|
|
1621
1955
|
UPDATE ${schemaVersions3}
|
|
1622
|
-
SET ${
|
|
1956
|
+
SET ${chunkJTI5WT4P_cjs.quotedColumn(schemaVersions3.isActive)} = ${strategy.booleanLiteral(false)}
|
|
1623
1957
|
WHERE ${schemaVersions3.graphId} = ${graphId}
|
|
1624
1958
|
`;
|
|
1625
1959
|
const activateVersion = drizzleOrm.sql`
|
|
1626
1960
|
UPDATE ${schemaVersions3}
|
|
1627
|
-
SET ${
|
|
1961
|
+
SET ${chunkJTI5WT4P_cjs.quotedColumn(schemaVersions3.isActive)} = ${strategy.booleanLiteral(true)}
|
|
1628
1962
|
WHERE ${schemaVersions3.graphId} = ${graphId}
|
|
1629
1963
|
AND ${schemaVersions3.version} = ${version}
|
|
1630
1964
|
`;
|
|
@@ -1642,22 +1976,22 @@ function buildInsertUniqueSqlite(tables3, params) {
|
|
|
1642
1976
|
)
|
|
1643
1977
|
ON CONFLICT (${conflictColumns})
|
|
1644
1978
|
DO UPDATE SET
|
|
1645
|
-
${
|
|
1646
|
-
WHEN ${
|
|
1647
|
-
WHEN ${
|
|
1648
|
-
ELSE ${
|
|
1979
|
+
${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} = CASE
|
|
1980
|
+
WHEN ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.nodeId}
|
|
1981
|
+
WHEN ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.nodeId}
|
|
1982
|
+
ELSE ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)}
|
|
1649
1983
|
END,
|
|
1650
|
-
${
|
|
1651
|
-
WHEN ${
|
|
1652
|
-
WHEN ${
|
|
1653
|
-
ELSE ${
|
|
1984
|
+
${chunkJTI5WT4P_cjs.quotedColumn(uniques3.concreteKind)} = CASE
|
|
1985
|
+
WHEN ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.concreteKind}
|
|
1986
|
+
WHEN ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.concreteKind}
|
|
1987
|
+
ELSE ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.concreteKind)}
|
|
1654
1988
|
END,
|
|
1655
|
-
${
|
|
1656
|
-
WHEN ${
|
|
1657
|
-
WHEN ${
|
|
1658
|
-
ELSE ${
|
|
1989
|
+
${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)} = CASE
|
|
1990
|
+
WHEN ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN NULL
|
|
1991
|
+
WHEN ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN NULL
|
|
1992
|
+
ELSE ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)}
|
|
1659
1993
|
END
|
|
1660
|
-
RETURNING ${
|
|
1994
|
+
RETURNING ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} as node_id
|
|
1661
1995
|
`;
|
|
1662
1996
|
}
|
|
1663
1997
|
function buildInsertUniquePostgres(tables3, params) {
|
|
@@ -1674,22 +2008,22 @@ function buildInsertUniquePostgres(tables3, params) {
|
|
|
1674
2008
|
)
|
|
1675
2009
|
ON CONFLICT (${conflictColumns})
|
|
1676
2010
|
DO UPDATE SET
|
|
1677
|
-
${
|
|
2011
|
+
${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} = CASE
|
|
1678
2012
|
WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.nodeId}
|
|
1679
2013
|
WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.nodeId}
|
|
1680
2014
|
ELSE ${existingColumn(uniques3.nodeId)}
|
|
1681
2015
|
END,
|
|
1682
|
-
${
|
|
2016
|
+
${chunkJTI5WT4P_cjs.quotedColumn(uniques3.concreteKind)} = CASE
|
|
1683
2017
|
WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.concreteKind}
|
|
1684
2018
|
WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.concreteKind}
|
|
1685
2019
|
ELSE ${existingColumn(uniques3.concreteKind)}
|
|
1686
2020
|
END,
|
|
1687
|
-
${
|
|
2021
|
+
${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)} = CASE
|
|
1688
2022
|
WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN NULL
|
|
1689
2023
|
WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN NULL
|
|
1690
2024
|
ELSE ${existingColumn(uniques3.deletedAt)}
|
|
1691
2025
|
END
|
|
1692
|
-
RETURNING ${
|
|
2026
|
+
RETURNING ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.nodeId)} as node_id
|
|
1693
2027
|
`;
|
|
1694
2028
|
}
|
|
1695
2029
|
var UNIQUE_INSERT_BUILDERS = {
|
|
@@ -1704,7 +2038,7 @@ function buildDeleteUnique(tables3, params, timestamp2) {
|
|
|
1704
2038
|
const { uniques: uniques3 } = tables3;
|
|
1705
2039
|
return drizzleOrm.sql`
|
|
1706
2040
|
UPDATE ${uniques3}
|
|
1707
|
-
SET ${
|
|
2041
|
+
SET ${chunkJTI5WT4P_cjs.quotedColumn(uniques3.deletedAt)} = ${timestamp2}
|
|
1708
2042
|
WHERE ${uniques3.graphId} = ${params.graphId}
|
|
1709
2043
|
AND ${uniques3.nodeKind} = ${params.nodeKind}
|
|
1710
2044
|
AND ${uniques3.constraintName} = ${params.constraintName}
|
|
@@ -2178,11 +2512,11 @@ function generateVectorIndexName(graphId, nodeKind, fieldPath, metric = "cosine"
|
|
|
2178
2512
|
metric
|
|
2179
2513
|
];
|
|
2180
2514
|
const name = parts.join("_");
|
|
2181
|
-
if (name.length <=
|
|
2515
|
+
if (name.length <= chunkCTHNVU6K_cjs.MAX_PG_IDENTIFIER_LENGTH) {
|
|
2182
2516
|
return name;
|
|
2183
2517
|
}
|
|
2184
2518
|
const hash = shortHash(name);
|
|
2185
|
-
const truncated = name.slice(0,
|
|
2519
|
+
const truncated = name.slice(0, chunkCTHNVU6K_cjs.MAX_PG_IDENTIFIER_LENGTH - 1 - hash.length);
|
|
2186
2520
|
return `${truncated}_${hash}`;
|
|
2187
2521
|
}
|
|
2188
2522
|
function getOperatorClass(metric) {
|
|
@@ -2231,9 +2565,10 @@ async function createPostgresVectorIndex(db, options) {
|
|
|
2231
2565
|
const safeNodeKind = escapeSqlString(nodeKind);
|
|
2232
2566
|
const safeFieldPath = escapeSqlString(fieldPath);
|
|
2233
2567
|
let indexSql;
|
|
2568
|
+
const concurrentClause = options.concurrent === true ? "CONCURRENTLY " : "";
|
|
2234
2569
|
if (indexType === "hnsw") {
|
|
2235
2570
|
indexSql = drizzleOrm.sql.raw(`
|
|
2236
|
-
CREATE INDEX IF NOT EXISTS ${indexName}
|
|
2571
|
+
CREATE INDEX ${concurrentClause}IF NOT EXISTS ${indexName}
|
|
2237
2572
|
ON ${quotedEmbeddingsTableName}
|
|
2238
2573
|
USING hnsw ((embedding::vector(${dimensions})) ${operatorClass})
|
|
2239
2574
|
WITH (m = ${hnswM}, ef_construction = ${hnswEfConstruction})
|
|
@@ -2243,7 +2578,7 @@ async function createPostgresVectorIndex(db, options) {
|
|
|
2243
2578
|
`);
|
|
2244
2579
|
} else if (indexType === "ivfflat") {
|
|
2245
2580
|
indexSql = drizzleOrm.sql.raw(`
|
|
2246
|
-
CREATE INDEX IF NOT EXISTS ${indexName}
|
|
2581
|
+
CREATE INDEX ${concurrentClause}IF NOT EXISTS ${indexName}
|
|
2247
2582
|
ON ${quotedEmbeddingsTableName}
|
|
2248
2583
|
USING ivfflat ((embedding::vector(${dimensions})) ${operatorClass})
|
|
2249
2584
|
WITH (lists = ${ivfflatLists})
|
|
@@ -2340,8 +2675,16 @@ function compileQueryWithDialect(db, query, backendName) {
|
|
|
2340
2675
|
return compiler.sqlToQuery(query);
|
|
2341
2676
|
}
|
|
2342
2677
|
|
|
2678
|
+
exports.POSTGRES_INDEX_MAT_TIMESTAMPS = POSTGRES_INDEX_MAT_TIMESTAMPS;
|
|
2679
|
+
exports.POSTGRES_KIND_REMOVAL_TIMESTAMPS = POSTGRES_KIND_REMOVAL_TIMESTAMPS;
|
|
2343
2680
|
exports.POSTGRES_ROW_MAPPER_CONFIG = POSTGRES_ROW_MAPPER_CONFIG;
|
|
2681
|
+
exports.SQLITE_INDEX_MAT_TIMESTAMPS = SQLITE_INDEX_MAT_TIMESTAMPS;
|
|
2682
|
+
exports.SQLITE_KIND_REMOVAL_TIMESTAMPS = SQLITE_KIND_REMOVAL_TIMESTAMPS;
|
|
2344
2683
|
exports.SQLITE_ROW_MAPPER_CONFIG = SQLITE_ROW_MAPPER_CONFIG;
|
|
2684
|
+
exports.buildKindRemovalInsertValues = buildKindRemovalInsertValues;
|
|
2685
|
+
exports.buildKindRemovalOnConflictSet = buildKindRemovalOnConflictSet;
|
|
2686
|
+
exports.buildMaterializationInsertValues = buildMaterializationInsertValues;
|
|
2687
|
+
exports.buildMaterializationOnConflictSet = buildMaterializationOnConflictSet;
|
|
2345
2688
|
exports.compileQueryWithDialect = compileQueryWithDialect;
|
|
2346
2689
|
exports.createCommonOperationBackend = createCommonOperationBackend;
|
|
2347
2690
|
exports.createEdgeRowMapper = createEdgeRowMapper;
|
|
@@ -2361,12 +2704,17 @@ exports.edges2 = edges2;
|
|
|
2361
2704
|
exports.embeddings = embeddings;
|
|
2362
2705
|
exports.embeddings2 = embeddings2;
|
|
2363
2706
|
exports.formatPostgresTimestamp = formatPostgresTimestamp;
|
|
2707
|
+
exports.fulltext = fulltext;
|
|
2708
|
+
exports.generatePgCreateTableSQL = generatePgCreateTableSQL;
|
|
2364
2709
|
exports.generatePostgresDDL = generatePostgresDDL;
|
|
2365
2710
|
exports.generatePostgresMigrationSQL = generatePostgresMigrationSQL;
|
|
2711
|
+
exports.generateSqliteCreateTableSQL = generateSqliteCreateTableSQL;
|
|
2366
2712
|
exports.generateSqliteDDL = generateSqliteDDL;
|
|
2367
2713
|
exports.generateSqliteMigrationSQL = generateSqliteMigrationSQL;
|
|
2368
2714
|
exports.generateVectorIndexName = generateVectorIndexName;
|
|
2369
2715
|
exports.getOrCreateLru = getOrCreateLru;
|
|
2716
|
+
exports.mapKindRemovalRow = mapKindRemovalRow;
|
|
2717
|
+
exports.mapMaterializationRow = mapMaterializationRow;
|
|
2370
2718
|
exports.nodes = nodes;
|
|
2371
2719
|
exports.nodes2 = nodes2;
|
|
2372
2720
|
exports.nowIso = nowIso;
|
|
@@ -2376,5 +2724,5 @@ exports.tables = tables;
|
|
|
2376
2724
|
exports.tables2 = tables2;
|
|
2377
2725
|
exports.uniques = uniques;
|
|
2378
2726
|
exports.uniques2 = uniques2;
|
|
2379
|
-
//# sourceMappingURL=chunk-
|
|
2380
|
-
//# sourceMappingURL=chunk-
|
|
2727
|
+
//# sourceMappingURL=chunk-CQVNGKU7.cjs.map
|
|
2728
|
+
//# sourceMappingURL=chunk-CQVNGKU7.cjs.map
|