@xnetjs/sqlite 0.0.2 → 0.1.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/{adapter-I7yAV6iu.d.ts → adapter-imtxkmXZ.d.ts} +48 -1
- package/dist/adapters/electron.d.ts +70 -6
- package/dist/adapters/electron.js +662 -36
- package/dist/adapters/expo.d.ts +6 -2
- package/dist/adapters/expo.js +34 -6
- package/dist/adapters/memory.d.ts +6 -2
- package/dist/adapters/memory.js +8 -1
- package/dist/adapters/reader-thread.d.ts +78 -0
- package/dist/adapters/reader-thread.js +57 -0
- package/dist/adapters/web-proxy.d.ts +71 -3
- package/dist/adapters/web-proxy.js +554 -39
- package/dist/adapters/web-router-worker.d.ts +76 -0
- package/dist/adapters/web-router-worker.js +91 -0
- package/dist/adapters/web-worker.d.ts +56 -1
- package/dist/adapters/web-worker.js +253 -14
- package/dist/adapters/web.d.ts +90 -3
- package/dist/adapters/web.js +10 -4
- package/dist/browser-support.d.ts +65 -1
- package/dist/browser-support.js +15 -3
- package/dist/chunk-5HC5V73T.js +191 -0
- package/dist/chunk-BBZDKLA3.js +727 -0
- package/dist/chunk-CBU263LI.js +30 -0
- package/dist/chunk-CGI2YBZY.js +16 -0
- package/dist/chunk-S6MT6KCI.js +279 -0
- package/dist/chunk-SV475UL5.js +44 -0
- package/dist/chunk-W3L4FXU5.js +415 -0
- package/dist/index.d.ts +111 -8
- package/dist/index.js +219 -130
- package/dist/schema-C4gufY3B.d.ts +35 -0
- package/dist/types-BTabr_VP.d.ts +225 -0
- package/dist/worker-scheduler-D04DqMmR.d.ts +56 -0
- package/package.json +5 -1
- package/dist/chunk-BXYZU3OL.js +0 -245
- package/dist/chunk-HIREU5S5.js +0 -193
- package/dist/chunk-ZRR5D2OD.js +0 -140
- package/dist/schema-CjkXTqxn.d.ts +0 -35
- package/dist/types-C_aHfRDF.d.ts +0 -42
package/dist/index.js
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
checkBrowserSupport,
|
|
3
|
+
checkPersistentStorage,
|
|
4
|
+
getMemoryFallbackSessionCount,
|
|
5
|
+
isSilentPersistRequestSafe,
|
|
6
|
+
recordMemoryFallbackSession,
|
|
7
|
+
requestPersistentStorage,
|
|
8
|
+
showUnsupportedBrowserMessage,
|
|
9
|
+
watchPersistentStoragePermission
|
|
10
|
+
} from "./chunk-S6MT6KCI.js";
|
|
11
|
+
import {
|
|
12
|
+
detectOpfsCapability,
|
|
13
|
+
isCrossOriginIsolated,
|
|
14
|
+
supportsOpfs,
|
|
15
|
+
supportsSyncAccessHandle
|
|
16
|
+
} from "./chunk-SV475UL5.js";
|
|
17
|
+
import {
|
|
18
|
+
isSQLiteCorruptionError
|
|
19
|
+
} from "./chunk-CBU263LI.js";
|
|
1
20
|
import {
|
|
2
21
|
SCHEMA_DDL,
|
|
3
22
|
SCHEMA_DDL_CORE,
|
|
@@ -5,11 +24,7 @@ import {
|
|
|
5
24
|
SCHEMA_MIGRATIONS,
|
|
6
25
|
SCHEMA_VERSION,
|
|
7
26
|
getMigrationSQL
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import {
|
|
10
|
-
checkBrowserSupport,
|
|
11
|
-
showUnsupportedBrowserMessage
|
|
12
|
-
} from "./chunk-ZRR5D2OD.js";
|
|
27
|
+
} from "./chunk-W3L4FXU5.js";
|
|
13
28
|
|
|
14
29
|
// src/query-builder.ts
|
|
15
30
|
function buildInsert(table, columns, options) {
|
|
@@ -54,6 +69,179 @@ function buildBatchInsert(table, columns, rowCount) {
|
|
|
54
69
|
return `INSERT INTO ${table} (${columnList}) VALUES ${valuesList}`;
|
|
55
70
|
}
|
|
56
71
|
|
|
72
|
+
// src/diagnostics.ts
|
|
73
|
+
var indexInfoCache = /* @__PURE__ */ new WeakMap();
|
|
74
|
+
async function readSchemaVersion(db) {
|
|
75
|
+
try {
|
|
76
|
+
const row = await db.queryOne("PRAGMA schema_version");
|
|
77
|
+
return Number(row?.schema_version ?? 0);
|
|
78
|
+
} catch {
|
|
79
|
+
return 0;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async function getIndexInfo(db) {
|
|
83
|
+
const schemaVersion = await readSchemaVersion(db);
|
|
84
|
+
const cached = indexInfoCache.get(db);
|
|
85
|
+
if (cached && cached.schemaVersion === schemaVersion) {
|
|
86
|
+
return cached.indexes;
|
|
87
|
+
}
|
|
88
|
+
const indexes = await db.query(
|
|
89
|
+
"SELECT name, tbl_name, sql FROM sqlite_master WHERE type='index' AND name NOT LIKE 'sqlite_%'"
|
|
90
|
+
);
|
|
91
|
+
const result = [];
|
|
92
|
+
for (const idx of indexes) {
|
|
93
|
+
const columns = await db.query(`PRAGMA index_info('${idx.name}')`);
|
|
94
|
+
result.push({
|
|
95
|
+
name: idx.name,
|
|
96
|
+
tableName: idx.tbl_name,
|
|
97
|
+
unique: idx.sql?.includes("UNIQUE") ?? false,
|
|
98
|
+
columns: columns.map((c) => c.name),
|
|
99
|
+
partial: idx.sql?.includes("WHERE") ?? false
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
indexInfoCache.set(db, { schemaVersion, indexes: result });
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
async function analyzeQuery(db, sql, params) {
|
|
106
|
+
const plan = await db.query(`EXPLAIN QUERY PLAN ${sql}`, params);
|
|
107
|
+
const steps = plan.map((row) => ({
|
|
108
|
+
id: row.id,
|
|
109
|
+
parent: row.parent,
|
|
110
|
+
detail: row.detail
|
|
111
|
+
}));
|
|
112
|
+
const usedIndexes = [];
|
|
113
|
+
let fullTableScan = false;
|
|
114
|
+
for (const step of steps) {
|
|
115
|
+
const detail = step.detail.toUpperCase();
|
|
116
|
+
const indexMatch = step.detail.match(/USING (?:COVERING )?INDEX (\w+)/i);
|
|
117
|
+
if (indexMatch) {
|
|
118
|
+
usedIndexes.push(indexMatch[1]);
|
|
119
|
+
}
|
|
120
|
+
if (detail.includes("SCAN TABLE") && !detail.includes("USING")) {
|
|
121
|
+
fullTableScan = true;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return { plan: steps, usedIndexes, fullTableScan };
|
|
125
|
+
}
|
|
126
|
+
async function analyzeTable(db, tableName) {
|
|
127
|
+
const countResult = await db.queryOne(`SELECT COUNT(*) as count FROM ${tableName}`);
|
|
128
|
+
const rowCount = countResult?.count ?? 0;
|
|
129
|
+
let pageCount = 0;
|
|
130
|
+
let unusedBytes = 0;
|
|
131
|
+
try {
|
|
132
|
+
const pages = await db.query(`SELECT pageno, unused FROM dbstat WHERE name = ?`, [
|
|
133
|
+
tableName
|
|
134
|
+
]);
|
|
135
|
+
pageCount = pages.length;
|
|
136
|
+
unusedBytes = pages.reduce((sum, p) => sum + p.unused, 0);
|
|
137
|
+
} catch {
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
name: tableName,
|
|
141
|
+
rowCount,
|
|
142
|
+
pageCount,
|
|
143
|
+
unusedBytes
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
async function getAllTableStats(db) {
|
|
147
|
+
const tables = await db.query(
|
|
148
|
+
"SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'"
|
|
149
|
+
);
|
|
150
|
+
const stats = [];
|
|
151
|
+
for (const table of tables) {
|
|
152
|
+
stats.push(await analyzeTable(db, table.name));
|
|
153
|
+
}
|
|
154
|
+
return stats.sort((a, b) => b.rowCount - a.rowCount);
|
|
155
|
+
}
|
|
156
|
+
async function getDatabaseStats(db) {
|
|
157
|
+
const [pageSize, pageCount, freePageCount, schemaVersion, walMode, foreignKeys] = await Promise.all([
|
|
158
|
+
db.queryOne("PRAGMA page_size"),
|
|
159
|
+
db.queryOne("PRAGMA page_count"),
|
|
160
|
+
db.queryOne("PRAGMA freelist_count"),
|
|
161
|
+
db.queryOne("PRAGMA schema_version"),
|
|
162
|
+
db.queryOne("PRAGMA journal_mode"),
|
|
163
|
+
db.queryOne("PRAGMA foreign_keys")
|
|
164
|
+
]);
|
|
165
|
+
return {
|
|
166
|
+
pageSize: Number(pageSize?.page_size ?? 4096),
|
|
167
|
+
pageCount: Number(pageCount?.page_count ?? 0),
|
|
168
|
+
freePageCount: Number(freePageCount?.freelist_count ?? 0),
|
|
169
|
+
schemaVersion: Number(schemaVersion?.schema_version ?? 0),
|
|
170
|
+
walMode: String(walMode?.journal_mode ?? "").toLowerCase() === "wal",
|
|
171
|
+
foreignKeys: Boolean(foreignKeys?.foreign_keys)
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
var sqliteRuntimeCapabilities = /* @__PURE__ */ new WeakMap();
|
|
175
|
+
async function detectSQLiteCapabilities(db) {
|
|
176
|
+
const cached = sqliteRuntimeCapabilities.get(db);
|
|
177
|
+
if (cached) {
|
|
178
|
+
return cached;
|
|
179
|
+
}
|
|
180
|
+
const capabilities = {
|
|
181
|
+
fts5: await canCreateVirtualTable(db, "temp.__xnet_capability_fts5_probe", "fts5(content)"),
|
|
182
|
+
rtree: await canCreateVirtualTable(
|
|
183
|
+
db,
|
|
184
|
+
"temp.__xnet_capability_rtree_probe",
|
|
185
|
+
"rtree(id, min_x, max_x, min_y, max_y)"
|
|
186
|
+
)
|
|
187
|
+
};
|
|
188
|
+
sqliteRuntimeCapabilities.set(db, capabilities);
|
|
189
|
+
return capabilities;
|
|
190
|
+
}
|
|
191
|
+
async function canCreateVirtualTable(db, tableName, moduleDefinition) {
|
|
192
|
+
await dropProbeTable(db, tableName);
|
|
193
|
+
try {
|
|
194
|
+
await db.exec(`CREATE VIRTUAL TABLE ${tableName} USING ${moduleDefinition}`);
|
|
195
|
+
return true;
|
|
196
|
+
} catch {
|
|
197
|
+
return false;
|
|
198
|
+
} finally {
|
|
199
|
+
await dropProbeTable(db, tableName);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
async function dropProbeTable(db, tableName) {
|
|
203
|
+
try {
|
|
204
|
+
await db.exec(`DROP TABLE IF EXISTS ${tableName}`);
|
|
205
|
+
} catch {
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
async function runAnalyze(db, tableName) {
|
|
209
|
+
if (tableName) {
|
|
210
|
+
await db.exec(`ANALYZE ${tableName}`);
|
|
211
|
+
} else {
|
|
212
|
+
await db.exec("ANALYZE");
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
async function checkIntegrity(db) {
|
|
216
|
+
const results = await db.query("PRAGMA integrity_check(100)");
|
|
217
|
+
const errors = [];
|
|
218
|
+
for (const row of results) {
|
|
219
|
+
if (row.integrity_check !== "ok") {
|
|
220
|
+
errors.push(row.integrity_check);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
ok: errors.length === 0,
|
|
225
|
+
errors
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
async function explainQuery(db, sql, params) {
|
|
229
|
+
const rows = await db.query(`EXPLAIN ${sql}`, params);
|
|
230
|
+
return rows.map(
|
|
231
|
+
(row) => `${row.opcode.padEnd(15)} ${String(row.p1).padStart(4)} ${String(row.p2).padStart(4)} ${String(row.p3).padStart(4)} ${row.p4 || ""}`
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
async function timeQuery(db, sql, params) {
|
|
235
|
+
const start = performance.now();
|
|
236
|
+
const result = await db.query(sql, params);
|
|
237
|
+
const durationMs = performance.now() - start;
|
|
238
|
+
return {
|
|
239
|
+
result,
|
|
240
|
+
durationMs,
|
|
241
|
+
rowCount: result.length
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
|
|
57
245
|
// src/fts.ts
|
|
58
246
|
async function updateNodeFTS(db, nodeId, title, content) {
|
|
59
247
|
const hasFTS = await checkFTSSupport(db);
|
|
@@ -168,6 +356,14 @@ function extractSearchableContent(properties) {
|
|
|
168
356
|
if (typeof body === "string") {
|
|
169
357
|
parts.push(body);
|
|
170
358
|
}
|
|
359
|
+
const name = properties.name;
|
|
360
|
+
if (typeof name === "string") {
|
|
361
|
+
parts.push(name);
|
|
362
|
+
}
|
|
363
|
+
const note = properties.note;
|
|
364
|
+
if (typeof note === "string") {
|
|
365
|
+
parts.push(note);
|
|
366
|
+
}
|
|
171
367
|
return parts.length > 0 ? parts.join(" ") : null;
|
|
172
368
|
}
|
|
173
369
|
var ftsSupport = /* @__PURE__ */ new WeakMap();
|
|
@@ -176,6 +372,11 @@ async function checkFTSSupport(db) {
|
|
|
176
372
|
return ftsSupport.get(db);
|
|
177
373
|
}
|
|
178
374
|
try {
|
|
375
|
+
const capabilities = await detectSQLiteCapabilities(db);
|
|
376
|
+
if (!capabilities.fts5) {
|
|
377
|
+
ftsSupport.set(db, false);
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
179
380
|
const result = await db.queryOne(
|
|
180
381
|
"SELECT name FROM sqlite_master WHERE type='table' AND name='nodes_fts'"
|
|
181
382
|
);
|
|
@@ -196,130 +397,6 @@ function escapeFTSQuery(query) {
|
|
|
196
397
|
}
|
|
197
398
|
return query;
|
|
198
399
|
}
|
|
199
|
-
|
|
200
|
-
// src/diagnostics.ts
|
|
201
|
-
async function getIndexInfo(db) {
|
|
202
|
-
const indexes = await db.query(
|
|
203
|
-
"SELECT name, tbl_name, sql FROM sqlite_master WHERE type='index' AND name NOT LIKE 'sqlite_%'"
|
|
204
|
-
);
|
|
205
|
-
const result = [];
|
|
206
|
-
for (const idx of indexes) {
|
|
207
|
-
const columns = await db.query(`PRAGMA index_info('${idx.name}')`);
|
|
208
|
-
result.push({
|
|
209
|
-
name: idx.name,
|
|
210
|
-
tableName: idx.tbl_name,
|
|
211
|
-
unique: idx.sql?.includes("UNIQUE") ?? false,
|
|
212
|
-
columns: columns.map((c) => c.name),
|
|
213
|
-
partial: idx.sql?.includes("WHERE") ?? false
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
return result;
|
|
217
|
-
}
|
|
218
|
-
async function analyzeQuery(db, sql, params) {
|
|
219
|
-
const plan = await db.query(`EXPLAIN QUERY PLAN ${sql}`, params);
|
|
220
|
-
const steps = plan.map((row) => ({
|
|
221
|
-
id: row.id,
|
|
222
|
-
parent: row.parent,
|
|
223
|
-
detail: row.detail
|
|
224
|
-
}));
|
|
225
|
-
const usedIndexes = [];
|
|
226
|
-
let fullTableScan = false;
|
|
227
|
-
for (const step of steps) {
|
|
228
|
-
const detail = step.detail.toUpperCase();
|
|
229
|
-
const indexMatch = step.detail.match(/USING (?:COVERING )?INDEX (\w+)/i);
|
|
230
|
-
if (indexMatch) {
|
|
231
|
-
usedIndexes.push(indexMatch[1]);
|
|
232
|
-
}
|
|
233
|
-
if (detail.includes("SCAN TABLE") && !detail.includes("USING")) {
|
|
234
|
-
fullTableScan = true;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return { plan: steps, usedIndexes, fullTableScan };
|
|
238
|
-
}
|
|
239
|
-
async function analyzeTable(db, tableName) {
|
|
240
|
-
const countResult = await db.queryOne(`SELECT COUNT(*) as count FROM ${tableName}`);
|
|
241
|
-
const rowCount = countResult?.count ?? 0;
|
|
242
|
-
let pageCount = 0;
|
|
243
|
-
let unusedBytes = 0;
|
|
244
|
-
try {
|
|
245
|
-
const pages = await db.query(`SELECT pageno, unused FROM dbstat WHERE name = ?`, [
|
|
246
|
-
tableName
|
|
247
|
-
]);
|
|
248
|
-
pageCount = pages.length;
|
|
249
|
-
unusedBytes = pages.reduce((sum, p) => sum + p.unused, 0);
|
|
250
|
-
} catch {
|
|
251
|
-
}
|
|
252
|
-
return {
|
|
253
|
-
name: tableName,
|
|
254
|
-
rowCount,
|
|
255
|
-
pageCount,
|
|
256
|
-
unusedBytes
|
|
257
|
-
};
|
|
258
|
-
}
|
|
259
|
-
async function getAllTableStats(db) {
|
|
260
|
-
const tables = await db.query(
|
|
261
|
-
"SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'"
|
|
262
|
-
);
|
|
263
|
-
const stats = [];
|
|
264
|
-
for (const table of tables) {
|
|
265
|
-
stats.push(await analyzeTable(db, table.name));
|
|
266
|
-
}
|
|
267
|
-
return stats.sort((a, b) => b.rowCount - a.rowCount);
|
|
268
|
-
}
|
|
269
|
-
async function getDatabaseStats(db) {
|
|
270
|
-
const [pageSize, pageCount, freePageCount, schemaVersion, walMode, foreignKeys] = await Promise.all([
|
|
271
|
-
db.queryOne("PRAGMA page_size"),
|
|
272
|
-
db.queryOne("PRAGMA page_count"),
|
|
273
|
-
db.queryOne("PRAGMA freelist_count"),
|
|
274
|
-
db.queryOne("PRAGMA schema_version"),
|
|
275
|
-
db.queryOne("PRAGMA journal_mode"),
|
|
276
|
-
db.queryOne("PRAGMA foreign_keys")
|
|
277
|
-
]);
|
|
278
|
-
return {
|
|
279
|
-
pageSize: Number(pageSize?.page_size ?? 4096),
|
|
280
|
-
pageCount: Number(pageCount?.page_count ?? 0),
|
|
281
|
-
freePageCount: Number(freePageCount?.freelist_count ?? 0),
|
|
282
|
-
schemaVersion: Number(schemaVersion?.schema_version ?? 0),
|
|
283
|
-
walMode: String(walMode?.journal_mode ?? "").toLowerCase() === "wal",
|
|
284
|
-
foreignKeys: Boolean(foreignKeys?.foreign_keys)
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
async function runAnalyze(db, tableName) {
|
|
288
|
-
if (tableName) {
|
|
289
|
-
await db.exec(`ANALYZE ${tableName}`);
|
|
290
|
-
} else {
|
|
291
|
-
await db.exec("ANALYZE");
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
async function checkIntegrity(db) {
|
|
295
|
-
const results = await db.query("PRAGMA integrity_check(100)");
|
|
296
|
-
const errors = [];
|
|
297
|
-
for (const row of results) {
|
|
298
|
-
if (row.integrity_check !== "ok") {
|
|
299
|
-
errors.push(row.integrity_check);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
return {
|
|
303
|
-
ok: errors.length === 0,
|
|
304
|
-
errors
|
|
305
|
-
};
|
|
306
|
-
}
|
|
307
|
-
async function explainQuery(db, sql, params) {
|
|
308
|
-
const rows = await db.query(`EXPLAIN ${sql}`, params);
|
|
309
|
-
return rows.map(
|
|
310
|
-
(row) => `${row.opcode.padEnd(15)} ${String(row.p1).padStart(4)} ${String(row.p2).padStart(4)} ${String(row.p3).padStart(4)} ${row.p4 || ""}`
|
|
311
|
-
);
|
|
312
|
-
}
|
|
313
|
-
async function timeQuery(db, sql, params) {
|
|
314
|
-
const start = performance.now();
|
|
315
|
-
const result = await db.query(sql, params);
|
|
316
|
-
const durationMs = performance.now() - start;
|
|
317
|
-
return {
|
|
318
|
-
result,
|
|
319
|
-
durationMs,
|
|
320
|
-
rowCount: result.length
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
400
|
export {
|
|
324
401
|
SCHEMA_DDL,
|
|
325
402
|
SCHEMA_DDL_CORE,
|
|
@@ -334,7 +411,10 @@ export {
|
|
|
334
411
|
buildUpdate,
|
|
335
412
|
checkBrowserSupport,
|
|
336
413
|
checkIntegrity,
|
|
414
|
+
checkPersistentStorage,
|
|
337
415
|
deleteNodeFTS,
|
|
416
|
+
detectOpfsCapability,
|
|
417
|
+
detectSQLiteCapabilities,
|
|
338
418
|
escapeLike,
|
|
339
419
|
explainQuery,
|
|
340
420
|
extractSearchableContent,
|
|
@@ -342,12 +422,21 @@ export {
|
|
|
342
422
|
getAllTableStats,
|
|
343
423
|
getDatabaseStats,
|
|
344
424
|
getIndexInfo,
|
|
425
|
+
getMemoryFallbackSessionCount,
|
|
345
426
|
getMigrationSQL,
|
|
427
|
+
isCrossOriginIsolated,
|
|
428
|
+
isSQLiteCorruptionError,
|
|
429
|
+
isSilentPersistRequestSafe,
|
|
346
430
|
optimizeFTS,
|
|
347
431
|
rebuildFTS,
|
|
432
|
+
recordMemoryFallbackSession,
|
|
433
|
+
requestPersistentStorage,
|
|
348
434
|
runAnalyze,
|
|
349
435
|
searchNodes,
|
|
350
436
|
showUnsupportedBrowserMessage,
|
|
437
|
+
supportsOpfs,
|
|
438
|
+
supportsSyncAccessHandle,
|
|
351
439
|
timeQuery,
|
|
352
|
-
updateNodeFTS
|
|
440
|
+
updateNodeFTS,
|
|
441
|
+
watchPersistentStoragePermission
|
|
353
442
|
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @xnetjs/sqlite - Unified SQLite schema for xNet
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Current schema version.
|
|
6
|
+
* Increment this when making schema changes.
|
|
7
|
+
*/
|
|
8
|
+
declare const SCHEMA_VERSION = 7;
|
|
9
|
+
/**
|
|
10
|
+
* Core SQLite schema for xNet (without FTS5).
|
|
11
|
+
* This schema works on all platforms including sql.js.
|
|
12
|
+
*/
|
|
13
|
+
declare const SCHEMA_DDL_CORE = "\n-- ============================================\n-- Schema Version Tracking\n-- ============================================\n\nCREATE TABLE IF NOT EXISTS _schema_version (\n version INTEGER PRIMARY KEY,\n applied_at INTEGER NOT NULL\n);\n\n-- ============================================\n-- Core Tables\n-- ============================================\n\n-- All nodes (Pages, Databases, Rows, Comments, etc.)\nCREATE TABLE IF NOT EXISTS nodes (\n id TEXT PRIMARY KEY,\n schema_id TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n created_by TEXT NOT NULL,\n deleted_at INTEGER\n);\n\n-- Node properties (LWW per-property)\nCREATE TABLE IF NOT EXISTS node_properties (\n node_id TEXT NOT NULL,\n property_key TEXT NOT NULL,\n value BLOB,\n lamport_time INTEGER NOT NULL,\n updated_by TEXT NOT NULL,\n updated_at INTEGER NOT NULL,\n\n PRIMARY KEY (node_id, property_key),\n FOREIGN KEY (node_id) REFERENCES nodes(id) ON DELETE CASCADE\n);\n\n-- Rebuildable scalar property index for query planning.\nCREATE TABLE IF NOT EXISTS node_property_scalars (\n node_id TEXT NOT NULL,\n schema_id TEXT NOT NULL,\n property_key TEXT NOT NULL,\n value_type TEXT NOT NULL,\n value_text TEXT,\n value_number REAL,\n value_boolean INTEGER,\n value_hash TEXT,\n updated_at INTEGER NOT NULL,\n lamport_time INTEGER NOT NULL,\n\n PRIMARY KEY (schema_id, property_key, node_id),\n FOREIGN KEY (node_id) REFERENCES nodes(id) ON DELETE CASCADE\n);\n\n-- Query planner telemetry for adaptive read indexes.\nCREATE TABLE IF NOT EXISTS query_descriptor_stats (\n descriptor_hash TEXT PRIMARY KEY,\n schema_id TEXT NOT NULL,\n descriptor_json TEXT NOT NULL,\n hits INTEGER NOT NULL,\n total_duration_ms REAL NOT NULL,\n avg_duration_ms REAL NOT NULL,\n avg_candidates REAL NOT NULL,\n last_seen_at INTEGER NOT NULL\n);\n\nCREATE TABLE IF NOT EXISTS query_index_candidates (\n index_name TEXT PRIMARY KEY,\n descriptor_hash TEXT NOT NULL,\n schema_id TEXT NOT NULL,\n property_key TEXT NOT NULL,\n value_type TEXT NOT NULL,\n ddl TEXT NOT NULL,\n created_at INTEGER NOT NULL,\n last_used_at INTEGER NOT NULL,\n estimated_bytes INTEGER NOT NULL DEFAULT 0,\n estimated_rows INTEGER NOT NULL DEFAULT 0,\n\n FOREIGN KEY (descriptor_hash) REFERENCES query_descriptor_stats(descriptor_hash)\n ON DELETE CASCADE\n);\n\nCREATE TABLE IF NOT EXISTS node_query_materializations (\n view_id TEXT PRIMARY KEY,\n descriptor_hash TEXT NOT NULL,\n schema_id TEXT NOT NULL,\n descriptor_json TEXT NOT NULL,\n generated_at INTEGER NOT NULL,\n invalidated_at INTEGER,\n row_count INTEGER NOT NULL,\n -- Authorization fingerprint the view was materialized under (exploration\n -- 0226). NULL when authz is off; a mismatch forces an 'authz-changed'\n -- refresh so a cached id list can never serve rows the viewer can no\n -- longer read.\n auth_fingerprint TEXT\n);\n\nCREATE TABLE IF NOT EXISTS node_query_materialized_ids (\n view_id TEXT NOT NULL,\n ordinal INTEGER NOT NULL,\n node_id TEXT NOT NULL,\n\n PRIMARY KEY (view_id, ordinal),\n UNIQUE (view_id, node_id),\n FOREIGN KEY (view_id) REFERENCES node_query_materializations(view_id)\n ON DELETE CASCADE,\n FOREIGN KEY (node_id) REFERENCES nodes(id)\n ON DELETE CASCADE\n);\n\n-- Change log (event sourcing)\nCREATE TABLE IF NOT EXISTS changes (\n hash TEXT PRIMARY KEY,\n node_id TEXT NOT NULL,\n payload BLOB NOT NULL,\n lamport_time INTEGER NOT NULL,\n lamport_peer TEXT NOT NULL,\n wall_time INTEGER NOT NULL,\n author TEXT NOT NULL,\n parent_hash TEXT,\n batch_id TEXT,\n signature BLOB NOT NULL,\n\n FOREIGN KEY (node_id) REFERENCES nodes(id) ON DELETE CASCADE\n);\n\n-- Y.Doc binary state (for nodes with collaborative content)\nCREATE TABLE IF NOT EXISTS yjs_state (\n node_id TEXT PRIMARY KEY,\n state BLOB NOT NULL,\n updated_at INTEGER NOT NULL,\n\n FOREIGN KEY (node_id) REFERENCES nodes(id) ON DELETE CASCADE\n);\n\n-- Y.Doc incremental updates (for sync)\nCREATE TABLE IF NOT EXISTS yjs_updates (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n node_id TEXT NOT NULL,\n update_data BLOB NOT NULL,\n timestamp INTEGER NOT NULL,\n origin TEXT,\n\n FOREIGN KEY (node_id) REFERENCES nodes(id) ON DELETE CASCADE\n);\n\n-- Yjs snapshots (for document time travel)\nCREATE TABLE IF NOT EXISTS yjs_snapshots (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n node_id TEXT NOT NULL,\n timestamp INTEGER NOT NULL,\n snapshot BLOB NOT NULL,\n doc_state BLOB NOT NULL,\n byte_size INTEGER NOT NULL,\n\n FOREIGN KEY (node_id) REFERENCES nodes(id) ON DELETE CASCADE\n);\n\n-- Blobs (content-addressed)\nCREATE TABLE IF NOT EXISTS blobs (\n cid TEXT PRIMARY KEY,\n data BLOB NOT NULL,\n mime_type TEXT,\n size INTEGER NOT NULL,\n created_at INTEGER NOT NULL,\n reference_count INTEGER DEFAULT 1\n);\n\n-- Documents (for @xnetjs/storage compatibility)\nCREATE TABLE IF NOT EXISTS documents (\n id TEXT PRIMARY KEY,\n content BLOB NOT NULL,\n metadata TEXT NOT NULL,\n version INTEGER NOT NULL DEFAULT 1\n);\n\n-- Signed updates (for @xnetjs/storage compatibility)\nCREATE TABLE IF NOT EXISTS updates (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n doc_id TEXT NOT NULL,\n update_hash TEXT NOT NULL,\n update_data TEXT NOT NULL,\n created_at INTEGER DEFAULT (strftime('%s', 'now') * 1000),\n UNIQUE(doc_id, update_hash)\n);\n\n-- Snapshots (for @xnetjs/storage compatibility)\nCREATE TABLE IF NOT EXISTS snapshots (\n doc_id TEXT PRIMARY KEY,\n snapshot_data TEXT NOT NULL,\n created_at INTEGER DEFAULT (strftime('%s', 'now') * 1000)\n);\n\n-- Sync metadata\nCREATE TABLE IF NOT EXISTS sync_state (\n key TEXT PRIMARY KEY,\n value TEXT NOT NULL\n);\n\n-- ============================================\n-- Indexes\n-- ============================================\n\nCREATE INDEX IF NOT EXISTS idx_nodes_schema ON nodes(schema_id);\nCREATE INDEX IF NOT EXISTS idx_nodes_updated ON nodes(updated_at);\nCREATE INDEX IF NOT EXISTS idx_nodes_created_by ON nodes(created_by);\nCREATE INDEX IF NOT EXISTS idx_nodes_deleted ON nodes(deleted_at);\nCREATE INDEX IF NOT EXISTS idx_nodes_live_schema_updated\n ON nodes(schema_id, updated_at DESC, id)\n WHERE deleted_at IS NULL;\nCREATE INDEX IF NOT EXISTS idx_nodes_all_schema_updated\n ON nodes(schema_id, updated_at DESC, id);\nCREATE INDEX IF NOT EXISTS idx_nodes_live_schema_created\n ON nodes(schema_id, created_at DESC, id)\n WHERE deleted_at IS NULL;\n\nCREATE INDEX IF NOT EXISTS idx_properties_node ON node_properties(node_id);\nCREATE INDEX IF NOT EXISTS idx_properties_lamport ON node_properties(lamport_time);\n\nCREATE INDEX IF NOT EXISTS idx_prop_scalars_text\n ON node_property_scalars(schema_id, property_key, value_text, node_id)\n WHERE value_type = 'text';\nCREATE INDEX IF NOT EXISTS idx_prop_scalars_number\n ON node_property_scalars(schema_id, property_key, value_number, node_id)\n WHERE value_type = 'number';\nCREATE INDEX IF NOT EXISTS idx_prop_scalars_boolean\n ON node_property_scalars(schema_id, property_key, value_boolean, node_id)\n WHERE value_type = 'boolean';\nCREATE INDEX IF NOT EXISTS idx_prop_scalars_null\n ON node_property_scalars(schema_id, property_key, node_id)\n WHERE value_type = 'null';\nCREATE INDEX IF NOT EXISTS idx_prop_scalars_node\n ON node_property_scalars(node_id);\n\nCREATE INDEX IF NOT EXISTS idx_query_stats_schema_seen\n ON query_descriptor_stats(schema_id, last_seen_at DESC);\nCREATE INDEX IF NOT EXISTS idx_query_indexes_schema_property\n ON query_index_candidates(schema_id, property_key, value_type);\nCREATE INDEX IF NOT EXISTS idx_query_materializations_schema\n ON node_query_materializations(schema_id, invalidated_at);\nCREATE INDEX IF NOT EXISTS idx_query_materialized_ids_node\n ON node_query_materialized_ids(node_id);\n\nCREATE INDEX IF NOT EXISTS idx_changes_node ON changes(node_id);\nCREATE INDEX IF NOT EXISTS idx_changes_lamport ON changes(lamport_time);\nCREATE INDEX IF NOT EXISTS idx_changes_wall_time ON changes(wall_time);\nCREATE INDEX IF NOT EXISTS idx_changes_batch ON changes(batch_id);\nCREATE INDEX IF NOT EXISTS idx_changes_node_lamport\n ON changes(node_id, lamport_time DESC, hash);\n\nCREATE INDEX IF NOT EXISTS idx_yjs_state_updated ON yjs_state(updated_at);\nCREATE INDEX IF NOT EXISTS idx_yjs_updates_node ON yjs_updates(node_id);\nCREATE INDEX IF NOT EXISTS idx_yjs_snapshots_node ON yjs_snapshots(node_id);\nCREATE INDEX IF NOT EXISTS idx_yjs_snapshots_timestamp ON yjs_snapshots(node_id, timestamp);\n\nCREATE INDEX IF NOT EXISTS idx_updates_doc ON updates(doc_id);\nCREATE INDEX IF NOT EXISTS idx_updates_created ON updates(created_at);\n";
|
|
14
|
+
/**
|
|
15
|
+
* FTS5 schema for full-text search.
|
|
16
|
+
* This is applied separately because sql.js doesn't support FTS5.
|
|
17
|
+
*/
|
|
18
|
+
declare const SCHEMA_DDL_FTS = "\n-- ============================================\n-- Full-Text Search (FTS5)\n-- ============================================\n\n-- FTS index for searchable node content\nCREATE VIRTUAL TABLE IF NOT EXISTS nodes_fts USING fts5(\n node_id,\n title,\n content,\n tokenize='porter unicode61'\n);\n\n-- Triggers to keep FTS in sync will be managed by application layer\n-- since the searchable content is derived from node properties\n";
|
|
19
|
+
/**
|
|
20
|
+
* Unified SQLite schema for xNet.
|
|
21
|
+
* This schema is shared across all platforms (with FTS5).
|
|
22
|
+
* Use SCHEMA_DDL_CORE for platforms without FTS5 support (sql.js).
|
|
23
|
+
*/
|
|
24
|
+
declare const SCHEMA_DDL: string;
|
|
25
|
+
/**
|
|
26
|
+
* Schema for future versions (migrations).
|
|
27
|
+
* Each key is the version number, value is the upgrade SQL.
|
|
28
|
+
*/
|
|
29
|
+
declare const SCHEMA_MIGRATIONS: Record<number, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Get the SQL to upgrade from one version to another.
|
|
32
|
+
*/
|
|
33
|
+
declare function getMigrationSQL(fromVersion: number, toVersion: number): string;
|
|
34
|
+
|
|
35
|
+
export { SCHEMA_VERSION as S, SCHEMA_DDL as a, SCHEMA_DDL_CORE as b, SCHEMA_DDL_FTS as c, SCHEMA_MIGRATIONS as d, getMigrationSQL as g };
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @xnetjs/sqlite - Type definitions for unified SQLite adapter
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* SQL parameter types that can be bound to statements.
|
|
6
|
+
*/
|
|
7
|
+
type SQLValue = string | number | bigint | Uint8Array | null;
|
|
8
|
+
/**
|
|
9
|
+
* Row type for query results.
|
|
10
|
+
*/
|
|
11
|
+
type SQLRow = Record<string, SQLValue>;
|
|
12
|
+
/**
|
|
13
|
+
* One read of a {@link SQLiteAdapter.queryBatch} call: a SELECT plus its
|
|
14
|
+
* bound parameters. Results come back positionally, one row array per read.
|
|
15
|
+
*/
|
|
16
|
+
interface SQLBatchRead {
|
|
17
|
+
sql: string;
|
|
18
|
+
params?: SQLValue[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Result of a mutation query (INSERT, UPDATE, DELETE).
|
|
22
|
+
*/
|
|
23
|
+
interface RunResult {
|
|
24
|
+
/** Number of rows affected by the query */
|
|
25
|
+
changes: number;
|
|
26
|
+
/** Last inserted row ID (for INSERT with AUTOINCREMENT) */
|
|
27
|
+
lastInsertRowid: bigint;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Configuration options for SQLite database.
|
|
31
|
+
*/
|
|
32
|
+
interface SQLiteConfig {
|
|
33
|
+
/** Database file path or name */
|
|
34
|
+
path: string;
|
|
35
|
+
/** Enable WAL mode (default: true) */
|
|
36
|
+
walMode?: boolean;
|
|
37
|
+
/** Enable foreign keys (default: true) */
|
|
38
|
+
foreignKeys?: boolean;
|
|
39
|
+
/** Busy timeout in milliseconds (default: 5000) */
|
|
40
|
+
busyTimeout?: number;
|
|
41
|
+
/**
|
|
42
|
+
* Emit boot diagnostics from the worker: a per-operation queue/exec timing
|
|
43
|
+
* trace and a one-shot DB-stats line at open (exploration 0229). Set by the
|
|
44
|
+
* main thread, which can read the `xnet:boot:debug` flag — the worker can't
|
|
45
|
+
* (`localStorage` is unavailable in workers).
|
|
46
|
+
*/
|
|
47
|
+
bootDebug?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Per-attempt timeout (ms) for the web worker's `open()` before the worker is
|
|
50
|
+
* terminated and retried with a fresh one (default: 15000). A cold
|
|
51
|
+
* `installOpfsSAHPoolVfs()` on a large DB file can intermittently exceed this —
|
|
52
|
+
* usually because a prior boot leaked a worker still holding the file's
|
|
53
|
+
* exclusive OPFS handle; terminating + retrying clears that contention rather
|
|
54
|
+
* than hard-failing the boot (exploration 0253). Web adapter only.
|
|
55
|
+
*/
|
|
56
|
+
openTimeoutMs?: number;
|
|
57
|
+
/**
|
|
58
|
+
* Multi-tab leadership routing (exploration 0263). When Web Locks and
|
|
59
|
+
* SharedWorker are available, tabs elect a leader that owns the SQLite
|
|
60
|
+
* worker; other tabs route their storage RPCs to it instead of losing the
|
|
61
|
+
* OPFS handle race and silently falling back to a non-durable `:memory:`
|
|
62
|
+
* database (exploration 0204). Default: `true` where supported — set `false`
|
|
63
|
+
* to force the previous per-tab behaviour. Web proxy only.
|
|
64
|
+
*/
|
|
65
|
+
multiTab?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Front every storage operation with the priority scheduler so a queued write
|
|
68
|
+
* burst can't head-of-line block an interactive read, and a manual transaction
|
|
69
|
+
* holds the connection exclusively (`BEGIN`…`COMMIT` can't be interleaved).
|
|
70
|
+
* Default: `true`. Has no effect on the WASM/web adapters, which schedule in
|
|
71
|
+
* their worker host instead.
|
|
72
|
+
*/
|
|
73
|
+
scheduler?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Open a second, **read-only** `better-sqlite3` connection so plain reads use
|
|
76
|
+
* a different connection than the writer (no contention with write locks).
|
|
77
|
+
* Ignored for `:memory:` databases (each connection would be a separate DB).
|
|
78
|
+
* Default: `false`.
|
|
79
|
+
*/
|
|
80
|
+
readonlyReadConnection?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Spawn a pool of read-only `better-sqlite3` reader threads so **heavy** reads
|
|
83
|
+
* (FTS, large aggregates, big scans) run in parallel on other cores instead of
|
|
84
|
+
* blocking the data-process thread. `'auto'` sizes the pool to the host's core
|
|
85
|
+
* count (capped). `0` / `undefined` disables it. Ignored for `:memory:`.
|
|
86
|
+
* Default: disabled.
|
|
87
|
+
*/
|
|
88
|
+
readerPoolSize?: number | 'auto';
|
|
89
|
+
/**
|
|
90
|
+
* Reads issued within this many milliseconds of the most recent commit route
|
|
91
|
+
* to the writer connection (read-your-writes safety) instead of the read-only
|
|
92
|
+
* connection / reader pool. WAL already makes committed writes visible across
|
|
93
|
+
* in-process connections, so the default `0` trusts WAL; raise it only if a
|
|
94
|
+
* platform shows stale cross-connection reads.
|
|
95
|
+
*/
|
|
96
|
+
readYourWritesWindowMs?: number;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Point-in-time diagnostics for the Electron SQLite adapter (exploration 0230):
|
|
100
|
+
* scheduler queue depth, reader-pool occupancy, and WAL growth. Surfaced to the
|
|
101
|
+
* desktop diagnostics seam.
|
|
102
|
+
*/
|
|
103
|
+
interface ElectronSQLiteDiagnostics {
|
|
104
|
+
/** Scheduler lane depths + in-flight flag, or null when the scheduler is off. */
|
|
105
|
+
scheduler: {
|
|
106
|
+
interactive: number;
|
|
107
|
+
bulk: number;
|
|
108
|
+
write: number;
|
|
109
|
+
inFlight: boolean;
|
|
110
|
+
} | null;
|
|
111
|
+
/** Reader-thread pool occupancy, or null when no pool is configured. */
|
|
112
|
+
readerPool: {
|
|
113
|
+
size: number;
|
|
114
|
+
healthy: number;
|
|
115
|
+
inFlight: number;
|
|
116
|
+
dispatched: number;
|
|
117
|
+
failures: number;
|
|
118
|
+
} | null;
|
|
119
|
+
/** WAL file growth, or null when unavailable / not in WAL mode. */
|
|
120
|
+
wal: {
|
|
121
|
+
walBytes: number;
|
|
122
|
+
pageCount: number;
|
|
123
|
+
} | null;
|
|
124
|
+
/** Whether a read-only secondary connection is open. */
|
|
125
|
+
readonlyConnection: boolean;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Schema version information.
|
|
129
|
+
*/
|
|
130
|
+
interface SchemaVersion {
|
|
131
|
+
version: number;
|
|
132
|
+
appliedAt: number;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Runtime operation counters for diagnosing SQLite import performance.
|
|
136
|
+
*
|
|
137
|
+
* Counts are cumulative until reset by the adapter. Proxy-backed adapters can
|
|
138
|
+
* use `workerRequestCount` to show serialization-boundary pressure separately
|
|
139
|
+
* from the SQL statements executed by SQLite.
|
|
140
|
+
*/
|
|
141
|
+
interface SQLiteOperationStats {
|
|
142
|
+
/** SELECT statements returning many rows. */
|
|
143
|
+
queryCount: number;
|
|
144
|
+
/** SELECT statements returning at most one row. */
|
|
145
|
+
queryOneCount: number;
|
|
146
|
+
/** INSERT, UPDATE, DELETE, or other mutation statements. */
|
|
147
|
+
runCount: number;
|
|
148
|
+
/** Raw SQL executions, often schema or transaction control statements. */
|
|
149
|
+
execCount: number;
|
|
150
|
+
/** Callback transactions requested through this adapter. */
|
|
151
|
+
transactionCount: number;
|
|
152
|
+
/** Batch transactions requested through this adapter. */
|
|
153
|
+
transactionBatchCount: number;
|
|
154
|
+
/** SQL operations included in batch transactions. */
|
|
155
|
+
transactionBatchOperationCount: number;
|
|
156
|
+
/** Comlink or postMessage requests crossing into a worker. */
|
|
157
|
+
workerRequestCount: number;
|
|
158
|
+
}
|
|
159
|
+
type SQLiteNodeBatchIndexMode = 'eager' | 'touched' | 'defer-schema';
|
|
160
|
+
interface SQLiteNodeBatchNodeRow {
|
|
161
|
+
id: string;
|
|
162
|
+
schemaId: string;
|
|
163
|
+
createdAt: number;
|
|
164
|
+
updatedAt: number;
|
|
165
|
+
createdBy: string;
|
|
166
|
+
deletedAt: number | null;
|
|
167
|
+
propertyKeys: string[];
|
|
168
|
+
}
|
|
169
|
+
interface SQLiteNodeBatchPropertyRow {
|
|
170
|
+
nodeId: string;
|
|
171
|
+
propertyKey: string;
|
|
172
|
+
value: Uint8Array | null;
|
|
173
|
+
lamportTime: number;
|
|
174
|
+
updatedBy: string;
|
|
175
|
+
updatedAt: number;
|
|
176
|
+
}
|
|
177
|
+
interface SQLiteNodeBatchChangeRow {
|
|
178
|
+
hash: string;
|
|
179
|
+
nodeId: string;
|
|
180
|
+
payload: Uint8Array;
|
|
181
|
+
lamportTime: number;
|
|
182
|
+
lamportPeer: string;
|
|
183
|
+
wallTime: number;
|
|
184
|
+
author: string;
|
|
185
|
+
parentHash: string | null;
|
|
186
|
+
batchId: string | null;
|
|
187
|
+
signature: Uint8Array;
|
|
188
|
+
}
|
|
189
|
+
interface SQLiteNodeBatchScalarIndexRow {
|
|
190
|
+
nodeId: string;
|
|
191
|
+
schemaId: string;
|
|
192
|
+
propertyKey: string;
|
|
193
|
+
valueType: string;
|
|
194
|
+
valueText: string | null;
|
|
195
|
+
valueNumber: number | null;
|
|
196
|
+
valueBoolean: number | null;
|
|
197
|
+
valueHash: string | null;
|
|
198
|
+
updatedAt: number;
|
|
199
|
+
lamportTime: number;
|
|
200
|
+
}
|
|
201
|
+
interface SQLiteNodeBatchFtsRow {
|
|
202
|
+
nodeId: string;
|
|
203
|
+
title: string;
|
|
204
|
+
content: string;
|
|
205
|
+
}
|
|
206
|
+
interface SQLiteNodeBatchApplyInput {
|
|
207
|
+
nodes: SQLiteNodeBatchNodeRow[];
|
|
208
|
+
properties: SQLiteNodeBatchPropertyRow[];
|
|
209
|
+
changes: SQLiteNodeBatchChangeRow[];
|
|
210
|
+
scalarIndexRows: SQLiteNodeBatchScalarIndexRow[];
|
|
211
|
+
ftsNodeIds: string[];
|
|
212
|
+
ftsRows: SQLiteNodeBatchFtsRow[];
|
|
213
|
+
affectedSchemaIds: string[];
|
|
214
|
+
lastLamportTime: number;
|
|
215
|
+
indexMode: SQLiteNodeBatchIndexMode;
|
|
216
|
+
}
|
|
217
|
+
interface SQLiteNodeBatchApplyResult {
|
|
218
|
+
nodeRowsWritten: number;
|
|
219
|
+
propertyRowsWritten: number;
|
|
220
|
+
changeRowsWritten: number;
|
|
221
|
+
scalarRowsWritten: number;
|
|
222
|
+
ftsRowsWritten: number;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export type { ElectronSQLiteDiagnostics as E, RunResult as R, SQLValue as S, SQLRow as a, SQLiteConfig as b, SQLBatchRead as c, SchemaVersion as d, SQLiteOperationStats as e, SQLiteNodeBatchIndexMode as f, SQLiteNodeBatchNodeRow as g, SQLiteNodeBatchPropertyRow as h, SQLiteNodeBatchChangeRow as i, SQLiteNodeBatchScalarIndexRow as j, SQLiteNodeBatchFtsRow as k, SQLiteNodeBatchApplyInput as l, SQLiteNodeBatchApplyResult as m };
|