@nicia-ai/typegraph 0.25.0 → 0.26.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.
Files changed (122) hide show
  1. package/dist/backend/postgres/index.cjs +167 -71
  2. package/dist/backend/postgres/index.cjs.map +1 -1
  3. package/dist/backend/postgres/index.d.cts +6 -8
  4. package/dist/backend/postgres/index.d.ts +6 -8
  5. package/dist/backend/postgres/index.js +119 -27
  6. package/dist/backend/postgres/index.js.map +1 -1
  7. package/dist/backend/sqlite/index.cjs +16 -15
  8. package/dist/backend/sqlite/index.d.cts +11 -26
  9. package/dist/backend/sqlite/index.d.ts +11 -26
  10. package/dist/backend/sqlite/index.js +6 -5
  11. package/dist/backend/sqlite/libsql.cjs +9 -8
  12. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  13. package/dist/backend/sqlite/libsql.d.cts +4 -3
  14. package/dist/backend/sqlite/libsql.d.ts +4 -3
  15. package/dist/backend/sqlite/libsql.js +6 -5
  16. package/dist/backend/sqlite/libsql.js.map +1 -1
  17. package/dist/backend/sqlite/local.cjs +11 -10
  18. package/dist/backend/sqlite/local.cjs.map +1 -1
  19. package/dist/backend/sqlite/local.d.cts +4 -3
  20. package/dist/backend/sqlite/local.d.ts +4 -3
  21. package/dist/backend/sqlite/local.js +6 -5
  22. package/dist/backend/sqlite/local.js.map +1 -1
  23. package/dist/{chunk-LVCSL6A3.js → chunk-3W6AIFT2.js} +11 -34
  24. package/dist/chunk-3W6AIFT2.js.map +1 -0
  25. package/dist/chunk-4FJVSF3K.cjs +12 -0
  26. package/dist/{chunk-D2GO3RBL.cjs.map → chunk-4FJVSF3K.cjs.map} +1 -1
  27. package/dist/{chunk-7W3KAMVQ.cjs → chunk-4TJI44WP.cjs} +94 -119
  28. package/dist/chunk-4TJI44WP.cjs.map +1 -0
  29. package/dist/chunk-5H3BAMTB.js +32 -0
  30. package/dist/chunk-5H3BAMTB.js.map +1 -0
  31. package/dist/{chunk-OJ6IQVZG.js → chunk-DDVA4QBA.js} +177 -37
  32. package/dist/chunk-DDVA4QBA.js.map +1 -0
  33. package/dist/{chunk-7CDXX3QZ.cjs → chunk-DN4RUDF3.cjs} +2 -2
  34. package/dist/chunk-DN4RUDF3.cjs.map +1 -0
  35. package/dist/{chunk-NHQWXSTS.js → chunk-E5ROA3MN.js} +3 -3
  36. package/dist/{chunk-NHQWXSTS.js.map → chunk-E5ROA3MN.js.map} +1 -1
  37. package/dist/{chunk-FPCOUJSL.js → chunk-ENXJLDRK.js} +2 -2
  38. package/dist/chunk-ENXJLDRK.js.map +1 -0
  39. package/dist/chunk-IUIWCFG3.cjs +36 -0
  40. package/dist/chunk-IUIWCFG3.cjs.map +1 -0
  41. package/dist/{chunk-EG6TJ3I5.js → chunk-OYLF3IC7.js} +3 -3
  42. package/dist/{chunk-EG6TJ3I5.js.map → chunk-OYLF3IC7.js.map} +1 -1
  43. package/dist/{chunk-JTI5WT4P.cjs → chunk-PN37HVAV.cjs} +32 -10
  44. package/dist/chunk-PN37HVAV.cjs.map +1 -0
  45. package/dist/{chunk-RCAJZG67.cjs → chunk-PYJOBZR3.cjs} +10 -10
  46. package/dist/{chunk-RCAJZG67.cjs.map → chunk-PYJOBZR3.cjs.map} +1 -1
  47. package/dist/{chunk-WI5VRP3X.js → chunk-RF5EUQWS.js} +371 -47
  48. package/dist/chunk-RF5EUQWS.js.map +1 -0
  49. package/dist/{chunk-ZEMNF3QK.cjs → chunk-RVT2N4RF.cjs} +209 -69
  50. package/dist/chunk-RVT2N4RF.cjs.map +1 -0
  51. package/dist/{chunk-4BOWVUGQ.js → chunk-TSGBRPNE.js} +3 -3
  52. package/dist/{chunk-4BOWVUGQ.js.map → chunk-TSGBRPNE.js.map} +1 -1
  53. package/dist/{chunk-O2P3KAUT.cjs → chunk-TVUARC7S.cjs} +445 -110
  54. package/dist/chunk-TVUARC7S.cjs.map +1 -0
  55. package/dist/{chunk-DOTEN2FG.js → chunk-U5ROKVRF.js} +26 -3
  56. package/dist/chunk-U5ROKVRF.js.map +1 -0
  57. package/dist/{chunk-E5JZSEGJ.cjs → chunk-WFUN6DCM.cjs} +8 -8
  58. package/dist/{chunk-E5JZSEGJ.cjs.map → chunk-WFUN6DCM.cjs.map} +1 -1
  59. package/dist/{chunk-W5MTHMTE.cjs → chunk-YEDQLNVE.cjs} +26 -2
  60. package/dist/chunk-YEDQLNVE.cjs.map +1 -0
  61. package/dist/{chunk-YZZBDCLV.js → chunk-ZTREJOGB.js} +32 -11
  62. package/dist/chunk-ZTREJOGB.js.map +1 -0
  63. package/dist/{ddl-B2jjLjpR.d.cts → ddl-9kw8UADK.d.ts} +697 -29
  64. package/dist/{ddl-DpaeAKPp.d.ts → ddl-Cw82BPM4.d.cts} +697 -29
  65. package/dist/{extension-types-D07e_NTw.d.cts → extension-types-B78CZfA5.d.cts} +1 -1
  66. package/dist/{extension-types-D07e_NTw.d.ts → extension-types-B78CZfA5.d.ts} +1 -1
  67. package/dist/graph-extension/index.cjs +18 -18
  68. package/dist/graph-extension/index.d.cts +4 -4
  69. package/dist/graph-extension/index.d.ts +4 -4
  70. package/dist/graph-extension/index.js +3 -3
  71. package/dist/{index-CT6nvtxL.d.cts → index-Bilw0pYm.d.cts} +34 -3
  72. package/dist/{index-DQheiVQV.d.ts → index-CWdBFWbI.d.ts} +34 -3
  73. package/dist/index.cjs +460 -361
  74. package/dist/index.cjs.map +1 -1
  75. package/dist/index.d.cts +13 -11
  76. package/dist/index.d.ts +13 -11
  77. package/dist/index.js +131 -36
  78. package/dist/index.js.map +1 -1
  79. package/dist/indexes/index.cjs +13 -13
  80. package/dist/indexes/index.d.cts +5 -5
  81. package/dist/indexes/index.d.ts +5 -5
  82. package/dist/indexes/index.js +1 -1
  83. package/dist/interchange/index.cjs +7 -7
  84. package/dist/interchange/index.d.cts +7 -5
  85. package/dist/interchange/index.d.ts +7 -5
  86. package/dist/interchange/index.js +2 -2
  87. package/dist/{manager-BpjBW1JK.d.cts → manager-Aqzmztkb.d.cts} +11 -3
  88. package/dist/{manager-BKaPQbns.d.ts → manager-C3LxzPcX.d.ts} +11 -3
  89. package/dist/{materialize-indexes-BB9N5uQl.d.cts → materialize-indexes-BQfaAZKA.d.cts} +1 -1
  90. package/dist/{materialize-indexes-BYpU2RKh.d.ts → materialize-indexes-DFavFQah.d.ts} +1 -1
  91. package/dist/profiler/index.d.cts +9 -7
  92. package/dist/profiler/index.d.ts +9 -7
  93. package/dist/schema/index.cjs +28 -27
  94. package/dist/schema/index.cjs.map +1 -1
  95. package/dist/schema/index.d.cts +9 -7
  96. package/dist/schema/index.d.ts +9 -7
  97. package/dist/schema/index.js +6 -5
  98. package/dist/schema/index.js.map +1 -1
  99. package/dist/{sqlite-Myo8e3Lr.d.cts → sqlite-BvSEbybu.d.cts} +320 -1
  100. package/dist/{sqlite-CU3j6rc7.d.ts → sqlite-GKvcDPVn.d.ts} +320 -1
  101. package/dist/{store-BAGuOHDh.d.cts → store-CiS_AGNH.d.ts} +112 -4
  102. package/dist/{store-De98Lod4.d.ts → store-DbQLsSor.d.cts} +112 -4
  103. package/dist/{types-CYga3lZp.d.cts → types-CF7nDH3q.d.cts} +2 -2
  104. package/dist/{types-BLmJq4wI.d.ts → types-Cars4JZ1.d.ts} +2 -2
  105. package/dist/{types--0EslBx5.d.cts → types-DZPBXZOK.d.cts} +275 -8
  106. package/dist/{types-BNWYZ-0-.d.ts → types-Dzkr0Eqi.d.ts} +275 -8
  107. package/dist/{where-m1uWsdua.d.cts → where-BmtjfWuS.d.cts} +2 -2
  108. package/dist/{where-CluR73rs.d.ts → where-kk1Zz2En.d.ts} +2 -2
  109. package/package.json +3 -1
  110. package/dist/chunk-7CDXX3QZ.cjs.map +0 -1
  111. package/dist/chunk-7W3KAMVQ.cjs.map +0 -1
  112. package/dist/chunk-D2GO3RBL.cjs +0 -12
  113. package/dist/chunk-DOTEN2FG.js.map +0 -1
  114. package/dist/chunk-FPCOUJSL.js.map +0 -1
  115. package/dist/chunk-JTI5WT4P.cjs.map +0 -1
  116. package/dist/chunk-LVCSL6A3.js.map +0 -1
  117. package/dist/chunk-O2P3KAUT.cjs.map +0 -1
  118. package/dist/chunk-OJ6IQVZG.js.map +0 -1
  119. package/dist/chunk-W5MTHMTE.cjs.map +0 -1
  120. package/dist/chunk-WI5VRP3X.js.map +0 -1
  121. package/dist/chunk-YZZBDCLV.js.map +0 -1
  122. package/dist/chunk-ZEMNF3QK.cjs.map +0 -1
