@nicia-ai/typegraph 0.24.1 → 0.25.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 +226 -55
- package/dist/backend/postgres/index.cjs.map +1 -1
- package/dist/backend/postgres/index.d.cts +6 -7
- package/dist/backend/postgres/index.d.ts +6 -7
- package/dist/backend/postgres/index.js +195 -28
- package/dist/backend/postgres/index.js.map +1 -1
- package/dist/backend/sqlite/index.cjs +19 -17
- package/dist/backend/sqlite/index.d.cts +6 -7
- package/dist/backend/sqlite/index.d.ts +6 -7
- package/dist/backend/sqlite/index.js +9 -7
- package/dist/backend/sqlite/libsql.cjs +12 -10
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +4 -5
- package/dist/backend/sqlite/libsql.d.ts +4 -5
- package/dist/backend/sqlite/libsql.js +9 -7
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +14 -12
- package/dist/backend/sqlite/local.cjs.map +1 -1
- package/dist/backend/sqlite/local.d.cts +4 -5
- package/dist/backend/sqlite/local.d.ts +4 -5
- package/dist/backend/sqlite/local.js +9 -7
- package/dist/backend/sqlite/local.js.map +1 -1
- package/dist/chunk-4BOWVUGQ.js +2029 -0
- package/dist/chunk-4BOWVUGQ.js.map +1 -0
- package/dist/chunk-7V335GHG.cjs +112 -0
- package/dist/chunk-7V335GHG.cjs.map +1 -0
- package/dist/chunk-AAA2CR3P.js +2628 -0
- package/dist/chunk-AAA2CR3P.js.map +1 -0
- package/dist/{chunk-QOLTW7OZ.js → chunk-CLEUFN2K.js} +195 -13
- package/dist/chunk-CLEUFN2K.js.map +1 -0
- package/dist/{chunk-OVJ2BE5Q.cjs → chunk-CLGC7AQ2.cjs} +215 -33
- package/dist/chunk-CLGC7AQ2.cjs.map +1 -0
- package/dist/{chunk-GUTQTMOV.js → chunk-CPFR3O7L.js} +2 -2
- package/dist/chunk-CPFR3O7L.js.map +1 -0
- package/dist/{chunk-5HVDOPZU.cjs → chunk-CQVNGKU7.cjs} +452 -104
- package/dist/chunk-CQVNGKU7.cjs.map +1 -0
- package/dist/chunk-CTHNVU6K.cjs +551 -0
- package/dist/chunk-CTHNVU6K.cjs.map +1 -0
- package/dist/chunk-D2GO3RBL.cjs +12 -0
- package/dist/chunk-D2GO3RBL.cjs.map +1 -0
- package/dist/{chunk-WFMTAEEN.js → chunk-DOTEN2FG.js} +81 -7
- package/dist/chunk-DOTEN2FG.js.map +1 -0
- package/dist/chunk-E5JZSEGJ.cjs +301 -0
- package/dist/chunk-E5JZSEGJ.cjs.map +1 -0
- package/dist/chunk-EG6TJ3I5.js +286 -0
- package/dist/chunk-EG6TJ3I5.js.map +1 -0
- package/dist/chunk-EJCDOA37.js +537 -0
- package/dist/chunk-EJCDOA37.js.map +1 -0
- package/dist/{chunk-UVZHTBZ5.cjs → chunk-EK6RJ373.cjs} +7 -150
- package/dist/chunk-EK6RJ373.cjs.map +1 -0
- package/dist/{chunk-3JK66E3I.cjs → chunk-JTI5WT4P.cjs} +630 -59
- package/dist/chunk-JTI5WT4P.cjs.map +1 -0
- package/dist/chunk-NHQWXSTS.js +10 -0
- package/dist/chunk-NHQWXSTS.js.map +1 -0
- package/dist/chunk-NZ5PMBTG.js +105 -0
- package/dist/chunk-NZ5PMBTG.js.map +1 -0
- package/dist/{chunk-SUHW2UYL.cjs → chunk-OECDVACY.cjs} +2 -2
- package/dist/chunk-OECDVACY.cjs.map +1 -0
- package/dist/{chunk-EYELZHKY.js → chunk-OOS2RKRH.js} +5 -140
- package/dist/chunk-OOS2RKRH.js.map +1 -0
- package/dist/{chunk-EY4LBX3F.js → chunk-PSKUWVCB.js} +373 -38
- package/dist/chunk-PSKUWVCB.js.map +1 -0
- package/dist/chunk-QMQYK3IF.cjs +2680 -0
- package/dist/chunk-QMQYK3IF.cjs.map +1 -0
- package/dist/chunk-RCAJZG67.cjs +2069 -0
- package/dist/chunk-RCAJZG67.cjs.map +1 -0
- package/dist/{chunk-O5PST6TB.cjs → chunk-W5MTHMTE.cjs} +83 -6
- package/dist/chunk-W5MTHMTE.cjs.map +1 -0
- package/dist/chunk-WVQXAFP3.js +79 -0
- package/dist/chunk-WVQXAFP3.js.map +1 -0
- package/dist/chunk-X3244EKP.cjs +84 -0
- package/dist/chunk-X3244EKP.cjs.map +1 -0
- package/dist/{chunk-753F33CV.js → chunk-YZZBDCLV.js} +617 -44
- package/dist/chunk-YZZBDCLV.js.map +1 -0
- package/dist/{ddl-B_H8JM-E.d.cts → ddl-BqMmpNor.d.ts} +1328 -283
- package/dist/{ddl-1tFIvt9V.d.ts → ddl-Bwjh8Hff.d.cts} +1328 -283
- package/dist/extension-types-D07e_NTw.d.cts +543 -0
- package/dist/extension-types-D07e_NTw.d.ts +543 -0
- package/dist/graph-extension/index.cjs +71 -0
- package/dist/graph-extension/index.cjs.map +1 -0
- package/dist/graph-extension/index.d.cts +278 -0
- package/dist/graph-extension/index.d.ts +278 -0
- package/dist/graph-extension/index.js +6 -0
- package/dist/graph-extension/index.js.map +1 -0
- package/dist/{index-DXkEXpNz.d.ts → index-CT6nvtxL.d.cts} +114 -5
- package/dist/{index-DXkEXpNz.d.cts → index-DQheiVQV.d.ts} +114 -5
- package/dist/index.cjs +2672 -901
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -10
- package/dist/index.d.ts +29 -10
- package/dist/index.js +2248 -598
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +25 -23
- package/dist/indexes/index.d.cts +40 -22
- package/dist/indexes/index.d.ts +40 -22
- package/dist/indexes/index.js +5 -3
- package/dist/interchange/index.cjs +8 -7
- package/dist/interchange/index.cjs.map +1 -1
- package/dist/interchange/index.d.cts +5 -4
- package/dist/interchange/index.d.ts +5 -4
- package/dist/interchange/index.js +3 -2
- package/dist/interchange/index.js.map +1 -1
- package/dist/{manager-Vkz28eAC.d.cts → manager-Cy3dhwYO.d.cts} +194 -6
- package/dist/{manager-nIhmttD-.d.ts → manager-sZkU2VPC.d.ts} +194 -6
- package/dist/materialize-indexes-BB9N5uQl.d.cts +68 -0
- package/dist/materialize-indexes-BYpU2RKh.d.ts +68 -0
- package/dist/profiler/index.cjs +10 -8
- package/dist/profiler/index.cjs.map +1 -1
- package/dist/profiler/index.d.cts +8 -7
- package/dist/profiler/index.d.ts +8 -7
- package/dist/profiler/index.js +3 -1
- package/dist/profiler/index.js.map +1 -1
- package/dist/schema/index.cjs +43 -22
- package/dist/schema/index.cjs.map +1 -1
- package/dist/schema/index.d.cts +17 -8
- package/dist/schema/index.d.ts +17 -8
- package/dist/schema/index.js +9 -4
- package/dist/schema/index.js.map +1 -1
- package/dist/{sqlite-D0aceIe0.d.cts → sqlite-BhFswiAR.d.cts} +837 -120
- package/dist/{sqlite-SUxbZqfy.d.ts → sqlite-h6dta1IJ.d.ts} +837 -120
- package/dist/{store-CpvwTMxV.d.cts → store-BS_hehiz.d.ts} +659 -23
- package/dist/{store-U3i2tUch.d.ts → store-CkCvqRUf.d.cts} +659 -23
- package/dist/{types-yH4_p0XB.d.cts → types-BpgACExN.d.cts} +3 -2
- package/dist/{types-qYFZ9SqD.d.ts → types-Bz-Pi681.d.ts} +3 -2
- package/dist/types-DptZHe-l.d.ts +2132 -0
- package/dist/types-WF5ItKQu.d.cts +2132 -0
- package/dist/where-C40InMIp.d.ts +11 -0
- package/dist/where-DZYMiXVq.d.cts +11 -0
- package/package.json +33 -73
- package/dist/ast-C8S37w1A.d.ts +0 -497
- package/dist/ast-dgLhLOg0.d.cts +0 -497
- package/dist/chunk-3JK66E3I.cjs.map +0 -1
- package/dist/chunk-3PPEHLGK.js +0 -1116
- package/dist/chunk-3PPEHLGK.js.map +0 -1
- package/dist/chunk-5HVDOPZU.cjs.map +0 -1
- package/dist/chunk-753F33CV.js.map +0 -1
- package/dist/chunk-EY4LBX3F.js.map +0 -1
- package/dist/chunk-EYELZHKY.js.map +0 -1
- package/dist/chunk-GFGVREHH.js +0 -1381
- package/dist/chunk-GFGVREHH.js.map +0 -1
- package/dist/chunk-GUTQTMOV.js.map +0 -1
- package/dist/chunk-LBORRUNJ.js +0 -135
- package/dist/chunk-LBORRUNJ.js.map +0 -1
- package/dist/chunk-O5PST6TB.cjs.map +0 -1
- package/dist/chunk-OLROXS2S.cjs +0 -147
- package/dist/chunk-OLROXS2S.cjs.map +0 -1
- package/dist/chunk-OVJ2BE5Q.cjs.map +0 -1
- package/dist/chunk-PAUN562Y.cjs +0 -1417
- package/dist/chunk-PAUN562Y.cjs.map +0 -1
- package/dist/chunk-PEE4EWXZ.cjs +0 -1131
- package/dist/chunk-PEE4EWXZ.cjs.map +0 -1
- package/dist/chunk-QOLTW7OZ.js.map +0 -1
- package/dist/chunk-SUHW2UYL.cjs.map +0 -1
- package/dist/chunk-UVZHTBZ5.cjs.map +0 -1
- package/dist/chunk-WFMTAEEN.js.map +0 -1
- package/dist/types-C-zfYDJB.d.ts +0 -159
- package/dist/types-CQx4iW5Y.d.cts +0 -159
- package/dist/types-Qk2l3IkQ.d.cts +0 -1254
- package/dist/types-Qk2l3IkQ.d.ts +0 -1254
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkHTGDWIDE_cjs = require('../../chunk-HTGDWIDE.cjs');
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
require('../../chunk-
|
|
7
|
-
require('../../chunk-
|
|
8
|
-
|
|
9
|
-
require('../../chunk-
|
|
4
|
+
var chunkCQVNGKU7_cjs = require('../../chunk-CQVNGKU7.cjs');
|
|
5
|
+
var chunkOECDVACY_cjs = require('../../chunk-OECDVACY.cjs');
|
|
6
|
+
var chunkJTI5WT4P_cjs = require('../../chunk-JTI5WT4P.cjs');
|
|
7
|
+
require('../../chunk-CTHNVU6K.cjs');
|
|
8
|
+
require('../../chunk-EK6RJ373.cjs');
|
|
9
|
+
require('../../chunk-X3244EKP.cjs');
|
|
10
|
+
var chunkW5MTHMTE_cjs = require('../../chunk-W5MTHMTE.cjs');
|
|
11
|
+
require('../../chunk-7V335GHG.cjs');
|
|
10
12
|
var drizzleOrm = require('drizzle-orm');
|
|
11
13
|
|
|
12
14
|
// src/backend/drizzle/execution/postgres-execution.ts
|
|
@@ -31,7 +33,7 @@ var DEFAULT_POSTGRES_STATEMENT_CACHE_MAX = 256;
|
|
|
31
33
|
var STATEMENT_NAME_CACHE = /* @__PURE__ */ new Map();
|
|
32
34
|
var nextStatementId = 0;
|
|
33
35
|
function statementNameFor(sqlText, cacheMax) {
|
|
34
|
-
return
|
|
36
|
+
return chunkCQVNGKU7_cjs.getOrCreateLru(STATEMENT_NAME_CACHE, sqlText, cacheMax, () => {
|
|
35
37
|
const name = `tg_${nextStatementId}`;
|
|
36
38
|
nextStatementId += 1;
|
|
37
39
|
return name;
|
|
@@ -122,7 +124,7 @@ function createPostgresExecutionAdapter(db, options = {}) {
|
|
|
122
124
|
const cacheMax = options.preparedStatementCacheMax ?? DEFAULT_POSTGRES_STATEMENT_CACHE_MAX;
|
|
123
125
|
const pgClient = resolvePgClient(db, prepareStatements, cacheMax);
|
|
124
126
|
function compile(query) {
|
|
125
|
-
return
|
|
127
|
+
return chunkCQVNGKU7_cjs.compileQueryWithDialect(db, query, "PostgreSQL");
|
|
126
128
|
}
|
|
127
129
|
if (pgClient === void 0) {
|
|
128
130
|
return {
|
|
@@ -178,10 +180,10 @@ var POSTGRES_CHECK_UNIQUE_BATCH_CHUNK_SIZE = Math.max(
|
|
|
178
180
|
1,
|
|
179
181
|
POSTGRES_MAX_BIND_PARAMETERS - CHECK_UNIQUE_BATCH_FIXED_PARAM_COUNT
|
|
180
182
|
);
|
|
181
|
-
var toNodeRow =
|
|
182
|
-
var toEdgeRow =
|
|
183
|
-
var toUniqueRow =
|
|
184
|
-
var toSchemaVersionRow =
|
|
183
|
+
var toNodeRow = chunkCQVNGKU7_cjs.createNodeRowMapper(chunkCQVNGKU7_cjs.POSTGRES_ROW_MAPPER_CONFIG);
|
|
184
|
+
var toEdgeRow = chunkCQVNGKU7_cjs.createEdgeRowMapper(chunkCQVNGKU7_cjs.POSTGRES_ROW_MAPPER_CONFIG);
|
|
185
|
+
var toUniqueRow = chunkCQVNGKU7_cjs.createUniqueRowMapper(chunkCQVNGKU7_cjs.POSTGRES_ROW_MAPPER_CONFIG);
|
|
186
|
+
var toSchemaVersionRow = chunkCQVNGKU7_cjs.createSchemaVersionRowMapper(chunkCQVNGKU7_cjs.POSTGRES_ROW_MAPPER_CONFIG);
|
|
185
187
|
function toEmbeddingRow(row) {
|
|
186
188
|
let embedding;
|
|
187
189
|
if (typeof row.embedding === "string") {
|
|
@@ -199,8 +201,8 @@ function toEmbeddingRow(row) {
|
|
|
199
201
|
field_path: row.field_path,
|
|
200
202
|
embedding,
|
|
201
203
|
dimensions: row.dimensions,
|
|
202
|
-
created_at:
|
|
203
|
-
updated_at:
|
|
204
|
+
created_at: chunkCQVNGKU7_cjs.formatPostgresTimestamp(row.created_at) ?? "",
|
|
205
|
+
updated_at: chunkCQVNGKU7_cjs.formatPostgresTimestamp(row.updated_at) ?? ""
|
|
204
206
|
};
|
|
205
207
|
}
|
|
206
208
|
function coerceNumericScore(value) {
|
|
@@ -215,7 +217,7 @@ function coerceNumericScore(value) {
|
|
|
215
217
|
}
|
|
216
218
|
function buildPostgresCapabilities(strategy) {
|
|
217
219
|
return {
|
|
218
|
-
...
|
|
220
|
+
...chunkOECDVACY_cjs.POSTGRES_CAPABILITIES,
|
|
219
221
|
vector: {
|
|
220
222
|
supported: true,
|
|
221
223
|
metrics: ["cosine", "l2", "inner_product"],
|
|
@@ -223,12 +225,12 @@ function buildPostgresCapabilities(strategy) {
|
|
|
223
225
|
maxDimensions: 16e3
|
|
224
226
|
// pgvector limit
|
|
225
227
|
},
|
|
226
|
-
fulltext:
|
|
228
|
+
fulltext: chunkJTI5WT4P_cjs.buildFulltextCapabilities(strategy)
|
|
227
229
|
};
|
|
228
230
|
}
|
|
229
231
|
function createPostgresBackend(db, options = {}) {
|
|
230
|
-
const tables2 = options.tables ??
|
|
231
|
-
const fulltextStrategy = options.fulltext ??
|
|
232
|
+
const tables2 = options.tables ?? chunkCQVNGKU7_cjs.tables;
|
|
233
|
+
const fulltextStrategy = options.fulltext ?? chunkJTI5WT4P_cjs.tsvectorStrategy;
|
|
232
234
|
const baseCapabilities = buildPostgresCapabilities(fulltextStrategy);
|
|
233
235
|
const httpOnlyOverrides = isNeonHttpClient(db) ? { transactions: false } : {};
|
|
234
236
|
const capabilities = {
|
|
@@ -245,7 +247,8 @@ function createPostgresBackend(db, options = {}) {
|
|
|
245
247
|
nodes: drizzleOrm.getTableName(tables2.nodes),
|
|
246
248
|
edges: drizzleOrm.getTableName(tables2.edges),
|
|
247
249
|
embeddings: drizzleOrm.getTableName(tables2.embeddings),
|
|
248
|
-
fulltext: tables2.fulltextTableName
|
|
250
|
+
fulltext: tables2.fulltextTableName,
|
|
251
|
+
uniques: drizzleOrm.getTableName(tables2.uniques)
|
|
249
252
|
};
|
|
250
253
|
const analyzeStatement = drizzleOrm.sql`ANALYZE ${drizzleOrm.sql.join(
|
|
251
254
|
[
|
|
@@ -257,7 +260,7 @@ function createPostgresBackend(db, options = {}) {
|
|
|
257
260
|
].map((name) => chunkHTGDWIDE_cjs.quoteIdentifier(name)),
|
|
258
261
|
drizzleOrm.sql`, `
|
|
259
262
|
)}`;
|
|
260
|
-
const operationStrategy =
|
|
263
|
+
const operationStrategy = chunkCQVNGKU7_cjs.createPostgresOperationStrategy(
|
|
261
264
|
tables2,
|
|
262
265
|
fulltextStrategy
|
|
263
266
|
);
|
|
@@ -269,25 +272,186 @@ function createPostgresBackend(db, options = {}) {
|
|
|
269
272
|
capabilities,
|
|
270
273
|
fulltextStrategy
|
|
271
274
|
});
|
|
275
|
+
function runSchemaWriteTransaction(graphId, fn) {
|
|
276
|
+
if (!capabilities.transactions) {
|
|
277
|
+
throw new chunkW5MTHMTE_cjs.ConfigurationError(
|
|
278
|
+
"commitSchemaVersion and setActiveVersion require atomic transactions, but this Postgres backend does not provide them. The drizzle-orm/neon-http driver communicates over HTTP and cannot hold a session across statements; use drizzle-orm/neon-serverless (websocket) for transactional writes.",
|
|
279
|
+
{
|
|
280
|
+
backend: "postgres",
|
|
281
|
+
capability: "transactions",
|
|
282
|
+
supportsTransactions: false
|
|
283
|
+
}
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
return db.transaction(async (tx) => {
|
|
287
|
+
await tx.execute(
|
|
288
|
+
drizzleOrm.sql`SELECT pg_advisory_xact_lock(hashtext(${graphId}))`
|
|
289
|
+
);
|
|
290
|
+
const txBackend = createTransactionBackend({
|
|
291
|
+
db: tx,
|
|
292
|
+
adapterOptions,
|
|
293
|
+
operationStrategy,
|
|
294
|
+
tableNames,
|
|
295
|
+
capabilities,
|
|
296
|
+
fulltextStrategy
|
|
297
|
+
});
|
|
298
|
+
return fn(txBackend);
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
let fulltextEnsured = false;
|
|
302
|
+
async function ensureFulltextDdl() {
|
|
303
|
+
if (fulltextEnsured) return;
|
|
304
|
+
for (const statement of fulltextStrategy.generateDdl(
|
|
305
|
+
tables2.fulltextTableName
|
|
306
|
+
)) {
|
|
307
|
+
await db.execute(drizzleOrm.sql.raw(statement));
|
|
308
|
+
}
|
|
309
|
+
fulltextEnsured = true;
|
|
310
|
+
}
|
|
272
311
|
const backend = {
|
|
273
312
|
...operations,
|
|
274
313
|
async bootstrapTables() {
|
|
275
|
-
const statements =
|
|
314
|
+
const statements = chunkCQVNGKU7_cjs.generatePostgresDDL(tables2, fulltextStrategy);
|
|
276
315
|
for (const statement of statements) {
|
|
277
316
|
await db.execute(drizzleOrm.sql.raw(statement));
|
|
278
317
|
}
|
|
318
|
+
fulltextEnsured = true;
|
|
319
|
+
},
|
|
320
|
+
async upsertFulltext(params) {
|
|
321
|
+
await ensureFulltextDdl();
|
|
322
|
+
await operations.upsertFulltext(params);
|
|
323
|
+
},
|
|
324
|
+
async deleteFulltext(params) {
|
|
325
|
+
await ensureFulltextDdl();
|
|
326
|
+
await operations.deleteFulltext(params);
|
|
327
|
+
},
|
|
328
|
+
async upsertFulltextBatch(params) {
|
|
329
|
+
if (params.rows.length === 0) return;
|
|
330
|
+
await ensureFulltextDdl();
|
|
331
|
+
await operations.upsertFulltextBatch(params);
|
|
332
|
+
},
|
|
333
|
+
async deleteFulltextBatch(params) {
|
|
334
|
+
if (params.nodeIds.length === 0) return;
|
|
335
|
+
await ensureFulltextDdl();
|
|
336
|
+
await operations.deleteFulltextBatch(params);
|
|
337
|
+
},
|
|
338
|
+
async fulltextSearch(params) {
|
|
339
|
+
await ensureFulltextDdl();
|
|
340
|
+
return operations.fulltextSearch(params);
|
|
341
|
+
},
|
|
342
|
+
// hardDeleteNode is wrapped because the operation-backend-core
|
|
343
|
+
// cascade unconditionally deletes from the fulltext table — it
|
|
344
|
+
// would fail even on graphs that declare no searchable() fields.
|
|
345
|
+
async hardDeleteNode(params) {
|
|
346
|
+
await ensureFulltextDdl();
|
|
347
|
+
await operations.hardDeleteNode(params);
|
|
348
|
+
},
|
|
349
|
+
async executeDdl(ddl) {
|
|
350
|
+
await db.execute(drizzleOrm.sql.raw(ddl));
|
|
351
|
+
},
|
|
352
|
+
async ensureIndexMaterializationsTable() {
|
|
353
|
+
await db.execute(
|
|
354
|
+
drizzleOrm.sql.raw(chunkCQVNGKU7_cjs.generatePgCreateTableSQL(tables2.indexMaterializations))
|
|
355
|
+
);
|
|
356
|
+
},
|
|
357
|
+
async getIndexMaterialization(indexName) {
|
|
358
|
+
const t = tables2.indexMaterializations;
|
|
359
|
+
const rows = await db.select().from(t).where(drizzleOrm.eq(t.indexName, indexName));
|
|
360
|
+
const row = rows[0];
|
|
361
|
+
if (row === void 0) return void 0;
|
|
362
|
+
return chunkCQVNGKU7_cjs.mapMaterializationRow(row, chunkCQVNGKU7_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.decode);
|
|
363
|
+
},
|
|
364
|
+
async getIndexMaterializations(statusKeys) {
|
|
365
|
+
if (statusKeys.length === 0) return [];
|
|
366
|
+
const t = tables2.indexMaterializations;
|
|
367
|
+
const rows = await db.select().from(t).where(drizzleOrm.inArray(t.indexName, [...statusKeys]));
|
|
368
|
+
return rows.map(
|
|
369
|
+
(row) => chunkCQVNGKU7_cjs.mapMaterializationRow(row, chunkCQVNGKU7_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.decode)
|
|
370
|
+
);
|
|
371
|
+
},
|
|
372
|
+
async recordIndexMaterialization(params) {
|
|
373
|
+
const t = tables2.indexMaterializations;
|
|
374
|
+
await db.insert(t).values(
|
|
375
|
+
chunkCQVNGKU7_cjs.buildMaterializationInsertValues(
|
|
376
|
+
params,
|
|
377
|
+
chunkCQVNGKU7_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.encode
|
|
378
|
+
)
|
|
379
|
+
).onConflictDoUpdate({
|
|
380
|
+
target: t.indexName,
|
|
381
|
+
set: chunkCQVNGKU7_cjs.buildMaterializationOnConflictSet(
|
|
382
|
+
t.materializedAt,
|
|
383
|
+
params.materializedAt
|
|
384
|
+
)
|
|
385
|
+
});
|
|
386
|
+
},
|
|
387
|
+
async ensureKindRemovalsTable() {
|
|
388
|
+
await db.execute(
|
|
389
|
+
drizzleOrm.sql.raw(chunkCQVNGKU7_cjs.generatePgCreateTableSQL(tables2.kindRemovals))
|
|
390
|
+
);
|
|
391
|
+
},
|
|
392
|
+
async getPendingKindRemovals(graphId) {
|
|
393
|
+
const t = tables2.kindRemovals;
|
|
394
|
+
const rows = await db.select().from(t).where(drizzleOrm.and(drizzleOrm.eq(t.graphId, graphId), drizzleOrm.isNull(t.removedAt)));
|
|
395
|
+
return rows.map(
|
|
396
|
+
(row) => chunkCQVNGKU7_cjs.mapKindRemovalRow(row, chunkCQVNGKU7_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.decode)
|
|
397
|
+
);
|
|
398
|
+
},
|
|
399
|
+
async getAllKindRemovals(graphId) {
|
|
400
|
+
const t = tables2.kindRemovals;
|
|
401
|
+
const rows = await db.select().from(t).where(drizzleOrm.eq(t.graphId, graphId));
|
|
402
|
+
return rows.map(
|
|
403
|
+
(row) => chunkCQVNGKU7_cjs.mapKindRemovalRow(row, chunkCQVNGKU7_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.decode)
|
|
404
|
+
);
|
|
405
|
+
},
|
|
406
|
+
async recordKindRemoval(params) {
|
|
407
|
+
const t = tables2.kindRemovals;
|
|
408
|
+
await db.insert(t).values(
|
|
409
|
+
chunkCQVNGKU7_cjs.buildKindRemovalInsertValues(
|
|
410
|
+
params,
|
|
411
|
+
chunkCQVNGKU7_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.encode
|
|
412
|
+
)
|
|
413
|
+
).onConflictDoUpdate({
|
|
414
|
+
target: [t.graphId, t.kindName, t.entity, t.schemaVersion],
|
|
415
|
+
set: chunkCQVNGKU7_cjs.buildKindRemovalOnConflictSet(t.removedAt, params.removedAt)
|
|
416
|
+
});
|
|
417
|
+
},
|
|
418
|
+
async ensureReconciliationMarkersTable() {
|
|
419
|
+
await db.execute(
|
|
420
|
+
drizzleOrm.sql.raw(chunkCQVNGKU7_cjs.generatePgCreateTableSQL(tables2.reconciliationMarkers))
|
|
421
|
+
);
|
|
422
|
+
},
|
|
423
|
+
async ensureFulltextTable() {
|
|
424
|
+
await ensureFulltextDdl();
|
|
425
|
+
},
|
|
426
|
+
async getReconciliationMarker(graphId) {
|
|
427
|
+
const t = tables2.reconciliationMarkers;
|
|
428
|
+
const rows = await db.select().from(t).where(drizzleOrm.eq(t.graphId, graphId));
|
|
429
|
+
return rows[0]?.reconciledToVersion;
|
|
430
|
+
},
|
|
431
|
+
async setReconciliationMarker(graphId, version) {
|
|
432
|
+
const t = tables2.reconciliationMarkers;
|
|
433
|
+
await db.insert(t).values({ graphId, reconciledToVersion: version }).onConflictDoUpdate({
|
|
434
|
+
target: t.graphId,
|
|
435
|
+
set: { reconciledToVersion: version }
|
|
436
|
+
});
|
|
279
437
|
},
|
|
280
438
|
async refreshStatistics() {
|
|
281
439
|
await db.execute(analyzeStatement);
|
|
282
440
|
},
|
|
283
|
-
async
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
(target) => target.
|
|
287
|
-
|
|
441
|
+
async commitSchemaVersion(params) {
|
|
442
|
+
return runSchemaWriteTransaction(
|
|
443
|
+
params.graphId,
|
|
444
|
+
(target) => target.commitSchemaVersion(params)
|
|
445
|
+
);
|
|
446
|
+
},
|
|
447
|
+
async setActiveVersion(params) {
|
|
448
|
+
await runSchemaWriteTransaction(
|
|
449
|
+
params.graphId,
|
|
450
|
+
(target) => target.setActiveVersion(params)
|
|
288
451
|
);
|
|
289
452
|
},
|
|
290
453
|
async transaction(fn, options2) {
|
|
454
|
+
await ensureFulltextDdl();
|
|
291
455
|
const txConfig = options2?.isolationLevel ? {
|
|
292
456
|
isolationLevel: options2.isolationLevel.replace("_", " ")
|
|
293
457
|
} : void 0;
|
|
@@ -327,7 +491,7 @@ function createPostgresOperationBackend(options) {
|
|
|
327
491
|
async function execRun(query) {
|
|
328
492
|
await executionAdapter.execute(query);
|
|
329
493
|
}
|
|
330
|
-
const commonBackend =
|
|
494
|
+
const commonBackend = chunkCQVNGKU7_cjs.createCommonOperationBackend({
|
|
331
495
|
batchConfig: {
|
|
332
496
|
checkUniqueBatchChunkSize: POSTGRES_CHECK_UNIQUE_BATCH_CHUNK_SIZE,
|
|
333
497
|
edgeInsertBatchSize: POSTGRES_EDGE_INSERT_BATCH_SIZE,
|
|
@@ -340,7 +504,7 @@ function createPostgresOperationBackend(options) {
|
|
|
340
504
|
execGet,
|
|
341
505
|
execRun
|
|
342
506
|
},
|
|
343
|
-
nowIso:
|
|
507
|
+
nowIso: chunkCQVNGKU7_cjs.nowIso,
|
|
344
508
|
operationStrategy,
|
|
345
509
|
rowMappers: {
|
|
346
510
|
toEdgeRow,
|
|
@@ -364,7 +528,7 @@ function createPostgresOperationBackend(options) {
|
|
|
364
528
|
tableNames,
|
|
365
529
|
// === Embedding Operations ===
|
|
366
530
|
async upsertEmbedding(params) {
|
|
367
|
-
const timestamp =
|
|
531
|
+
const timestamp = chunkCQVNGKU7_cjs.nowIso();
|
|
368
532
|
const query = operationStrategy.buildUpsertEmbedding(params, timestamp);
|
|
369
533
|
await execRun(query);
|
|
370
534
|
},
|
|
@@ -401,9 +565,10 @@ function createPostgresOperationBackend(options) {
|
|
|
401
565
|
metric: params.metric,
|
|
402
566
|
...params.indexParams?.m === void 0 ? {} : { hnswM: params.indexParams.m },
|
|
403
567
|
...params.indexParams?.efConstruction === void 0 ? {} : { hnswEfConstruction: params.indexParams.efConstruction },
|
|
404
|
-
...params.indexParams?.lists === void 0 ? {} : { ivfflatLists: params.indexParams.lists }
|
|
568
|
+
...params.indexParams?.lists === void 0 ? {} : { ivfflatLists: params.indexParams.lists },
|
|
569
|
+
...params.concurrent === true ? { concurrent: true } : {}
|
|
405
570
|
};
|
|
406
|
-
const result = await
|
|
571
|
+
const result = await chunkCQVNGKU7_cjs.createPostgresVectorIndex(db, indexOptions);
|
|
407
572
|
if (!result.success) {
|
|
408
573
|
throw new Error(
|
|
409
574
|
result.message ?? "Failed to create PostgreSQL vector index"
|
|
@@ -412,7 +577,7 @@ function createPostgresOperationBackend(options) {
|
|
|
412
577
|
},
|
|
413
578
|
// === Fulltext Operations ===
|
|
414
579
|
async upsertFulltext(params) {
|
|
415
|
-
const timestamp =
|
|
580
|
+
const timestamp = chunkCQVNGKU7_cjs.nowIso();
|
|
416
581
|
const statements = operationStrategy.buildUpsertFulltext(
|
|
417
582
|
params,
|
|
418
583
|
timestamp
|
|
@@ -429,7 +594,7 @@ function createPostgresOperationBackend(options) {
|
|
|
429
594
|
},
|
|
430
595
|
async upsertFulltextBatch(params) {
|
|
431
596
|
if (params.rows.length === 0) return;
|
|
432
|
-
const timestamp =
|
|
597
|
+
const timestamp = chunkCQVNGKU7_cjs.nowIso();
|
|
433
598
|
const statements = operationStrategy.buildUpsertFulltextBatch(
|
|
434
599
|
params,
|
|
435
600
|
timestamp
|
|
@@ -457,20 +622,22 @@ function createPostgresOperationBackend(options) {
|
|
|
457
622
|
},
|
|
458
623
|
async dropVectorIndex(params) {
|
|
459
624
|
const metrics = capabilities.vector?.metrics ?? ["cosine"];
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
const result = await chunk5HVDOPZU_cjs.dropPostgresVectorIndex(db, indexName);
|
|
468
|
-
if (!result.success) {
|
|
469
|
-
throw new Error(
|
|
470
|
-
result.message ?? "Failed to drop PostgreSQL vector index"
|
|
625
|
+
await Promise.all(
|
|
626
|
+
metrics.map(async (metric) => {
|
|
627
|
+
const indexName = chunkCQVNGKU7_cjs.generateVectorIndexName(
|
|
628
|
+
params.graphId,
|
|
629
|
+
params.nodeKind,
|
|
630
|
+
params.fieldPath,
|
|
631
|
+
metric
|
|
471
632
|
);
|
|
472
|
-
|
|
473
|
-
|
|
633
|
+
const result = await chunkCQVNGKU7_cjs.dropPostgresVectorIndex(db, indexName);
|
|
634
|
+
if (!result.success) {
|
|
635
|
+
throw new Error(
|
|
636
|
+
result.message ?? "Failed to drop PostgreSQL vector index"
|
|
637
|
+
);
|
|
638
|
+
}
|
|
639
|
+
})
|
|
640
|
+
);
|
|
474
641
|
},
|
|
475
642
|
// === Query Execution ===
|
|
476
643
|
async execute(query) {
|
|
@@ -496,39 +663,43 @@ function createTransactionBackend(options) {
|
|
|
496
663
|
|
|
497
664
|
Object.defineProperty(exports, "createPostgresTables", {
|
|
498
665
|
enumerable: true,
|
|
499
|
-
get: function () { return
|
|
666
|
+
get: function () { return chunkCQVNGKU7_cjs.createPostgresTables; }
|
|
500
667
|
});
|
|
501
668
|
Object.defineProperty(exports, "edges", {
|
|
502
669
|
enumerable: true,
|
|
503
|
-
get: function () { return
|
|
670
|
+
get: function () { return chunkCQVNGKU7_cjs.edges; }
|
|
504
671
|
});
|
|
505
672
|
Object.defineProperty(exports, "embeddings", {
|
|
506
673
|
enumerable: true,
|
|
507
|
-
get: function () { return
|
|
674
|
+
get: function () { return chunkCQVNGKU7_cjs.embeddings; }
|
|
675
|
+
});
|
|
676
|
+
Object.defineProperty(exports, "fulltext", {
|
|
677
|
+
enumerable: true,
|
|
678
|
+
get: function () { return chunkCQVNGKU7_cjs.fulltext; }
|
|
508
679
|
});
|
|
509
680
|
Object.defineProperty(exports, "generatePostgresDDL", {
|
|
510
681
|
enumerable: true,
|
|
511
|
-
get: function () { return
|
|
682
|
+
get: function () { return chunkCQVNGKU7_cjs.generatePostgresDDL; }
|
|
512
683
|
});
|
|
513
684
|
Object.defineProperty(exports, "generatePostgresMigrationSQL", {
|
|
514
685
|
enumerable: true,
|
|
515
|
-
get: function () { return
|
|
686
|
+
get: function () { return chunkCQVNGKU7_cjs.generatePostgresMigrationSQL; }
|
|
516
687
|
});
|
|
517
688
|
Object.defineProperty(exports, "nodes", {
|
|
518
689
|
enumerable: true,
|
|
519
|
-
get: function () { return
|
|
690
|
+
get: function () { return chunkCQVNGKU7_cjs.nodes; }
|
|
520
691
|
});
|
|
521
692
|
Object.defineProperty(exports, "schemaVersions", {
|
|
522
693
|
enumerable: true,
|
|
523
|
-
get: function () { return
|
|
694
|
+
get: function () { return chunkCQVNGKU7_cjs.schemaVersions; }
|
|
524
695
|
});
|
|
525
696
|
Object.defineProperty(exports, "tables", {
|
|
526
697
|
enumerable: true,
|
|
527
|
-
get: function () { return
|
|
698
|
+
get: function () { return chunkCQVNGKU7_cjs.tables; }
|
|
528
699
|
});
|
|
529
700
|
Object.defineProperty(exports, "uniques", {
|
|
530
701
|
enumerable: true,
|
|
531
|
-
get: function () { return
|
|
702
|
+
get: function () { return chunkCQVNGKU7_cjs.uniques; }
|
|
532
703
|
});
|
|
533
704
|
exports.createPostgresBackend = createPostgresBackend;
|
|
534
705
|
//# sourceMappingURL=index.cjs.map
|