@capgo/capacitor-fast-sql 8.2.16 → 8.2.17
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/README.md +8 -8
- package/android/src/main/java/app/capgo/capacitor/fastsql/CapgoCapacitorFastSqlPlugin.java +29 -6
- package/android/src/main/java/app/capgo/capacitor/fastsql/DatabaseConnection.java +2 -0
- package/android/src/main/java/app/capgo/capacitor/fastsql/EncryptedSQLDatabase.java +33 -46
- package/android/src/main/java/app/capgo/capacitor/fastsql/SQLDatabase.java +32 -50
- package/android/src/main/java/app/capgo/capacitor/fastsql/SQLHTTPServer.java +11 -23
- package/dist/esm/definitions.d.ts +6 -2
- package/dist/esm/definitions.d.ts.map +1 -1
- package/dist/esm/definitions.js +3 -1
- package/dist/esm/fast-sql.d.ts +4 -0
- package/dist/esm/fast-sql.d.ts.map +1 -1
- package/dist/esm/fast-sql.js +35 -3
- package/dist/esm/native-sql-connection.d.ts +1 -0
- package/dist/esm/native-sql-connection.d.ts.map +1 -1
- package/dist/esm/native-sql-connection.js +13 -6
- package/dist/esm/transaction-isolation.d.ts +3 -0
- package/dist/esm/transaction-isolation.d.ts.map +1 -0
- package/dist/esm/transaction-isolation.js +6 -0
- package/dist/esm/vector-store.d.ts.map +1 -1
- package/dist/esm/vector-store.js +5 -2
- package/dist/esm/web-sql-connection.d.ts.map +1 -1
- package/dist/esm/web-sql-connection.js +2 -0
- package/dist/esm/web.d.ts.map +1 -1
- package/dist/esm/web.js +10 -2
- package/dist/plugin.cjs.js +71 -14
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +71 -14
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapgoCapacitorFastSqlPlugin/CapgoCapacitorFastSqlPlugin.swift +25 -3
- package/ios/Sources/CapgoCapacitorFastSqlPlugin/SQLDatabase.swift +15 -5
- package/ios/Sources/CapgoCapacitorFastSqlPlugin/SQLHTTPServer.swift +6 -0
- package/ios/Tests/CapgoCapacitorFastSqlPluginTests/CapgoCapacitorFastSqlPluginTests.swift +13 -3
- package/ios/Tests/CapgoCapacitorFastSqlPluginTests/SQLResultMetadataTests.swift +15 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector-store.d.ts","sourceRoot":"","sources":["../../src/vector-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAoB,MAAM,eAAe,CAAC;AAE5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAMtD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAErD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IAC1C,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC;CACvD;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED,MAAM,WAAW,sBAAuB,SAAQ,oBAAoB;IAClE,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE,MAAM,CAAC;IA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AgBvB,OAAO,CAAC,cAAc;IAItB,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,gBAAgB;IAqBxB,OAAO,CAAC,QAAQ;CAYjB"}
|
package/dist/esm/vector-store.js
CHANGED
|
@@ -162,8 +162,11 @@ export class FastSQLVectorStore {
|
|
|
162
162
|
.map((row) => this.rowToGetResult(row))
|
|
163
163
|
.filter(params.predicate)
|
|
164
164
|
.map((row) => row.id);
|
|
165
|
-
for (
|
|
166
|
-
await this.connection.
|
|
165
|
+
for (let offset = 0; offset < ids.length; offset += 100) {
|
|
166
|
+
await this.connection.executeBatch(ids.slice(offset, offset + 100).map((id) => ({
|
|
167
|
+
statement: `DELETE FROM ${VECTOR_TABLE} WHERE store = ? AND id = ?`,
|
|
168
|
+
params: [this.store, id],
|
|
169
|
+
})));
|
|
167
170
|
}
|
|
168
171
|
}
|
|
169
172
|
async query(params) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-sql-connection.d.ts","sourceRoot":"","sources":["../../src/web-sql-connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,QAAQ,EACR,MAAM,EACN,SAAS,EACT,iBAAiB,EACjB,cAAc,EACf,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"web-sql-connection.d.ts","sourceRoot":"","sources":["../../src/web-sql-connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,QAAQ,EACR,MAAM,EACN,SAAS,EACT,iBAAiB,EACjB,cAAc,EACf,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGtD;;;GAGG;AACH,qBAAa,gBAAiB,YAAW,aAAa;IACpD,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAA8B;IAC5C,OAAO,CAAC,aAAa,CAAS;gBAElB,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,2BAA2B;IAKjE;;OAEG;IACH,eAAe,IAAI,MAAM;IAIzB;;;;;;OAMG;IACG,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC;IAIzE;;;;;OAKG;IACG,YAAY,CAAC,UAAU,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAQzE;;;;OAIG;IACG,gBAAgB,CAAC,cAAc,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAUtE;;OAEG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAS7B;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAS/B;;;;;OAKG;IACG,WAAW,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,OAAO,CAAC,CAAC,CAAC,EAAE,cAAc,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC;IAsBhH;;;;;;OAMG;IACG,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAKtE;;;;;;OAMG;IACG,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAOxG"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assertSupportedIsolation } from './transaction-isolation';
|
|
1
2
|
/**
|
|
2
3
|
* Web implementation of SQLConnection that calls the Capacitor plugin directly,
|
|
3
4
|
* avoiding HTTP network requests which are not available on the web platform.
|
|
@@ -43,6 +44,7 @@ export class WebSQLConnection {
|
|
|
43
44
|
* @param isolationLevel - Optional isolation level
|
|
44
45
|
*/
|
|
45
46
|
async beginTransaction(isolationLevel) {
|
|
47
|
+
assertSupportedIsolation(isolationLevel);
|
|
46
48
|
if (this.inTransaction) {
|
|
47
49
|
throw new Error('Transaction already in progress');
|
|
48
50
|
}
|
package/dist/esm/web.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,OAAO,KAAK,EACV,2BAA2B,EAC3B,oBAAoB,EACpB,SAAS,EACT,QAAQ,EACR,cAAc,EACd,SAAS,EACV,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAI5C,OAAO,KAAK,EACV,2BAA2B,EAC3B,oBAAoB,EACpB,SAAS,EACT,QAAQ,EACR,cAAc,EACd,SAAS,EACV,MAAM,eAAe,CAAC;AAevB;;;;;;GAMG;AACH,qBAAa,wBAAyB,SAAQ,SAAU,YAAW,2BAA2B;IAC5F,OAAO,CAAC,SAAS,CAAkC;IACnD,OAAO,CAAC,eAAe,CAAyC;IAChE,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,SAAS,CAAiB;IAElC;;;OAGG;IACG,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAKpD,OAAO,CAAC,WAAW;IAQnB,OAAO,CAAC,MAAM;IAOR,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAsDlG,UAAU,CAAC,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAYxD,aAAa,CAAC,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAYtF,OAAO,CAAC,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,SAAS,CAAC;IA+ClG,gBAAgB,CAAC,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,cAAc,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ/F,iBAAiB,CAAC,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAO/D,mBAAmB,CAAC,OAAO,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,IAAI,CAAC;YAOzD,sBAAsB;IAkBpC,OAAO,CAAC,aAAa;IAMf,gBAAgB,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAGvD"}
|
package/dist/esm/web.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
2
|
import { sqlite3Worker1Promiser } from '@sqlite.org/sqlite-wasm';
|
|
3
|
+
import { assertSupportedIsolation } from './transaction-isolation';
|
|
3
4
|
/**
|
|
4
5
|
* Web implementation using the official SQLite Wasm build with OPFS persistence.
|
|
5
6
|
*
|
|
@@ -31,9 +32,15 @@ export class CapgoCapacitorFastSqlWeb extends WebPlugin {
|
|
|
31
32
|
return this.promiserPromise;
|
|
32
33
|
}
|
|
33
34
|
dbPath(database) {
|
|
35
|
+
if (!database || database === '.' || database === '..' || /[/\\\0]/.test(database)) {
|
|
36
|
+
throw new Error('Database must be a non-empty file name without path separators');
|
|
37
|
+
}
|
|
34
38
|
return `/capgo-fast-sql/${database}.sqlite3`;
|
|
35
39
|
}
|
|
36
40
|
async connect(options) {
|
|
41
|
+
if (options.readOnly) {
|
|
42
|
+
throw new Error('Read-only opens are not supported by the SQLite Wasm Worker transport');
|
|
43
|
+
}
|
|
37
44
|
if (this.databases.has(options.database)) {
|
|
38
45
|
const existing = this.databases.get(options.database);
|
|
39
46
|
return {
|
|
@@ -42,14 +49,14 @@ export class CapgoCapacitorFastSqlWeb extends WebPlugin {
|
|
|
42
49
|
database: options.database,
|
|
43
50
|
};
|
|
44
51
|
}
|
|
45
|
-
const promiser = await this.getPromiser();
|
|
46
52
|
const path = this.dbPath(options.database);
|
|
53
|
+
const promiser = await this.getPromiser();
|
|
47
54
|
const useOpfs = this.webConfig.useOpfs !== false;
|
|
48
55
|
let openResult;
|
|
49
56
|
if (useOpfs) {
|
|
50
57
|
try {
|
|
51
58
|
openResult = await promiser('open', {
|
|
52
|
-
filename: `file
|
|
59
|
+
filename: `file:/capgo-fast-sql/${encodeURIComponent(options.database)}.sqlite3?vfs=opfs`,
|
|
53
60
|
});
|
|
54
61
|
}
|
|
55
62
|
catch (opfsError) {
|
|
@@ -141,6 +148,7 @@ export class CapgoCapacitorFastSqlWeb extends WebPlugin {
|
|
|
141
148
|
}
|
|
142
149
|
}
|
|
143
150
|
async beginTransaction(options) {
|
|
151
|
+
assertSupportedIsolation(options.isolationLevel);
|
|
144
152
|
await this.execute({
|
|
145
153
|
database: options.database,
|
|
146
154
|
statement: 'BEGIN TRANSACTION',
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -4,7 +4,9 @@ var core = require('@capacitor/core');
|
|
|
4
4
|
var sqliteWasm = require('@sqlite.org/sqlite-wasm');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Transaction isolation levels
|
|
7
|
+
* Transaction isolation levels. Only Serializable is supported by the current
|
|
8
|
+
* SQLite backends. Other values are retained for source compatibility but reject
|
|
9
|
+
* before starting a transaction; they are not silently mapped to another level.
|
|
8
10
|
*/
|
|
9
11
|
exports.IsolationLevel = void 0;
|
|
10
12
|
(function (IsolationLevel) {
|
|
@@ -18,6 +20,12 @@ const CapgoCapacitorFastSql = core.registerPlugin('CapgoCapacitorFastSql', {
|
|
|
18
20
|
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.CapgoCapacitorFastSqlWeb()),
|
|
19
21
|
});
|
|
20
22
|
|
|
23
|
+
function assertSupportedIsolation(level) {
|
|
24
|
+
if (level !== undefined && level !== exports.IsolationLevel.Serializable) {
|
|
25
|
+
throw new Error('Only SERIALIZABLE transaction isolation is supported');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
21
29
|
/**
|
|
22
30
|
* SQL Connection class that uses HTTP protocol for efficient communication
|
|
23
31
|
* with native SQLite databases, bypassing Capacitor's standard bridge.
|
|
@@ -30,7 +38,12 @@ class NativeSQLConnection {
|
|
|
30
38
|
this.database = database;
|
|
31
39
|
this.port = port;
|
|
32
40
|
this.token = token;
|
|
33
|
-
this.baseUrl = `http://
|
|
41
|
+
this.baseUrl = `http://127.0.0.1:${port}`;
|
|
42
|
+
}
|
|
43
|
+
browserFetch(input, init) {
|
|
44
|
+
const savedFetch = Reflect.get(globalThis, 'CapacitorWebFetch');
|
|
45
|
+
const browserFetch = typeof savedFetch === 'function' ? savedFetch : globalThis.fetch;
|
|
46
|
+
return browserFetch.call(globalThis, input, init);
|
|
34
47
|
}
|
|
35
48
|
/**
|
|
36
49
|
* Get the database name
|
|
@@ -46,7 +59,7 @@ class NativeSQLConnection {
|
|
|
46
59
|
* @returns Query results
|
|
47
60
|
*/
|
|
48
61
|
async execute(statement, params) {
|
|
49
|
-
const response = await
|
|
62
|
+
const response = await this.browserFetch(`${this.baseUrl}/execute`, {
|
|
50
63
|
method: 'POST',
|
|
51
64
|
headers: {
|
|
52
65
|
'Content-Type': 'application/json',
|
|
@@ -72,7 +85,7 @@ class NativeSQLConnection {
|
|
|
72
85
|
* @returns Array of results for each operation
|
|
73
86
|
*/
|
|
74
87
|
async executeBatch(operations) {
|
|
75
|
-
const response = await
|
|
88
|
+
const response = await this.browserFetch(`${this.baseUrl}/batch`, {
|
|
76
89
|
method: 'POST',
|
|
77
90
|
headers: {
|
|
78
91
|
'Content-Type': 'application/json',
|
|
@@ -99,10 +112,11 @@ class NativeSQLConnection {
|
|
|
99
112
|
* @param isolationLevel - Optional isolation level
|
|
100
113
|
*/
|
|
101
114
|
async beginTransaction(isolationLevel) {
|
|
115
|
+
assertSupportedIsolation(isolationLevel);
|
|
102
116
|
if (this.inTransaction) {
|
|
103
117
|
throw new Error('Transaction already in progress');
|
|
104
118
|
}
|
|
105
|
-
const response = await
|
|
119
|
+
const response = await this.browserFetch(`${this.baseUrl}/transaction/begin`, {
|
|
106
120
|
method: 'POST',
|
|
107
121
|
headers: {
|
|
108
122
|
'Content-Type': 'application/json',
|
|
@@ -126,7 +140,7 @@ class NativeSQLConnection {
|
|
|
126
140
|
if (!this.inTransaction) {
|
|
127
141
|
throw new Error('No transaction in progress');
|
|
128
142
|
}
|
|
129
|
-
const response = await
|
|
143
|
+
const response = await this.browserFetch(`${this.baseUrl}/transaction/commit`, {
|
|
130
144
|
method: 'POST',
|
|
131
145
|
headers: {
|
|
132
146
|
Authorization: `Bearer ${this.token}`,
|
|
@@ -146,7 +160,7 @@ class NativeSQLConnection {
|
|
|
146
160
|
if (!this.inTransaction) {
|
|
147
161
|
throw new Error('No transaction in progress');
|
|
148
162
|
}
|
|
149
|
-
const response = await
|
|
163
|
+
const response = await this.browserFetch(`${this.baseUrl}/transaction/rollback`, {
|
|
150
164
|
method: 'POST',
|
|
151
165
|
headers: {
|
|
152
166
|
Authorization: `Bearer ${this.token}`,
|
|
@@ -307,6 +321,7 @@ class WebSQLConnection {
|
|
|
307
321
|
* @param isolationLevel - Optional isolation level
|
|
308
322
|
*/
|
|
309
323
|
async beginTransaction(isolationLevel) {
|
|
324
|
+
assertSupportedIsolation(isolationLevel);
|
|
310
325
|
if (this.inTransaction) {
|
|
311
326
|
throw new Error('Transaction already in progress');
|
|
312
327
|
}
|
|
@@ -401,12 +416,40 @@ class FastSQL {
|
|
|
401
416
|
* @returns SQLConnection instance for executing queries
|
|
402
417
|
*/
|
|
403
418
|
static async connect(options) {
|
|
404
|
-
|
|
405
|
-
const
|
|
419
|
+
var _a;
|
|
420
|
+
const saved = this.openOptions.get(options.database);
|
|
421
|
+
if (saved && !this.optionsMatch(saved, options)) {
|
|
422
|
+
throw new Error(`Database '${options.database}' is already opening or open with different options`);
|
|
423
|
+
}
|
|
424
|
+
const existing = (_a = this.connections.get(options.database)) !== null && _a !== void 0 ? _a : this.opening.get(options.database);
|
|
406
425
|
if (existing) {
|
|
407
426
|
this.sharedConnections.add(options.database);
|
|
408
427
|
return existing;
|
|
409
428
|
}
|
|
429
|
+
const snapshot = Object.assign({}, options);
|
|
430
|
+
this.openOptions.set(options.database, snapshot);
|
|
431
|
+
const pending = this.open(snapshot);
|
|
432
|
+
this.opening.set(options.database, pending);
|
|
433
|
+
try {
|
|
434
|
+
return await pending;
|
|
435
|
+
}
|
|
436
|
+
catch (error) {
|
|
437
|
+
this.openOptions.delete(options.database);
|
|
438
|
+
this.sharedConnections.delete(options.database);
|
|
439
|
+
throw error;
|
|
440
|
+
}
|
|
441
|
+
finally {
|
|
442
|
+
this.opening.delete(options.database);
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
static optionsMatch(left, right) {
|
|
446
|
+
return (Boolean(left.encrypted) === Boolean(right.encrypted) &&
|
|
447
|
+
left.encryptionKey === right.encryptionKey &&
|
|
448
|
+
Boolean(left.readOnly) === Boolean(right.readOnly) &&
|
|
449
|
+
Boolean(left.walMode) === Boolean(right.walMode) &&
|
|
450
|
+
Boolean(left.performancePresets) === Boolean(right.performancePresets));
|
|
451
|
+
}
|
|
452
|
+
static async open(options) {
|
|
410
453
|
// Connect via native plugin
|
|
411
454
|
const info = await CapgoCapacitorFastSql.connect(options);
|
|
412
455
|
// Create connection instance appropriate for the current platform
|
|
@@ -429,6 +472,7 @@ class FastSQL {
|
|
|
429
472
|
*/
|
|
430
473
|
static async disconnect(database) {
|
|
431
474
|
var _a;
|
|
475
|
+
await this.opening.get(database);
|
|
432
476
|
const connection = this.connections.get(database);
|
|
433
477
|
if (!connection) {
|
|
434
478
|
throw new Error(`Database '${database}' is not connected`);
|
|
@@ -441,6 +485,7 @@ class FastSQL {
|
|
|
441
485
|
await CapgoCapacitorFastSql.disconnect({ database });
|
|
442
486
|
// Remove connection
|
|
443
487
|
this.connections.delete(database);
|
|
488
|
+
this.openOptions.delete(database);
|
|
444
489
|
this.sharedConnections.delete(database);
|
|
445
490
|
this.connectionRetainers.delete(database);
|
|
446
491
|
this.pendingDisconnects.delete(database);
|
|
@@ -492,7 +537,7 @@ class FastSQL {
|
|
|
492
537
|
* Close all open connections
|
|
493
538
|
*/
|
|
494
539
|
static async disconnectAll() {
|
|
495
|
-
const databases = Array.from(this.connections.keys());
|
|
540
|
+
const databases = Array.from(new Set([...this.connections.keys(), ...this.opening.keys()]));
|
|
496
541
|
await Promise.all(databases.map((db) => {
|
|
497
542
|
this.connectionRetainers.delete(db);
|
|
498
543
|
this.pendingDisconnects.delete(db);
|
|
@@ -508,6 +553,8 @@ class FastSQL {
|
|
|
508
553
|
return Array.from(this.connections.keys());
|
|
509
554
|
}
|
|
510
555
|
}
|
|
556
|
+
FastSQL.opening = new Map();
|
|
557
|
+
FastSQL.openOptions = new Map();
|
|
511
558
|
FastSQL.connections = new Map();
|
|
512
559
|
FastSQL.sharedConnections = new Set();
|
|
513
560
|
FastSQL.connectionRetainers = new Map();
|
|
@@ -859,8 +906,11 @@ class FastSQLVectorStore {
|
|
|
859
906
|
.map((row) => this.rowToGetResult(row))
|
|
860
907
|
.filter(params.predicate)
|
|
861
908
|
.map((row) => row.id);
|
|
862
|
-
for (
|
|
863
|
-
await this.connection.
|
|
909
|
+
for (let offset = 0; offset < ids.length; offset += 100) {
|
|
910
|
+
await this.connection.executeBatch(ids.slice(offset, offset + 100).map((id) => ({
|
|
911
|
+
statement: `DELETE FROM ${VECTOR_TABLE} WHERE store = ? AND id = ?`,
|
|
912
|
+
params: [this.store, id],
|
|
913
|
+
})));
|
|
864
914
|
}
|
|
865
915
|
}
|
|
866
916
|
async query(params) {
|
|
@@ -1104,9 +1154,15 @@ class CapgoCapacitorFastSqlWeb extends core.WebPlugin {
|
|
|
1104
1154
|
return this.promiserPromise;
|
|
1105
1155
|
}
|
|
1106
1156
|
dbPath(database) {
|
|
1157
|
+
if (!database || database === '.' || database === '..' || /[/\\\0]/.test(database)) {
|
|
1158
|
+
throw new Error('Database must be a non-empty file name without path separators');
|
|
1159
|
+
}
|
|
1107
1160
|
return `/capgo-fast-sql/${database}.sqlite3`;
|
|
1108
1161
|
}
|
|
1109
1162
|
async connect(options) {
|
|
1163
|
+
if (options.readOnly) {
|
|
1164
|
+
throw new Error('Read-only opens are not supported by the SQLite Wasm Worker transport');
|
|
1165
|
+
}
|
|
1110
1166
|
if (this.databases.has(options.database)) {
|
|
1111
1167
|
const existing = this.databases.get(options.database);
|
|
1112
1168
|
return {
|
|
@@ -1115,14 +1171,14 @@ class CapgoCapacitorFastSqlWeb extends core.WebPlugin {
|
|
|
1115
1171
|
database: options.database,
|
|
1116
1172
|
};
|
|
1117
1173
|
}
|
|
1118
|
-
const promiser = await this.getPromiser();
|
|
1119
1174
|
const path = this.dbPath(options.database);
|
|
1175
|
+
const promiser = await this.getPromiser();
|
|
1120
1176
|
const useOpfs = this.webConfig.useOpfs !== false;
|
|
1121
1177
|
let openResult;
|
|
1122
1178
|
if (useOpfs) {
|
|
1123
1179
|
try {
|
|
1124
1180
|
openResult = await promiser('open', {
|
|
1125
|
-
filename: `file
|
|
1181
|
+
filename: `file:/capgo-fast-sql/${encodeURIComponent(options.database)}.sqlite3?vfs=opfs`,
|
|
1126
1182
|
});
|
|
1127
1183
|
}
|
|
1128
1184
|
catch (opfsError) {
|
|
@@ -1214,6 +1270,7 @@ class CapgoCapacitorFastSqlWeb extends core.WebPlugin {
|
|
|
1214
1270
|
}
|
|
1215
1271
|
}
|
|
1216
1272
|
async beginTransaction(options) {
|
|
1273
|
+
assertSupportedIsolation(options.isolationLevel);
|
|
1217
1274
|
await this.execute({
|
|
1218
1275
|
database: options.database,
|
|
1219
1276
|
statement: 'BEGIN TRANSACTION',
|