@nicia-ai/typegraph 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend/postgres/index.cjs +33 -33
- package/dist/backend/postgres/index.js +4 -4
- package/dist/backend/sqlite/index.cjs +14 -14
- package/dist/backend/sqlite/index.d.cts +11 -0
- package/dist/backend/sqlite/index.d.ts +11 -0
- package/dist/backend/sqlite/index.js +4 -4
- package/dist/backend/sqlite/libsql.cjs +7 -7
- package/dist/backend/sqlite/libsql.js +4 -4
- package/dist/backend/sqlite/local.cjs +26 -9
- package/dist/backend/sqlite/local.cjs.map +1 -1
- package/dist/backend/sqlite/local.js +21 -5
- package/dist/backend/sqlite/local.js.map +1 -1
- 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-UQVBVBVG.js → chunk-5ZMMHUWR.js} +53 -7
- package/dist/chunk-5ZMMHUWR.js.map +1 -0
- package/dist/{chunk-4XNE2JG3.js → chunk-753F33CV.js} +4 -2
- package/dist/chunk-753F33CV.js.map +1 -0
- package/dist/{chunk-CQL6FOTT.cjs → chunk-GUYI6VAS.cjs} +43 -24
- package/dist/chunk-GUYI6VAS.cjs.map +1 -0
- package/dist/{chunk-NRNJ52AA.js → chunk-NSLTDXVH.js} +26 -7
- package/dist/chunk-NSLTDXVH.js.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-Q73OWTJY.cjs → chunk-SCXOGKLD.cjs} +112 -66
- package/dist/chunk-SCXOGKLD.cjs.map +1 -0
- package/dist/index.cjs +135 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +45 -1
- package/dist/index.d.ts +45 -1
- package/dist/index.js +115 -36
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +16 -16
- package/dist/indexes/index.js +2 -2
- package/package.json +1 -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,8 +1,8 @@
|
|
|
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');
|
|
@@ -100,7 +100,7 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
100
100
|
),
|
|
101
101
|
pgCore.index(`${n.nodes}_deleted_idx`).on(t.graphId, t.deletedAt),
|
|
102
102
|
pgCore.index(`${n.nodes}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),
|
|
103
|
-
...
|
|
103
|
+
...chunkPEE4EWXZ_cjs.buildPostgresNodeIndexBuilders(t, indexes)
|
|
104
104
|
]
|
|
105
105
|
);
|
|
106
106
|
const edges3 = pgCore.pgTable(
|
|
@@ -159,7 +159,7 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
159
159
|
t.fromId,
|
|
160
160
|
t.validTo
|
|
161
161
|
),
|
|
162
|
-
...
|
|
162
|
+
...chunkPEE4EWXZ_cjs.buildPostgresEdgeIndexBuilders(t, indexes)
|
|
163
163
|
]
|
|
164
164
|
);
|
|
165
165
|
const uniques3 = pgCore.pgTable(
|
|
@@ -283,7 +283,7 @@ function createSqliteTables(names = {}, options = {}) {
|
|
|
283
283
|
),
|
|
284
284
|
sqliteCore.index(`${n.nodes}_deleted_idx`).on(t.graphId, t.deletedAt),
|
|
285
285
|
sqliteCore.index(`${n.nodes}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),
|
|
286
|
-
...
|
|
286
|
+
...chunkPEE4EWXZ_cjs.buildSqliteNodeIndexBuilders(t, indexes)
|
|
287
287
|
]
|
|
288
288
|
);
|
|
289
289
|
const edges3 = sqliteCore.sqliteTable(
|
|
@@ -342,7 +342,7 @@ function createSqliteTables(names = {}, options = {}) {
|
|
|
342
342
|
t.fromId,
|
|
343
343
|
t.validTo
|
|
344
344
|
),
|
|
345
|
-
...
|
|
345
|
+
...chunkPEE4EWXZ_cjs.buildSqliteEdgeIndexBuilders(t, indexes)
|
|
346
346
|
]
|
|
347
347
|
);
|
|
348
348
|
const uniques3 = sqliteCore.sqliteTable(
|
|
@@ -505,8 +505,17 @@ function flattenSqlChunk(chunk) {
|
|
|
505
505
|
return chunk;
|
|
506
506
|
}
|
|
507
507
|
if (typeof chunk === "object" && chunk !== null) {
|
|
508
|
-
if ("
|
|
509
|
-
return chunk.
|
|
508
|
+
if ("name" in chunk && typeof chunk.name === "string") {
|
|
509
|
+
return `"${chunk.name}"`;
|
|
510
|
+
}
|
|
511
|
+
if ("value" in chunk) {
|
|
512
|
+
const value = chunk.value;
|
|
513
|
+
if (typeof value === "string") {
|
|
514
|
+
return value;
|
|
515
|
+
}
|
|
516
|
+
if (Array.isArray(value)) {
|
|
517
|
+
return value.map((part) => flattenSqlChunk(part)).join("");
|
|
518
|
+
}
|
|
510
519
|
}
|
|
511
520
|
if ("queryChunks" in chunk && Array.isArray(chunk.queryChunks)) {
|
|
512
521
|
return chunk.queryChunks.map((part) => flattenSqlChunk(part)).join("");
|
|
@@ -552,7 +561,7 @@ function isSqliteTable(value) {
|
|
|
552
561
|
return typeof value === "object" && value !== null && // Drizzle tables are always objects; strings are our escape hatch.
|
|
553
562
|
typeof value !== "string";
|
|
554
563
|
}
|
|
555
|
-
function generateSqliteDDL(tables3 = tables2, fulltextStrategy =
|
|
564
|
+
function generateSqliteDDL(tables3 = tables2, fulltextStrategy = chunk3JK66E3I_cjs.fts5Strategy) {
|
|
556
565
|
const statements = [];
|
|
557
566
|
for (const table of Object.values(tables3)) {
|
|
558
567
|
if (!isSqliteTable(table)) continue;
|
|
@@ -565,7 +574,7 @@ function generateSqliteDDL(tables3 = tables2, fulltextStrategy = chunkFQCQM3KG_c
|
|
|
565
574
|
statements.push(...fulltextStrategy.generateDdl(tables3.fulltextTableName));
|
|
566
575
|
return statements;
|
|
567
576
|
}
|
|
568
|
-
function generateSqliteMigrationSQL(tables3 = tables2, fulltextStrategy =
|
|
577
|
+
function generateSqliteMigrationSQL(tables3 = tables2, fulltextStrategy = chunk3JK66E3I_cjs.fts5Strategy) {
|
|
569
578
|
return generateSqliteDDL(tables3, fulltextStrategy).join("\n\n");
|
|
570
579
|
}
|
|
571
580
|
function getPgColumnType(column) {
|
|
@@ -650,7 +659,7 @@ function generatePgCreateIndexSQL(table) {
|
|
|
650
659
|
function isPgTable(value) {
|
|
651
660
|
return typeof value === "object" && value !== null && typeof value !== "string";
|
|
652
661
|
}
|
|
653
|
-
function generatePostgresDDL(tables3 = tables, fulltextStrategy =
|
|
662
|
+
function generatePostgresDDL(tables3 = tables, fulltextStrategy = chunk3JK66E3I_cjs.tsvectorStrategy) {
|
|
654
663
|
const statements = [];
|
|
655
664
|
for (const table of Object.values(tables3)) {
|
|
656
665
|
if (!isPgTable(table)) continue;
|
|
@@ -663,7 +672,7 @@ function generatePostgresDDL(tables3 = tables, fulltextStrategy = chunkFQCQM3KG_
|
|
|
663
672
|
statements.push(...fulltextStrategy.generateDdl(tables3.fulltextTableName));
|
|
664
673
|
return statements;
|
|
665
674
|
}
|
|
666
|
-
function generatePostgresMigrationSQL(tables3 = tables, fulltextStrategy =
|
|
675
|
+
function generatePostgresMigrationSQL(tables3 = tables, fulltextStrategy = chunk3JK66E3I_cjs.tsvectorStrategy) {
|
|
667
676
|
const extensionSql = "-- Enable pgvector extension for vector similarity search\nCREATE EXTENSION IF NOT EXISTS vector;";
|
|
668
677
|
const ddlSql = generatePostgresDDL(tables3, fulltextStrategy).join("\n\n");
|
|
669
678
|
return `${extensionSql}
|
|
@@ -1074,7 +1083,7 @@ function createCommonOperationBackend(options) {
|
|
|
1074
1083
|
};
|
|
1075
1084
|
}
|
|
1076
1085
|
function buildClearGraph(tables3, graphId) {
|
|
1077
|
-
const fulltext =
|
|
1086
|
+
const fulltext = chunk3JK66E3I_cjs.quotedTableName(tables3.fulltextTableName);
|
|
1078
1087
|
return [
|
|
1079
1088
|
drizzleOrm.sql`DELETE FROM ${fulltext} WHERE "graph_id" = ${graphId}`,
|
|
1080
1089
|
drizzleOrm.sql`DELETE FROM ${tables3.embeddings} WHERE ${tables3.embeddings.graphId} = ${graphId}`,
|
|
@@ -1221,13 +1230,13 @@ function buildCountEdgesByKind(tables3, params) {
|
|
|
1221
1230
|
function buildInsertEdge(tables3, params, timestamp2) {
|
|
1222
1231
|
const { edges: edges3 } = tables3;
|
|
1223
1232
|
const propsJson = JSON.stringify(params.props);
|
|
1224
|
-
const columns =
|
|
1233
|
+
const columns = chunk3JK66E3I_cjs.edgeColumnList(edges3);
|
|
1225
1234
|
return drizzleOrm.sql`
|
|
1226
1235
|
INSERT INTO ${edges3} (${columns})
|
|
1227
1236
|
VALUES (
|
|
1228
1237
|
${params.graphId}, ${params.id}, ${params.kind},
|
|
1229
1238
|
${params.fromKind}, ${params.fromId}, ${params.toKind}, ${params.toId},
|
|
1230
|
-
${propsJson}, ${
|
|
1239
|
+
${propsJson}, ${chunk3JK66E3I_cjs.sqlNull(params.validFrom)}, ${chunk3JK66E3I_cjs.sqlNull(params.validTo)},
|
|
1231
1240
|
${timestamp2}, ${timestamp2}
|
|
1232
1241
|
)
|
|
1233
1242
|
RETURNING *
|
|
@@ -1236,23 +1245,23 @@ function buildInsertEdge(tables3, params, timestamp2) {
|
|
|
1236
1245
|
function buildInsertEdgeNoReturn(tables3, params, timestamp2) {
|
|
1237
1246
|
const { edges: edges3 } = tables3;
|
|
1238
1247
|
const propsJson = JSON.stringify(params.props);
|
|
1239
|
-
const columns =
|
|
1248
|
+
const columns = chunk3JK66E3I_cjs.edgeColumnList(edges3);
|
|
1240
1249
|
return drizzleOrm.sql`
|
|
1241
1250
|
INSERT INTO ${edges3} (${columns})
|
|
1242
1251
|
VALUES (
|
|
1243
1252
|
${params.graphId}, ${params.id}, ${params.kind},
|
|
1244
1253
|
${params.fromKind}, ${params.fromId}, ${params.toKind}, ${params.toId},
|
|
1245
|
-
${propsJson}, ${
|
|
1254
|
+
${propsJson}, ${chunk3JK66E3I_cjs.sqlNull(params.validFrom)}, ${chunk3JK66E3I_cjs.sqlNull(params.validTo)},
|
|
1246
1255
|
${timestamp2}, ${timestamp2}
|
|
1247
1256
|
)
|
|
1248
1257
|
`;
|
|
1249
1258
|
}
|
|
1250
1259
|
function buildInsertEdgesBatch(tables3, params, timestamp2) {
|
|
1251
1260
|
const { edges: edges3 } = tables3;
|
|
1252
|
-
const columns =
|
|
1261
|
+
const columns = chunk3JK66E3I_cjs.edgeColumnList(edges3);
|
|
1253
1262
|
const values = params.map((edgeParams) => {
|
|
1254
1263
|
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}, ${
|
|
1264
|
+
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
1265
|
});
|
|
1257
1266
|
return drizzleOrm.sql`
|
|
1258
1267
|
INSERT INTO ${edges3} (${columns})
|
|
@@ -1261,10 +1270,10 @@ function buildInsertEdgesBatch(tables3, params, timestamp2) {
|
|
|
1261
1270
|
}
|
|
1262
1271
|
function buildInsertEdgesBatchReturning(tables3, params, timestamp2) {
|
|
1263
1272
|
const { edges: edges3 } = tables3;
|
|
1264
|
-
const columns =
|
|
1273
|
+
const columns = chunk3JK66E3I_cjs.edgeColumnList(edges3);
|
|
1265
1274
|
const values = params.map((edgeParams) => {
|
|
1266
1275
|
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}, ${
|
|
1276
|
+
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
1277
|
});
|
|
1269
1278
|
return drizzleOrm.sql`
|
|
1270
1279
|
INSERT INTO ${edges3} (${columns})
|
|
@@ -1296,14 +1305,14 @@ function buildUpdateEdge(tables3, params, timestamp2) {
|
|
|
1296
1305
|
const { edges: edges3 } = tables3;
|
|
1297
1306
|
const propsJson = JSON.stringify(params.props);
|
|
1298
1307
|
const setParts = [
|
|
1299
|
-
drizzleOrm.sql`${
|
|
1300
|
-
drizzleOrm.sql`${
|
|
1308
|
+
drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(edges3.props)} = ${propsJson}`,
|
|
1309
|
+
drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(edges3.updatedAt)} = ${timestamp2}`
|
|
1301
1310
|
];
|
|
1302
1311
|
if (params.validTo !== void 0) {
|
|
1303
|
-
setParts.push(drizzleOrm.sql`${
|
|
1312
|
+
setParts.push(drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(edges3.validTo)} = ${params.validTo}`);
|
|
1304
1313
|
}
|
|
1305
1314
|
if (params.clearDeleted) {
|
|
1306
|
-
setParts.push(drizzleOrm.sql`${
|
|
1315
|
+
setParts.push(drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(edges3.deletedAt)} = NULL`);
|
|
1307
1316
|
}
|
|
1308
1317
|
const setClause = drizzleOrm.sql.join(setParts, drizzleOrm.sql`, `);
|
|
1309
1318
|
if (params.clearDeleted) {
|
|
@@ -1328,7 +1337,7 @@ function buildDeleteEdge(tables3, params, timestamp2) {
|
|
|
1328
1337
|
const { edges: edges3 } = tables3;
|
|
1329
1338
|
return drizzleOrm.sql`
|
|
1330
1339
|
UPDATE ${edges3}
|
|
1331
|
-
SET ${
|
|
1340
|
+
SET ${chunk3JK66E3I_cjs.quotedColumn(edges3.deletedAt)} = ${timestamp2}
|
|
1332
1341
|
WHERE ${edges3.graphId} = ${params.graphId}
|
|
1333
1342
|
AND ${edges3.id} = ${params.id}
|
|
1334
1343
|
AND ${edges3.deletedAt} IS NULL
|
|
@@ -1415,7 +1424,7 @@ function resolveMode(mode) {
|
|
|
1415
1424
|
function buildFulltextSearch(tableName, params, strategy) {
|
|
1416
1425
|
assertValidSearchParams(params);
|
|
1417
1426
|
const mode = resolveMode(params.mode);
|
|
1418
|
-
const table =
|
|
1427
|
+
const table = chunk3JK66E3I_cjs.quotedTableName(tableName);
|
|
1419
1428
|
const matchCondition = strategy.matchCondition(
|
|
1420
1429
|
tableName,
|
|
1421
1430
|
params.query,
|
|
@@ -1466,12 +1475,12 @@ function assertValidSearchParams(params) {
|
|
|
1466
1475
|
function buildInsertNode(tables3, params, timestamp2) {
|
|
1467
1476
|
const { nodes: nodes3 } = tables3;
|
|
1468
1477
|
const propsJson = JSON.stringify(params.props);
|
|
1469
|
-
const columns =
|
|
1478
|
+
const columns = chunk3JK66E3I_cjs.nodeColumnList(nodes3);
|
|
1470
1479
|
return drizzleOrm.sql`
|
|
1471
1480
|
INSERT INTO ${nodes3} (${columns})
|
|
1472
1481
|
VALUES (
|
|
1473
1482
|
${params.graphId}, ${params.kind}, ${params.id}, ${propsJson},
|
|
1474
|
-
1, ${
|
|
1483
|
+
1, ${chunk3JK66E3I_cjs.sqlNull(params.validFrom)}, ${chunk3JK66E3I_cjs.sqlNull(params.validTo)},
|
|
1475
1484
|
${timestamp2}, ${timestamp2}
|
|
1476
1485
|
)
|
|
1477
1486
|
RETURNING *
|
|
@@ -1480,22 +1489,22 @@ function buildInsertNode(tables3, params, timestamp2) {
|
|
|
1480
1489
|
function buildInsertNodeNoReturn(tables3, params, timestamp2) {
|
|
1481
1490
|
const { nodes: nodes3 } = tables3;
|
|
1482
1491
|
const propsJson = JSON.stringify(params.props);
|
|
1483
|
-
const columns =
|
|
1492
|
+
const columns = chunk3JK66E3I_cjs.nodeColumnList(nodes3);
|
|
1484
1493
|
return drizzleOrm.sql`
|
|
1485
1494
|
INSERT INTO ${nodes3} (${columns})
|
|
1486
1495
|
VALUES (
|
|
1487
1496
|
${params.graphId}, ${params.kind}, ${params.id}, ${propsJson},
|
|
1488
|
-
1, ${
|
|
1497
|
+
1, ${chunk3JK66E3I_cjs.sqlNull(params.validFrom)}, ${chunk3JK66E3I_cjs.sqlNull(params.validTo)},
|
|
1489
1498
|
${timestamp2}, ${timestamp2}
|
|
1490
1499
|
)
|
|
1491
1500
|
`;
|
|
1492
1501
|
}
|
|
1493
1502
|
function buildInsertNodesBatch(tables3, params, timestamp2) {
|
|
1494
1503
|
const { nodes: nodes3 } = tables3;
|
|
1495
|
-
const columns =
|
|
1504
|
+
const columns = chunk3JK66E3I_cjs.nodeColumnList(nodes3);
|
|
1496
1505
|
const values = params.map((nodeParams) => {
|
|
1497
1506
|
const propsJson = JSON.stringify(nodeParams.props);
|
|
1498
|
-
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${
|
|
1507
|
+
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${chunk3JK66E3I_cjs.sqlNull(nodeParams.validFrom)}, ${chunk3JK66E3I_cjs.sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1499
1508
|
});
|
|
1500
1509
|
return drizzleOrm.sql`
|
|
1501
1510
|
INSERT INTO ${nodes3} (${columns})
|
|
@@ -1504,10 +1513,10 @@ function buildInsertNodesBatch(tables3, params, timestamp2) {
|
|
|
1504
1513
|
}
|
|
1505
1514
|
function buildInsertNodesBatchReturning(tables3, params, timestamp2) {
|
|
1506
1515
|
const { nodes: nodes3 } = tables3;
|
|
1507
|
-
const columns =
|
|
1516
|
+
const columns = chunk3JK66E3I_cjs.nodeColumnList(nodes3);
|
|
1508
1517
|
const values = params.map((nodeParams) => {
|
|
1509
1518
|
const propsJson = JSON.stringify(nodeParams.props);
|
|
1510
|
-
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${
|
|
1519
|
+
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${chunk3JK66E3I_cjs.sqlNull(nodeParams.validFrom)}, ${chunk3JK66E3I_cjs.sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1511
1520
|
});
|
|
1512
1521
|
return drizzleOrm.sql`
|
|
1513
1522
|
INSERT INTO ${nodes3} (${columns})
|
|
@@ -1541,19 +1550,19 @@ function buildUpdateNode(tables3, params, timestamp2) {
|
|
|
1541
1550
|
const { nodes: nodes3 } = tables3;
|
|
1542
1551
|
const propsJson = JSON.stringify(params.props);
|
|
1543
1552
|
const setParts = [
|
|
1544
|
-
drizzleOrm.sql`${
|
|
1545
|
-
drizzleOrm.sql`${
|
|
1553
|
+
drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(nodes3.props)} = ${propsJson}`,
|
|
1554
|
+
drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(nodes3.updatedAt)} = ${timestamp2}`
|
|
1546
1555
|
];
|
|
1547
1556
|
if (params.incrementVersion) {
|
|
1548
1557
|
setParts.push(
|
|
1549
|
-
drizzleOrm.sql`${
|
|
1558
|
+
drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(nodes3.version)} = ${chunk3JK66E3I_cjs.quotedColumn(nodes3.version)} + 1`
|
|
1550
1559
|
);
|
|
1551
1560
|
}
|
|
1552
1561
|
if (params.validTo !== void 0) {
|
|
1553
|
-
setParts.push(drizzleOrm.sql`${
|
|
1562
|
+
setParts.push(drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(nodes3.validTo)} = ${params.validTo}`);
|
|
1554
1563
|
}
|
|
1555
1564
|
if (params.clearDeleted) {
|
|
1556
|
-
setParts.push(drizzleOrm.sql`${
|
|
1565
|
+
setParts.push(drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(nodes3.deletedAt)} = NULL`);
|
|
1557
1566
|
}
|
|
1558
1567
|
const setClause = drizzleOrm.sql.join(setParts, drizzleOrm.sql`, `);
|
|
1559
1568
|
if (params.clearDeleted) {
|
|
@@ -1580,7 +1589,7 @@ function buildDeleteNode(tables3, params, timestamp2) {
|
|
|
1580
1589
|
const { nodes: nodes3 } = tables3;
|
|
1581
1590
|
return drizzleOrm.sql`
|
|
1582
1591
|
UPDATE ${nodes3}
|
|
1583
|
-
SET ${
|
|
1592
|
+
SET ${chunk3JK66E3I_cjs.quotedColumn(nodes3.deletedAt)} = ${timestamp2}
|
|
1584
1593
|
WHERE ${nodes3.graphId} = ${params.graphId}
|
|
1585
1594
|
AND ${nodes3.kind} = ${params.kind}
|
|
1586
1595
|
AND ${nodes3.id} = ${params.id}
|
|
@@ -1647,12 +1656,12 @@ function buildSetActiveSchema(tables3, graphId, version, dialect = "sqlite") {
|
|
|
1647
1656
|
const strategy = SCHEMA_DIALECT_STRATEGIES[dialect];
|
|
1648
1657
|
const deactivateAll = drizzleOrm.sql`
|
|
1649
1658
|
UPDATE ${schemaVersions3}
|
|
1650
|
-
SET ${
|
|
1659
|
+
SET ${chunk3JK66E3I_cjs.quotedColumn(schemaVersions3.isActive)} = ${strategy.booleanLiteral(false)}
|
|
1651
1660
|
WHERE ${schemaVersions3.graphId} = ${graphId}
|
|
1652
1661
|
`;
|
|
1653
1662
|
const activateVersion = drizzleOrm.sql`
|
|
1654
1663
|
UPDATE ${schemaVersions3}
|
|
1655
|
-
SET ${
|
|
1664
|
+
SET ${chunk3JK66E3I_cjs.quotedColumn(schemaVersions3.isActive)} = ${strategy.booleanLiteral(true)}
|
|
1656
1665
|
WHERE ${schemaVersions3.graphId} = ${graphId}
|
|
1657
1666
|
AND ${schemaVersions3.version} = ${version}
|
|
1658
1667
|
`;
|
|
@@ -1670,22 +1679,22 @@ function buildInsertUniqueSqlite(tables3, params) {
|
|
|
1670
1679
|
)
|
|
1671
1680
|
ON CONFLICT (${conflictColumns})
|
|
1672
1681
|
DO UPDATE SET
|
|
1673
|
-
${
|
|
1674
|
-
WHEN ${
|
|
1675
|
-
WHEN ${
|
|
1676
|
-
ELSE ${
|
|
1682
|
+
${chunk3JK66E3I_cjs.quotedColumn(uniques3.nodeId)} = CASE
|
|
1683
|
+
WHEN ${chunk3JK66E3I_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.nodeId}
|
|
1684
|
+
WHEN ${chunk3JK66E3I_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.nodeId}
|
|
1685
|
+
ELSE ${chunk3JK66E3I_cjs.quotedColumn(uniques3.nodeId)}
|
|
1677
1686
|
END,
|
|
1678
|
-
${
|
|
1679
|
-
WHEN ${
|
|
1680
|
-
WHEN ${
|
|
1681
|
-
ELSE ${
|
|
1687
|
+
${chunk3JK66E3I_cjs.quotedColumn(uniques3.concreteKind)} = CASE
|
|
1688
|
+
WHEN ${chunk3JK66E3I_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.concreteKind}
|
|
1689
|
+
WHEN ${chunk3JK66E3I_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.concreteKind}
|
|
1690
|
+
ELSE ${chunk3JK66E3I_cjs.quotedColumn(uniques3.concreteKind)}
|
|
1682
1691
|
END,
|
|
1683
|
-
${
|
|
1684
|
-
WHEN ${
|
|
1685
|
-
WHEN ${
|
|
1686
|
-
ELSE ${
|
|
1692
|
+
${chunk3JK66E3I_cjs.quotedColumn(uniques3.deletedAt)} = CASE
|
|
1693
|
+
WHEN ${chunk3JK66E3I_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN NULL
|
|
1694
|
+
WHEN ${chunk3JK66E3I_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN NULL
|
|
1695
|
+
ELSE ${chunk3JK66E3I_cjs.quotedColumn(uniques3.deletedAt)}
|
|
1687
1696
|
END
|
|
1688
|
-
RETURNING ${
|
|
1697
|
+
RETURNING ${chunk3JK66E3I_cjs.quotedColumn(uniques3.nodeId)} as node_id
|
|
1689
1698
|
`;
|
|
1690
1699
|
}
|
|
1691
1700
|
function buildInsertUniquePostgres(tables3, params) {
|
|
@@ -1702,22 +1711,22 @@ function buildInsertUniquePostgres(tables3, params) {
|
|
|
1702
1711
|
)
|
|
1703
1712
|
ON CONFLICT (${conflictColumns})
|
|
1704
1713
|
DO UPDATE SET
|
|
1705
|
-
${
|
|
1714
|
+
${chunk3JK66E3I_cjs.quotedColumn(uniques3.nodeId)} = CASE
|
|
1706
1715
|
WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.nodeId}
|
|
1707
1716
|
WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.nodeId}
|
|
1708
1717
|
ELSE ${existingColumn(uniques3.nodeId)}
|
|
1709
1718
|
END,
|
|
1710
|
-
${
|
|
1719
|
+
${chunk3JK66E3I_cjs.quotedColumn(uniques3.concreteKind)} = CASE
|
|
1711
1720
|
WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.concreteKind}
|
|
1712
1721
|
WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.concreteKind}
|
|
1713
1722
|
ELSE ${existingColumn(uniques3.concreteKind)}
|
|
1714
1723
|
END,
|
|
1715
|
-
${
|
|
1724
|
+
${chunk3JK66E3I_cjs.quotedColumn(uniques3.deletedAt)} = CASE
|
|
1716
1725
|
WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN NULL
|
|
1717
1726
|
WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN NULL
|
|
1718
1727
|
ELSE ${existingColumn(uniques3.deletedAt)}
|
|
1719
1728
|
END
|
|
1720
|
-
RETURNING ${
|
|
1729
|
+
RETURNING ${chunk3JK66E3I_cjs.quotedColumn(uniques3.nodeId)} as node_id
|
|
1721
1730
|
`;
|
|
1722
1731
|
}
|
|
1723
1732
|
var UNIQUE_INSERT_BUILDERS = {
|
|
@@ -1732,7 +1741,7 @@ function buildDeleteUnique(tables3, params, timestamp2) {
|
|
|
1732
1741
|
const { uniques: uniques3 } = tables3;
|
|
1733
1742
|
return drizzleOrm.sql`
|
|
1734
1743
|
UPDATE ${uniques3}
|
|
1735
|
-
SET ${
|
|
1744
|
+
SET ${chunk3JK66E3I_cjs.quotedColumn(uniques3.deletedAt)} = ${timestamp2}
|
|
1736
1745
|
WHERE ${uniques3.graphId} = ${params.graphId}
|
|
1737
1746
|
AND ${uniques3.nodeKind} = ${params.nodeKind}
|
|
1738
1747
|
AND ${uniques3.constraintName} = ${params.constraintName}
|
|
@@ -1837,6 +1846,30 @@ function buildUpsertEmbeddingPostgres(tables3, params, timestamp2) {
|
|
|
1837
1846
|
${column(embeddings3.updatedAt)} = ${timestamp2}
|
|
1838
1847
|
`;
|
|
1839
1848
|
}
|
|
1849
|
+
function buildUpsertEmbeddingSqlite(tables3, params, timestamp2) {
|
|
1850
|
+
const { embeddings: embeddings3 } = tables3;
|
|
1851
|
+
const embeddingJson = JSON.stringify(params.embedding);
|
|
1852
|
+
assertFiniteNumberArray(params.embedding, "embedding");
|
|
1853
|
+
const columns = drizzleOrm.sql.raw(
|
|
1854
|
+
`"${embeddings3.graphId.name}", "${embeddings3.nodeKind.name}", "${embeddings3.nodeId.name}", "${embeddings3.fieldPath.name}", "${embeddings3.embedding.name}", "${embeddings3.dimensions.name}", "${embeddings3.createdAt.name}", "${embeddings3.updatedAt.name}"`
|
|
1855
|
+
);
|
|
1856
|
+
const conflictColumns = drizzleOrm.sql.raw(
|
|
1857
|
+
`"${embeddings3.graphId.name}", "${embeddings3.nodeKind.name}", "${embeddings3.nodeId.name}", "${embeddings3.fieldPath.name}"`
|
|
1858
|
+
);
|
|
1859
|
+
const column = (target) => drizzleOrm.sql.raw(`"${target.name}"`);
|
|
1860
|
+
return drizzleOrm.sql`
|
|
1861
|
+
INSERT INTO ${embeddings3} (${columns})
|
|
1862
|
+
VALUES (
|
|
1863
|
+
${params.graphId}, ${params.nodeKind}, ${params.nodeId}, ${params.fieldPath},
|
|
1864
|
+
vec_f32(${embeddingJson}), ${params.dimensions}, ${timestamp2}, ${timestamp2}
|
|
1865
|
+
)
|
|
1866
|
+
ON CONFLICT (${conflictColumns})
|
|
1867
|
+
DO UPDATE SET
|
|
1868
|
+
${column(embeddings3.embedding)} = vec_f32(${embeddingJson}),
|
|
1869
|
+
${column(embeddings3.dimensions)} = ${params.dimensions},
|
|
1870
|
+
${column(embeddings3.updatedAt)} = ${timestamp2}
|
|
1871
|
+
`;
|
|
1872
|
+
}
|
|
1840
1873
|
function buildDeleteEmbedding(tables3, params) {
|
|
1841
1874
|
const { embeddings: embeddings3 } = tables3;
|
|
1842
1875
|
return drizzleOrm.sql`
|
|
@@ -2039,7 +2072,20 @@ function createCommonOperationStrategy(tables3, dialect, fulltextStrategy) {
|
|
|
2039
2072
|
};
|
|
2040
2073
|
}
|
|
2041
2074
|
function createSqliteOperationStrategy(tables3, fulltextStrategy) {
|
|
2042
|
-
|
|
2075
|
+
const common = createCommonOperationStrategy(
|
|
2076
|
+
tables3,
|
|
2077
|
+
"sqlite",
|
|
2078
|
+
fulltextStrategy
|
|
2079
|
+
);
|
|
2080
|
+
return {
|
|
2081
|
+
...common,
|
|
2082
|
+
buildUpsertEmbedding(params, timestamp2) {
|
|
2083
|
+
return buildUpsertEmbeddingSqlite(tables3, params, timestamp2);
|
|
2084
|
+
},
|
|
2085
|
+
buildDeleteEmbedding(params) {
|
|
2086
|
+
return buildDeleteEmbedding(tables3, params);
|
|
2087
|
+
}
|
|
2088
|
+
};
|
|
2043
2089
|
}
|
|
2044
2090
|
function createPostgresOperationStrategy(tables3, fulltextStrategy) {
|
|
2045
2091
|
const common = createCommonOperationStrategy(
|
|
@@ -2104,11 +2150,11 @@ function generateVectorIndexName(graphId, nodeKind, fieldPath, metric = "cosine"
|
|
|
2104
2150
|
metric
|
|
2105
2151
|
];
|
|
2106
2152
|
const name = parts.join("_");
|
|
2107
|
-
if (name.length <=
|
|
2153
|
+
if (name.length <= chunk3JK66E3I_cjs.MAX_PG_IDENTIFIER_LENGTH) {
|
|
2108
2154
|
return name;
|
|
2109
2155
|
}
|
|
2110
2156
|
const hash = shortHash(name);
|
|
2111
|
-
const truncated = name.slice(0,
|
|
2157
|
+
const truncated = name.slice(0, chunk3JK66E3I_cjs.MAX_PG_IDENTIFIER_LENGTH - 1 - hash.length);
|
|
2112
2158
|
return `${truncated}_${hash}`;
|
|
2113
2159
|
}
|
|
2114
2160
|
function getOperatorClass(metric) {
|
|
@@ -2287,5 +2333,5 @@ exports.tables2 = tables2;
|
|
|
2287
2333
|
exports.uniques = uniques;
|
|
2288
2334
|
exports.uniques2 = uniques2;
|
|
2289
2335
|
exports.wrapWithManagedClose = wrapWithManagedClose;
|
|
2290
|
-
//# sourceMappingURL=chunk-
|
|
2291
|
-
//# sourceMappingURL=chunk-
|
|
2336
|
+
//# sourceMappingURL=chunk-SCXOGKLD.cjs.map
|
|
2337
|
+
//# sourceMappingURL=chunk-SCXOGKLD.cjs.map
|