@nicia-ai/typegraph 0.28.1 → 0.30.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 (178) hide show
  1. package/dist/backend/postgres/index.cjs +24 -762
  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 +11 -753
  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 +23 -27
  14. package/dist/backend/sqlite/index.d.cts +22 -15
  15. package/dist/backend/sqlite/index.d.ts +22 -15
  16. package/dist/backend/sqlite/index.js +10 -10
  17. package/dist/backend/sqlite/libsql.cjs +18 -14
  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 +17 -13
  22. package/dist/backend/sqlite/libsql.js.map +1 -1
  23. package/dist/backend/sqlite/local.cjs +19 -17
  24. package/dist/backend/sqlite/local.cjs.map +1 -1
  25. package/dist/backend/sqlite/local.d.cts +9 -3
  26. package/dist/backend/sqlite/local.d.ts +9 -3
  27. package/dist/backend/sqlite/local.js +17 -15
  28. package/dist/backend/sqlite/local.js.map +1 -1
  29. package/dist/chunk-26HWIIVS.cjs +740 -0
  30. package/dist/chunk-26HWIIVS.cjs.map +1 -0
  31. package/dist/chunk-2QA5EHEN.js +181 -0
  32. package/dist/chunk-2QA5EHEN.js.map +1 -0
  33. package/dist/chunk-3IRMLJEK.js +206 -0
  34. package/dist/chunk-3IRMLJEK.js.map +1 -0
  35. package/dist/{chunk-5MTOKWDA.js → chunk-3JLRHQ67.js} +9 -9
  36. package/dist/{chunk-5MTOKWDA.js.map → chunk-3JLRHQ67.js.map} +1 -1
  37. package/dist/{chunk-WVQXAFP3.js → chunk-454I6GDF.js} +46 -5
  38. package/dist/chunk-454I6GDF.js.map +1 -0
  39. package/dist/{chunk-CTHNVU6K.cjs → chunk-4BXHVEFB.cjs} +16 -16
  40. package/dist/{chunk-CTHNVU6K.cjs.map → chunk-4BXHVEFB.cjs.map} +1 -1
  41. package/dist/{chunk-NMOE2ZEU.cjs → chunk-4LBO6KIF.cjs} +139 -128
  42. package/dist/chunk-4LBO6KIF.cjs.map +1 -0
  43. package/dist/chunk-633N7DSE.js +258 -0
  44. package/dist/chunk-633N7DSE.js.map +1 -0
  45. package/dist/{chunk-WFUN6DCM.cjs → chunk-7JGLPAFV.cjs} +11 -11
  46. package/dist/chunk-7JGLPAFV.cjs.map +1 -0
  47. package/dist/{chunk-ZTREJOGB.js → chunk-AI3RNREM.js} +140 -69
  48. package/dist/chunk-AI3RNREM.js.map +1 -0
  49. package/dist/{chunk-TSGBRPNE.js → chunk-ENDUY2CD.js} +46 -46
  50. package/dist/chunk-ENDUY2CD.js.map +1 -0
  51. package/dist/{chunk-7V335GHG.cjs → chunk-FLRCVI2G.cjs} +12 -2
  52. package/dist/chunk-FLRCVI2G.cjs.map +1 -0
  53. package/dist/chunk-FVIGJTS7.js +305 -0
  54. package/dist/chunk-FVIGJTS7.js.map +1 -0
  55. package/dist/chunk-FWBVPATK.cjs +208 -0
  56. package/dist/chunk-FWBVPATK.cjs.map +1 -0
  57. package/dist/chunk-IE6GN7L3.cjs +319 -0
  58. package/dist/chunk-IE6GN7L3.cjs.map +1 -0
  59. package/dist/{chunk-PGU2XKMA.js → chunk-IUIJJYPI.js} +117 -106
  60. package/dist/chunk-IUIJJYPI.js.map +1 -0
  61. package/dist/{chunk-E5ROA3MN.js → chunk-IX7RE7CG.js} +3 -3
  62. package/dist/{chunk-E5ROA3MN.js.map → chunk-IX7RE7CG.js.map} +1 -1
  63. package/dist/{chunk-YEDQLNVE.cjs → chunk-JIEJCTDS.cjs} +30 -2
  64. package/dist/chunk-JIEJCTDS.cjs.map +1 -0
  65. package/dist/{chunk-WZH2MKHW.cjs → chunk-K4N35E7B.cjs} +101 -101
  66. package/dist/{chunk-WZH2MKHW.cjs.map → chunk-K4N35E7B.cjs.map} +1 -1
  67. package/dist/{chunk-NZ5PMBTG.js → chunk-K5P5OZXS.js} +12 -3
  68. package/dist/chunk-K5P5OZXS.js.map +1 -0
  69. package/dist/chunk-K5VREXMZ.js +738 -0
  70. package/dist/chunk-K5VREXMZ.js.map +1 -0
  71. package/dist/chunk-LUHU4T2F.cjs +12 -0
  72. package/dist/{chunk-4FJVSF3K.cjs.map → chunk-LUHU4T2F.cjs.map} +1 -1
  73. package/dist/{chunk-O57GYGYK.js → chunk-M6OC455F.js} +32 -18
  74. package/dist/chunk-M6OC455F.js.map +1 -0
  75. package/dist/{chunk-OYLF3IC7.js → chunk-MAQJYNJR.js} +4 -4
  76. package/dist/chunk-MAQJYNJR.js.map +1 -0
  77. package/dist/{chunk-OOS2RKRH.js → chunk-MXE2U3EX.js} +4 -4
  78. package/dist/{chunk-OOS2RKRH.js.map → chunk-MXE2U3EX.js.map} +1 -1
  79. package/dist/{chunk-TKM2WDT4.js → chunk-N2OEOGBB.js} +386 -1093
  80. package/dist/chunk-N2OEOGBB.js.map +1 -0
  81. package/dist/{chunk-EJCDOA37.js → chunk-R4JOBEJU.js} +5 -5
  82. package/dist/{chunk-EJCDOA37.js.map → chunk-R4JOBEJU.js.map} +1 -1
  83. package/dist/{chunk-FFHW2JEK.cjs → chunk-RP7YITHX.cjs} +32 -17
  84. package/dist/chunk-RP7YITHX.cjs.map +1 -0
  85. package/dist/{chunk-PYJOBZR3.cjs → chunk-SGPXKJ4A.cjs} +60 -60
  86. package/dist/chunk-SGPXKJ4A.cjs.map +1 -0
  87. package/dist/{chunk-U5ROKVRF.js → chunk-TQOYM4LN.js} +29 -3
  88. package/dist/chunk-TQOYM4LN.js.map +1 -0
  89. package/dist/{chunk-PN37HVAV.cjs → chunk-UESTHN47.cjs} +153 -71
  90. package/dist/chunk-UESTHN47.cjs.map +1 -0
  91. package/dist/chunk-VFX3LC76.cjs +183 -0
  92. package/dist/chunk-VFX3LC76.cjs.map +1 -0
  93. package/dist/chunk-WEMZM7J7.cjs +270 -0
  94. package/dist/chunk-WEMZM7J7.cjs.map +1 -0
  95. package/dist/{chunk-NYQFPGYP.cjs → chunk-WFCECD6Q.cjs} +423 -1139
  96. package/dist/chunk-WFCECD6Q.cjs.map +1 -0
  97. package/dist/{chunk-EK6RJ373.cjs → chunk-YQGLVWB2.cjs} +7 -7
  98. package/dist/{chunk-EK6RJ373.cjs.map → chunk-YQGLVWB2.cjs.map} +1 -1
  99. package/dist/{chunk-X3244EKP.cjs → chunk-ZFWNO3GE.cjs} +48 -4
  100. package/dist/chunk-ZFWNO3GE.cjs.map +1 -0
  101. package/dist/ddl-BSFlbGQF.d.cts +38 -0
  102. package/dist/ddl-EdkIiFVU.d.ts +38 -0
  103. package/dist/{extension-types-B78CZfA5.d.cts → extension-types-CwHV-Uk4.d.cts} +4 -4
  104. package/dist/{extension-types-B78CZfA5.d.ts → extension-types-CwHV-Uk4.d.ts} +4 -4
  105. package/dist/graph-extension/index.cjs +19 -19
  106. package/dist/graph-extension/index.d.cts +4 -4
  107. package/dist/graph-extension/index.d.ts +4 -4
  108. package/dist/graph-extension/index.js +4 -4
  109. package/dist/{index-CWdBFWbI.d.ts → index-DzeIiMO3.d.ts} +30 -3
  110. package/dist/{index-Bilw0pYm.d.cts → index-Ln_KHTGA.d.cts} +30 -3
  111. package/dist/index.cjs +1542 -1011
  112. package/dist/index.cjs.map +1 -1
  113. package/dist/index.d.cts +142 -12
  114. package/dist/index.d.ts +142 -12
  115. package/dist/index.js +1138 -643
  116. package/dist/index.js.map +1 -1
  117. package/dist/indexes/index.cjs +19 -19
  118. package/dist/indexes/index.d.cts +9 -9
  119. package/dist/indexes/index.d.ts +9 -9
  120. package/dist/indexes/index.js +5 -5
  121. package/dist/interchange/index.cjs +8 -14
  122. package/dist/interchange/index.cjs.map +1 -1
  123. package/dist/interchange/index.d.cts +5 -16
  124. package/dist/interchange/index.d.ts +5 -16
  125. package/dist/interchange/index.js +3 -9
  126. package/dist/interchange/index.js.map +1 -1
  127. package/dist/{manager-ehLTTNq0.d.ts → manager-BbdyNhkv.d.ts} +2 -2
  128. package/dist/{manager-c1MGaVVR.d.cts → manager-wTDgjoXG.d.cts} +2 -2
  129. package/dist/{materialize-indexes-DFavFQah.d.ts → materialize-indexes-lkawaDor.d.ts} +1 -1
  130. package/dist/{materialize-indexes-BQfaAZKA.d.cts → materialize-indexes-oanE3RU0.d.cts} +1 -1
  131. package/dist/{ddl-0Ooc2dpL.d.ts → postgres-CK2ByP1q.d.cts} +2 -471
  132. package/dist/{ddl-Dza3kDrI.d.cts → postgres-ymXYC6Rr.d.ts} +2 -471
  133. package/dist/profiler/index.cjs +10 -10
  134. package/dist/profiler/index.d.cts +7 -7
  135. package/dist/profiler/index.d.ts +7 -7
  136. package/dist/profiler/index.js +3 -3
  137. package/dist/schema/index.cjs +33 -33
  138. package/dist/schema/index.d.cts +7 -7
  139. package/dist/schema/index.d.ts +7 -7
  140. package/dist/schema/index.js +10 -10
  141. package/dist/{sqlite-BxZUPbyD.d.ts → sqlite-DxH1lrwD.d.cts} +2 -468
  142. package/dist/{sqlite-mvpXjEeB.d.cts → sqlite-R8YGOqVQ.d.ts} +2 -468
  143. package/dist/{store-Ufc1Eoey.d.ts → store--z1Tmk7U.d.cts} +124 -5
  144. package/dist/{store-D7YEMg2v.d.cts → store-CNKM334w.d.ts} +124 -5
  145. package/dist/{types-CMQymcwk.d.cts → types-BBiDqJCU.d.ts} +252 -46
  146. package/dist/{types-B-sJJ4GQ.d.ts → types-CMvxx2kd.d.ts} +2 -2
  147. package/dist/{types-CmUA9sal.d.cts → types-D5B6Be5c.d.cts} +2 -2
  148. package/dist/{types-CQ7xXJMP.d.ts → types-dL-clxO3.d.cts} +252 -46
  149. package/dist/{where-CtrLu1Zf.d.ts → where-CAo6wsBZ.d.ts} +2 -2
  150. package/dist/{where-5zf15aFZ.d.cts → where-bJjuOCeV.d.cts} +2 -2
  151. package/package.json +20 -5
  152. package/dist/chunk-3EUKJEQ3.js +0 -77
  153. package/dist/chunk-3EUKJEQ3.js.map +0 -1
  154. package/dist/chunk-4FJVSF3K.cjs +0 -12
  155. package/dist/chunk-7V335GHG.cjs.map +0 -1
  156. package/dist/chunk-FFHW2JEK.cjs.map +0 -1
  157. package/dist/chunk-HTGDWIDE.cjs +0 -89
  158. package/dist/chunk-HTGDWIDE.cjs.map +0 -1
  159. package/dist/chunk-LYRUNG6E.cjs +0 -52
  160. package/dist/chunk-LYRUNG6E.cjs.map +0 -1
  161. package/dist/chunk-NMOE2ZEU.cjs.map +0 -1
  162. package/dist/chunk-NYQFPGYP.cjs.map +0 -1
  163. package/dist/chunk-NZ5PMBTG.js.map +0 -1
  164. package/dist/chunk-O57GYGYK.js.map +0 -1
  165. package/dist/chunk-OYLF3IC7.js.map +0 -1
  166. package/dist/chunk-PCHTTG42.js +0 -47
  167. package/dist/chunk-PCHTTG42.js.map +0 -1
  168. package/dist/chunk-PGU2XKMA.js.map +0 -1
  169. package/dist/chunk-PN37HVAV.cjs.map +0 -1
  170. package/dist/chunk-PYJOBZR3.cjs.map +0 -1
  171. package/dist/chunk-TKM2WDT4.js.map +0 -1
  172. package/dist/chunk-TSGBRPNE.js.map +0 -1
  173. package/dist/chunk-U5ROKVRF.js.map +0 -1
  174. package/dist/chunk-WFUN6DCM.cjs.map +0 -1
  175. package/dist/chunk-WVQXAFP3.js.map +0 -1
  176. package/dist/chunk-X3244EKP.cjs.map +0 -1
  177. package/dist/chunk-YEDQLNVE.cjs.map +0 -1
  178. package/dist/chunk-ZTREJOGB.js.map +0 -1
