@nicia-ai/typegraph 0.19.0 → 0.21.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 +11 -7
- package/dist/backend/sqlite/index.d.ts +11 -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 +9 -9
- package/dist/backend/sqlite/local.d.cts +4 -5
- package/dist/backend/sqlite/local.d.ts +4 -5
- package/dist/backend/sqlite/local.js +5 -5
- package/dist/{chunk-LELLOHJK.cjs → chunk-2X7P7AD5.cjs} +35 -35
- package/dist/{chunk-LELLOHJK.cjs.map → chunk-2X7P7AD5.cjs.map} +1 -1
- package/dist/{chunk-GNIYZKBI.js → chunk-4XNE2JG3.js} +376 -8
- package/dist/chunk-4XNE2JG3.js.map +1 -0
- package/dist/{chunk-HXJXTOXR.cjs → chunk-CQL6FOTT.cjs} +82 -21
- package/dist/chunk-CQL6FOTT.cjs.map +1 -0
- package/dist/{chunk-K7SQ3SWP.js → chunk-EYELZHKY.js} +120 -12
- package/dist/chunk-EYELZHKY.js.map +1 -0
- package/dist/{chunk-MME3H4ZF.cjs → chunk-FQCQM3KG.cjs} +385 -9
- package/dist/chunk-FQCQM3KG.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-NRNJ52AA.js} +72 -11
- package/dist/chunk-NRNJ52AA.js.map +1 -0
- package/dist/{chunk-IYWWXOVK.cjs → chunk-Q73OWTJY.cjs} +204 -89
- package/dist/chunk-Q73OWTJY.cjs.map +1 -0
- 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-6GWJH6AR.js → chunk-SMMOAVJ5.js} +4 -4
- package/dist/{chunk-6GWJH6AR.js.map → chunk-SMMOAVJ5.js.map} +1 -1
- package/dist/{chunk-QFZQGEQ3.js → chunk-UQVBVBVG.js} +151 -36
- package/dist/chunk-UQVBVBVG.js.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 +2102 -556
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -10
- package/dist/index.d.ts +8 -10
- package/dist/index.js +1961 -439
- 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-BnUu4qo5.d.cts → store-2QW2SIRk.d.cts} +626 -7
- package/dist/{store-CCOwNft_.d.ts → store-C0q13mtJ.d.ts} +626 -7
- 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 +10 -10
- 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 chunk2X7P7AD5_cjs = require('./chunk-2X7P7AD5.cjs');
|
|
5
|
+
var chunkFQCQM3KG_cjs = require('./chunk-FQCQM3KG.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
|
+
...chunk2X7P7AD5_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
|
+
...chunk2X7P7AD5_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
|
+
...chunk2X7P7AD5_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
|
+
...chunk2X7P7AD5_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;
|
|
@@ -518,18 +548,25 @@ function generateSqliteCreateIndexSQL(table) {
|
|
|
518
548
|
}
|
|
519
549
|
return statements;
|
|
520
550
|
}
|
|
521
|
-
function
|
|
551
|
+
function isSqliteTable(value) {
|
|
552
|
+
return typeof value === "object" && value !== null && // Drizzle tables are always objects; strings are our escape hatch.
|
|
553
|
+
typeof value !== "string";
|
|
554
|
+
}
|
|
555
|
+
function generateSqliteDDL(tables3 = tables2, fulltextStrategy = chunkFQCQM3KG_cjs.fts5Strategy) {
|
|
522
556
|
const statements = [];
|
|
523
557
|
for (const table of Object.values(tables3)) {
|
|
558
|
+
if (!isSqliteTable(table)) continue;
|
|
524
559
|
statements.push(generateSqliteCreateTableSQL(table));
|
|
525
560
|
}
|
|
526
561
|
for (const table of Object.values(tables3)) {
|
|
562
|
+
if (!isSqliteTable(table)) continue;
|
|
527
563
|
statements.push(...generateSqliteCreateIndexSQL(table));
|
|
528
564
|
}
|
|
565
|
+
statements.push(...fulltextStrategy.generateDdl(tables3.fulltextTableName));
|
|
529
566
|
return statements;
|
|
530
567
|
}
|
|
531
|
-
function generateSqliteMigrationSQL(tables3 = tables2) {
|
|
532
|
-
return generateSqliteDDL(tables3).join("\n\n");
|
|
568
|
+
function generateSqliteMigrationSQL(tables3 = tables2, fulltextStrategy = chunkFQCQM3KG_cjs.fts5Strategy) {
|
|
569
|
+
return generateSqliteDDL(tables3, fulltextStrategy).join("\n\n");
|
|
533
570
|
}
|
|
534
571
|
function getPgColumnType(column) {
|
|
535
572
|
switch (column.columnType) {
|
|
@@ -610,19 +647,25 @@ function generatePgCreateIndexSQL(table) {
|
|
|
610
647
|
}
|
|
611
648
|
return statements;
|
|
612
649
|
}
|
|
613
|
-
function
|
|
650
|
+
function isPgTable(value) {
|
|
651
|
+
return typeof value === "object" && value !== null && typeof value !== "string";
|
|
652
|
+
}
|
|
653
|
+
function generatePostgresDDL(tables3 = tables, fulltextStrategy = chunkFQCQM3KG_cjs.tsvectorStrategy) {
|
|
614
654
|
const statements = [];
|
|
615
655
|
for (const table of Object.values(tables3)) {
|
|
656
|
+
if (!isPgTable(table)) continue;
|
|
616
657
|
statements.push(generatePgCreateTableSQL(table));
|
|
617
658
|
}
|
|
618
659
|
for (const table of Object.values(tables3)) {
|
|
660
|
+
if (!isPgTable(table)) continue;
|
|
619
661
|
statements.push(...generatePgCreateIndexSQL(table));
|
|
620
662
|
}
|
|
663
|
+
statements.push(...fulltextStrategy.generateDdl(tables3.fulltextTableName));
|
|
621
664
|
return statements;
|
|
622
665
|
}
|
|
623
|
-
function generatePostgresMigrationSQL(tables3 = tables) {
|
|
666
|
+
function generatePostgresMigrationSQL(tables3 = tables, fulltextStrategy = chunkFQCQM3KG_cjs.tsvectorStrategy) {
|
|
624
667
|
const extensionSql = "-- Enable pgvector extension for vector similarity search\nCREATE EXTENSION IF NOT EXISTS vector;";
|
|
625
|
-
const ddlSql = generatePostgresDDL(tables3).join("\n\n");
|
|
668
|
+
const ddlSql = generatePostgresDDL(tables3, fulltextStrategy).join("\n\n");
|
|
626
669
|
return `${extensionSql}
|
|
627
670
|
|
|
628
671
|
${ddlSql}`;
|
|
@@ -849,6 +892,14 @@ function createCommonOperationBackend(options) {
|
|
|
849
892
|
params.id
|
|
850
893
|
);
|
|
851
894
|
await execution.execRun(deleteEmbeddingsQuery);
|
|
895
|
+
const deleteFulltextStatements = operationStrategy.buildDeleteFulltextByNode(
|
|
896
|
+
params.graphId,
|
|
897
|
+
params.kind,
|
|
898
|
+
params.id
|
|
899
|
+
);
|
|
900
|
+
for (const stmt of deleteFulltextStatements) {
|
|
901
|
+
await execution.execRun(stmt);
|
|
902
|
+
}
|
|
852
903
|
const deleteEdgesQuery = operationStrategy.buildHardDeleteEdgesByNode(
|
|
853
904
|
params.graphId,
|
|
854
905
|
params.kind,
|
|
@@ -1023,7 +1074,9 @@ function createCommonOperationBackend(options) {
|
|
|
1023
1074
|
};
|
|
1024
1075
|
}
|
|
1025
1076
|
function buildClearGraph(tables3, graphId) {
|
|
1077
|
+
const fulltext = chunkFQCQM3KG_cjs.quotedTableName(tables3.fulltextTableName);
|
|
1026
1078
|
return [
|
|
1079
|
+
drizzleOrm.sql`DELETE FROM ${fulltext} WHERE "graph_id" = ${graphId}`,
|
|
1027
1080
|
drizzleOrm.sql`DELETE FROM ${tables3.embeddings} WHERE ${tables3.embeddings.graphId} = ${graphId}`,
|
|
1028
1081
|
drizzleOrm.sql`DELETE FROM ${tables3.uniques} WHERE ${tables3.uniques.graphId} = ${graphId}`,
|
|
1029
1082
|
drizzleOrm.sql`DELETE FROM ${tables3.edges} WHERE ${tables3.edges.graphId} = ${graphId}`,
|
|
@@ -1058,12 +1111,16 @@ function buildFindNodesByKind(tables3, params) {
|
|
|
1058
1111
|
drizzleOrm.sql`${nodes3.kind} = ${params.kind}`,
|
|
1059
1112
|
...buildTemporalConditions(nodes3, params)
|
|
1060
1113
|
];
|
|
1114
|
+
if (params.orderBy === "id" && params.after !== void 0) {
|
|
1115
|
+
conditions.push(drizzleOrm.sql`${nodes3.id} > ${params.after}`);
|
|
1116
|
+
}
|
|
1061
1117
|
const whereClause = drizzleOrm.sql.join(conditions, drizzleOrm.sql` AND `);
|
|
1118
|
+
const orderByClause = params.orderBy === "id" ? drizzleOrm.sql`${nodes3.id} ASC` : drizzleOrm.sql`${nodes3.createdAt} DESC, ${nodes3.id} DESC`;
|
|
1062
1119
|
if (params.limit !== void 0 && params.offset !== void 0) {
|
|
1063
1120
|
return drizzleOrm.sql`
|
|
1064
1121
|
SELECT * FROM ${nodes3}
|
|
1065
1122
|
WHERE ${whereClause}
|
|
1066
|
-
ORDER BY ${
|
|
1123
|
+
ORDER BY ${orderByClause}
|
|
1067
1124
|
LIMIT ${params.limit} OFFSET ${params.offset}
|
|
1068
1125
|
`;
|
|
1069
1126
|
}
|
|
@@ -1071,14 +1128,14 @@ function buildFindNodesByKind(tables3, params) {
|
|
|
1071
1128
|
return drizzleOrm.sql`
|
|
1072
1129
|
SELECT * FROM ${nodes3}
|
|
1073
1130
|
WHERE ${whereClause}
|
|
1074
|
-
ORDER BY ${
|
|
1131
|
+
ORDER BY ${orderByClause}
|
|
1075
1132
|
LIMIT ${params.limit}
|
|
1076
1133
|
`;
|
|
1077
1134
|
}
|
|
1078
1135
|
return drizzleOrm.sql`
|
|
1079
1136
|
SELECT * FROM ${nodes3}
|
|
1080
1137
|
WHERE ${whereClause}
|
|
1081
|
-
ORDER BY ${
|
|
1138
|
+
ORDER BY ${orderByClause}
|
|
1082
1139
|
`;
|
|
1083
1140
|
}
|
|
1084
1141
|
function buildCountNodesByKind(tables3, params) {
|
|
@@ -1161,30 +1218,16 @@ function buildCountEdgesByKind(tables3, params) {
|
|
|
1161
1218
|
WHERE ${whereClause}
|
|
1162
1219
|
`;
|
|
1163
1220
|
}
|
|
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
1221
|
function buildInsertEdge(tables3, params, timestamp2) {
|
|
1179
1222
|
const { edges: edges3 } = tables3;
|
|
1180
1223
|
const propsJson = JSON.stringify(params.props);
|
|
1181
|
-
const columns = edgeColumnList(edges3);
|
|
1224
|
+
const columns = chunkFQCQM3KG_cjs.edgeColumnList(edges3);
|
|
1182
1225
|
return drizzleOrm.sql`
|
|
1183
1226
|
INSERT INTO ${edges3} (${columns})
|
|
1184
1227
|
VALUES (
|
|
1185
1228
|
${params.graphId}, ${params.id}, ${params.kind},
|
|
1186
1229
|
${params.fromKind}, ${params.fromId}, ${params.toKind}, ${params.toId},
|
|
1187
|
-
${propsJson}, ${sqlNull(params.validFrom)}, ${sqlNull(params.validTo)},
|
|
1230
|
+
${propsJson}, ${chunkFQCQM3KG_cjs.sqlNull(params.validFrom)}, ${chunkFQCQM3KG_cjs.sqlNull(params.validTo)},
|
|
1188
1231
|
${timestamp2}, ${timestamp2}
|
|
1189
1232
|
)
|
|
1190
1233
|
RETURNING *
|
|
@@ -1193,23 +1236,23 @@ function buildInsertEdge(tables3, params, timestamp2) {
|
|
|
1193
1236
|
function buildInsertEdgeNoReturn(tables3, params, timestamp2) {
|
|
1194
1237
|
const { edges: edges3 } = tables3;
|
|
1195
1238
|
const propsJson = JSON.stringify(params.props);
|
|
1196
|
-
const columns = edgeColumnList(edges3);
|
|
1239
|
+
const columns = chunkFQCQM3KG_cjs.edgeColumnList(edges3);
|
|
1197
1240
|
return drizzleOrm.sql`
|
|
1198
1241
|
INSERT INTO ${edges3} (${columns})
|
|
1199
1242
|
VALUES (
|
|
1200
1243
|
${params.graphId}, ${params.id}, ${params.kind},
|
|
1201
1244
|
${params.fromKind}, ${params.fromId}, ${params.toKind}, ${params.toId},
|
|
1202
|
-
${propsJson}, ${sqlNull(params.validFrom)}, ${sqlNull(params.validTo)},
|
|
1245
|
+
${propsJson}, ${chunkFQCQM3KG_cjs.sqlNull(params.validFrom)}, ${chunkFQCQM3KG_cjs.sqlNull(params.validTo)},
|
|
1203
1246
|
${timestamp2}, ${timestamp2}
|
|
1204
1247
|
)
|
|
1205
1248
|
`;
|
|
1206
1249
|
}
|
|
1207
1250
|
function buildInsertEdgesBatch(tables3, params, timestamp2) {
|
|
1208
1251
|
const { edges: edges3 } = tables3;
|
|
1209
|
-
const columns = edgeColumnList(edges3);
|
|
1252
|
+
const columns = chunkFQCQM3KG_cjs.edgeColumnList(edges3);
|
|
1210
1253
|
const values = params.map((edgeParams) => {
|
|
1211
1254
|
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})`;
|
|
1255
|
+
return drizzleOrm.sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${chunkFQCQM3KG_cjs.sqlNull(edgeParams.validFrom)}, ${chunkFQCQM3KG_cjs.sqlNull(edgeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1213
1256
|
});
|
|
1214
1257
|
return drizzleOrm.sql`
|
|
1215
1258
|
INSERT INTO ${edges3} (${columns})
|
|
@@ -1218,10 +1261,10 @@ function buildInsertEdgesBatch(tables3, params, timestamp2) {
|
|
|
1218
1261
|
}
|
|
1219
1262
|
function buildInsertEdgesBatchReturning(tables3, params, timestamp2) {
|
|
1220
1263
|
const { edges: edges3 } = tables3;
|
|
1221
|
-
const columns = edgeColumnList(edges3);
|
|
1264
|
+
const columns = chunkFQCQM3KG_cjs.edgeColumnList(edges3);
|
|
1222
1265
|
const values = params.map((edgeParams) => {
|
|
1223
1266
|
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})`;
|
|
1267
|
+
return drizzleOrm.sql`(${edgeParams.graphId}, ${edgeParams.id}, ${edgeParams.kind}, ${edgeParams.fromKind}, ${edgeParams.fromId}, ${edgeParams.toKind}, ${edgeParams.toId}, ${propsJson}, ${chunkFQCQM3KG_cjs.sqlNull(edgeParams.validFrom)}, ${chunkFQCQM3KG_cjs.sqlNull(edgeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1225
1268
|
});
|
|
1226
1269
|
return drizzleOrm.sql`
|
|
1227
1270
|
INSERT INTO ${edges3} (${columns})
|
|
@@ -1253,14 +1296,14 @@ function buildUpdateEdge(tables3, params, timestamp2) {
|
|
|
1253
1296
|
const { edges: edges3 } = tables3;
|
|
1254
1297
|
const propsJson = JSON.stringify(params.props);
|
|
1255
1298
|
const setParts = [
|
|
1256
|
-
drizzleOrm.sql`${quotedColumn(edges3.props)} = ${propsJson}`,
|
|
1257
|
-
drizzleOrm.sql`${quotedColumn(edges3.updatedAt)} = ${timestamp2}`
|
|
1299
|
+
drizzleOrm.sql`${chunkFQCQM3KG_cjs.quotedColumn(edges3.props)} = ${propsJson}`,
|
|
1300
|
+
drizzleOrm.sql`${chunkFQCQM3KG_cjs.quotedColumn(edges3.updatedAt)} = ${timestamp2}`
|
|
1258
1301
|
];
|
|
1259
1302
|
if (params.validTo !== void 0) {
|
|
1260
|
-
setParts.push(drizzleOrm.sql`${quotedColumn(edges3.validTo)} = ${params.validTo}`);
|
|
1303
|
+
setParts.push(drizzleOrm.sql`${chunkFQCQM3KG_cjs.quotedColumn(edges3.validTo)} = ${params.validTo}`);
|
|
1261
1304
|
}
|
|
1262
1305
|
if (params.clearDeleted) {
|
|
1263
|
-
setParts.push(drizzleOrm.sql`${quotedColumn(edges3.deletedAt)} = NULL`);
|
|
1306
|
+
setParts.push(drizzleOrm.sql`${chunkFQCQM3KG_cjs.quotedColumn(edges3.deletedAt)} = NULL`);
|
|
1264
1307
|
}
|
|
1265
1308
|
const setClause = drizzleOrm.sql.join(setParts, drizzleOrm.sql`, `);
|
|
1266
1309
|
if (params.clearDeleted) {
|
|
@@ -1285,7 +1328,7 @@ function buildDeleteEdge(tables3, params, timestamp2) {
|
|
|
1285
1328
|
const { edges: edges3 } = tables3;
|
|
1286
1329
|
return drizzleOrm.sql`
|
|
1287
1330
|
UPDATE ${edges3}
|
|
1288
|
-
SET ${quotedColumn(edges3.deletedAt)} = ${timestamp2}
|
|
1331
|
+
SET ${chunkFQCQM3KG_cjs.quotedColumn(edges3.deletedAt)} = ${timestamp2}
|
|
1289
1332
|
WHERE ${edges3.graphId} = ${params.graphId}
|
|
1290
1333
|
AND ${edges3.id} = ${params.id}
|
|
1291
1334
|
AND ${edges3.deletedAt} IS NULL
|
|
@@ -1366,15 +1409,69 @@ function buildFindEdgesConnectedTo(tables3, params) {
|
|
|
1366
1409
|
)
|
|
1367
1410
|
`;
|
|
1368
1411
|
}
|
|
1412
|
+
function resolveMode(mode) {
|
|
1413
|
+
return mode ?? "websearch";
|
|
1414
|
+
}
|
|
1415
|
+
function buildFulltextSearch(tableName, params, strategy) {
|
|
1416
|
+
assertValidSearchParams(params);
|
|
1417
|
+
const mode = resolveMode(params.mode);
|
|
1418
|
+
const table = chunkFQCQM3KG_cjs.quotedTableName(tableName);
|
|
1419
|
+
const matchCondition = strategy.matchCondition(
|
|
1420
|
+
tableName,
|
|
1421
|
+
params.query,
|
|
1422
|
+
mode,
|
|
1423
|
+
params.language
|
|
1424
|
+
);
|
|
1425
|
+
const rankExpression = strategy.rankExpression(
|
|
1426
|
+
tableName,
|
|
1427
|
+
params.query,
|
|
1428
|
+
mode,
|
|
1429
|
+
params.language
|
|
1430
|
+
);
|
|
1431
|
+
const conditions = [
|
|
1432
|
+
matchCondition,
|
|
1433
|
+
drizzleOrm.sql`"graph_id" = ${params.graphId}`,
|
|
1434
|
+
drizzleOrm.sql`"node_kind" = ${params.nodeKind}`
|
|
1435
|
+
];
|
|
1436
|
+
if (params.minScore !== void 0) {
|
|
1437
|
+
conditions.push(drizzleOrm.sql`${rankExpression} >= ${params.minScore}`);
|
|
1438
|
+
}
|
|
1439
|
+
const snippetExpr = params.includeSnippets === true && strategy.supportsSnippets ? strategy.snippetExpression(
|
|
1440
|
+
tableName,
|
|
1441
|
+
params.query,
|
|
1442
|
+
mode,
|
|
1443
|
+
params.language
|
|
1444
|
+
) : drizzleOrm.sql`NULL`;
|
|
1445
|
+
return drizzleOrm.sql`
|
|
1446
|
+
SELECT
|
|
1447
|
+
"node_id" AS node_id,
|
|
1448
|
+
${rankExpression} AS score,
|
|
1449
|
+
${snippetExpr} AS snippet
|
|
1450
|
+
FROM ${table}
|
|
1451
|
+
WHERE ${drizzleOrm.sql.join(conditions, drizzleOrm.sql` AND `)}
|
|
1452
|
+
ORDER BY ${rankExpression} DESC, "node_id" ASC
|
|
1453
|
+
LIMIT ${params.limit}
|
|
1454
|
+
`;
|
|
1455
|
+
}
|
|
1456
|
+
function assertValidSearchParams(params) {
|
|
1457
|
+
if (!Number.isInteger(params.limit) || params.limit <= 0) {
|
|
1458
|
+
throw new Error(`limit must be a positive integer, got: ${params.limit}`);
|
|
1459
|
+
}
|
|
1460
|
+
if (params.minScore !== void 0 && !Number.isFinite(params.minScore)) {
|
|
1461
|
+
throw new TypeError(
|
|
1462
|
+
`minScore must be a finite number, got: ${params.minScore}`
|
|
1463
|
+
);
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1369
1466
|
function buildInsertNode(tables3, params, timestamp2) {
|
|
1370
1467
|
const { nodes: nodes3 } = tables3;
|
|
1371
1468
|
const propsJson = JSON.stringify(params.props);
|
|
1372
|
-
const columns = nodeColumnList(nodes3);
|
|
1469
|
+
const columns = chunkFQCQM3KG_cjs.nodeColumnList(nodes3);
|
|
1373
1470
|
return drizzleOrm.sql`
|
|
1374
1471
|
INSERT INTO ${nodes3} (${columns})
|
|
1375
1472
|
VALUES (
|
|
1376
1473
|
${params.graphId}, ${params.kind}, ${params.id}, ${propsJson},
|
|
1377
|
-
1, ${sqlNull(params.validFrom)}, ${sqlNull(params.validTo)},
|
|
1474
|
+
1, ${chunkFQCQM3KG_cjs.sqlNull(params.validFrom)}, ${chunkFQCQM3KG_cjs.sqlNull(params.validTo)},
|
|
1378
1475
|
${timestamp2}, ${timestamp2}
|
|
1379
1476
|
)
|
|
1380
1477
|
RETURNING *
|
|
@@ -1383,22 +1480,22 @@ function buildInsertNode(tables3, params, timestamp2) {
|
|
|
1383
1480
|
function buildInsertNodeNoReturn(tables3, params, timestamp2) {
|
|
1384
1481
|
const { nodes: nodes3 } = tables3;
|
|
1385
1482
|
const propsJson = JSON.stringify(params.props);
|
|
1386
|
-
const columns = nodeColumnList(nodes3);
|
|
1483
|
+
const columns = chunkFQCQM3KG_cjs.nodeColumnList(nodes3);
|
|
1387
1484
|
return drizzleOrm.sql`
|
|
1388
1485
|
INSERT INTO ${nodes3} (${columns})
|
|
1389
1486
|
VALUES (
|
|
1390
1487
|
${params.graphId}, ${params.kind}, ${params.id}, ${propsJson},
|
|
1391
|
-
1, ${sqlNull(params.validFrom)}, ${sqlNull(params.validTo)},
|
|
1488
|
+
1, ${chunkFQCQM3KG_cjs.sqlNull(params.validFrom)}, ${chunkFQCQM3KG_cjs.sqlNull(params.validTo)},
|
|
1392
1489
|
${timestamp2}, ${timestamp2}
|
|
1393
1490
|
)
|
|
1394
1491
|
`;
|
|
1395
1492
|
}
|
|
1396
1493
|
function buildInsertNodesBatch(tables3, params, timestamp2) {
|
|
1397
1494
|
const { nodes: nodes3 } = tables3;
|
|
1398
|
-
const columns = nodeColumnList(nodes3);
|
|
1495
|
+
const columns = chunkFQCQM3KG_cjs.nodeColumnList(nodes3);
|
|
1399
1496
|
const values = params.map((nodeParams) => {
|
|
1400
1497
|
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})`;
|
|
1498
|
+
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${chunkFQCQM3KG_cjs.sqlNull(nodeParams.validFrom)}, ${chunkFQCQM3KG_cjs.sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1402
1499
|
});
|
|
1403
1500
|
return drizzleOrm.sql`
|
|
1404
1501
|
INSERT INTO ${nodes3} (${columns})
|
|
@@ -1407,10 +1504,10 @@ function buildInsertNodesBatch(tables3, params, timestamp2) {
|
|
|
1407
1504
|
}
|
|
1408
1505
|
function buildInsertNodesBatchReturning(tables3, params, timestamp2) {
|
|
1409
1506
|
const { nodes: nodes3 } = tables3;
|
|
1410
|
-
const columns = nodeColumnList(nodes3);
|
|
1507
|
+
const columns = chunkFQCQM3KG_cjs.nodeColumnList(nodes3);
|
|
1411
1508
|
const values = params.map((nodeParams) => {
|
|
1412
1509
|
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})`;
|
|
1510
|
+
return drizzleOrm.sql`(${nodeParams.graphId}, ${nodeParams.kind}, ${nodeParams.id}, ${propsJson}, 1, ${chunkFQCQM3KG_cjs.sqlNull(nodeParams.validFrom)}, ${chunkFQCQM3KG_cjs.sqlNull(nodeParams.validTo)}, ${timestamp2}, ${timestamp2})`;
|
|
1414
1511
|
});
|
|
1415
1512
|
return drizzleOrm.sql`
|
|
1416
1513
|
INSERT INTO ${nodes3} (${columns})
|
|
@@ -1444,19 +1541,19 @@ function buildUpdateNode(tables3, params, timestamp2) {
|
|
|
1444
1541
|
const { nodes: nodes3 } = tables3;
|
|
1445
1542
|
const propsJson = JSON.stringify(params.props);
|
|
1446
1543
|
const setParts = [
|
|
1447
|
-
drizzleOrm.sql`${quotedColumn(nodes3.props)} = ${propsJson}`,
|
|
1448
|
-
drizzleOrm.sql`${quotedColumn(nodes3.updatedAt)} = ${timestamp2}`
|
|
1544
|
+
drizzleOrm.sql`${chunkFQCQM3KG_cjs.quotedColumn(nodes3.props)} = ${propsJson}`,
|
|
1545
|
+
drizzleOrm.sql`${chunkFQCQM3KG_cjs.quotedColumn(nodes3.updatedAt)} = ${timestamp2}`
|
|
1449
1546
|
];
|
|
1450
1547
|
if (params.incrementVersion) {
|
|
1451
1548
|
setParts.push(
|
|
1452
|
-
drizzleOrm.sql`${quotedColumn(nodes3.version)} = ${quotedColumn(nodes3.version)} + 1`
|
|
1549
|
+
drizzleOrm.sql`${chunkFQCQM3KG_cjs.quotedColumn(nodes3.version)} = ${chunkFQCQM3KG_cjs.quotedColumn(nodes3.version)} + 1`
|
|
1453
1550
|
);
|
|
1454
1551
|
}
|
|
1455
1552
|
if (params.validTo !== void 0) {
|
|
1456
|
-
setParts.push(drizzleOrm.sql`${quotedColumn(nodes3.validTo)} = ${params.validTo}`);
|
|
1553
|
+
setParts.push(drizzleOrm.sql`${chunkFQCQM3KG_cjs.quotedColumn(nodes3.validTo)} = ${params.validTo}`);
|
|
1457
1554
|
}
|
|
1458
1555
|
if (params.clearDeleted) {
|
|
1459
|
-
setParts.push(drizzleOrm.sql`${quotedColumn(nodes3.deletedAt)} = NULL`);
|
|
1556
|
+
setParts.push(drizzleOrm.sql`${chunkFQCQM3KG_cjs.quotedColumn(nodes3.deletedAt)} = NULL`);
|
|
1460
1557
|
}
|
|
1461
1558
|
const setClause = drizzleOrm.sql.join(setParts, drizzleOrm.sql`, `);
|
|
1462
1559
|
if (params.clearDeleted) {
|
|
@@ -1483,7 +1580,7 @@ function buildDeleteNode(tables3, params, timestamp2) {
|
|
|
1483
1580
|
const { nodes: nodes3 } = tables3;
|
|
1484
1581
|
return drizzleOrm.sql`
|
|
1485
1582
|
UPDATE ${nodes3}
|
|
1486
|
-
SET ${quotedColumn(nodes3.deletedAt)} = ${timestamp2}
|
|
1583
|
+
SET ${chunkFQCQM3KG_cjs.quotedColumn(nodes3.deletedAt)} = ${timestamp2}
|
|
1487
1584
|
WHERE ${nodes3.graphId} = ${params.graphId}
|
|
1488
1585
|
AND ${nodes3.kind} = ${params.kind}
|
|
1489
1586
|
AND ${nodes3.id} = ${params.id}
|
|
@@ -1550,12 +1647,12 @@ function buildSetActiveSchema(tables3, graphId, version, dialect = "sqlite") {
|
|
|
1550
1647
|
const strategy = SCHEMA_DIALECT_STRATEGIES[dialect];
|
|
1551
1648
|
const deactivateAll = drizzleOrm.sql`
|
|
1552
1649
|
UPDATE ${schemaVersions3}
|
|
1553
|
-
SET ${quotedColumn(schemaVersions3.isActive)} = ${strategy.booleanLiteral(false)}
|
|
1650
|
+
SET ${chunkFQCQM3KG_cjs.quotedColumn(schemaVersions3.isActive)} = ${strategy.booleanLiteral(false)}
|
|
1554
1651
|
WHERE ${schemaVersions3.graphId} = ${graphId}
|
|
1555
1652
|
`;
|
|
1556
1653
|
const activateVersion = drizzleOrm.sql`
|
|
1557
1654
|
UPDATE ${schemaVersions3}
|
|
1558
|
-
SET ${quotedColumn(schemaVersions3.isActive)} = ${strategy.booleanLiteral(true)}
|
|
1655
|
+
SET ${chunkFQCQM3KG_cjs.quotedColumn(schemaVersions3.isActive)} = ${strategy.booleanLiteral(true)}
|
|
1559
1656
|
WHERE ${schemaVersions3.graphId} = ${graphId}
|
|
1560
1657
|
AND ${schemaVersions3.version} = ${version}
|
|
1561
1658
|
`;
|
|
@@ -1573,22 +1670,22 @@ function buildInsertUniqueSqlite(tables3, params) {
|
|
|
1573
1670
|
)
|
|
1574
1671
|
ON CONFLICT (${conflictColumns})
|
|
1575
1672
|
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)}
|
|
1673
|
+
${chunkFQCQM3KG_cjs.quotedColumn(uniques3.nodeId)} = CASE
|
|
1674
|
+
WHEN ${chunkFQCQM3KG_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.nodeId}
|
|
1675
|
+
WHEN ${chunkFQCQM3KG_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.nodeId}
|
|
1676
|
+
ELSE ${chunkFQCQM3KG_cjs.quotedColumn(uniques3.nodeId)}
|
|
1580
1677
|
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)}
|
|
1678
|
+
${chunkFQCQM3KG_cjs.quotedColumn(uniques3.concreteKind)} = CASE
|
|
1679
|
+
WHEN ${chunkFQCQM3KG_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.concreteKind}
|
|
1680
|
+
WHEN ${chunkFQCQM3KG_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.concreteKind}
|
|
1681
|
+
ELSE ${chunkFQCQM3KG_cjs.quotedColumn(uniques3.concreteKind)}
|
|
1585
1682
|
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)}
|
|
1683
|
+
${chunkFQCQM3KG_cjs.quotedColumn(uniques3.deletedAt)} = CASE
|
|
1684
|
+
WHEN ${chunkFQCQM3KG_cjs.quotedColumn(uniques3.nodeId)} = ${params.nodeId} THEN NULL
|
|
1685
|
+
WHEN ${chunkFQCQM3KG_cjs.quotedColumn(uniques3.deletedAt)} IS NOT NULL THEN NULL
|
|
1686
|
+
ELSE ${chunkFQCQM3KG_cjs.quotedColumn(uniques3.deletedAt)}
|
|
1590
1687
|
END
|
|
1591
|
-
RETURNING ${quotedColumn(uniques3.nodeId)} as node_id
|
|
1688
|
+
RETURNING ${chunkFQCQM3KG_cjs.quotedColumn(uniques3.nodeId)} as node_id
|
|
1592
1689
|
`;
|
|
1593
1690
|
}
|
|
1594
1691
|
function buildInsertUniquePostgres(tables3, params) {
|
|
@@ -1605,22 +1702,22 @@ function buildInsertUniquePostgres(tables3, params) {
|
|
|
1605
1702
|
)
|
|
1606
1703
|
ON CONFLICT (${conflictColumns})
|
|
1607
1704
|
DO UPDATE SET
|
|
1608
|
-
${quotedColumn(uniques3.nodeId)} = CASE
|
|
1705
|
+
${chunkFQCQM3KG_cjs.quotedColumn(uniques3.nodeId)} = CASE
|
|
1609
1706
|
WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.nodeId}
|
|
1610
1707
|
WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.nodeId}
|
|
1611
1708
|
ELSE ${existingColumn(uniques3.nodeId)}
|
|
1612
1709
|
END,
|
|
1613
|
-
${quotedColumn(uniques3.concreteKind)} = CASE
|
|
1710
|
+
${chunkFQCQM3KG_cjs.quotedColumn(uniques3.concreteKind)} = CASE
|
|
1614
1711
|
WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN ${params.concreteKind}
|
|
1615
1712
|
WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN ${params.concreteKind}
|
|
1616
1713
|
ELSE ${existingColumn(uniques3.concreteKind)}
|
|
1617
1714
|
END,
|
|
1618
|
-
${quotedColumn(uniques3.deletedAt)} = CASE
|
|
1715
|
+
${chunkFQCQM3KG_cjs.quotedColumn(uniques3.deletedAt)} = CASE
|
|
1619
1716
|
WHEN ${existingColumn(uniques3.nodeId)} = ${params.nodeId} THEN NULL
|
|
1620
1717
|
WHEN ${existingColumn(uniques3.deletedAt)} IS NOT NULL THEN NULL
|
|
1621
1718
|
ELSE ${existingColumn(uniques3.deletedAt)}
|
|
1622
1719
|
END
|
|
1623
|
-
RETURNING ${quotedColumn(uniques3.nodeId)} as node_id
|
|
1720
|
+
RETURNING ${chunkFQCQM3KG_cjs.quotedColumn(uniques3.nodeId)} as node_id
|
|
1624
1721
|
`;
|
|
1625
1722
|
}
|
|
1626
1723
|
var UNIQUE_INSERT_BUILDERS = {
|
|
@@ -1635,7 +1732,7 @@ function buildDeleteUnique(tables3, params, timestamp2) {
|
|
|
1635
1732
|
const { uniques: uniques3 } = tables3;
|
|
1636
1733
|
return drizzleOrm.sql`
|
|
1637
1734
|
UPDATE ${uniques3}
|
|
1638
|
-
SET ${quotedColumn(uniques3.deletedAt)} = ${timestamp2}
|
|
1735
|
+
SET ${chunkFQCQM3KG_cjs.quotedColumn(uniques3.deletedAt)} = ${timestamp2}
|
|
1639
1736
|
WHERE ${uniques3.graphId} = ${params.graphId}
|
|
1640
1737
|
AND ${uniques3.nodeKind} = ${params.nodeKind}
|
|
1641
1738
|
AND ${uniques3.constraintName} = ${params.constraintName}
|
|
@@ -1903,13 +2000,27 @@ var COMMON_TABLE_OPERATION_BUILDERS = {
|
|
|
1903
2000
|
buildCheckUniqueBatch,
|
|
1904
2001
|
buildGetSchemaVersion
|
|
1905
2002
|
};
|
|
1906
|
-
function createCommonOperationStrategy(tables3, dialect) {
|
|
2003
|
+
function createCommonOperationStrategy(tables3, dialect, fulltextStrategy) {
|
|
1907
2004
|
const tableOperations = bindTableOperationBuilders(
|
|
1908
2005
|
tables3,
|
|
1909
2006
|
COMMON_TABLE_OPERATION_BUILDERS
|
|
1910
2007
|
);
|
|
2008
|
+
const fulltextTable = tables3.fulltextTableName;
|
|
2009
|
+
const fulltextBuilders = {
|
|
2010
|
+
buildUpsertFulltext: (params, timestamp2) => fulltextStrategy.buildUpsert(fulltextTable, params, timestamp2),
|
|
2011
|
+
buildDeleteFulltext: (params) => fulltextStrategy.buildDelete(fulltextTable, params),
|
|
2012
|
+
buildDeleteFulltextByNode: (graphId, nodeKind, nodeId) => fulltextStrategy.buildDelete(fulltextTable, {
|
|
2013
|
+
graphId,
|
|
2014
|
+
nodeKind,
|
|
2015
|
+
nodeId
|
|
2016
|
+
}),
|
|
2017
|
+
buildUpsertFulltextBatch: (params, timestamp2) => fulltextStrategy.buildBatchUpsert(fulltextTable, params, timestamp2),
|
|
2018
|
+
buildDeleteFulltextBatch: (params) => fulltextStrategy.buildBatchDelete(fulltextTable, params),
|
|
2019
|
+
buildFulltextSearch: (params) => buildFulltextSearch(fulltextTable, params, fulltextStrategy)
|
|
2020
|
+
};
|
|
1911
2021
|
return {
|
|
1912
2022
|
...tableOperations,
|
|
2023
|
+
...fulltextBuilders,
|
|
1913
2024
|
buildInsertUnique(params) {
|
|
1914
2025
|
return buildInsertUnique(tables3, dialect, params);
|
|
1915
2026
|
},
|
|
@@ -1927,11 +2038,15 @@ function createCommonOperationStrategy(tables3, dialect) {
|
|
|
1927
2038
|
}
|
|
1928
2039
|
};
|
|
1929
2040
|
}
|
|
1930
|
-
function createSqliteOperationStrategy(tables3) {
|
|
1931
|
-
return createCommonOperationStrategy(tables3, "sqlite");
|
|
2041
|
+
function createSqliteOperationStrategy(tables3, fulltextStrategy) {
|
|
2042
|
+
return createCommonOperationStrategy(tables3, "sqlite", fulltextStrategy);
|
|
1932
2043
|
}
|
|
1933
|
-
function createPostgresOperationStrategy(tables3) {
|
|
1934
|
-
const common = createCommonOperationStrategy(
|
|
2044
|
+
function createPostgresOperationStrategy(tables3, fulltextStrategy) {
|
|
2045
|
+
const common = createCommonOperationStrategy(
|
|
2046
|
+
tables3,
|
|
2047
|
+
"postgres",
|
|
2048
|
+
fulltextStrategy
|
|
2049
|
+
);
|
|
1935
2050
|
return {
|
|
1936
2051
|
...common,
|
|
1937
2052
|
buildUpsertEmbedding(params, timestamp2) {
|
|
@@ -1989,11 +2104,11 @@ function generateVectorIndexName(graphId, nodeKind, fieldPath, metric = "cosine"
|
|
|
1989
2104
|
metric
|
|
1990
2105
|
];
|
|
1991
2106
|
const name = parts.join("_");
|
|
1992
|
-
if (name.length <=
|
|
2107
|
+
if (name.length <= chunkFQCQM3KG_cjs.MAX_PG_IDENTIFIER_LENGTH) {
|
|
1993
2108
|
return name;
|
|
1994
2109
|
}
|
|
1995
2110
|
const hash = shortHash(name);
|
|
1996
|
-
const truncated = name.slice(0,
|
|
2111
|
+
const truncated = name.slice(0, chunkFQCQM3KG_cjs.MAX_PG_IDENTIFIER_LENGTH - 1 - hash.length);
|
|
1997
2112
|
return `${truncated}_${hash}`;
|
|
1998
2113
|
}
|
|
1999
2114
|
function getOperatorClass(metric) {
|
|
@@ -2172,5 +2287,5 @@ exports.tables2 = tables2;
|
|
|
2172
2287
|
exports.uniques = uniques;
|
|
2173
2288
|
exports.uniques2 = uniques2;
|
|
2174
2289
|
exports.wrapWithManagedClose = wrapWithManagedClose;
|
|
2175
|
-
//# sourceMappingURL=chunk-
|
|
2176
|
-
//# sourceMappingURL=chunk-
|
|
2290
|
+
//# sourceMappingURL=chunk-Q73OWTJY.cjs.map
|
|
2291
|
+
//# sourceMappingURL=chunk-Q73OWTJY.cjs.map
|