@@ -1,10 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var chunkO2P3KAUT_cjs = require('./chunk-O2P3KAUT.cjs');
4
- var chunk7CDXX3QZ_cjs = require('./chunk-7CDXX3QZ.cjs');
5
- var chunkJTI5WT4P_cjs = require('./chunk-JTI5WT4P.cjs');
6
- var chunkW5MTHMTE_cjs = require('./chunk-W5MTHMTE.cjs');
3
+ var chunkTVUARC7S_cjs = require('./chunk-TVUARC7S.cjs');
4
+ var chunkDN4RUDF3_cjs = require('./chunk-DN4RUDF3.cjs');
5
+ var chunkPN37HVAV_cjs = require('./chunk-PN37HVAV.cjs');
6
+ var chunkYEDQLNVE_cjs = require('./chunk-YEDQLNVE.cjs');
7
7
  var drizzleOrm = require('drizzle-orm');
8
+ var sqliteCore = require('drizzle-orm/sqlite-core');
8
9
 
9
10
  var DEFAULT_PREPARED_STATEMENT_CACHE_MAX = 256;
10
11
  function getSessionName(db) {
@@ -20,7 +21,7 @@ function isD1DatabaseBySessionName(db) {
20
21
  }
21
22
  function isDurableObjectBySessionName(db) {
22
23
  const sessionName = getSessionName(db);
23
- return sessionName === "SQLiteDurableObjectSession";
24
+ return sessionName === "SQLiteDOSession" || sessionName === "SQLiteDurableObjectSession";
24
25
  }
25
26
  function isSyncDatabaseBySessionName(db) {
26
27
  const sessionName = getSessionName(db);
@@ -34,6 +35,9 @@ function detectSyncProfile(db, profileHints) {
34
35
  if (sessionName === "BetterSQLiteSession" || sessionName === "BunSQLiteSession") {
35
36
  return true;
36
37
  }
38
+ if (isDurableObjectBySessionName(db)) {
39
+ return true;
40
+ }
37
41
  if (sessionName === "SQLiteD1Session") {
38
42
  return false;
39
43
  }
@@ -48,7 +52,10 @@ function detectTransactionMode(db, profileHints, isSync) {
48
52
  if (profileHints.transactionMode !== void 0) {
49
53
  return profileHints.transactionMode;
50
54
  }
51
- if (isD1DatabaseBySessionName(db) || isDurableObjectBySessionName(db)) {
55
+ if (isDurableObjectBySessionName(db)) {
56
+ return "do-sqlite";
57
+ }
58
+ if (isD1DatabaseBySessionName(db)) {
52
59
  return "none";
53
60
  }
54
61
  if (isSync) return "sql";
@@ -63,7 +70,7 @@ function resolveSqliteClient(db) {
63
70
  return sqliteClient;
64
71
  }
65
72
  function getOrCreatePreparedStatement(cache, sqliteClient, sqlText, cacheMax) {
66
- return chunkO2P3KAUT_cjs.getOrCreateLru(
73
+ return chunkTVUARC7S_cjs.getOrCreateLru(
67
74
  cache,
68
75
  sqlText,
69
76
  cacheMax,
@@ -99,7 +106,7 @@ function createSqliteExecutionAdapter(db, statementCacheMaxOrOptions = {}) {
99
106
  supportsCompiledExecution: sqliteClient !== void 0,
100
107
  transactionMode
101
108
  };
102
- const compile = (query) => chunkO2P3KAUT_cjs.compileQueryWithDialect(db, query, "SQLite");
109
+ const compile = (query) => chunkTVUARC7S_cjs.compileQueryWithDialect(db, query, "SQLite");
103
110
  if (sqliteClient !== void 0) {
104
111
  let executeCompiled2 = function(compiledQuery) {
105
112
  const preparedStatement = getOrCreatePreparedStatement(
@@ -170,10 +177,10 @@ var SQLITE_CHECK_UNIQUE_BATCH_CHUNK_SIZE = Math.max(
170
177
  1,
171
178
  SQLITE_MAX_BIND_PARAMETERS - CHECK_UNIQUE_BATCH_FIXED_PARAM_COUNT
172
179
  );
173
- var toNodeRow = chunkO2P3KAUT_cjs.createNodeRowMapper(chunkO2P3KAUT_cjs.SQLITE_ROW_MAPPER_CONFIG);
174
- var toEdgeRow = chunkO2P3KAUT_cjs.createEdgeRowMapper(chunkO2P3KAUT_cjs.SQLITE_ROW_MAPPER_CONFIG);
175
- var toUniqueRow = chunkO2P3KAUT_cjs.createUniqueRowMapper(chunkO2P3KAUT_cjs.SQLITE_ROW_MAPPER_CONFIG);
176
- var toSchemaVersionRow = chunkO2P3KAUT_cjs.createSchemaVersionRowMapper(chunkO2P3KAUT_cjs.SQLITE_ROW_MAPPER_CONFIG);
180
+ var toNodeRow = chunkTVUARC7S_cjs.createNodeRowMapper(chunkTVUARC7S_cjs.SQLITE_ROW_MAPPER_CONFIG);
181
+ var toEdgeRow = chunkTVUARC7S_cjs.createEdgeRowMapper(chunkTVUARC7S_cjs.SQLITE_ROW_MAPPER_CONFIG);
182
+ var toUniqueRow = chunkTVUARC7S_cjs.createUniqueRowMapper(chunkTVUARC7S_cjs.SQLITE_ROW_MAPPER_CONFIG);
183
+ var toSchemaVersionRow = chunkTVUARC7S_cjs.createSchemaVersionRowMapper(chunkTVUARC7S_cjs.SQLITE_ROW_MAPPER_CONFIG);
177
184
  var PENDING_FOREVER = new Promise(noop);
178
185
  function pendingForever() {
179
186
  return PENDING_FOREVER;
@@ -191,7 +198,7 @@ function createSerializedExecutionQueue() {
191
198
  disposed = true;
192
199
  },
193
200
  runExclusive(task) {
194
- if (isDisposed()) return Promise.reject(new chunkW5MTHMTE_cjs.BackendDisposedError());
201
+ if (isDisposed()) return Promise.reject(new chunkYEDQLNVE_cjs.BackendDisposedError());
195
202
  const runTask = async () => {
196
203
  if (isDisposed()) return pendingForever();
197
204
  try {
@@ -217,11 +224,18 @@ function runWithSerializedQueue(queue, task) {
217
224
  var SQLITE_VECTOR_METRICS = ["cosine", "l2"];
218
225
  var SQLITE_VECTOR_INDEX_TYPES = ["none"];
219
226
  var SQLITE_VECTOR_MAX_DIMENSIONS = 8e3;
227
+ function throwSqliteTransactionsDisabled(message) {
228
+ throw new chunkYEDQLNVE_cjs.ConfigurationError(message, {
229
+ backend: "sqlite",
230
+ capability: "transactions",
231
+ supportsTransactions: false
232
+ });
233
+ }
220
234
  function buildSqliteCapabilities(options) {
221
- const base = options.transactionMode === "none" ? { ...chunk7CDXX3QZ_cjs.SQLITE_CAPABILITIES, transactions: false } : chunk7CDXX3QZ_cjs.SQLITE_CAPABILITIES;
235
+ const base = options.transactionMode === "none" ? { ...chunkDN4RUDF3_cjs.SQLITE_CAPABILITIES, transactions: false } : chunkDN4RUDF3_cjs.SQLITE_CAPABILITIES;
222
236
  return {
223
237
  ...base,
224
- fulltext: chunkJTI5WT4P_cjs.buildFulltextCapabilities(options.fulltextStrategy),
238
+ fulltext: chunkPN37HVAV_cjs.buildFulltextCapabilities(options.fulltextStrategy),
225
239
  ...options.hasVectorEmbeddings ? {
226
240
  vector: {
227
241
  supported: true,
@@ -258,7 +272,7 @@ function createSqliteOperationBackend(options) {
258
272
  await db.run(query);
259
273
  });
260
274
  }
261
- const commonBackend = chunkO2P3KAUT_cjs.createCommonOperationBackend({
275
+ const commonBackend = chunkTVUARC7S_cjs.createCommonOperationBackend({
262
276
  batchConfig: {
263
277
  checkUniqueBatchChunkSize: SQLITE_CHECK_UNIQUE_BATCH_CHUNK_SIZE,
264
278
  edgeInsertBatchSize: SQLITE_EDGE_INSERT_BATCH_SIZE,
@@ -271,7 +285,7 @@ function createSqliteOperationBackend(options) {
271
285
  execGet,
272
286
  execRun
273
287
  },
274
- nowIso: chunkO2P3KAUT_cjs.nowIso,
288
+ nowIso: chunkTVUARC7S_cjs.nowIso,
275
289
  operationStrategy,
276
290
  rowMappers: {
277
291
  toEdgeRow,
@@ -293,7 +307,7 @@ function createSqliteOperationBackend(options) {
293
307
  async upsertEmbedding(params) {
294
308
  const query = operationStrategy.buildUpsertEmbedding(
295
309
  params,
296
- chunkO2P3KAUT_cjs.nowIso()
310
+ chunkTVUARC7S_cjs.nowIso()
297
311
  );
298
312
  await execRun(query);
299
313
  },
@@ -332,14 +346,14 @@ function createSqliteOperationBackend(options) {
332
346
  ...params.indexParams?.efConstruction === void 0 ? {} : { hnswEfConstruction: params.indexParams.efConstruction },
333
347
  ...params.indexParams?.lists === void 0 ? {} : { ivfflatLists: params.indexParams.lists }
334
348
  };
335
- const result = chunkO2P3KAUT_cjs.createSqliteVectorIndex(indexOptions);
349
+ const result = chunkTVUARC7S_cjs.createSqliteVectorIndex(indexOptions);
336
350
  if (!result.success) {
337
351
  throw new Error(result.message ?? "Failed to create SQLite vector index");
338
352
  }
339
353
  return Promise.resolve();
340
354
  },
341
355
  dropVectorIndex(params) {
342
- const result = chunkO2P3KAUT_cjs.dropSqliteVectorIndex(
356
+ const result = chunkTVUARC7S_cjs.dropSqliteVectorIndex(
343
357
  params.graphId,
344
358
  params.nodeKind,
345
359
  params.fieldPath
@@ -351,7 +365,7 @@ function createSqliteOperationBackend(options) {
351
365
  },
352
366
  // === Fulltext Operations ===
353
367
  async upsertFulltext(params) {
354
- const timestamp = chunkO2P3KAUT_cjs.nowIso();
368
+ const timestamp = chunkTVUARC7S_cjs.nowIso();
355
369
  const statements = operationStrategy.buildUpsertFulltext(
356
370
  params,
357
371
  timestamp
@@ -368,7 +382,7 @@ function createSqliteOperationBackend(options) {
368
382
  },
369
383
  async upsertFulltextBatch(params) {
370
384
  if (params.rows.length === 0) return;
371
- const timestamp = chunkO2P3KAUT_cjs.nowIso();
385
+ const timestamp = chunkTVUARC7S_cjs.nowIso();
372
386
  const statements = operationStrategy.buildUpsertFulltextBatch(
373
387
  params,
374
388
  timestamp
@@ -389,7 +403,7 @@ function createSqliteOperationBackend(options) {
389
403
  const rows = await execAll(query);
390
404
  return rows.map((row, index) => ({
391
405
  nodeId: row.node_id,
392
- score: row.score,
406
+ score: chunkTVUARC7S_cjs.coerceNumericScore(row.score),
393
407
  rank: index + 1,
394
408
  ...row.snippet === null ? {} : { snippet: row.snippet }
395
409
  }));
@@ -408,8 +422,8 @@ function createSqliteOperationBackend(options) {
408
422
  return operationBackend;
409
423
  }
410
424
  function createSqliteBackend(db, options = {}) {
411
- const tables2 = options.tables ?? chunkO2P3KAUT_cjs.tables2;
412
- const fulltextStrategy = options.fulltext ?? chunkJTI5WT4P_cjs.fts5Strategy;
425
+ const tables2 = options.tables ?? chunkTVUARC7S_cjs.tables2;
426
+ const fulltextStrategy = options.fulltext ?? chunkPN37HVAV_cjs.fts5Strategy;
413
427
  const profileHints = options.executionProfile ?? {};
414
428
  const executionAdapter = createSqliteExecutionAdapter(db, { profileHints });
415
429
  const { isSync, transactionMode } = executionAdapter.profile;
@@ -426,7 +440,7 @@ function createSqliteBackend(db, options = {}) {
426
440
  fulltext: tables2.fulltextTableName,
427
441
  uniques: drizzleOrm.getTableName(tables2.uniques)
428
442
  };
429
- const operationStrategy = chunkO2P3KAUT_cjs.createSqliteOperationStrategy(
443
+ const operationStrategy = chunkTVUARC7S_cjs.createSqliteOperationStrategy(
430
444
  tables2,
431
445
  fulltextStrategy
432
446
  );
@@ -441,15 +455,23 @@ function createSqliteBackend(db, options = {}) {
441
455
  hasVectorEmbeddings,
442
456
  ...serializedQueue === void 0 ? {} : { serializedQueue }
443
457
  });
458
+ function runDoSqliteStorageTransaction(run) {
459
+ const storage = db.$client;
460
+ const storageTransaction = storage?.transaction;
461
+ if (typeof storageTransaction !== "function") {
462
+ throwSqliteTransactionsDisabled(
463
+ "transactionMode 'do-sqlite' requires a Drizzle Durable Objects database (drizzle(ctx.storage)) whose `$client` exposes the async storage `transaction(async () => ...)` runner."
464
+ );
465
+ }
466
+ return runWithSerializedQueue(
467
+ serializedQueue,
468
+ async () => storageTransaction.call(storage, run)
469
+ );
470
+ }
444
471
  function runSchemaWriteTransaction(fn) {
445
472
  if (transactionMode === "none") {
446
- throw new chunkW5MTHMTE_cjs.ConfigurationError(
447
- "commitSchemaVersion and setActiveVersion require atomic transactions, but this SQLite backend has transactions disabled. Configure a driver that supports transactions (better-sqlite3, libsql, bun:sqlite) to use schema commits.",
448
- {
449
- backend: "sqlite",
450
- capability: "transactions",
451
- supportsTransactions: false
452
- }
473
+ throwSqliteTransactionsDisabled(
474
+ "commitSchemaVersion and setActiveVersion require atomic transactions, but this SQLite backend has transactions disabled. Configure a driver that supports transactions (better-sqlite3, libsql, bun:sqlite) to use schema commits."
453
475
  );
454
476
  }
455
477
  if (transactionMode === "sql") {
@@ -475,6 +497,20 @@ function createSqliteBackend(db, options = {}) {
475
497
  }
476
498
  });
477
499
  }
500
+ if (transactionMode === "do-sqlite") {
501
+ return runDoSqliteStorageTransaction(async () => {
502
+ const txBackend = createTransactionBackend({
503
+ capabilities,
504
+ db,
505
+ operationStrategy,
506
+ profileHints: { isSync },
507
+ tableNames,
508
+ fulltextStrategy,
509
+ hasVectorEmbeddings
510
+ });
511
+ return fn(txBackend);
512
+ });
513
+ }
478
514
  return runWithSerializedQueue(
479
515
  serializedQueue,
480
516
  async () => db.transaction(async (tx) => {
@@ -491,20 +527,91 @@ function createSqliteBackend(db, options = {}) {
491
527
  }, { behavior: "immediate" })
492
528
  );
493
529
  }
530
+ const matTable = tables2.contributionMaterializations;
531
+ async function ensureContributionMaterializationsTableImpl() {
532
+ await db.run(drizzleOrm.sql.raw(chunkTVUARC7S_cjs.generateSqliteCreateTableSQL(matTable)));
533
+ }
534
+ async function getContributionMaterializationRow(identity) {
535
+ const rows = await db.select().from(matTable).where(
536
+ drizzleOrm.and(
537
+ drizzleOrm.eq(matTable.graphId, identity.graphId),
538
+ drizzleOrm.eq(matTable.logicalName, identity.logicalName),
539
+ drizzleOrm.eq(matTable.owner, identity.owner),
540
+ drizzleOrm.eq(matTable.tableName, identity.tableName)
541
+ )
542
+ );
543
+ const row = rows[0];
544
+ if (row === void 0) return void 0;
545
+ return chunkTVUARC7S_cjs.mapContributionMaterializationRow(
546
+ row,
547
+ chunkTVUARC7S_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.decode
548
+ );
549
+ }
550
+ async function recordContributionMaterializationRow(params) {
551
+ await db.insert(matTable).values(
552
+ chunkTVUARC7S_cjs.buildContributionInsertValues(
553
+ params,
554
+ chunkTVUARC7S_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.encode
555
+ )
556
+ ).onConflictDoUpdate({
557
+ target: [
558
+ matTable.graphId,
559
+ matTable.logicalName,
560
+ matTable.owner,
561
+ matTable.tableName
562
+ ],
563
+ set: chunkTVUARC7S_cjs.buildContributionOnConflictSet(
564
+ matTable.materializedAt,
565
+ params.materializedAt
566
+ )
567
+ });
568
+ }
569
+ const contributionMaterializer = chunkTVUARC7S_cjs.createContributionMaterializer({
570
+ dialect: "sqlite",
571
+ fulltextStrategy,
572
+ fulltextTableName: tables2.fulltextTableName,
573
+ execDdl: async (statement) => {
574
+ await db.run(drizzleOrm.sql.raw(statement));
575
+ },
576
+ ensureMarkerTable: ensureContributionMaterializationsTableImpl,
577
+ getMarker: getContributionMaterializationRow,
578
+ recordMarker: recordContributionMaterializationRow
579
+ });
580
+ function bindTransactionBackend(tx) {
581
+ const txBackend = createTransactionBackend({
582
+ capabilities,
583
+ db: tx,
584
+ operationStrategy,
585
+ profileHints: { isSync },
586
+ tableNames,
587
+ fulltextStrategy,
588
+ hasVectorEmbeddings
589
+ });
590
+ return chunkTVUARC7S_cjs.gateFulltext(txBackend, contributionMaterializer.assertInitialized);
591
+ }
494
592
  const backend = {
495
593
  ...operations,
496
594
  async bootstrapTables() {
497
- const statements = chunkO2P3KAUT_cjs.generateSqliteDDL(tables2, fulltextStrategy);
595
+ const statements = chunkTVUARC7S_cjs.generateSqliteDDL(tables2, fulltextStrategy);
498
596
  for (const statement of statements) {
499
597
  await db.run(drizzleOrm.sql.raw(statement));
500
598
  }
501
599
  },
600
+ // Every fulltext-touching method asserts the durable marker instead
601
+ // of lazily emitting DDL. Steady state performs zero ensure; an
602
+ // uninitialized database throws `StoreNotInitializedError` rather
603
+ // than self-healing (#135). Shared verbatim with the tx-scoped gate
604
+ // via `gateFulltextMethods`.
605
+ ...chunkTVUARC7S_cjs.gateFulltextMethods(
606
+ operations,
607
+ contributionMaterializer.assertInitialized
608
+ ),
502
609
  async executeDdl(ddl) {
503
610
  await db.run(drizzleOrm.sql.raw(ddl));
504
611
  },
505
612
  async ensureIndexMaterializationsTable() {
506
613
  await db.run(
507
- drizzleOrm.sql.raw(chunkO2P3KAUT_cjs.generateSqliteCreateTableSQL(tables2.indexMaterializations))
614
+ drizzleOrm.sql.raw(chunkTVUARC7S_cjs.generateSqliteCreateTableSQL(tables2.indexMaterializations))
508
615
  );
509
616
  },
510
617
  async getIndexMaterialization(indexName) {
@@ -512,65 +619,88 @@ function createSqliteBackend(db, options = {}) {
512
619
  const rows = await db.select().from(t).where(drizzleOrm.eq(t.indexName, indexName));
513
620
  const row = rows[0];
514
621
  if (row === void 0) return void 0;
515
- return chunkO2P3KAUT_cjs.mapMaterializationRow(row, chunkO2P3KAUT_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode);
622
+ return chunkTVUARC7S_cjs.mapMaterializationRow(row, chunkTVUARC7S_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode);
516
623
  },
517
624
  async getIndexMaterializations(statusKeys) {
518
625
  if (statusKeys.length === 0) return [];
519
626
  const t = tables2.indexMaterializations;
520
627
  const rows = await db.select().from(t).where(drizzleOrm.inArray(t.indexName, [...statusKeys]));
521
628
  return rows.map(
522
- (row) => chunkO2P3KAUT_cjs.mapMaterializationRow(row, chunkO2P3KAUT_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode)
629
+ (row) => chunkTVUARC7S_cjs.mapMaterializationRow(row, chunkTVUARC7S_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode)
523
630
  );
524
631
  },
525
632
  async recordIndexMaterialization(params) {
526
633
  const t = tables2.indexMaterializations;
527
634
  await db.insert(t).values(
528
- chunkO2P3KAUT_cjs.buildMaterializationInsertValues(
635
+ chunkTVUARC7S_cjs.buildMaterializationInsertValues(
529
636
  params,
530
- chunkO2P3KAUT_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.encode
637
+ chunkTVUARC7S_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.encode
531
638
  )
532
639
  ).onConflictDoUpdate({
533
640
  target: t.indexName,
534
- set: chunkO2P3KAUT_cjs.buildMaterializationOnConflictSet(
641
+ set: chunkTVUARC7S_cjs.buildMaterializationOnConflictSet(
535
642
  t.materializedAt,
536
643
  params.materializedAt
537
644
  )
538
645
  });
539
646
  },
647
+ async ensureContributionMaterializationsTable() {
648
+ await ensureContributionMaterializationsTableImpl();
649
+ },
650
+ async getContributionMaterialization(identity) {
651
+ return getContributionMaterializationRow(identity);
652
+ },
653
+ async recordContributionMaterialization(params) {
654
+ await recordContributionMaterializationRow(params);
655
+ },
656
+ async assertRuntimeContributionsInitialized(graphId) {
657
+ await contributionMaterializer.assertInitialized(graphId);
658
+ },
540
659
  async ensureKindRemovalsTable() {
541
- await db.run(drizzleOrm.sql.raw(chunkO2P3KAUT_cjs.generateSqliteCreateTableSQL(tables2.kindRemovals)));
660
+ await db.run(drizzleOrm.sql.raw(chunkTVUARC7S_cjs.generateSqliteCreateTableSQL(tables2.kindRemovals)));
542
661
  },
543
662
  async getPendingKindRemovals(graphId) {
544
663
  const t = tables2.kindRemovals;
545
664
  const rows = await db.select().from(t).where(drizzleOrm.and(drizzleOrm.eq(t.graphId, graphId), drizzleOrm.isNull(t.removedAt)));
546
665
  return rows.map(
547
- (row) => chunkO2P3KAUT_cjs.mapKindRemovalRow(row, chunkO2P3KAUT_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
666
+ (row) => chunkTVUARC7S_cjs.mapKindRemovalRow(row, chunkTVUARC7S_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
548
667
  );
549
668
  },
550
669
  async getAllKindRemovals(graphId) {
551
670
  const t = tables2.kindRemovals;
552
671
  const rows = await db.select().from(t).where(drizzleOrm.eq(t.graphId, graphId));
553
672
  return rows.map(
554
- (row) => chunkO2P3KAUT_cjs.mapKindRemovalRow(row, chunkO2P3KAUT_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
673
+ (row) => chunkTVUARC7S_cjs.mapKindRemovalRow(row, chunkTVUARC7S_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
555
674
  );
556
675
  },
557
676
  async recordKindRemoval(params) {
558
677
  const t = tables2.kindRemovals;
559
678
  await db.insert(t).values(
560
- chunkO2P3KAUT_cjs.buildKindRemovalInsertValues(
679
+ chunkTVUARC7S_cjs.buildKindRemovalInsertValues(
561
680
  params,
562
- chunkO2P3KAUT_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.encode
681
+ chunkTVUARC7S_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.encode
563
682
  )
564
683
  ).onConflictDoUpdate({
565
684
  target: [t.graphId, t.kindName, t.entity, t.schemaVersion],
566
- set: chunkO2P3KAUT_cjs.buildKindRemovalOnConflictSet(t.removedAt, params.removedAt)
685
+ set: chunkTVUARC7S_cjs.buildKindRemovalOnConflictSet(t.removedAt, params.removedAt)
567
686
  });
568
687
  },
569
688
  async ensureReconciliationMarkersTable() {
570
689
  await db.run(
571
- drizzleOrm.sql.raw(chunkO2P3KAUT_cjs.generateSqliteCreateTableSQL(tables2.reconciliationMarkers))
690
+ drizzleOrm.sql.raw(chunkTVUARC7S_cjs.generateSqliteCreateTableSQL(tables2.reconciliationMarkers))
572
691
  );
573
692
  },
693
+ async ensureRuntimeContributions(graphId) {
694
+ await contributionMaterializer.ensureRuntimeContributions(graphId);
695
+ },
696
+ /**
697
+ * Superseded by `ensureRuntimeContributions(graphId)` (#129).
698
+ * Retained as a thin back-compat wrapper for callers predating
699
+ * #129; #135 routed it through the durable-marker writer.
700
+ */
701
+ async ensureFulltextTable(graphId) {
702
+ await contributionMaterializer.ensureRuntimeContributions(graphId);
703
+ },
574
704
  async getReconciliationMarker(graphId) {
575
705
  const t = tables2.reconciliationMarkers;
576
706
  const rows = await db.select().from(t).where(drizzleOrm.eq(t.graphId, graphId));
@@ -598,13 +728,8 @@ function createSqliteBackend(db, options = {}) {
598
728
  },
599
729
  async transaction(fn, _options) {
600
730
  if (transactionMode === "none") {
601
- throw new chunkW5MTHMTE_cjs.ConfigurationError(
602
- "This SQLite backend does not support atomic transactions. Operations within a transaction are not rolled back on failure. Use backend.capabilities.transactions to check for transaction support, or use individual operations with manual error handling.",
603
- {
604
- backend: "sqlite",
605
- capability: "transactions",
606
- supportsTransactions: false
607
- }
731
+ throwSqliteTransactionsDisabled(
732
+ "This SQLite backend does not support atomic transactions. Operations within a transaction are not rolled back on failure. Use backend.capabilities.transactions to check for transaction support, or use individual operations with manual error handling."
608
733
  );
609
734
  }
610
735
  if (transactionMode === "sql") {
@@ -621,7 +746,13 @@ function createSqliteBackend(db, options = {}) {
621
746
  });
622
747
  db.run(drizzleOrm.sql`BEGIN`);
623
748
  try {
624
- const result = await fn(txBackend);
749
+ const result = await fn(
750
+ chunkTVUARC7S_cjs.gateFulltext(
751
+ txBackend,
752
+ contributionMaterializer.assertInitialized
753
+ ),
754
+ db
755
+ );
625
756
  db.run(drizzleOrm.sql`COMMIT`);
626
757
  return result;
627
758
  } catch (error) {
@@ -630,21 +761,30 @@ function createSqliteBackend(db, options = {}) {
630
761
  }
631
762
  });
632
763
  }
764
+ if (transactionMode === "do-sqlite") {
765
+ return runDoSqliteStorageTransaction(
766
+ async () => fn(bindTransactionBackend(db), db)
767
+ );
768
+ }
633
769
  return runWithSerializedQueue(
634
770
  serializedQueue,
635
- async () => db.transaction(async (tx) => {
636
- const txBackend = createTransactionBackend({
637
- capabilities,
638
- db: tx,
639
- operationStrategy,
640
- profileHints: { isSync },
641
- tableNames,
642
- fulltextStrategy,
643
- hasVectorEmbeddings
644
- });
645
- return fn(txBackend);
646
- })
771
+ async () => db.transaction(
772
+ async (tx) => fn(bindTransactionBackend(tx), tx)
773
+ )
774
+ );
775
+ },
776
+ adoptTransaction(externalTx) {
777
+ if (transactionMode === "none") {
778
+ throwSqliteTransactionsDisabled(
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
+ );
781
+ }
782
+ chunkTVUARC7S_cjs.assertAdoptedDialect(
783
+ externalTx,
784
+ sqliteCore.BaseSQLiteDatabase,
785
+ "sqlite"
647
786
  );
787
+ return bindTransactionBackend(externalTx);
648
788
  },
649
789
  close() {
650
790
  serializedQueue?.dispose();
@@ -669,5 +809,5 @@ function createTransactionBackend(options) {
669
809
  }
670
810
 
671
811
  exports.createSqliteBackend = createSqliteBackend;
672
- //# sourceMappingURL=chunk-ZEMNF3QK.cjs.map
673
- //# sourceMappingURL=chunk-ZEMNF3QK.cjs.map
812
+ //# sourceMappingURL=chunk-RVT2N4RF.cjs.map
813
+ //# sourceMappingURL=chunk-RVT2N4RF.cjs.map