@nicia-ai/typegraph 0.28.0 → 0.29.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 (174) hide show
  1. package/dist/backend/postgres/index.cjs +23 -761
  2. package/dist/backend/postgres/index.cjs.map +1 -1
  3. package/dist/backend/postgres/index.d.cts +24 -5
  4. package/dist/backend/postgres/index.d.ts +24 -5
  5. package/dist/backend/postgres/index.js +10 -752
  6. package/dist/backend/postgres/index.js.map +1 -1
  7. package/dist/backend/postgres/pglite.cjs +52 -0
  8. package/dist/backend/postgres/pglite.cjs.map +1 -0
  9. package/dist/backend/postgres/pglite.d.cts +116 -0
  10. package/dist/backend/postgres/pglite.d.ts +116 -0
  11. package/dist/backend/postgres/pglite.js +50 -0
  12. package/dist/backend/postgres/pglite.js.map +1 -0
  13. package/dist/backend/sqlite/index.cjs +22 -26
  14. package/dist/backend/sqlite/index.d.cts +17 -15
  15. package/dist/backend/sqlite/index.d.ts +17 -15
  16. package/dist/backend/sqlite/index.js +9 -9
  17. package/dist/backend/sqlite/libsql.cjs +17 -13
  18. package/dist/backend/sqlite/libsql.cjs.map +1 -1
  19. package/dist/backend/sqlite/libsql.d.cts +3 -3
  20. package/dist/backend/sqlite/libsql.d.ts +3 -3
  21. package/dist/backend/sqlite/libsql.js +16 -12
  22. package/dist/backend/sqlite/libsql.js.map +1 -1
  23. package/dist/backend/sqlite/local.cjs +17 -16
  24. package/dist/backend/sqlite/local.cjs.map +1 -1
  25. package/dist/backend/sqlite/local.d.cts +3 -3
  26. package/dist/backend/sqlite/local.d.ts +3 -3
  27. package/dist/backend/sqlite/local.js +15 -14
  28. package/dist/backend/sqlite/local.js.map +1 -1
  29. package/dist/{chunk-DFHLG75V.js → chunk-3DTLDGIM.js} +386 -1093
  30. package/dist/chunk-3DTLDGIM.js.map +1 -0
  31. package/dist/{chunk-WVQXAFP3.js → chunk-454I6GDF.js} +46 -5
  32. package/dist/chunk-454I6GDF.js.map +1 -0
  33. package/dist/chunk-4K6IHUW6.cjs +183 -0
  34. package/dist/chunk-4K6IHUW6.cjs.map +1 -0
  35. package/dist/{chunk-ZTREJOGB.js → chunk-7KLVFWXR.js} +113 -68
  36. package/dist/chunk-7KLVFWXR.js.map +1 -0
  37. package/dist/{chunk-UKG7XHZ3.js → chunk-A4H6QMV4.js} +110 -102
  38. package/dist/chunk-A4H6QMV4.js.map +1 -0
  39. package/dist/{chunk-E5ROA3MN.js → chunk-BMDF2S7S.js} +3 -3
  40. package/dist/{chunk-E5ROA3MN.js.map → chunk-BMDF2S7S.js.map} +1 -1
  41. package/dist/{chunk-PN37HVAV.cjs → chunk-C2RWFIYP.cjs} +121 -67
  42. package/dist/chunk-C2RWFIYP.cjs.map +1 -0
  43. package/dist/chunk-CUZGBWFT.js +206 -0
  44. package/dist/chunk-CUZGBWFT.js.map +1 -0
  45. package/dist/chunk-F2Q76CQ4.cjs +266 -0
  46. package/dist/chunk-F2Q76CQ4.cjs.map +1 -0
  47. package/dist/{chunk-YEDQLNVE.cjs → chunk-G6P3OVDY.cjs} +14 -2
  48. package/dist/chunk-G6P3OVDY.cjs.map +1 -0
  49. package/dist/chunk-GPUNAJFH.js +181 -0
  50. package/dist/chunk-GPUNAJFH.js.map +1 -0
  51. package/dist/chunk-HKN622O4.js +254 -0
  52. package/dist/chunk-HKN622O4.js.map +1 -0
  53. package/dist/{chunk-PYJOBZR3.cjs → chunk-HM6XMR3E.cjs} +52 -52
  54. package/dist/chunk-HM6XMR3E.cjs.map +1 -0
  55. package/dist/chunk-IE2TPFBT.js +305 -0
  56. package/dist/chunk-IE2TPFBT.js.map +1 -0
  57. package/dist/chunk-KGAJ5HFO.cjs +319 -0
  58. package/dist/chunk-KGAJ5HFO.cjs.map +1 -0
  59. package/dist/chunk-M6OC455F.js +65 -0
  60. package/dist/chunk-M6OC455F.js.map +1 -0
  61. package/dist/{chunk-U5ROKVRF.js → chunk-MB363HT5.js} +14 -3
  62. package/dist/chunk-MB363HT5.js.map +1 -0
  63. package/dist/{chunk-X53YKGHR.js → chunk-MRMD7S7E.js} +9 -9
  64. package/dist/{chunk-X53YKGHR.js.map → chunk-MRMD7S7E.js.map} +1 -1
  65. package/dist/{chunk-OOS2RKRH.js → chunk-N3VVQDMA.js} +3 -3
  66. package/dist/{chunk-OOS2RKRH.js.map → chunk-N3VVQDMA.js.map} +1 -1
  67. package/dist/{chunk-EJCDOA37.js → chunk-OGUH56BB.js} +4 -4
  68. package/dist/{chunk-EJCDOA37.js.map → chunk-OGUH56BB.js.map} +1 -1
  69. package/dist/chunk-Q3ZZLU3O.cjs +12 -0
  70. package/dist/{chunk-4FJVSF3K.cjs.map → chunk-Q3ZZLU3O.cjs.map} +1 -1
  71. package/dist/chunk-Q5ASTPM4.cjs +208 -0
  72. package/dist/chunk-Q5ASTPM4.cjs.map +1 -0
  73. package/dist/{chunk-WFUN6DCM.cjs → chunk-R2LA6MKR.cjs} +11 -11
  74. package/dist/chunk-R2LA6MKR.cjs.map +1 -0
  75. package/dist/chunk-RP7YITHX.cjs +70 -0
  76. package/dist/chunk-RP7YITHX.cjs.map +1 -0
  77. package/dist/{chunk-33K3ZYFG.cjs → chunk-RU5BBUU2.cjs} +132 -124
  78. package/dist/chunk-RU5BBUU2.cjs.map +1 -0
  79. package/dist/{chunk-TSGBRPNE.js → chunk-SFNUHFON.js} +45 -45
  80. package/dist/chunk-SFNUHFON.js.map +1 -0
  81. package/dist/chunk-UP4QAJND.cjs +740 -0
  82. package/dist/chunk-UP4QAJND.cjs.map +1 -0
  83. package/dist/{chunk-CTHNVU6K.cjs → chunk-UPBXUOW7.cjs} +8 -8
  84. package/dist/{chunk-CTHNVU6K.cjs.map → chunk-UPBXUOW7.cjs.map} +1 -1
  85. package/dist/{chunk-EK6RJ373.cjs → chunk-VGU26WIU.cjs} +5 -5
  86. package/dist/{chunk-EK6RJ373.cjs.map → chunk-VGU26WIU.cjs.map} +1 -1
  87. package/dist/{chunk-ZGEMI7MJ.cjs → chunk-XTQHSOIC.cjs} +101 -101
  88. package/dist/{chunk-ZGEMI7MJ.cjs.map → chunk-XTQHSOIC.cjs.map} +1 -1
  89. package/dist/chunk-Y52UNT66.js +738 -0
  90. package/dist/chunk-Y52UNT66.js.map +1 -0
  91. package/dist/{chunk-OYLF3IC7.js → chunk-Z36W5WUM.js} +4 -4
  92. package/dist/chunk-Z36W5WUM.js.map +1 -0
  93. package/dist/{chunk-X3244EKP.cjs → chunk-ZFWNO3GE.cjs} +48 -4
  94. package/dist/chunk-ZFWNO3GE.cjs.map +1 -0
  95. package/dist/{chunk-2E4VTD2E.cjs → chunk-ZYQEXGYC.cjs} +423 -1139
  96. package/dist/chunk-ZYQEXGYC.cjs.map +1 -0
  97. package/dist/ddl-BwH00BB6.d.ts +38 -0
  98. package/dist/ddl-D3o-RmsV.d.cts +38 -0
  99. package/dist/{extension-types-B78CZfA5.d.ts → extension-types-CwHV-Uk4.d.cts} +4 -4
  100. package/dist/{extension-types-B78CZfA5.d.cts → extension-types-CwHV-Uk4.d.ts} +4 -4
  101. package/dist/graph-extension/index.cjs +18 -18
  102. package/dist/graph-extension/index.d.cts +4 -4
  103. package/dist/graph-extension/index.d.ts +4 -4
  104. package/dist/graph-extension/index.js +3 -3
  105. package/dist/{index-CWdBFWbI.d.ts → index-CapHwi1a.d.ts} +22 -3
  106. package/dist/{index-Bilw0pYm.d.cts → index-jPPexxM5.d.cts} +22 -3
  107. package/dist/index.cjs +1211 -945
  108. package/dist/index.cjs.map +1 -1
  109. package/dist/index.d.cts +142 -12
  110. package/dist/index.d.ts +142 -12
  111. package/dist/index.js +778 -544
  112. package/dist/index.js.map +1 -1
  113. package/dist/indexes/index.cjs +18 -18
  114. package/dist/indexes/index.d.cts +9 -9
  115. package/dist/indexes/index.d.ts +9 -9
  116. package/dist/indexes/index.js +4 -4
  117. package/dist/interchange/index.cjs +8 -14
  118. package/dist/interchange/index.cjs.map +1 -1
  119. package/dist/interchange/index.d.cts +5 -16
  120. package/dist/interchange/index.d.ts +5 -16
  121. package/dist/interchange/index.js +3 -9
  122. package/dist/interchange/index.js.map +1 -1
  123. package/dist/{manager-ehLTTNq0.d.ts → manager-BUugwCYz.d.ts} +2 -2
  124. package/dist/{manager-c1MGaVVR.d.cts → manager-DpIpn1HQ.d.cts} +2 -2
  125. package/dist/{materialize-indexes-DFavFQah.d.ts → materialize-indexes-lkawaDor.d.ts} +1 -1
  126. package/dist/{materialize-indexes-BQfaAZKA.d.cts → materialize-indexes-oanE3RU0.d.cts} +1 -1
  127. package/dist/{ddl-0Ooc2dpL.d.ts → postgres-CQL9UIn2.d.cts} +2 -471
  128. package/dist/{ddl-Dza3kDrI.d.cts → postgres-CcRLaxz0.d.ts} +2 -471
  129. package/dist/profiler/index.cjs +4 -4
  130. package/dist/profiler/index.d.cts +7 -7
  131. package/dist/profiler/index.d.ts +7 -7
  132. package/dist/profiler/index.js +2 -2
  133. package/dist/schema/index.cjs +32 -32
  134. package/dist/schema/index.d.cts +7 -7
  135. package/dist/schema/index.d.ts +7 -7
  136. package/dist/schema/index.js +9 -9
  137. package/dist/{sqlite-BxZUPbyD.d.ts → sqlite-CZDFUfHS.d.ts} +2 -468
  138. package/dist/{sqlite-mvpXjEeB.d.cts → sqlite-Rj3xu4It.d.cts} +2 -468
  139. package/dist/{store-Ufc1Eoey.d.ts → store-B43FpOVX.d.cts} +84 -5
  140. package/dist/{store-D7YEMg2v.d.cts → store-De0Y33wP.d.ts} +84 -5
  141. package/dist/{types-B-sJJ4GQ.d.ts → types-B5GSeE3t.d.ts} +2 -2
  142. package/dist/{types-CmUA9sal.d.cts → types-Bwlp_yvu.d.cts} +2 -2
  143. package/dist/{types-CMQymcwk.d.cts → types-CmAT-Z47.d.ts} +250 -46
  144. package/dist/{types-CQ7xXJMP.d.ts → types-DXCSyxac.d.cts} +250 -46
  145. package/dist/{where-5zf15aFZ.d.cts → where-2dsyYt3d.d.cts} +2 -2
  146. package/dist/{where-CtrLu1Zf.d.ts → where-CP4qGIHd.d.ts} +2 -2
  147. package/package.json +20 -5
  148. package/dist/chunk-2E4VTD2E.cjs.map +0 -1
  149. package/dist/chunk-33K3ZYFG.cjs.map +0 -1
  150. package/dist/chunk-3EUKJEQ3.js +0 -77
  151. package/dist/chunk-3EUKJEQ3.js.map +0 -1
  152. package/dist/chunk-4FJVSF3K.cjs +0 -12
  153. package/dist/chunk-5H3BAMTB.js +0 -32
  154. package/dist/chunk-5H3BAMTB.js.map +0 -1
  155. package/dist/chunk-DFHLG75V.js.map +0 -1
  156. package/dist/chunk-HTGDWIDE.cjs +0 -89
  157. package/dist/chunk-HTGDWIDE.cjs.map +0 -1
  158. package/dist/chunk-IUIWCFG3.cjs +0 -36
  159. package/dist/chunk-IUIWCFG3.cjs.map +0 -1
  160. package/dist/chunk-LYRUNG6E.cjs +0 -52
  161. package/dist/chunk-LYRUNG6E.cjs.map +0 -1
  162. package/dist/chunk-OYLF3IC7.js.map +0 -1
  163. package/dist/chunk-PCHTTG42.js +0 -47
  164. package/dist/chunk-PCHTTG42.js.map +0 -1
  165. package/dist/chunk-PN37HVAV.cjs.map +0 -1
  166. package/dist/chunk-PYJOBZR3.cjs.map +0 -1
  167. package/dist/chunk-TSGBRPNE.js.map +0 -1
  168. package/dist/chunk-U5ROKVRF.js.map +0 -1
  169. package/dist/chunk-UKG7XHZ3.js.map +0 -1
  170. package/dist/chunk-WFUN6DCM.cjs.map +0 -1
  171. package/dist/chunk-WVQXAFP3.js.map +0 -1
  172. package/dist/chunk-X3244EKP.cjs.map +0 -1
  173. package/dist/chunk-YEDQLNVE.cjs.map +0 -1
  174. package/dist/chunk-ZTREJOGB.js.map +0 -1
