@nicia-ai/typegraph 0.28.0 → 0.28.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 +55 -55
- package/dist/backend/postgres/index.js +3 -3
- package/dist/backend/sqlite/index.cjs +13 -13
- package/dist/backend/sqlite/index.js +3 -3
- package/dist/backend/sqlite/libsql.cjs +6 -6
- package/dist/backend/sqlite/libsql.js +3 -3
- package/dist/backend/sqlite/local.cjs +6 -6
- package/dist/backend/sqlite/local.js +3 -3
- package/dist/{chunk-X53YKGHR.js → chunk-5MTOKWDA.js} +3 -3
- package/dist/{chunk-X53YKGHR.js.map → chunk-5MTOKWDA.js.map} +1 -1
- package/dist/chunk-FFHW2JEK.cjs +55 -0
- package/dist/chunk-FFHW2JEK.cjs.map +1 -0
- package/dist/{chunk-33K3ZYFG.cjs → chunk-NMOE2ZEU.cjs} +44 -44
- package/dist/{chunk-33K3ZYFG.cjs.map → chunk-NMOE2ZEU.cjs.map} +1 -1
- package/dist/{chunk-2E4VTD2E.cjs → chunk-NYQFPGYP.cjs} +5 -5
- package/dist/{chunk-2E4VTD2E.cjs.map → chunk-NYQFPGYP.cjs.map} +1 -1
- package/dist/chunk-O57GYGYK.js +51 -0
- package/dist/chunk-O57GYGYK.js.map +1 -0
- package/dist/{chunk-UKG7XHZ3.js → chunk-PGU2XKMA.js} +3 -3
- package/dist/{chunk-UKG7XHZ3.js.map → chunk-PGU2XKMA.js.map} +1 -1
- package/dist/{chunk-DFHLG75V.js → chunk-TKM2WDT4.js} +3 -3
- package/dist/{chunk-DFHLG75V.js.map → chunk-TKM2WDT4.js.map} +1 -1
- package/dist/{chunk-ZGEMI7MJ.cjs → chunk-WZH2MKHW.cjs} +15 -15
- package/dist/{chunk-ZGEMI7MJ.cjs.map → chunk-WZH2MKHW.cjs.map} +1 -1
- package/dist/index.cjs +64 -64
- package/dist/index.js +3 -3
- package/dist/schema/index.cjs +26 -26
- package/dist/schema/index.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-5H3BAMTB.js +0 -32
- package/dist/chunk-5H3BAMTB.js.map +0 -1
- package/dist/chunk-IUIWCFG3.cjs +0 -36
- package/dist/chunk-IUIWCFG3.cjs.map +0 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/schema/canonical.ts
|
|
4
|
+
function sortedReplacer(_key, value) {
|
|
5
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
6
|
+
const sorted = {};
|
|
7
|
+
for (const key of Object.keys(value).toSorted()) {
|
|
8
|
+
sorted[key] = value[key];
|
|
9
|
+
}
|
|
10
|
+
return sorted;
|
|
11
|
+
}
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
function canonicalEqual(a, b) {
|
|
15
|
+
return JSON.stringify(a, sortedReplacer) === JSON.stringify(b, sortedReplacer);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// src/utils/sql-errors.ts
|
|
19
|
+
var MISSING_TABLE_PATTERNS = [
|
|
20
|
+
"no such table",
|
|
21
|
+
// SQLite
|
|
22
|
+
"does not exist",
|
|
23
|
+
// PostgreSQL ("relation ... does not exist")
|
|
24
|
+
"SQLITE_ERROR"
|
|
25
|
+
// D1 / Durable Objects error code
|
|
26
|
+
];
|
|
27
|
+
var POSTGRES_UNDEFINED_TABLE_CODE = "42P01";
|
|
28
|
+
function* errorChain(error) {
|
|
29
|
+
const seen = /* @__PURE__ */ new Set();
|
|
30
|
+
let current = error;
|
|
31
|
+
while (current !== void 0 && current !== null && !seen.has(current)) {
|
|
32
|
+
seen.add(current);
|
|
33
|
+
yield current;
|
|
34
|
+
current = current instanceof Error ? current.cause : void 0;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function isPostgresUndefinedTable(link) {
|
|
38
|
+
return typeof link === "object" && link !== null && "code" in link && link.code === POSTGRES_UNDEFINED_TABLE_CODE;
|
|
39
|
+
}
|
|
40
|
+
function isMissingTableError(error) {
|
|
41
|
+
for (const link of errorChain(error)) {
|
|
42
|
+
if (isPostgresUndefinedTable(link)) return true;
|
|
43
|
+
const message = link instanceof Error ? link.message : String(link);
|
|
44
|
+
if (MISSING_TABLE_PATTERNS.some((pattern) => message.includes(pattern))) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
exports.canonicalEqual = canonicalEqual;
|
|
52
|
+
exports.isMissingTableError = isMissingTableError;
|
|
53
|
+
exports.sortedReplacer = sortedReplacer;
|
|
54
|
+
//# sourceMappingURL=chunk-FFHW2JEK.cjs.map
|
|
55
|
+
//# sourceMappingURL=chunk-FFHW2JEK.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schema/canonical.ts","../src/utils/sql-errors.ts"],"names":[],"mappings":";;;AAiBO,SAAS,cAAA,CAAe,MAAc,KAAA,EAAyB;AACpE,EAAA,IAAI,KAAA,KAAU,QAAQ,OAAO,KAAA,KAAU,YAAY,CAAC,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,EAAG;AACxE,IAAA,MAAM,SAAkC,EAAC;AACzC,IAAA,KAAA,MAAW,OAAO,MAAA,CAAO,IAAA,CAAK,KAAK,CAAA,CAAE,UAAS,EAAG;AAC/C,MAAA,MAAA,CAAO,GAAG,CAAA,GAAK,KAAA,CAAkC,GAAG,CAAA;AAAA,IACtD;AACA,IAAA,OAAO,MAAA;AAAA,EACT;AACA,EAAA,OAAO,KAAA;AACT;AAaO,SAAS,cAAA,CAAe,GAAY,CAAA,EAAqB;AAC9D,EAAA,OACE,IAAA,CAAK,UAAU,CAAA,EAAG,cAAc,MAAM,IAAA,CAAK,SAAA,CAAU,GAAG,cAAc,CAAA;AAE1E;;;ACtBA,IAAM,sBAAA,GAAyB;AAAA,EAC7B,eAAA;AAAA;AAAA,EACA,gBAAA;AAAA;AAAA,EACA;AAAA;AACF,CAAA;AASA,IAAM,6BAAA,GAAgC,OAAA;AAOtC,UAAU,WAAW,KAAA,EAAgD;AACnE,EAAA,MAAM,IAAA,uBAAW,GAAA,EAAa;AAC9B,EAAA,IAAI,OAAA,GAAmB,KAAA;AACvB,EAAA,OAAO,OAAA,KAAY,UAAa,OAAA,KAAY,IAAA,IAAQ,CAAC,IAAA,CAAK,GAAA,CAAI,OAAO,CAAA,EAAG;AACtE,IAAA,IAAA,CAAK,IAAI,OAAO,CAAA;AAChB,IAAA,MAAM,OAAA;AACN,IAAA,OAAA,GAAU,OAAA,YAAmB,KAAA,GAAQ,OAAA,CAAQ,KAAA,GAAQ,MAAA;AAAA,EACvD;AACF;AAMA,SAAS,yBAAyB,IAAA,EAAwB;AACxD,EAAA,OACE,OAAO,SAAS,QAAA,IAChB,IAAA,KAAS,QACT,MAAA,IAAU,IAAA,IACT,KAAsC,IAAA,KACrC,6BAAA;AAEN;AAEO,SAAS,oBAAoB,KAAA,EAAyB;AAC3D,EAAA,KAAA,MAAW,IAAA,IAAQ,UAAA,CAAW,KAAK,CAAA,EAAG;AACpC,IAAA,IAAI,wBAAA,CAAyB,IAAI,CAAA,EAAG,OAAO,IAAA;AAC3C,IAAA,MAAM,UAAU,IAAA,YAAgB,KAAA,GAAQ,IAAA,CAAK,OAAA,GAAU,OAAO,IAAI,CAAA;AAClE,IAAA,IAAI,sBAAA,CAAuB,KAAK,CAAC,OAAA,KAAY,QAAQ,QAAA,CAAS,OAAO,CAAC,CAAA,EAAG;AACvE,MAAA,OAAO,IAAA;AAAA,IACT;AAAA,EACF;AACA,EAAA,OAAO,KAAA;AACT","file":"chunk-FFHW2JEK.cjs","sourcesContent":["/**\n * Canonical-form helpers for deterministic schema serialization.\n *\n * Used by both content-hashing (`computeSchemaHash`) and structural diffing\n * (`computeSchemaDiff`) to ensure that semantically-equivalent objects with\n * differently-ordered keys produce identical canonical strings.\n */\n\n/**\n * `JSON.stringify` replacer that sorts object keys recursively.\n *\n * Apply via `JSON.stringify(value, sortedReplacer)` to obtain output in\n * which sibling keys at every depth appear in lexicographic order.\n *\n * Arrays are passed through unchanged — array order is semantically\n * meaningful and must not be normalized.\n */\nexport function sortedReplacer(_key: string, value: unknown): unknown {\n if (value !== null && typeof value === \"object\" && !Array.isArray(value)) {\n const sorted: Record<string, unknown> = {};\n for (const key of Object.keys(value).toSorted()) {\n sorted[key] = (value as Record<string, unknown>)[key];\n }\n return sorted;\n }\n return value;\n}\n\n/**\n * Compare two values for canonical-form equality.\n *\n * Returns `true` when both values produce identical JSON under `sortedReplacer`\n * — i.e., they have the same JSON structure regardless of object key order.\n * Used by diff machinery to detect semantic changes in JSON-shaped fields.\n *\n * Note: callers must handle `undefined` themselves — `JSON.stringify(undefined)`\n * returns `undefined`, so two `undefined` inputs would compare equal here, which\n * may or may not be the desired semantics depending on context.\n */\nexport function canonicalEqual(a: unknown, b: unknown): boolean {\n return (\n JSON.stringify(a, sortedReplacer) === JSON.stringify(b, sortedReplacer)\n );\n}\n","/**\n * Cross-dialect detection of \"this relation does not exist yet\" errors.\n *\n * Shared so the schema bootstrap (`loadActiveSchemaWithBootstrap`) and\n * the durable contribution-materialization gate (#135) agree on what a\n * missing-table failure looks like, and — critically — so neither one\n * swallows a genuine system fault (connection/permission/driver error)\n * as a benign \"not bootstrapped yet\".\n *\n * Detection walks the error's `cause` chain because Drizzle (>= the\n * `DrizzleQueryError` era, drizzle-orm ≥ 0.36) wraps every failure from a\n * query-builder call (`db.select()`, `db.insert()`, …): the wrapper's\n * `.message` becomes the failed query text and the real driver error —\n * which carries both the missing-relation text and the SQLSTATE — is\n * preserved on `.cause`. node-postgres / postgres-js nest the pg error\n * one link deep; better-sqlite3 throws it unwrapped; raw `client.query()`\n * fast paths surface it directly. Walking the chain makes the check\n * wrapper- and driver-agnostic instead of only matching the outermost\n * `.message`, which on Postgres is just the SQL string.\n */\n\nconst MISSING_TABLE_PATTERNS = [\n \"no such table\", // SQLite\n \"does not exist\", // PostgreSQL (\"relation ... does not exist\")\n \"SQLITE_ERROR\", // D1 / Durable Objects error code\n] as const;\n\n/**\n * SQLSTATE for PostgreSQL `undefined_table`. Preferred over the\n * human-readable message: it is locale-independent (the \"... does not\n * exist\" text is translated under a non-English `lc_messages`) and is\n * preserved on the underlying driver error even when Drizzle overwrites\n * `.message` with the query text.\n */\nconst POSTGRES_UNDEFINED_TABLE_CODE = \"42P01\";\n\n/**\n * Yields an error and each error reachable by following `.cause`,\n * outermost first. `seen` guards the pathological cyclic-cause case so a\n * self-referential chain can't spin forever.\n */\nfunction* errorChain(error: unknown): Generator<unknown, void, void> {\n const seen = new Set<unknown>();\n let current: unknown = error;\n while (current !== undefined && current !== null && !seen.has(current)) {\n seen.add(current);\n yield current;\n current = current instanceof Error ? current.cause : undefined;\n }\n}\n\n/**\n * Whether a single chain link is a PostgreSQL `undefined_table` failure,\n * identified by its SQLSTATE rather than a message substring.\n */\nfunction isPostgresUndefinedTable(link: unknown): boolean {\n return (\n typeof link === \"object\" &&\n link !== null &&\n \"code\" in link &&\n (link as Readonly<{ code?: unknown }>).code ===\n POSTGRES_UNDEFINED_TABLE_CODE\n );\n}\n\nexport function isMissingTableError(error: unknown): boolean {\n for (const link of errorChain(error)) {\n if (isPostgresUndefinedTable(link)) return true;\n const message = link instanceof Error ? link.message : String(link);\n if (MISSING_TABLE_PATTERNS.some((pattern) => message.includes(pattern))) {\n return true;\n }\n }\n return false;\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkNYQFPGYP_cjs = require('./chunk-NYQFPGYP.cjs');
|
|
4
4
|
var chunkLYRUNG6E_cjs = require('./chunk-LYRUNG6E.cjs');
|
|
5
5
|
var chunkPN37HVAV_cjs = require('./chunk-PN37HVAV.cjs');
|
|
6
6
|
var chunkYEDQLNVE_cjs = require('./chunk-YEDQLNVE.cjs');
|
|
@@ -70,7 +70,7 @@ function resolveSqliteClient(db) {
|
|
|
70
70
|
return sqliteClient;
|
|
71
71
|
}
|
|
72
72
|
function getOrCreatePreparedStatement(cache, sqliteClient, sqlText, cacheMax) {
|
|
73
|
-
return
|
|
73
|
+
return chunkNYQFPGYP_cjs.getOrCreateLru(
|
|
74
74
|
cache,
|
|
75
75
|
sqlText,
|
|
76
76
|
cacheMax,
|
|
@@ -106,7 +106,7 @@ function createSqliteExecutionAdapter(db, statementCacheMaxOrOptions = {}) {
|
|
|
106
106
|
supportsCompiledExecution: sqliteClient !== void 0,
|
|
107
107
|
transactionMode
|
|
108
108
|
};
|
|
109
|
-
const compile = (query) =>
|
|
109
|
+
const compile = (query) => chunkNYQFPGYP_cjs.compileQueryWithDialect(db, query, "SQLite");
|
|
110
110
|
if (sqliteClient !== void 0) {
|
|
111
111
|
let executeCompiled2 = function(compiledQuery) {
|
|
112
112
|
const preparedStatement = getOrCreatePreparedStatement(
|
|
@@ -177,10 +177,10 @@ var SQLITE_CHECK_UNIQUE_BATCH_CHUNK_SIZE = Math.max(
|
|
|
177
177
|
1,
|
|
178
178
|
SQLITE_MAX_BIND_PARAMETERS - CHECK_UNIQUE_BATCH_FIXED_PARAM_COUNT
|
|
179
179
|
);
|
|
180
|
-
var toNodeRow =
|
|
181
|
-
var toEdgeRow =
|
|
182
|
-
var toUniqueRow =
|
|
183
|
-
var toSchemaVersionRow =
|
|
180
|
+
var toNodeRow = chunkNYQFPGYP_cjs.createNodeRowMapper(chunkNYQFPGYP_cjs.SQLITE_ROW_MAPPER_CONFIG);
|
|
181
|
+
var toEdgeRow = chunkNYQFPGYP_cjs.createEdgeRowMapper(chunkNYQFPGYP_cjs.SQLITE_ROW_MAPPER_CONFIG);
|
|
182
|
+
var toUniqueRow = chunkNYQFPGYP_cjs.createUniqueRowMapper(chunkNYQFPGYP_cjs.SQLITE_ROW_MAPPER_CONFIG);
|
|
183
|
+
var toSchemaVersionRow = chunkNYQFPGYP_cjs.createSchemaVersionRowMapper(chunkNYQFPGYP_cjs.SQLITE_ROW_MAPPER_CONFIG);
|
|
184
184
|
var PENDING_FOREVER = new Promise(noop);
|
|
185
185
|
function pendingForever() {
|
|
186
186
|
return PENDING_FOREVER;
|
|
@@ -272,7 +272,7 @@ function createSqliteOperationBackend(options) {
|
|
|
272
272
|
await db.run(query);
|
|
273
273
|
});
|
|
274
274
|
}
|
|
275
|
-
const commonBackend =
|
|
275
|
+
const commonBackend = chunkNYQFPGYP_cjs.createCommonOperationBackend({
|
|
276
276
|
batchConfig: {
|
|
277
277
|
checkUniqueBatchChunkSize: SQLITE_CHECK_UNIQUE_BATCH_CHUNK_SIZE,
|
|
278
278
|
edgeInsertBatchSize: SQLITE_EDGE_INSERT_BATCH_SIZE,
|
|
@@ -285,7 +285,7 @@ function createSqliteOperationBackend(options) {
|
|
|
285
285
|
execGet,
|
|
286
286
|
execRun
|
|
287
287
|
},
|
|
288
|
-
nowIso:
|
|
288
|
+
nowIso: chunkNYQFPGYP_cjs.nowIso,
|
|
289
289
|
operationStrategy,
|
|
290
290
|
rowMappers: {
|
|
291
291
|
toEdgeRow,
|
|
@@ -307,7 +307,7 @@ function createSqliteOperationBackend(options) {
|
|
|
307
307
|
async upsertEmbedding(params) {
|
|
308
308
|
const query = operationStrategy.buildUpsertEmbedding(
|
|
309
309
|
params,
|
|
310
|
-
|
|
310
|
+
chunkNYQFPGYP_cjs.nowIso()
|
|
311
311
|
);
|
|
312
312
|
await execRun(query);
|
|
313
313
|
},
|
|
@@ -346,14 +346,14 @@ function createSqliteOperationBackend(options) {
|
|
|
346
346
|
...params.indexParams?.efConstruction === void 0 ? {} : { hnswEfConstruction: params.indexParams.efConstruction },
|
|
347
347
|
...params.indexParams?.lists === void 0 ? {} : { ivfflatLists: params.indexParams.lists }
|
|
348
348
|
};
|
|
349
|
-
const result =
|
|
349
|
+
const result = chunkNYQFPGYP_cjs.createSqliteVectorIndex(indexOptions);
|
|
350
350
|
if (!result.success) {
|
|
351
351
|
throw new Error(result.message ?? "Failed to create SQLite vector index");
|
|
352
352
|
}
|
|
353
353
|
return Promise.resolve();
|
|
354
354
|
},
|
|
355
355
|
dropVectorIndex(params) {
|
|
356
|
-
const result =
|
|
356
|
+
const result = chunkNYQFPGYP_cjs.dropSqliteVectorIndex(
|
|
357
357
|
params.graphId,
|
|
358
358
|
params.nodeKind,
|
|
359
359
|
params.fieldPath
|
|
@@ -365,7 +365,7 @@ function createSqliteOperationBackend(options) {
|
|
|
365
365
|
},
|
|
366
366
|
// === Fulltext Operations ===
|
|
367
367
|
async upsertFulltext(params) {
|
|
368
|
-
const timestamp =
|
|
368
|
+
const timestamp = chunkNYQFPGYP_cjs.nowIso();
|
|
369
369
|
const statements = operationStrategy.buildUpsertFulltext(
|
|
370
370
|
params,
|
|
371
371
|
timestamp
|
|
@@ -382,7 +382,7 @@ function createSqliteOperationBackend(options) {
|
|
|
382
382
|
},
|
|
383
383
|
async upsertFulltextBatch(params) {
|
|
384
384
|
if (params.rows.length === 0) return;
|
|
385
|
-
const timestamp =
|
|
385
|
+
const timestamp = chunkNYQFPGYP_cjs.nowIso();
|
|
386
386
|
const statements = operationStrategy.buildUpsertFulltextBatch(
|
|
387
387
|
params,
|
|
388
388
|
timestamp
|
|
@@ -403,7 +403,7 @@ function createSqliteOperationBackend(options) {
|
|
|
403
403
|
const rows = await execAll(query);
|
|
404
404
|
return rows.map((row, index) => ({
|
|
405
405
|
nodeId: row.node_id,
|
|
406
|
-
score:
|
|
406
|
+
score: chunkNYQFPGYP_cjs.coerceNumericScore(row.score),
|
|
407
407
|
rank: index + 1,
|
|
408
408
|
...row.snippet === null ? {} : { snippet: row.snippet }
|
|
409
409
|
}));
|
|
@@ -422,7 +422,7 @@ function createSqliteOperationBackend(options) {
|
|
|
422
422
|
return operationBackend;
|
|
423
423
|
}
|
|
424
424
|
function createSqliteBackend(db, options = {}) {
|
|
425
|
-
const tables2 = options.tables ??
|
|
425
|
+
const tables2 = options.tables ?? chunkNYQFPGYP_cjs.tables2;
|
|
426
426
|
const fulltextStrategy = options.fulltext ?? chunkPN37HVAV_cjs.fts5Strategy;
|
|
427
427
|
const profileHints = options.executionProfile ?? {};
|
|
428
428
|
const executionAdapter = createSqliteExecutionAdapter(db, { profileHints });
|
|
@@ -440,7 +440,7 @@ function createSqliteBackend(db, options = {}) {
|
|
|
440
440
|
fulltext: tables2.fulltextTableName,
|
|
441
441
|
uniques: drizzleOrm.getTableName(tables2.uniques)
|
|
442
442
|
};
|
|
443
|
-
const operationStrategy =
|
|
443
|
+
const operationStrategy = chunkNYQFPGYP_cjs.createSqliteOperationStrategy(
|
|
444
444
|
tables2,
|
|
445
445
|
fulltextStrategy
|
|
446
446
|
);
|
|
@@ -529,7 +529,7 @@ function createSqliteBackend(db, options = {}) {
|
|
|
529
529
|
}
|
|
530
530
|
const matTable = tables2.contributionMaterializations;
|
|
531
531
|
async function ensureContributionMaterializationsTableImpl() {
|
|
532
|
-
await db.run(drizzleOrm.sql.raw(
|
|
532
|
+
await db.run(drizzleOrm.sql.raw(chunkNYQFPGYP_cjs.generateSqliteCreateTableSQL(matTable)));
|
|
533
533
|
}
|
|
534
534
|
async function getContributionMaterializationRow(identity) {
|
|
535
535
|
const rows = await db.select().from(matTable).where(
|
|
@@ -542,16 +542,16 @@ function createSqliteBackend(db, options = {}) {
|
|
|
542
542
|
);
|
|
543
543
|
const row = rows[0];
|
|
544
544
|
if (row === void 0) return void 0;
|
|
545
|
-
return
|
|
545
|
+
return chunkNYQFPGYP_cjs.mapContributionMaterializationRow(
|
|
546
546
|
row,
|
|
547
|
-
|
|
547
|
+
chunkNYQFPGYP_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.decode
|
|
548
548
|
);
|
|
549
549
|
}
|
|
550
550
|
async function recordContributionMaterializationRow(params) {
|
|
551
551
|
await db.insert(matTable).values(
|
|
552
|
-
|
|
552
|
+
chunkNYQFPGYP_cjs.buildContributionInsertValues(
|
|
553
553
|
params,
|
|
554
|
-
|
|
554
|
+
chunkNYQFPGYP_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.encode
|
|
555
555
|
)
|
|
556
556
|
).onConflictDoUpdate({
|
|
557
557
|
target: [
|
|
@@ -560,13 +560,13 @@ function createSqliteBackend(db, options = {}) {
|
|
|
560
560
|
matTable.owner,
|
|
561
561
|
matTable.tableName
|
|
562
562
|
],
|
|
563
|
-
set:
|
|
563
|
+
set: chunkNYQFPGYP_cjs.buildContributionOnConflictSet(
|
|
564
564
|
matTable.materializedAt,
|
|
565
565
|
params.materializedAt
|
|
566
566
|
)
|
|
567
567
|
});
|
|
568
568
|
}
|
|
569
|
-
const contributionMaterializer =
|
|
569
|
+
const contributionMaterializer = chunkNYQFPGYP_cjs.createContributionMaterializer({
|
|
570
570
|
dialect: "sqlite",
|
|
571
571
|
fulltextStrategy,
|
|
572
572
|
fulltextTableName: tables2.fulltextTableName,
|
|
@@ -587,12 +587,12 @@ function createSqliteBackend(db, options = {}) {
|
|
|
587
587
|
fulltextStrategy,
|
|
588
588
|
hasVectorEmbeddings
|
|
589
589
|
});
|
|
590
|
-
return
|
|
590
|
+
return chunkNYQFPGYP_cjs.gateFulltext(txBackend, contributionMaterializer.assertInitialized);
|
|
591
591
|
}
|
|
592
592
|
const backend = {
|
|
593
593
|
...operations,
|
|
594
594
|
async bootstrapTables() {
|
|
595
|
-
const statements =
|
|
595
|
+
const statements = chunkNYQFPGYP_cjs.generateSqliteDDL(tables2, fulltextStrategy);
|
|
596
596
|
for (const statement of statements) {
|
|
597
597
|
await db.run(drizzleOrm.sql.raw(statement));
|
|
598
598
|
}
|
|
@@ -602,7 +602,7 @@ function createSqliteBackend(db, options = {}) {
|
|
|
602
602
|
// uninitialized database throws `StoreNotInitializedError` rather
|
|
603
603
|
// than self-healing (#135). Shared verbatim with the tx-scoped gate
|
|
604
604
|
// via `gateFulltextMethods`.
|
|
605
|
-
...
|
|
605
|
+
...chunkNYQFPGYP_cjs.gateFulltextMethods(
|
|
606
606
|
operations,
|
|
607
607
|
contributionMaterializer.assertInitialized
|
|
608
608
|
),
|
|
@@ -611,7 +611,7 @@ function createSqliteBackend(db, options = {}) {
|
|
|
611
611
|
},
|
|
612
612
|
async ensureIndexMaterializationsTable() {
|
|
613
613
|
await db.run(
|
|
614
|
-
drizzleOrm.sql.raw(
|
|
614
|
+
drizzleOrm.sql.raw(chunkNYQFPGYP_cjs.generateSqliteCreateTableSQL(tables2.indexMaterializations))
|
|
615
615
|
);
|
|
616
616
|
},
|
|
617
617
|
async getIndexMaterialization(indexName) {
|
|
@@ -619,26 +619,26 @@ function createSqliteBackend(db, options = {}) {
|
|
|
619
619
|
const rows = await db.select().from(t).where(drizzleOrm.eq(t.indexName, indexName));
|
|
620
620
|
const row = rows[0];
|
|
621
621
|
if (row === void 0) return void 0;
|
|
622
|
-
return
|
|
622
|
+
return chunkNYQFPGYP_cjs.mapMaterializationRow(row, chunkNYQFPGYP_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode);
|
|
623
623
|
},
|
|
624
624
|
async getIndexMaterializations(statusKeys) {
|
|
625
625
|
if (statusKeys.length === 0) return [];
|
|
626
626
|
const t = tables2.indexMaterializations;
|
|
627
627
|
const rows = await db.select().from(t).where(drizzleOrm.inArray(t.indexName, [...statusKeys]));
|
|
628
628
|
return rows.map(
|
|
629
|
-
(row) =>
|
|
629
|
+
(row) => chunkNYQFPGYP_cjs.mapMaterializationRow(row, chunkNYQFPGYP_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode)
|
|
630
630
|
);
|
|
631
631
|
},
|
|
632
632
|
async recordIndexMaterialization(params) {
|
|
633
633
|
const t = tables2.indexMaterializations;
|
|
634
634
|
await db.insert(t).values(
|
|
635
|
-
|
|
635
|
+
chunkNYQFPGYP_cjs.buildMaterializationInsertValues(
|
|
636
636
|
params,
|
|
637
|
-
|
|
637
|
+
chunkNYQFPGYP_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.encode
|
|
638
638
|
)
|
|
639
639
|
).onConflictDoUpdate({
|
|
640
640
|
target: t.indexName,
|
|
641
|
-
set:
|
|
641
|
+
set: chunkNYQFPGYP_cjs.buildMaterializationOnConflictSet(
|
|
642
642
|
t.materializedAt,
|
|
643
643
|
params.materializedAt
|
|
644
644
|
)
|
|
@@ -657,37 +657,37 @@ function createSqliteBackend(db, options = {}) {
|
|
|
657
657
|
await contributionMaterializer.assertInitialized(graphId);
|
|
658
658
|
},
|
|
659
659
|
async ensureKindRemovalsTable() {
|
|
660
|
-
await db.run(drizzleOrm.sql.raw(
|
|
660
|
+
await db.run(drizzleOrm.sql.raw(chunkNYQFPGYP_cjs.generateSqliteCreateTableSQL(tables2.kindRemovals)));
|
|
661
661
|
},
|
|
662
662
|
async getPendingKindRemovals(graphId) {
|
|
663
663
|
const t = tables2.kindRemovals;
|
|
664
664
|
const rows = await db.select().from(t).where(drizzleOrm.and(drizzleOrm.eq(t.graphId, graphId), drizzleOrm.isNull(t.removedAt)));
|
|
665
665
|
return rows.map(
|
|
666
|
-
(row) =>
|
|
666
|
+
(row) => chunkNYQFPGYP_cjs.mapKindRemovalRow(row, chunkNYQFPGYP_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
|
|
667
667
|
);
|
|
668
668
|
},
|
|
669
669
|
async getAllKindRemovals(graphId) {
|
|
670
670
|
const t = tables2.kindRemovals;
|
|
671
671
|
const rows = await db.select().from(t).where(drizzleOrm.eq(t.graphId, graphId));
|
|
672
672
|
return rows.map(
|
|
673
|
-
(row) =>
|
|
673
|
+
(row) => chunkNYQFPGYP_cjs.mapKindRemovalRow(row, chunkNYQFPGYP_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
|
|
674
674
|
);
|
|
675
675
|
},
|
|
676
676
|
async recordKindRemoval(params) {
|
|
677
677
|
const t = tables2.kindRemovals;
|
|
678
678
|
await db.insert(t).values(
|
|
679
|
-
|
|
679
|
+
chunkNYQFPGYP_cjs.buildKindRemovalInsertValues(
|
|
680
680
|
params,
|
|
681
|
-
|
|
681
|
+
chunkNYQFPGYP_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.encode
|
|
682
682
|
)
|
|
683
683
|
).onConflictDoUpdate({
|
|
684
684
|
target: [t.graphId, t.kindName, t.entity, t.schemaVersion],
|
|
685
|
-
set:
|
|
685
|
+
set: chunkNYQFPGYP_cjs.buildKindRemovalOnConflictSet(t.removedAt, params.removedAt)
|
|
686
686
|
});
|
|
687
687
|
},
|
|
688
688
|
async ensureReconciliationMarkersTable() {
|
|
689
689
|
await db.run(
|
|
690
|
-
drizzleOrm.sql.raw(
|
|
690
|
+
drizzleOrm.sql.raw(chunkNYQFPGYP_cjs.generateSqliteCreateTableSQL(tables2.reconciliationMarkers))
|
|
691
691
|
);
|
|
692
692
|
},
|
|
693
693
|
async ensureRuntimeContributions(graphId) {
|
|
@@ -747,7 +747,7 @@ function createSqliteBackend(db, options = {}) {
|
|
|
747
747
|
db.run(drizzleOrm.sql`BEGIN`);
|
|
748
748
|
try {
|
|
749
749
|
const result = await fn(
|
|
750
|
-
|
|
750
|
+
chunkNYQFPGYP_cjs.gateFulltext(
|
|
751
751
|
txBackend,
|
|
752
752
|
contributionMaterializer.assertInitialized
|
|
753
753
|
),
|
|
@@ -779,7 +779,7 @@ function createSqliteBackend(db, options = {}) {
|
|
|
779
779
|
"Cross-store atomicity is unavailable on this SQLite backend: transactions are disabled (transactionMode: 'none'). Adopting an external transaction here would let the caller's relational write commit with no way to roll back the graph write. Configure a driver that supports transactions (better-sqlite3, libsql, bun:sqlite)."
|
|
780
780
|
);
|
|
781
781
|
}
|
|
782
|
-
|
|
782
|
+
chunkNYQFPGYP_cjs.assertAdoptedDialect(
|
|
783
783
|
externalTx,
|
|
784
784
|
sqliteCore.BaseSQLiteDatabase,
|
|
785
785
|
"sqlite"
|
|
@@ -809,5 +809,5 @@ function createTransactionBackend(options) {
|
|
|
809
809
|
}
|
|
810
810
|
|
|
811
811
|
exports.createSqliteBackend = createSqliteBackend;
|
|
812
|
-
//# sourceMappingURL=chunk-
|
|
813
|
-
//# sourceMappingURL=chunk-
|
|
812
|
+
//# sourceMappingURL=chunk-NMOE2ZEU.cjs.map
|
|
813
|
+
//# sourceMappingURL=chunk-NMOE2ZEU.cjs.map
|