@nicia-ai/typegraph 0.20.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 +1705 -490
- 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 +1552 -361
- 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,6 +1,6 @@
|
|
|
1
1
|
import { DatabaseOperationError, UniquenessError } from './chunk-WFMTAEEN.js';
|
|
2
|
-
import { buildPostgresNodeIndexBuilders, buildPostgresEdgeIndexBuilders, buildSqliteNodeIndexBuilders, buildSqliteEdgeIndexBuilders } from './chunk-
|
|
3
|
-
import { MAX_PG_IDENTIFIER_LENGTH } from './chunk-
|
|
2
|
+
import { buildPostgresNodeIndexBuilders, buildPostgresEdgeIndexBuilders, buildSqliteNodeIndexBuilders, buildSqliteEdgeIndexBuilders } from './chunk-SMMOAVJ5.js';
|
|
3
|
+
import { tsvectorStrategy, fts5Strategy, MAX_PG_IDENTIFIER_LENGTH, quotedTableName, quotedColumn, edgeColumnList, sqlNull, nodeColumnList } from './chunk-4XNE2JG3.js';
|
|
4
4
|
import { customType, pgTable, timestamp, integer, jsonb, text, primaryKey, index, boolean, getTableConfig as getTableConfig$1 } from 'drizzle-orm/pg-core';
|
|
5
5
|
import { sqliteTable, text as text$1, integer as integer$1, primaryKey as primaryKey$1, index as index$1, blob, getTableConfig } from 'drizzle-orm/sqlite-core';
|
|
6
6
|
import { sql, getTableName } from 'drizzle-orm';
|
|
@@ -67,7 +67,8 @@ var DEFAULT_TABLE_NAMES = {
|
|
|
67
67
|
edges: "typegraph_edges",
|
|
68
68
|
uniques: "typegraph_node_uniques",
|
|
69
69
|
schemaVersions: "typegraph_schema_versions",
|
|
70
|
-
embeddings: "typegraph_node_embeddings"
|
|
70
|
+
embeddings: "typegraph_node_embeddings",
|
|
71
|
+
fulltext: "typegraph_node_fulltext"
|
|
71
72
|
};
|
|
72
73
|
function createPostgresTables(names = {}, options = {}) {
|
|
73
74
|
const n = { ...DEFAULT_TABLE_NAMES, ...names };
|
|
@@ -224,7 +225,23 @@ function createPostgresTables(names = {}, options = {}) {
|
|
|
224
225
|
)
|
|
225
226
|
]
|
|
226
227
|
);
|
|
227
|
-
return {
|
|
228
|
+
return {
|
|
229
|
+
nodes: nodes3,
|
|
230
|
+
edges: edges3,
|
|
231
|
+
uniques: uniques3,
|
|
232
|
+
schemaVersions: schemaVersions3,
|
|
233
|
+
embeddings: embeddings3,
|
|
234
|
+
/**
|
|
235
|
+
* The fulltext storage table is owned by the active `FulltextStrategy`,
|
|
236
|
+
* not Drizzle. Shapes vary across strategies — the default `tsvectorStrategy`
|
|
237
|
+
* uses a `regconfig` language column, a GENERATED STORED `tsv` column,
|
|
238
|
+
* and a GIN index; alternate strategies (ParadeDB, pg_trgm, pgroonga)
|
|
239
|
+
* pick their own column types and index methods. DDL is emitted as
|
|
240
|
+
* raw SQL via `strategy.generateDdl()`; reads and writes are composed
|
|
241
|
+
* from the strategy's fragment helpers.
|
|
242
|
+
*/
|
|
243
|
+
fulltextTableName: n.fulltext
|
|
244
|
+
};
|
|
228
245
|
}
|
|
229
246
|
var tables = createPostgresTables();
|
|
230
247
|
var { nodes, edges, uniques, schemaVersions, embeddings } = tables;
|
|
@@ -233,7 +250,8 @@ var DEFAULT_TABLE_NAMES2 = {
|
|
|
233
250
|
edges: "typegraph_edges",
|
|
234
251
|
uniques: "typegraph_node_uniques",
|
|
235
252
|
schemaVersions: "typegraph_schema_versions",
|
|
236
|
-
embeddings: "typegraph_node_embeddings"
|
|
253
|
+
embeddings: "typegraph_node_embeddings",
|
|
254
|
+
fulltext: "typegraph_node_fulltext"
|
|
237
255
|
};
|
|
238
256
|
function createSqliteTables(names = {}, options = {}) {
|
|
239
257
|
const n = { ...DEFAULT_TABLE_NAMES2, ...names };
|
|
@@ -394,7 +412,19 @@ function createSqliteTables(names = {}, options = {}) {
|
|
|
394
412
|
)
|
|
395
413
|
]
|
|
396
414
|
);
|
|
397
|
-
return {
|
|
415
|
+
return {
|
|
416
|
+
nodes: nodes3,
|
|
417
|
+
edges: edges3,
|
|
418
|
+
uniques: uniques3,
|
|
419
|
+
schemaVersions: schemaVersions3,
|
|
420
|
+
embeddings: embeddings3,
|
|
421
|
+
/**
|
|
422
|
+
* The fulltext storage is a FTS5 virtual table which Drizzle cannot
|
|
423
|
+
* represent. DDL is emitted as raw SQL and operations query it via
|
|
424
|
+
* `sql.raw()`.
|
|
425
|
+
*/
|
|
426
|
+
fulltextTableName: n.fulltext
|
|
427
|
+
};
|
|
398
428
|
}
|
|
399
429
|
var tables2 = createSqliteTables();
|
|
400
430
|
var { nodes: nodes2, edges: edges2, uniques: uniques2, schemaVersions: schemaVersions2, embeddings: embeddings2 } = tables2;
|
|
@@ -516,18 +546,25 @@ function generateSqliteCreateIndexSQL(table) {
|
|
|
516
546
|
}
|
|
517
547
|
return statements;
|
|
518
548
|
}
|
|
519
|
-
function
|
|
549
|
+
function isSqliteTable(value) {
|
|
550
|
+
return typeof value === "object" && value !== null && // Drizzle tables are always objects; strings are our escape hatch.
|
|
551
|
+
typeof value !== "string";
|
|
552
|
+
}
|
|
553
|
+
function generateSqliteDDL(tables3 = tables2, fulltextStrategy = fts5Strategy) {
|
|
520
554
|
const statements = [];
|
|
521
555
|
for (const table of Object.values(tables3)) {
|
|
556
|
+
if (!isSqliteTable(table)) continue;
|
|
522
557
|
statements.push(generateSqliteCreateTableSQL(table));
|
|
523
558
|
}
|
|
524
559
|
for (const table of Object.values(tables3)) {
|
|
560
|
+
if (!isSqliteTable(table)) continue;
|
|
525
561
|
statements.push(...generateSqliteCreateIndexSQL(table));
|
|
526
562
|
}
|
|
563
|
+
statements.push(...fulltextStrategy.generateDdl(tables3.fulltextTableName));
|
|
527
564
|
return statements;
|
|
528
565
|
}
|
|
529
|
-
function generateSqliteMigrationSQL(tables3 = tables2) {
|
|
530
|
-
return generateSqliteDDL(tables3).join("\n\n");
|
|
566
|
+
function generateSqliteMigrationSQL(tables3 = tables2, fulltextStrategy = fts5Strategy) {
|
|
567
|
+
return generateSqliteDDL(tables3, fulltextStrategy).join("\n\n");
|
|
531
568
|
}
|
|
532
569
|
function getPgColumnType(column) {
|
|
533
570
|
switch (column.columnType) {
|
|
@@ -608,19 +645,25 @@ function generatePgCreateIndexSQL(table) {
|
|
|
608
645
|
}
|
|
609
646
|
return statements;
|
|
610
647
|
}
|
|
611
|
-
function
|
|
648
|
+
function isPgTable(value) {
|
|
649
|
+
return typeof value === "object" && value !== null && typeof value !== "string";
|
|
650
|
+
}
|
|
651
|
+
function generatePostgresDDL(tables3 = tables, fulltextStrategy = tsvectorStrategy) {
|
|
612
652
|
const statements = [];
|
|
613
653
|
for (const table of Object.values(tables3)) {
|
|
654
|
+
if (!isPgTable(table)) continue;
|
|
614
655
|
statements.push(generatePgCreateTableSQL(table));
|
|
615
656
|
}
|
|
616
657
|
for (const table of Object.values(tables3)) {
|
|
658
|
+
if (!isPgTable(table)) continue;
|
|
617
659
|
statements.push(...generatePgCreateIndexSQL(table));
|
|
618
660
|
}
|
|
661
|
+
statements.push(...fulltextStrategy.generateDdl(tables3.fulltextTableName));
|
|
619
662
|
return statements;
|
|
620
663
|
}
|
|
621
|
-
function generatePostgresMigrationSQL(tables3 = tables) {
|
|
664
|
+
function generatePostgresMigrationSQL(tables3 = tables, fulltextStrategy = tsvectorStrategy) {
|
|
622
665
|
const extensionSql = "-- Enable pgvector extension for vector similarity search\nCREATE EXTENSION IF NOT EXISTS vector;";
|
|
623
|
-
const ddlSql = generatePostgresDDL(tables3).join("\n\n");
|
|
666
|
+
const ddlSql = generatePostgresDDL(tables3, fulltextStrategy).join("\n\n");
|
|
624
667
|
return `${extensionSql}
|
|
625
668
|
|
|
626
669
|
${ddlSql}`;
|
|
@@ -847,6 +890,14 @@ function createCommonOperationBackend(options) {
|
|
|
847
890
|
params.id
|
|
848
891
|
);
|
|
849
892
|
await execution.execRun(deleteEmbeddingsQuery);
|
|
893
|
+
const deleteFulltextStatements = operationStrategy.buildDeleteFulltextByNode(
|
|
894
|
+
params.graphId,
|
|
895
|
+
params.kind,
|
|
896
|
+
params.id
|
|
897
|
+
);
|
|
898
|
+
for (const stmt of deleteFulltextStatements) {
|
|
899
|
+
await execution.execRun(stmt);
|
|
900
|
+
}
|
|
850
901
|
const deleteEdgesQuery = operationStrategy.buildHardDeleteEdgesByNode(
|
|
851
902
|
params.graphId,
|
|
852
903
|
params.kind,
|
|
@@ -1021,7 +1072,9 @@ function createCommonOperationBackend(options) {
|
|
|
1021
1072
|
};
|
|
1022
1073
|
}
|
|
1023
1074
|
function buildClearGraph(tables3, graphId) {
|
|
1075
|
+
const fulltext = quotedTableName(tables3.fulltextTableName);
|
|
1024
1076
|
return [
|
|
1077
|
+
sql`DELETE FROM ${fulltext} WHERE "graph_id" = ${graphId}`,
|
|
1025
1078
|
sql`DELETE FROM ${tables3.embeddings} WHERE ${tables3.embeddings.graphId} = ${graphId}`,
|
|
1026
1079
|
sql`DELETE FROM ${tables3.uniques} WHERE ${tables3.uniques.graphId} = ${graphId}`,
|
|
1027
1080
|
sql`DELETE FROM ${tables3.edges} WHERE ${tables3.edges.graphId} = ${graphId}`,
|
|
@@ -1056,12 +1109,16 @@ function buildFindNodesByKind(tables3, params) {
|
|
|
1056
1109
|
sql`${nodes3.kind} = ${params.kind}`,
|
|
1057
1110
|
...buildTemporalConditions(nodes3, params)
|
|
1058
1111
|
];
|
|
1112
|
+
if (params.orderBy === "id" && params.after !== void 0) {
|
|
1113
|
+
conditions.push(sql`${nodes3.id} > ${params.after}`);
|
|
1114
|
+
}
|
|
1059
1115
|
const whereClause = sql.join(conditions, sql` AND `);
|
|
1116
|
+
const orderByClause = params.orderBy === "id" ? sql`${nodes3.id} ASC` : sql`${nodes3.createdAt} DESC, ${nodes3.id} DESC`;
|
|
1060
1117
|
if (params.limit !== void 0 && params.offset !== void 0) {
|
|
1061
1118
|
return sql`
|
|
1062
1119
|
SELECT * FROM ${nodes3}
|
|
1063
1120
|
WHERE ${whereClause}
|
|
1064
|
-
ORDER BY ${
|
|
1121
|
+
ORDER BY ${orderByClause}
|
|
1065
1122
|
LIMIT ${params.limit} OFFSET ${params.offset}
|
|
1066
1123
|
`;
|
|
1067
1124
|
}
|
|
@@ -1069,14 +1126,14 @@ function buildFindNodesByKind(tables3, params) {
|
|
|
1069
1126
|
return sql`
|
|
1070
1127
|
SELECT * FROM ${nodes3}
|
|
1071
1128
|
WHERE ${whereClause}
|
|
1072
|
-
ORDER BY ${
|
|
1129
|
+
ORDER BY ${orderByClause}
|
|
1073
1130
|
LIMIT ${params.limit}
|
|
1074
1131
|
`;
|
|
1075
1132
|
}
|
|
1076
1133
|
return sql`
|
|
1077
1134
|
SELECT * FROM ${nodes3}
|
|
1078
1135
|
WHERE ${whereClause}
|
|
1079
|
-
ORDER BY ${
|
|
1136
|
+
ORDER BY ${orderByClause}
|
|
1080
1137
|
`;
|
|
1081
1138
|
}
|
|
1082
1139
|
function buildCountNodesByKind(tables3, params) {
|
|
@@ -1159,20 +1216,6 @@ function buildCountEdgesByKind(tables3, params) {
|
|
|
1159
1216
|
WHERE ${whereClause}
|
|
1160
1217
|
`;
|
|
1161
1218
|
}
|
|
1162
|
-
function sqlNull(value) {
|
|
1163
|
-
return value ?? sql.raw("NULL");
|
|
1164
|
-
}
|
|
1165
|
-
function quotedColumn(column) {
|
|
1166
|
-
return sql.raw(`"${column.name.replaceAll('"', '""')}"`);
|
|
1167
|
-
}
|
|
1168
|
-
function nodeColumnList(nodes3) {
|
|
1169
|
-
return 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}"`);
|
|
1170
|
-
}
|
|
1171
|
-
function edgeColumnList(edges3) {
|
|
1172
|
-
return 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}"`);
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
// src/backend/drizzle/operations/edges.ts
|
|
1176
1219
|
function buildInsertEdge(tables3, params, timestamp2) {
|
|
1177
1220
|
const { edges: edges3 } = tables3;
|
|
1178
1221
|
const propsJson = JSON.stringify(params.props);
|
|
@@ -1364,6 +1407,60 @@ function buildFindEdgesConnectedTo(tables3, params) {
|
|
|
1364
1407
|
)
|
|
1365
1408
|
`;
|
|
1366
1409
|
}
|
|
1410
|
+
function resolveMode(mode) {
|
|
1411
|
+
return mode ?? "websearch";
|
|
1412
|
+
}
|
|
1413
|
+
function buildFulltextSearch(tableName, params, strategy) {
|
|
1414
|
+
assertValidSearchParams(params);
|
|
1415
|
+
const mode = resolveMode(params.mode);
|
|
1416
|
+
const table = quotedTableName(tableName);
|
|
1417
|
+
const matchCondition = strategy.matchCondition(
|
|
1418
|
+
tableName,
|
|
1419
|
+
params.query,
|
|
1420
|
+
mode,
|
|
1421
|
+
params.language
|
|
1422
|
+
);
|
|
1423
|
+
const rankExpression = strategy.rankExpression(
|
|
1424
|
+
tableName,
|
|
1425
|
+
params.query,
|
|
1426
|
+
mode,
|
|
1427
|
+
params.language
|
|
1428
|
+
);
|
|
1429
|
+
const conditions = [
|
|
1430
|
+
matchCondition,
|
|
1431
|
+
sql`"graph_id" = ${params.graphId}`,
|
|
1432
|
+
sql`"node_kind" = ${params.nodeKind}`
|
|
1433
|
+
];
|
|
1434
|
+
if (params.minScore !== void 0) {
|
|
1435
|
+
conditions.push(sql`${rankExpression} >= ${params.minScore}`);
|
|
1436
|
+
}
|
|
1437
|
+
const snippetExpr = params.includeSnippets === true && strategy.supportsSnippets ? strategy.snippetExpression(
|
|
1438
|
+
tableName,
|
|
1439
|
+
params.query,
|
|
1440
|
+
mode,
|
|
1441
|
+
params.language
|
|
1442
|
+
) : sql`NULL`;
|
|
1443
|
+
return sql`
|
|
1444
|
+
SELECT
|
|
1445
|
+
"node_id" AS node_id,
|
|
1446
|
+
${rankExpression} AS score,
|
|
1447
|
+
${snippetExpr} AS snippet
|
|
1448
|
+
FROM ${table}
|
|
1449
|
+
WHERE ${sql.join(conditions, sql` AND `)}
|
|
1450
|
+
ORDER BY ${rankExpression} DESC, "node_id" ASC
|
|
1451
|
+
LIMIT ${params.limit}
|
|
1452
|
+
`;
|
|
1453
|
+
}
|
|
1454
|
+
function assertValidSearchParams(params) {
|
|
1455
|
+
if (!Number.isInteger(params.limit) || params.limit <= 0) {
|
|
1456
|
+
throw new Error(`limit must be a positive integer, got: ${params.limit}`);
|
|
1457
|
+
}
|
|
1458
|
+
if (params.minScore !== void 0 && !Number.isFinite(params.minScore)) {
|
|
1459
|
+
throw new TypeError(
|
|
1460
|
+
`minScore must be a finite number, got: ${params.minScore}`
|
|
1461
|
+
);
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1367
1464
|
function buildInsertNode(tables3, params, timestamp2) {
|
|
1368
1465
|
const { nodes: nodes3 } = tables3;
|
|
1369
1466
|
const propsJson = JSON.stringify(params.props);
|
|
@@ -1901,13 +1998,27 @@ var COMMON_TABLE_OPERATION_BUILDERS = {
|
|
|
1901
1998
|
buildCheckUniqueBatch,
|
|
1902
1999
|
buildGetSchemaVersion
|
|
1903
2000
|
};
|
|
1904
|
-
function createCommonOperationStrategy(tables3, dialect) {
|
|
2001
|
+
function createCommonOperationStrategy(tables3, dialect, fulltextStrategy) {
|
|
1905
2002
|
const tableOperations = bindTableOperationBuilders(
|
|
1906
2003
|
tables3,
|
|
1907
2004
|
COMMON_TABLE_OPERATION_BUILDERS
|
|
1908
2005
|
);
|
|
2006
|
+
const fulltextTable = tables3.fulltextTableName;
|
|
2007
|
+
const fulltextBuilders = {
|
|
2008
|
+
buildUpsertFulltext: (params, timestamp2) => fulltextStrategy.buildUpsert(fulltextTable, params, timestamp2),
|
|
2009
|
+
buildDeleteFulltext: (params) => fulltextStrategy.buildDelete(fulltextTable, params),
|
|
2010
|
+
buildDeleteFulltextByNode: (graphId, nodeKind, nodeId) => fulltextStrategy.buildDelete(fulltextTable, {
|
|
2011
|
+
graphId,
|
|
2012
|
+
nodeKind,
|
|
2013
|
+
nodeId
|
|
2014
|
+
}),
|
|
2015
|
+
buildUpsertFulltextBatch: (params, timestamp2) => fulltextStrategy.buildBatchUpsert(fulltextTable, params, timestamp2),
|
|
2016
|
+
buildDeleteFulltextBatch: (params) => fulltextStrategy.buildBatchDelete(fulltextTable, params),
|
|
2017
|
+
buildFulltextSearch: (params) => buildFulltextSearch(fulltextTable, params, fulltextStrategy)
|
|
2018
|
+
};
|
|
1909
2019
|
return {
|
|
1910
2020
|
...tableOperations,
|
|
2021
|
+
...fulltextBuilders,
|
|
1911
2022
|
buildInsertUnique(params) {
|
|
1912
2023
|
return buildInsertUnique(tables3, dialect, params);
|
|
1913
2024
|
},
|
|
@@ -1925,11 +2036,15 @@ function createCommonOperationStrategy(tables3, dialect) {
|
|
|
1925
2036
|
}
|
|
1926
2037
|
};
|
|
1927
2038
|
}
|
|
1928
|
-
function createSqliteOperationStrategy(tables3) {
|
|
1929
|
-
return createCommonOperationStrategy(tables3, "sqlite");
|
|
2039
|
+
function createSqliteOperationStrategy(tables3, fulltextStrategy) {
|
|
2040
|
+
return createCommonOperationStrategy(tables3, "sqlite", fulltextStrategy);
|
|
1930
2041
|
}
|
|
1931
|
-
function createPostgresOperationStrategy(tables3) {
|
|
1932
|
-
const common = createCommonOperationStrategy(
|
|
2042
|
+
function createPostgresOperationStrategy(tables3, fulltextStrategy) {
|
|
2043
|
+
const common = createCommonOperationStrategy(
|
|
2044
|
+
tables3,
|
|
2045
|
+
"postgres",
|
|
2046
|
+
fulltextStrategy
|
|
2047
|
+
);
|
|
1933
2048
|
return {
|
|
1934
2049
|
...common,
|
|
1935
2050
|
buildUpsertEmbedding(params, timestamp2) {
|
|
@@ -2133,5 +2248,5 @@ function compileQueryWithDialect(db, query, backendName) {
|
|
|
2133
2248
|
}
|
|
2134
2249
|
|
|
2135
2250
|
export { POSTGRES_CAPABILITIES, POSTGRES_ROW_MAPPER_CONFIG, SQLITE_CAPABILITIES, SQLITE_ROW_MAPPER_CONFIG, compileQueryWithDialect, createCommonOperationBackend, createEdgeRowMapper, createNodeRowMapper, createPostgresOperationStrategy, createPostgresTables, createPostgresVectorIndex, createSchemaVersionRowMapper, createSqliteOperationStrategy, createSqliteTables, createSqliteVectorIndex, createUniqueRowMapper, dropPostgresVectorIndex, dropSqliteVectorIndex, edges, edges2, embeddings, embeddings2, formatPostgresTimestamp, generatePostgresDDL, generatePostgresMigrationSQL, generateSqliteDDL, generateSqliteMigrationSQL, generateVectorIndexName, nodes, nodes2, nowIso, schemaVersions, schemaVersions2, tables, tables2, uniques, uniques2, wrapWithManagedClose };
|
|
2136
|
-
//# sourceMappingURL=chunk-
|
|
2137
|
-
//# sourceMappingURL=chunk-
|
|
2251
|
+
//# sourceMappingURL=chunk-UQVBVBVG.js.map
|
|
2252
|
+
//# sourceMappingURL=chunk-UQVBVBVG.js.map
|