@nicia-ai/typegraph 0.23.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backend/postgres/index.cjs +29 -29
- package/dist/backend/postgres/index.js +2 -2
- package/dist/backend/sqlite/index.cjs +12 -12
- package/dist/backend/sqlite/index.js +2 -2
- package/dist/backend/sqlite/libsql.cjs +5 -5
- package/dist/backend/sqlite/libsql.js +2 -2
- package/dist/backend/sqlite/local.cjs +5 -5
- package/dist/backend/sqlite/local.js +2 -2
- package/dist/{chunk-O5BRZEIZ.cjs → chunk-3MDBMCFF.cjs} +53 -25
- package/dist/chunk-3MDBMCFF.cjs.map +1 -0
- 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-EP2KSSD5.js → chunk-GTG5J4UP.js} +38 -10
- package/dist/chunk-GTG5J4UP.js.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-7OD2EPN4.cjs.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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkHTGDWIDE_cjs = require('../../chunk-HTGDWIDE.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunk5HVDOPZU_cjs = require('../../chunk-5HVDOPZU.cjs');
|
|
5
5
|
var chunkRNUNP5JD_cjs = require('../../chunk-RNUNP5JD.cjs');
|
|
6
6
|
require('../../chunk-O5PST6TB.cjs');
|
|
7
7
|
require('../../chunk-PEE4EWXZ.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) {
|
|
@@ -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
|
}
|
|
@@ -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,6 +1,6 @@
|
|
|
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-
|
|
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
4
|
import { runOptionallyInTransaction, POSTGRES_CAPABILITIES } from '../../chunk-7TU5EWQ7.js';
|
|
5
5
|
import '../../chunk-WFMTAEEN.js';
|
|
6
6
|
import '../../chunk-3PPEHLGK.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk3MDBMCFF_cjs = require('../../chunk-3MDBMCFF.cjs');
|
|
4
|
+
var chunk5HVDOPZU_cjs = require('../../chunk-5HVDOPZU.cjs');
|
|
5
5
|
require('../../chunk-RNUNP5JD.cjs');
|
|
6
6
|
require('../../chunk-O5PST6TB.cjs');
|
|
7
7
|
require('../../chunk-PEE4EWXZ.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 chunk3MDBMCFF_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,5 +1,5 @@
|
|
|
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-
|
|
1
|
+
export { createSqliteBackend } from '../../chunk-GTG5J4UP.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
3
|
import '../../chunk-7TU5EWQ7.js';
|
|
4
4
|
import '../../chunk-WFMTAEEN.js';
|
|
5
5
|
import '../../chunk-3PPEHLGK.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk3MDBMCFF_cjs = require('../../chunk-3MDBMCFF.cjs');
|
|
4
|
+
var chunk5HVDOPZU_cjs = require('../../chunk-5HVDOPZU.cjs');
|
|
5
5
|
require('../../chunk-RNUNP5JD.cjs');
|
|
6
6
|
require('../../chunk-O5PST6TB.cjs');
|
|
7
7
|
require('../../chunk-PEE4EWXZ.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 = chunk3MDBMCFF_cjs.createSqliteBackend(db, {
|
|
18
18
|
executionProfile: {
|
|
19
19
|
isSync: false,
|
|
20
20
|
transactionMode: "drizzle"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createSqliteBackend } from '../../chunk-
|
|
2
|
-
import { tables2, generateSqliteDDL } from '../../chunk-
|
|
1
|
+
import { createSqliteBackend } from '../../chunk-GTG5J4UP.js';
|
|
2
|
+
import { tables2, generateSqliteDDL } from '../../chunk-EY4LBX3F.js';
|
|
3
3
|
import '../../chunk-7TU5EWQ7.js';
|
|
4
4
|
import '../../chunk-WFMTAEEN.js';
|
|
5
5
|
import '../../chunk-3PPEHLGK.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunk3MDBMCFF_cjs = require('../../chunk-3MDBMCFF.cjs');
|
|
4
|
+
var chunk5HVDOPZU_cjs = require('../../chunk-5HVDOPZU.cjs');
|
|
5
5
|
var chunkRNUNP5JD_cjs = require('../../chunk-RNUNP5JD.cjs');
|
|
6
6
|
var chunkO5PST6TB_cjs = require('../../chunk-O5PST6TB.cjs');
|
|
7
7
|
require('../../chunk-PEE4EWXZ.cjs');
|
|
@@ -57,15 +57,15 @@ 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 = chunk3MDBMCFF_cjs.createSqliteBackend(db, {
|
|
69
69
|
executionProfile: {
|
|
70
70
|
isSync: true
|
|
71
71
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createSqliteBackend } from '../../chunk-
|
|
2
|
-
import { tables2, generateSqliteDDL } from '../../chunk-
|
|
1
|
+
import { createSqliteBackend } from '../../chunk-GTG5J4UP.js';
|
|
2
|
+
import { tables2, generateSqliteDDL } from '../../chunk-EY4LBX3F.js';
|
|
3
3
|
import { wrapWithManagedClose } from '../../chunk-7TU5EWQ7.js';
|
|
4
4
|
import { ConfigurationError } from '../../chunk-WFMTAEEN.js';
|
|
5
5
|
import '../../chunk-3PPEHLGK.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk5HVDOPZU_cjs = require('./chunk-5HVDOPZU.cjs');
|
|
4
4
|
var chunkRNUNP5JD_cjs = require('./chunk-RNUNP5JD.cjs');
|
|
5
5
|
var chunkO5PST6TB_cjs = require('./chunk-O5PST6TB.cjs');
|
|
6
6
|
var chunk3JK66E3I_cjs = require('./chunk-3JK66E3I.cjs');
|
|
@@ -63,7 +63,7 @@ function resolveSqliteClient(db) {
|
|
|
63
63
|
return sqliteClient;
|
|
64
64
|
}
|
|
65
65
|
function getOrCreatePreparedStatement(cache, sqliteClient, sqlText, cacheMax) {
|
|
66
|
-
return
|
|
66
|
+
return chunk5HVDOPZU_cjs.getOrCreateLru(
|
|
67
67
|
cache,
|
|
68
68
|
sqlText,
|
|
69
69
|
cacheMax,
|
|
@@ -99,7 +99,7 @@ function createSqliteExecutionAdapter(db, statementCacheMaxOrOptions = {}) {
|
|
|
99
99
|
supportsCompiledExecution: sqliteClient !== void 0,
|
|
100
100
|
transactionMode
|
|
101
101
|
};
|
|
102
|
-
const compile = (query) =>
|
|
102
|
+
const compile = (query) => chunk5HVDOPZU_cjs.compileQueryWithDialect(db, query, "SQLite");
|
|
103
103
|
if (sqliteClient !== void 0) {
|
|
104
104
|
let executeCompiled2 = function(compiledQuery) {
|
|
105
105
|
const preparedStatement = getOrCreatePreparedStatement(
|
|
@@ -170,10 +170,10 @@ var SQLITE_CHECK_UNIQUE_BATCH_CHUNK_SIZE = Math.max(
|
|
|
170
170
|
1,
|
|
171
171
|
SQLITE_MAX_BIND_PARAMETERS - CHECK_UNIQUE_BATCH_FIXED_PARAM_COUNT
|
|
172
172
|
);
|
|
173
|
-
var toNodeRow =
|
|
174
|
-
var toEdgeRow =
|
|
175
|
-
var toUniqueRow =
|
|
176
|
-
var toSchemaVersionRow =
|
|
173
|
+
var toNodeRow = chunk5HVDOPZU_cjs.createNodeRowMapper(chunk5HVDOPZU_cjs.SQLITE_ROW_MAPPER_CONFIG);
|
|
174
|
+
var toEdgeRow = chunk5HVDOPZU_cjs.createEdgeRowMapper(chunk5HVDOPZU_cjs.SQLITE_ROW_MAPPER_CONFIG);
|
|
175
|
+
var toUniqueRow = chunk5HVDOPZU_cjs.createUniqueRowMapper(chunk5HVDOPZU_cjs.SQLITE_ROW_MAPPER_CONFIG);
|
|
176
|
+
var toSchemaVersionRow = chunk5HVDOPZU_cjs.createSchemaVersionRowMapper(chunk5HVDOPZU_cjs.SQLITE_ROW_MAPPER_CONFIG);
|
|
177
177
|
var PENDING_FOREVER = new Promise(noop);
|
|
178
178
|
function pendingForever() {
|
|
179
179
|
return PENDING_FOREVER;
|
|
@@ -214,6 +214,24 @@ function runWithSerializedQueue(queue, task) {
|
|
|
214
214
|
if (queue === void 0) return task();
|
|
215
215
|
return queue.runExclusive(task);
|
|
216
216
|
}
|
|
217
|
+
var SQLITE_VECTOR_METRICS = ["cosine", "l2"];
|
|
218
|
+
var SQLITE_VECTOR_INDEX_TYPES = ["none"];
|
|
219
|
+
var SQLITE_VECTOR_MAX_DIMENSIONS = 8e3;
|
|
220
|
+
function buildSqliteCapabilities(options) {
|
|
221
|
+
const base = options.transactionMode === "none" ? { ...chunkRNUNP5JD_cjs.SQLITE_CAPABILITIES, transactions: false } : chunkRNUNP5JD_cjs.SQLITE_CAPABILITIES;
|
|
222
|
+
return {
|
|
223
|
+
...base,
|
|
224
|
+
fulltext: chunk3JK66E3I_cjs.buildFulltextCapabilities(options.fulltextStrategy),
|
|
225
|
+
...options.hasVectorEmbeddings ? {
|
|
226
|
+
vector: {
|
|
227
|
+
supported: true,
|
|
228
|
+
metrics: SQLITE_VECTOR_METRICS,
|
|
229
|
+
indexTypes: SQLITE_VECTOR_INDEX_TYPES,
|
|
230
|
+
maxDimensions: SQLITE_VECTOR_MAX_DIMENSIONS
|
|
231
|
+
}
|
|
232
|
+
} : {}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
217
235
|
function createSqliteOperationBackend(options) {
|
|
218
236
|
const {
|
|
219
237
|
capabilities,
|
|
@@ -240,7 +258,7 @@ function createSqliteOperationBackend(options) {
|
|
|
240
258
|
await db.run(query);
|
|
241
259
|
});
|
|
242
260
|
}
|
|
243
|
-
const commonBackend =
|
|
261
|
+
const commonBackend = chunk5HVDOPZU_cjs.createCommonOperationBackend({
|
|
244
262
|
batchConfig: {
|
|
245
263
|
checkUniqueBatchChunkSize: SQLITE_CHECK_UNIQUE_BATCH_CHUNK_SIZE,
|
|
246
264
|
edgeInsertBatchSize: SQLITE_EDGE_INSERT_BATCH_SIZE,
|
|
@@ -253,7 +271,7 @@ function createSqliteOperationBackend(options) {
|
|
|
253
271
|
execGet,
|
|
254
272
|
execRun
|
|
255
273
|
},
|
|
256
|
-
nowIso:
|
|
274
|
+
nowIso: chunk5HVDOPZU_cjs.nowIso,
|
|
257
275
|
operationStrategy,
|
|
258
276
|
rowMappers: {
|
|
259
277
|
toEdgeRow,
|
|
@@ -275,13 +293,23 @@ function createSqliteOperationBackend(options) {
|
|
|
275
293
|
async upsertEmbedding(params) {
|
|
276
294
|
const query = operationStrategy.buildUpsertEmbedding(
|
|
277
295
|
params,
|
|
278
|
-
|
|
296
|
+
chunk5HVDOPZU_cjs.nowIso()
|
|
279
297
|
);
|
|
280
298
|
await execRun(query);
|
|
281
299
|
},
|
|
282
300
|
async deleteEmbedding(params) {
|
|
283
301
|
const query = operationStrategy.buildDeleteEmbedding(params);
|
|
284
302
|
await execRun(query);
|
|
303
|
+
},
|
|
304
|
+
async vectorSearch(params) {
|
|
305
|
+
const query = operationStrategy.buildVectorSearch(params);
|
|
306
|
+
const rows = await execAll(
|
|
307
|
+
query
|
|
308
|
+
);
|
|
309
|
+
return rows.map((row) => ({
|
|
310
|
+
nodeId: row.node_id,
|
|
311
|
+
score: row.score
|
|
312
|
+
}));
|
|
285
313
|
}
|
|
286
314
|
} : {};
|
|
287
315
|
const operationBackend = {
|
|
@@ -304,14 +332,14 @@ function createSqliteOperationBackend(options) {
|
|
|
304
332
|
...params.indexParams?.efConstruction === void 0 ? {} : { hnswEfConstruction: params.indexParams.efConstruction },
|
|
305
333
|
...params.indexParams?.lists === void 0 ? {} : { ivfflatLists: params.indexParams.lists }
|
|
306
334
|
};
|
|
307
|
-
const result =
|
|
335
|
+
const result = chunk5HVDOPZU_cjs.createSqliteVectorIndex(indexOptions);
|
|
308
336
|
if (!result.success) {
|
|
309
337
|
throw new Error(result.message ?? "Failed to create SQLite vector index");
|
|
310
338
|
}
|
|
311
339
|
return Promise.resolve();
|
|
312
340
|
},
|
|
313
341
|
dropVectorIndex(params) {
|
|
314
|
-
const result =
|
|
342
|
+
const result = chunk5HVDOPZU_cjs.dropSqliteVectorIndex(
|
|
315
343
|
params.graphId,
|
|
316
344
|
params.nodeKind,
|
|
317
345
|
params.fieldPath
|
|
@@ -323,7 +351,7 @@ function createSqliteOperationBackend(options) {
|
|
|
323
351
|
},
|
|
324
352
|
// === Fulltext Operations ===
|
|
325
353
|
async upsertFulltext(params) {
|
|
326
|
-
const timestamp =
|
|
354
|
+
const timestamp = chunk5HVDOPZU_cjs.nowIso();
|
|
327
355
|
const statements = operationStrategy.buildUpsertFulltext(
|
|
328
356
|
params,
|
|
329
357
|
timestamp
|
|
@@ -340,7 +368,7 @@ function createSqliteOperationBackend(options) {
|
|
|
340
368
|
},
|
|
341
369
|
async upsertFulltextBatch(params) {
|
|
342
370
|
if (params.rows.length === 0) return;
|
|
343
|
-
const timestamp =
|
|
371
|
+
const timestamp = chunk5HVDOPZU_cjs.nowIso();
|
|
344
372
|
const statements = operationStrategy.buildUpsertFulltextBatch(
|
|
345
373
|
params,
|
|
346
374
|
timestamp
|
|
@@ -380,28 +408,28 @@ function createSqliteOperationBackend(options) {
|
|
|
380
408
|
return operationBackend;
|
|
381
409
|
}
|
|
382
410
|
function createSqliteBackend(db, options = {}) {
|
|
383
|
-
const tables2 = options.tables ??
|
|
411
|
+
const tables2 = options.tables ?? chunk5HVDOPZU_cjs.tables2;
|
|
384
412
|
const fulltextStrategy = options.fulltext ?? chunk3JK66E3I_cjs.fts5Strategy;
|
|
385
413
|
const profileHints = options.executionProfile ?? {};
|
|
386
414
|
const executionAdapter = createSqliteExecutionAdapter(db, { profileHints });
|
|
387
415
|
const { isSync, transactionMode } = executionAdapter.profile;
|
|
388
|
-
const
|
|
389
|
-
const capabilities = {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
416
|
+
const hasVectorEmbeddings = options.hasVectorEmbeddings === true;
|
|
417
|
+
const capabilities = buildSqliteCapabilities({
|
|
418
|
+
fulltextStrategy,
|
|
419
|
+
hasVectorEmbeddings,
|
|
420
|
+
transactionMode
|
|
421
|
+
});
|
|
393
422
|
const tableNames = {
|
|
394
423
|
nodes: drizzleOrm.getTableName(tables2.nodes),
|
|
395
424
|
edges: drizzleOrm.getTableName(tables2.edges),
|
|
396
425
|
embeddings: drizzleOrm.getTableName(tables2.embeddings),
|
|
397
426
|
fulltext: tables2.fulltextTableName
|
|
398
427
|
};
|
|
399
|
-
const operationStrategy =
|
|
428
|
+
const operationStrategy = chunk5HVDOPZU_cjs.createSqliteOperationStrategy(
|
|
400
429
|
tables2,
|
|
401
430
|
fulltextStrategy
|
|
402
431
|
);
|
|
403
432
|
const serializedQueue = isSync ? createSerializedExecutionQueue() : void 0;
|
|
404
|
-
const hasVectorEmbeddings = options.hasVectorEmbeddings === true;
|
|
405
433
|
const operations = createSqliteOperationBackend({
|
|
406
434
|
capabilities,
|
|
407
435
|
db,
|
|
@@ -415,7 +443,7 @@ function createSqliteBackend(db, options = {}) {
|
|
|
415
443
|
const backend = {
|
|
416
444
|
...operations,
|
|
417
445
|
async bootstrapTables() {
|
|
418
|
-
const statements =
|
|
446
|
+
const statements = chunk5HVDOPZU_cjs.generateSqliteDDL(tables2, fulltextStrategy);
|
|
419
447
|
for (const statement of statements) {
|
|
420
448
|
await db.run(drizzleOrm.sql.raw(statement));
|
|
421
449
|
}
|
|
@@ -503,5 +531,5 @@ function createTransactionBackend(options) {
|
|
|
503
531
|
}
|
|
504
532
|
|
|
505
533
|
exports.createSqliteBackend = createSqliteBackend;
|
|
506
|
-
//# sourceMappingURL=chunk-
|
|
507
|
-
//# sourceMappingURL=chunk-
|
|
534
|
+
//# sourceMappingURL=chunk-3MDBMCFF.cjs.map
|
|
535
|
+
//# sourceMappingURL=chunk-3MDBMCFF.cjs.map
|