@@ -1,9 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkNYQFPGYP_cjs = require('./chunk-NYQFPGYP.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 chunkWFCECD6Q_cjs = require('./chunk-WFCECD6Q.cjs');
4
+ var chunkWEMZM7J7_cjs = require('./chunk-WEMZM7J7.cjs');
5
+ var chunkRP7YITHX_cjs = require('./chunk-RP7YITHX.cjs');
6
+ var chunkUESTHN47_cjs = require('./chunk-UESTHN47.cjs');
7
+ var chunkJIEJCTDS_cjs = require('./chunk-JIEJCTDS.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 chunkNYQFPGYP_cjs.getOrCreateLru(
74
+ return chunkWFCECD6Q_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) => chunkNYQFPGYP_cjs.compileQueryWithDialect(db, query, "SQLite");
110
+ const compile = (query) => chunkWFCECD6Q_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 = 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);
181
+ var toNodeRow = chunkWFCECD6Q_cjs.createNodeRowMapper(chunkWFCECD6Q_cjs.SQLITE_ROW_MAPPER_CONFIG);
182
+ var toEdgeRow = chunkWFCECD6Q_cjs.createEdgeRowMapper(chunkWFCECD6Q_cjs.SQLITE_ROW_MAPPER_CONFIG);
183
+ var toUniqueRow = chunkWFCECD6Q_cjs.createUniqueRowMapper(chunkWFCECD6Q_cjs.SQLITE_ROW_MAPPER_CONFIG);
184
+ var toSchemaVersionRow = chunkWFCECD6Q_cjs.createSchemaVersionRowMapper(
185
+ chunkWFCECD6Q_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 chunkJIEJCTDS_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 chunkJIEJCTDS_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" ? { ...chunkWEMZM7J7_cjs.SQLITE_CAPABILITIES, transactions: false } : chunkWEMZM7J7_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: chunkUESTHN47_cjs.buildFulltextCapabilities(options.fulltextStrategy),
239
+ ...options.vectorStrategy === void 0 ? {} : { vector: chunkUESTHN47_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 = chunkNYQFPGYP_cjs.createCommonOperationBackend({
270
+ const commonBackend = chunkWFCECD6Q_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: chunkNYQFPGYP_cjs.nowIso,
283
+ nowIso: chunkWFCECD6Q_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
- chunkNYQFPGYP_cjs.nowIso()
311
- );
312
- await execRun(query);
309
+ const slot = chunkWFCECD6Q_cjs.vectorSlotFromParams(params);
310
+ await ensureVectorSlotStorage(slot);
311
+ const statements = vectorStrategy.buildUpsert(slot, params, chunkWFCECD6Q_cjs.nowIso());
312
+ try {
313
+ for (const statement of statements) {
314
+ await execRun(statement);
315
+ }
316
+ } catch (error) {
317
+ throw chunkWFCECD6Q_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 = chunkWFCECD6Q_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
+ chunkUESTHN47_cjs.assertVectorSearchLimit(params.limit);
330
+ const slot = chunkWFCECD6Q_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 chunkWFCECD6Q_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 = chunkNYQFPGYP_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 = chunkWFCECD6Q_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 = chunkNYQFPGYP_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 = chunkWFCECD6Q_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 = chunkNYQFPGYP_cjs.nowIso();
376
+ const timestamp = chunkWFCECD6Q_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 = chunkNYQFPGYP_cjs.nowIso();
393
+ const timestamp = chunkWFCECD6Q_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: chunkNYQFPGYP_cjs.coerceNumericScore(row.score),
414
+ score: chunkWFCECD6Q_cjs.coerceNumericScore(row.score),
407
415
  rank: index + 1,
408
416
  ...row.snippet === null ? {} : { snippet: row.snippet }
409
417
  }));
@@ -422,25 +430,28 @@ function createSqliteOperationBackend(options) {
422
430
  return operationBackend;
423
431
  }
424
432
  function createSqliteBackend(db, options = {}) {
425
- const tables2 = options.tables ?? chunkNYQFPGYP_cjs.tables2;
426
- const fulltextStrategy = options.fulltext ?? chunkPN37HVAV_cjs.fts5Strategy;
433
+ const tables2 = options.tables ?? chunkWEMZM7J7_cjs.tables;
434
+ const fulltextStrategy = options.fulltext ?? chunkUESTHN47_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;
431
- const capabilities = buildSqliteCapabilities({
432
- fulltextStrategy,
433
- hasVectorEmbeddings,
434
- transactionMode
435
- });
438
+ const vectorStrategy = options.vector;
439
+ const vectorSlotLatch = vectorStrategy === void 0 ? void 0 : chunkWFCECD6Q_cjs.createVectorSlotLatch();
440
+ const capabilities = {
441
+ ...buildSqliteCapabilities({
442
+ fulltextStrategy,
443
+ vectorStrategy,
444
+ transactionMode
445
+ }),
446
+ ...options.capabilities
447
+ };
436
448
  const tableNames = {
437
449
  nodes: drizzleOrm.getTableName(tables2.nodes),
438
450
  edges: drizzleOrm.getTableName(tables2.edges),
439
- embeddings: drizzleOrm.getTableName(tables2.embeddings),
440
451
  fulltext: tables2.fulltextTableName,
441
452
  uniques: drizzleOrm.getTableName(tables2.uniques)
442
453
  };
443
- const operationStrategy = chunkNYQFPGYP_cjs.createSqliteOperationStrategy(
454
+ const operationStrategy = chunkWFCECD6Q_cjs.createSqliteOperationStrategy(
444
455
  tables2,
445
456
  fulltextStrategy
446
457
  );
@@ -452,7 +463,8 @@ function createSqliteBackend(db, options = {}) {
452
463
  operationStrategy,
453
464
  tableNames,
454
465
  fulltextStrategy,
455
- hasVectorEmbeddings,
466
+ vectorStrategy,
467
+ vectorSlotLatch,
456
468
  ...serializedQueue === void 0 ? {} : { serializedQueue }
457
469
  });
458
470
  function runDoSqliteStorageTransaction(run) {
@@ -484,8 +496,7 @@ function createSqliteBackend(db, options = {}) {
484
496
  profileHints: { isSync: true },
485
497
  tableNames,
486
498
  fulltextStrategy,
487
- hasVectorEmbeddings
488
- });
499
+ vectorStrategy});
489
500
  db.run(drizzleOrm.sql`BEGIN IMMEDIATE`);
