@nicia-ai/typegraph 0.26.0 → 0.28.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 +99 -57
- package/dist/backend/postgres/index.cjs.map +1 -1
- package/dist/backend/postgres/index.d.cts +4 -4
- package/dist/backend/postgres/index.d.ts +4 -4
- package/dist/backend/postgres/index.js +47 -5
- package/dist/backend/postgres/index.js.map +1 -1
- package/dist/backend/sqlite/index.cjs +13 -13
- package/dist/backend/sqlite/index.d.cts +5 -5
- package/dist/backend/sqlite/index.d.ts +5 -5
- package/dist/backend/sqlite/index.js +3 -3
- package/dist/backend/sqlite/libsql.cjs +6 -6
- package/dist/backend/sqlite/libsql.d.cts +2 -2
- package/dist/backend/sqlite/libsql.d.ts +2 -2
- package/dist/backend/sqlite/libsql.js +3 -3
- package/dist/backend/sqlite/local.cjs +7 -7
- package/dist/backend/sqlite/local.d.cts +2 -2
- package/dist/backend/sqlite/local.d.ts +2 -2
- package/dist/backend/sqlite/local.js +3 -3
- package/dist/{chunk-TVUARC7S.cjs → chunk-2E4VTD2E.cjs} +50 -22
- package/dist/chunk-2E4VTD2E.cjs.map +1 -0
- package/dist/{chunk-RVT2N4RF.cjs → chunk-33K3ZYFG.cjs} +46 -46
- package/dist/{chunk-RVT2N4RF.cjs.map → chunk-33K3ZYFG.cjs.map} +1 -1
- package/dist/{chunk-RF5EUQWS.js → chunk-DFHLG75V.js} +50 -22
- package/dist/chunk-DFHLG75V.js.map +1 -0
- package/dist/{chunk-DN4RUDF3.cjs → chunk-LYRUNG6E.cjs} +2 -2
- package/dist/chunk-LYRUNG6E.cjs.map +1 -0
- package/dist/{chunk-ENXJLDRK.js → chunk-PCHTTG42.js} +2 -2
- package/dist/chunk-PCHTTG42.js.map +1 -0
- package/dist/{chunk-DDVA4QBA.js → chunk-UKG7XHZ3.js} +4 -4
- package/dist/{chunk-DDVA4QBA.js.map → chunk-UKG7XHZ3.js.map} +1 -1
- package/dist/{chunk-3W6AIFT2.js → chunk-X53YKGHR.js} +74 -8
- package/dist/chunk-X53YKGHR.js.map +1 -0
- package/dist/{chunk-4TJI44WP.cjs → chunk-ZGEMI7MJ.cjs} +75 -7
- package/dist/chunk-ZGEMI7MJ.cjs.map +1 -0
- package/dist/{ddl-9kw8UADK.d.ts → ddl-0Ooc2dpL.d.ts} +2 -2
- package/dist/{ddl-Cw82BPM4.d.cts → ddl-Dza3kDrI.d.cts} +2 -2
- package/dist/index.cjs +100 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -7
- package/dist/index.d.ts +7 -7
- package/dist/index.js +40 -7
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.d.cts +4 -4
- package/dist/indexes/index.d.ts +4 -4
- package/dist/interchange/index.d.cts +3 -3
- package/dist/interchange/index.d.ts +3 -3
- package/dist/{manager-Aqzmztkb.d.cts → manager-c1MGaVVR.d.cts} +35 -11
- package/dist/{manager-C3LxzPcX.d.ts → manager-ehLTTNq0.d.ts} +35 -11
- package/dist/profiler/index.d.cts +5 -5
- package/dist/profiler/index.d.ts +5 -5
- package/dist/schema/index.cjs +28 -24
- package/dist/schema/index.d.cts +4 -4
- package/dist/schema/index.d.ts +4 -4
- package/dist/schema/index.js +2 -2
- package/dist/{sqlite-GKvcDPVn.d.ts → sqlite-BxZUPbyD.d.ts} +1 -1
- package/dist/{sqlite-BvSEbybu.d.cts → sqlite-mvpXjEeB.d.cts} +1 -1
- package/dist/{store-DbQLsSor.d.cts → store-D7YEMg2v.d.cts} +69 -3
- package/dist/{store-CiS_AGNH.d.ts → store-Ufc1Eoey.d.ts} +69 -3
- package/dist/{types-Cars4JZ1.d.ts → types-B-sJJ4GQ.d.ts} +1 -1
- package/dist/{types-DZPBXZOK.d.cts → types-CMQymcwk.d.cts} +11 -0
- package/dist/{types-Dzkr0Eqi.d.ts → types-CQ7xXJMP.d.ts} +11 -0
- package/dist/{types-CF7nDH3q.d.cts → types-CmUA9sal.d.cts} +1 -1
- package/dist/{where-BmtjfWuS.d.cts → where-5zf15aFZ.d.cts} +1 -1
- package/dist/{where-kk1Zz2En.d.ts → where-CtrLu1Zf.d.ts} +1 -1
- package/package.json +8 -8
- package/dist/chunk-3W6AIFT2.js.map +0 -1
- package/dist/chunk-4TJI44WP.cjs.map +0 -1
- package/dist/chunk-DN4RUDF3.cjs.map +0 -1
- package/dist/chunk-ENXJLDRK.js.map +0 -1
- package/dist/chunk-RF5EUQWS.js.map +0 -1
- package/dist/chunk-TVUARC7S.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 chunk2E4VTD2E_cjs = require('../../chunk-2E4VTD2E.cjs');
|
|
5
|
+
var chunkLYRUNG6E_cjs = require('../../chunk-LYRUNG6E.cjs');
|
|
6
6
|
require('../../chunk-IUIWCFG3.cjs');
|
|
7
7
|
var chunkPN37HVAV_cjs = require('../../chunk-PN37HVAV.cjs');
|
|
8
8
|
require('../../chunk-CTHNVU6K.cjs');
|
|
@@ -35,7 +35,7 @@ var DEFAULT_POSTGRES_STATEMENT_CACHE_MAX = 256;
|
|
|
35
35
|
var STATEMENT_NAME_CACHE = /* @__PURE__ */ new Map();
|
|
36
36
|
var nextStatementId = 0;
|
|
37
37
|
function statementNameFor(sqlText, cacheMax) {
|
|
38
|
-
return
|
|
38
|
+
return chunk2E4VTD2E_cjs.getOrCreateLru(STATEMENT_NAME_CACHE, sqlText, cacheMax, () => {
|
|
39
39
|
const name = `tg_${nextStatementId}`;
|
|
40
40
|
nextStatementId += 1;
|
|
41
41
|
return name;
|
|
@@ -126,7 +126,7 @@ function createPostgresExecutionAdapter(db, options = {}) {
|
|
|
126
126
|
const cacheMax = options.preparedStatementCacheMax ?? DEFAULT_POSTGRES_STATEMENT_CACHE_MAX;
|
|
127
127
|
const pgClient = resolvePgClient(db, prepareStatements, cacheMax);
|
|
128
128
|
function compile(query) {
|
|
129
|
-
return
|
|
129
|
+
return chunk2E4VTD2E_cjs.compileQueryWithDialect(db, query, "PostgreSQL");
|
|
130
130
|
}
|
|
131
131
|
if (pgClient === void 0) {
|
|
132
132
|
return {
|
|
@@ -182,10 +182,10 @@ var POSTGRES_CHECK_UNIQUE_BATCH_CHUNK_SIZE = Math.max(
|
|
|
182
182
|
1,
|
|
183
183
|
POSTGRES_MAX_BIND_PARAMETERS - CHECK_UNIQUE_BATCH_FIXED_PARAM_COUNT
|
|
184
184
|
);
|
|
185
|
-
var toNodeRow =
|
|
186
|
-
var toEdgeRow =
|
|
187
|
-
var toUniqueRow =
|
|
188
|
-
var toSchemaVersionRow =
|
|
185
|
+
var toNodeRow = chunk2E4VTD2E_cjs.createNodeRowMapper(chunk2E4VTD2E_cjs.POSTGRES_ROW_MAPPER_CONFIG);
|
|
186
|
+
var toEdgeRow = chunk2E4VTD2E_cjs.createEdgeRowMapper(chunk2E4VTD2E_cjs.POSTGRES_ROW_MAPPER_CONFIG);
|
|
187
|
+
var toUniqueRow = chunk2E4VTD2E_cjs.createUniqueRowMapper(chunk2E4VTD2E_cjs.POSTGRES_ROW_MAPPER_CONFIG);
|
|
188
|
+
var toSchemaVersionRow = chunk2E4VTD2E_cjs.createSchemaVersionRowMapper(chunk2E4VTD2E_cjs.POSTGRES_ROW_MAPPER_CONFIG);
|
|
189
189
|
function toEmbeddingRow(row) {
|
|
190
190
|
let embedding;
|
|
191
191
|
if (typeof row.embedding === "string") {
|
|
@@ -203,13 +203,13 @@ function toEmbeddingRow(row) {
|
|
|
203
203
|
field_path: row.field_path,
|
|
204
204
|
embedding,
|
|
205
205
|
dimensions: row.dimensions,
|
|
206
|
-
created_at:
|
|
207
|
-
updated_at:
|
|
206
|
+
created_at: chunk2E4VTD2E_cjs.formatPostgresTimestamp(row.created_at) ?? "",
|
|
207
|
+
updated_at: chunk2E4VTD2E_cjs.formatPostgresTimestamp(row.updated_at) ?? ""
|
|
208
208
|
};
|
|
209
209
|
}
|
|
210
210
|
function buildPostgresCapabilities(strategy) {
|
|
211
211
|
return {
|
|
212
|
-
...
|
|
212
|
+
...chunkLYRUNG6E_cjs.POSTGRES_CAPABILITIES,
|
|
213
213
|
vector: {
|
|
214
214
|
supported: true,
|
|
215
215
|
metrics: ["cosine", "l2", "inner_product"],
|
|
@@ -221,7 +221,7 @@ function buildPostgresCapabilities(strategy) {
|
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
223
|
function createPostgresBackend(db, options = {}) {
|
|
224
|
-
const tables2 = options.tables ??
|
|
224
|
+
const tables2 = options.tables ?? chunk2E4VTD2E_cjs.tables;
|
|
225
225
|
const fulltextStrategy = options.fulltext ?? chunkPN37HVAV_cjs.tsvectorStrategy;
|
|
226
226
|
const baseCapabilities = buildPostgresCapabilities(fulltextStrategy);
|
|
227
227
|
const httpOnlyOverrides = isNeonHttpClient(db) ? { transactions: false } : {};
|
|
@@ -252,13 +252,14 @@ function createPostgresBackend(db, options = {}) {
|
|
|
252
252
|
].map((name) => chunkHTGDWIDE_cjs.quoteIdentifier(name)),
|
|
253
253
|
drizzleOrm.sql`, `
|
|
254
254
|
)}`;
|
|
255
|
-
const operationStrategy =
|
|
255
|
+
const operationStrategy = chunk2E4VTD2E_cjs.createPostgresOperationStrategy(
|
|
256
256
|
tables2,
|
|
257
257
|
fulltextStrategy
|
|
258
258
|
);
|
|
259
259
|
const operations = createPostgresOperationBackend({
|
|
260
260
|
db,
|
|
261
261
|
executionAdapter,
|
|
262
|
+
adapterOptions,
|
|
262
263
|
operationStrategy,
|
|
263
264
|
tableNames,
|
|
264
265
|
capabilities,
|
|
@@ -292,7 +293,7 @@ function createPostgresBackend(db, options = {}) {
|
|
|
292
293
|
}
|
|
293
294
|
const matTable = tables2.contributionMaterializations;
|
|
294
295
|
async function ensureContributionMaterializationsTableImpl() {
|
|
295
|
-
await db.execute(drizzleOrm.sql.raw(
|
|
296
|
+
await db.execute(drizzleOrm.sql.raw(chunk2E4VTD2E_cjs.generatePgCreateTableSQL(matTable)));
|
|
296
297
|
}
|
|
297
298
|
async function getContributionMaterializationRow(identity) {
|
|
298
299
|
const rows = await db.select().from(matTable).where(
|
|
@@ -305,16 +306,16 @@ function createPostgresBackend(db, options = {}) {
|
|
|
305
306
|
);
|
|
306
307
|
const row = rows[0];
|
|
307
308
|
if (row === void 0) return void 0;
|
|
308
|
-
return
|
|
309
|
+
return chunk2E4VTD2E_cjs.mapContributionMaterializationRow(
|
|
309
310
|
row,
|
|
310
|
-
|
|
311
|
+
chunk2E4VTD2E_cjs.POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS.decode
|
|
311
312
|
);
|
|
312
313
|
}
|
|
313
314
|
async function recordContributionMaterializationRow(params) {
|
|
314
315
|
await db.insert(matTable).values(
|
|
315
|
-
|
|
316
|
+
chunk2E4VTD2E_cjs.buildContributionInsertValues(
|
|
316
317
|
params,
|
|
317
|
-
|
|
318
|
+
chunk2E4VTD2E_cjs.POSTGRES_CONTRIBUTION_MAT_TIMESTAMPS.encode
|
|
318
319
|
)
|
|
319
320
|
).onConflictDoUpdate({
|
|
320
321
|
target: [
|
|
@@ -323,13 +324,13 @@ function createPostgresBackend(db, options = {}) {
|
|
|
323
324
|
matTable.owner,
|
|
324
325
|
matTable.tableName
|
|
325
326
|
],
|
|
326
|
-
set:
|
|
327
|
+
set: chunk2E4VTD2E_cjs.buildContributionOnConflictSet(
|
|
327
328
|
matTable.materializedAt,
|
|
328
329
|
params.materializedAt
|
|
329
330
|
)
|
|
330
331
|
});
|
|
331
332
|
}
|
|
332
|
-
const contributionMaterializer =
|
|
333
|
+
const contributionMaterializer = chunk2E4VTD2E_cjs.createContributionMaterializer({
|
|
333
334
|
dialect: "postgres",
|
|
334
335
|
fulltextStrategy,
|
|
335
336
|
fulltextTableName: tables2.fulltextTableName,
|
|
@@ -349,12 +350,12 @@ function createPostgresBackend(db, options = {}) {
|
|
|
349
350
|
capabilities,
|
|
350
351
|
fulltextStrategy
|
|
351
352
|
});
|
|
352
|
-
return
|
|
353
|
+
return chunk2E4VTD2E_cjs.gateFulltext(txBackend, contributionMaterializer.assertInitialized);
|
|
353
354
|
}
|
|
354
355
|
const backend = {
|
|
355
356
|
...operations,
|
|
356
357
|
async bootstrapTables() {
|
|
357
|
-
const statements =
|
|
358
|
+
const statements = chunk2E4VTD2E_cjs.generatePostgresDDL(tables2, fulltextStrategy);
|
|
358
359
|
for (const statement of statements) {
|
|
359
360
|
await db.execute(drizzleOrm.sql.raw(statement));
|
|
360
361
|
}
|
|
@@ -364,7 +365,7 @@ function createPostgresBackend(db, options = {}) {
|
|
|
364
365
|
// uninitialized database throws `StoreNotInitializedError` loudly
|
|
365
366
|
// rather than self-healing on a read/write path (#135). Shared
|
|
366
367
|
// verbatim with the tx-scoped gate via `gateFulltextMethods`.
|
|
367
|
-
...
|
|
368
|
+
...chunk2E4VTD2E_cjs.gateFulltextMethods(
|
|
368
369
|
operations,
|
|
369
370
|
contributionMaterializer.assertInitialized
|
|
370
371
|
),
|
|
@@ -373,7 +374,7 @@ function createPostgresBackend(db, options = {}) {
|
|
|
373
374
|
},
|
|
374
375
|
async ensureIndexMaterializationsTable() {
|
|
375
376
|
await db.execute(
|
|
376
|
-
drizzleOrm.sql.raw(
|
|
377
|
+
drizzleOrm.sql.raw(chunk2E4VTD2E_cjs.generatePgCreateTableSQL(tables2.indexMaterializations))
|
|
377
378
|
);
|
|
378
379
|
},
|
|
379
380
|
async getIndexMaterialization(indexName) {
|
|
@@ -381,26 +382,26 @@ function createPostgresBackend(db, options = {}) {
|
|
|
381
382
|
const rows = await db.select().from(t).where(drizzleOrm.eq(t.indexName, indexName));
|
|
382
383
|
const row = rows[0];
|
|
383
384
|
if (row === void 0) return void 0;
|
|
384
|
-
return
|
|
385
|
+
return chunk2E4VTD2E_cjs.mapMaterializationRow(row, chunk2E4VTD2E_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.decode);
|
|
385
386
|
},
|
|
386
387
|
async getIndexMaterializations(statusKeys) {
|
|
387
388
|
if (statusKeys.length === 0) return [];
|
|
388
389
|
const t = tables2.indexMaterializations;
|
|
389
390
|
const rows = await db.select().from(t).where(drizzleOrm.inArray(t.indexName, [...statusKeys]));
|
|
390
391
|
return rows.map(
|
|
391
|
-
(row) =>
|
|
392
|
+
(row) => chunk2E4VTD2E_cjs.mapMaterializationRow(row, chunk2E4VTD2E_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.decode)
|
|
392
393
|
);
|
|
393
394
|
},
|
|
394
395
|
async recordIndexMaterialization(params) {
|
|
395
396
|
const t = tables2.indexMaterializations;
|
|
396
397
|
await db.insert(t).values(
|
|
397
|
-
|
|
398
|
+
chunk2E4VTD2E_cjs.buildMaterializationInsertValues(
|
|
398
399
|
params,
|
|
399
|
-
|
|
400
|
+
chunk2E4VTD2E_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.encode
|
|
400
401
|
)
|
|
401
402
|
).onConflictDoUpdate({
|
|
402
403
|
target: t.indexName,
|
|
403
|
-
set:
|
|
404
|
+
set: chunk2E4VTD2E_cjs.buildMaterializationOnConflictSet(
|
|
404
405
|
t.materializedAt,
|
|
405
406
|
params.materializedAt
|
|
406
407
|
)
|
|
@@ -420,38 +421,38 @@ function createPostgresBackend(db, options = {}) {
|
|
|
420
421
|
},
|
|
421
422
|
async ensureKindRemovalsTable() {
|
|
422
423
|
await db.execute(
|
|
423
|
-
drizzleOrm.sql.raw(
|
|
424
|
+
drizzleOrm.sql.raw(chunk2E4VTD2E_cjs.generatePgCreateTableSQL(tables2.kindRemovals))
|
|
424
425
|
);
|
|
425
426
|
},
|
|
426
427
|
async getPendingKindRemovals(graphId) {
|
|
427
428
|
const t = tables2.kindRemovals;
|
|
428
429
|
const rows = await db.select().from(t).where(drizzleOrm.and(drizzleOrm.eq(t.graphId, graphId), drizzleOrm.isNull(t.removedAt)));
|
|
429
430
|
return rows.map(
|
|
430
|
-
(row) =>
|
|
431
|
+
(row) => chunk2E4VTD2E_cjs.mapKindRemovalRow(row, chunk2E4VTD2E_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.decode)
|
|
431
432
|
);
|
|
432
433
|
},
|
|
433
434
|
async getAllKindRemovals(graphId) {
|
|
434
435
|
const t = tables2.kindRemovals;
|
|
435
436
|
const rows = await db.select().from(t).where(drizzleOrm.eq(t.graphId, graphId));
|
|
436
437
|
return rows.map(
|
|
437
|
-
(row) =>
|
|
438
|
+
(row) => chunk2E4VTD2E_cjs.mapKindRemovalRow(row, chunk2E4VTD2E_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.decode)
|
|
438
439
|
);
|
|
439
440
|
},
|
|
440
441
|
async recordKindRemoval(params) {
|
|
441
442
|
const t = tables2.kindRemovals;
|
|
442
443
|
await db.insert(t).values(
|
|
443
|
-
|
|
444
|
+
chunk2E4VTD2E_cjs.buildKindRemovalInsertValues(
|
|
444
445
|
params,
|
|
445
|
-
|
|
446
|
+
chunk2E4VTD2E_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.encode
|
|
446
447
|
)
|
|
447
448
|
).onConflictDoUpdate({
|
|
448
449
|
target: [t.graphId, t.kindName, t.entity, t.schemaVersion],
|
|
449
|
-
set:
|
|
450
|
+
set: chunk2E4VTD2E_cjs.buildKindRemovalOnConflictSet(t.removedAt, params.removedAt)
|
|
450
451
|
});
|
|
451
452
|
},
|
|
452
453
|
async ensureReconciliationMarkersTable() {
|
|
453
454
|
await db.execute(
|
|
454
|
-
drizzleOrm.sql.raw(
|
|
455
|
+
drizzleOrm.sql.raw(chunk2E4VTD2E_cjs.generatePgCreateTableSQL(tables2.reconciliationMarkers))
|
|
455
456
|
);
|
|
456
457
|
},
|
|
457
458
|
async ensureRuntimeContributions(graphId) {
|
|
@@ -512,7 +513,7 @@ function createPostgresBackend(db, options = {}) {
|
|
|
512
513
|
}
|
|
513
514
|
);
|
|
514
515
|
}
|
|
515
|
-
|
|
516
|
+
chunk2E4VTD2E_cjs.assertAdoptedDialect(externalTx, pgCore.PgDatabase, "postgres");
|
|
516
517
|
return bindTransactionBackend(externalTx);
|
|
517
518
|
},
|
|
518
519
|
async close() {
|
|
@@ -524,6 +525,7 @@ function createPostgresOperationBackend(options) {
|
|
|
524
525
|
const {
|
|
525
526
|
db,
|
|
526
527
|
executionAdapter,
|
|
528
|
+
adapterOptions,
|
|
527
529
|
operationStrategy,
|
|
528
530
|
tableNames,
|
|
529
531
|
capabilities,
|
|
@@ -539,7 +541,46 @@ function createPostgresOperationBackend(options) {
|
|
|
539
541
|
async function execRun(query) {
|
|
540
542
|
await executionAdapter.execute(query);
|
|
541
543
|
}
|
|
542
|
-
|
|
544
|
+
let efSearchUnsupportedWarned = false;
|
|
545
|
+
function warnEfSearchUnsupported() {
|
|
546
|
+
if (efSearchUnsupportedWarned) return;
|
|
547
|
+
efSearchUnsupportedWarned = true;
|
|
548
|
+
if (typeof console === "undefined" || typeof console.warn !== "function") {
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
console.warn(
|
|
552
|
+
"[typegraph] efSearch (hnsw.ef_search override) was ignored: this Postgres backend has transactions disabled (e.g. drizzle-orm/neon-http), and SET LOCAL needs a transaction to scope the override. Use a transactional driver (node-postgres / neon-serverless / postgres-js) to apply efSearch."
|
|
553
|
+
);
|
|
554
|
+
}
|
|
555
|
+
async function runVectorSearch(efSearch, query) {
|
|
556
|
+
if (efSearch === void 0) {
|
|
557
|
+
return execAll(query);
|
|
558
|
+
}
|
|
559
|
+
if (!capabilities.transactions) {
|
|
560
|
+
warnEfSearchUnsupported();
|
|
561
|
+
return execAll(query);
|
|
562
|
+
}
|
|
563
|
+
const setEfSearch = drizzleOrm.sql.raw(`SET LOCAL hnsw.ef_search = ${efSearch}`);
|
|
564
|
+
if (db instanceof pgCore.PgTransaction) {
|
|
565
|
+
const [setting] = await execAll(
|
|
566
|
+
drizzleOrm.sql`SELECT current_setting('hnsw.ef_search') AS ef_search`
|
|
567
|
+
);
|
|
568
|
+
await execRun(setEfSearch);
|
|
569
|
+
const rows = await execAll(query);
|
|
570
|
+
if (setting !== void 0) {
|
|
571
|
+
await execRun(
|
|
572
|
+
drizzleOrm.sql`SELECT set_config('hnsw.ef_search', ${setting.ef_search}, true)`
|
|
573
|
+
);
|
|
574
|
+
}
|
|
575
|
+
return rows;
|
|
576
|
+
}
|
|
577
|
+
return db.transaction(async (tx) => {
|
|
578
|
+
const txAdapter = createPostgresExecutionAdapter(tx, adapterOptions);
|
|
579
|
+
await txAdapter.execute(setEfSearch);
|
|
580
|
+
return txAdapter.execute(query);
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
const commonBackend = chunk2E4VTD2E_cjs.createCommonOperationBackend({
|
|
543
584
|
batchConfig: {
|
|
544
585
|
checkUniqueBatchChunkSize: POSTGRES_CHECK_UNIQUE_BATCH_CHUNK_SIZE,
|
|
545
586
|
edgeInsertBatchSize: POSTGRES_EDGE_INSERT_BATCH_SIZE,
|
|
@@ -552,7 +593,7 @@ function createPostgresOperationBackend(options) {
|
|
|
552
593
|
execGet,
|
|
553
594
|
execRun
|
|
554
595
|
},
|
|
555
|
-
nowIso:
|
|
596
|
+
nowIso: chunk2E4VTD2E_cjs.nowIso,
|
|
556
597
|
operationStrategy,
|
|
557
598
|
rowMappers: {
|
|
558
599
|
toEdgeRow,
|
|
@@ -576,7 +617,7 @@ function createPostgresOperationBackend(options) {
|
|
|
576
617
|
tableNames,
|
|
577
618
|
// === Embedding Operations ===
|
|
578
619
|
async upsertEmbedding(params) {
|
|
579
|
-
const timestamp =
|
|
620
|
+
const timestamp = chunk2E4VTD2E_cjs.nowIso();
|
|
580
621
|
const query = operationStrategy.buildUpsertEmbedding(params, timestamp);
|
|
581
622
|
await execRun(query);
|
|
582
623
|
},
|
|
@@ -596,7 +637,7 @@ function createPostgresOperationBackend(options) {
|
|
|
596
637
|
},
|
|
597
638
|
async vectorSearch(params) {
|
|
598
639
|
const query = operationStrategy.buildVectorSearch(params);
|
|
599
|
-
const rows = await
|
|
640
|
+
const rows = await runVectorSearch(params.efSearch, query);
|
|
600
641
|
return rows.map((row) => ({
|
|
601
642
|
nodeId: row.node_id,
|
|
602
643
|
score: row.score
|
|
@@ -616,7 +657,7 @@ function createPostgresOperationBackend(options) {
|
|
|
616
657
|
...params.indexParams?.lists === void 0 ? {} : { ivfflatLists: params.indexParams.lists },
|
|
617
658
|
...params.concurrent === true ? { concurrent: true } : {}
|
|
618
659
|
};
|
|
619
|
-
const result = await
|
|
660
|
+
const result = await chunk2E4VTD2E_cjs.createPostgresVectorIndex(db, indexOptions);
|
|
620
661
|
if (!result.success) {
|
|
621
662
|
throw new Error(
|
|
622
663
|
result.message ?? "Failed to create PostgreSQL vector index"
|
|
@@ -625,7 +666,7 @@ function createPostgresOperationBackend(options) {
|
|
|
625
666
|
},
|
|
626
667
|
// === Fulltext Operations ===
|
|
627
668
|
async upsertFulltext(params) {
|
|
628
|
-
const timestamp =
|
|
669
|
+
const timestamp = chunk2E4VTD2E_cjs.nowIso();
|
|
629
670
|
const statements = operationStrategy.buildUpsertFulltext(
|
|
630
671
|
params,
|
|
631
672
|
timestamp
|
|
@@ -642,7 +683,7 @@ function createPostgresOperationBackend(options) {
|
|
|
642
683
|
},
|
|
643
684
|
async upsertFulltextBatch(params) {
|
|
644
685
|
if (params.rows.length === 0) return;
|
|
645
|
-
const timestamp =
|
|
686
|
+
const timestamp = chunk2E4VTD2E_cjs.nowIso();
|
|
646
687
|
const statements = operationStrategy.buildUpsertFulltextBatch(
|
|
647
688
|
params,
|
|
648
689
|
timestamp
|
|
@@ -663,7 +704,7 @@ function createPostgresOperationBackend(options) {
|
|
|
663
704
|
const rows = await execAll(query);
|
|
664
705
|
return rows.map((row, index) => ({
|
|
665
706
|
nodeId: row.node_id,
|
|
666
|
-
score:
|
|
707
|
+
score: chunk2E4VTD2E_cjs.coerceNumericScore(row.score),
|
|
667
708
|
rank: index + 1,
|
|
668
709
|
...row.snippet === null ? {} : { snippet: row.snippet }
|
|
669
710
|
}));
|
|
@@ -672,13 +713,13 @@ function createPostgresOperationBackend(options) {
|
|
|
672
713
|
const metrics = capabilities.vector?.metrics ?? ["cosine"];
|
|
673
714
|
await Promise.all(
|
|
674
715
|
metrics.map(async (metric) => {
|
|
675
|
-
const indexName =
|
|
716
|
+
const indexName = chunk2E4VTD2E_cjs.generateVectorIndexName(
|
|
676
717
|
params.graphId,
|
|
677
718
|
params.nodeKind,
|
|
678
719
|
params.fieldPath,
|
|
679
720
|
metric
|
|
680
721
|
);
|
|
681
|
-
const result = await
|
|
722
|
+
const result = await chunk2E4VTD2E_cjs.dropPostgresVectorIndex(db, indexName);
|
|
682
723
|
if (!result.success) {
|
|
683
724
|
throw new Error(
|
|
684
725
|
result.message ?? "Failed to drop PostgreSQL vector index"
|
|
@@ -702,6 +743,7 @@ function createTransactionBackend(options) {
|
|
|
702
743
|
return createPostgresOperationBackend({
|
|
703
744
|
db: options.db,
|
|
704
745
|
executionAdapter: txExecutionAdapter,
|
|
746
|
+
adapterOptions: options.adapterOptions,
|
|
705
747
|
operationStrategy: options.operationStrategy,
|
|
706
748
|
tableNames: options.tableNames,
|
|
707
749
|
capabilities: options.capabilities,
|
|
@@ -711,43 +753,43 @@ function createTransactionBackend(options) {
|
|
|
711
753
|
|
|
712
754
|
Object.defineProperty(exports, "createPostgresTables", {
|
|
713
755
|
enumerable: true,
|
|
714
|
-
get: function () { return
|
|
756
|
+
get: function () { return chunk2E4VTD2E_cjs.createPostgresTables; }
|
|
715
757
|
});
|
|
716
758
|
Object.defineProperty(exports, "edges", {
|
|
717
759
|
enumerable: true,
|
|
718
|
-
get: function () { return
|
|
760
|
+
get: function () { return chunk2E4VTD2E_cjs.edges; }
|
|
719
761
|
});
|
|
720
762
|
Object.defineProperty(exports, "embeddings", {
|
|
721
763
|
enumerable: true,
|
|
722
|
-
get: function () { return
|
|
764
|
+
get: function () { return chunk2E4VTD2E_cjs.embeddings; }
|
|
723
765
|
});
|
|
724
766
|
Object.defineProperty(exports, "fulltext", {
|
|
725
767
|
enumerable: true,
|
|
726
|
-
get: function () { return
|
|
768
|
+
get: function () { return chunk2E4VTD2E_cjs.fulltext; }
|
|
727
769
|
});
|
|
728
770
|
Object.defineProperty(exports, "generatePostgresDDL", {
|
|
729
771
|
enumerable: true,
|
|
730
|
-
get: function () { return
|
|
772
|
+
get: function () { return chunk2E4VTD2E_cjs.generatePostgresDDL; }
|
|
731
773
|
});
|
|
732
774
|
Object.defineProperty(exports, "generatePostgresMigrationSQL", {
|
|
733
775
|
enumerable: true,
|
|
734
|
-
get: function () { return
|
|
776
|
+
get: function () { return chunk2E4VTD2E_cjs.generatePostgresMigrationSQL; }
|
|
735
777
|
});
|
|
736
778
|
Object.defineProperty(exports, "nodes", {
|
|
737
779
|
enumerable: true,
|
|
738
|
-
get: function () { return
|
|
780
|
+
get: function () { return chunk2E4VTD2E_cjs.nodes; }
|
|
739
781
|
});
|
|
740
782
|
Object.defineProperty(exports, "schemaVersions", {
|
|
741
783
|
enumerable: true,
|
|
742
|
-
get: function () { return
|
|
784
|
+
get: function () { return chunk2E4VTD2E_cjs.schemaVersions; }
|
|
743
785
|
});
|
|
744
786
|
Object.defineProperty(exports, "tables", {
|
|
745
787
|
enumerable: true,
|
|
746
|
-
get: function () { return
|
|
788
|
+
get: function () { return chunk2E4VTD2E_cjs.tables; }
|
|
747
789
|
});
|
|
748
790
|
Object.defineProperty(exports, "uniques", {
|
|
749
791
|
enumerable: true,
|
|
750
|
-
get: function () { return
|
|
792
|
+
get: function () { return chunk2E4VTD2E_cjs.uniques; }
|
|
751
793
|
});
|
|
752
794
|
exports.createPostgresBackend = createPostgresBackend;
|
|
753
795
|
//# sourceMappingURL=index.cjs.map
|