@nicia-ai/typegraph 0.20.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/{ast-Bh2NDeaK.d.cts → ast-CSLbPIOC.d.ts} +56 -3
- package/dist/{ast-COMyNeMn.d.ts → ast-DogwbBqA.d.cts} +56 -3
- package/dist/backend/postgres/index.cjs +123 -45
- package/dist/backend/postgres/index.cjs.map +1 -1
- package/dist/backend/postgres/index.d.cts +15 -7
- package/dist/backend/postgres/index.d.ts +15 -7
- package/dist/backend/postgres/index.js +101 -23
- package/dist/backend/postgres/index.js.map +1 -1
- package/dist/backend/sqlite/index.cjs +15 -15
- package/dist/backend/sqlite/index.d.cts +22 -7
- package/dist/backend/sqlite/index.d.ts +22 -7
- package/dist/backend/sqlite/index.js +5 -5
- package/dist/backend/sqlite/libsql.cjs +8 -8
- package/dist/backend/sqlite/libsql.d.cts +4 -5
- package/dist/backend/sqlite/libsql.d.ts +4 -5
- package/dist/backend/sqlite/libsql.js +5 -5
- package/dist/backend/sqlite/local.cjs +27 -10
- 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 +22 -6
- package/dist/backend/sqlite/local.js.map +1 -1
- package/dist/{chunk-MME3H4ZF.cjs → chunk-3JK66E3I.cjs} +387 -9
- package/dist/chunk-3JK66E3I.cjs.map +1 -0
- package/dist/{chunk-6GWJH6AR.js → chunk-3PPEHLGK.js} +4 -4
- package/dist/{chunk-6GWJH6AR.js.map → chunk-3PPEHLGK.js.map} +1 -1
- package/dist/{chunk-QFZQGEQ3.js → chunk-5ZMMHUWR.js} +199 -38
- package/dist/chunk-5ZMMHUWR.js.map +1 -0
- package/dist/{chunk-GNIYZKBI.js → chunk-753F33CV.js} +378 -8
- package/dist/chunk-753F33CV.js.map +1 -0
- package/dist/{chunk-K7SQ3SWP.js → chunk-EYELZHKY.js} +120 -12
- package/dist/chunk-EYELZHKY.js.map +1 -0
- package/dist/{chunk-HXJXTOXR.cjs → chunk-GUYI6VAS.cjs} +101 -21
- package/dist/chunk-GUYI6VAS.cjs.map +1 -0
- package/dist/{chunk-X33WV2UF.cjs → chunk-HRNQ3DVJ.cjs} +24 -21
- package/dist/chunk-HRNQ3DVJ.cjs.map +1 -0
- package/dist/{chunk-W6M7XWKX.js → chunk-JYUQA77I.js} +21 -18
- package/dist/chunk-JYUQA77I.js.map +1 -0
- package/dist/{chunk-LLHFS53Q.js → chunk-NSLTDXVH.js} +91 -11
- package/dist/chunk-NSLTDXVH.js.map +1 -0
- package/dist/{chunk-LELLOHJK.cjs → chunk-PEE4EWXZ.cjs} +35 -35
- package/dist/{chunk-LELLOHJK.cjs.map → chunk-PEE4EWXZ.cjs.map} +1 -1
- package/dist/{chunk-G5CYWKRF.js → chunk-RS5OLGEW.js} +2 -2
- package/dist/{chunk-G5CYWKRF.js.map → chunk-RS5OLGEW.js.map} +1 -1
- package/dist/{chunk-IYWWXOVK.cjs → chunk-SCXOGKLD.cjs} +252 -91
- package/dist/chunk-SCXOGKLD.cjs.map +1 -0
- package/dist/{chunk-P5CNM325.cjs → chunk-UVZHTBZ5.cjs} +123 -11
- package/dist/chunk-UVZHTBZ5.cjs.map +1 -0
- package/dist/{chunk-5GZMPJOP.cjs → chunk-WRWVWKQL.cjs} +2 -2
- package/dist/{chunk-5GZMPJOP.cjs.map → chunk-WRWVWKQL.cjs.map} +1 -1
- package/dist/{ddl-BBo2EcFc.d.cts → ddl-BqkTShcR.d.ts} +28 -6
- package/dist/{ddl-D4jlcOH_.d.ts → ddl-Dk1NDN3M.d.cts} +28 -6
- package/dist/index.cjs +1809 -513
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +53 -11
- package/dist/index.d.ts +53 -11
- package/dist/index.js +1668 -398
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +17 -17
- package/dist/indexes/index.d.cts +5 -5
- package/dist/indexes/index.d.ts +5 -5
- package/dist/indexes/index.js +3 -3
- package/dist/interchange/index.cjs +6 -6
- package/dist/interchange/index.d.cts +4 -5
- package/dist/interchange/index.d.ts +4 -5
- package/dist/interchange/index.js +1 -1
- package/dist/{manager-Chhrq1vl.d.ts → manager-0jVZtiE8.d.ts} +1 -2
- package/dist/{manager-Bj1UEnhE.d.cts → manager-BPK-2PUI.d.cts} +1 -2
- package/dist/profiler/index.cjs +15 -8
- package/dist/profiler/index.cjs.map +1 -1
- package/dist/profiler/index.d.cts +7 -8
- package/dist/profiler/index.d.ts +7 -8
- package/dist/profiler/index.js +8 -1
- package/dist/profiler/index.js.map +1 -1
- package/dist/schema/index.cjs +21 -21
- package/dist/schema/index.d.cts +4 -5
- package/dist/schema/index.d.ts +4 -5
- package/dist/schema/index.js +3 -3
- package/dist/{sqlite-DE-6NWtC.d.cts → sqlite-D1rrwcir.d.cts} +14 -1
- package/dist/{sqlite-Blq-AhmK.d.ts → sqlite-W3rmJMlc.d.ts} +14 -1
- package/dist/{store-BMrRi_mY.d.ts → store-2QW2SIRk.d.cts} +404 -5
- package/dist/{store-DRRvALu8.d.cts → store-C0q13mtJ.d.ts} +404 -5
- package/dist/{types-B3mmOMJV.d.cts → types-CQF88McG.d.cts} +475 -2
- package/dist/{types-ThB4cFLp.d.ts → types-CQF88McG.d.ts} +475 -2
- package/dist/{types-COPePE8_.d.ts → types-CglvhPKz.d.ts} +1 -1
- package/dist/{types-CVtGFpB9.d.cts → types-D23slCOA.d.cts} +1 -1
- package/dist/{types-Ceb01czq.d.ts → types-IMQCuser.d.ts} +2 -2
- package/dist/{types-CZd2PEOc.d.cts → types-vgjar7Ch.d.cts} +2 -2
- package/package.json +9 -9
- package/dist/chunk-GNIYZKBI.js.map +0 -1
- package/dist/chunk-HXJXTOXR.cjs.map +0 -1
- package/dist/chunk-IYWWXOVK.cjs.map +0 -1
- package/dist/chunk-K7SQ3SWP.js.map +0 -1
- package/dist/chunk-LLHFS53Q.js.map +0 -1
- package/dist/chunk-MME3H4ZF.cjs.map +0 -1
- package/dist/chunk-P5CNM325.cjs.map +0 -1
- package/dist/chunk-QFZQGEQ3.js.map +0 -1
- package/dist/chunk-W6M7XWKX.js.map +0 -1
- package/dist/chunk-X33WV2UF.cjs.map +0 -1
- package/dist/types-DMzKq0d5.d.cts +0 -181
- package/dist/types-DMzKq0d5.d.ts +0 -181
|
@@ -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');
|
|
@@ -69,7 +69,8 @@ var DEFAULT_TABLE_NAMES = {
|
|
|
69
69
|
edges: "typegraph_edges",
|
|
70
70
|
uniques: "typegraph_node_uniques",
|
|
71
71
|
schemaVersions: "typegraph_schema_versions",
|
|
72
|
-
embeddings: "typegraph_node_embeddings"
|
|
72
|
+
embeddings: "typegraph_node_embeddings",
|
|
73
|
+
fulltext: "typegraph_node_fulltext"
|
|
73
74
|
};
|
|
74
75
|
function createPostgresTables(names = {}, options = {}) {
|
|
75
76
|
const n = { ...DEFAULT_TABLE_NAMES, ...names };
|
|
@@ -99,7 +100,7 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
99
100
|
),
|
|
100
101
|
pgCore.index(`${n.nodes}_deleted_idx`).on(t.graphId, t.deletedAt),
|
|
101
102
|
pgCore.index(`${n.nodes}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),
|
|
102
|
-
...
|
|
103
|
+
...chunkPEE4EWXZ_cjs.buildPostgresNodeIndexBuilders(t, indexes)
|
|
103
104
|
]
|
|
104
105
|
);
|
|
105
106
|
const edges3 = pgCore.pgTable(
|
|
@@ -158,7 +159,7 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
158
159
|
t.fromId,
|
|
159
160
|
t.validTo
|
|
160
161
|
),
|
|
161
|
-
...
|
|
162
|
+
...chunkPEE4EWXZ_cjs.buildPostgresEdgeIndexBuilders(t, indexes)
|
|
162
163
|
]
|
|
163
164
|
);
|
|
164
165
|
const uniques3 = pgCore.pgTable(
|
|
@@ -226,7 +227,23 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
226
227
|
)
|
|
227
228
|
]
|
|
228
229
|
);
|
|
229
|
-
return {
|
|
230
|
+
return {
|
|
231
|
+
nodes: nodes3,
|
|
232
|
+
edges: edges3,
|
|
233
|
+
uniques: uniques3,
|
|
234
|
+
schemaVersions: schemaVersions3,
|
|
235
|
+
embeddings: embeddings3,
|
|
236
|
+
/**
|
|
237
|
+
* The fulltext storage table is owned by the active `FulltextStrategy`,
|
|
238
|
+
* not Drizzle. Shapes vary across strategies — the default `tsvectorStrategy`
|
|
239
|
+
* uses a `regconfig` language column, a GENERATED STORED `tsv` column,
|
|
240
|
+
* and a GIN index; alternate strategies (ParadeDB, pg_trgm, pgroonga)
|
|
241
|
+
* pick their own column types and index methods. DDL is emitted as
|
|
242
|
+
* raw SQL via `strategy.generateDdl()`; reads and writes are composed
|
|
243
|
+
* from the strategy's fragment helpers.
|
|
244
|
+
*/
|
|
245
|
+
fulltextTableName: n.fulltext
|
|
246
|
+
};
|
|
230
247
|
}
|
|
231
248
|
var tables = createPostgresTables();
|
|
232
249
|
var { nodes, edges, uniques, schemaVersions, embeddings } = tables;
|
|
@@ -235,7 +252,8 @@ var DEFAULT_TABLE_NAMES2 = {
|
|
|
235
252
|
edges: "typegraph_edges",
|
|
236
253
|
uniques: "typegraph_node_uniques",
|
|
237
254
|
schemaVersions: "typegraph_schema_versions",
|
|
238
|
-
embeddings: "typegraph_node_embeddings"
|
|
255
|
+
embeddings: "typegraph_node_embeddings",
|
|
256
|
+
fulltext: "typegraph_node_fulltext"
|
|
239
257
|
};
|
|
240
258
|
function createSqliteTables(names = {}, options = {}) {
|
|
241
259
|
const n = { ...DEFAULT_TABLE_NAMES2, ...names };
|
|
@@ -265,7 +283,7 @@ function createSqliteTables(names = {}, options = {}) {
|
|
|
265
283
|
),
|
|
266
284
|
sqliteCore.index(`${n.nodes}_deleted_idx`).on(t.graphId, t.deletedAt),
|
|
267
285
|
sqliteCore.index(`${n.nodes}_valid_idx`).on(t.graphId, t.validFrom, t.validTo),
|
|
268
|
-
...
|
|
286
|
+
...chunkPEE4EWXZ_cjs.buildSqliteNodeIndexBuilders(t, indexes)
|
|
269
287
|
]
|
|
270
288
|
);
|
|
271
289
|
const edges3 = sqliteCore.sqliteTable(
|
|
@@ -324,7 +342,7 @@ function createSqliteTables(names = {}, options = {}) {
|
|
|
324
342
|
t.fromId,
|
|
325
343
|
t.validTo
|
|
326
344
|
),
|
|
327
|
-
...
|
|
345
|
+
...chunkPEE4EWXZ_cjs.buildSqliteEdgeIndexBuilders(t, indexes)
|
|
328
346
|
]
|
|
329
347
|
);
|
|
330
348
|
const uniques3 = sqliteCore.sqliteTable(
|
|
@@ -396,7 +414,19 @@ function createSqliteTables(names = {}, options = {}) {
|
|
|
396
414
|
)
|
|
397
415
|
]
|
|
398
416
|
);
|
|
399
|
-
return {
|
|
417
|
+
return {
|
|
418
|
+
nodes: nodes3,
|
|
419
|
+
edges: edges3,
|
|
420
|
+
uniques: uniques3,
|
|
421
|
+
schemaVersions: schemaVersions3,
|
|
422
|
+
embeddings: embeddings3,
|
|
423
|
+
/**
|
|
424
|
+
* The fulltext storage is a FTS5 virtual table which Drizzle cannot
|
|
425
|
+
* represent. DDL is emitted as raw SQL and operations query it via
|
|
426
|
+
* `sql.raw()`.
|
|
427
|
+
*/
|
|
428
|
+
fulltextTableName: n.fulltext
|
|
429
|
+
};
|
|
400
430
|
}
|
|
401
431
|
var tables2 = createSqliteTables();
|
|
402
432
|
var { nodes: nodes2, edges: edges2, uniques: uniques2, schemaVersions: schemaVersions2, embeddings: embeddings2 } = tables2;
|
|
@@ -475,8 +505,17 @@ function flattenSqlChunk(chunk) {
|
|
|
475
505
|
return chunk;
|
|
476
506
|
}
|
|
477
507
|
if (typeof chunk === "object" && chunk !== null) {
|
|
478
|
-
if ("
|
|
479
|
-
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
|
+
}
|
|
480
519
|
}
|
|
481
520
|
if ("queryChunks" in chunk && Array.isArray(chunk.queryChunks)) {
|
|
482
521
|
return chunk.queryChunks.map((part) => flattenSqlChunk(part)).join("");
|
|
@@ -518,18 +557,25 @@ function generateSqliteCreateIndexSQL(table) {
|
|
|
518
557
|
}
|
|
519
558
|
return statements;
|
|
520
559
|
}
|
|
521
|
-
function
|
|
560
|
+
function isSqliteTable(value) {
|
|
561
|
+
return typeof value === "object" && value !== null && // Drizzle tables are always objects; strings are our escape hatch.
|
|
562
|
+
typeof value !== "string";
|
|
563
|
+
}
|
|
564
|
+
function generateSqliteDDL(tables3 = tables2, fulltextStrategy = chunk3JK66E3I_cjs.fts5Strategy) {
|
|
522
565
|
const statements = [];
|
|
523
566
|
for (const table of Object.values(tables3)) {
|
|
567
|
+
if (!isSqliteTable(table)) continue;
|
|
524
568
|
statements.push(generateSqliteCreateTableSQL(table));
|
|
525
569
|
}
|
|
526
570
|
for (const table of Object.values(tables3)) {
|
|
571
|
+
if (!isSqliteTable(table)) continue;
|
|
527
572
|
statements.push(...generateSqliteCreateIndexSQL(table));
|
|
528
573
|
}
|
|
574
|
+
statements.push(...fulltextStrategy.generateDdl(tables3.fulltextTableName));
|
|
529
575
|
return statements;
|
|
530
576
|
}
|
|
531
|
-
function generateSqliteMigrationSQL(tables3 = tables2) {
|
|
532
|
-
return generateSqliteDDL(tables3).join("\n\n");
|
|
577
|
+
function generateSqliteMigrationSQL(tables3 = tables2, fulltextStrategy = chunk3JK66E3I_cjs.fts5Strategy) {
|
|
578
|
+
return generateSqliteDDL(tables3, fulltextStrategy).join("\n\n");
|
|
533
579
|
}
|
|
534
580
|
function getPgColumnType(column) {
|
|
535
581
|
switch (column.columnType) {
|
|
@@ -610,19 +656,25 @@ function generatePgCreateIndexSQL(table) {
|
|
|
610
656
|
}
|
|
611
657
|
return statements;
|
|
612
658
|
}
|
|
613
|
-
function
|
|
659
|
+
function isPgTable(value) {
|
|
660
|
+
return typeof value === "object" && value !== null && typeof value !== "string";
|
|
661
|
+
}
|
|
662
|
+
function generatePostgresDDL(tables3 = tables, fulltextStrategy = chunk3JK66E3I_cjs.tsvectorStrategy) {
|
|
614
663
|
const statements = [];
|
|
615
664
|
for (const table of Object.values(tables3)) {
|
|
665
|
+
if (!isPgTable(table)) continue;
|
|
616
666
|
statements.push(generatePgCreateTableSQL(table));
|
|
617
667
|
}
|
|
618
668
|
for (const table of Object.values(tables3)) {
|
|
669
|
+
if (!isPgTable(table)) continue;
|
|
619
670
|
statements.push(...generatePgCreateIndexSQL(table));
|
|
620
671
|
}
|
|
672
|
+
statements.push(...fulltextStrategy.generateDdl(tables3.fulltextTableName));
|
|
621
673
|
return statements;
|
|
622
674
|
}
|
|
623
|
-
function generatePostgresMigrationSQL(tables3 = tables) {
|
|
675
|
+
function generatePostgresMigrationSQL(tables3 = tables, fulltextStrategy = chunk3JK66E3I_cjs.tsvectorStrategy) {
|
|
624
676
|
const extensionSql = "-- Enable pgvector extension for vector similarity search\nCREATE EXTENSION IF NOT EXISTS vector;";
|
|
625
|
-
const ddlSql = generatePostgresDDL(tables3).join("\n\n");
|
|
677
|
+
const ddlSql = generatePostgresDDL(tables3, fulltextStrategy).join("\n\n");
|
|
626
678
|
return `${extensionSql}
|
|
627
679
|
|
|
628
680
|
${ddlSql}`;
|
|
@@ -849,6 +901,14 @@ function createCommonOperationBackend(options) {
|
|
|
849
901
|
params.id
|
|
850
902
|
);
|
|
851
903
|
await execution.execRun(deleteEmbeddingsQuery);
|
|
904
|
+
const deleteFulltextStatements = operationStrategy.buildDeleteFulltextByNode(
|
|
905
|
+
params.graphId,
|
|
906
|
+
params.kind,
|
|
907
|
+
params.id
|
|
908
|
+
);
|
|
909
|
+
for (const stmt of deleteFulltextStatements) {
|
|
910
|
+
await execution.execRun(stmt);
|
|
911
|
+
}
|
|
852
912
|
const deleteEdgesQuery = operationStrategy.buildHardDeleteEdgesByNode(
|
|
853
913
|
params.graphId,
|
|
854
914
|
params.kind,
|
|
@@ -1023,7 +1083,9 @@ function createCommonOperationBackend(options) {
|
|
|
1023
1083
|
};
|
|
1024
1084
|
}
|
|
1025
1085
|
function buildClearGraph(tables3, graphId) {
|
|
1086
|
+
const fulltext = chunk3JK66E3I_cjs.quotedTableName(tables3.fulltextTableName);
|
|
1026
1087
|
return [
|
|
1088
|
+
drizzleOrm.sql`DELETE FROM ${fulltext} WHERE "graph_id" = ${graphId}`,
|
|
1027
1089
|
drizzleOrm.sql`DELETE FROM ${tables3.embeddings} WHERE ${tables3.embeddings.graphId} = ${graphId}`,
|
|
1028
1090
|
drizzleOrm.sql`DELETE FROM ${tables3.uniques} WHERE ${tables3.uniques.graphId} = ${graphId}`,
|
|
1029
1091
|
drizzleOrm.sql`DELETE FROM ${tables3.edges} WHERE ${tables3.edges.graphId} = ${graphId}`,
|
|
@@ -1058,12 +1120,16 @@ function buildFindNodesByKind(tables3, params) {
|
|
|
1058
1120
|
drizzleOrm.sql`${nodes3.kind} = ${params.kind}`,
|
|
1059
1121
|
...buildTemporalConditions(nodes3, params)
|
|
1060
1122
|
];
|
|
1123
|
+
if (params.orderBy === "id" && params.after !== void 0) {
|
|
1124
|
+
conditions.push(drizzleOrm.sql`${nodes3.id} > ${params.after}`);
|
|
1125
|
+
}
|
|
1061
1126
|
const whereClause = drizzleOrm.sql.join(conditions, drizzleOrm.sql` AND `);
|
|
1127
|
+
const orderByClause = params.orderBy === "id" ? drizzleOrm.sql`${nodes3.id} ASC` : drizzleOrm.sql`${nodes3.createdAt} DESC, ${nodes3.id} DESC`;
|
|
1062
1128
|
if (params.limit !== void 0 && params.offset !== void 0) {
|
|
1063
1129
|
return drizzleOrm.sql`
|
|
1064
1130
|
SELECT * FROM ${nodes3}
|
|
1065
1131
|
WHERE ${whereClause}
|
|
1066
|
-
ORDER BY ${
|
|
1132
|
+
ORDER BY ${orderByClause}
|
|
1067
1133
|
LIMIT ${params.limit} OFFSET ${params.offset}
|
|
1068
1134
|
`;
|
|
1069
1135
|
}
|
|
@@ -1071,14 +1137,14 @@ function buildFindNodesByKind(tables3, params) {
|
|
|
1071
1137
|
return drizzleOrm.sql`
|
|
1072
1138
|
SELECT * FROM ${nodes3}
|
|
1073
1139
|
WHERE ${whereClause}
|
|
1074
|
-
ORDER BY ${
|
|
1140
|
+
ORDER BY ${orderByClause}
|
|
1075
1141
|
LIMIT ${params.limit}
|
|
1076
1142
|
`;
|
|
1077
1143
|
}
|
|
1078
1144
|
return drizzleOrm.sql`
|
|
1079
1145
|
SELECT * FROM ${nodes3}
|
|
1080
1146
|
WHERE ${whereClause}
|
|
1081
|
-
ORDER BY ${
|
|
1147
|
+
ORDER BY ${orderByClause}
|
|
1082
1148
|
`;
|
|
1083
1149
|
}
|
|
1084
1150
|
function buildCountNodesByKind(tables3, params) {
|
|
@@ -1161,30 +1227,16 @@ function buildCountEdgesByKind(tables3, params) {
|
|
|
1161
1227
|
WHERE ${whereClause}
|
|
1162
1228
|
`;
|
|
1163
1229
|
}
|
|
1164
|
-
function sqlNull(value) {
|
|
1165
|
-
return value ?? drizzleOrm.sql.raw("NULL");
|
|
1166
|
-
}
|
|
1167
|
-
function quotedColumn(column) {
|
|
1168
|
-
return drizzleOrm.sql.raw(`"${column.name.replaceAll('"', '""')}"`);
|
|
1169
|
-
}
|
|
1170
|
-
function nodeColumnList(nodes3) {
|
|
1171
|
-
return drizzleOrm.sql.raw(`"${nodes3.graphId.name}", "${nodes3.kind.name}", "${nodes3.id.name}", "${nodes3.props.name}", "${nodes3.version.name}", "${nodes3.validFrom.name}", "${nodes3.validTo.name}", "${nodes3.createdAt.name}", "${nodes3.updatedAt.name}"`);
|
|
1172
|
-
}
|
|
1173
|
-
function edgeColumnList(edges3) {
|
|
1174
|
-
return drizzleOrm.sql.raw(`"${edges3.graphId.name}", "${edges3.id.name}", "${edges3.kind.name}", "${edges3.fromKind.name}", "${edges3.fromId.name}", "${edges3.toKind.name}", "${edges3.toId.name}", "${edges3.props.name}", "${edges3.validFrom.name}", "${edges3.validTo.name}", "${edges3.createdAt.name}", "${edges3.updatedAt.name}"`);
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
// src/backend/drizzle/operations/edges.ts
|
|
1178
1230
|
function buildInsertEdge(tables3, params, timestamp2) {
|
|
1179
1231
|
const { edges: edges3 } = tables3;
|
|
1180
1232
|
const propsJson = JSON.stringify(params.props);
|
|
1181
|
-
const columns = edgeColumnList(edges3);
|
|
1233
|
+
const columns = chunk3JK66E3I_cjs.edgeColumnList(edges3);
|
|
1182
1234
|
return drizzleOrm.sql`
|
|
1183
1235
|
INSERT INTO ${edges3} (${columns})
|
|
1184
1236
|
VALUES (
|
|
1185
1237
|
${params.graphId}, ${params.id}, ${params.kind},
|
|
1186
1238
|
${params.fromKind}, ${params.fromId}, ${params.toKind}, ${params.toId},
|
|
1187
|
-
${propsJson}, ${sqlNull(params.validFrom)}, ${sqlNull(params.validTo)},
|
|
1239
|
+
${propsJson}, ${chunk3JK66E3I_cjs.sqlNull(params.validFrom)}, ${chunk3JK66E3I_cjs.sqlNull(params.validTo)},
|
|
1188
1240
|
${timestamp2}, ${timestamp2}
|
|
1189
1241
|
)
|
|
1190
1242
|
RETURNING *
|
|
@@ -1193,23 +1245,23 @@ function buildInsertEdge(tables3, params, timestamp2) {
|
|
|
1193
1245
|
function buildInsertEdgeNoReturn(tables3, params, timestamp2) {
|
|
1194
1246
|
const { edges: edges3 } = tables3;
|
|
1195
1247
|
const propsJson = JSON.stringify(params.props);
|
|
1196
|
-
const columns = edgeColumnList(edges3);
|
|
1248
|
+
const columns = chunk3JK66E3I_cjs.edgeColumnList(edges3);
|
|
1197
1249
|
return drizzleOrm.sql`
|
|
1198
1250
|
INSERT INTO ${edges3} (${columns})
|
|
1199
1251
|
VALUES (
|
|
1200
1252
|
${params.graphId}, ${params.id}, ${params.kind},
|
|
1201
1253
|
${params.fromKind}, ${params.fromId}, ${params.toKind}, ${params.toId},
|
|
1202
|
-
${propsJson}, ${sqlNull(params.validFrom)}, ${sqlNull(params.validTo)},
|
|
1254
|
+
${propsJson}, ${chunk3JK66E3I_cjs.sqlNull(params.validFrom)}, ${chunk3JK66E3I_cjs.sqlNull(params.validTo)},
|
|
1203
1255
|
${timestamp2}, ${timestamp2}
|
|
1204
1256
|
)
|
|
1205
1257
|
`;
|
|
1206
1258
|
}
|
|
1207
1259
|
function buildInsertEdgesBatch(tables3, params, timestamp2) {
|
|
1208
1260
|
const { edges: edges3 } = tables3;
|
|
1209
|
-
const columns = edgeColumnList(edges3);
|
|
1261
|
+
const columns = chunk3JK66E3I_cjs.edgeColumnList(edges3);
|
|
1210
1262
|
const values = params.map((edgeParams) => {
|
|
1211
1263
|
const propsJson = JSON.stringify(edgeParams.props);
|
|
1212
|
-
return drizzleOrm.sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${sqlNull(edgeParams.validFrom)}, ${sqlNull(edgeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
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})`;
|
|
1213
1265
|
});
|
|
1214
1266
|
return drizzleOrm.sql`
|
|
1215
1267
|
INSERT INTO ${edges3} (${columns})
|
|
@@ -1218,10 +1270,10 @@ function buildInsertEdgesBatch(tables3, params, timestamp2) {
|
|
|
1218
1270
|
}
|
|
1219
1271
|
function buildInsertEdgesBatchReturning(tables3, params, timestamp2) {
|
|
1220
1272
|
const { edges: edges3 } = tables3;
|
|
1221
|
-
const columns = edgeColumnList(edges3);
|
|
1273
|
+
const columns = chunk3JK66E3I_cjs.edgeColumnList(edges3);
|
|
1222
1274
|
const values = params.map((edgeParams) => {
|
|
1223
1275
|
const propsJson = JSON.stringify(edgeParams.props);
|
|
1224
|
-
return drizzleOrm.sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${sqlNull(edgeParams.validFrom)}, ${sqlNull(edgeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
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})`;
|
|
1225
1277
|
});
|
|
1226
1278
|
return drizzleOrm.sql`
|
|
1227
1279
|
INSERT INTO ${edges3} (${columns})
|
|
@@ -1253,14 +1305,14 @@ function buildUpdateEdge(tables3, params, timestamp2) {
|
|
|
1253
1305
|
const { edges: edges3 } = tables3;
|
|
1254
1306
|
const propsJson = JSON.stringify(params.props);
|
|
1255
1307
|
const setParts = [
|
|
1256
|
-
drizzleOrm.sql`${quotedColumn(edges3.props)} = ${propsJson}`,
|
|
1257
|
-
drizzleOrm.sql`${quotedColumn(edges3.updatedAt)} = ${timestamp2}`
|
|
1308
|
+
drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(edges3.props)} = ${propsJson}`,
|
|
1309
|
+
drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(edges3.updatedAt)} = ${timestamp2}`
|
|
1258
1310
|
];
|
|
1259
1311
|
if (params.validTo !== void 0) {
|
|
1260
|
-
setParts.push(drizzleOrm.sql`${quotedColumn(edges3.validTo)} = ${params.validTo}`);
|
|
1312
|
+
setParts.push(drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(edges3.validTo)} = ${params.validTo}`);
|
|
1261
1313
|
}
|
|
1262
1314
|
if (params.clearDeleted) {
|
|
1263
|
-
setParts.push(drizzleOrm.sql`${quotedColumn(edges3.deletedAt)} = NULL`);
|
|
1315
|
+
setParts.push(drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(edges3.deletedAt)} = NULL`);
|
|
1264
1316
|
}
|
|
1265
1317
|
const setClause = drizzleOrm.sql.join(setParts, drizzleOrm.sql`, `);
|
|
1266
1318
|
if (params.clearDeleted) {
|
|
@@ -1285,7 +1337,7 @@ function buildDeleteEdge(tables3, params, timestamp2) {
|
|
|
1285
1337
|
const { edges: edges3 } = tables3;
|
|
1286
1338
|
return drizzleOrm.sql`
|
|
1287
1339
|
UPDATE ${edges3}
|
|
1288
|
-
SET ${quotedColumn(edges3.deletedAt)} = ${timestamp2}
|
|
1340
|
+
SET ${chunk3JK66E3I_cjs.quotedColumn(edges3.deletedAt)} = ${timestamp2}
|
|
1289
1341
|
WHERE ${edges3.graphId} = ${params.graphId}
|
|
1290
1342
|
AND ${edges3.id} = ${params.id}
|
|
1291
1343
|
AND ${edges3.deletedAt} IS NULL
|
|
@@ -1366,15 +1418,69 @@ function buildFindEdgesConnectedTo(tables3, params) {
|
|
|
1366
1418
|
)
|
|
1367
1419
|
`;
|
|
1368
1420
|
}
|
|
1421
|
+
function resolveMode(mode) {
|
|
1422
|
+
return mode ?? "websearch";
|
|
1423
|
+
}
|
|
1424
|
+
function buildFulltextSearch(tableName, params, strategy) {
|
|
1425
|
+
assertValidSearchParams(params);
|
|
1426
|
+
const mode = resolveMode(params.mode);
|
|
1427
|
+
const table = chunk3JK66E3I_cjs.quotedTableName(tableName);
|
|
1428
|
+
const matchCondition = strategy.matchCondition(
|
|
1429
|
+
tableName,
|
|
1430
|
+
params.query,
|
|
1431
|
+
mode,
|
|
1432
|
+
params.language
|
|
1433
|
+
);
|
|
1434
|
+
const rankExpression = strategy.rankExpression(
|
|
1435
|
+
tableName,
|
|
1436
|
+
params.query,
|
|
1437
|
+
mode,
|
|
1438
|
+
params.language
|
|
1439
|
+
);
|
|
1440
|
+
const conditions = [
|
|
1441
|
+
matchCondition,
|
|
1442
|
+
drizzleOrm.sql`"graph_id" = ${params.graphId}`,
|
|
1443
|
+
drizzleOrm.sql`"node_kind" = ${params.nodeKind}`
|
|
1444
|
+
];
|
|
1445
|
+
if (params.minScore !== void 0) {
|
|
1446
|
+
conditions.push(drizzleOrm.sql`${rankExpression} >= ${params.minScore}`);
|
|
1447
|
+
}
|
|
1448
|
+
const snippetExpr = params.includeSnippets === true && strategy.supportsSnippets ? strategy.snippetExpression(
|
|
1449
|
+
tableName,
|
|
1450
|
+
params.query,
|
|
1451
|
+
mode,
|
|
1452
|
+
params.language
|
|
1453
|
+
) : drizzleOrm.sql`NULL`;
|
|
1454
|
+
return drizzleOrm.sql`
|
|
1455
|
+
SELECT
|
|
1456
|
+
"node_id" AS node_id,
|
|
1457
|
+
${rankExpression} AS score,
|
|
1458
|
+
${snippetExpr} AS snippet
|
|
1459
|
+
FROM ${table}
|
|
1460
|
+
WHERE ${drizzleOrm.sql.join(conditions, drizzleOrm.sql` AND `)}
|
|
1461
|
+
ORDER BY ${rankExpression} DESC, "node_id" ASC
|
|
1462
|
+
LIMIT ${params.limit}
|
|
1463
|
+
`;
|
|
1464
|
+
}
|
|
1465
|
+
function assertValidSearchParams(params) {
|
|
1466
|
+
if (!Number.isInteger(params.limit) || params.limit <= 0) {
|
|
1467
|
+
throw new Error(`limit must be a positive integer, got: ${params.limit}`);
|
|
1468
|
+
}
|
|
1469
|
+
if (params.minScore !== void 0 && !Number.isFinite(params.minScore)) {
|
|
1470
|
+
throw new TypeError(
|
|
1471
|
+
`minScore must be a finite number, got: ${params.minScore}`
|
|
1472
|
+
);
|
|
1473
|
+
}
|
|
1474
|
+
}
|
|
1369
1475
|
function buildInsertNode(tables3, params, timestamp2) {
|
|
1370
1476
|
const { nodes: nodes3 } = tables3;
|
|
1371
1477
|
const propsJson = JSON.stringify(params.props);
|
|
1372
|
-
const columns = nodeColumnList(nodes3);
|
|
1478
|
+
const columns = chunk3JK66E3I_cjs.nodeColumnList(nodes3);
|
|
1373
1479
|
return drizzleOrm.sql`
|
|
1374
1480
|
INSERT INTO ${nodes3} (${columns})
|
|
1375
1481
|
VALUES (
|
|
1376
1482
|
${params.graphId}, ${params.kind}, ${params.id}, ${propsJson},
|
|
1377
|
-
1, ${sqlNull(params.validFrom)}, ${sqlNull(params.validTo)},
|
|
1483
|
+
1, ${chunk3JK66E3I_cjs.sqlNull(params.validFrom)}, ${chunk3JK66E3I_cjs.sqlNull(params.validTo)},
|
|
1378
1484
|
${timestamp2}, ${timestamp2}
|
|
1379
1485
|
)
|
|
1380
1486
|
RETURNING *
|
|
@@ -1383,22 +1489,22 @@ function buildInsertNode(tables3, params, timestamp2) {
|
|
|
1383
1489
|
function buildInsertNodeNoReturn(tables3, params, timestamp2) {
|
|
1384
1490
|
const { nodes: nodes3 } = tables3;
|
|
1385
1491
|
const propsJson = JSON.stringify(params.props);
|
|
1386
|
-
const columns = nodeColumnList(nodes3);
|
|
1492
|
+
const columns = chunk3JK66E3I_cjs.nodeColumnList(nodes3);
|
|
1387
1493
|
return drizzleOrm.sql`
|
|
1388
1494
|
INSERT INTO ${nodes3} (${columns})
|
|
1389
1495
|
VALUES (
|
|
1390
1496
|
${params.graphId}, ${params.kind}, ${params.id}, ${propsJson},
|
|
1391
|
-
1, ${sqlNull(params.validFrom)}, ${sqlNull(params.validTo)},
|
|
1497
|
+
1, ${chunk3JK66E3I_cjs.sqlNull(params.validFrom)}, ${chunk3JK66E3I_cjs.sqlNull(params.validTo)},
|
|
1392
1498
|
${timestamp2}, ${timestamp2}
|
|
1393
1499
|
)
|
|
1394
1500
|
`;
|
|
1395
1501
|
}
|
|
1396
1502
|
function buildInsertNodesBatch(tables3, params, timestamp2) {
|
|
1397
1503
|
const { nodes: nodes3 } = tables3;
|
|
1398
|
-
const columns = nodeColumnList(nodes3);
|
|
1504
|
+
const columns = chunk3JK66E3I_cjs.nodeColumnList(nodes3);
|
|
1399
1505
|
const values = params.map((nodeParams) => {
|
|
1400
1506
|
const propsJson = JSON.stringify(nodeParams.props);
|
|
1401
|
-
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${sqlNull(nodeParams.validFrom)}, ${sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1507
|
+
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${chunk3JK66E3I_cjs.sqlNull(nodeParams.validFrom)}, ${chunk3JK66E3I_cjs.sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1402
1508
|
});
|
|
1403
1509
|
return drizzleOrm.sql`
|
|
1404
1510
|
INSERT INTO ${nodes3} (${columns})
|
|
@@ -1407,10 +1513,10 @@ function buildInsertNodesBatch(tables3, params, timestamp2) {
|
|
|
1407
1513
|
}
|
|
1408
1514
|
function buildInsertNodesBatchReturning(tables3, params, timestamp2) {
|
|
1409
1515
|
const { nodes: nodes3 } = tables3;
|
|
1410
|
-
const columns = nodeColumnList(nodes3);
|
|
1516
|
+
const columns = chunk3JK66E3I_cjs.nodeColumnList(nodes3);
|
|
1411
1517
|
const values = params.map((nodeParams) => {
|
|
1412
1518
|
const propsJson = JSON.stringify(nodeParams.props);
|
|
1413
|
-
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${sqlNull(nodeParams.validFrom)}, ${sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1519
|
+
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${chunk3JK66E3I_cjs.sqlNull(nodeParams.validFrom)}, ${chunk3JK66E3I_cjs.sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1414
1520
|
});
|
|
1415
1521
|
return drizzleOrm.sql`
|
|
1416
1522
|
INSERT INTO ${nodes3} (${columns})
|
|
@@ -1444,19 +1550,19 @@ function buildUpdateNode(tables3, params, timestamp2) {
|
|
|
1444
1550
|
const { nodes: nodes3 } = tables3;
|
|
1445
1551
|
const propsJson = JSON.stringify(params.props);
|
|
1446
1552
|
const setParts = [
|
|
1447
|
-
drizzleOrm.sql`${quotedColumn(nodes3.props)} = ${propsJson}`,
|
|
1448
|
-
drizzleOrm.sql`${quotedColumn(nodes3.updatedAt)} = ${timestamp2}`
|
|
1553
|
+
drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(nodes3.props)} = ${propsJson}`,
|
|
1554
|
+
drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(nodes3.updatedAt)} = ${timestamp2}`
|
|
1449
1555
|
];
|
|
1450
1556
|
if (params.incrementVersion) {
|
|
1451
1557
|
setParts.push(
|
|
1452
|
-
drizzleOrm.sql`${quotedColumn(nodes3.version)} = ${quotedColumn(nodes3.version)} + 1`
|
|
1558
|
+
drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(nodes3.version)} = ${chunk3JK66E3I_cjs.quotedColumn(nodes3.version)} + 1`
|
|
1453
1559
|
);
|
|
1454
1560
|
}
|
|
1455
1561
|
if (params.validTo !== void 0) {
|
|
1456
|
-
setParts.push(drizzleOrm.sql`${quotedColumn(nodes3.validTo)} = ${params.validTo}`);
|
|
1562
|
+
setParts.push(drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(nodes3.validTo)} = ${params.validTo}`);
|
|
1457
1563
|
}
|
|
1458
1564
|
if (params.clearDeleted) {
|
|
1459
|
-
setParts.push(drizzleOrm.sql`${quotedColumn(nodes3.deletedAt)} = NULL`);
|
|
1565
|
+
setParts.push(drizzleOrm.sql`${chunk3JK66E3I_cjs.quotedColumn(nodes3.deletedAt)} = NULL`);
|
|
1460
1566
|
}
|
|
1461
1567
|
const setClause = drizzleOrm.sql.join(setParts, drizzleOrm.sql`, `);
|
|
1462
1568
|
if (params.clearDeleted) {
|
|
@@ -1483,7 +1589,7 @@ function buildDeleteNode(tables3, params, timestamp2) {
|
|
|
1483
1589
|
const { nodes: nodes3 } = tables3;
|
|
1484
1590
|
return drizzleOrm.sql`
|
|
1485
1591
|
UPDATE ${nodes3}
|
|
1486
|
-
SET ${quotedColumn(nodes3.deletedAt)} = ${timestamp2}
|
|
1592
|
+
SET ${chunk3JK66E3I_cjs.quotedColumn(nodes3.deletedAt)} = ${timestamp2}
|
|
1487
1593
|
WHERE ${nodes3.graphId} = ${params.graphId}
|
|
1488
1594
|
AND ${nodes3.kind} = ${params.kind}
|
|
1489
1595
|
AND ${nodes3.id} = ${params.id}
|
|
@@ -1550,12 +1656,12 @@ function buildSetActiveSchema(tables3, graphId, version, dialect = "sqlite") {
|
|
|
1550
1656
|
const strategy = SCHEMA_DIALECT_STRATEGIES[dialect];
|
|
1551
1657
|
const deactivateAll = drizzleOrm.sql`
|
|
1552
1658
|
UPDATE ${schemaVersions3}
|
|
1553
|
-
SET ${quotedColumn(schemaVersions3.isActive)} = ${strategy.booleanLiteral(false)}
|
|
1659
|
+
SET ${chunk3JK66E3I_cjs.quotedColumn(schemaVersions3.isActive)} = ${strategy.booleanLiteral(false)}
|
|
1554
1660
|
WHERE ${schemaVersions3.graphId} = ${graphId}
|
|
1555
1661
|
`;
|
|
1556
1662
|
const activateVersion = drizzleOrm.sql`
|
|
1557
1663
|
UPDATE ${schemaVersions3}
|
|
1558
|
-
SET ${quotedColumn(schemaVersions3.isActive)} = ${strategy.booleanLiteral(true)}
|
|
1664
|
+
SET ${chunk3JK66E3I_cjs.quotedColumn(schemaVersions3.isActive)} = ${strategy.booleanLiteral(true)}
|
|
1559
1665
|
WHERE ${schemaVersions3.graphId} = ${graphId}
|
|
1560
1666
|
AND ${schemaVersions3.version} = ${version}
|
|
1561
1667
|
`;
|
|
@@ -1573,22 +1679,22 @@ function buildInsertUniqueSqlite(tables3, params) {
|
|
|
1573
1679
|
)
|
|
1574
1680
|
ON CONFLICT (${conflictColumns})
|
|
1575
1681
|
DO UPDATE SET
|
|
1576
|
-
${quotedColumn(uniques3.nodeId)} = CASE
|
|
1577
|
-
WHEN ${quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.nodeId}
|
|
1578
|
-
WHEN ${quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.nodeId}
|
|
1579
|
-
ELSE ${quotedColumn(uniques3.nodeId)}
|
|
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)}
|
|
1580
1686
|
END,
|
|
1581
|
-
${quotedColumn(uniques3.concreteKind)} = CASE
|
|
1582
|
-
WHEN ${quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.concreteKind}
|
|
1583
|
-
WHEN ${quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.concreteKind}
|
|
1584
|
-
ELSE ${quotedColumn(uniques3.concreteKind)}
|
|
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)}
|
|
1585
1691
|
END,
|
|
1586
|
-
${quotedColumn(uniques3.deletedAt)} = CASE
|
|
1587
|
-
WHEN ${quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN NULL
|
|
1588
|
-
WHEN ${quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN NULL
|
|
1589
|
-
ELSE ${quotedColumn(uniques3.deletedAt)}
|
|
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)}
|
|
1590
1696
|
END
|
|
1591
|
-
RETURNING ${quotedColumn(uniques3.nodeId)} as node_id
|
|
1697
|
+
RETURNING ${chunk3JK66E3I_cjs.quotedColumn(uniques3.nodeId)} as node_id
|
|
1592
1698
|
`;
|
|
1593
1699
|
}
|
|
1594
1700
|
function buildInsertUniquePostgres(tables3, params) {
|
|
@@ -1605,22 +1711,22 @@ function buildInsertUniquePostgres(tables3, params) {
|
|
|
1605
1711
|
)
|
|
1606
1712
|
ON CONFLICT (${conflictColumns})
|
|
1607
1713
|
DO UPDATE SET
|
|
1608
|
-
${quotedColumn(uniques3.nodeId)} = CASE
|
|
1714
|
+
${chunk3JK66E3I_cjs.quotedColumn(uniques3.nodeId)} = CASE
|
|
1609
1715
|
WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.nodeId}
|
|
1610
1716
|
WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.nodeId}
|
|
1611
1717
|
ELSE ${existingColumn(uniques3.nodeId)}
|
|
1612
1718
|
END,
|
|
1613
|
-
${quotedColumn(uniques3.concreteKind)} = CASE
|
|
1719
|
+
${chunk3JK66E3I_cjs.quotedColumn(uniques3.concreteKind)} = CASE
|
|
1614
1720
|
WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.concreteKind}
|
|
1615
1721
|
WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.concreteKind}
|
|
1616
1722
|
ELSE ${existingColumn(uniques3.concreteKind)}
|
|
1617
1723
|
END,
|
|
1618
|
-
${quotedColumn(uniques3.deletedAt)} = CASE
|
|
1724
|
+
${chunk3JK66E3I_cjs.quotedColumn(uniques3.deletedAt)} = CASE
|
|
1619
1725
|
WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN NULL
|
|
1620
1726
|
WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN NULL
|
|
1621
1727
|
ELSE ${existingColumn(uniques3.deletedAt)}
|
|
1622
1728
|
END
|
|
1623
|
-
RETURNING ${quotedColumn(uniques3.nodeId)} as node_id
|
|
1729
|
+
RETURNING ${chunk3JK66E3I_cjs.quotedColumn(uniques3.nodeId)} as node_id
|
|
1624
1730
|
`;
|
|
1625
1731
|
}
|
|
1626
1732
|
var UNIQUE_INSERT_BUILDERS = {
|
|
@@ -1635,7 +1741,7 @@ function buildDeleteUnique(tables3, params, timestamp2) {
|
|
|
1635
1741
|
const { uniques: uniques3 } = tables3;
|
|
1636
1742
|
return drizzleOrm.sql`
|
|
1637
1743
|
UPDATE ${uniques3}
|
|
1638
|
-
SET ${quotedColumn(uniques3.deletedAt)} = ${timestamp2}
|
|
1744
|
+
SET ${chunk3JK66E3I_cjs.quotedColumn(uniques3.deletedAt)} = ${timestamp2}
|
|
1639
1745
|
WHERE ${uniques3.graphId} = ${params.graphId}
|
|
1640
1746
|
AND ${uniques3.nodeKind} = ${params.nodeKind}
|
|
1641
1747
|
AND ${uniques3.constraintName} = ${params.constraintName}
|
|
@@ -1740,6 +1846,30 @@ function buildUpsertEmbeddingPostgres(tables3, params, timestamp2) {
|
|
|
1740
1846
|
${column(embeddings3.updatedAt)} = ${timestamp2}
|
|
1741
1847
|
`;
|
|
1742
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
|
+
}
|
|
1743
1873
|
function buildDeleteEmbedding(tables3, params) {
|
|
1744
1874
|
const { embeddings: embeddings3 } = tables3;
|
|
1745
1875
|
return drizzleOrm.sql`
|
|
@@ -1903,13 +2033,27 @@ var COMMON_TABLE_OPERATION_BUILDERS = {
|
|
|
1903
2033
|
buildCheckUniqueBatch,
|
|
1904
2034
|
buildGetSchemaVersion
|
|
1905
2035
|
};
|
|
1906
|
-
function createCommonOperationStrategy(tables3, dialect) {
|
|
2036
|
+
function createCommonOperationStrategy(tables3, dialect, fulltextStrategy) {
|
|
1907
2037
|
const tableOperations = bindTableOperationBuilders(
|
|
1908
2038
|
tables3,
|
|
1909
2039
|
COMMON_TABLE_OPERATION_BUILDERS
|
|
1910
2040
|
);
|
|
2041
|
+
const fulltextTable = tables3.fulltextTableName;
|
|
2042
|
+
const fulltextBuilders = {
|
|
2043
|
+
buildUpsertFulltext: (params, timestamp2) => fulltextStrategy.buildUpsert(fulltextTable, params, timestamp2),
|
|
2044
|
+
buildDeleteFulltext: (params) => fulltextStrategy.buildDelete(fulltextTable, params),
|
|
2045
|
+
buildDeleteFulltextByNode: (graphId, nodeKind, nodeId) => fulltextStrategy.buildDelete(fulltextTable, {
|
|
2046
|
+
graphId,
|
|
2047
|
+
nodeKind,
|
|
2048
|
+
nodeId
|
|
2049
|
+
}),
|
|
2050
|
+
buildUpsertFulltextBatch: (params, timestamp2) => fulltextStrategy.buildBatchUpsert(fulltextTable, params, timestamp2),
|
|
2051
|
+
buildDeleteFulltextBatch: (params) => fulltextStrategy.buildBatchDelete(fulltextTable, params),
|
|
2052
|
+
buildFulltextSearch: (params) => buildFulltextSearch(fulltextTable, params, fulltextStrategy)
|
|
2053
|
+
};
|
|
1911
2054
|
return {
|
|
1912
2055
|
...tableOperations,
|
|
2056
|
+
...fulltextBuilders,
|
|
1913
2057
|
buildInsertUnique(params) {
|
|
1914
2058
|
return buildInsertUnique(tables3, dialect, params);
|
|
1915
2059
|
},
|
|
@@ -1927,11 +2071,28 @@ function createCommonOperationStrategy(tables3, dialect) {
|
|
|
1927
2071
|
}
|
|
1928
2072
|
};
|
|
1929
2073
|
}
|
|
1930
|
-
function createSqliteOperationStrategy(tables3) {
|
|
1931
|
-
|
|
2074
|
+
function createSqliteOperationStrategy(tables3, fulltextStrategy) {
|
|
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
|
+
};
|
|
1932
2089
|
}
|
|
1933
|
-
function createPostgresOperationStrategy(tables3) {
|
|
1934
|
-
const common = createCommonOperationStrategy(
|
|
2090
|
+
function createPostgresOperationStrategy(tables3, fulltextStrategy) {
|
|
2091
|
+
const common = createCommonOperationStrategy(
|
|
2092
|
+
tables3,
|
|
2093
|
+
"postgres",
|
|
2094
|
+
fulltextStrategy
|
|
2095
|
+
);
|
|
1935
2096
|
return {
|
|
1936
2097
|
...common,
|
|
1937
2098
|
buildUpsertEmbedding(params, timestamp2) {
|
|
@@ -1989,11 +2150,11 @@ function generateVectorIndexName(graphId, nodeKind, fieldPath, metric = "cosine"
|
|
|
1989
2150
|
metric
|
|
1990
2151
|
];
|
|
1991
2152
|
const name = parts.join("_");
|
|
1992
|
-
if (name.length <=
|
|
2153
|
+
if (name.length <= chunk3JK66E3I_cjs.MAX_PG_IDENTIFIER_LENGTH) {
|
|
1993
2154
|
return name;
|
|
1994
2155
|
}
|
|
1995
2156
|
const hash = shortHash(name);
|
|
1996
|
-
const truncated = name.slice(0,
|
|
2157
|
+
const truncated = name.slice(0, chunk3JK66E3I_cjs.MAX_PG_IDENTIFIER_LENGTH - 1 - hash.length);
|
|
1997
2158
|
return `${truncated}_${hash}`;
|
|
1998
2159
|
}
|
|
1999
2160
|
function getOperatorClass(metric) {
|
|
@@ -2172,5 +2333,5 @@ exports.tables2 = tables2;
|
|
|
2172
2333
|
exports.uniques = uniques;
|
|
2173
2334
|
exports.uniques2 = uniques2;
|
|
2174
2335
|
exports.wrapWithManagedClose = wrapWithManagedClose;
|
|
2175
|
-
//# sourceMappingURL=chunk-
|
|
2176
|
-
//# sourceMappingURL=chunk-
|
|
2336
|
+
//# sourceMappingURL=chunk-SCXOGKLD.cjs.map
|
|
2337
|
+
//# sourceMappingURL=chunk-SCXOGKLD.cjs.map
|