490
501
  try {
491
502
  const result = await fn(txBackend);
@@ -506,30 +517,31 @@ function createSqliteBackend(db, options = {}) {
506
517
  profileHints: { isSync },
507
518
  tableNames,
508
519
  fulltextStrategy,
509
- hasVectorEmbeddings
510
- });
520
+ vectorStrategy});
511
521
  return fn(txBackend);
512
522
  });
513
523
  }
514
524
  return runWithSerializedQueue(
515
525
  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" })
526
+ async () => db.transaction(
527
+ async (tx) => {
528
+ const txBackend = createTransactionBackend({
529
+ capabilities,
530
+ db: tx,
531
+ operationStrategy,
532
+ profileHints: { isSync },
533
+ tableNames,
534
+ fulltextStrategy,
535
+ vectorStrategy});
536
+ return fn(txBackend);
537
+ },
538
+ { behavior: "immediate" }
539
+ )
528
540
  );
529
541
  }
530
542
  const matTable = tables2.contributionMaterializations;
531
543
  async function ensureContributionMaterializationsTableImpl() {
532
- await db.run(drizzleOrm.sql.raw(chunkNYQFPGYP_cjs.generateSqliteCreateTableSQL(matTable)));
544
+ await db.run(drizzleOrm.sql.raw(chunkWFCECD6Q_cjs.generateSqliteCreateTableSQL(matTable)));
533
545
  }
