@nicia-ai/typegraph 0.21.0 → 0.23.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/{ast-CSLbPIOC.d.ts → ast-C8S37w1A.d.ts} +1 -1
- package/dist/{ast-DogwbBqA.d.cts → ast-dgLhLOg0.d.cts} +1 -1
- package/dist/backend/postgres/index.cjs +169 -52
- package/dist/backend/postgres/index.cjs.map +1 -1
- package/dist/backend/postgres/index.d.cts +43 -6
- package/dist/backend/postgres/index.d.ts +43 -6
- package/dist/backend/postgres/index.js +140 -23
- package/dist/backend/postgres/index.js.map +1 -1
- package/dist/backend/sqlite/index.cjs +15 -14
- package/dist/backend/sqlite/index.d.cts +17 -6
- package/dist/backend/sqlite/index.d.ts +17 -6
- package/dist/backend/sqlite/index.js +5 -4
- package/dist/backend/sqlite/libsql.cjs +8 -7
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +4 -4
- package/dist/backend/sqlite/libsql.d.ts +4 -4
- package/dist/backend/sqlite/libsql.js +5 -4
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +27 -9
- package/dist/backend/sqlite/local.cjs.map +1 -1
- package/dist/backend/sqlite/local.d.cts +4 -4
- package/dist/backend/sqlite/local.d.ts +4 -4
- package/dist/backend/sqlite/local.js +22 -5
- package/dist/backend/sqlite/local.js.map +1 -1
- package/dist/chunk-3EUKJEQ3.js +77 -0
- package/dist/chunk-3EUKJEQ3.js.map +1 -0
- package/dist/{chunk-FQCQM3KG.cjs → chunk-3JK66E3I.cjs} +4 -2
- package/dist/chunk-3JK66E3I.cjs.map +1 -0
- package/dist/{chunk-SMMOAVJ5.js → chunk-3PPEHLGK.js} +3 -3
- package/dist/{chunk-SMMOAVJ5.js.map → chunk-3PPEHLGK.js.map} +1 -1
- package/dist/{chunk-4XNE2JG3.js → chunk-753F33CV.js} +4 -2
- package/dist/chunk-753F33CV.js.map +1 -0
- package/dist/{chunk-Q73OWTJY.cjs → chunk-7OD2EPN4.cjs} +130 -106
- package/dist/chunk-7OD2EPN4.cjs.map +1 -0
- package/dist/chunk-7TU5EWQ7.js +47 -0
- package/dist/chunk-7TU5EWQ7.js.map +1 -0
- package/dist/{chunk-NRNJ52AA.js → chunk-EP2KSSD5.js} +41 -25
- package/dist/chunk-EP2KSSD5.js.map +1 -0
- package/dist/{chunk-UQVBVBVG.js → chunk-H2CAJ4ZV.js} +71 -45
- package/dist/chunk-H2CAJ4ZV.js.map +1 -0
- package/dist/chunk-HTGDWIDE.cjs +89 -0
- package/dist/chunk-HTGDWIDE.cjs.map +1 -0
- package/dist/{chunk-CQL6FOTT.cjs → chunk-O5BRZEIZ.cjs} +58 -42
- package/dist/chunk-O5BRZEIZ.cjs.map +1 -0
- package/dist/{chunk-2X7P7AD5.cjs → chunk-PEE4EWXZ.cjs} +22 -22
- package/dist/{chunk-2X7P7AD5.cjs.map → chunk-PEE4EWXZ.cjs.map} +1 -1
- package/dist/chunk-RNUNP5JD.cjs +52 -0
- package/dist/chunk-RNUNP5JD.cjs.map +1 -0
- package/dist/{ddl-BqkTShcR.d.ts → ddl-1tFIvt9V.d.ts} +3 -3
- package/dist/{ddl-Dk1NDN3M.d.cts → ddl-B_H8JM-E.d.cts} +3 -3
- package/dist/index.cjs +267 -198
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -9
- package/dist/index.d.ts +53 -9
- package/dist/index.js +209 -142
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +16 -16
- package/dist/indexes/index.d.cts +5 -5
- package/dist/indexes/index.d.ts +5 -5
- package/dist/indexes/index.js +2 -2
- package/dist/interchange/index.d.cts +4 -4
- package/dist/interchange/index.d.ts +4 -4
- package/dist/{manager-BPK-2PUI.d.cts → manager-Vkz28eAC.d.cts} +1 -1
- package/dist/{manager-0jVZtiE8.d.ts → manager-nIhmttD-.d.ts} +1 -1
- package/dist/profiler/index.d.cts +6 -6
- package/dist/profiler/index.d.ts +6 -6
- package/dist/schema/index.d.cts +4 -4
- package/dist/schema/index.d.ts +4 -4
- package/dist/{sqlite-D1rrwcir.d.cts → sqlite-D0aceIe0.d.cts} +1 -1
- package/dist/{sqlite-W3rmJMlc.d.ts → sqlite-SUxbZqfy.d.ts} +1 -1
- package/dist/{store-C0q13mtJ.d.ts → store-CpvwTMxV.d.cts} +58 -8
- package/dist/{store-2QW2SIRk.d.cts → store-U3i2tUch.d.ts} +58 -8
- package/dist/{types-IMQCuser.d.ts → types-C-zfYDJB.d.ts} +2 -2
- package/dist/{types-vgjar7Ch.d.cts → types-CQx4iW5Y.d.cts} +2 -2
- package/dist/{types-CQF88McG.d.ts → types-Qk2l3IkQ.d.cts} +20 -1
- package/dist/{types-CQF88McG.d.cts → types-Qk2l3IkQ.d.ts} +20 -1
- package/dist/{types-CglvhPKz.d.ts → types-qYFZ9SqD.d.ts} +1 -1
- package/dist/{types-D23slCOA.d.cts → types-yH4_p0XB.d.cts} +1 -1
- package/package.json +15 -1
- package/dist/chunk-4XNE2JG3.js.map +0 -1
- package/dist/chunk-CQL6FOTT.cjs.map +0 -1
- package/dist/chunk-FQCQM3KG.cjs.map +0 -1
- package/dist/chunk-NRNJ52AA.js.map +0 -1
- package/dist/chunk-Q73OWTJY.cjs.map +0 -1
- package/dist/chunk-UQVBVBVG.js.map +0 -1
|
@@ -1,49 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkO5PST6TB_cjs = require('./chunk-O5PST6TB.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var chunkPEE4EWXZ_cjs = require('./chunk-PEE4EWXZ.cjs');
|
|
5
|
+
var chunk3JK66E3I_cjs = require('./chunk-3JK66E3I.cjs');
|
|
6
6
|
var pgCore = require('drizzle-orm/pg-core');
|
|
7
7
|
var sqliteCore = require('drizzle-orm/sqlite-core');
|
|
8
8
|
var drizzleOrm = require('drizzle-orm');
|
|
9
9
|
|
|
10
|
-
// src/backend/types.ts
|
|
11
|
-
function wrapWithManagedClose(backend, teardown) {
|
|
12
|
-
let isClosed = false;
|
|
13
|
-
return {
|
|
14
|
-
...backend,
|
|
15
|
-
async close() {
|
|
16
|
-
if (isClosed) return;
|
|
17
|
-
isClosed = true;
|
|
18
|
-
await backend.close();
|
|
19
|
-
await teardown();
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
var SQLITE_CAPABILITIES = {
|
|
24
|
-
jsonb: false,
|
|
25
|
-
// SQLite uses TEXT with json functions
|
|
26
|
-
partialIndexes: true,
|
|
27
|
-
// SQLite supports WHERE in CREATE INDEX
|
|
28
|
-
ginIndexes: false,
|
|
29
|
-
// SQLite doesn't have GIN
|
|
30
|
-
cte: true,
|
|
31
|
-
// SQLite supports WITH
|
|
32
|
-
returning: true,
|
|
33
|
-
// SQLite 3.35+ supports RETURNING
|
|
34
|
-
transactions: true
|
|
35
|
-
// SQLite supports transactions
|
|
36
|
-
};
|
|
37
|
-
var POSTGRES_CAPABILITIES = {
|
|
38
|
-
jsonb: true,
|
|
39
|
-
// PostgreSQL has native JSONB
|
|
40
|
-
partialIndexes: true,
|
|
41
|
-
ginIndexes: true,
|
|
42
|
-
cte: true,
|
|
43
|
-
returning: true,
|
|
44
|
-
transactions: true
|
|
45
|
-
// PostgreSQL supports transactions
|
|
46
|
-
};
|
|
47
10
|
var vector = pgCore.customType({
|
|
48
11
|
dataType(config) {
|
|
49
12
|
return config?.dimensions ? `vector(${config.dimensions})` : "vector";
|
|
@@ -100,7 +63,7 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
100
63
|
),
|
|
101
64
|
pgCore.index(`${n.nodes}_deleted_idx`).on(t.graphId, t.deletedAt),
|
|
102
65
|
pgCore.index(`${n.nodes}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),
|
|
103
|
-
...
|
|
66
|
+
...chunkPEE4EWXZ_cjs.buildPostgresNodeIndexBuilders(t, indexes)
|
|
104
67
|
]
|
|
105
68
|
);
|
|
106
69
|
const edges3 = pgCore.pgTable(
|
|
@@ -159,7 +122,7 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
159
122
|
t.fromId,
|
|
160
123
|
t.validTo
|
|
161
124
|
),
|
|
162
|
-
...
|
|
125
|
+
...chunkPEE4EWXZ_cjs.buildPostgresEdgeIndexBuilders(t, indexes)
|
|
163
126
|
]
|
|
164
127
|
);
|
|
165
128
|
const uniques3 = pgCore.pgTable(
|
|
@@ -283,7 +246,7 @@ function createSqliteTables(names = {}, options = {}) {
|
|
|
283
246
|
),
|
|
284
247
|
sqliteCore.index(`${n.nodes}_deleted_idx`).on(t.graphId, t.deletedAt),
|
|
285
248
|
sqliteCore.index(`${n.nodes}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),
|
|
286
|
-
...
|
|
249
|
+
...chunkPEE4EWXZ_cjs.buildSqliteNodeIndexBuilders(t, indexes)
|
|
287
250
|
]
|
|
288
251
|
);
|
|
289
252
|
const edges3 = sqliteCore.sqliteTable(
|
|
@@ -342,7 +305,7 @@ function createSqliteTables(names = {}, options = {}) {
|
|
|
342
305
|
t.fromId,
|
|
343
306
|
t.validTo
|
|
344
307
|
),
|
|
345
|
-
...
|
|
308
|
+
...chunkPEE4EWXZ_cjs.buildSqliteEdgeIndexBuilders(t, indexes)
|
|
346
309
|
]
|
|
347
310
|
);
|
|
348
311
|
const uniques3 = sqliteCore.sqliteTable(
|
|
@@ -505,8 +468,17 @@ function flattenSqlChunk(chunk) {
|
|
|
505
468
|
return chunk;
|
|
506
469
|
}
|
|
507
470
|
if (typeof chunk === "object" && chunk !== null) {
|
|
508
|
-
if ("
|
|
509
|
-
return chunk.
|
|
471
|
+
if ("name" in chunk && typeof chunk.name === "string") {
|
|
472
|
+
return `"${chunk.name}"`;
|
|
473
|
+
}
|
|
474
|
+
if ("value" in chunk) {
|
|
475
|
+
const value = chunk.value;
|
|
476
|
+
if (typeof value === "string") {
|
|
477
|
+
return value;
|
|
478
|
+
}
|
|
479
|
+
if (Array.isArray(value)) {
|
|
480
|
+
return value.map((part) => flattenSqlChunk(part)).join("");
|
|
481
|
+
}
|
|
510
482
|
}
|
|
511
483
|
if ("queryChunks" in chunk && Array.isArray(chunk.queryChunks)) {
|
|
512
484
|
return chunk.queryChunks.map((part) => flattenSqlChunk(part)).join("");
|
|
@@ -552,7 +524,7 @@ function isSqliteTable(value) {
|
|
|
552
524
|
return typeof value === "object" && value !== null && // Drizzle tables are always objects; strings are our escape hatch.
|
|
553
525
|
typeof value !== "string";
|
|
554
526
|
}
|
|
555
|
-
function generateSqliteDDL(tables3 = tables2, fulltextStrategy =
|
|
527
|
+
function generateSqliteDDL(tables3 = tables2, fulltextStrategy = chunk3JK66E3I_cjs.fts5Strategy) {
|
|
556
528
|
const statements = [];
|
|
557
529
|
for (const table of Object.values(tables3)) {
|
|
558
530
|
if (!isSqliteTable(table)) continue;
|
|
@@ -565,7 +537,7 @@ function generateSqliteDDL(tables3 = tables2, fulltextStrategy = chunkFQCQM3KG_c
|
|
|
565
537
|
statements.push(...fulltextStrategy.generateDdl(tables3.fulltextTableName));
|
|
566
538
|
return statements;
|
|
567
539
|
}
|
|
568
|
-
function generateSqliteMigrationSQL(tables3 = tables2, fulltextStrategy =
|
|
540
|
+
function generateSqliteMigrationSQL(tables3 = tables2, fulltextStrategy = chunk3JK66E3I_cjs.fts5Strategy) {
|
|
569
541
|
return generateSqliteDDL(tables3, fulltextStrategy).join("\n\n");
|
|
570
542
|
}
|
|
571
543
|
function getPgColumnType(column) {
|
|
@@ -650,7 +622,7 @@ function generatePgCreateIndexSQL(table) {
|
|
|
650
622
|
function isPgTable(value) {
|
|
651
623
|
return typeof value === "object" && value !== null && typeof value !== "string";
|
|
652
624
|
}
|
|
653
|
-
function generatePostgresDDL(tables3 = tables, fulltextStrategy =
|
|
625
|
+
function generatePostgresDDL(tables3 = tables, fulltextStrategy = chunk3JK66E3I_cjs.tsvectorStrategy) {
|
|
654
626
|
const statements = [];
|
|
655
627
|
for (const table of Object.values(tables3)) {
|
|
656
628
|
if (!isPgTable(table)) continue;
|
|
@@ -663,7 +635,7 @@ function generatePostgresDDL(tables3 = tables, fulltextStrategy = chunkFQCQM3KG_
|
|
|
663
635
|
statements.push(...fulltextStrategy.generateDdl(tables3.fulltextTableName));
|
|
664
636
|
return statements;
|
|
665
637
|
}
|
|
666
|
-
function generatePostgresMigrationSQL(tables3 = tables, fulltextStrategy =
|
|
638
|
+
function generatePostgresMigrationSQL(tables3 = tables, fulltextStrategy = chunk3JK66E3I_cjs.tsvectorStrategy) {
|
|
667
639
|
const extensionSql = "-- Enable pgvector extension for vector similarity search\nCREATE EXTENSION IF NOT EXISTS vector;";
|
|
668
640
|
const ddlSql = generatePostgresDDL(tables3, fulltextStrategy).join("\n\n");
|
|
669
641
|
return `${extensionSql}
|
|
@@ -1074,7 +1046,7 @@ function createCommonOperationBackend(options) {
|
|
|
1074
1046
|
};
|
|
1075
1047
|
}
|
|
1076
1048
|
function buildClearGraph(tables3, graphId) {
|
|
1077
|
-
const fulltext =
|
|
1049
|
+
const fulltext = chunk3JK66E3I_cjs.quotedTableName(tables3.fulltextTableName);
|
|
1078
1050
|
return [
|
|
1079
1051
|
drizzleOrm.sql`DELETE FROM ${fulltext} WHERE "graph_id" = ${graphId}`,
|
|
1080
1052
|
drizzleOrm.sql`DELETE FROM ${tables3.embeddings} WHERE ${tables3.embeddings.graphId} = ${graphId}`,
|
|
@@ -1221,13 +1193,13 @@ function buildCountEdgesByKind(tables3, params) {
|
|
|
1221
1193
|
function buildInsertEdge(tables3, params, timestamp2) {
|
|
1222
1194
|
const { edges: edges3 } = tables3;
|
|
1223
1195
|
const propsJson = JSON.stringify(params.props);
|
|
1224
|
-
const columns =
|
|
1196
|
+
const columns = chunk3JK66E3I_cjs.edgeColumnList(edges3);
|
|
1225
1197
|
return drizzleOrm.sql`
|
|
1226
1198
|
INSERT INTO ${edges3} (${columns})
|
|
1227
1199
|
VALUES (
|
|
1228
1200
|
${params.graphId}, ${params.id}, ${params.kind},
|
|
1229
1201
|
${params.fromKind}, ${params.fromId}, ${params.toKind}, ${params.toId},
|
|
1230
|
-
${propsJson}, ${
|
|
1202
|
+
${propsJson}, ${chunk3JK66E3I_cjs.sqlNull(params.validFrom)}, ${chunk3JK66E3I_cjs.sqlNull(params.validTo)},
|
|
1231
1203
|
${timestamp2}, ${timestamp2}
|
|
1232
1204
|
)
|
|
1233
1205
|
RETURNING *
|
|
@@ -1236,23 +1208,23 @@ function buildInsertEdge(tables3, params, timestamp2) {
|
|
|
1236
1208
|
function buildInsertEdgeNoReturn(tables3, params, timestamp2) {
|
|
1237
1209
|
const { edges: edges3 } = tables3;
|
|
1238
1210
|
const propsJson = JSON.stringify(params.props);
|
|
1239
|
-
const columns =
|
|
1211
|
+
const columns = chunk3JK66E3I_cjs.edgeColumnList(edges3);
|
|
1240
1212
|
return drizzleOrm.sql`
|
|
1241
1213
|
INSERT INTO ${edges3} (${columns})
|
|
1242
1214
|
VALUES (
|
|
1243
1215
|
${params.graphId}, ${params.id}, ${params.kind},
|
|
1244
1216
|
${params.fromKind}, ${params.fromId}, ${params.toKind}, ${params.toId},
|
|
1245
|
-
${propsJson}, ${
|
|
1217
|
+
${propsJson}, ${chunk3JK66E3I_cjs.sqlNull(params.validFrom)}, ${chunk3JK66E3I_cjs.sqlNull(params.validTo)},
|
|
1246
1218
|
${timestamp2}, ${timestamp2}
|
|
1247
1219
|
)
|
|
1248
1220
|
`;
|
|
1249
1221
|
}
|
|
1250
1222
|
function buildInsertEdgesBatch(tables3, params, timestamp2) {
|
|
1251
1223
|
const { edges: edges3 } = tables3;
|
|
1252
|
-
const columns =
|
|
1224
|
+
const columns = chunk3JK66E3I_cjs.edgeColumnList(edges3);
|
|
1253
1225
|
const values = params.map((edgeParams) => {
|
|
1254
1226
|
const propsJson = JSON.stringify(edgeParams.props);
|
|
1255
|
-
return drizzleOrm.sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${
|
|
1227
|
+
return drizzleOrm.sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${chunk3JK66E3I_cjs.sqlNull(edgeParams.validFrom)}, ${chunk3JK66E3I_cjs.sqlNull(edgeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1256
1228
|
});
|
|
1257
1229
|
return drizzleOrm.sql`
|
|
1258
1230
|
INSERT INTO ${edges3} (${columns})
|
|
@@ -1261,10 +1233,10 @@ function buildInsertEdgesBatch(tables3, params, timestamp2) {
|
|
|
1261
1233
|
}
|
|
1262
1234
|
function buildInsertEdgesBatchReturning(tables3, params, timestamp2) {
|
|
1263
1235
|
const { edges: edges3 } = tables3;
|
|
1264
|
-
const columns =
|
|
1236
|
+
const columns = chunk3JK66E3I_cjs.edgeColumnList(edges3);
|
|
1265
1237
|
const values = params.map((edgeParams) => {
|
|
1266
1238
|
const propsJson = JSON.stringify(edgeParams.props);
|
|
1267
|
-
return drizzleOrm.sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${
|
|
1239
|
+
return drizzleOrm.sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${chunk3JK66E3I_cjs.sqlNull(edgeParams.validFrom)}, ${chunk3JK66E3I_cjs.sqlNull(edgeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1268
1240
|
});
|
|
1269
1241
|
return drizzleOrm.sql`
|
|
1270
1242
|
INSERT INTO ${edges3} (${columns})
|
|
@@ -1296,14 +1268,14 @@ function buildUpdateEdge(tables3, params, timestamp2) {
|
|
|
1296
1268
|
const { edges: edges3 } = tables3;
|
|
1297
1269
|
const propsJson = JSON.stringify(params.props);
|
|
1298
1270
|
const setParts = [
|
|
1299
|
-
drizzleOrm.sql`${
|
|
1300
|
-
drizzleOrm.sql`${
|
|
1271
|
+
drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(edges3.props)} = ${propsJson}`,
|
|
1272
|
+
drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(edges3.updatedAt)} = ${timestamp2}`
|
|
1301
1273
|
];
|
|
1302
1274
|
if (params.validTo !== void 0) {
|
|
1303
|
-
setParts.push(drizzleOrm.sql`${
|
|
1275
|
+
setParts.push(drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(edges3.validTo)} = ${params.validTo}`);
|
|
1304
1276
|
}
|
|
1305
1277
|
if (params.clearDeleted) {
|
|
1306
|
-
setParts.push(drizzleOrm.sql`${
|
|
1278
|
+
setParts.push(drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(edges3.deletedAt)} = NULL`);
|
|
1307
1279
|
}
|
|
1308
1280
|
const setClause = drizzleOrm.sql.join(setParts, drizzleOrm.sql`, `);
|
|
1309
1281
|
if (params.clearDeleted) {
|
|
@@ -1328,7 +1300,7 @@ function buildDeleteEdge(tables3, params, timestamp2) {
|
|
|
1328
1300
|
const { edges: edges3 } = tables3;
|
|
1329
1301
|
return drizzleOrm.sql`
|
|
1330
1302
|
UPDATE ${edges3}
|
|
1331
|
-
SET ${
|
|
1303
|
+
SET ${chunk3JK66E3I_cjs.quotedColumn(edges3.deletedAt)} = ${timestamp2}
|
|
1332
1304
|
WHERE ${edges3.graphId} = ${params.graphId}
|
|
1333
1305
|
AND ${edges3.id} = ${params.id}
|
|
1334
1306
|
AND ${edges3.deletedAt} IS NULL
|
|
@@ -1415,7 +1387,7 @@ function resolveMode(mode) {
|
|
|
1415
1387
|
function buildFulltextSearch(tableName, params, strategy) {
|
|
1416
1388
|
assertValidSearchParams(params);
|
|
1417
1389
|
const mode = resolveMode(params.mode);
|
|
1418
|
-
const table =
|
|
1390
|
+
const table = chunk3JK66E3I_cjs.quotedTableName(tableName);
|
|
1419
1391
|
const matchCondition = strategy.matchCondition(
|
|
1420
1392
|
tableName,
|
|
1421
1393
|
params.query,
|
|
@@ -1466,12 +1438,12 @@ function assertValidSearchParams(params) {
|
|
|
1466
1438
|
function buildInsertNode(tables3, params, timestamp2) {
|
|
1467
1439
|
const { nodes: nodes3 } = tables3;
|
|
1468
1440
|
const propsJson = JSON.stringify(params.props);
|
|
1469
|
-
const columns =
|
|
1441
|
+
const columns = chunk3JK66E3I_cjs.nodeColumnList(nodes3);
|
|
1470
1442
|
return drizzleOrm.sql`
|
|
1471
1443
|
INSERT INTO ${nodes3} (${columns})
|
|
1472
1444
|
VALUES (
|
|
1473
1445
|
${params.graphId}, ${params.kind}, ${params.id}, ${propsJson},
|
|
1474
|
-
1, ${
|
|
1446
|
+
1, ${chunk3JK66E3I_cjs.sqlNull(params.validFrom)}, ${chunk3JK66E3I_cjs.sqlNull(params.validTo)},
|
|
1475
1447
|
${timestamp2}, ${timestamp2}
|
|
1476
1448
|
)
|
|
1477
1449
|
RETURNING *
|
|
@@ -1480,22 +1452,22 @@ function buildInsertNode(tables3, params, timestamp2) {
|
|
|
1480
1452
|
function buildInsertNodeNoReturn(tables3, params, timestamp2) {
|
|
1481
1453
|
const { nodes: nodes3 } = tables3;
|
|
1482
1454
|
const propsJson = JSON.stringify(params.props);
|
|
1483
|
-
const columns =
|
|
1455
|
+
const columns = chunk3JK66E3I_cjs.nodeColumnList(nodes3);
|
|
1484
1456
|
return drizzleOrm.sql`
|
|
1485
1457
|
INSERT INTO ${nodes3} (${columns})
|
|
1486
1458
|
VALUES (
|
|
1487
1459
|
${params.graphId}, ${params.kind}, ${params.id}, ${propsJson},
|
|
1488
|
-
1, ${
|
|
1460
|
+
1, ${chunk3JK66E3I_cjs.sqlNull(params.validFrom)}, ${chunk3JK66E3I_cjs.sqlNull(params.validTo)},
|
|
1489
1461
|
${timestamp2}, ${timestamp2}
|
|
1490
1462
|
)
|
|
1491
1463
|
`;
|
|
1492
1464
|
}
|
|
1493
1465
|
function buildInsertNodesBatch(tables3, params, timestamp2) {
|
|
1494
1466
|
const { nodes: nodes3 } = tables3;
|
|
1495
|
-
const columns =
|
|
1467
|
+
const columns = chunk3JK66E3I_cjs.nodeColumnList(nodes3);
|
|
1496
1468
|
const values = params.map((nodeParams) => {
|
|
1497
1469
|
const propsJson = JSON.stringify(nodeParams.props);
|
|
1498
|
-
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${
|
|
1470
|
+
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${chunk3JK66E3I_cjs.sqlNull(nodeParams.validFrom)}, ${chunk3JK66E3I_cjs.sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1499
1471
|
});
|
|
1500
1472
|
return drizzleOrm.sql`
|
|
1501
1473
|
INSERT INTO ${nodes3} (${columns})
|
|
@@ -1504,10 +1476,10 @@ function buildInsertNodesBatch(tables3, params, timestamp2) {
|
|
|
1504
1476
|
}
|
|
1505
1477
|
function buildInsertNodesBatchReturning(tables3, params, timestamp2) {
|
|
1506
1478
|
const { nodes: nodes3 } = tables3;
|
|
1507
|
-
const columns =
|
|
1479
|
+
const columns = chunk3JK66E3I_cjs.nodeColumnList(nodes3);
|
|
1508
1480
|
const values = params.map((nodeParams) => {
|
|
1509
1481
|
const propsJson = JSON.stringify(nodeParams.props);
|
|
1510
|
-
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${
|
|
1482
|
+
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${chunk3JK66E3I_cjs.sqlNull(nodeParams.validFrom)}, ${chunk3JK66E3I_cjs.sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1511
1483
|
});
|
|
1512
1484
|
return drizzleOrm.sql`
|
|
1513
1485
|
INSERT INTO ${nodes3} (${columns})
|
|
@@ -1541,19 +1513,19 @@ function buildUpdateNode(tables3, params, timestamp2) {
|
|
|
1541
1513
|
const { nodes: nodes3 } = tables3;
|
|
1542
1514
|
const propsJson = JSON.stringify(params.props);
|
|
1543
1515
|
const setParts = [
|
|
1544
|
-
drizzleOrm.sql`${
|
|
1545
|
-
drizzleOrm.sql`${
|
|
1516
|
+
drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(nodes3.props)} = ${propsJson}`,
|
|
1517
|
+
drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(nodes3.updatedAt)} = ${timestamp2}`
|
|
1546
1518
|
];
|
|
1547
1519
|
if (params.incrementVersion) {
|
|
1548
1520
|
setParts.push(
|
|
1549
|
-
drizzleOrm.sql`${
|
|
1521
|
+
drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(nodes3.version)} = ${chunk3JK66E3I_cjs.quotedColumn(nodes3.version)} + 1`
|
|
1550
1522
|
);
|
|
1551
1523
|
}
|
|
1552
1524
|
if (params.validTo !== void 0) {
|
|
1553
|
-
setParts.push(drizzleOrm.sql`${
|
|
1525
|
+
setParts.push(drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(nodes3.validTo)} = ${params.validTo}`);
|
|
1554
1526
|
}
|
|
1555
1527
|
if (params.clearDeleted) {
|
|
1556
|
-
setParts.push(drizzleOrm.sql`${
|
|
1528
|
+
setParts.push(drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(nodes3.deletedAt)} = NULL`);
|
|
1557
1529
|
}
|
|
1558
1530
|
const setClause = drizzleOrm.sql.join(setParts, drizzleOrm.sql`, `);
|
|
1559
1531
|
if (params.clearDeleted) {
|
|
@@ -1580,7 +1552,7 @@ function buildDeleteNode(tables3, params, timestamp2) {
|
|
|
1580
1552
|
const { nodes: nodes3 } = tables3;
|
|
1581
1553
|
return drizzleOrm.sql`
|
|
1582
1554
|
UPDATE ${nodes3}
|
|
1583
|
-
SET ${
|
|
1555
|
+
SET ${chunk3JK66E3I_cjs.quotedColumn(nodes3.deletedAt)} = ${timestamp2}
|
|
1584
1556
|
WHERE ${nodes3.graphId} = ${params.graphId}
|
|
1585
1557
|
AND ${nodes3.kind} = ${params.kind}
|
|
1586
1558
|
AND ${nodes3.id} = ${params.id}
|
|
@@ -1647,12 +1619,12 @@ function buildSetActiveSchema(tables3, graphId, version, dialect = "sqlite") {
|
|
|
1647
1619
|
const strategy = SCHEMA_DIALECT_STRATEGIES[dialect];
|
|
1648
1620
|
const deactivateAll = drizzleOrm.sql`
|
|
1649
1621
|
UPDATE ${schemaVersions3}
|
|
1650
|
-
SET ${
|
|
1622
|
+
SET ${chunk3JK66E3I_cjs.quotedColumn(schemaVersions3.isActive)} = ${strategy.booleanLiteral(false)}
|
|
1651
1623
|
WHERE ${schemaVersions3.graphId} = ${graphId}
|
|
1652
1624
|
`;
|
|
1653
1625
|
const activateVersion = drizzleOrm.sql`
|
|
1654
1626
|
UPDATE ${schemaVersions3}
|
|
1655
|
-
SET ${
|
|
1627
|
+
SET ${chunk3JK66E3I_cjs.quotedColumn(schemaVersions3.isActive)} = ${strategy.booleanLiteral(true)}
|
|
1656
1628
|
WHERE ${schemaVersions3.graphId} = ${graphId}
|
|
1657
1629
|
AND ${schemaVersions3.version} = ${version}
|
|
1658
1630
|
`;
|
|
@@ -1670,22 +1642,22 @@ function buildInsertUniqueSqlite(tables3, params) {
|
|
|
1670
1642
|
)
|
|
1671
1643
|
ON CONFLICT (${conflictColumns})
|
|
1672
1644
|
DO UPDATE SET
|
|
1673
|
-
${
|
|
1674
|
-
WHEN ${
|
|
1675
|
-
WHEN ${
|
|
1676
|
-
ELSE ${
|
|
1645
|
+
${chunk3JK66E3I_cjs.quotedColumn(uniques3.nodeId)} = CASE
|
|
1646
|
+
WHEN ${chunk3JK66E3I_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.nodeId}
|
|
1647
|
+
WHEN ${chunk3JK66E3I_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.nodeId}
|
|
1648
|
+
ELSE ${chunk3JK66E3I_cjs.quotedColumn(uniques3.nodeId)}
|
|
1677
1649
|
END,
|
|
1678
|
-
${
|
|
1679
|
-
WHEN ${
|
|
1680
|
-
WHEN ${
|
|
1681
|
-
ELSE ${
|
|
1650
|
+
${chunk3JK66E3I_cjs.quotedColumn(uniques3.concreteKind)} = CASE
|
|
1651
|
+
WHEN ${chunk3JK66E3I_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.concreteKind}
|
|
1652
|
+
WHEN ${chunk3JK66E3I_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.concreteKind}
|
|
1653
|
+
ELSE ${chunk3JK66E3I_cjs.quotedColumn(uniques3.concreteKind)}
|
|
1682
1654
|
END,
|
|
1683
|
-
${
|
|
1684
|
-
WHEN ${
|
|
1685
|
-
WHEN ${
|
|
1686
|
-
ELSE ${
|
|
1655
|
+
${chunk3JK66E3I_cjs.quotedColumn(uniques3.deletedAt)} = CASE
|
|
1656
|
+
WHEN ${chunk3JK66E3I_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN NULL
|
|
1657
|
+
WHEN ${chunk3JK66E3I_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN NULL
|
|
1658
|
+
ELSE ${chunk3JK66E3I_cjs.quotedColumn(uniques3.deletedAt)}
|
|
1687
1659
|
END
|
|
1688
|
-
RETURNING ${
|
|
1660
|
+
RETURNING ${chunk3JK66E3I_cjs.quotedColumn(uniques3.nodeId)} as node_id
|
|
1689
1661
|
`;
|
|
1690
1662
|
}
|
|
1691
1663
|
function buildInsertUniquePostgres(tables3, params) {
|
|
@@ -1702,22 +1674,22 @@ function buildInsertUniquePostgres(tables3, params) {
|
|
|
1702
1674
|
)
|
|
1703
1675
|
ON CONFLICT (${conflictColumns})
|
|
1704
1676
|
DO UPDATE SET
|
|
1705
|
-
${
|
|
1677
|
+
${chunk3JK66E3I_cjs.quotedColumn(uniques3.nodeId)} = CASE
|
|
1706
1678
|
WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.nodeId}
|
|
1707
1679
|
WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.nodeId}
|
|
1708
1680
|
ELSE ${existingColumn(uniques3.nodeId)}
|
|
1709
1681
|
END,
|
|
1710
|
-
${
|
|
1682
|
+
${chunk3JK66E3I_cjs.quotedColumn(uniques3.concreteKind)} = CASE
|
|
1711
1683
|
WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.concreteKind}
|
|
1712
1684
|
WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.concreteKind}
|
|
1713
1685
|
ELSE ${existingColumn(uniques3.concreteKind)}
|
|
1714
1686
|
END,
|
|
1715
|
-
${
|
|
1687
|
+
${chunk3JK66E3I_cjs.quotedColumn(uniques3.deletedAt)} = CASE
|
|
1716
1688
|
WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN NULL
|
|
1717
1689
|
WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN NULL
|
|
1718
1690
|
ELSE ${existingColumn(uniques3.deletedAt)}
|
|
1719
1691
|
END
|
|
1720
|
-
RETURNING ${
|
|
1692
|
+
RETURNING ${chunk3JK66E3I_cjs.quotedColumn(uniques3.nodeId)} as node_id
|
|
1721
1693
|
`;
|
|
1722
1694
|
}
|
|
1723
1695
|
var UNIQUE_INSERT_BUILDERS = {
|
|
@@ -1732,7 +1704,7 @@ function buildDeleteUnique(tables3, params, timestamp2) {
|
|
|
1732
1704
|
const { uniques: uniques3 } = tables3;
|
|
1733
1705
|
return drizzleOrm.sql`
|
|
1734
1706
|
UPDATE ${uniques3}
|
|
1735
|
-
SET ${
|
|
1707
|
+
SET ${chunk3JK66E3I_cjs.quotedColumn(uniques3.deletedAt)} = ${timestamp2}
|
|
1736
1708
|
WHERE ${uniques3.graphId} = ${params.graphId}
|
|
1737
1709
|
AND ${uniques3.nodeKind} = ${params.nodeKind}
|
|
1738
1710
|
AND ${uniques3.constraintName} = ${params.constraintName}
|
|
@@ -1837,6 +1809,30 @@ function buildUpsertEmbeddingPostgres(tables3, params, timestamp2) {
|
|
|
1837
1809
|
${column(embeddings3.updatedAt)} = ${timestamp2}
|
|
1838
1810
|
`;
|
|
1839
1811
|
}
|
|
1812
|
+
function buildUpsertEmbeddingSqlite(tables3, params, timestamp2) {
|
|
1813
|
+
const { embeddings: embeddings3 } = tables3;
|
|
1814
|
+
const embeddingJson = JSON.stringify(params.embedding);
|
|
1815
|
+
assertFiniteNumberArray(params.embedding, "embedding");
|
|
1816
|
+
const columns = drizzleOrm.sql.raw(
|
|
1817
|
+
`"${embeddings3.graphId.name}", "${embeddings3.nodeKind.name}", "${embeddings3.nodeId.name}", "${embeddings3.fieldPath.name}", "${embeddings3.embedding.name}", "${embeddings3.dimensions.name}", "${embeddings3.createdAt.name}", "${embeddings3.updatedAt.name}"`
|
|
1818
|
+
);
|
|
1819
|
+
const conflictColumns = drizzleOrm.sql.raw(
|
|
1820
|
+
`"${embeddings3.graphId.name}", "${embeddings3.nodeKind.name}", "${embeddings3.nodeId.name}", "${embeddings3.fieldPath.name}"`
|
|
1821
|
+
);
|
|
1822
|
+
const column = (target) => drizzleOrm.sql.raw(`"${target.name}"`);
|
|
1823
|
+
return drizzleOrm.sql`
|
|
1824
|
+
INSERT INTO ${embeddings3} (${columns})
|
|
1825
|
+
VALUES (
|
|
1826
|
+
${params.graphId}, ${params.nodeKind}, ${params.nodeId}, ${params.fieldPath},
|
|
1827
|
+
vec_f32(${embeddingJson}), ${params.dimensions}, ${timestamp2}, ${timestamp2}
|
|
1828
|
+
)
|
|
1829
|
+
ON CONFLICT (${conflictColumns})
|
|
1830
|
+
DO UPDATE SET
|
|
1831
|
+
${column(embeddings3.embedding)} = vec_f32(${embeddingJson}),
|
|
1832
|
+
${column(embeddings3.dimensions)} = ${params.dimensions},
|
|
1833
|
+
${column(embeddings3.updatedAt)} = ${timestamp2}
|
|
1834
|
+
`;
|
|
1835
|
+
}
|
|
1840
1836
|
function buildDeleteEmbedding(tables3, params) {
|
|
1841
1837
|
const { embeddings: embeddings3 } = tables3;
|
|
1842
1838
|
return drizzleOrm.sql`
|
|
@@ -2039,7 +2035,20 @@ function createCommonOperationStrategy(tables3, dialect, fulltextStrategy) {
|
|
|
2039
2035
|
};
|
|
2040
2036
|
}
|
|
2041
2037
|
function createSqliteOperationStrategy(tables3, fulltextStrategy) {
|
|
2042
|
-
|
|
2038
|
+
const common = createCommonOperationStrategy(
|
|
2039
|
+
tables3,
|
|
2040
|
+
"sqlite",
|
|
2041
|
+
fulltextStrategy
|
|
2042
|
+
);
|
|
2043
|
+
return {
|
|
2044
|
+
...common,
|
|
2045
|
+
buildUpsertEmbedding(params, timestamp2) {
|
|
2046
|
+
return buildUpsertEmbeddingSqlite(tables3, params, timestamp2);
|
|
2047
|
+
},
|
|
2048
|
+
buildDeleteEmbedding(params) {
|
|
2049
|
+
return buildDeleteEmbedding(tables3, params);
|
|
2050
|
+
}
|
|
2051
|
+
};
|
|
2043
2052
|
}
|
|
2044
2053
|
function createPostgresOperationStrategy(tables3, fulltextStrategy) {
|
|
2045
2054
|
const common = createCommonOperationStrategy(
|
|
@@ -2104,11 +2113,11 @@ function generateVectorIndexName(graphId, nodeKind, fieldPath, metric = "cosine"
|
|
|
2104
2113
|
metric
|
|
2105
2114
|
];
|
|
2106
2115
|
const name = parts.join("_");
|
|
2107
|
-
if (name.length <=
|
|
2116
|
+
if (name.length <= chunk3JK66E3I_cjs.MAX_PG_IDENTIFIER_LENGTH) {
|
|
2108
2117
|
return name;
|
|
2109
2118
|
}
|
|
2110
2119
|
const hash = shortHash(name);
|
|
2111
|
-
const truncated = name.slice(0,
|
|
2120
|
+
const truncated = name.slice(0, chunk3JK66E3I_cjs.MAX_PG_IDENTIFIER_LENGTH - 1 - hash.length);
|
|
2112
2121
|
return `${truncated}_${hash}`;
|
|
2113
2122
|
}
|
|
2114
2123
|
function getOperatorClass(metric) {
|
|
@@ -2239,6 +2248,23 @@ function dropSqliteVectorIndex(graphId, nodeKind, fieldPath, metric = "cosine")
|
|
|
2239
2248
|
};
|
|
2240
2249
|
}
|
|
2241
2250
|
|
|
2251
|
+
// src/backend/drizzle/execution/lru.ts
|
|
2252
|
+
function getOrCreateLru(cache, key, cacheMax, create) {
|
|
2253
|
+
const cached = cache.get(key);
|
|
2254
|
+
if (cached !== void 0) {
|
|
2255
|
+
cache.delete(key);
|
|
2256
|
+
cache.set(key, cached);
|
|
2257
|
+
return cached;
|
|
2258
|
+
}
|
|
2259
|
+
const value = create();
|
|
2260
|
+
cache.set(key, value);
|
|
2261
|
+
if (cache.size > cacheMax) {
|
|
2262
|
+
const oldest = cache.keys().next().value;
|
|
2263
|
+
if (oldest !== void 0) cache.delete(oldest);
|
|
2264
|
+
}
|
|
2265
|
+
return value;
|
|
2266
|
+
}
|
|
2267
|
+
|
|
2242
2268
|
// src/backend/drizzle/execution/types.ts
|
|
2243
2269
|
function compileQueryWithDialect(db, query, backendName) {
|
|
2244
2270
|
const databaseWithCompiler = db;
|
|
@@ -2249,9 +2275,7 @@ function compileQueryWithDialect(db, query, backendName) {
|
|
|
2249
2275
|
return compiler.sqlToQuery(query);
|
|
2250
2276
|
}
|
|
2251
2277
|
|
|
2252
|
-
exports.POSTGRES_CAPABILITIES = POSTGRES_CAPABILITIES;
|
|
2253
2278
|
exports.POSTGRES_ROW_MAPPER_CONFIG = POSTGRES_ROW_MAPPER_CONFIG;
|
|
2254
|
-
exports.SQLITE_CAPABILITIES = SQLITE_CAPABILITIES;
|
|
2255
2279
|
exports.SQLITE_ROW_MAPPER_CONFIG = SQLITE_ROW_MAPPER_CONFIG;
|
|
2256
2280
|
exports.compileQueryWithDialect = compileQueryWithDialect;
|
|
2257
2281
|
exports.createCommonOperationBackend = createCommonOperationBackend;
|
|
@@ -2277,6 +2301,7 @@ exports.generatePostgresMigrationSQL = generatePostgresMigrationSQL;
|
|
|
2277
2301
|
exports.generateSqliteDDL = generateSqliteDDL;
|
|
2278
2302
|
exports.generateSqliteMigrationSQL = generateSqliteMigrationSQL;
|
|
2279
2303
|
exports.generateVectorIndexName = generateVectorIndexName;
|
|
2304
|
+
exports.getOrCreateLru = getOrCreateLru;
|
|
2280
2305
|
exports.nodes = nodes;
|
|
2281
2306
|
exports.nodes2 = nodes2;
|
|
2282
2307
|
exports.nowIso = nowIso;
|
|
@@ -2286,6 +2311,5 @@ exports.tables = tables;
|
|
|
2286
2311
|
exports.tables2 = tables2;
|
|
2287
2312
|
exports.uniques = uniques;
|
|
2288
2313
|
exports.uniques2 = uniques2;
|
|
2289
|
-
|
|
2290
|
-
//# sourceMappingURL=chunk-
|
|
2291
|
-
//# sourceMappingURL=chunk-Q73OWTJY.cjs.map
|
|
2314
|
+
//# sourceMappingURL=chunk-7OD2EPN4.cjs.map
|
|
2315
|
+
//# sourceMappingURL=chunk-7OD2EPN4.cjs.map
|