@nicia-ai/typegraph 0.36.0 → 0.37.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 +24 -24
- package/dist/backend/postgres/index.d.cts +6 -6
- package/dist/backend/postgres/index.d.ts +6 -6
- package/dist/backend/postgres/index.js +11 -11
- package/dist/backend/postgres/pglite.cjs +16 -16
- package/dist/backend/postgres/pglite.d.cts +3 -3
- package/dist/backend/postgres/pglite.d.ts +3 -3
- package/dist/backend/postgres/pglite.js +11 -11
- package/dist/backend/sqlite/index.cjs +22 -21
- package/dist/backend/sqlite/index.d.cts +11 -9
- package/dist/backend/sqlite/index.d.ts +11 -9
- package/dist/backend/sqlite/index.js +10 -9
- package/dist/backend/sqlite/libsql.cjs +15 -14
- 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 +11 -10
- package/dist/backend/sqlite/libsql.js.map +1 -1
- package/dist/backend/sqlite/local.cjs +30 -23
- 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 +18 -11
- package/dist/backend/sqlite/local.js.map +1 -1
- package/dist/{chunk-TCOCYN2P.cjs → chunk-27SSDCEP.cjs} +14 -14
- package/dist/{chunk-TCOCYN2P.cjs.map → chunk-27SSDCEP.cjs.map} +1 -1
- package/dist/{chunk-5AQIKK56.cjs → chunk-2N6EOBTH.cjs} +16 -16
- package/dist/{chunk-5AQIKK56.cjs.map → chunk-2N6EOBTH.cjs.map} +1 -1
- package/dist/{chunk-FN35DLCN.cjs → chunk-3C2RYI6L.cjs} +13 -107
- package/dist/chunk-3C2RYI6L.cjs.map +1 -0
- package/dist/{chunk-HW3LW7DH.cjs → chunk-3DS7Z4T4.cjs} +39 -39
- package/dist/{chunk-HW3LW7DH.cjs.map → chunk-3DS7Z4T4.cjs.map} +1 -1
- package/dist/{chunk-RSSQKPSZ.cjs → chunk-3GH67G4Z.cjs} +5 -5
- package/dist/{chunk-RSSQKPSZ.cjs.map → chunk-3GH67G4Z.cjs.map} +1 -1
- package/dist/{chunk-M75SUBFG.js → chunk-3RWZPJKV.js} +24 -9
- package/dist/chunk-3RWZPJKV.js.map +1 -0
- package/dist/{chunk-SKCOUWAX.js → chunk-3SLPDKHQ.js} +4 -4
- package/dist/chunk-3SLPDKHQ.js.map +1 -0
- package/dist/{chunk-5A6FNS6N.cjs → chunk-3XXGYU62.cjs} +11 -11
- package/dist/{chunk-5A6FNS6N.cjs.map → chunk-3XXGYU62.cjs.map} +1 -1
- package/dist/{chunk-IU46OHVW.js → chunk-44TA22QT.js} +58 -11
- package/dist/chunk-44TA22QT.js.map +1 -0
- package/dist/{chunk-5DIPR3L3.js → chunk-552KNYQJ.js} +2392 -279
- package/dist/chunk-552KNYQJ.js.map +1 -0
- package/dist/{chunk-2THZ3TQI.cjs → chunk-5KEQ74YU.cjs} +14 -14
- package/dist/chunk-5KEQ74YU.cjs.map +1 -0
- package/dist/{chunk-Q5TEXCTB.js → chunk-5KPNWT6X.js} +3 -3
- package/dist/{chunk-Q5TEXCTB.js.map → chunk-5KPNWT6X.js.map} +1 -1
- package/dist/{chunk-WI7ISNQF.js → chunk-5PNMDJ7J.js} +94 -5
- package/dist/chunk-5PNMDJ7J.js.map +1 -0
- package/dist/{chunk-AW4A3P5A.cjs → chunk-5VQM6VWP.cjs} +2 -2
- package/dist/{chunk-AW4A3P5A.cjs.map → chunk-5VQM6VWP.cjs.map} +1 -1
- package/dist/{chunk-A3W7QG7K.js → chunk-5WWVZMVX.js} +2 -2
- package/dist/{chunk-A3W7QG7K.js.map → chunk-5WWVZMVX.js.map} +1 -1
- package/dist/{chunk-FACJJWGF.cjs → chunk-6EEO3OVU.cjs} +7 -7
- package/dist/{chunk-FACJJWGF.cjs.map → chunk-6EEO3OVU.cjs.map} +1 -1
- package/dist/{chunk-DIK74MXX.cjs → chunk-BVRDGYXQ.cjs} +97 -4
- package/dist/chunk-BVRDGYXQ.cjs.map +1 -0
- package/dist/{chunk-4BCU6VFZ.cjs → chunk-DEFQM7JU.cjs} +7 -7
- package/dist/{chunk-4BCU6VFZ.cjs.map → chunk-DEFQM7JU.cjs.map} +1 -1
- package/dist/{chunk-456Z2U7Y.cjs → chunk-DIQ3AV5W.cjs} +574 -268
- package/dist/chunk-DIQ3AV5W.cjs.map +1 -0
- package/dist/{chunk-FPIZFYHE.js → chunk-EXU3RASM.js} +74 -15
- package/dist/chunk-EXU3RASM.js.map +1 -0
- package/dist/{chunk-H7YNSMA7.cjs → chunk-HAHNRASW.cjs} +20 -2
- package/dist/chunk-HAHNRASW.cjs.map +1 -0
- package/dist/{chunk-J3LEGNQB.cjs → chunk-IP3CGGPA.cjs} +8 -8
- package/dist/{chunk-J3LEGNQB.cjs.map → chunk-IP3CGGPA.cjs.map} +1 -1
- package/dist/{chunk-X4JBT642.cjs → chunk-IPSVVTWT.cjs} +94 -35
- package/dist/chunk-IPSVVTWT.cjs.map +1 -0
- package/dist/{chunk-VQEXF5D4.js → chunk-IXGYRP2P.js} +184 -92
- package/dist/chunk-IXGYRP2P.js.map +1 -0
- package/dist/{chunk-BJVEU3ZL.js → chunk-J4IUSYFF.js} +251 -121
- package/dist/chunk-J4IUSYFF.js.map +1 -0
- package/dist/{chunk-JFMEONLG.cjs → chunk-JBNOGRKW.cjs} +318 -188
- package/dist/chunk-JBNOGRKW.cjs.map +1 -0
- package/dist/{chunk-4GX2JJXS.js → chunk-K3Q3LJY3.js} +520 -221
- package/dist/chunk-K3Q3LJY3.js.map +1 -0
- package/dist/{chunk-OR5ZA5WP.js → chunk-K5UBVGJN.js} +4 -4
- package/dist/{chunk-OR5ZA5WP.js.map → chunk-K5UBVGJN.js.map} +1 -1
- package/dist/{chunk-UZV3AZKF.js → chunk-KQJ54OG5.js} +3 -3
- package/dist/{chunk-UZV3AZKF.js.map → chunk-KQJ54OG5.js.map} +1 -1
- package/dist/{chunk-SXGE7ITL.js → chunk-L7HQ2OSI.js} +4 -4
- package/dist/{chunk-SXGE7ITL.js.map → chunk-L7HQ2OSI.js.map} +1 -1
- package/dist/{chunk-RAXU3RMB.js → chunk-M6VES7V6.js} +4 -4
- package/dist/{chunk-RAXU3RMB.js.map → chunk-M6VES7V6.js.map} +1 -1
- package/dist/{chunk-7BQLPXK6.cjs → chunk-NBP2WTJW.cjs} +3011 -898
- package/dist/chunk-NBP2WTJW.cjs.map +1 -0
- package/dist/{chunk-PWGX5DF5.cjs → chunk-NUIG3BCV.cjs} +100 -85
- package/dist/chunk-NUIG3BCV.cjs.map +1 -0
- package/dist/{chunk-ZAMFOJ5P.cjs → chunk-NXQFATMF.cjs} +269 -177
- package/dist/chunk-NXQFATMF.cjs.map +1 -0
- package/dist/{chunk-KBGQIPRQ.js → chunk-PC2UBAUB.js} +20 -3
- package/dist/chunk-PC2UBAUB.js.map +1 -0
- package/dist/chunk-QARBLBXT.cjs +219 -0
- package/dist/chunk-QARBLBXT.cjs.map +1 -0
- package/dist/{chunk-6FR2MMS6.js → chunk-QERAIDRJ.js} +45 -4
- package/dist/chunk-QERAIDRJ.js.map +1 -0
- package/dist/chunk-QSXTWU4U.cjs +12 -0
- package/dist/{chunk-4BMPGT35.cjs.map → chunk-QSXTWU4U.cjs.map} +1 -1
- package/dist/{chunk-DN5VP4JC.js → chunk-RCVLFTCT.js} +9 -10
- package/dist/chunk-RCVLFTCT.js.map +1 -0
- package/dist/{chunk-ZIGXMKQQ.js → chunk-RRSNR3TP.js} +3 -3
- package/dist/{chunk-ZIGXMKQQ.js.map → chunk-RRSNR3TP.js.map} +1 -1
- package/dist/{chunk-4CAXEB2F.cjs → chunk-TGOMW4MB.cjs} +91 -92
- package/dist/chunk-TGOMW4MB.cjs.map +1 -0
- package/dist/{chunk-PZKNKG5M.js → chunk-TKT2XHED.js} +8 -8
- package/dist/{chunk-PZKNKG5M.js.map → chunk-TKT2XHED.js.map} +1 -1
- package/dist/{chunk-S5F7ZLP2.js → chunk-TPF25IG6.js} +3 -3
- package/dist/{chunk-S5F7ZLP2.js.map → chunk-TPF25IG6.js.map} +1 -1
- package/dist/{chunk-5SEGFTZX.js → chunk-UGZUAYAR.js} +3 -3
- package/dist/{chunk-5SEGFTZX.js.map → chunk-UGZUAYAR.js.map} +1 -1
- package/dist/{chunk-VHMPG6UL.js → chunk-UXLSNRYL.js} +11 -105
- package/dist/chunk-UXLSNRYL.js.map +1 -0
- package/dist/{chunk-FRV5Q5IO.js → chunk-UYQMBBWJ.js} +3 -3
- package/dist/{chunk-FRV5Q5IO.js.map → chunk-UYQMBBWJ.js.map} +1 -1
- package/dist/{chunk-UUT7UN2N.cjs → chunk-VGDDG3XJ.cjs} +7 -7
- package/dist/{chunk-UUT7UN2N.cjs.map → chunk-VGDDG3XJ.cjs.map} +1 -1
- package/dist/{chunk-5VTR2F2K.js → chunk-VKGKDOKR.js} +12 -10
- package/dist/chunk-VKGKDOKR.js.map +1 -0
- package/dist/{chunk-5W4L6DLF.cjs → chunk-VL2V6PEN.cjs} +11 -11
- package/dist/{chunk-5W4L6DLF.cjs.map → chunk-VL2V6PEN.cjs.map} +1 -1
- package/dist/{chunk-ZUNQ5BEP.cjs → chunk-WOJMKB3N.cjs} +82 -80
- package/dist/chunk-WOJMKB3N.cjs.map +1 -0
- package/dist/{chunk-UMDVATGY.cjs → chunk-WWFHO375.cjs} +6 -6
- package/dist/{chunk-UMDVATGY.cjs.map → chunk-WWFHO375.cjs.map} +1 -1
- package/dist/{chunk-JFUPDJXD.js → chunk-XGPUQ56G.js} +3 -3
- package/dist/{chunk-JFUPDJXD.js.map → chunk-XGPUQ56G.js.map} +1 -1
- package/dist/{chunk-D7ZEOS56.cjs → chunk-XGU7DZDA.cjs} +74 -14
- package/dist/chunk-XGU7DZDA.cjs.map +1 -0
- package/dist/{chunk-S55OV6PW.cjs → chunk-XPCZADMT.cjs} +54 -11
- package/dist/chunk-XPCZADMT.cjs.map +1 -0
- package/dist/{chunk-T2WUSPDA.js → chunk-XWV4JT34.js} +3 -3
- package/dist/{chunk-T2WUSPDA.js.map → chunk-XWV4JT34.js.map} +1 -1
- package/dist/chunk-YTSN73ND.js +212 -0
- package/dist/chunk-YTSN73ND.js.map +1 -0
- package/dist/{ddl-CZz7a0E8.d.cts → ddl-BD-ZfKeX.d.cts} +3 -3
- package/dist/{ddl-C2rZ-Aen.d.ts → ddl-CS0KUVwB.d.ts} +3 -3
- package/dist/{extension-types-ixRpJVUp.d.ts → extension-types-BM2ACfYO.d.cts} +6 -1
- package/dist/{extension-types-ixRpJVUp.d.cts → extension-types-BM2ACfYO.d.ts} +6 -1
- package/dist/{fulltext-strategy-CDkSSYhq.d.cts → fulltext-strategy-C27vXaeB.d.cts} +127 -8
- package/dist/{fulltext-strategy-B57yvC5Q.d.ts → fulltext-strategy-DebsMrqg.d.ts} +127 -8
- package/dist/graph-extension/index.cjs +19 -19
- package/dist/graph-extension/index.d.cts +4 -4
- package/dist/graph-extension/index.d.ts +4 -4
- package/dist/graph-extension/index.js +4 -4
- package/dist/graph-merge/index.cjs +88 -88
- package/dist/graph-merge/index.d.cts +6 -6
- package/dist/graph-merge/index.d.ts +6 -6
- package/dist/graph-merge/index.js +19 -19
- package/dist/{index-BLtQWKRj.d.cts → index-BPM59vsg.d.cts} +52 -7
- package/dist/{index-BFvdmBPV.d.ts → index-BeacbPoe.d.ts} +52 -7
- package/dist/index.cjs +224 -187
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +53 -40
- package/dist/index.js.map +1 -1
- package/dist/indexes/index.cjs +30 -21
- package/dist/indexes/index.d.cts +5 -5
- package/dist/indexes/index.d.ts +5 -5
- package/dist/indexes/index.js +8 -7
- package/dist/interchange/index.cjs +207 -30
- package/dist/interchange/index.cjs.map +1 -1
- package/dist/interchange/index.d.cts +25 -8
- package/dist/interchange/index.d.ts +25 -8
- package/dist/interchange/index.js +190 -11
- package/dist/interchange/index.js.map +1 -1
- package/dist/{manager-DwQi8eV0.d.cts → manager-D00_NXvT.d.ts} +11 -2
- package/dist/{manager-ejUCB52T.d.ts → manager-nU1vTJLy.d.cts} +11 -2
- package/dist/{materialize-indexes-B4e9360H.d.cts → materialize-indexes-CuR3gAZb.d.cts} +8 -2
- package/dist/{materialize-indexes-te9TPMMJ.d.ts → materialize-indexes-zK2J_flP.d.ts} +8 -2
- package/dist/{postgres-CfEqsRMp.d.cts → postgres-IaBA4RgE.d.ts} +1 -1
- package/dist/{postgres-DQ5R6rzV.d.ts → postgres-YrYmPlaU.d.cts} +1 -1
- package/dist/profiler/index.cjs +3 -3
- 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/provenance/index.cjs +32 -33
- package/dist/provenance/index.cjs.map +1 -1
- package/dist/provenance/index.d.cts +5 -5
- package/dist/provenance/index.d.ts +5 -5
- package/dist/provenance/index.js +5 -6
- package/dist/provenance/index.js.map +1 -1
- package/dist/schema/index.cjs +35 -35
- package/dist/schema/index.d.cts +7 -7
- package/dist/schema/index.d.ts +7 -7
- package/dist/schema/index.js +11 -11
- package/dist/{sqlite-DvQndLky.d.ts → sqlite-BUOHPx7p.d.ts} +1 -1
- package/dist/{sqlite-D7zBinNR.d.cts → sqlite-Pp8O19WE.d.cts} +1 -1
- package/dist/{store-view-DplHC3Nt.d.ts → store-view-ANL6mTph.d.ts} +213 -27
- package/dist/{store-view-9KDOpZzF.d.cts → store-view-X96Rd00T.d.cts} +213 -27
- package/dist/{types-Bv9DcS_E.d.cts → types-r-Zyq2Hz.d.cts} +2 -2
- package/dist/{types-CoxuV7EJ.d.ts → types-wsvuBgPK.d.ts} +2 -2
- package/dist/where-CJOpJj3a.d.ts +36 -0
- package/dist/where-K3uBP33l.d.cts +36 -0
- package/package.json +1 -1
- package/dist/chunk-2THZ3TQI.cjs.map +0 -1
- package/dist/chunk-456Z2U7Y.cjs.map +0 -1
- package/dist/chunk-4BMPGT35.cjs +0 -12
- package/dist/chunk-4CAXEB2F.cjs.map +0 -1
- package/dist/chunk-4GX2JJXS.js.map +0 -1
- package/dist/chunk-5DIPR3L3.js.map +0 -1
- package/dist/chunk-5VTR2F2K.js.map +0 -1
- package/dist/chunk-6FR2MMS6.js.map +0 -1
- package/dist/chunk-7BQLPXK6.cjs.map +0 -1
- package/dist/chunk-BJVEU3ZL.js.map +0 -1
- package/dist/chunk-D7ZEOS56.cjs.map +0 -1
- package/dist/chunk-DIK74MXX.cjs.map +0 -1
- package/dist/chunk-DN5VP4JC.js.map +0 -1
- package/dist/chunk-EOLERH7Y.cjs +0 -40
- package/dist/chunk-EOLERH7Y.cjs.map +0 -1
- package/dist/chunk-FN35DLCN.cjs.map +0 -1
- package/dist/chunk-FPIZFYHE.js.map +0 -1
- package/dist/chunk-H7YNSMA7.cjs.map +0 -1
- package/dist/chunk-IU46OHVW.js.map +0 -1
- package/dist/chunk-JFMEONLG.cjs.map +0 -1
- package/dist/chunk-KBGQIPRQ.js.map +0 -1
- package/dist/chunk-M75SUBFG.js.map +0 -1
- package/dist/chunk-PWGX5DF5.cjs.map +0 -1
- package/dist/chunk-S55OV6PW.cjs.map +0 -1
- package/dist/chunk-SKCOUWAX.js.map +0 -1
- package/dist/chunk-UT3S4SEN.js +0 -31
- package/dist/chunk-UT3S4SEN.js.map +0 -1
- package/dist/chunk-VHMPG6UL.js.map +0 -1
- package/dist/chunk-VQEXF5D4.js.map +0 -1
- package/dist/chunk-WI7ISNQF.js.map +0 -1
- package/dist/chunk-X4JBT642.cjs.map +0 -1
- package/dist/chunk-ZAMFOJ5P.cjs.map +0 -1
- package/dist/chunk-ZUNQ5BEP.cjs.map +0 -1
- package/dist/where-7RKFOsXt.d.ts +0 -11
- package/dist/where-DdMIXOtH.d.cts +0 -11
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { tables } from './chunk-
|
|
3
|
-
import { createNodeRowMapper, SQLITE_ROW_MAPPER_CONFIG, createEdgeRowMapper, createUniqueRowMapper, createSchemaVersionRowMapper, quoteIdentifier, nowIso, coerceNumericScore } from './chunk-
|
|
4
|
-
import { fts5Strategy, buildVectorCapabilities, buildFulltextCapabilities, assertVectorSearchLimit } from './chunk-
|
|
5
|
-
import { SQLITE_CAPABILITIES, SQLITE_MAX_BIND_PARAMETERS,
|
|
6
|
-
import { isMissingTableError } from './chunk-
|
|
7
|
-
import { ConfigurationError, BackendDisposedError } from './chunk-
|
|
8
|
-
import { getTableName, sql,
|
|
1
|
+
import { createSqliteOperationStrategy, createContributionMaterializer, gateFulltextMethods, assertTrustedImportDatabaseEmpty, suspendSqliteSecondaryIndexes, createSqliteTrustedImportSession, restoreSecondaryIndexes, analyzeImportedTables, generateSqliteCreateTableSQL, mapContributionMaterializationRow, SQLITE_CONTRIBUTION_MAT_TIMESTAMPS, buildContributionInsertValues, buildContributionOnConflictSet, assertAdoptedDialect, buildKindRemovalInsertValues, SQLITE_KIND_REMOVAL_TIMESTAMPS, buildKindRemovalOnConflictSet, mapKindRemovalRow, buildMaterializationInsertValues, SQLITE_INDEX_MAT_TIMESTAMPS, buildMaterializationOnConflictSet, mapMaterializationRow, generateSqliteDDL, createCommonOperationBackend, vectorSlotFromParams, hybridCandidatesRef, mapVectorWriteError, mapHybridSearchRow, gateFulltext, compileQueryWithDialect, EMBEDDING_UPSERT_PARAM_COUNT, vectorSlotFromDropIndexParams, vectorSlotFromCreateIndexParams, getOrCreateLru } from './chunk-K3Q3LJY3.js';
|
|
2
|
+
import { tables } from './chunk-UXLSNRYL.js';
|
|
3
|
+
import { createNodeRowMapper, SQLITE_ROW_MAPPER_CONFIG, createEdgeRowMapper, createUniqueRowMapper, createSchemaVersionRowMapper, quoteIdentifier, nowIso, coerceNumericScore } from './chunk-M6VES7V6.js';
|
|
4
|
+
import { fts5Strategy, buildVectorCapabilities, buildFulltextCapabilities, assertVectorSearchLimit } from './chunk-EXU3RASM.js';
|
|
5
|
+
import { normalizeGraphAnalyticsCapabilities, INTERNAL_TEMPORARY_WRITES, SQLITE_CAPABILITIES, SQLITE_MAX_BIND_PARAMETERS, MODERN_SQLITE_MAX_BIND_PARAMETERS, chunk, DURABLE_OBJECT_MAX_BIND_PARAMETERS, D1_MAX_BIND_PARAMETERS } from './chunk-44TA22QT.js';
|
|
6
|
+
import { isMissingTableError } from './chunk-XGPUQ56G.js';
|
|
7
|
+
import { ConfigurationError, BackendDisposedError } from './chunk-5PNMDJ7J.js';
|
|
8
|
+
import { getTableName, sql, eq, and, isNull, inArray } from 'drizzle-orm';
|
|
9
9
|
import { BaseSQLiteDatabase } from 'drizzle-orm/sqlite-core';
|
|
10
10
|
|
|
11
11
|
var DEFAULT_PREPARED_STATEMENT_CACHE_MAX = 256;
|
|
@@ -24,11 +24,30 @@ function isDurableObjectBySessionName(db) {
|
|
|
24
24
|
const sessionName = getSessionName(db);
|
|
25
25
|
return sessionName === "SQLiteDOSession" || sessionName === "SQLiteDurableObjectSession";
|
|
26
26
|
}
|
|
27
|
+
function isDurableObjectStorageClient(value) {
|
|
28
|
+
if (typeof value !== "object" || value === null) return false;
|
|
29
|
+
const candidate = value;
|
|
30
|
+
const sqlApi = candidate.sql;
|
|
31
|
+
return typeof candidate.transaction === "function" && typeof candidate.transactionSync === "function" && typeof sqlApi === "object" && sqlApi !== null && typeof sqlApi.exec === "function";
|
|
32
|
+
}
|
|
33
|
+
function getDurableObjectStorageClient(db) {
|
|
34
|
+
const client = db.$client;
|
|
35
|
+
return isDurableObjectStorageClient(client) ? client : void 0;
|
|
36
|
+
}
|
|
37
|
+
function detectHostedPlatform(db) {
|
|
38
|
+
if (getDurableObjectStorageClient(db) !== void 0 || isDurableObjectBySessionName(db)) {
|
|
39
|
+
return "durable-object";
|
|
40
|
+
}
|
|
41
|
+
if (isD1DatabaseBySessionName(db)) return "d1";
|
|
42
|
+
return void 0;
|
|
43
|
+
}
|
|
27
44
|
function isSyncDatabaseBySessionName(db) {
|
|
28
45
|
const sessionName = getSessionName(db);
|
|
29
46
|
return sessionName === "BetterSQLiteSession" || sessionName === "BunSQLiteSession";
|
|
30
47
|
}
|
|
31
|
-
function detectSyncProfile(db, profileHints) {
|
|
48
|
+
function detectSyncProfile(db, profileHints, hostedPlatform) {
|
|
49
|
+
if (hostedPlatform === "durable-object") return true;
|
|
50
|
+
if (hostedPlatform === "d1") return false;
|
|
32
51
|
if (profileHints.isSync !== void 0) {
|
|
33
52
|
return profileHints.isSync;
|
|
34
53
|
}
|
|
@@ -36,12 +55,6 @@ function detectSyncProfile(db, profileHints) {
|
|
|
36
55
|
if (sessionName === "BetterSQLiteSession" || sessionName === "BunSQLiteSession") {
|
|
37
56
|
return true;
|
|
38
57
|
}
|
|
39
|
-
if (isDurableObjectBySessionName(db)) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
if (sessionName === "SQLiteD1Session") {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
58
|
try {
|
|
46
59
|
const probeResult = db.get(sql`SELECT 1 AS __typegraph_sync_probe__`);
|
|
47
60
|
return !(probeResult instanceof Promise);
|
|
@@ -49,16 +62,12 @@ function detectSyncProfile(db, profileHints) {
|
|
|
49
62
|
return isSyncDatabaseBySessionName(db);
|
|
50
63
|
}
|
|
51
64
|
}
|
|
52
|
-
function detectTransactionMode(
|
|
65
|
+
function detectTransactionMode(profileHints, isSync, hostedPlatform) {
|
|
66
|
+
if (hostedPlatform === "durable-object") return "do-sqlite";
|
|
67
|
+
if (hostedPlatform === "d1") return "none";
|
|
53
68
|
if (profileHints.transactionMode !== void 0) {
|
|
54
69
|
return profileHints.transactionMode;
|
|
55
70
|
}
|
|
56
|
-
if (isDurableObjectBySessionName(db)) {
|
|
57
|
-
return "do-sqlite";
|
|
58
|
-
}
|
|
59
|
-
if (isD1DatabaseBySessionName(db)) {
|
|
60
|
-
return "none";
|
|
61
|
-
}
|
|
62
71
|
if (isSync) return "sql";
|
|
63
72
|
return "drizzle";
|
|
64
73
|
}
|
|
@@ -84,8 +93,15 @@ function hasModernBindLimitByVersion(rows) {
|
|
|
84
93
|
if (!Number.isFinite(major) || !Number.isFinite(minor)) return false;
|
|
85
94
|
return major > FIRST_MODERN_BIND_LIMIT_MAJOR || major === FIRST_MODERN_BIND_LIMIT_MAJOR && minor >= FIRST_MODERN_BIND_LIMIT_MINOR;
|
|
86
95
|
}
|
|
87
|
-
function
|
|
88
|
-
if (
|
|
96
|
+
function detectHardMaxBindParameters(transactionMode, hostedPlatform) {
|
|
97
|
+
if (hostedPlatform === "durable-object" || transactionMode === "do-sqlite") {
|
|
98
|
+
return DURABLE_OBJECT_MAX_BIND_PARAMETERS;
|
|
99
|
+
}
|
|
100
|
+
if (hostedPlatform === "d1") return D1_MAX_BIND_PARAMETERS;
|
|
101
|
+
return void 0;
|
|
102
|
+
}
|
|
103
|
+
function detectMaxBindParameters(sqliteClient, hardMaxBindParameters) {
|
|
104
|
+
if (hardMaxBindParameters !== void 0) return hardMaxBindParameters;
|
|
89
105
|
if (sqliteClient === void 0) return SQLITE_MAX_BIND_PARAMETERS;
|
|
90
106
|
try {
|
|
91
107
|
const compiled = parseCompiledMaxVariableNumber(
|
|
@@ -101,11 +117,10 @@ function detectMaxBindParameters(db, sqliteClient) {
|
|
|
101
117
|
}
|
|
102
118
|
}
|
|
103
119
|
function resolveSqliteClient(db) {
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
120
|
+
const sqliteClient = db.$client;
|
|
121
|
+
if (typeof sqliteClient !== "object" || sqliteClient === null) return;
|
|
122
|
+
const candidate = sqliteClient;
|
|
123
|
+
if (typeof candidate.prepare !== "function") return;
|
|
109
124
|
return sqliteClient;
|
|
110
125
|
}
|
|
111
126
|
function getOrCreatePreparedStatement(cache, sqliteClient, sqlText, cacheMax) {
|
|
@@ -137,12 +152,27 @@ function createSqliteExecutionAdapter(db, statementCacheMaxOrOptions = {}) {
|
|
|
137
152
|
const options = typeof statementCacheMaxOrOptions === "number" ? { statementCacheMax: statementCacheMaxOrOptions } : statementCacheMaxOrOptions;
|
|
138
153
|
const statementCacheMax = options.statementCacheMax ?? DEFAULT_PREPARED_STATEMENT_CACHE_MAX;
|
|
139
154
|
const profileHints = options.profileHints ?? {};
|
|
140
|
-
const
|
|
155
|
+
const hostedPlatform = detectHostedPlatform(db);
|
|
156
|
+
const isSync = detectSyncProfile(db, profileHints, hostedPlatform);
|
|
141
157
|
const sqliteClient = isSync ? resolveSqliteClient(db) : void 0;
|
|
142
|
-
const transactionMode = detectTransactionMode(
|
|
158
|
+
const transactionMode = detectTransactionMode(
|
|
159
|
+
profileHints,
|
|
160
|
+
isSync,
|
|
161
|
+
hostedPlatform
|
|
162
|
+
);
|
|
163
|
+
const hardMaxBindParameters = detectHardMaxBindParameters(
|
|
164
|
+
transactionMode,
|
|
165
|
+
hostedPlatform
|
|
166
|
+
);
|
|
167
|
+
const maxBindParameters = detectMaxBindParameters(
|
|
168
|
+
sqliteClient,
|
|
169
|
+
hardMaxBindParameters
|
|
170
|
+
);
|
|
143
171
|
const profile = {
|
|
172
|
+
...hostedPlatform === void 0 ? {} : { hostedPlatform },
|
|
173
|
+
...hardMaxBindParameters === void 0 ? {} : { hardMaxBindParameters },
|
|
144
174
|
isSync,
|
|
145
|
-
maxBindParameters
|
|
175
|
+
maxBindParameters,
|
|
146
176
|
supportsCompiledExecution: sqliteClient !== void 0,
|
|
147
177
|
transactionMode
|
|
148
178
|
};
|
|
@@ -170,6 +200,22 @@ function createSqliteExecutionAdapter(db, statementCacheMaxOrOptions = {}) {
|
|
|
170
200
|
preparedStatement.run(...compiledQuery.params);
|
|
171
201
|
}
|
|
172
202
|
return Promise.resolve();
|
|
203
|
+
}, executePreparedRunBatch2 = function(sqlText, parameterRows) {
|
|
204
|
+
const preparedStatement = getOrCreatePreparedStatement(
|
|
205
|
+
statementCache,
|
|
206
|
+
client,
|
|
207
|
+
sqlText,
|
|
208
|
+
statementCacheMax
|
|
209
|
+
);
|
|
210
|
+
if (preparedStatement.run === void 0) {
|
|
211
|
+
throw new Error(
|
|
212
|
+
"Trusted SQLite import requires a prepared statement run() method."
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
for (const params of parameterRows) {
|
|
216
|
+
preparedStatement.run(...params);
|
|
217
|
+
}
|
|
218
|
+
return Promise.resolve();
|
|
173
219
|
};
|
|
174
220
|
const client = sqliteClient;
|
|
175
221
|
const statementCache = /* @__PURE__ */ new Map();
|
|
@@ -184,6 +230,7 @@ function createSqliteExecutionAdapter(db, statementCacheMaxOrOptions = {}) {
|
|
|
184
230
|
},
|
|
185
231
|
executeCompiled: executeCompiled2,
|
|
186
232
|
executeCompiledRun: executeCompiledRun2,
|
|
233
|
+
executePreparedRunBatch: executePreparedRunBatch2,
|
|
187
234
|
prepare(sqlText) {
|
|
188
235
|
return createPreparedStatementExecutor(
|
|
189
236
|
client,
|
|
@@ -335,7 +382,16 @@ function throwSqliteTransactionsDisabled(message) {
|
|
|
335
382
|
});
|
|
336
383
|
}
|
|
337
384
|
function buildSqliteCapabilities(options) {
|
|
338
|
-
const base = options.transactionMode === "none" ? {
|
|
385
|
+
const base = options.transactionMode === "none" ? {
|
|
386
|
+
...SQLITE_CAPABILITIES,
|
|
387
|
+
transactions: false,
|
|
388
|
+
graphAnalytics: {
|
|
389
|
+
...SQLITE_CAPABILITIES.graphAnalytics ?? {
|
|
390
|
+
mathFunctions: false
|
|
391
|
+
},
|
|
392
|
+
supported: false
|
|
393
|
+
}
|
|
394
|
+
} : SQLITE_CAPABILITIES;
|
|
339
395
|
return {
|
|
340
396
|
...base,
|
|
341
397
|
maxBindParameters: options.maxBindParameters,
|
|
@@ -343,6 +399,10 @@ function buildSqliteCapabilities(options) {
|
|
|
343
399
|
...options.vectorStrategy === void 0 ? {} : { vector: buildVectorCapabilities(options.vectorStrategy) }
|
|
344
400
|
};
|
|
345
401
|
}
|
|
402
|
+
function resolveMaxBindParametersCapability(profile, override) {
|
|
403
|
+
const requested = override ?? profile.maxBindParameters;
|
|
404
|
+
return profile.hardMaxBindParameters === void 0 ? requested : Math.min(requested, profile.hardMaxBindParameters);
|
|
405
|
+
}
|
|
346
406
|
function createSqliteOperationBackend(options) {
|
|
347
407
|
const {
|
|
348
408
|
capabilities,
|
|
@@ -353,7 +413,7 @@ function createSqliteOperationBackend(options) {
|
|
|
353
413
|
tableNames,
|
|
354
414
|
fulltextStrategy,
|
|
355
415
|
vectorStrategy,
|
|
356
|
-
|
|
416
|
+
contributionMaterializer
|
|
357
417
|
} = options;
|
|
358
418
|
const compiledExecute = executionAdapter.executeCompiled;
|
|
359
419
|
const compiledRun = executionAdapter.executeCompiledRun;
|
|
@@ -412,16 +472,10 @@ function createSqliteOperationBackend(options) {
|
|
|
412
472
|
);
|
|
413
473
|
}
|
|
414
474
|
};
|
|
415
|
-
async function ensureVectorSlotStorage(slot) {
|
|
416
|
-
if (vectorStrategy === void 0 || vectorSlotLatch === void 0) return;
|
|
417
|
-
await vectorSlotLatch.ensure(vectorStrategy, slot, async (statement) => {
|
|
418
|
-
await execRun(sql.raw(statement));
|
|
419
|
-
});
|
|
420
|
-
}
|
|
421
475
|
const vectorEmbeddingMethods = vectorStrategy === void 0 ? {} : {
|
|
422
476
|
async upsertEmbedding(params) {
|
|
423
477
|
const slot = vectorSlotFromParams(params);
|
|
424
|
-
await
|
|
478
|
+
await contributionMaterializer.assertVectorSlot(slot);
|
|
425
479
|
const statements = vectorStrategy.buildUpsert(slot, params, nowIso());
|
|
426
480
|
try {
|
|
427
481
|
for (const statement of statements) {
|
|
@@ -434,7 +488,7 @@ function createSqliteOperationBackend(options) {
|
|
|
434
488
|
async upsertEmbeddingBatch(params) {
|
|
435
489
|
if (params.rows.length === 0) return;
|
|
436
490
|
const slot = vectorSlotFromParams(params);
|
|
437
|
-
await
|
|
491
|
+
await contributionMaterializer.assertVectorSlot(slot);
|
|
438
492
|
const rowsById = new Map(
|
|
439
493
|
params.rows.map((row) => [row.nodeId, row])
|
|
440
494
|
);
|
|
@@ -475,7 +529,7 @@ function createSqliteOperationBackend(options) {
|
|
|
475
529
|
},
|
|
476
530
|
async deleteEmbedding(params) {
|
|
477
531
|
const slot = vectorSlotFromParams(params);
|
|
478
|
-
await
|
|
532
|
+
await contributionMaterializer.assertVectorSlot(slot);
|
|
479
533
|
const statements = vectorStrategy.buildDelete(slot, params);
|
|
480
534
|
for (const statement of statements) {
|
|
481
535
|
await execRun(statement);
|
|
@@ -484,7 +538,6 @@ function createSqliteOperationBackend(options) {
|
|
|
484
538
|
async vectorSearch(params) {
|
|
485
539
|
assertVectorSearchLimit(params.limit);
|
|
486
540
|
const slot = vectorSlotFromParams(params);
|
|
487
|
-
await ensureVectorSlotStorage(slot);
|
|
488
541
|
const query = vectorStrategy.buildSearch(
|
|
489
542
|
slot,
|
|
490
543
|
params,
|
|
@@ -521,7 +574,6 @@ function createSqliteOperationBackend(options) {
|
|
|
521
574
|
metric: params.vector.metric,
|
|
522
575
|
indexType: params.vector.indexType
|
|
523
576
|
});
|
|
524
|
-
await ensureVectorSlotStorage(slot);
|
|
525
577
|
const candidates = params.candidates ?? operationStrategy.buildLiveNodeIds(
|
|
526
578
|
params.graphId,
|
|
527
579
|
params.nodeKind
|
|
@@ -569,7 +621,7 @@ function createSqliteOperationBackend(options) {
|
|
|
569
621
|
async createVectorIndex(params) {
|
|
570
622
|
if (vectorStrategy === void 0) return;
|
|
571
623
|
const slot = vectorSlotFromCreateIndexParams(params);
|
|
572
|
-
await
|
|
624
|
+
await contributionMaterializer.ensureVectorSlot(slot);
|
|
573
625
|
const indexStatement = vectorStrategy.buildCreateIndex?.(slot);
|
|
574
626
|
if (indexStatement !== void 0) {
|
|
575
627
|
await execRun(indexStatement);
|
|
@@ -664,16 +716,20 @@ function createSqliteBackend(db, options = {}) {
|
|
|
664
716
|
const executionAdapter = createSqliteExecutionAdapter(db, { profileHints });
|
|
665
717
|
const { isSync, transactionMode } = executionAdapter.profile;
|
|
666
718
|
const vectorStrategy = options.vector;
|
|
667
|
-
const
|
|
668
|
-
const capabilities = {
|
|
719
|
+
const capabilityOverrides = options.capabilities ?? {};
|
|
720
|
+
const capabilities = normalizeGraphAnalyticsCapabilities({
|
|
669
721
|
...buildSqliteCapabilities({
|
|
670
722
|
fulltextStrategy,
|
|
671
723
|
vectorStrategy,
|
|
672
724
|
transactionMode,
|
|
673
725
|
maxBindParameters: executionAdapter.profile.maxBindParameters
|
|
674
726
|
}),
|
|
675
|
-
...
|
|
676
|
-
|
|
727
|
+
...capabilityOverrides,
|
|
728
|
+
maxBindParameters: resolveMaxBindParametersCapability(
|
|
729
|
+
executionAdapter.profile,
|
|
730
|
+
capabilityOverrides.maxBindParameters
|
|
731
|
+
)
|
|
732
|
+
});
|
|
677
733
|
const tableNames = {
|
|
678
734
|
nodes: getTableName(tables2.nodes),
|
|
679
735
|
edges: getTableName(tables2.edges),
|
|
@@ -700,6 +756,77 @@ function createSqliteBackend(db, options = {}) {
|
|
|
700
756
|
fulltextStrategy
|
|
701
757
|
);
|
|
702
758
|
const serializedQueue = transactionMode === "none" ? void 0 : createSerializedExecutionQueue();
|
|
759
|
+
const matTable = tables2.contributionMaterializations;
|
|
760
|
+
async function ensureContributionMaterializationsTableImpl() {
|
|
761
|
+
await db.run(sql.raw(generateSqliteCreateTableSQL(matTable)));
|
|
762
|
+
}
|
|
763
|
+
async function getContributionMaterializationRow(identity) {
|
|
764
|
+
const rows = await db.select().from(matTable).where(
|
|
765
|
+
and(
|
|
766
|
+
eq(matTable.graphId, identity.graphId),
|
|
767
|
+
eq(matTable.logicalName, identity.logicalName),
|
|
768
|
+
eq(matTable.owner, identity.owner),
|
|
769
|
+
eq(matTable.tableName, identity.tableName)
|
|
770
|
+
)
|
|
771
|
+
);
|
|
772
|
+
const row = rows[0];
|
|
773
|
+
if (row === void 0) return void 0;
|
|
774
|
+
return mapContributionMaterializationRow(
|
|
775
|
+
row,
|
|
776
|
+
SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.decode
|
|
777
|
+
);
|
|
778
|
+
}
|
|
779
|
+
async function getContributionMaterializationRows(graphId) {
|
|
780
|
+
const rows = await db.select().from(matTable).where(eq(matTable.graphId, graphId));
|
|
781
|
+
return rows.map(
|
|
782
|
+
(row) => mapContributionMaterializationRow(
|
|
783
|
+
row,
|
|
784
|
+
SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.decode
|
|
785
|
+
)
|
|
786
|
+
);
|
|
787
|
+
}
|
|
788
|
+
async function recordContributionMaterializationRow(params) {
|
|
789
|
+
await db.insert(matTable).values(
|
|
790
|
+
buildContributionInsertValues(
|
|
791
|
+
params,
|
|
792
|
+
SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.encode
|
|
793
|
+
)
|
|
794
|
+
).onConflictDoUpdate({
|
|
795
|
+
target: [
|
|
796
|
+
matTable.graphId,
|
|
797
|
+
matTable.logicalName,
|
|
798
|
+
matTable.owner,
|
|
799
|
+
matTable.tableName
|
|
800
|
+
],
|
|
801
|
+
set: buildContributionOnConflictSet(
|
|
802
|
+
matTable.materializedAt,
|
|
803
|
+
params.materializedAt
|
|
804
|
+
)
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
async function deleteContributionMaterializationRow(identity) {
|
|
808
|
+
await db.delete(matTable).where(
|
|
809
|
+
and(
|
|
810
|
+
eq(matTable.graphId, identity.graphId),
|
|
811
|
+
eq(matTable.logicalName, identity.logicalName),
|
|
812
|
+
eq(matTable.owner, identity.owner),
|
|
813
|
+
eq(matTable.tableName, identity.tableName)
|
|
814
|
+
)
|
|
815
|
+
);
|
|
816
|
+
}
|
|
817
|
+
const contributionMaterializer = createContributionMaterializer({
|
|
818
|
+
dialect: "sqlite",
|
|
819
|
+
fulltextStrategy,
|
|
820
|
+
fulltextTableName: tables2.fulltextTableName,
|
|
821
|
+
vectorStrategy,
|
|
822
|
+
execDdl: async (statement) => {
|
|
823
|
+
await db.run(sql.raw(statement));
|
|
824
|
+
},
|
|
825
|
+
ensureMarkerTable: ensureContributionMaterializationsTableImpl,
|
|
826
|
+
getMarkers: getContributionMaterializationRows,
|
|
827
|
+
recordMarker: recordContributionMaterializationRow,
|
|
828
|
+
deleteMarker: deleteContributionMaterializationRow
|
|
829
|
+
});
|
|
703
830
|
const operations = createSqliteOperationBackend({
|
|
704
831
|
capabilities,
|
|
705
832
|
db,
|
|
@@ -708,20 +835,19 @@ function createSqliteBackend(db, options = {}) {
|
|
|
708
835
|
tableNames,
|
|
709
836
|
fulltextStrategy,
|
|
710
837
|
vectorStrategy,
|
|
711
|
-
|
|
838
|
+
contributionMaterializer,
|
|
712
839
|
...serializedQueue === void 0 ? {} : { serializedQueue }
|
|
713
840
|
});
|
|
714
841
|
function runDoSqliteStorageTransaction(run) {
|
|
715
|
-
const storage = db
|
|
716
|
-
|
|
717
|
-
if (typeof storageTransaction !== "function") {
|
|
842
|
+
const storage = getDurableObjectStorageClient(db);
|
|
843
|
+
if (storage === void 0) {
|
|
718
844
|
throwSqliteTransactionsDisabled(
|
|
719
|
-
"transactionMode 'do-sqlite' requires a Drizzle Durable Objects database (drizzle(ctx.storage)) whose `$client` exposes the
|
|
845
|
+
"transactionMode 'do-sqlite' requires a Drizzle Durable Objects database (drizzle(ctx.storage)) whose `$client` exposes the SQL, transactionSync, and async transaction runners."
|
|
720
846
|
);
|
|
721
847
|
}
|
|
722
848
|
return runWithSerializedQueue(
|
|
723
849
|
serializedQueue,
|
|
724
|
-
|
|
850
|
+
() => storage.transaction(run)
|
|
725
851
|
);
|
|
726
852
|
}
|
|
727
853
|
async function runFrameStatement(query) {
|
|
@@ -748,7 +874,9 @@ function createSqliteBackend(db, options = {}) {
|
|
|
748
874
|
profileHints: { isSync },
|
|
749
875
|
tableNames,
|
|
750
876
|
fulltextStrategy,
|
|
751
|
-
vectorStrategy
|
|
877
|
+
vectorStrategy,
|
|
878
|
+
contributionMaterializer
|
|
879
|
+
});
|
|
752
880
|
await runFrameStatement(sql`BEGIN IMMEDIATE`);
|
|
753
881
|
try {
|
|
754
882
|
const result = await fn(txBackend);
|
|
@@ -769,7 +897,9 @@ function createSqliteBackend(db, options = {}) {
|
|
|
769
897
|
profileHints: { isSync },
|
|
770
898
|
tableNames,
|
|
771
899
|
fulltextStrategy,
|
|
772
|
-
vectorStrategy
|
|
900
|
+
vectorStrategy,
|
|
901
|
+
contributionMaterializer
|
|
902
|
+
});
|
|
773
903
|
return fn(txBackend);
|
|
774
904
|
});
|
|
775
905
|
}
|
|
@@ -784,63 +914,15 @@ function createSqliteBackend(db, options = {}) {
|
|
|
784
914
|
profileHints: { isSync },
|
|
785
915
|
tableNames,
|
|
786
916
|
fulltextStrategy,
|
|
787
|
-
vectorStrategy
|
|
917
|
+
vectorStrategy,
|
|
918
|
+
contributionMaterializer
|
|
919
|
+
});
|
|
788
920
|
return fn(txBackend);
|
|
789
921
|
},
|
|
790
922
|
{ behavior: "immediate" }
|
|
791
923
|
)
|
|
792
924
|
);
|
|
793
925
|
}
|
|
794
|
-
const matTable = tables2.contributionMaterializations;
|
|
795
|
-
async function ensureContributionMaterializationsTableImpl() {
|
|
796
|
-
await db.run(sql.raw(generateSqliteCreateTableSQL(matTable)));
|
|
797
|
-
}
|
|
798
|
-
async function getContributionMaterializationRow(identity) {
|
|
799
|
-
const rows = await db.select().from(matTable).where(
|
|
800
|
-
and(
|
|
801
|
-
eq(matTable.graphId, identity.graphId),
|
|
802
|
-
eq(matTable.logicalName, identity.logicalName),
|
|
803
|
-
eq(matTable.owner, identity.owner),
|
|
804
|
-
eq(matTable.tableName, identity.tableName)
|
|
805
|
-
)
|
|
806
|
-
);
|
|
807
|
-
const row = rows[0];
|
|
808
|
-
if (row === void 0) return void 0;
|
|
809
|
-
return mapContributionMaterializationRow(
|
|
810
|
-
row,
|
|
811
|
-
SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.decode
|
|
812
|
-
);
|
|
813
|
-
}
|
|
814
|
-
async function recordContributionMaterializationRow(params) {
|
|
815
|
-
await db.insert(matTable).values(
|
|
816
|
-
buildContributionInsertValues(
|
|
817
|
-
params,
|
|
818
|
-
SQLITE_CONTRIBUTION_MAT_TIMESTAMPS.encode
|
|
819
|
-
)
|
|
820
|
-
).onConflictDoUpdate({
|
|
821
|
-
target: [
|
|
822
|
-
matTable.graphId,
|
|
823
|
-
matTable.logicalName,
|
|
824
|
-
matTable.owner,
|
|
825
|
-
matTable.tableName
|
|
826
|
-
],
|
|
827
|
-
set: buildContributionOnConflictSet(
|
|
828
|
-
matTable.materializedAt,
|
|
829
|
-
params.materializedAt
|
|
830
|
-
)
|
|
831
|
-
});
|
|
832
|
-
}
|
|
833
|
-
const contributionMaterializer = createContributionMaterializer({
|
|
834
|
-
dialect: "sqlite",
|
|
835
|
-
fulltextStrategy,
|
|
836
|
-
fulltextTableName: tables2.fulltextTableName,
|
|
837
|
-
execDdl: async (statement) => {
|
|
838
|
-
await db.run(sql.raw(statement));
|
|
839
|
-
},
|
|
840
|
-
ensureMarkerTable: ensureContributionMaterializationsTableImpl,
|
|
841
|
-
getMarker: getContributionMaterializationRow,
|
|
842
|
-
recordMarker: recordContributionMaterializationRow
|
|
843
|
-
});
|
|
844
926
|
function bindTransactionBackend(tx) {
|
|
845
927
|
const txBackend = createTransactionBackend({
|
|
846
928
|
capabilities,
|
|
@@ -849,11 +931,30 @@ function createSqliteBackend(db, options = {}) {
|
|
|
849
931
|
profileHints: { isSync },
|
|
850
932
|
tableNames,
|
|
851
933
|
fulltextStrategy,
|
|
852
|
-
vectorStrategy
|
|
934
|
+
vectorStrategy,
|
|
935
|
+
contributionMaterializer
|
|
936
|
+
});
|
|
853
937
|
return gateFulltext(txBackend, contributionMaterializer.assertInitialized);
|
|
854
938
|
}
|
|
855
939
|
const backend = {
|
|
856
940
|
...operations,
|
|
941
|
+
...isSync && transactionMode === "sql" && executionAdapter.executePreparedRunBatch !== void 0 ? {
|
|
942
|
+
async trustedImport(fn) {
|
|
943
|
+
return backend.transaction(async (tx) => {
|
|
944
|
+
await assertTrustedImportDatabaseEmpty(tx, tableNames);
|
|
945
|
+
const indexDefinitions = await suspendSqliteSecondaryIndexes(
|
|
946
|
+
tx,
|
|
947
|
+
tableNames
|
|
948
|
+
);
|
|
949
|
+
const result = await fn(
|
|
950
|
+
createSqliteTrustedImportSession(executionAdapter, tableNames)
|
|
951
|
+
);
|
|
952
|
+
await restoreSecondaryIndexes(tx, indexDefinitions);
|
|
953
|
+
await analyzeImportedTables(tx, tableNames);
|
|
954
|
+
return result;
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
} : {},
|
|
857
958
|
async bootstrapTables() {
|
|
858
959
|
const statements = generateSqliteDDL(tables2, fulltextStrategy);
|
|
859
960
|
for (const statement of statements) {
|
|
@@ -906,10 +1007,7 @@ function createSqliteBackend(db, options = {}) {
|
|
|
906
1007
|
)
|
|
907
1008
|
).onConflictDoUpdate({
|
|
908
1009
|
target: t.indexName,
|
|
909
|
-
set: buildMaterializationOnConflictSet(
|
|
910
|
-
t.materializedAt,
|
|
911
|
-
params.materializedAt
|
|
912
|
-
)
|
|
1010
|
+
set: buildMaterializationOnConflictSet(params.materializedAt)
|
|
913
1011
|
});
|
|
914
1012
|
},
|
|
915
1013
|
async ensureContributionMaterializationsTable() {
|
|
@@ -969,6 +1067,27 @@ function createSqliteBackend(db, options = {}) {
|
|
|
969
1067
|
async ensureFulltextTable(graphId) {
|
|
970
1068
|
await contributionMaterializer.ensureRuntimeContributions(graphId);
|
|
971
1069
|
},
|
|
1070
|
+
// Vector counterparts of the runtime-contribution methods. Present
|
|
1071
|
+
// only when a vector strategy is wired (omitted on a plain SQLite
|
|
1072
|
+
// connection with no vector extension), mirroring the embedding/
|
|
1073
|
+
// search methods.
|
|
1074
|
+
...vectorStrategy === void 0 ? {} : {
|
|
1075
|
+
async ensureVectorSlotContribution(slot, options_) {
|
|
1076
|
+
await contributionMaterializer.ensureVectorSlot(slot, options_);
|
|
1077
|
+
},
|
|
1078
|
+
async ensureVectorSlotContributions(slots, options_) {
|
|
1079
|
+
await contributionMaterializer.ensureVectorSlots(slots, options_);
|
|
1080
|
+
},
|
|
1081
|
+
async assertVectorSlotInitialized(slot) {
|
|
1082
|
+
await contributionMaterializer.assertVectorSlot(slot);
|
|
1083
|
+
},
|
|
1084
|
+
async assertVectorSlotsInitialized(slots) {
|
|
1085
|
+
await contributionMaterializer.assertVectorSlots(slots);
|
|
1086
|
+
},
|
|
1087
|
+
async deleteVectorSlotContribution(slot) {
|
|
1088
|
+
await contributionMaterializer.dropVectorSlot(slot);
|
|
1089
|
+
}
|
|
1090
|
+
},
|
|
972
1091
|
async getReconciliationMarker(graphId) {
|
|
973
1092
|
const t = tables2.reconciliationMarkers;
|
|
974
1093
|
const rows = await db.select().from(t).where(eq(t.graphId, graphId));
|
|
@@ -1006,7 +1125,14 @@ function createSqliteBackend(db, options = {}) {
|
|
|
1006
1125
|
(target) => target.setActiveVersion(params)
|
|
1007
1126
|
);
|
|
1008
1127
|
},
|
|
1009
|
-
async transaction(fn,
|
|
1128
|
+
async transaction(fn, options2) {
|
|
1129
|
+
const temporaryWrites = options2?.temporaryWrites === INTERNAL_TEMPORARY_WRITES;
|
|
1130
|
+
if (temporaryWrites && options2.accessMode !== "read_only") {
|
|
1131
|
+
throw new ConfigurationError(
|
|
1132
|
+
"Temporary-write transactions must be semantically read-only.",
|
|
1133
|
+
{ dialect: "sqlite" }
|
|
1134
|
+
);
|
|
1135
|
+
}
|
|
1010
1136
|
if (transactionMode === "none") {
|
|
1011
1137
|
throwSqliteTransactionsDisabled(
|
|
1012
1138
|
"This SQLite backend does not support atomic transactions. Operations within a transaction are not rolled back on failure. Use backend.capabilities.transactions to check for transaction support, or use individual operations with manual error handling."
|
|
@@ -1022,8 +1148,12 @@ function createSqliteBackend(db, options = {}) {
|
|
|
1022
1148
|
profileHints: { isSync },
|
|
1023
1149
|
tableNames,
|
|
1024
1150
|
fulltextStrategy,
|
|
1025
|
-
vectorStrategy
|
|
1026
|
-
|
|
1151
|
+
vectorStrategy,
|
|
1152
|
+
contributionMaterializer
|
|
1153
|
+
});
|
|
1154
|
+
await runFrameStatement(
|
|
1155
|
+
options2?.accessMode === "read_only" || temporaryWrites ? sql`BEGIN` : sql`BEGIN IMMEDIATE`
|
|
1156
|
+
);
|
|
1027
1157
|
try {
|
|
1028
1158
|
const result = await fn(
|
|
1029
1159
|
gateFulltext(
|
|
@@ -1048,7 +1178,7 @@ function createSqliteBackend(db, options = {}) {
|
|
|
1048
1178
|
return runWithSerializedQueue(
|
|
1049
1179
|
serializedQueue,
|
|
1050
1180
|
async () => db.transaction(async (tx) => fn(bindTransactionBackend(tx), tx), {
|
|
1051
|
-
behavior: "immediate"
|
|
1181
|
+
behavior: options2?.accessMode === "read_only" || temporaryWrites ? "deferred" : "immediate"
|
|
1052
1182
|
})
|
|
1053
1183
|
);
|
|
1054
1184
|
},
|
|
@@ -1084,10 +1214,10 @@ function createTransactionBackend(options) {
|
|
|
1084
1214
|
tableNames: options.tableNames,
|
|
1085
1215
|
fulltextStrategy: options.fulltextStrategy,
|
|
1086
1216
|
vectorStrategy: options.vectorStrategy,
|
|
1087
|
-
|
|
1217
|
+
contributionMaterializer: options.contributionMaterializer
|
|
1088
1218
|
});
|
|
1089
1219
|
}
|
|
1090
1220
|
|
|
1091
1221
|
export { createSqliteBackend };
|
|
1092
|
-
//# sourceMappingURL=chunk-
|
|
1093
|
-
//# sourceMappingURL=chunk-
|
|
1222
|
+
//# sourceMappingURL=chunk-J4IUSYFF.js.map
|
|
1223
|
+
//# sourceMappingURL=chunk-J4IUSYFF.js.map
|