534
546
  async function getContributionMaterializationRow(identity) {
535
547
  const rows = await db.select().from(matTable).where(
@@ -542,16 +554,16 @@ function createSqliteBackend(db, options = {}) {
542
554
  );
543
555
  const row = rows[0];
544
556
  if (row === void 0) return void 0;
545
- return chunkNYQFPGYP_cjs.mapContributionMaterializationRow(
557
+ return chunkWFCECD6Q_cjs.mapContributionMaterializationRow(
546
558
  row,
547
- chunkNYQFPGYP_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.decode
559
+ chunkWFCECD6Q_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.decode
548
560
  );
549
561
  }
550
562
  async function recordContributionMaterializationRow(params) {
551
563
  await db.insert(matTable).values(
552
- chunkNYQFPGYP_cjs.buildContributionInsertValues(
564
+ chunkWFCECD6Q_cjs.buildContributionInsertValues(
553
565
  params,
554
- chunkNYQFPGYP_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.encode
566
+ chunkWFCECD6Q_cjs.SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.encode
555
567
  )
556
568
  ).onConflictDoUpdate({
557
569
  target: [
@@ -560,13 +572,13 @@ function createSqliteBackend(db, options = {}) {
560
572
  matTable.owner,
561
573
  matTable.tableName
562
574
  ],
563
- set: chunkNYQFPGYP_cjs.buildContributionOnConflictSet(
575
+ set: chunkWFCECD6Q_cjs.buildContributionOnConflictSet(
564
576
  matTable.materializedAt,
565
577
  params.materializedAt
566
578
  )
567
579
  });
568
580
  }
569
- const contributionMaterializer = chunkNYQFPGYP_cjs.createContributionMaterializer({
581
+ const contributionMaterializer = chunkWFCECD6Q_cjs.createContributionMaterializer({
570
582
  dialect: "sqlite",
571
583
  fulltextStrategy,
572
584
  fulltextTableName: tables2.fulltextTableName,
@@ -585,14 +597,13 @@ function createSqliteBackend(db, options = {}) {
585
597
  profileHints: { isSync },
586
598
  tableNames,
587
599
  fulltextStrategy,
588
- hasVectorEmbeddings
589
- });
590
- return chunkNYQFPGYP_cjs.gateFulltext(txBackend, contributionMaterializer.assertInitialized);
600
+ vectorStrategy});
601
+ return chunkWFCECD6Q_cjs.gateFulltext(txBackend, contributionMaterializer.assertInitialized);
591
602
  }
592
603
  const backend = {
593
604
  ...operations,
594
605
  async bootstrapTables() {
595
- const statements = chunkNYQFPGYP_cjs.generateSqliteDDL(tables2, fulltextStrategy);
606
+ const statements = chunkWFCECD6Q_cjs.generateSqliteDDL(tables2, fulltextStrategy);
596
607
  for (const statement of statements) {
597
608
  await db.run(drizzleOrm.sql.raw(statement));
598
609
  }
@@ -602,7 +613,7 @@ function createSqliteBackend(db, options = {}) {
602
613
  // uninitialized database throws `StoreNotInitializedError` rather
603
614
  // than self-healing (#135). Shared verbatim with the tx-scoped gate
604
615
  // via `gateFulltextMethods`.
605
- ...chunkNYQFPGYP_cjs.gateFulltextMethods(
616
+ ...chunkWFCECD6Q_cjs.gateFulltextMethods(
606
617
  operations,
607
618
  contributionMaterializer.assertInitialized
608
619
  ),
@@ -611,7 +622,7 @@ function createSqliteBackend(db, options = {}) {
611
622
  },
612
623
  async ensureIndexMaterializationsTable() {
613
624
  await db.run(
614
- drizzleOrm.sql.raw(chunkNYQFPGYP_cjs.generateSqliteCreateTableSQL(tables2.indexMaterializations))
625
+ drizzleOrm.sql.raw(chunkWFCECD6Q_cjs.generateSqliteCreateTableSQL(tables2.indexMaterializations))
615
626
  );
616
627
  },
617
628
  async getIndexMaterialization(indexName) {
@@ -619,26 +630,26 @@ function createSqliteBackend(db, options = {}) {
619
630
  const rows = await db.select().from(t).where(drizzleOrm.eq(t.indexName, indexName));
620
631
  const row = rows[0];
621
632
  if (row === void 0) return void 0;
622
- return chunkNYQFPGYP_cjs.mapMaterializationRow(row, chunkNYQFPGYP_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode);
633
+ return chunkWFCECD6Q_cjs.mapMaterializationRow(row, chunkWFCECD6Q_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode);
623
634
  },
624
635
  async getIndexMaterializations(statusKeys) {
625
636
  if (statusKeys.length === 0) return [];
626
637
  const t = tables2.indexMaterializations;
627
638
  const rows = await db.select().from(t).where(drizzleOrm.inArray(t.indexName, [...statusKeys]));
628
639
  return rows.map(
629
- (row) => chunkNYQFPGYP_cjs.mapMaterializationRow(row, chunkNYQFPGYP_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode)
640
+ (row) => chunkWFCECD6Q_cjs.mapMaterializationRow(row, chunkWFCECD6Q_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.decode)
630
641
  );
631
642
  },
632
643
  async recordIndexMaterialization(params) {
633
644
  const t = tables2.indexMaterializations;
634
645
  await db.insert(t).values(
635
- chunkNYQFPGYP_cjs.buildMaterializationInsertValues(
646
+ chunkWFCECD6Q_cjs.buildMaterializationInsertValues(
636
647
  params,
637
- chunkNYQFPGYP_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.encode
648
+ chunkWFCECD6Q_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.encode
638
649
  )
639
650
  ).onConflictDoUpdate({
640
651
  target: t.indexName,
641
- set: chunkNYQFPGYP_cjs.buildMaterializationOnConflictSet(
652
+ set: chunkWFCECD6Q_cjs.buildMaterializationOnConflictSet(
642
653
  t.materializedAt,
643
654
  params.materializedAt
644
655
  )
@@ -657,37 +668,37 @@ function createSqliteBackend(db, options = {}) {
657
668
  await contributionMaterializer.assertInitialized(graphId);
658
669
  },
659
670
  async ensureKindRemovalsTable() {
660
- await db.run(drizzleOrm.sql.raw(chunkNYQFPGYP_cjs.generateSqliteCreateTableSQL(tables2.kindRemovals)));
671
+ await db.run(drizzleOrm.sql.raw(chunkWFCECD6Q_cjs.generateSqliteCreateTableSQL(tables2.kindRemovals)));
661
672
  },
662
673
  async getPendingKindRemovals(graphId) {
663
674
  const t = tables2.kindRemovals;
664
675
  const rows = await db.select().from(t).where(drizzleOrm.and(drizzleOrm.eq(t.graphId, graphId), drizzleOrm.isNull(t.removedAt)));
665
676
  return rows.map(
666
- (row) => chunkNYQFPGYP_cjs.mapKindRemovalRow(row, chunkNYQFPGYP_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
677
+ (row) => chunkWFCECD6Q_cjs.mapKindRemovalRow(row, chunkWFCECD6Q_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
667
678
  );
668
679
  },
669
680
  async getAllKindRemovals(graphId) {
670
681
  const t = tables2.kindRemovals;
671
682
  const rows = await db.select().from(t).where(drizzleOrm.eq(t.graphId, graphId));
672
683
  return rows.map(
673
- (row) => chunkNYQFPGYP_cjs.mapKindRemovalRow(row, chunkNYQFPGYP_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
684
+ (row) => chunkWFCECD6Q_cjs.mapKindRemovalRow(row, chunkWFCECD6Q_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.decode)
674
685
  );
675
686
  },
676
687
  async recordKindRemoval(params) {
677
688
  const t = tables2.kindRemovals;
678
689
  await db.insert(t).values(
679
- chunkNYQFPGYP_cjs.buildKindRemovalInsertValues(
690
+ chunkWFCECD6Q_cjs.buildKindRemovalInsertValues(
680
691
  params,
681
- chunkNYQFPGYP_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.encode
692
+ chunkWFCECD6Q_cjs.SQLITE_KIND_REMOVAL_TIMESTAMPS.encode
682
693
  )
683
694
  ).onConflictDoUpdate({
684
695
  target: [t.graphId, t.kindName, t.entity, t.schemaVersion],
685
- set: chunkNYQFPGYP_cjs.buildKindRemovalOnConflictSet(t.removedAt, params.removedAt)
696
+ set: chunkWFCECD6Q_cjs.buildKindRemovalOnConflictSet(t.removedAt, params.removedAt)
686
697
  });
687
698
  },
688
699
  async ensureReconciliationMarkersTable() {
689
700
  await db.run(
690
- drizzleOrm.sql.raw(chunkNYQFPGYP_cjs.generateSqliteCreateTableSQL(tables2.reconciliationMarkers))
701
+ drizzleOrm.sql.raw(chunkWFCECD6Q_cjs.generateSqliteCreateTableSQL(tables2.reconciliationMarkers))
691
702
  );
692
703
  },
693
704
  async ensureRuntimeContributions(graphId) {
@@ -742,12 +753,11 @@ function createSqliteBackend(db, options = {}) {
742
753
  profileHints: { isSync: true },
743
754
  tableNames,
744
755
  fulltextStrategy,
745
- hasVectorEmbeddings
746
- });
756
+ vectorStrategy});
747
757
  db.run(drizzleOrm.sql`BEGIN`);
748
758
  try {
749
759
  const result = await fn(
750
- chunkNYQFPGYP_cjs.gateFulltext(
760
+ chunkWFCECD6Q_cjs.gateFulltext(
751
761
  txBackend,
752
762
  contributionMaterializer.assertInitialized
753
763
  ),
@@ -779,7 +789,7 @@ function createSqliteBackend(db, options = {}) {
779
789
  "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
790
  );
781
791
  }
782
- chunkNYQFPGYP_cjs.assertAdoptedDialect(
792
+ chunkWFCECD6Q_cjs.assertAdoptedDialect(
783
793
  externalTx,
784
794
  sqliteCore.BaseSQLiteDatabase,
785
795
  "sqlite"
@@ -804,10 +814,11 @@ function createTransactionBackend(options) {
804
814
  operationStrategy: options.operationStrategy,
805
815
  tableNames: options.tableNames,
806
816
  fulltextStrategy: options.fulltextStrategy,
807
- ...options.hasVectorEmbeddings === void 0 ? {} : { hasVectorEmbeddings: options.hasVectorEmbeddings }
817
+ vectorStrategy: options.vectorStrategy,
818
+ ...options.vectorStrategy === void 0 ? {} : { vectorSlotLatch: chunkWFCECD6Q_cjs.createVectorSlotLatch() }
808
819
  });
809
820
  }
810
821
 
811
822
  exports.createSqliteBackend = createSqliteBackend;
812
- //# sourceMappingURL=chunk-NMOE2ZEU.cjs.map
813
- //# sourceMappingURL=chunk-NMOE2ZEU.cjs.map
823
+ //# sourceMappingURL=chunk-4LBO6KIF.cjs.map
824
+ //# sourceMappingURL=chunk-4LBO6KIF.cjs.map