@nicia-ai/typegraph 0.24.1 → 0.25.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 +178 -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 +151 -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-SUHW2UYL.cjs → chunk-7CDXX3QZ.cjs} +2 -2
- package/dist/chunk-7CDXX3QZ.cjs.map +1 -0
- package/dist/chunk-7V335GHG.cjs +112 -0
- package/dist/chunk-7V335GHG.cjs.map +1 -0
- package/dist/chunk-7W3KAMVQ.cjs +2678 -0
- package/dist/chunk-7W3KAMVQ.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-GUTQTMOV.js → chunk-FPCOUJSL.js} +2 -2
- package/dist/chunk-FPCOUJSL.js.map +1 -0
- package/dist/{chunk-3JK66E3I.cjs → chunk-JTI5WT4P.cjs} +630 -59
- package/dist/chunk-JTI5WT4P.cjs.map +1 -0
- package/dist/chunk-LVCSL6A3.js +2626 -0
- package/dist/chunk-LVCSL6A3.js.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-5HVDOPZU.cjs → chunk-O2P3KAUT.cjs} +416 -93
- package/dist/chunk-O2P3KAUT.cjs.map +1 -0
- package/dist/{chunk-QOLTW7OZ.js → chunk-OJ6IQVZG.js} +151 -13
- package/dist/chunk-OJ6IQVZG.js.map +1 -0
- package/dist/{chunk-EYELZHKY.js → chunk-OOS2RKRH.js} +5 -140
- package/dist/chunk-OOS2RKRH.js.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-EY4LBX3F.js → chunk-WI5VRP3X.js} +337 -26
- package/dist/chunk-WI5VRP3X.js.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/{chunk-OVJ2BE5Q.cjs → chunk-ZEMNF3QK.cjs} +171 -33
- package/dist/chunk-ZEMNF3QK.cjs.map +1 -0
- package/dist/{ddl-B_H8JM-E.d.cts → ddl-B2jjLjpR.d.cts} +762 -99
- package/dist/{ddl-1tFIvt9V.d.ts → ddl-DpaeAKPp.d.ts} +762 -99
- 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-nIhmttD-.d.ts → manager-BKaPQbns.d.ts} +189 -6
- package/dist/{manager-Vkz28eAC.d.cts → manager-BpjBW1JK.d.cts} +189 -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-CU3j6rc7.d.ts} +837 -120
- package/dist/{sqlite-SUxbZqfy.d.ts → sqlite-Myo8e3Lr.d.cts} +837 -120
- package/dist/{store-U3i2tUch.d.ts → store-BAGuOHDh.d.cts} +659 -23
- package/dist/{store-CpvwTMxV.d.cts → store-De98Lod4.d.ts} +659 -23
- package/dist/types--0EslBx5.d.cts +2123 -0
- package/dist/{types-qYFZ9SqD.d.ts → types-BLmJq4wI.d.ts} +3 -2
- package/dist/types-BNWYZ-0-.d.ts +2123 -0
- package/dist/{types-yH4_p0XB.d.cts → types-CYga3lZp.d.cts} +3 -2
- package/dist/where-CluR73rs.d.ts +11 -0
- package/dist/where-m1uWsdua.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 chunkO2P3KAUT_cjs = require('../../chunk-O2P3KAUT.cjs');
|
|
5
|
+
var chunk7CDXX3QZ_cjs = require('../../chunk-7CDXX3QZ.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 chunkO2P3KAUT_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 chunkO2P3KAUT_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 = chunkO2P3KAUT_cjs.createNodeRowMapper(chunkO2P3KAUT_cjs.POSTGRES_ROW_MAPPER_CONFIG);
|
|
184
|
+
var toEdgeRow = chunkO2P3KAUT_cjs.createEdgeRowMapper(chunkO2P3KAUT_cjs.POSTGRES_ROW_MAPPER_CONFIG);
|
|
185
|
+
var toUniqueRow = chunkO2P3KAUT_cjs.createUniqueRowMapper(chunkO2P3KAUT_cjs.POSTGRES_ROW_MAPPER_CONFIG);
|
|
186
|
+
var toSchemaVersionRow = chunkO2P3KAUT_cjs.createSchemaVersionRowMapper(chunkO2P3KAUT_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: chunkO2P3KAUT_cjs.formatPostgresTimestamp(row.created_at) ?? "",
|
|
205
|
+
updated_at: chunkO2P3KAUT_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
|
+
...chunk7CDXX3QZ_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 ?? chunkO2P3KAUT_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 = chunkO2P3KAUT_cjs.createPostgresOperationStrategy(
|
|
261
264
|
tables2,
|
|
262
265
|
fulltextStrategy
|
|
263
266
|
);
|
|
@@ -269,22 +272,139 @@ 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
|
+
}
|
|
272
301
|
const backend = {
|
|
273
302
|
...operations,
|
|
274
303
|
async bootstrapTables() {
|
|
275
|
-
const statements =
|
|
304
|
+
const statements = chunkO2P3KAUT_cjs.generatePostgresDDL(tables2, fulltextStrategy);
|
|
276
305
|
for (const statement of statements) {
|
|
277
306
|
await db.execute(drizzleOrm.sql.raw(statement));
|
|
278
307
|
}
|
|
279
308
|
},
|
|
309
|
+
async executeDdl(ddl) {
|
|
310
|
+
await db.execute(drizzleOrm.sql.raw(ddl));
|
|
311
|
+
},
|
|
312
|
+
async ensureIndexMaterializationsTable() {
|
|
313
|
+
await db.execute(
|
|
314
|
+
drizzleOrm.sql.raw(chunkO2P3KAUT_cjs.generatePgCreateTableSQL(tables2.indexMaterializations))
|
|
315
|
+
);
|
|
316
|
+
},
|
|
317
|
+
async getIndexMaterialization(indexName) {
|
|
318
|
+
const t = tables2.indexMaterializations;
|
|
319
|
+
const rows = await db.select().from(t).where(drizzleOrm.eq(t.indexName, indexName));
|
|
320
|
+
const row = rows[0];
|
|
321
|
+
if (row === void 0) return void 0;
|
|
322
|
+
return chunkO2P3KAUT_cjs.mapMaterializationRow(row, chunkO2P3KAUT_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.decode);
|
|
323
|
+
},
|
|
324
|
+
async getIndexMaterializations(statusKeys) {
|
|
325
|
+
if (statusKeys.length === 0) return [];
|
|
326
|
+
const t = tables2.indexMaterializations;
|
|
327
|
+
const rows = await db.select().from(t).where(drizzleOrm.inArray(t.indexName, [...statusKeys]));
|
|
328
|
+
return rows.map(
|
|
329
|
+
(row) => chunkO2P3KAUT_cjs.mapMaterializationRow(row, chunkO2P3KAUT_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.decode)
|
|
330
|
+
);
|
|
331
|
+
},
|
|
332
|
+
async recordIndexMaterialization(params) {
|
|
333
|
+
const t = tables2.indexMaterializations;
|
|
334
|
+
await db.insert(t).values(
|
|
335
|
+
chunkO2P3KAUT_cjs.buildMaterializationInsertValues(
|
|
336
|
+
params,
|
|
337
|
+
chunkO2P3KAUT_cjs.POSTGRES_INDEX_MAT_TIMESTAMPS.encode
|
|
338
|
+
)
|
|
339
|
+
).onConflictDoUpdate({
|
|
340
|
+
target: t.indexName,
|
|
341
|
+
set: chunkO2P3KAUT_cjs.buildMaterializationOnConflictSet(
|
|
342
|
+
t.materializedAt,
|
|
343
|
+
params.materializedAt
|
|
344
|
+
)
|
|
345
|
+
});
|
|
346
|
+
},
|
|
347
|
+
async ensureKindRemovalsTable() {
|
|
348
|
+
await db.execute(
|
|
349
|
+
drizzleOrm.sql.raw(chunkO2P3KAUT_cjs.generatePgCreateTableSQL(tables2.kindRemovals))
|
|
350
|
+
);
|
|
351
|
+
},
|
|
352
|
+
async getPendingKindRemovals(graphId) {
|
|
353
|
+
const t = tables2.kindRemovals;
|
|
354
|
+
const rows = await db.select().from(t).where(drizzleOrm.and(drizzleOrm.eq(t.graphId, graphId), drizzleOrm.isNull(t.removedAt)));
|
|
355
|
+
return rows.map(
|
|
356
|
+
(row) => chunkO2P3KAUT_cjs.mapKindRemovalRow(row, chunkO2P3KAUT_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.decode)
|
|
357
|
+
);
|
|
358
|
+
},
|
|
359
|
+
async getAllKindRemovals(graphId) {
|
|
360
|
+
const t = tables2.kindRemovals;
|
|
361
|
+
const rows = await db.select().from(t).where(drizzleOrm.eq(t.graphId, graphId));
|
|
362
|
+
return rows.map(
|
|
363
|
+
(row) => chunkO2P3KAUT_cjs.mapKindRemovalRow(row, chunkO2P3KAUT_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.decode)
|
|
364
|
+
);
|
|
365
|
+
},
|
|
366
|
+
async recordKindRemoval(params) {
|
|
367
|
+
const t = tables2.kindRemovals;
|
|
368
|
+
await db.insert(t).values(
|
|
369
|
+
chunkO2P3KAUT_cjs.buildKindRemovalInsertValues(
|
|
370
|
+
params,
|
|
371
|
+
chunkO2P3KAUT_cjs.POSTGRES_KIND_REMOVAL_TIMESTAMPS.encode
|
|
372
|
+
)
|
|
373
|
+
).onConflictDoUpdate({
|
|
374
|
+
target: [t.graphId, t.kindName, t.entity, t.schemaVersion],
|
|
375
|
+
set: chunkO2P3KAUT_cjs.buildKindRemovalOnConflictSet(t.removedAt, params.removedAt)
|
|
376
|
+
});
|
|
377
|
+
},
|
|
378
|
+
async ensureReconciliationMarkersTable() {
|
|
379
|
+
await db.execute(
|
|
380
|
+
drizzleOrm.sql.raw(chunkO2P3KAUT_cjs.generatePgCreateTableSQL(tables2.reconciliationMarkers))
|
|
381
|
+
);
|
|
382
|
+
},
|
|
383
|
+
async getReconciliationMarker(graphId) {
|
|
384
|
+
const t = tables2.reconciliationMarkers;
|
|
385
|
+
const rows = await db.select().from(t).where(drizzleOrm.eq(t.graphId, graphId));
|
|
386
|
+
return rows[0]?.reconciledToVersion;
|
|
387
|
+
},
|
|
388
|
+
async setReconciliationMarker(graphId, version) {
|
|
389
|
+
const t = tables2.reconciliationMarkers;
|
|
390
|
+
await db.insert(t).values({ graphId, reconciledToVersion: version }).onConflictDoUpdate({
|
|
391
|
+
target: t.graphId,
|
|
392
|
+
set: { reconciledToVersion: version }
|
|
393
|
+
});
|
|
394
|
+
},
|
|
280
395
|
async refreshStatistics() {
|
|
281
396
|
await db.execute(analyzeStatement);
|
|
282
397
|
},
|
|
283
|
-
async
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
(target) => target.
|
|
287
|
-
|
|
398
|
+
async commitSchemaVersion(params) {
|
|
399
|
+
return runSchemaWriteTransaction(
|
|
400
|
+
params.graphId,
|
|
401
|
+
(target) => target.commitSchemaVersion(params)
|
|
402
|
+
);
|
|
403
|
+
},
|
|
404
|
+
async setActiveVersion(params) {
|
|
405
|
+
await runSchemaWriteTransaction(
|
|
406
|
+
params.graphId,
|
|
407
|
+
(target) => target.setActiveVersion(params)
|
|
288
408
|
);
|
|
289
409
|
},
|
|
290
410
|
async transaction(fn, options2) {
|
|
@@ -327,7 +447,7 @@ function createPostgresOperationBackend(options) {
|
|
|
327
447
|
async function execRun(query) {
|
|
328
448
|
await executionAdapter.execute(query);
|
|
329
449
|
}
|
|
330
|
-
const commonBackend =
|
|
450
|
+
const commonBackend = chunkO2P3KAUT_cjs.createCommonOperationBackend({
|
|
331
451
|
batchConfig: {
|
|
332
452
|
checkUniqueBatchChunkSize: POSTGRES_CHECK_UNIQUE_BATCH_CHUNK_SIZE,
|
|
333
453
|
edgeInsertBatchSize: POSTGRES_EDGE_INSERT_BATCH_SIZE,
|
|
@@ -340,7 +460,7 @@ function createPostgresOperationBackend(options) {
|
|
|
340
460
|
execGet,
|
|
341
461
|
execRun
|
|
342
462
|
},
|
|
343
|
-
nowIso:
|
|
463
|
+
nowIso: chunkO2P3KAUT_cjs.nowIso,
|
|
344
464
|
operationStrategy,
|
|
345
465
|
rowMappers: {
|
|
346
466
|
toEdgeRow,
|
|
@@ -364,7 +484,7 @@ function createPostgresOperationBackend(options) {
|
|
|
364
484
|
tableNames,
|
|
365
485
|
// === Embedding Operations ===
|
|
366
486
|
async upsertEmbedding(params) {
|
|
367
|
-
const timestamp =
|
|
487
|
+
const timestamp = chunkO2P3KAUT_cjs.nowIso();
|
|
368
488
|
const query = operationStrategy.buildUpsertEmbedding(params, timestamp);
|
|
369
489
|
await execRun(query);
|
|
370
490
|
},
|
|
@@ -401,9 +521,10 @@ function createPostgresOperationBackend(options) {
|
|
|
401
521
|
metric: params.metric,
|
|
402
522
|
...params.indexParams?.m === void 0 ? {} : { hnswM: params.indexParams.m },
|
|
403
523
|
...params.indexParams?.efConstruction === void 0 ? {} : { hnswEfConstruction: params.indexParams.efConstruction },
|
|
404
|
-
...params.indexParams?.lists === void 0 ? {} : { ivfflatLists: params.indexParams.lists }
|
|
524
|
+
...params.indexParams?.lists === void 0 ? {} : { ivfflatLists: params.indexParams.lists },
|
|
525
|
+
...params.concurrent === true ? { concurrent: true } : {}
|
|
405
526
|
};
|
|
406
|
-
const result = await
|
|
527
|
+
const result = await chunkO2P3KAUT_cjs.createPostgresVectorIndex(db, indexOptions);
|
|
407
528
|
if (!result.success) {
|
|
408
529
|
throw new Error(
|
|
409
530
|
result.message ?? "Failed to create PostgreSQL vector index"
|
|
@@ -412,7 +533,7 @@ function createPostgresOperationBackend(options) {
|
|
|
412
533
|
},
|
|
413
534
|
// === Fulltext Operations ===
|
|
414
535
|
async upsertFulltext(params) {
|
|
415
|
-
const timestamp =
|
|
536
|
+
const timestamp = chunkO2P3KAUT_cjs.nowIso();
|
|
416
537
|
const statements = operationStrategy.buildUpsertFulltext(
|
|
417
538
|
params,
|
|
418
539
|
timestamp
|
|
@@ -429,7 +550,7 @@ function createPostgresOperationBackend(options) {
|
|
|
429
550
|
},
|
|
430
551
|
async upsertFulltextBatch(params) {
|
|
431
552
|
if (params.rows.length === 0) return;
|
|
432
|
-
const timestamp =
|
|
553
|
+
const timestamp = chunkO2P3KAUT_cjs.nowIso();
|
|
433
554
|
const statements = operationStrategy.buildUpsertFulltextBatch(
|
|
434
555
|
params,
|
|
435
556
|
timestamp
|
|
@@ -457,20 +578,22 @@ function createPostgresOperationBackend(options) {
|
|
|
457
578
|
},
|
|
458
579
|
async dropVectorIndex(params) {
|
|
459
580
|
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"
|
|
581
|
+
await Promise.all(
|
|
582
|
+
metrics.map(async (metric) => {
|
|
583
|
+
const indexName = chunkO2P3KAUT_cjs.generateVectorIndexName(
|
|
584
|
+
params.graphId,
|
|
585
|
+
params.nodeKind,
|
|
586
|
+
params.fieldPath,
|
|
587
|
+
metric
|
|
471
588
|
);
|
|
472
|
-
|
|
473
|
-
|
|
589
|
+
const result = await chunkO2P3KAUT_cjs.dropPostgresVectorIndex(db, indexName);
|
|
590
|
+
if (!result.success) {
|
|
591
|
+
throw new Error(
|
|
592
|
+
result.message ?? "Failed to drop PostgreSQL vector index"
|
|
593
|
+
);
|
|
594
|
+
}
|
|
595
|
+
})
|
|
596
|
+
);
|
|
474
597
|
},
|
|
475
598
|
// === Query Execution ===
|
|
476
599
|
async execute(query) {
|
|
@@ -496,39 +619,39 @@ function createTransactionBackend(options) {
|
|
|
496
619
|
|
|
497
620
|
Object.defineProperty(exports, "createPostgresTables", {
|
|
498
621
|
enumerable: true,
|
|
499
|
-
get: function () { return
|
|
622
|
+
get: function () { return chunkO2P3KAUT_cjs.createPostgresTables; }
|
|
500
623
|
});
|
|
501
624
|
Object.defineProperty(exports, "edges", {
|
|
502
625
|
enumerable: true,
|
|
503
|
-
get: function () { return
|
|
626
|
+
get: function () { return chunkO2P3KAUT_cjs.edges; }
|
|
504
627
|
});
|
|
505
628
|
Object.defineProperty(exports, "embeddings", {
|
|
506
629
|
enumerable: true,
|
|
507
|
-
get: function () { return
|
|
630
|
+
get: function () { return chunkO2P3KAUT_cjs.embeddings; }
|
|
508
631
|
});
|
|
509
632
|
Object.defineProperty(exports, "generatePostgresDDL", {
|
|
510
633
|
enumerable: true,
|
|
511
|
-
get: function () { return
|
|
634
|
+
get: function () { return chunkO2P3KAUT_cjs.generatePostgresDDL; }
|
|
512
635
|
});
|
|
513
636
|
Object.defineProperty(exports, "generatePostgresMigrationSQL", {
|
|
514
637
|
enumerable: true,
|
|
515
|
-
get: function () { return
|
|
638
|
+
get: function () { return chunkO2P3KAUT_cjs.generatePostgresMigrationSQL; }
|
|
516
639
|
});
|
|
517
640
|
Object.defineProperty(exports, "nodes", {
|
|
518
641
|
enumerable: true,
|
|
519
|
-
get: function () { return
|
|
642
|
+
get: function () { return chunkO2P3KAUT_cjs.nodes; }
|
|
520
643
|
});
|
|
521
644
|
Object.defineProperty(exports, "schemaVersions", {
|
|
522
645
|
enumerable: true,
|
|
523
|
-
get: function () { return
|
|
646
|
+
get: function () { return chunkO2P3KAUT_cjs.schemaVersions; }
|
|
524
647
|
});
|
|
525
648
|
Object.defineProperty(exports, "tables", {
|
|
526
649
|
enumerable: true,
|
|
527
|
-
get: function () { return
|
|
650
|
+
get: function () { return chunkO2P3KAUT_cjs.tables; }
|
|
528
651
|
});
|
|
529
652
|
Object.defineProperty(exports, "uniques", {
|
|
530
653
|
enumerable: true,
|
|
531
|
-
get: function () { return
|
|
654
|
+
get: function () { return chunkO2P3KAUT_cjs.uniques; }
|
|
532
655
|
});
|
|
533
656
|
exports.createPostgresBackend = createPostgresBackend;
|
|
534
657
|
//# sourceMappingURL=index.cjs.map
|