@nicia-ai/typegraph 0.23.0 → 0.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend/postgres/index.cjs +32 -32
- package/dist/backend/postgres/index.js +3 -3
- package/dist/backend/sqlite/index.cjs +13 -13
- package/dist/backend/sqlite/index.js +3 -3
- package/dist/backend/sqlite/libsql.cjs +6 -6
- package/dist/backend/sqlite/libsql.js +3 -3
- package/dist/backend/sqlite/local.cjs +7 -7
- package/dist/backend/sqlite/local.js +3 -3
- package/dist/{chunk-7OD2EPN4.cjs → chunk-5HVDOPZU.cjs} +70 -5
- package/dist/chunk-5HVDOPZU.cjs.map +1 -0
- package/dist/{chunk-H2CAJ4ZV.js → chunk-EY4LBX3F.js} +70 -5
- package/dist/chunk-EY4LBX3F.js.map +1 -0
- package/dist/{chunk-JYUQA77I.js → chunk-GFGVREHH.js} +3 -3
- package/dist/{chunk-JYUQA77I.js.map → chunk-GFGVREHH.js.map} +1 -1
- package/dist/{chunk-7TU5EWQ7.js → chunk-GUTQTMOV.js} +2 -2
- package/dist/chunk-GUTQTMOV.js.map +1 -0
- package/dist/{chunk-RS5OLGEW.js → chunk-LBORRUNJ.js} +2 -2
- package/dist/chunk-LBORRUNJ.js.map +1 -0
- package/dist/{chunk-WRWVWKQL.cjs → chunk-OLROXS2S.cjs} +2 -2
- package/dist/chunk-OLROXS2S.cjs.map +1 -0
- package/dist/{chunk-O5BRZEIZ.cjs → chunk-OVJ2BE5Q.cjs} +55 -27
- package/dist/chunk-OVJ2BE5Q.cjs.map +1 -0
- package/dist/{chunk-HRNQ3DVJ.cjs → chunk-PAUN562Y.cjs} +6 -6
- package/dist/{chunk-HRNQ3DVJ.cjs.map → chunk-PAUN562Y.cjs.map} +1 -1
- package/dist/{chunk-EP2KSSD5.js → chunk-QOLTW7OZ.js} +38 -10
- package/dist/chunk-QOLTW7OZ.js.map +1 -0
- package/dist/{chunk-RNUNP5JD.cjs → chunk-SUHW2UYL.cjs} +2 -2
- package/dist/chunk-SUHW2UYL.cjs.map +1 -0
- package/dist/index.cjs +61 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/interchange/index.cjs +6 -6
- package/dist/interchange/index.js +1 -1
- package/dist/schema/index.cjs +21 -21
- package/dist/schema/index.js +3 -3
- package/package.json +5 -5
- package/dist/chunk-7OD2EPN4.cjs.map +0 -1
- package/dist/chunk-7TU5EWQ7.js.map +0 -1
- package/dist/chunk-EP2KSSD5.js.map +0 -1
- package/dist/chunk-H2CAJ4ZV.js.map +0 -1
- package/dist/chunk-O5BRZEIZ.cjs.map +0 -1
- package/dist/chunk-RNUNP5JD.cjs.map +0 -1
- package/dist/chunk-RS5OLGEW.js.map +0 -1
- package/dist/chunk-WRWVWKQL.cjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkHTGDWIDE_cjs = require('../../chunk-HTGDWIDE.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var chunk5HVDOPZU_cjs = require('../../chunk-5HVDOPZU.cjs');
|
|
5
|
+
var chunkSUHW2UYL_cjs = require('../../chunk-SUHW2UYL.cjs');
|
|
6
6
|
require('../../chunk-O5PST6TB.cjs');
|
|
7
7
|
require('../../chunk-PEE4EWXZ.cjs');
|
|
8
8
|
var chunk3JK66E3I_cjs = require('../../chunk-3JK66E3I.cjs');
|
|
@@ -31,7 +31,7 @@ var DEFAULT_POSTGRES_STATEMENT_CACHE_MAX = 256;
|
|
|
31
31
|
var STATEMENT_NAME_CACHE = /* @__PURE__ */ new Map();
|
|
32
32
|
var nextStatementId = 0;
|
|
33
33
|
function statementNameFor(sqlText, cacheMax) {
|
|
34
|
-
return
|
|
34
|
+
return chunk5HVDOPZU_cjs.getOrCreateLru(STATEMENT_NAME_CACHE, sqlText, cacheMax, () => {
|
|
35
35
|
const name = `tg_${nextStatementId}`;
|
|
36
36
|
nextStatementId += 1;
|
|
37
37
|
return name;
|
|
@@ -122,7 +122,7 @@ function createPostgresExecutionAdapter(db, options = {}) {
|
|
|
122
122
|
const cacheMax = options.preparedStatementCacheMax ?? DEFAULT_POSTGRES_STATEMENT_CACHE_MAX;
|
|
123
123
|
const pgClient = resolvePgClient(db, prepareStatements, cacheMax);
|
|
124
124
|
function compile(query) {
|
|
125
|
-
return
|
|
125
|
+
return chunk5HVDOPZU_cjs.compileQueryWithDialect(db, query, "PostgreSQL");
|
|
126
126
|
}
|
|
127
127
|
if (pgClient === void 0) {
|
|
128
128
|
return {
|
|
@@ -178,10 +178,10 @@ var POSTGRES_CHECK_UNIQUE_BATCH_CHUNK_SIZE = Math.max(
|
|
|
178
178
|
1,
|
|
179
179
|
POSTGRES_MAX_BIND_PARAMETERS - CHECK_UNIQUE_BATCH_FIXED_PARAM_COUNT
|
|
180
180
|
);
|
|
181
|
-
var toNodeRow =
|
|
182
|
-
var toEdgeRow =
|
|
183
|
-
var toUniqueRow =
|
|
184
|
-
var toSchemaVersionRow =
|
|
181
|
+
var toNodeRow = chunk5HVDOPZU_cjs.createNodeRowMapper(chunk5HVDOPZU_cjs.POSTGRES_ROW_MAPPER_CONFIG);
|
|
182
|
+
var toEdgeRow = chunk5HVDOPZU_cjs.createEdgeRowMapper(chunk5HVDOPZU_cjs.POSTGRES_ROW_MAPPER_CONFIG);
|
|
183
|
+
var toUniqueRow = chunk5HVDOPZU_cjs.createUniqueRowMapper(chunk5HVDOPZU_cjs.POSTGRES_ROW_MAPPER_CONFIG);
|
|
184
|
+
var toSchemaVersionRow = chunk5HVDOPZU_cjs.createSchemaVersionRowMapper(chunk5HVDOPZU_cjs.POSTGRES_ROW_MAPPER_CONFIG);
|
|
185
185
|
function toEmbeddingRow(row) {
|
|
186
186
|
let embedding;
|
|
187
187
|
if (typeof row.embedding === "string") {
|
|
@@ -199,8 +199,8 @@ function toEmbeddingRow(row) {
|
|
|
199
199
|
field_path: row.field_path,
|
|
200
200
|
embedding,
|
|
201
201
|
dimensions: row.dimensions,
|
|
202
|
-
created_at:
|
|
203
|
-
updated_at:
|
|
202
|
+
created_at: chunk5HVDOPZU_cjs.formatPostgresTimestamp(row.created_at) ?? "",
|
|
203
|
+
updated_at: chunk5HVDOPZU_cjs.formatPostgresTimestamp(row.updated_at) ?? ""
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
206
|
function coerceNumericScore(value) {
|
|
@@ -215,7 +215,7 @@ function coerceNumericScore(value) {
|
|
|
215
215
|
}
|
|
216
216
|
function buildPostgresCapabilities(strategy) {
|
|
217
217
|
return {
|
|
218
|
-
...
|
|
218
|
+
...chunkSUHW2UYL_cjs.POSTGRES_CAPABILITIES,
|
|
219
219
|
vector: {
|
|
220
220
|
supported: true,
|
|
221
221
|
metrics: ["cosine", "l2", "inner_product"],
|
|
@@ -227,7 +227,7 @@ function buildPostgresCapabilities(strategy) {
|
|
|
227
227
|
};
|
|
228
228
|
}
|
|
229
229
|
function createPostgresBackend(db, options = {}) {
|
|
230
|
-
const tables2 = options.tables ??
|
|
230
|
+
const tables2 = options.tables ?? chunk5HVDOPZU_cjs.tables;
|
|
231
231
|
const fulltextStrategy = options.fulltext ?? chunk3JK66E3I_cjs.tsvectorStrategy;
|
|
232
232
|
const baseCapabilities = buildPostgresCapabilities(fulltextStrategy);
|
|
233
233
|
const httpOnlyOverrides = isNeonHttpClient(db) ? { transactions: false } : {};
|
|
@@ -257,7 +257,7 @@ function createPostgresBackend(db, options = {}) {
|
|
|
257
257
|
].map((name) => chunkHTGDWIDE_cjs.quoteIdentifier(name)),
|
|
258
258
|
drizzleOrm.sql`, `
|
|
259
259
|
)}`;
|
|
260
|
-
const operationStrategy =
|
|
260
|
+
const operationStrategy = chunk5HVDOPZU_cjs.createPostgresOperationStrategy(
|
|
261
261
|
tables2,
|
|
262
262
|
fulltextStrategy
|
|
263
263
|
);
|
|
@@ -272,7 +272,7 @@ function createPostgresBackend(db, options = {}) {
|
|
|
272
272
|
const backend = {
|
|
273
273
|
...operations,
|
|
274
274
|
async bootstrapTables() {
|
|
275
|
-
const statements =
|
|
275
|
+
const statements = chunk5HVDOPZU_cjs.generatePostgresDDL(tables2, fulltextStrategy);
|
|
276
276
|
for (const statement of statements) {
|
|
277
277
|
await db.execute(drizzleOrm.sql.raw(statement));
|
|
278
278
|
}
|
|
@@ -281,7 +281,7 @@ function createPostgresBackend(db, options = {}) {
|
|
|
281
281
|
await db.execute(analyzeStatement);
|
|
282
282
|
},
|
|
283
283
|
async setActiveSchema(graphId, version) {
|
|
284
|
-
await
|
|
284
|
+
await chunkSUHW2UYL_cjs.runOptionallyInTransaction(
|
|
285
285
|
backend,
|
|
286
286
|
(target) => target.setActiveSchema(graphId, version),
|
|
287
287
|
operations
|
|
@@ -327,7 +327,7 @@ function createPostgresOperationBackend(options) {
|
|
|
327
327
|
async function execRun(query) {
|
|
328
328
|
await executionAdapter.execute(query);
|
|
329
329
|
}
|
|
330
|
-
const commonBackend =
|
|
330
|
+
const commonBackend = chunk5HVDOPZU_cjs.createCommonOperationBackend({
|
|
331
331
|
batchConfig: {
|
|
332
332
|
checkUniqueBatchChunkSize: POSTGRES_CHECK_UNIQUE_BATCH_CHUNK_SIZE,
|
|
333
333
|
edgeInsertBatchSize: POSTGRES_EDGE_INSERT_BATCH_SIZE,
|
|
@@ -340,7 +340,7 @@ function createPostgresOperationBackend(options) {
|
|
|
340
340
|
execGet,
|
|
341
341
|
execRun
|
|
342
342
|
},
|
|
343
|
-
nowIso:
|
|
343
|
+
nowIso: chunk5HVDOPZU_cjs.nowIso,
|
|
344
344
|
operationStrategy,
|
|
345
345
|
rowMappers: {
|
|
346
346
|
toEdgeRow,
|
|
@@ -364,7 +364,7 @@ function createPostgresOperationBackend(options) {
|
|
|
364
364
|
tableNames,
|
|
365
365
|
// === Embedding Operations ===
|
|
366
366
|
async upsertEmbedding(params) {
|
|
367
|
-
const timestamp =
|
|
367
|
+
const timestamp = chunk5HVDOPZU_cjs.nowIso();
|
|
368
368
|
const query = operationStrategy.buildUpsertEmbedding(params, timestamp);
|
|
369
369
|
await execRun(query);
|
|
370
370
|
},
|
|
@@ -403,7 +403,7 @@ function createPostgresOperationBackend(options) {
|
|
|
403
403
|
...params.indexParams?.efConstruction === void 0 ? {} : { hnswEfConstruction: params.indexParams.efConstruction },
|
|
404
404
|
...params.indexParams?.lists === void 0 ? {} : { ivfflatLists: params.indexParams.lists }
|
|
405
405
|
};
|
|
406
|
-
const result = await
|
|
406
|
+
const result = await chunk5HVDOPZU_cjs.createPostgresVectorIndex(db, indexOptions);
|
|
407
407
|
if (!result.success) {
|
|
408
408
|
throw new Error(
|
|
409
409
|
result.message ?? "Failed to create PostgreSQL vector index"
|
|
@@ -412,7 +412,7 @@ function createPostgresOperationBackend(options) {
|
|
|
412
412
|
},
|
|
413
413
|
// === Fulltext Operations ===
|
|
414
414
|
async upsertFulltext(params) {
|
|
415
|
-
const timestamp =
|
|
415
|
+
const timestamp = chunk5HVDOPZU_cjs.nowIso();
|
|
416
416
|
const statements = operationStrategy.buildUpsertFulltext(
|
|
417
417
|
params,
|
|
418
418
|
timestamp
|
|
@@ -429,7 +429,7 @@ function createPostgresOperationBackend(options) {
|
|
|
429
429
|
},
|
|
430
430
|
async upsertFulltextBatch(params) {
|
|
431
431
|
if (params.rows.length === 0) return;
|
|
432
|
-
const timestamp =
|
|
432
|
+
const timestamp = chunk5HVDOPZU_cjs.nowIso();
|
|
433
433
|
const statements = operationStrategy.buildUpsertFulltextBatch(
|
|
434
434
|
params,
|
|
435
435
|
timestamp
|
|
@@ -458,13 +458,13 @@ function createPostgresOperationBackend(options) {
|
|
|
458
458
|
async dropVectorIndex(params) {
|
|
459
459
|
const metrics = capabilities.vector?.metrics ?? ["cosine"];
|
|
460
460
|
for (const metric of metrics) {
|
|
461
|
-
const indexName =
|
|
461
|
+
const indexName = chunk5HVDOPZU_cjs.generateVectorIndexName(
|
|
462
462
|
params.graphId,
|
|
463
463
|
params.nodeKind,
|
|
464
464
|
params.fieldPath,
|
|
465
465
|
metric
|
|
466
466
|
);
|
|
467
|
-
const result = await
|
|
467
|
+
const result = await chunk5HVDOPZU_cjs.dropPostgresVectorIndex(db, indexName);
|
|
468
468
|
if (!result.success) {
|
|
469
469
|
throw new Error(
|
|
470
470
|
result.message ?? "Failed to drop PostgreSQL vector index"
|
|
@@ -496,39 +496,39 @@ function createTransactionBackend(options) {
|
|
|
496
496
|
|
|
497
497
|
Object.defineProperty(exports, "createPostgresTables", {
|
|
498
498
|
enumerable: true,
|
|
499
|
-
get: function () { return
|
|
499
|
+
get: function () { return chunk5HVDOPZU_cjs.createPostgresTables; }
|
|
500
500
|
});
|
|
501
501
|
Object.defineProperty(exports, "edges", {
|
|
502
502
|
enumerable: true,
|
|
503
|
-
get: function () { return
|
|
503
|
+
get: function () { return chunk5HVDOPZU_cjs.edges; }
|
|
504
504
|
});
|
|
505
505
|
Object.defineProperty(exports, "embeddings", {
|
|
506
506
|
enumerable: true,
|
|
507
|
-
get: function () { return
|
|
507
|
+
get: function () { return chunk5HVDOPZU_cjs.embeddings; }
|
|
508
508
|
});
|
|
509
509
|
Object.defineProperty(exports, "generatePostgresDDL", {
|
|
510
510
|
enumerable: true,
|
|
511
|
-
get: function () { return
|
|
511
|
+
get: function () { return chunk5HVDOPZU_cjs.generatePostgresDDL; }
|
|
512
512
|
});
|
|
513
513
|
Object.defineProperty(exports, "generatePostgresMigrationSQL", {
|
|
514
514
|
enumerable: true,
|
|
515
|
-
get: function () { return
|
|
515
|
+
get: function () { return chunk5HVDOPZU_cjs.generatePostgresMigrationSQL; }
|
|
516
516
|
});
|
|
517
517
|
Object.defineProperty(exports, "nodes", {
|
|
518
518
|
enumerable: true,
|
|
519
|
-
get: function () { return
|
|
519
|
+
get: function () { return chunk5HVDOPZU_cjs.nodes; }
|
|
520
520
|
});
|
|
521
521
|
Object.defineProperty(exports, "schemaVersions", {
|
|
522
522
|
enumerable: true,
|
|
523
|
-
get: function () { return
|
|
523
|
+
get: function () { return chunk5HVDOPZU_cjs.schemaVersions; }
|
|
524
524
|
});
|
|
525
525
|
Object.defineProperty(exports, "tables", {
|
|
526
526
|
enumerable: true,
|
|
527
|
-
get: function () { return
|
|
527
|
+
get: function () { return chunk5HVDOPZU_cjs.tables; }
|
|
528
528
|
});
|
|
529
529
|
Object.defineProperty(exports, "uniques", {
|
|
530
530
|
enumerable: true,
|
|
531
|
-
get: function () { return
|
|
531
|
+
get: function () { return chunk5HVDOPZU_cjs.uniques; }
|
|
532
532
|
});
|
|
533
533
|
exports.createPostgresBackend = createPostgresBackend;
|
|
534
534
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { quoteIdentifier } from '../../chunk-3EUKJEQ3.js';
|
|
2
|
-
import { createNodeRowMapper, POSTGRES_ROW_MAPPER_CONFIG, createEdgeRowMapper, createUniqueRowMapper, createSchemaVersionRowMapper, tables, createPostgresOperationStrategy, createCommonOperationBackend, nowIso, generatePostgresDDL, generateVectorIndexName, dropPostgresVectorIndex, createPostgresVectorIndex, compileQueryWithDialect, formatPostgresTimestamp, getOrCreateLru } from '../../chunk-
|
|
3
|
-
export { createPostgresTables, edges, embeddings, generatePostgresDDL, generatePostgresMigrationSQL, nodes, schemaVersions, tables, uniques } from '../../chunk-
|
|
4
|
-
import { runOptionallyInTransaction, POSTGRES_CAPABILITIES } from '../../chunk-
|
|
2
|
+
import { createNodeRowMapper, POSTGRES_ROW_MAPPER_CONFIG, createEdgeRowMapper, createUniqueRowMapper, createSchemaVersionRowMapper, tables, createPostgresOperationStrategy, createCommonOperationBackend, nowIso, generatePostgresDDL, generateVectorIndexName, dropPostgresVectorIndex, createPostgresVectorIndex, compileQueryWithDialect, formatPostgresTimestamp, getOrCreateLru } from '../../chunk-EY4LBX3F.js';
|
|
3
|
+
export { createPostgresTables, edges, embeddings, generatePostgresDDL, generatePostgresMigrationSQL, nodes, schemaVersions, tables, uniques } from '../../chunk-EY4LBX3F.js';
|
|
4
|
+
import { runOptionallyInTransaction, POSTGRES_CAPABILITIES } from '../../chunk-GUTQTMOV.js';
|
|
5
5
|
import '../../chunk-WFMTAEEN.js';
|
|
6
6
|
import '../../chunk-3PPEHLGK.js';
|
|
7
7
|
import { tsvectorStrategy, buildFulltextCapabilities } from '../../chunk-753F33CV.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
require('../../chunk-
|
|
3
|
+
var chunkOVJ2BE5Q_cjs = require('../../chunk-OVJ2BE5Q.cjs');
|
|
4
|
+
var chunk5HVDOPZU_cjs = require('../../chunk-5HVDOPZU.cjs');
|
|
5
|
+
require('../../chunk-SUHW2UYL.cjs');
|
|
6
6
|
require('../../chunk-O5PST6TB.cjs');
|
|
7
7
|
require('../../chunk-PEE4EWXZ.cjs');
|
|
8
8
|
require('../../chunk-3JK66E3I.cjs');
|
|
@@ -12,43 +12,43 @@ require('../../chunk-UVZHTBZ5.cjs');
|
|
|
12
12
|
|
|
13
13
|
Object.defineProperty(exports, "createSqliteBackend", {
|
|
14
14
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunkOVJ2BE5Q_cjs.createSqliteBackend; }
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "createSqliteTables", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunk5HVDOPZU_cjs.createSqliteTables; }
|
|
20
20
|
});
|
|
21
21
|
Object.defineProperty(exports, "edges", {
|
|
22
22
|
enumerable: true,
|
|
23
|
-
get: function () { return
|
|
23
|
+
get: function () { return chunk5HVDOPZU_cjs.edges2; }
|
|
24
24
|
});
|
|
25
25
|
Object.defineProperty(exports, "embeddings", {
|
|
26
26
|
enumerable: true,
|
|
27
|
-
get: function () { return
|
|
27
|
+
get: function () { return chunk5HVDOPZU_cjs.embeddings2; }
|
|
28
28
|
});
|
|
29
29
|
Object.defineProperty(exports, "generateSqliteDDL", {
|
|
30
30
|
enumerable: true,
|
|
31
|
-
get: function () { return
|
|
31
|
+
get: function () { return chunk5HVDOPZU_cjs.generateSqliteDDL; }
|
|
32
32
|
});
|
|
33
33
|
Object.defineProperty(exports, "generateSqliteMigrationSQL", {
|
|
34
34
|
enumerable: true,
|
|
35
|
-
get: function () { return
|
|
35
|
+
get: function () { return chunk5HVDOPZU_cjs.generateSqliteMigrationSQL; }
|
|
36
36
|
});
|
|
37
37
|
Object.defineProperty(exports, "nodes", {
|
|
38
38
|
enumerable: true,
|
|
39
|
-
get: function () { return
|
|
39
|
+
get: function () { return chunk5HVDOPZU_cjs.nodes2; }
|
|
40
40
|
});
|
|
41
41
|
Object.defineProperty(exports, "schemaVersions", {
|
|
42
42
|
enumerable: true,
|
|
43
|
-
get: function () { return
|
|
43
|
+
get: function () { return chunk5HVDOPZU_cjs.schemaVersions2; }
|
|
44
44
|
});
|
|
45
45
|
Object.defineProperty(exports, "tables", {
|
|
46
46
|
enumerable: true,
|
|
47
|
-
get: function () { return
|
|
47
|
+
get: function () { return chunk5HVDOPZU_cjs.tables2; }
|
|
48
48
|
});
|
|
49
49
|
Object.defineProperty(exports, "uniques", {
|
|
50
50
|
enumerable: true,
|
|
51
|
-
get: function () { return
|
|
51
|
+
get: function () { return chunk5HVDOPZU_cjs.uniques2; }
|
|
52
52
|
});
|
|
53
53
|
//# sourceMappingURL=index.cjs.map
|
|
54
54
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { createSqliteBackend } from '../../chunk-
|
|
2
|
-
export { createSqliteTables, edges2 as edges, embeddings2 as embeddings, generateSqliteDDL, generateSqliteMigrationSQL, nodes2 as nodes, schemaVersions2 as schemaVersions, tables2 as tables, uniques2 as uniques } from '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
1
|
+
export { createSqliteBackend } from '../../chunk-QOLTW7OZ.js';
|
|
2
|
+
export { createSqliteTables, edges2 as edges, embeddings2 as embeddings, generateSqliteDDL, generateSqliteMigrationSQL, nodes2 as nodes, schemaVersions2 as schemaVersions, tables2 as tables, uniques2 as uniques } from '../../chunk-EY4LBX3F.js';
|
|
3
|
+
import '../../chunk-GUTQTMOV.js';
|
|
4
4
|
import '../../chunk-WFMTAEEN.js';
|
|
5
5
|
import '../../chunk-3PPEHLGK.js';
|
|
6
6
|
import '../../chunk-753F33CV.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
require('../../chunk-
|
|
3
|
+
var chunkOVJ2BE5Q_cjs = require('../../chunk-OVJ2BE5Q.cjs');
|
|
4
|
+
var chunk5HVDOPZU_cjs = require('../../chunk-5HVDOPZU.cjs');
|
|
5
|
+
require('../../chunk-SUHW2UYL.cjs');
|
|
6
6
|
require('../../chunk-O5PST6TB.cjs');
|
|
7
7
|
require('../../chunk-PEE4EWXZ.cjs');
|
|
8
8
|
require('../../chunk-3JK66E3I.cjs');
|
|
@@ -10,11 +10,11 @@ require('../../chunk-UVZHTBZ5.cjs');
|
|
|
10
10
|
var libsql = require('drizzle-orm/libsql');
|
|
11
11
|
|
|
12
12
|
async function createLibsqlBackend(client, options = {}) {
|
|
13
|
-
const tables2 = options.tables ??
|
|
13
|
+
const tables2 = options.tables ?? chunk5HVDOPZU_cjs.tables2;
|
|
14
14
|
const db = libsql.drizzle(client);
|
|
15
|
-
const ddlStatements =
|
|
15
|
+
const ddlStatements = chunk5HVDOPZU_cjs.generateSqliteDDL(tables2);
|
|
16
16
|
await client.executeMultiple(ddlStatements.join(";\n"));
|
|
17
|
-
const backend =
|
|
17
|
+
const backend = chunkOVJ2BE5Q_cjs.createSqliteBackend(db, {
|
|
18
18
|
executionProfile: {
|
|
19
19
|
isSync: false,
|
|
20
20
|
transactionMode: "drizzle"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createSqliteBackend } from '../../chunk-
|
|
2
|
-
import { tables2, generateSqliteDDL } from '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
1
|
+
import { createSqliteBackend } from '../../chunk-QOLTW7OZ.js';
|
|
2
|
+
import { tables2, generateSqliteDDL } from '../../chunk-EY4LBX3F.js';
|
|
3
|
+
import '../../chunk-GUTQTMOV.js';
|
|
4
4
|
import '../../chunk-WFMTAEEN.js';
|
|
5
5
|
import '../../chunk-3PPEHLGK.js';
|
|
6
6
|
import '../../chunk-753F33CV.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkOVJ2BE5Q_cjs = require('../../chunk-OVJ2BE5Q.cjs');
|
|
4
|
+
var chunk5HVDOPZU_cjs = require('../../chunk-5HVDOPZU.cjs');
|
|
5
|
+
var chunkSUHW2UYL_cjs = require('../../chunk-SUHW2UYL.cjs');
|
|
6
6
|
var chunkO5PST6TB_cjs = require('../../chunk-O5PST6TB.cjs');
|
|
7
7
|
require('../../chunk-PEE4EWXZ.cjs');
|
|
8
8
|
require('../../chunk-3JK66E3I.cjs');
|
|
@@ -57,22 +57,22 @@ function createDatabase(path) {
|
|
|
57
57
|
}
|
|
58
58
|
function createLocalSqliteBackend(options = {}) {
|
|
59
59
|
const path = options.path ?? ":memory:";
|
|
60
|
-
const tables2 = options.tables ??
|
|
60
|
+
const tables2 = options.tables ?? chunk5HVDOPZU_cjs.tables2;
|
|
61
61
|
const sqlite = createDatabase(path);
|
|
62
62
|
const hasVectorEmbeddings = tryLoadSqliteVec(sqlite);
|
|
63
63
|
const db = betterSqlite3.drizzle(sqlite);
|
|
64
|
-
const ddlStatements =
|
|
64
|
+
const ddlStatements = chunk5HVDOPZU_cjs.generateSqliteDDL(tables2);
|
|
65
65
|
for (const statement of ddlStatements) {
|
|
66
66
|
sqlite.exec(statement);
|
|
67
67
|
}
|
|
68
|
-
const backend =
|
|
68
|
+
const backend = chunkOVJ2BE5Q_cjs.createSqliteBackend(db, {
|
|
69
69
|
executionProfile: {
|
|
70
70
|
isSync: true
|
|
71
71
|
},
|
|
72
72
|
tables: tables2,
|
|
73
73
|
hasVectorEmbeddings
|
|
74
74
|
});
|
|
75
|
-
const managedBackend =
|
|
75
|
+
const managedBackend = chunkSUHW2UYL_cjs.wrapWithManagedClose(backend, () => {
|
|
76
76
|
sqlite.close();
|
|
77
77
|
});
|
|
78
78
|
return { backend: managedBackend, db };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createSqliteBackend } from '../../chunk-
|
|
2
|
-
import { tables2, generateSqliteDDL } from '../../chunk-
|
|
3
|
-
import { wrapWithManagedClose } from '../../chunk-
|
|
1
|
+
import { createSqliteBackend } from '../../chunk-QOLTW7OZ.js';
|
|
2
|
+
import { tables2, generateSqliteDDL } from '../../chunk-EY4LBX3F.js';
|
|
3
|
+
import { wrapWithManagedClose } from '../../chunk-GUTQTMOV.js';
|
|
4
4
|
import { ConfigurationError } from '../../chunk-WFMTAEEN.js';
|
|
5
5
|
import '../../chunk-3PPEHLGK.js';
|
|
6
6
|
import '../../chunk-753F33CV.js';
|
|
@@ -1905,9 +1905,7 @@ function buildVectorSearchMinScoreCondition(distanceExpression, metric, minScore
|
|
|
1905
1905
|
}
|
|
1906
1906
|
}
|
|
1907
1907
|
}
|
|
1908
|
-
function
|
|
1909
|
-
const { embeddings: embeddings3 } = tables3;
|
|
1910
|
-
const queryLiteral = formatEmbeddingLiteral(params.queryEmbedding);
|
|
1908
|
+
function assertVectorSearchBounds(params) {
|
|
1911
1909
|
if (params.minScore !== void 0 && !Number.isFinite(params.minScore)) {
|
|
1912
1910
|
throw new TypeError(
|
|
1913
1911
|
`minScore must be a finite number, got: ${params.minScore}`
|
|
@@ -1916,6 +1914,11 @@ function buildVectorSearchPostgres(tables3, params) {
|
|
|
1916
1914
|
if (!Number.isInteger(params.limit) || params.limit <= 0) {
|
|
1917
1915
|
throw new Error(`limit must be a positive integer, got: ${params.limit}`);
|
|
1918
1916
|
}
|
|
1917
|
+
}
|
|
1918
|
+
function buildVectorSearchPostgres(tables3, params) {
|
|
1919
|
+
const { embeddings: embeddings3 } = tables3;
|
|
1920
|
+
const queryLiteral = formatEmbeddingLiteral(params.queryEmbedding);
|
|
1921
|
+
assertVectorSearchBounds(params);
|
|
1919
1922
|
const embeddingColumn = drizzleOrm.sql`${embeddings3.embedding}`;
|
|
1920
1923
|
const distanceExpression = buildDistanceExpression(
|
|
1921
1924
|
embeddingColumn,
|
|
@@ -1951,6 +1954,65 @@ function buildVectorSearchPostgres(tables3, params) {
|
|
|
1951
1954
|
LIMIT ${params.limit}
|
|
1952
1955
|
`;
|
|
1953
1956
|
}
|
|
1957
|
+
function buildSqliteDistanceExpression(embeddingColumn, embeddingJson, metric) {
|
|
1958
|
+
switch (metric) {
|
|
1959
|
+
case "cosine": {
|
|
1960
|
+
return drizzleOrm.sql`vec_distance_cosine(${embeddingColumn}, vec_f32(${embeddingJson}))`;
|
|
1961
|
+
}
|
|
1962
|
+
case "l2": {
|
|
1963
|
+
return drizzleOrm.sql`vec_distance_l2(${embeddingColumn}, vec_f32(${embeddingJson}))`;
|
|
1964
|
+
}
|
|
1965
|
+
case "inner_product": {
|
|
1966
|
+
throw new Error(
|
|
1967
|
+
"Inner product distance is not supported by sqlite-vec. Use 'cosine' or 'l2' metrics instead."
|
|
1968
|
+
);
|
|
1969
|
+
}
|
|
1970
|
+
default: {
|
|
1971
|
+
const _exhaustive = metric;
|
|
1972
|
+
throw new Error(`Unsupported vector metric: ${String(_exhaustive)}`);
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
function buildVectorSearchSqlite(tables3, params) {
|
|
1977
|
+
const { embeddings: embeddings3 } = tables3;
|
|
1978
|
+
assertFiniteNumberArray(params.queryEmbedding, "queryEmbedding");
|
|
1979
|
+
const embeddingJson = JSON.stringify(params.queryEmbedding);
|
|
1980
|
+
assertVectorSearchBounds(params);
|
|
1981
|
+
const embeddingColumn = drizzleOrm.sql`${embeddings3.embedding}`;
|
|
1982
|
+
const distanceExpression = buildSqliteDistanceExpression(
|
|
1983
|
+
embeddingColumn,
|
|
1984
|
+
embeddingJson,
|
|
1985
|
+
params.metric
|
|
1986
|
+
);
|
|
1987
|
+
const conditions = [
|
|
1988
|
+
drizzleOrm.sql`${embeddings3.graphId} = ${params.graphId}`,
|
|
1989
|
+
drizzleOrm.sql`${embeddings3.nodeKind} = ${params.nodeKind}`,
|
|
1990
|
+
drizzleOrm.sql`${embeddings3.fieldPath} = ${params.fieldPath}`
|
|
1991
|
+
];
|
|
1992
|
+
if (params.minScore !== void 0) {
|
|
1993
|
+
conditions.push(
|
|
1994
|
+
buildVectorSearchMinScoreCondition(
|
|
1995
|
+
distanceExpression,
|
|
1996
|
+
params.metric,
|
|
1997
|
+
params.minScore
|
|
1998
|
+
)
|
|
1999
|
+
);
|
|
2000
|
+
}
|
|
2001
|
+
const whereClause = drizzleOrm.sql.join(conditions, drizzleOrm.sql` AND `);
|
|
2002
|
+
const scoreExpression = buildVectorSearchScoreExpression(
|
|
2003
|
+
distanceExpression,
|
|
2004
|
+
params.metric
|
|
2005
|
+
);
|
|
2006
|
+
return drizzleOrm.sql`
|
|
2007
|
+
SELECT
|
|
2008
|
+
${embeddings3.nodeId} as node_id,
|
|
2009
|
+
${scoreExpression} as score
|
|
2010
|
+
FROM ${embeddings3}
|
|
2011
|
+
WHERE ${whereClause}
|
|
2012
|
+
ORDER BY ${distanceExpression} ASC
|
|
2013
|
+
LIMIT ${params.limit}
|
|
2014
|
+
`;
|
|
2015
|
+
}
|
|
1954
2016
|
|
|
1955
2017
|
// src/backend/drizzle/operations/strategy.ts
|
|
1956
2018
|
function bindTableOperationBuilders(tables3, builders) {
|
|
@@ -2047,6 +2109,9 @@ function createSqliteOperationStrategy(tables3, fulltextStrategy) {
|
|
|
2047
2109
|
},
|
|
2048
2110
|
buildDeleteEmbedding(params) {
|
|
2049
2111
|
return buildDeleteEmbedding(tables3, params);
|
|
2112
|
+
},
|
|
2113
|
+
buildVectorSearch(params) {
|
|
2114
|
+
return buildVectorSearchSqlite(tables3, params);
|
|
2050
2115
|
}
|
|
2051
2116
|
};
|
|
2052
2117
|
}
|
|
@@ -2311,5 +2376,5 @@ exports.tables = tables;
|
|
|
2311
2376
|
exports.tables2 = tables2;
|
|
2312
2377
|
exports.uniques = uniques;
|
|
2313
2378
|
exports.uniques2 = uniques2;
|
|
2314
|
-
//# sourceMappingURL=chunk-
|
|
2315
|
-
//# sourceMappingURL=chunk-
|
|
2379
|
+
//# sourceMappingURL=chunk-5HVDOPZU.cjs.map
|
|
2380
|
+
//# sourceMappingURL=chunk-5HVDOPZU.cjs.map
|