@@ -1,9 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunk2E4VTD2E_cjs = require('./chunk-2E4VTD2E.cjs');
4
- var chunkLYRUNG6E_cjs = require('./chunk-LYRUNG6E.cjs');
5
- var chunkPN37HVAV_cjs = require('./chunk-PN37HVAV.cjs');
6
- var chunkYEDQLNVE_cjs = require('./chunk-YEDQLNVE.cjs');
3
+ var chunkZYQEXGYC_cjs = require('./chunk-ZYQEXGYC.cjs');
4
+ var chunkF2Q76CQ4_cjs = require('./chunk-F2Q76CQ4.cjs');
5
+ var chunkRP7YITHX_cjs = require('./chunk-RP7YITHX.cjs');
6
+ var chunkC2RWFIYP_cjs = require('./chunk-C2RWFIYP.cjs');
7
+ var chunkG6P3OVDY_cjs = require('./chunk-G6P3OVDY.cjs');
7
8
  var drizzleOrm = require('drizzle-orm');
8
9
  var sqliteCore = require('drizzle-orm/sqlite-core');
9
10
 
@@ -70,7 +71,7 @@ function resolveSqliteClient(db) {
70
71
  return sqliteClient;
71
72
  }
72
73
  function getOrCreatePreparedStatement(cache, sqliteClient, sqlText, cacheMax) {
73
- return chunk2E4VTD2E_cjs.getOrCreateLru(
74
+ return chunkZYQEXGYC_cjs.getOrCreateLru(
74
75
  cache,
75
76
  sqlText,
76
77
  cacheMax,
@@ -106,7 +107,7 @@ function createSqliteExecutionAdapter(db, statementCacheMaxOrOptions = {}) {
106
107
  supportsCompiledExecution: sqliteClient !== void 0,
107
108
  transactionMode
108
109
  };
109
- const compile = (query) => chunk2E4VTD2E_cjs.compileQueryWithDialect(db, query, "SQLite");
110
+ const compile = (query) => chunkZYQEXGYC_cjs.compileQueryWithDialect(db, query, "SQLite");
110
111
  if (sqliteClient !== void 0) {
111
112
  let executeCompiled2 = function(compiledQuery) {
112
113
  const preparedStatement = getOrCreatePreparedStatement(
@@ -177,10 +178,12 @@ var SQLITE_CHECK_UNIQUE_BATCH_CHUNK_SIZE = Math.max(
177
178
  1,
178
179
  SQLITE_MAX_BIND_PARAMETERS - CHECK_UNIQUE_BATCH_FIXED_PARAM_COUNT
179
180
  );
180
- var toNodeRow = chunk2E4VTD2E_cjs.createNodeRowMapper(chunk2E4VTD2E_cjs.SQLITE_ROW_MAPPER_CONFIG);
181
- var toEdgeRow = chunk2E4VTD2E_cjs.createEdgeRowMapper(chunk2E4VTD2E_cjs.SQLITE_ROW_MAPPER_CONFIG);
182
- var toUniqueRow = chunk2E4VTD2E_cjs.createUniqueRowMapper(chunk2E4VTD2E_cjs.SQLITE_ROW_MAPPER_CONFIG);
183
- var toSchemaVersionRow = chunk2E4VTD2E_cjs.createSchemaVersionRowMapper(chunk2E4VTD2E_cjs.SQLITE_ROW_MAPPER_CONFIG);
181
+ var toNodeRow = chunkZYQEXGYC_cjs.createNodeRowMapper(chunkZYQEXGYC_cjs.SQLITE_ROW_MAPPER_CONFIG);
182
+ var toEdgeRow = chunkZYQEXGYC_cjs.createEdgeRowMapper(chunkZYQEXGYC_cjs.SQLITE_ROW_MAPPER_CONFIG);
183
+ var toUniqueRow = chunkZYQEXGYC_cjs.createUniqueRowMapper(chunkZYQEXGYC_cjs.SQLITE_ROW_MAPPER_CONFIG);
184
+ var toSchemaVersionRow = chunkZYQEXGYC_cjs.createSchemaVersionRowMapper(
185
+ chunkZYQEXGYC_cjs.SQLITE_ROW_MAPPER_CONFIG
186
+ );
184
187
  var PENDING_FOREVER = new Promise(noop);
185
188
  function pendingForever() {
186
189
  return PENDING_FOREVER;
@@ -198,7 +201,7 @@ function createSerializedExecutionQueue() {
198
201
  disposed = true;
199
202
  },
200
203
  runExclusive(task) {
201
- if (isDisposed()) return Promise.reject(new chunkYEDQLNVE_cjs.BackendDisposedError());
204
+ if (isDisposed()) return Promise.reject(new chunkG6P3OVDY_cjs.BackendDisposedError());
202
205
  const runTask = async () => {
203
206
  if (isDisposed()) return pendingForever();
204
207
  try {
@@ -221,29 +224,19 @@ function runWithSerializedQueue(queue, task) {
221
224
  if (queue === void 0) return task();
222
225
  return queue.runExclusive(task);
223
226
  }
224
- var SQLITE_VECTOR_METRICS = ["cosine", "l2"];
225
- var SQLITE_VECTOR_INDEX_TYPES = ["none"];
226
- var SQLITE_VECTOR_MAX_DIMENSIONS = 8e3;
227
227
  function throwSqliteTransactionsDisabled(message) {
228
- throw new chunkYEDQLNVE_cjs.ConfigurationError(message, {
228
+ throw new chunkG6P3OVDY_cjs.ConfigurationError(message, {
229
229
  backend: "sqlite",
230
230
  capability: "transactions",
231
231
  supportsTransactions: false
232
232
  });
233
233
  }
234
234
  function buildSqliteCapabilities(options) {
235
- const base = options.transactionMode === "none" ? { ...chunkLYRUNG6E_cjs.SQLITE_CAPABILITIES, transactions: false } : chunkLYRUNG6E_cjs.SQLITE_CAPABILITIES;
235
+ const base = options.transactionMode === "none" ? { ...chunkF2Q76CQ4_cjs.SQLITE_CAPABILITIES, transactions: false } : chunkF2Q76CQ4_cjs.SQLITE_CAPABILITIES;
236
236
  return {
237
237
  ...base,
238
- fulltext: chunkPN37HVAV_cjs.buildFulltextCapabilities(options.fulltextStrategy),
239
- ...options.hasVectorEmbeddings ? {
240
- vector: {
241
- supported: true,
242
- metrics: SQLITE_VECTOR_METRICS,
243
- indexTypes: SQLITE_VECTOR_INDEX_TYPES,
244
- maxDimensions: SQLITE_VECTOR_MAX_DIMENSIONS
245
- }
246
- } : {}
238
+ fulltext: chunkC2RWFIYP_cjs.buildFulltextCapabilities(options.fulltextStrategy),
239
+ ...options.vectorStrategy === void 0 ? {} : { vector: chunkC2RWFIYP_cjs.buildVectorCapabilities(options.vectorStrategy) }
247
240
  };
248
241
  }
249
242
  function createSqliteOperationBackend(options) {
@@ -254,7 +247,9 @@ function createSqliteOperationBackend(options) {
254
247
  operationStrategy,
255
248
  serializedQueue,
256
249
  tableNames,
257
- fulltextStrategy
250
+ fulltextStrategy,
251
+ vectorStrategy,
252
+ vectorSlotLatch
258
253
  } = options;
259
254
  function execGet(query) {
260
255
  return runWithSerializedQueue(serializedQueue, async () => {
@@ -272,7 +267,7 @@ function createSqliteOperationBackend(options) {
272
267
  await db.run(query);
273
268
  });
274
269
  }
275
- const commonBackend = chunk2E4VTD2E_cjs.createCommonOperationBackend({
270
+ const commonBackend = chunkZYQEXGYC_cjs.createCommonOperationBackend({
276
271
  batchConfig: {
277
272
  checkUniqueBatchChunkSize: SQLITE_CHECK_UNIQUE_BATCH_CHUNK_SIZE,
278
273
  edgeInsertBatchSize: SQLITE_EDGE_INSERT_BATCH_SIZE,
@@ -285,7 +280,7 @@ function createSqliteOperationBackend(options) {
285
280
  execGet,
286
281
  execRun
287
282
  },
288
- nowIso: chunk2E4VTD2E_cjs.nowIso,
283
+ nowIso: chunkZYQEXGYC_cjs.nowIso,
289
284
  operationStrategy,
290
285
  rowMappers: {
291
286
  toEdgeRow,
@@ -303,29 +298,50 @@ function createSqliteOperationBackend(options) {
303
298
  );
304
299
  }
305
300
  };
306
- const vectorEmbeddingMethods = options.hasVectorEmbeddings ? {
301
+ async function ensureVectorSlotStorage(slot) {
302
+ if (vectorStrategy === void 0 || vectorSlotLatch === void 0) return;
303
+ await vectorSlotLatch.ensure(vectorStrategy, slot, async (statement) => {
304
+ await execRun(drizzleOrm.sql.raw(statement));
305
+ });
306
+ }
307
+ const vectorEmbeddingMethods = vectorStrategy === void 0 ? {} : {
307
308
  async upsertEmbedding(params) {
308
- const query = operationStrategy.buildUpsertEmbedding(
309
- params,
310
- chunk2E4VTD2E_cjs.nowIso()
311
- );
312
- await execRun(query);
309
+ const slot = chunkZYQEXGYC_cjs.vectorSlotFromParams(params);
310
+ await ensureVectorSlotStorage(slot);
311
+ const statements = vectorStrategy.buildUpsert(slot, params, chunkZYQEXGYC_cjs.nowIso());
312
+ try {
313
+ for (const statement of statements) {
314
+ await execRun(statement);
315
+ }
316
+ } catch (error) {
317
+ throw chunkZYQEXGYC_cjs.mapVectorWriteError(error, params);
318
+ }
313
319
  },
314
320
  async deleteEmbedding(params) {
315
- const query = operationStrategy.buildDeleteEmbedding(params);
316
- await execRun(query);
321
+ const slot = chunkZYQEXGYC_cjs.vectorSlotFromParams(params);
322
+ await ensureVectorSlotStorage(slot);
323
+ const statements = vectorStrategy.buildDelete(slot, params);
324
+ for (const statement of statements) {
325
+ await execRun(statement);
326
+ }
317
327
  },
318
328
  async vectorSearch(params) {
319
- const query = operationStrategy.buildVectorSearch(params);
320
- const rows = await execAll(
321
- query
322
- );
329
+ chunkC2RWFIYP_cjs.assertVectorSearchLimit(params.limit);
330
+ const slot = chunkZYQEXGYC_cjs.vectorSlotFromParams(params);
331
+ await ensureVectorSlotStorage(slot);
332
+ const query = vectorStrategy.buildSearch(slot, params);
333
+ let rows;
334
+ try {
335
+ rows = await execAll(query);
336
+ } catch (error) {
337
+ throw chunkZYQEXGYC_cjs.mapVectorWriteError(error, params);
338
+ }
323
339
  return rows.map((row) => ({
324
340
  nodeId: row.node_id,
325
341
  score: row.score
326
342
  }));
327
343
  }
328
- } : {};
344
+ };
329
345
  const operationBackend = {
330
346
  ...commonBackend,
331
347
  ...executeRawMethod,
@@ -334,38 +350,30 @@ function createSqliteOperationBackend(options) {
334
350
  dialect: "sqlite",
335
351
  tableNames,
336
352
  fulltextStrategy,
337
- createVectorIndex(params) {
338
- const indexOptions = {
339
- graphId: params.graphId,
340
- nodeKind: params.nodeKind,
341
- fieldPath: params.fieldPath,
342
- dimensions: params.dimensions,
343
- indexType: params.indexType,
344
- metric: params.metric,
345
- ...params.indexParams?.m === void 0 ? {} : { hnswM: params.indexParams.m },
346
- ...params.indexParams?.efConstruction === void 0 ? {} : { hnswEfConstruction: params.indexParams.efConstruction },
347
- ...params.indexParams?.lists === void 0 ? {} : { ivfflatLists: params.indexParams.lists }
348
- };
349
- const result = chunk2E4VTD2E_cjs.createSqliteVectorIndex(indexOptions);
350
- if (!result.success) {
351
- throw new Error(result.message ?? "Failed to create SQLite vector index");
353
+ ...vectorStrategy === void 0 ? {} : { vectorStrategy },
354
+ async createVectorIndex(params) {
355
+ if (vectorStrategy === void 0) return;
356
+ const slot = chunkZYQEXGYC_cjs.vectorSlotFromCreateIndexParams(params);
357
+ await ensureVectorSlotStorage(slot);
358
+ const indexStatement = vectorStrategy.buildCreateIndex?.(slot);
359
+ if (indexStatement !== void 0) {
360
+ await execRun(indexStatement);
352
361
  }
353
- return Promise.resolve();
354
362
  },
355
- dropVectorIndex(params) {
356
- const result = chunk2E4VTD2E_cjs.dropSqliteVectorIndex(
357
- params.graphId,
358
- params.nodeKind,
359
- params.fieldPath
360
- );
361
- if (!result.success) {
362
- throw new Error(result.message ?? "Failed to drop SQLite vector index");
363
+ async dropVectorIndex(params) {
364
+ if (vectorStrategy === void 0) return;
365
+ const slot = chunkZYQEXGYC_cjs.vectorSlotFromDropIndexParams(params);
366
+ const dropStatement = vectorStrategy.buildDropIndex?.(slot);
367
+ if (dropStatement === void 0) return;
368
+ try {
369
+ await execRun(dropStatement);
370
+ } catch (error) {
371
+ if (!chunkRP7YITHX_cjs.isMissingTableError(error)) throw error;
363
372
  }
364
- return Promise.resolve();
365
373
  },
366
374
  // === Fulltext Operations ===
367
375
  async upsertFulltext(params) {
368
- const timestamp = chunk2E4VTD2E_cjs.nowIso();
376
+ const timestamp = chunkZYQEXGYC_cjs.nowIso();
369
377
  const statements = operationStrategy.buildUpsertFulltext(
370
378
  params,
371
379
  timestamp
@@ -382,7 +390,7 @@ function createSqliteOperationBackend(options) {
382
390
  },
383
391
  async upsertFulltextBatch(params) {
384
392
  if (params.rows.length === 0) return;
385
- const timestamp = chunk2E4VTD2E_cjs.nowIso();
393
+ const timestamp = chunkZYQEXGYC_cjs.nowIso();
386
394
  const statements = operationStrategy.buildUpsertFulltextBatch(
387
395
  params,
388
396
  timestamp
@@ -403,7 +411,7 @@ function createSqliteOperationBackend(options) {
403
411
  const rows = await execAll(query);
404
412
  return rows.map((row, index) => ({
405
413
  nodeId: row.node_id,
406
- score: chunk2E4VTD2E_cjs.coerceNumericScore(row.score),
414
+ score: chunkZYQEXGYC_cjs.coerceNumericScore(row.score),
407
415
  rank: index + 1,
408
416
  ...row.snippet === null ? {} : { snippet: row.snippet }
409
417
  }));
@@ -422,25 +430,25 @@ function createSqliteOperationBackend(options) {
422
430
  return operationBackend;
423
431
  }
424
432
  function createSqliteBackend(db, options = {}) {
425
- const tables2 = options.tables ?? chunk2E4VTD2E_cjs.tables2;
426
- const fulltextStrategy = options.fulltext ?? chunkPN37HVAV_cjs.fts5Strategy;
433
+ const tables2 = options.tables ?? chunkF2Q76CQ4_cjs.tables;
434
+ const fulltextStrategy = options.fulltext ?? chunkC2RWFIYP_cjs.fts5Strategy;
427
435
  const profileHints = options.executionProfile ?? {};
428
436
  const executionAdapter = createSqliteExecutionAdapter(db, { profileHints });
429
437
  const { isSync, transactionMode } = executionAdapter.profile;
430
- const hasVectorEmbeddings = options.hasVectorEmbeddings === true;
438
+ const vectorStrategy = options.vector;
439
+ const vectorSlotLatch = vectorStrategy === void 0 ? void 0 : chunkZYQEXGYC_cjs.createVectorSlotLatch();
431
440
  const capabilities = buildSqliteCapabilities({
432
441
  fulltextStrategy,
433
- hasVectorEmbeddings,
442
+ vectorStrategy,
434
443
  transactionMode
435
444
  });
436
445
  const tableNames = {
437
446
  nodes: drizzleOrm.getTableName(tables2.nodes),
438
447
  edges: drizzleOrm.getTableName(tables2.edges),
439
- embeddings: drizzleOrm.getTableName(tables2.embeddings),
440
448
  fulltext: tables2.fulltextTableName,
441
449
  uniques: drizzleOrm.getTableName(tables2.uniques)
442
450
  };
443
- const operationStrategy = chunk2E4VTD2E_cjs.createSqliteOperationStrategy(
451
+ const operationStrategy = chunkZYQEXGYC_cjs.createSqliteOperationStrategy(
444
452
  tables2,
445
453
  fulltextStrategy
446
454
  );
@@ -452,7 +460,8 @@ function createSqliteBackend(db, options = {}) {
452
460
  operationStrategy,
453
461
  tableNames,
454
462
  fulltextStrategy,
455
- hasVectorEmbeddings,
463
+ vectorStrategy,
464
+ vectorSlotLatch,
456
465
  ...serializedQueue === void 0 ? {} : { serializedQueue }
457
466
  });
458
467
  function runDoSqliteStorageTransaction(run) {
@@ -484,8 +493,7 @@ function createSqliteBackend(db, options = {}) {
484
493
  profileHints: { isSync: true },
485
494
  tableNames,
486
495
  fulltextStrategy,
487
- hasVectorEmbeddings
488
- });
496
+ vectorStrategy});
489
497
  db.run(drizzleOrm.sql`BEGIN IMMEDIATE`);
490
498
  try {
491
499
  const result = await fn(txBackend);
@@ -506,30 +514,31 @@ function createSqliteBackend(db, options = {}) {
506
514
  profileHints: { isSync },
507
515
  tableNames,
508
516
  fulltextStrategy,
509
- hasVectorEmbeddings
510
- });
517
+ vectorStrategy});
511
518
  return fn(txBackend);
512
519
  });
513
520
  }
514
521
  return runWithSerializedQueue(
515
522
  serializedQueue,
516
- async () => db.transaction(async (tx) => {
517
- const txBackend = createTransactionBackend({
518
- capabilities,
519
- db: tx,
520
- operationStrategy,
521
- profileHints: { isSync },
522
- tableNames,
523
- fulltextStrategy,
524
- hasVectorEmbeddings
525
- });
526
- return fn(txBackend);
527
- }, { behavior: "immediate" })
523
+ async () => db.transaction(
524
+ async (tx) => {
525
+ const txBackend = createTransactionBackend({
526
+ capabilities,
527
+ db: tx,
528
+ operationStrategy,
529
+ profileHints: { isSync },
530
+ tableNames,
531
+ fulltextStrategy,
532
+ vectorStrategy});
533
+ return fn(txBackend);
534
+ },
535
+ { behavior: "immediate" }
536
+ )
528
537
  );
529
538
  }
530
539
  const matTable = tables2.contributionMaterializations;
531
540
  async function ensureContributionMaterializationsTableImpl() {
532
- await db.run(drizzleOrm.sql.raw(chunk2E4VTD2E_cjs.generateSqliteCreateTableSQL(matTable)));
541
+ await db.run(drizzleOrm.sql.raw(chunkZYQEXGYC_cjs.generateSqliteCreateTableSQL(matTable)));
533
542
  }
534
543
  async function getContributionMaterializationRow(identity) {
535
544
  const rows = await db.select().from(matTable).where(
@@ -542,16 +551,16 @@ function createSqliteBackend(db, options = {}) {
542
551
  );
543
552
  const row = rows[0];
544
553
  if (row === void 0) return void 0;
545
- return chunk2E4VTD2E_cjs.mapContributionMaterializationRow(
554
+ return chunkZYQEXGYC_cjs.mapContributionMaterializationRow(
546
555
  row,
547
- chunk2E4VTD2E_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.decode
556
+ chunkZYQEXGYC_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.decode
548
557
  );
549
558
  }
550
559
  async function recordContributionMaterializationRow(params) {
551
560
  await db.insert(matTable).values(
552
- chunk2E4VTD2E_cjs.buildContributionInsertValues(
561
+ chunkZYQEXGYC_cjs.buildContributionInsertValues(
553
562
  params,
554
- chunk2E4VTD2E_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.encode
563
+ chunkZYQEXGYC_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.encode
555
564
  )
556
565
  ).onConflictDoUpdate({
557
566
  target: [
@@ -560,13 +569,13 @@ function createSqliteBackend(db, options = {}) {
560
569
  matTable.owner,
561
570
  matTable.tableName
562
571
  ],
563
- set: chunk2E4VTD2E_cjs.buildContributionOnConflictSet(
572
+ set: chunkZYQEXGYC_cjs.buildContributionOnConflictSet(
564
573
  matTable.materializedAt,
565
574
  params.materializedAt
566
575
  )
567
576
  });
568
577
  }
569
- const contributionMaterializer = chunk2E4VTD2E_cjs.createContributionMaterializer({
578
+ const contributionMaterializer = chunkZYQEXGYC_cjs.createContributionMaterializer({
570
579
  dialect: "sqlite",
571
580
  fulltextStrategy,
572
581
  fulltextTableName: tables2.fulltextTableName,
@@ -585,14 +594,13 @@ function createSqliteBackend(db, options = {}) {
585
594
  profileHints: { isSync },
586
595
  tableNames,
587
596
  fulltextStrategy,
588
- hasVectorEmbeddings
589
- });
590
- return chunk2E4VTD2E_cjs.gateFulltext(txBackend, contributionMaterializer.assertInitialized);
597
+ vectorStrategy});
598
+ return chunkZYQEXGYC_cjs.gateFulltext(txBackend, contributionMaterializer.assertInitialized);
591
599
  }
592
600
  const backend = {
593
601
  ...operations,
594
602
  async bootstrapTables() {
595
- const statements = chunk2E4VTD2E_cjs.generateSqliteDDL(tables2, fulltextStrategy);
603
+ const statements = chunkZYQEXGYC_cjs.generateSqliteDDL(tables2, fulltextStrategy);
596
604
  for (const statement of statements) {
597
605
  await db.run(drizzleOrm.sql.raw(statement));
598
606
  }
@@ -602,7 +610,7 @@ function createSqliteBackend(db, options = {}) {
602
610
  // uninitialized database throws `StoreNotInitializedError` rather
603
611
  // than self-healing (#135). Shared verbatim with the tx-scoped gate
604
612
  // via `gateFulltextMethods`.
605
- ...chunk2E4VTD2E_cjs.gateFulltextMethods(
613
+ ...chunkZYQEXGYC_cjs.gateFulltextMethods(
606
614
  operations,
607
615
  contributionMaterializer.assertInitialized
608
616
  ),
@@ -611,7 +619,7 @@ function createSqliteBackend(db, options = {}) {
611
619
  },
612
620
  async ensureIndexMaterializationsTable() {
613
621
  await db.run(
614
- drizzleOrm.sql.raw(chunk2E4VTD2E_cjs.generateSqliteCreateTableSQL(tables2.indexMaterializations))
622
+ drizzleOrm.sql.raw(chunkZYQEXGYC_cjs.generateSqliteCreateTableSQL(tables2.indexMaterializations))
615
623
  );
616
624
  },
617
625
  async getIndexMaterialization(indexName) {
@@ -619,26 +627,26 @@ function createSqliteBackend(db, options = {}) {
619
627
  const rows = await db.select().from(t).where(drizzleOrm.eq(t.indexName, indexName));
620
628
  const row = rows[0];
621
629
  if (row === void 0) return void 0;
622
- return chunk2E4VTD2E_cjs.mapMaterializationRow(row, chunk2E4VTD2E_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode);
630
+ return chunkZYQEXGYC_cjs.mapMaterializationRow(row, chunkZYQEXGYC_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode);
623
631
  },
624
632
  async getIndexMaterializations(statusKeys) {
625
633
  if (statusKeys.length === 0) return [];
626
634
  const t = tables2.indexMaterializations;
627
635
  const rows = await db.select().from(t).where(drizzleOrm.inArray(t.indexName, [...statusKeys]));
628
636
  return rows.map(
629
- (row) => chunk2E4VTD2E_cjs.mapMaterializationRow(row, chunk2E4VTD2E_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode)
637
+ (row) => chunkZYQEXGYC_cjs.mapMaterializationRow(row, chunkZYQEXGYC_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode)
630
638
  );
631
639
  },
632
640
  async recordIndexMaterialization(params) {
633
641
  const t = tables2.indexMaterializations;
634
642
  await db.insert(t).values(
635
- chunk2E4VTD2E_cjs.buildMaterializationInsertValues(
643
+ chunkZYQEXGYC_cjs.buildMaterializationInsertValues(
636
644
  params,
637
- chunk2E4VTD2E_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.encode
645
+ chunkZYQEXGYC_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.encode
638
646
  )
639
647
  ).onConflictDoUpdate({
640
648
  target: t.indexName,
641
- set: chunk2E4VTD2E_cjs.buildMaterializationOnConflictSet(
649
+ set: chunkZYQEXGYC_cjs.buildMaterializationOnConflictSet(
642
650
  t.materializedAt,
643
651
  params.materializedAt
644
652
  )
@@ -657,37 +665,37 @@ function createSqliteBackend(db, options = {}) {
657
665
  await contributionMaterializer.assertInitialized(graphId);
658
666
  },
659
667
  async ensureKindRemovalsTable() {
660
- await db.run(drizzleOrm.sql.raw(chunk2E4VTD2E_cjs.generateSqliteCreateTableSQL(tables2.kindRemovals)));
668
+ await db.run(drizzleOrm.sql.raw(chunkZYQEXGYC_cjs.generateSqliteCreateTableSQL(tables2.kindRemovals)));
661
669
  },
662
670
  async getPendingKindRemovals(graphId) {
663
671
  const t = tables2.kindRemovals;
664
672
  const rows = await db.select().from(t).where(drizzleOrm.and(drizzleOrm.eq(t.graphId, graphId), drizzleOrm.isNull(t.removedAt)));
665
673
  return rows.map(
666
- (row) => chunk2E4VTD2E_cjs.mapKindRemovalRow(row, chunk2E4VTD2E_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
674
+ (row) => chunkZYQEXGYC_cjs.mapKindRemovalRow(row, chunkZYQEXGYC_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
667
675
  );
668
676
  },
669
677
  async getAllKindRemovals(graphId) {
670
678
  const t = tables2.kindRemovals;
671
679
  const rows = await db.select().from(t).where(drizzleOrm.eq(t.graphId, graphId));
672
680
  return rows.map(
673
- (row) => chunk2E4VTD2E_cjs.mapKindRemovalRow(row, chunk2E4VTD2E_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
681
+ (row) => chunkZYQEXGYC_cjs.mapKindRemovalRow(row, chunkZYQEXGYC_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
674
682
  );
675
683
  },
676
684
  async recordKindRemoval(params) {
677
685
  const t = tables2.kindRemovals;
678
686
  await db.insert(t).values(
679
- chunk2E4VTD2E_cjs.buildKindRemovalInsertValues(
687
+ chunkZYQEXGYC_cjs.buildKindRemovalInsertValues(
680
688
  params,
681
- chunk2E4VTD2E_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.encode
689
+ chunkZYQEXGYC_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.encode
682
690
  )
683
691
  ).onConflictDoUpdate({
684
692
  target: [t.graphId, t.kindName, t.entity, t.schemaVersion],
685
- set: chunk2E4VTD2E_cjs.buildKindRemovalOnConflictSet(t.removedAt, params.removedAt)
693
+ set: chunkZYQEXGYC_cjs.buildKindRemovalOnConflictSet(t.removedAt, params.removedAt)
686
694
  });
687
695
  },
688
696
  async ensureReconciliationMarkersTable() {
689
697
  await db.run(
690
- drizzleOrm.sql.raw(chunk2E4VTD2E_cjs.generateSqliteCreateTableSQL(tables2.reconciliationMarkers))
698
+ drizzleOrm.sql.raw(chunkZYQEXGYC_cjs.generateSqliteCreateTableSQL(tables2.reconciliationMarkers))
691
699
  );
692
700
  },
693
701
  async ensureRuntimeContributions(graphId) {
@@ -742,12 +750,11 @@ function createSqliteBackend(db, options = {}) {
742
750
  profileHints: { isSync: true },
743
751
  tableNames,
744
752
  fulltextStrategy,
745
- hasVectorEmbeddings
746
- });
753
+ vectorStrategy});
747
754
  db.run(drizzleOrm.sql`BEGIN`);
748
755
  try {
749
756
  const result = await fn(
750
- chunk2E4VTD2E_cjs.gateFulltext(
757
+ chunkZYQEXGYC_cjs.gateFulltext(
751
758
  txBackend,
752
759
  contributionMaterializer.assertInitialized
753
760
  ),
@@ -779,7 +786,7 @@ function createSqliteBackend(db, options = {}) {
779
786
  "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
787
  );
781
788
  }
782
- chunk2E4VTD2E_cjs.assertAdoptedDialect(
789
+ chunkZYQEXGYC_cjs.assertAdoptedDialect(
783
790
  externalTx,
784
791
  sqliteCore.BaseSQLiteDatabase,
785
792
  "sqlite"
@@ -804,10 +811,11 @@ function createTransactionBackend(options) {
804
811
  operationStrategy: options.operationStrategy,
805
812
  tableNames: options.tableNames,
806
813
  fulltextStrategy: options.fulltextStrategy,
807
- ...options.hasVectorEmbeddings === void 0 ? {} : { hasVectorEmbeddings: options.hasVectorEmbeddings }
814
+ vectorStrategy: options.vectorStrategy,
815
+ ...options.vectorStrategy === void 0 ? {} : { vectorSlotLatch: chunkZYQEXGYC_cjs.createVectorSlotLatch() }
808
816
  });
809
817
  }
810
818
 
811
819
  exports.createSqliteBackend = createSqliteBackend;
812
- //# sourceMappingURL=chunk-33K3ZYFG.cjs.map
813
- //# sourceMappingURL=chunk-33K3ZYFG.cjs.map
820
+ //# sourceMappingURL=chunk-RU5BBUU2.cjs.map
821
+ //# sourceMappingURL=chunk-RU5BBUU2.cjs.map