@nicia-ai/typegraph 0.28.1 → 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.
- package/dist/backend/postgres/index.cjs +23 -761
- package/dist/backend/postgres/index.cjs.map +1 -1
- package/dist/backend/postgres/index.d.cts +24 -5
- package/dist/backend/postgres/index.d.ts +24 -5
- package/dist/backend/postgres/index.js +10 -752
- package/dist/backend/postgres/index.js.map +1 -1
- package/dist/backend/postgres/pglite.cjs +52 -0
- package/dist/backend/postgres/pglite.cjs.map +1 -0
- package/dist/backend/postgres/pglite.d.cts +116 -0
- package/dist/backend/postgres/pglite.d.ts +116 -0
- package/dist/backend/postgres/pglite.js +50 -0
- package/dist/backend/postgres/pglite.js.map +1 -0
- package/dist/backend/sqlite/index.cjs +22 -26
- package/dist/backend/sqlite/index.d.cts +17 -15
- package/dist/backend/sqlite/index.d.ts +17 -15
- package/dist/backend/sqlite/index.js +9 -9
- package/dist/backend/sqlite/libsql.cjs +17 -13
- package/dist/backend/sqlite/libsql.cjs.map +1 -1
- package/dist/backend/sqlite/libsql.d.cts +3 -3
- package/dist/backend/sqlite/libsql.d.ts +3 -3
- package/dist/backend/sqlite/libsql.js +16 -12
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +17 -16
- package/dist/backend/sqlite/local.cjs.map +1 -1
- package/dist/backend/sqlite/local.d.cts +3 -3
- package/dist/backend/sqlite/local.d.ts +3 -3
- package/dist/backend/sqlite/local.js +15 -14
- package/dist/backend/sqlite/local.js.map +1 -1
- package/dist/{chunk-TKM2WDT4.js → chunk-3DTLDGIM.js} +386 -1093
- package/dist/chunk-3DTLDGIM.js.map +1 -0
- package/dist/{chunk-WVQXAFP3.js → chunk-454I6GDF.js} +46 -5
- package/dist/chunk-454I6GDF.js.map +1 -0
- package/dist/chunk-4K6IHUW6.cjs +183 -0
- package/dist/chunk-4K6IHUW6.cjs.map +1 -0
- package/dist/{chunk-ZTREJOGB.js → chunk-7KLVFWXR.js} +113 -68
- package/dist/chunk-7KLVFWXR.js.map +1 -0
- package/dist/{chunk-PGU2XKMA.js → chunk-A4H6QMV4.js} +110 -102
- package/dist/chunk-A4H6QMV4.js.map +1 -0
- package/dist/{chunk-E5ROA3MN.js → chunk-BMDF2S7S.js} +3 -3
- package/dist/{chunk-E5ROA3MN.js.map → chunk-BMDF2S7S.js.map} +1 -1
- package/dist/{chunk-PN37HVAV.cjs → chunk-C2RWFIYP.cjs} +121 -67
- package/dist/chunk-C2RWFIYP.cjs.map +1 -0
- package/dist/chunk-CUZGBWFT.js +206 -0
- package/dist/chunk-CUZGBWFT.js.map +1 -0
- package/dist/chunk-F2Q76CQ4.cjs +266 -0
- package/dist/chunk-F2Q76CQ4.cjs.map +1 -0
- package/dist/{chunk-YEDQLNVE.cjs → chunk-G6P3OVDY.cjs} +14 -2
- package/dist/chunk-G6P3OVDY.cjs.map +1 -0
- package/dist/chunk-GPUNAJFH.js +181 -0
- package/dist/chunk-GPUNAJFH.js.map +1 -0
- package/dist/chunk-HKN622O4.js +254 -0
- package/dist/chunk-HKN622O4.js.map +1 -0
- package/dist/{chunk-PYJOBZR3.cjs → chunk-HM6XMR3E.cjs} +52 -52
- package/dist/chunk-HM6XMR3E.cjs.map +1 -0
- package/dist/chunk-IE2TPFBT.js +305 -0
- package/dist/chunk-IE2TPFBT.js.map +1 -0
- package/dist/chunk-KGAJ5HFO.cjs +319 -0
- package/dist/chunk-KGAJ5HFO.cjs.map +1 -0
- package/dist/{chunk-O57GYGYK.js → chunk-M6OC455F.js} +32 -18
- package/dist/chunk-M6OC455F.js.map +1 -0
- package/dist/{chunk-U5ROKVRF.js → chunk-MB363HT5.js} +14 -3
- package/dist/chunk-MB363HT5.js.map +1 -0
- package/dist/{chunk-5MTOKWDA.js → chunk-MRMD7S7E.js} +9 -9
- package/dist/{chunk-5MTOKWDA.js.map → chunk-MRMD7S7E.js.map} +1 -1
- package/dist/{chunk-OOS2RKRH.js → chunk-N3VVQDMA.js} +3 -3
- package/dist/{chunk-OOS2RKRH.js.map → chunk-N3VVQDMA.js.map} +1 -1
- package/dist/{chunk-EJCDOA37.js → chunk-OGUH56BB.js} +4 -4
- package/dist/{chunk-EJCDOA37.js.map → chunk-OGUH56BB.js.map} +1 -1
- package/dist/chunk-Q3ZZLU3O.cjs +12 -0
- package/dist/{chunk-4FJVSF3K.cjs.map → chunk-Q3ZZLU3O.cjs.map} +1 -1
- package/dist/chunk-Q5ASTPM4.cjs +208 -0
- package/dist/chunk-Q5ASTPM4.cjs.map +1 -0
- package/dist/{chunk-WFUN6DCM.cjs → chunk-R2LA6MKR.cjs} +11 -11
- package/dist/chunk-R2LA6MKR.cjs.map +1 -0
- package/dist/{chunk-FFHW2JEK.cjs → chunk-RP7YITHX.cjs} +32 -17
- package/dist/chunk-RP7YITHX.cjs.map +1 -0
- package/dist/{chunk-NMOE2ZEU.cjs → chunk-RU5BBUU2.cjs} +132 -124
- package/dist/chunk-RU5BBUU2.cjs.map +1 -0
- package/dist/{chunk-TSGBRPNE.js → chunk-SFNUHFON.js} +45 -45
- package/dist/chunk-SFNUHFON.js.map +1 -0
- package/dist/chunk-UP4QAJND.cjs +740 -0
- package/dist/chunk-UP4QAJND.cjs.map +1 -0
- package/dist/{chunk-CTHNVU6K.cjs → chunk-UPBXUOW7.cjs} +8 -8
- package/dist/{chunk-CTHNVU6K.cjs.map → chunk-UPBXUOW7.cjs.map} +1 -1
- package/dist/{chunk-EK6RJ373.cjs → chunk-VGU26WIU.cjs} +5 -5
- package/dist/{chunk-EK6RJ373.cjs.map → chunk-VGU26WIU.cjs.map} +1 -1
- package/dist/{chunk-WZH2MKHW.cjs → chunk-XTQHSOIC.cjs} +101 -101
- package/dist/{chunk-WZH2MKHW.cjs.map → chunk-XTQHSOIC.cjs.map} +1 -1
- package/dist/chunk-Y52UNT66.js +738 -0
- package/dist/chunk-Y52UNT66.js.map +1 -0
- package/dist/{chunk-OYLF3IC7.js → chunk-Z36W5WUM.js} +4 -4
- package/dist/chunk-Z36W5WUM.js.map +1 -0
- package/dist/{chunk-X3244EKP.cjs → chunk-ZFWNO3GE.cjs} +48 -4
- package/dist/chunk-ZFWNO3GE.cjs.map +1 -0
- package/dist/{chunk-NYQFPGYP.cjs → chunk-ZYQEXGYC.cjs} +423 -1139
- package/dist/chunk-ZYQEXGYC.cjs.map +1 -0
- package/dist/ddl-BwH00BB6.d.ts +38 -0
- package/dist/ddl-D3o-RmsV.d.cts +38 -0
- package/dist/{extension-types-B78CZfA5.d.cts → extension-types-CwHV-Uk4.d.cts} +4 -4
- package/dist/{extension-types-B78CZfA5.d.ts → extension-types-CwHV-Uk4.d.ts} +4 -4
- package/dist/graph-extension/index.cjs +18 -18
- package/dist/graph-extension/index.d.cts +4 -4
- package/dist/graph-extension/index.d.ts +4 -4
- package/dist/graph-extension/index.js +3 -3
- package/dist/{index-CWdBFWbI.d.ts → index-CapHwi1a.d.ts} +22 -3
- package/dist/{index-Bilw0pYm.d.cts → index-jPPexxM5.d.cts} +22 -3
- package/dist/index.cjs +1211 -945
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +142 -12
- package/dist/index.d.ts +142 -12
- package/dist/index.js +778 -544
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +18 -18
- package/dist/indexes/index.d.cts +9 -9
- package/dist/indexes/index.d.ts +9 -9
- package/dist/indexes/index.js +4 -4
- package/dist/interchange/index.cjs +8 -14
- package/dist/interchange/index.cjs.map +1 -1
- package/dist/interchange/index.d.cts +5 -16
- package/dist/interchange/index.d.ts +5 -16
- package/dist/interchange/index.js +3 -9
- package/dist/interchange/index.js.map +1 -1
- package/dist/{manager-ehLTTNq0.d.ts → manager-BUugwCYz.d.ts} +2 -2
- package/dist/{manager-c1MGaVVR.d.cts → manager-DpIpn1HQ.d.cts} +2 -2
- package/dist/{materialize-indexes-DFavFQah.d.ts → materialize-indexes-lkawaDor.d.ts} +1 -1
- package/dist/{materialize-indexes-BQfaAZKA.d.cts → materialize-indexes-oanE3RU0.d.cts} +1 -1
- package/dist/{ddl-0Ooc2dpL.d.ts → postgres-CQL9UIn2.d.cts} +2 -471
- package/dist/{ddl-Dza3kDrI.d.cts → postgres-CcRLaxz0.d.ts} +2 -471
- package/dist/profiler/index.cjs +4 -4
- package/dist/profiler/index.d.cts +7 -7
- package/dist/profiler/index.d.ts +7 -7
- package/dist/profiler/index.js +2 -2
- package/dist/schema/index.cjs +32 -32
- package/dist/schema/index.d.cts +7 -7
- package/dist/schema/index.d.ts +7 -7
- package/dist/schema/index.js +9 -9
- package/dist/{sqlite-BxZUPbyD.d.ts → sqlite-CZDFUfHS.d.ts} +2 -468
- package/dist/{sqlite-mvpXjEeB.d.cts → sqlite-Rj3xu4It.d.cts} +2 -468
- package/dist/{store-D7YEMg2v.d.cts → store-B43FpOVX.d.cts} +84 -5
- package/dist/{store-Ufc1Eoey.d.ts → store-De0Y33wP.d.ts} +84 -5
- package/dist/{types-B-sJJ4GQ.d.ts → types-B5GSeE3t.d.ts} +2 -2
- package/dist/{types-CmUA9sal.d.cts → types-Bwlp_yvu.d.cts} +2 -2
- package/dist/{types-CMQymcwk.d.cts → types-CmAT-Z47.d.ts} +250 -46
- package/dist/{types-CQ7xXJMP.d.ts → types-DXCSyxac.d.cts} +250 -46
- package/dist/{where-5zf15aFZ.d.cts → where-2dsyYt3d.d.cts} +2 -2
- package/dist/{where-CtrLu1Zf.d.ts → where-CP4qGIHd.d.ts} +2 -2
- package/package.json +20 -5
- package/dist/chunk-3EUKJEQ3.js +0 -77
- package/dist/chunk-3EUKJEQ3.js.map +0 -1
- package/dist/chunk-4FJVSF3K.cjs +0 -12
- package/dist/chunk-FFHW2JEK.cjs.map +0 -1
- package/dist/chunk-HTGDWIDE.cjs +0 -89
- package/dist/chunk-HTGDWIDE.cjs.map +0 -1
- package/dist/chunk-LYRUNG6E.cjs +0 -52
- package/dist/chunk-LYRUNG6E.cjs.map +0 -1
- package/dist/chunk-NMOE2ZEU.cjs.map +0 -1
- package/dist/chunk-NYQFPGYP.cjs.map +0 -1
- package/dist/chunk-O57GYGYK.js.map +0 -1
- package/dist/chunk-OYLF3IC7.js.map +0 -1
- package/dist/chunk-PCHTTG42.js +0 -47
- package/dist/chunk-PCHTTG42.js.map +0 -1
- package/dist/chunk-PGU2XKMA.js.map +0 -1
- package/dist/chunk-PN37HVAV.cjs.map +0 -1
- package/dist/chunk-PYJOBZR3.cjs.map +0 -1
- package/dist/chunk-TKM2WDT4.js.map +0 -1
- package/dist/chunk-TSGBRPNE.js.map +0 -1
- package/dist/chunk-U5ROKVRF.js.map +0 -1
- package/dist/chunk-WFUN6DCM.cjs.map +0 -1
- package/dist/chunk-WVQXAFP3.js.map +0 -1
- package/dist/chunk-X3244EKP.cjs.map +0 -1
- package/dist/chunk-YEDQLNVE.cjs.map +0 -1
- package/dist/chunk-ZTREJOGB.js.map +0 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
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
|
|
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) =>
|
|
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 =
|
|
181
|
-
var toEdgeRow =
|
|
182
|
-
var toUniqueRow =
|
|
183
|
-
var toSchemaVersionRow =
|
|
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
|
|
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
|
|
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" ? { ...
|
|
235
|
+
const base = options.transactionMode === "none" ? { ...chunkF2Q76CQ4_cjs.SQLITE_CAPABILITIES, transactions: false } : chunkF2Q76CQ4_cjs.SQLITE_CAPABILITIES;
|
|
236
236
|
return {
|
|
237
237
|
...base,
|
|
238
|
-
fulltext:
|
|
239
|
-
...options.
|
|
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 =
|
|
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:
|
|
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
|
-
|
|
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
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
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
|
|
316
|
-
await
|
|
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
|
-
|
|
320
|
-
const
|
|
321
|
-
|
|
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
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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 = 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
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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 =
|
|
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 =
|
|
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:
|
|
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 ??
|
|
426
|
-
const fulltextStrategy = options.fulltext ??
|
|
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
|
|
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
|
-
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
510
|
-
});
|
|
517
|
+
vectorStrategy});
|
|
511
518
|
return fn(txBackend);
|
|
512
519
|
});
|
|
513
520
|
}
|
|
514
521
|
return runWithSerializedQueue(
|
|
515
522
|
serializedQueue,
|
|
516
|
-
async () => db.transaction(
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
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(
|
|
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
|
|
554
|
+
return chunkZYQEXGYC_cjs.mapContributionMaterializationRow(
|
|
546
555
|
row,
|
|
547
|
-
|
|
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
|
-
|
|
561
|
+
chunkZYQEXGYC_cjs.buildContributionInsertValues(
|
|
553
562
|
params,
|
|
554
|
-
|
|
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:
|
|
572
|
+
set: chunkZYQEXGYC_cjs.buildContributionOnConflictSet(
|
|
564
573
|
matTable.materializedAt,
|
|
565
574
|
params.materializedAt
|
|
566
575
|
)
|
|
567
576
|
});
|
|
568
577
|
}
|
|
569
|
-
const contributionMaterializer =
|
|
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
|
-
|
|
589
|
-
|
|
590
|
-
return chunkNYQFPGYP_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 =
|
|
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
|
-
...
|
|
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(
|
|
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
|
|
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) =>
|
|
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
|
-
|
|
643
|
+
chunkZYQEXGYC_cjs.buildMaterializationInsertValues(
|
|
636
644
|
params,
|
|
637
|
-
|
|
645
|
+
chunkZYQEXGYC_cjs.SQLITE_INDEX_MAT_TIMESTAMPS.encode
|
|
638
646
|
)
|
|
639
647
|
).onConflictDoUpdate({
|
|
640
648
|
target: t.indexName,
|
|
641
|
-
set:
|
|
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(
|
|
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) =>
|
|
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) =>
|
|
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
|
-
|
|
687
|
+
chunkZYQEXGYC_cjs.buildKindRemovalInsertValues(
|
|
680
688
|
params,
|
|
681
|
-
|
|
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:
|
|
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(
|
|
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
|
-
|
|
746
|
-
});
|
|
753
|
+
vectorStrategy});
|
|
747
754
|
db.run(drizzleOrm.sql`BEGIN`);
|
|
748
755
|
try {
|
|
749
756
|
const result = await fn(
|
|
750
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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-
|
|
813
|
-
//# sourceMappingURL=chunk-
|
|
820
|
+
//# sourceMappingURL=chunk-RU5BBUU2.cjs.map
|
|
821
|
+
//# sourceMappingURL=chunk-RU5BBUU2.cjs.map
|