@capgo/capacitor-fast-sql 8.0.12 → 8.0.13
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/CapgoCapacitorFastSql.podspec +1 -0
- package/README.md +23 -0
- package/android/build.gradle +2 -1
- package/android/src/main/java/app/capgo/capacitor/fastsql/CapgoCapacitorFastSqlPlugin.java +19 -8
- package/android/src/main/java/app/capgo/capacitor/fastsql/DatabaseConnection.java +16 -0
- package/android/src/main/java/app/capgo/capacitor/fastsql/EncryptedSQLDatabase.java +222 -0
- package/android/src/main/java/app/capgo/capacitor/fastsql/SQLDatabase.java +1 -1
- package/android/src/main/java/app/capgo/capacitor/fastsql/SQLHTTPServer.java +8 -8
- package/dist/esm/fast-sql.d.ts.map +1 -1
- package/dist/esm/fast-sql.js +3 -2
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/key-value.d.ts +61 -0
- package/dist/esm/key-value.d.ts.map +1 -0
- package/dist/esm/key-value.js +183 -0
- package/dist/plugin.cjs.js +187 -2
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +187 -2
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/CapgoCapacitorFastSqlPlugin/CapgoCapacitorFastSqlPlugin.swift +9 -2
- package/ios/Sources/CapgoCapacitorFastSqlPlugin/SQLDatabase.swift +68 -1
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -275,8 +275,9 @@ var capacitorCapgoCapacitorFastSql = (function (exports, core) {
|
|
|
275
275
|
*/
|
|
276
276
|
static async connect(options) {
|
|
277
277
|
// Check if already connected
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
const existing = this.connections.get(options.database);
|
|
279
|
+
if (existing) {
|
|
280
|
+
return existing;
|
|
280
281
|
}
|
|
281
282
|
// Connect via native plugin
|
|
282
283
|
const info = await CapgoCapacitorFastSql.connect(options);
|
|
@@ -328,6 +329,189 @@ var capacitorCapgoCapacitorFastSql = (function (exports, core) {
|
|
|
328
329
|
}
|
|
329
330
|
FastSQL.connections = new Map();
|
|
330
331
|
|
|
332
|
+
/**
|
|
333
|
+
* Key-value storage backed by the FastSQL database connection.
|
|
334
|
+
*
|
|
335
|
+
* This is a lightweight wrapper for mobile-focused secure storage use cases.
|
|
336
|
+
*/
|
|
337
|
+
class KeyValueStore {
|
|
338
|
+
constructor(connection, store) {
|
|
339
|
+
this.initialized = false;
|
|
340
|
+
this.ownsConnection = false;
|
|
341
|
+
this.closed = false;
|
|
342
|
+
this.connection = connection;
|
|
343
|
+
this.store = store;
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Open (or create) a key-value store for the given database.
|
|
347
|
+
*/
|
|
348
|
+
static async open(options) {
|
|
349
|
+
var _a;
|
|
350
|
+
const connection = await FastSQL.connect(options);
|
|
351
|
+
const store = (_a = options.store) !== null && _a !== void 0 ? _a : 'default';
|
|
352
|
+
const kv = new KeyValueStore(connection, store);
|
|
353
|
+
kv.ownsConnection = true;
|
|
354
|
+
await kv.ensureSchema();
|
|
355
|
+
return kv;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Create a key-value store from an existing SQLConnection.
|
|
359
|
+
* Note: The caller retains ownership and is responsible for closing the connection.
|
|
360
|
+
*/
|
|
361
|
+
static async fromConnection(connection, store = 'default') {
|
|
362
|
+
const kv = new KeyValueStore(connection, store);
|
|
363
|
+
await kv.ensureSchema();
|
|
364
|
+
return kv;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Close the key-value store and release resources.
|
|
368
|
+
* Only disconnects the database if this store owns the connection (created via open()).
|
|
369
|
+
*/
|
|
370
|
+
async close() {
|
|
371
|
+
if (this.closed) {
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
this.closed = true;
|
|
375
|
+
if (this.ownsConnection) {
|
|
376
|
+
try {
|
|
377
|
+
await FastSQL.disconnect(this.connection.getDatabaseName());
|
|
378
|
+
}
|
|
379
|
+
catch (_a) {
|
|
380
|
+
// Ignore disconnect errors during close.
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
this.initialized = false;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Store a value by key.
|
|
387
|
+
*/
|
|
388
|
+
async set(key, value) {
|
|
389
|
+
await this.ensureSchema();
|
|
390
|
+
const encoded = this.encodeValue(value);
|
|
391
|
+
await this.connection.run('INSERT OR REPLACE INTO __kv_store (s, k, t, v) VALUES (?, ?, ?, ?)', [
|
|
392
|
+
this.store,
|
|
393
|
+
key,
|
|
394
|
+
encoded.type,
|
|
395
|
+
encoded.value,
|
|
396
|
+
]);
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Retrieve a value by key. Returns null if the key is missing.
|
|
400
|
+
*/
|
|
401
|
+
async get(key) {
|
|
402
|
+
await this.ensureSchema();
|
|
403
|
+
const rows = await this.connection.query('SELECT t, v FROM __kv_store WHERE s = ? AND k = ? LIMIT 1', [
|
|
404
|
+
this.store,
|
|
405
|
+
key,
|
|
406
|
+
]);
|
|
407
|
+
if (!rows.length) {
|
|
408
|
+
return null;
|
|
409
|
+
}
|
|
410
|
+
const row = rows[0];
|
|
411
|
+
const type = row.t;
|
|
412
|
+
const value = row.v;
|
|
413
|
+
return this.decodeValue(type, value);
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Check if a key exists.
|
|
417
|
+
*/
|
|
418
|
+
async has(key) {
|
|
419
|
+
await this.ensureSchema();
|
|
420
|
+
const rows = await this.connection.query('SELECT 1 as existsFlag FROM __kv_store WHERE s = ? AND k = ? LIMIT 1', [
|
|
421
|
+
this.store,
|
|
422
|
+
key,
|
|
423
|
+
]);
|
|
424
|
+
return rows.length > 0;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* Remove a single key.
|
|
428
|
+
*/
|
|
429
|
+
async remove(key) {
|
|
430
|
+
await this.ensureSchema();
|
|
431
|
+
await this.connection.run('DELETE FROM __kv_store WHERE s = ? AND k = ?', [this.store, key]);
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Clear all keys for the current store.
|
|
435
|
+
*/
|
|
436
|
+
async clear() {
|
|
437
|
+
await this.ensureSchema();
|
|
438
|
+
await this.connection.run('DELETE FROM __kv_store WHERE s = ?', [this.store]);
|
|
439
|
+
}
|
|
440
|
+
/**
|
|
441
|
+
* List all keys for the current store.
|
|
442
|
+
*/
|
|
443
|
+
async keys() {
|
|
444
|
+
await this.ensureSchema();
|
|
445
|
+
const rows = await this.connection.query('SELECT k FROM __kv_store WHERE s = ? ORDER BY k', [this.store]);
|
|
446
|
+
return rows.map((row) => String(row.k));
|
|
447
|
+
}
|
|
448
|
+
async ensureSchema() {
|
|
449
|
+
if (this.initialized) {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
await this.connection.run('CREATE TABLE IF NOT EXISTS __kv_store (s TEXT NOT NULL, k TEXT NOT NULL, t TEXT NOT NULL, v BLOB, PRIMARY KEY (s, k))');
|
|
453
|
+
await this.connection.run('CREATE INDEX IF NOT EXISTS __kv_store_s_idx ON __kv_store (s)');
|
|
454
|
+
this.initialized = true;
|
|
455
|
+
}
|
|
456
|
+
encodeValue(value) {
|
|
457
|
+
if (value === null || value === undefined) {
|
|
458
|
+
return { type: 'null', value: null };
|
|
459
|
+
}
|
|
460
|
+
if (value instanceof Uint8Array) {
|
|
461
|
+
return { type: 'binary', value };
|
|
462
|
+
}
|
|
463
|
+
if (typeof value === 'string') {
|
|
464
|
+
return { type: 'string', value };
|
|
465
|
+
}
|
|
466
|
+
if (typeof value === 'number') {
|
|
467
|
+
return { type: 'number', value };
|
|
468
|
+
}
|
|
469
|
+
if (typeof value === 'boolean') {
|
|
470
|
+
return { type: 'boolean', value: value ? 1 : 0 };
|
|
471
|
+
}
|
|
472
|
+
return { type: 'json', value: JSON.stringify(value) };
|
|
473
|
+
}
|
|
474
|
+
decodeValue(type, value) {
|
|
475
|
+
switch (type) {
|
|
476
|
+
case 'null':
|
|
477
|
+
return null;
|
|
478
|
+
case 'binary':
|
|
479
|
+
return value instanceof Uint8Array ? value : null;
|
|
480
|
+
case 'string':
|
|
481
|
+
return value != null ? String(value) : '';
|
|
482
|
+
case 'number':
|
|
483
|
+
if (typeof value === 'number') {
|
|
484
|
+
return value;
|
|
485
|
+
}
|
|
486
|
+
if (typeof value === 'string') {
|
|
487
|
+
const parsed = Number(value);
|
|
488
|
+
return Number.isNaN(parsed) ? 0 : parsed;
|
|
489
|
+
}
|
|
490
|
+
return 0;
|
|
491
|
+
case 'boolean':
|
|
492
|
+
if (typeof value === 'number') {
|
|
493
|
+
return value !== 0;
|
|
494
|
+
}
|
|
495
|
+
if (typeof value === 'string') {
|
|
496
|
+
return value === '1' || value.toLowerCase() === 'true';
|
|
497
|
+
}
|
|
498
|
+
return Boolean(value);
|
|
499
|
+
case 'json':
|
|
500
|
+
if (typeof value === 'string') {
|
|
501
|
+
try {
|
|
502
|
+
return JSON.parse(value);
|
|
503
|
+
}
|
|
504
|
+
catch (_a) {
|
|
505
|
+
return null;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
return null;
|
|
509
|
+
default:
|
|
510
|
+
return value;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
331
515
|
/**
|
|
332
516
|
* Web implementation using sql.js (SQLite compiled to WebAssembly)
|
|
333
517
|
*
|
|
@@ -549,6 +733,7 @@ var capacitorCapgoCapacitorFastSql = (function (exports, core) {
|
|
|
549
733
|
|
|
550
734
|
exports.CapgoCapacitorFastSql = CapgoCapacitorFastSql;
|
|
551
735
|
exports.FastSQL = FastSQL;
|
|
736
|
+
exports.KeyValueStore = KeyValueStore;
|
|
552
737
|
exports.SQLConnection = SQLConnection;
|
|
553
738
|
|
|
554
739
|
return exports;
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/plugin.js","esm/sql-connection.js","esm/fast-sql.js","esm/web.js"],"sourcesContent":["/**\n * Transaction isolation levels\n */\nexport var IsolationLevel;\n(function (IsolationLevel) {\n IsolationLevel[\"ReadUncommitted\"] = \"READ UNCOMMITTED\";\n IsolationLevel[\"ReadCommitted\"] = \"READ COMMITTED\";\n IsolationLevel[\"RepeatableRead\"] = \"REPEATABLE READ\";\n IsolationLevel[\"Serializable\"] = \"SERIALIZABLE\";\n})(IsolationLevel || (IsolationLevel = {}));\n","import { registerPlugin } from '@capacitor/core';\nexport const CapgoCapacitorFastSql = registerPlugin('CapgoCapacitorFastSql', {\n web: () => import('./web').then((m) => new m.CapgoCapacitorFastSqlWeb()),\n});\n","import { IsolationLevel } from './definitions';\n/**\n * SQL Connection class that uses HTTP protocol for efficient communication\n * with native SQLite databases, bypassing Capacitor's standard bridge.\n *\n * Inspired by capacitor-blob-writer's approach to avoid serialization overhead.\n */\nexport class SQLConnection {\n constructor(database, port, token) {\n this.inTransaction = false;\n this.database = database;\n this.port = port;\n this.token = token;\n this.baseUrl = `http://localhost:${port}`;\n }\n /**\n * Get the database name\n */\n getDatabaseName() {\n return this.database;\n }\n /**\n * Execute a SQL query via HTTP protocol for optimal performance\n *\n * @param statement - SQL statement to execute\n * @param params - Parameters to bind to the statement\n * @returns Query results\n */\n async execute(statement, params) {\n const response = await fetch(`${this.baseUrl}/execute`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this.token}`,\n 'X-Database': this.database,\n },\n body: JSON.stringify({\n statement,\n params: params ? this.serializeParams(params) : [],\n }),\n });\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`SQL execution failed: ${error}`);\n }\n const result = await response.json();\n return this.deserializeResult(result);\n }\n /**\n * Execute multiple SQL statements in a batch for better performance\n *\n * @param operations - Array of SQL operations to execute\n * @returns Array of results for each operation\n */\n async executeBatch(operations) {\n const response = await fetch(`${this.baseUrl}/batch`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this.token}`,\n 'X-Database': this.database,\n },\n body: JSON.stringify({\n operations: operations.map((op) => ({\n statement: op.statement,\n params: op.params ? this.serializeParams(op.params) : [],\n })),\n }),\n });\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`SQL batch execution failed: ${error}`);\n }\n const results = await response.json();\n return results.map((r) => this.deserializeResult(r));\n }\n /**\n * Begin a transaction\n *\n * @param isolationLevel - Optional isolation level\n */\n async beginTransaction(isolationLevel) {\n if (this.inTransaction) {\n throw new Error('Transaction already in progress');\n }\n const response = await fetch(`${this.baseUrl}/transaction/begin`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this.token}`,\n 'X-Database': this.database,\n },\n body: JSON.stringify({\n isolationLevel: isolationLevel || IsolationLevel.Serializable,\n }),\n });\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`Failed to begin transaction: ${error}`);\n }\n this.inTransaction = true;\n }\n /**\n * Commit the current transaction\n */\n async commit() {\n if (!this.inTransaction) {\n throw new Error('No transaction in progress');\n }\n const response = await fetch(`${this.baseUrl}/transaction/commit`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${this.token}`,\n 'X-Database': this.database,\n },\n });\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`Failed to commit transaction: ${error}`);\n }\n this.inTransaction = false;\n }\n /**\n * Rollback the current transaction\n */\n async rollback() {\n if (!this.inTransaction) {\n throw new Error('No transaction in progress');\n }\n const response = await fetch(`${this.baseUrl}/transaction/rollback`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${this.token}`,\n 'X-Database': this.database,\n },\n });\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`Failed to rollback transaction: ${error}`);\n }\n this.inTransaction = false;\n }\n /**\n * Execute operations within a transaction automatically\n *\n * @param callback - Function containing operations to execute\n * @param isolationLevel - Optional isolation level\n */\n async transaction(callback, isolationLevel) {\n await this.beginTransaction(isolationLevel);\n try {\n const result = await callback(this);\n await this.commit();\n return result;\n }\n catch (error) {\n await this.rollback();\n throw error;\n }\n }\n /**\n * Query helper for SELECT statements\n *\n * @param statement - SELECT statement\n * @param params - Query parameters\n * @returns Array of rows\n */\n async query(statement, params) {\n const result = await this.execute(statement, params);\n return result.rows;\n }\n /**\n * Execute helper for INSERT/UPDATE/DELETE statements\n *\n * @param statement - SQL statement\n * @param params - Statement parameters\n * @returns Number of affected rows and insert ID if applicable\n */\n async run(statement, params) {\n const result = await this.execute(statement, params);\n return {\n rowsAffected: result.rowsAffected,\n insertId: result.insertId,\n };\n }\n /**\n * Serialize parameters for transmission\n * Binary data (Uint8Array) is converted to base64 for JSON transport\n */\n serializeParams(params) {\n return params.map((param) => {\n if (param instanceof Uint8Array) {\n return {\n _type: 'binary',\n _data: this.uint8ArrayToBase64(param),\n };\n }\n return param;\n });\n }\n /**\n * Deserialize result from server\n * Base64-encoded binary data is converted back to Uint8Array\n */\n deserializeResult(result) {\n return {\n rows: result.rows.map((row) => {\n const deserializedRow = {};\n for (const [key, value] of Object.entries(row)) {\n if (value && typeof value === 'object' && value._type === 'binary') {\n deserializedRow[key] = this.base64ToUint8Array(value._data);\n }\n else {\n deserializedRow[key] = value;\n }\n }\n return deserializedRow;\n }),\n rowsAffected: result.rowsAffected || 0,\n insertId: result.insertId,\n };\n }\n /**\n * Convert Uint8Array to base64 string\n */\n uint8ArrayToBase64(bytes) {\n let binary = '';\n for (let i = 0; i < bytes.byteLength; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n }\n /**\n * Convert base64 string to Uint8Array\n */\n base64ToUint8Array(base64) {\n const binary = atob(base64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n }\n}\n","import { CapgoCapacitorFastSql } from './plugin';\nimport { SQLConnection } from './sql-connection';\n/**\n * FastSQL - High-level API for managing SQL connections\n *\n * This class provides a convenient interface for opening/closing database connections\n * and managing multiple databases simultaneously.\n */\nexport class FastSQL {\n /**\n * Open a database connection\n *\n * @param options - Connection options\n * @returns SQLConnection instance for executing queries\n */\n static async connect(options) {\n // Check if already connected\n if (this.connections.has(options.database)) {\n return this.connections.get(options.database);\n }\n // Connect via native plugin\n const info = await CapgoCapacitorFastSql.connect(options);\n // Create connection instance\n const connection = new SQLConnection(info.database, info.port, info.token);\n // Store connection\n this.connections.set(options.database, connection);\n return connection;\n }\n /**\n * Close a database connection\n *\n * @param database - Database name to close\n */\n static async disconnect(database) {\n const connection = this.connections.get(database);\n if (!connection) {\n throw new Error(`Database '${database}' is not connected`);\n }\n // Disconnect via native plugin\n await CapgoCapacitorFastSql.disconnect({ database });\n // Remove connection\n this.connections.delete(database);\n }\n /**\n * Get an existing connection\n *\n * @param database - Database name\n * @returns SQLConnection instance or null if not connected\n */\n static getConnection(database) {\n return this.connections.get(database) || null;\n }\n /**\n * Close all open connections\n */\n static async disconnectAll() {\n const databases = Array.from(this.connections.keys());\n await Promise.all(databases.map((db) => this.disconnect(db)));\n }\n /**\n * Get list of all open database connections\n *\n * @returns Array of database names\n */\n static getOpenDatabases() {\n return Array.from(this.connections.keys());\n }\n}\nFastSQL.connections = new Map();\n","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation using sql.js (SQLite compiled to WebAssembly)\n *\n * This provides a compatible API on the web platform, storing databases\n * in IndexedDB for persistence.\n */\nexport class CapgoCapacitorFastSqlWeb extends WebPlugin {\n constructor() {\n super();\n this.databases = new Map();\n this.sqlPromise = null;\n this.nextPort = 9000;\n this.loadSqlJs();\n }\n /**\n * Load sql.js library\n */\n async loadSqlJs() {\n if (this.sqlPromise)\n return;\n this.sqlPromise = new Promise((resolve, reject) => {\n try {\n // Load sql.js from CDN\n const script = document.createElement('script');\n script.src = 'https://cdnjs.cloudflare.com/ajax/libs/sql.js/1.8.0/sql-wasm.js';\n script.onload = async () => {\n const initSqlJs = window.initSqlJs;\n const SQL = await initSqlJs({\n locateFile: (file) => `https://cdnjs.cloudflare.com/ajax/libs/sql.js/1.8.0/${file}`,\n });\n resolve(SQL);\n };\n script.onerror = reject;\n document.head.appendChild(script);\n }\n catch (error) {\n reject(error);\n }\n });\n }\n async connect(options) {\n const SQL = await this.sqlPromise;\n // Check if database already exists in IndexedDB\n const savedData = await this.loadFromIndexedDB(options.database);\n let db;\n if (savedData) {\n db = new SQL.Database(savedData);\n }\n else {\n db = new SQL.Database();\n }\n const token = this.generateToken();\n const port = this.nextPort++;\n this.databases.set(options.database, { db, token, port });\n return {\n port,\n token,\n database: options.database,\n };\n }\n async disconnect(options) {\n const dbInfo = this.databases.get(options.database);\n if (!dbInfo) {\n throw new Error(`Database '${options.database}' is not connected`);\n }\n // Save to IndexedDB before closing\n const data = dbInfo.db.export();\n await this.saveToIndexedDB(options.database, data);\n dbInfo.db.close();\n this.databases.delete(options.database);\n }\n async getServerInfo(options) {\n const dbInfo = this.databases.get(options.database);\n if (!dbInfo) {\n throw new Error(`Database '${options.database}' is not connected`);\n }\n return {\n port: dbInfo.port,\n token: dbInfo.token,\n };\n }\n async execute(options) {\n const dbInfo = this.databases.get(options.database);\n if (!dbInfo) {\n throw new Error(`Database '${options.database}' is not connected`);\n }\n try {\n const stmt = dbInfo.db.prepare(options.statement);\n if (options.params) {\n stmt.bind(options.params);\n }\n const rows = [];\n while (stmt.step()) {\n const row = stmt.getAsObject();\n rows.push(row);\n }\n stmt.free();\n // Get changes and last insert ID\n const changes = dbInfo.db.getRowsModified();\n const insertId = this.getLastInsertId(dbInfo.db);\n return {\n rows,\n rowsAffected: changes,\n insertId: insertId > 0 ? insertId : undefined,\n };\n }\n catch (error) {\n throw new Error(`SQL execution failed: ${error.message}`);\n }\n }\n async beginTransaction(options) {\n await this.execute({\n database: options.database,\n statement: 'BEGIN TRANSACTION',\n });\n }\n async commitTransaction(options) {\n await this.execute({\n database: options.database,\n statement: 'COMMIT',\n });\n }\n async rollbackTransaction(options) {\n await this.execute({\n database: options.database,\n statement: 'ROLLBACK',\n });\n }\n /**\n * Generate a random authentication token\n */\n generateToken() {\n return Array.from(crypto.getRandomValues(new Uint8Array(32)))\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n }\n /**\n * Get last insert row ID\n */\n getLastInsertId(db) {\n try {\n const result = db.exec('SELECT last_insert_rowid()');\n if (result.length > 0 && result[0].values.length > 0) {\n return result[0].values[0][0];\n }\n }\n catch (_a) {\n // Ignore error\n }\n return -1;\n }\n /**\n * Save database to IndexedDB\n */\n async saveToIndexedDB(dbName, data) {\n return new Promise((resolve, reject) => {\n const request = indexedDB.open('CapacitorNativeSQL', 1);\n request.onerror = () => reject(request.error);\n request.onupgradeneeded = (event) => {\n const db = event.target.result;\n if (!db.objectStoreNames.contains('databases')) {\n db.createObjectStore('databases');\n }\n };\n request.onsuccess = () => {\n const db = request.result;\n const transaction = db.transaction(['databases'], 'readwrite');\n const store = transaction.objectStore('databases');\n const putRequest = store.put(data, dbName);\n putRequest.onsuccess = () => {\n db.close();\n resolve();\n };\n putRequest.onerror = () => {\n db.close();\n reject(putRequest.error);\n };\n };\n });\n }\n /**\n * Load database from IndexedDB\n */\n async loadFromIndexedDB(dbName) {\n return new Promise((resolve, reject) => {\n const request = indexedDB.open('CapacitorNativeSQL', 1);\n request.onerror = () => reject(request.error);\n request.onupgradeneeded = (event) => {\n const db = event.target.result;\n if (!db.objectStoreNames.contains('databases')) {\n db.createObjectStore('databases');\n }\n };\n request.onsuccess = () => {\n const db = request.result;\n const transaction = db.transaction(['databases'], 'readonly');\n const store = transaction.objectStore('databases');\n const getRequest = store.get(dbName);\n getRequest.onsuccess = () => {\n db.close();\n resolve(getRequest.result || null);\n };\n getRequest.onerror = () => {\n db.close();\n reject(getRequest.error);\n };\n };\n });\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n"],"names":["IsolationLevel","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;AACWA;IACX,CAAC,UAAU,cA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CAAC,WAAW,CAAC,EAAE;IAChE,oBAAoB,EAAE,CAAC,iBAAiB,CAAC,WAAW,CAAC;IACrD,gBAAgB;IAChB,YAAY,CAAC;IACb,YAAY,OAAO,CAAC,SAAS,GAAG,MAAM;IACtC,gBAAgB,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM;IACzC,gBAAgB,MAAM,WAAW,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,WAAW,CAAC,EAAE,UAAU,CAAC;IAC7E,gBAAgB,MAAM,KAAK,GAAG,WAAW,CAAC,WAAW,CAAC,WAAW,CAAC;IAClE,gBAAgB,MAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC;IACpD,gBAAgB,UAAU,CAAC,SAAS,GAAG,MAAM;IAC7C,oBAAoB,EAAE,CAAC,KAAK,EAAE;IAC9B,oBAAoB,OAAO,CAAC,UAAU,CAAC,MAAM,IAAI,IAAI,CAAC;IACtD,gBAAgB,CAAC;IACjB,gBAAgB,UAAU,CAAC,OAAO,GAAG,MAAM;IAC3C,oBAAoB,EAAE,CAAC,KAAK,EAAE;IAC9B,oBAAoB,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC;IAC5C,gBAAgB,CAAC;IACjB,YAAY,CAAC;IACb,QAAQ,CAAC,CAAC;IACV,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/plugin.js","esm/sql-connection.js","esm/fast-sql.js","esm/key-value.js","esm/web.js"],"sourcesContent":["/**\n * Transaction isolation levels\n */\nexport var IsolationLevel;\n(function (IsolationLevel) {\n IsolationLevel[\"ReadUncommitted\"] = \"READ UNCOMMITTED\";\n IsolationLevel[\"ReadCommitted\"] = \"READ COMMITTED\";\n IsolationLevel[\"RepeatableRead\"] = \"REPEATABLE READ\";\n IsolationLevel[\"Serializable\"] = \"SERIALIZABLE\";\n})(IsolationLevel || (IsolationLevel = {}));\n","import { registerPlugin } from '@capacitor/core';\nexport const CapgoCapacitorFastSql = registerPlugin('CapgoCapacitorFastSql', {\n web: () => import('./web').then((m) => new m.CapgoCapacitorFastSqlWeb()),\n});\n","import { IsolationLevel } from './definitions';\n/**\n * SQL Connection class that uses HTTP protocol for efficient communication\n * with native SQLite databases, bypassing Capacitor's standard bridge.\n *\n * Inspired by capacitor-blob-writer's approach to avoid serialization overhead.\n */\nexport class SQLConnection {\n constructor(database, port, token) {\n this.inTransaction = false;\n this.database = database;\n this.port = port;\n this.token = token;\n this.baseUrl = `http://localhost:${port}`;\n }\n /**\n * Get the database name\n */\n getDatabaseName() {\n return this.database;\n }\n /**\n * Execute a SQL query via HTTP protocol for optimal performance\n *\n * @param statement - SQL statement to execute\n * @param params - Parameters to bind to the statement\n * @returns Query results\n */\n async execute(statement, params) {\n const response = await fetch(`${this.baseUrl}/execute`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this.token}`,\n 'X-Database': this.database,\n },\n body: JSON.stringify({\n statement,\n params: params ? this.serializeParams(params) : [],\n }),\n });\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`SQL execution failed: ${error}`);\n }\n const result = await response.json();\n return this.deserializeResult(result);\n }\n /**\n * Execute multiple SQL statements in a batch for better performance\n *\n * @param operations - Array of SQL operations to execute\n * @returns Array of results for each operation\n */\n async executeBatch(operations) {\n const response = await fetch(`${this.baseUrl}/batch`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this.token}`,\n 'X-Database': this.database,\n },\n body: JSON.stringify({\n operations: operations.map((op) => ({\n statement: op.statement,\n params: op.params ? this.serializeParams(op.params) : [],\n })),\n }),\n });\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`SQL batch execution failed: ${error}`);\n }\n const results = await response.json();\n return results.map((r) => this.deserializeResult(r));\n }\n /**\n * Begin a transaction\n *\n * @param isolationLevel - Optional isolation level\n */\n async beginTransaction(isolationLevel) {\n if (this.inTransaction) {\n throw new Error('Transaction already in progress');\n }\n const response = await fetch(`${this.baseUrl}/transaction/begin`, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this.token}`,\n 'X-Database': this.database,\n },\n body: JSON.stringify({\n isolationLevel: isolationLevel || IsolationLevel.Serializable,\n }),\n });\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`Failed to begin transaction: ${error}`);\n }\n this.inTransaction = true;\n }\n /**\n * Commit the current transaction\n */\n async commit() {\n if (!this.inTransaction) {\n throw new Error('No transaction in progress');\n }\n const response = await fetch(`${this.baseUrl}/transaction/commit`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${this.token}`,\n 'X-Database': this.database,\n },\n });\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`Failed to commit transaction: ${error}`);\n }\n this.inTransaction = false;\n }\n /**\n * Rollback the current transaction\n */\n async rollback() {\n if (!this.inTransaction) {\n throw new Error('No transaction in progress');\n }\n const response = await fetch(`${this.baseUrl}/transaction/rollback`, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${this.token}`,\n 'X-Database': this.database,\n },\n });\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`Failed to rollback transaction: ${error}`);\n }\n this.inTransaction = false;\n }\n /**\n * Execute operations within a transaction automatically\n *\n * @param callback - Function containing operations to execute\n * @param isolationLevel - Optional isolation level\n */\n async transaction(callback, isolationLevel) {\n await this.beginTransaction(isolationLevel);\n try {\n const result = await callback(this);\n await this.commit();\n return result;\n }\n catch (error) {\n await this.rollback();\n throw error;\n }\n }\n /**\n * Query helper for SELECT statements\n *\n * @param statement - SELECT statement\n * @param params - Query parameters\n * @returns Array of rows\n */\n async query(statement, params) {\n const result = await this.execute(statement, params);\n return result.rows;\n }\n /**\n * Execute helper for INSERT/UPDATE/DELETE statements\n *\n * @param statement - SQL statement\n * @param params - Statement parameters\n * @returns Number of affected rows and insert ID if applicable\n */\n async run(statement, params) {\n const result = await this.execute(statement, params);\n return {\n rowsAffected: result.rowsAffected,\n insertId: result.insertId,\n };\n }\n /**\n * Serialize parameters for transmission\n * Binary data (Uint8Array) is converted to base64 for JSON transport\n */\n serializeParams(params) {\n return params.map((param) => {\n if (param instanceof Uint8Array) {\n return {\n _type: 'binary',\n _data: this.uint8ArrayToBase64(param),\n };\n }\n return param;\n });\n }\n /**\n * Deserialize result from server\n * Base64-encoded binary data is converted back to Uint8Array\n */\n deserializeResult(result) {\n return {\n rows: result.rows.map((row) => {\n const deserializedRow = {};\n for (const [key, value] of Object.entries(row)) {\n if (value && typeof value === 'object' && value._type === 'binary') {\n deserializedRow[key] = this.base64ToUint8Array(value._data);\n }\n else {\n deserializedRow[key] = value;\n }\n }\n return deserializedRow;\n }),\n rowsAffected: result.rowsAffected || 0,\n insertId: result.insertId,\n };\n }\n /**\n * Convert Uint8Array to base64 string\n */\n uint8ArrayToBase64(bytes) {\n let binary = '';\n for (let i = 0; i < bytes.byteLength; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n }\n /**\n * Convert base64 string to Uint8Array\n */\n base64ToUint8Array(base64) {\n const binary = atob(base64);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) {\n bytes[i] = binary.charCodeAt(i);\n }\n return bytes;\n }\n}\n","import { CapgoCapacitorFastSql } from './plugin';\nimport { SQLConnection } from './sql-connection';\n/**\n * FastSQL - High-level API for managing SQL connections\n *\n * This class provides a convenient interface for opening/closing database connections\n * and managing multiple databases simultaneously.\n */\nexport class FastSQL {\n /**\n * Open a database connection\n *\n * @param options - Connection options\n * @returns SQLConnection instance for executing queries\n */\n static async connect(options) {\n // Check if already connected\n const existing = this.connections.get(options.database);\n if (existing) {\n return existing;\n }\n // Connect via native plugin\n const info = await CapgoCapacitorFastSql.connect(options);\n // Create connection instance\n const connection = new SQLConnection(info.database, info.port, info.token);\n // Store connection\n this.connections.set(options.database, connection);\n return connection;\n }\n /**\n * Close a database connection\n *\n * @param database - Database name to close\n */\n static async disconnect(database) {\n const connection = this.connections.get(database);\n if (!connection) {\n throw new Error(`Database '${database}' is not connected`);\n }\n // Disconnect via native plugin\n await CapgoCapacitorFastSql.disconnect({ database });\n // Remove connection\n this.connections.delete(database);\n }\n /**\n * Get an existing connection\n *\n * @param database - Database name\n * @returns SQLConnection instance or null if not connected\n */\n static getConnection(database) {\n return this.connections.get(database) || null;\n }\n /**\n * Close all open connections\n */\n static async disconnectAll() {\n const databases = Array.from(this.connections.keys());\n await Promise.all(databases.map((db) => this.disconnect(db)));\n }\n /**\n * Get list of all open database connections\n *\n * @returns Array of database names\n */\n static getOpenDatabases() {\n return Array.from(this.connections.keys());\n }\n}\nFastSQL.connections = new Map();\n","import { FastSQL } from './fast-sql';\n/**\n * Key-value storage backed by the FastSQL database connection.\n *\n * This is a lightweight wrapper for mobile-focused secure storage use cases.\n */\nexport class KeyValueStore {\n constructor(connection, store) {\n this.initialized = false;\n this.ownsConnection = false;\n this.closed = false;\n this.connection = connection;\n this.store = store;\n }\n /**\n * Open (or create) a key-value store for the given database.\n */\n static async open(options) {\n var _a;\n const connection = await FastSQL.connect(options);\n const store = (_a = options.store) !== null && _a !== void 0 ? _a : 'default';\n const kv = new KeyValueStore(connection, store);\n kv.ownsConnection = true;\n await kv.ensureSchema();\n return kv;\n }\n /**\n * Create a key-value store from an existing SQLConnection.\n * Note: The caller retains ownership and is responsible for closing the connection.\n */\n static async fromConnection(connection, store = 'default') {\n const kv = new KeyValueStore(connection, store);\n await kv.ensureSchema();\n return kv;\n }\n /**\n * Close the key-value store and release resources.\n * Only disconnects the database if this store owns the connection (created via open()).\n */\n async close() {\n if (this.closed) {\n return;\n }\n this.closed = true;\n if (this.ownsConnection) {\n try {\n await FastSQL.disconnect(this.connection.getDatabaseName());\n }\n catch (_a) {\n // Ignore disconnect errors during close.\n }\n }\n this.initialized = false;\n }\n /**\n * Store a value by key.\n */\n async set(key, value) {\n await this.ensureSchema();\n const encoded = this.encodeValue(value);\n await this.connection.run('INSERT OR REPLACE INTO __kv_store (s, k, t, v) VALUES (?, ?, ?, ?)', [\n this.store,\n key,\n encoded.type,\n encoded.value,\n ]);\n }\n /**\n * Retrieve a value by key. Returns null if the key is missing.\n */\n async get(key) {\n await this.ensureSchema();\n const rows = await this.connection.query('SELECT t, v FROM __kv_store WHERE s = ? AND k = ? LIMIT 1', [\n this.store,\n key,\n ]);\n if (!rows.length) {\n return null;\n }\n const row = rows[0];\n const type = row.t;\n const value = row.v;\n return this.decodeValue(type, value);\n }\n /**\n * Check if a key exists.\n */\n async has(key) {\n await this.ensureSchema();\n const rows = await this.connection.query('SELECT 1 as existsFlag FROM __kv_store WHERE s = ? AND k = ? LIMIT 1', [\n this.store,\n key,\n ]);\n return rows.length > 0;\n }\n /**\n * Remove a single key.\n */\n async remove(key) {\n await this.ensureSchema();\n await this.connection.run('DELETE FROM __kv_store WHERE s = ? AND k = ?', [this.store, key]);\n }\n /**\n * Clear all keys for the current store.\n */\n async clear() {\n await this.ensureSchema();\n await this.connection.run('DELETE FROM __kv_store WHERE s = ?', [this.store]);\n }\n /**\n * List all keys for the current store.\n */\n async keys() {\n await this.ensureSchema();\n const rows = await this.connection.query('SELECT k FROM __kv_store WHERE s = ? ORDER BY k', [this.store]);\n return rows.map((row) => String(row.k));\n }\n async ensureSchema() {\n if (this.initialized) {\n return;\n }\n await this.connection.run('CREATE TABLE IF NOT EXISTS __kv_store (s TEXT NOT NULL, k TEXT NOT NULL, t TEXT NOT NULL, v BLOB, PRIMARY KEY (s, k))');\n await this.connection.run('CREATE INDEX IF NOT EXISTS __kv_store_s_idx ON __kv_store (s)');\n this.initialized = true;\n }\n encodeValue(value) {\n if (value === null || value === undefined) {\n return { type: 'null', value: null };\n }\n if (value instanceof Uint8Array) {\n return { type: 'binary', value };\n }\n if (typeof value === 'string') {\n return { type: 'string', value };\n }\n if (typeof value === 'number') {\n return { type: 'number', value };\n }\n if (typeof value === 'boolean') {\n return { type: 'boolean', value: value ? 1 : 0 };\n }\n return { type: 'json', value: JSON.stringify(value) };\n }\n decodeValue(type, value) {\n switch (type) {\n case 'null':\n return null;\n case 'binary':\n return value instanceof Uint8Array ? value : null;\n case 'string':\n return value != null ? String(value) : '';\n case 'number':\n if (typeof value === 'number') {\n return value;\n }\n if (typeof value === 'string') {\n const parsed = Number(value);\n return Number.isNaN(parsed) ? 0 : parsed;\n }\n return 0;\n case 'boolean':\n if (typeof value === 'number') {\n return value !== 0;\n }\n if (typeof value === 'string') {\n return value === '1' || value.toLowerCase() === 'true';\n }\n return Boolean(value);\n case 'json':\n if (typeof value === 'string') {\n try {\n return JSON.parse(value);\n }\n catch (_a) {\n return null;\n }\n }\n return null;\n default:\n return value;\n }\n }\n}\n","import { WebPlugin } from '@capacitor/core';\n/**\n * Web implementation using sql.js (SQLite compiled to WebAssembly)\n *\n * This provides a compatible API on the web platform, storing databases\n * in IndexedDB for persistence.\n */\nexport class CapgoCapacitorFastSqlWeb extends WebPlugin {\n constructor() {\n super();\n this.databases = new Map();\n this.sqlPromise = null;\n this.nextPort = 9000;\n this.loadSqlJs();\n }\n /**\n * Load sql.js library\n */\n async loadSqlJs() {\n if (this.sqlPromise)\n return;\n this.sqlPromise = new Promise((resolve, reject) => {\n try {\n // Load sql.js from CDN\n const script = document.createElement('script');\n script.src = 'https://cdnjs.cloudflare.com/ajax/libs/sql.js/1.8.0/sql-wasm.js';\n script.onload = async () => {\n const initSqlJs = window.initSqlJs;\n const SQL = await initSqlJs({\n locateFile: (file) => `https://cdnjs.cloudflare.com/ajax/libs/sql.js/1.8.0/${file}`,\n });\n resolve(SQL);\n };\n script.onerror = reject;\n document.head.appendChild(script);\n }\n catch (error) {\n reject(error);\n }\n });\n }\n async connect(options) {\n const SQL = await this.sqlPromise;\n // Check if database already exists in IndexedDB\n const savedData = await this.loadFromIndexedDB(options.database);\n let db;\n if (savedData) {\n db = new SQL.Database(savedData);\n }\n else {\n db = new SQL.Database();\n }\n const token = this.generateToken();\n const port = this.nextPort++;\n this.databases.set(options.database, { db, token, port });\n return {\n port,\n token,\n database: options.database,\n };\n }\n async disconnect(options) {\n const dbInfo = this.databases.get(options.database);\n if (!dbInfo) {\n throw new Error(`Database '${options.database}' is not connected`);\n }\n // Save to IndexedDB before closing\n const data = dbInfo.db.export();\n await this.saveToIndexedDB(options.database, data);\n dbInfo.db.close();\n this.databases.delete(options.database);\n }\n async getServerInfo(options) {\n const dbInfo = this.databases.get(options.database);\n if (!dbInfo) {\n throw new Error(`Database '${options.database}' is not connected`);\n }\n return {\n port: dbInfo.port,\n token: dbInfo.token,\n };\n }\n async execute(options) {\n const dbInfo = this.databases.get(options.database);\n if (!dbInfo) {\n throw new Error(`Database '${options.database}' is not connected`);\n }\n try {\n const stmt = dbInfo.db.prepare(options.statement);\n if (options.params) {\n stmt.bind(options.params);\n }\n const rows = [];\n while (stmt.step()) {\n const row = stmt.getAsObject();\n rows.push(row);\n }\n stmt.free();\n // Get changes and last insert ID\n const changes = dbInfo.db.getRowsModified();\n const insertId = this.getLastInsertId(dbInfo.db);\n return {\n rows,\n rowsAffected: changes,\n insertId: insertId > 0 ? insertId : undefined,\n };\n }\n catch (error) {\n throw new Error(`SQL execution failed: ${error.message}`);\n }\n }\n async beginTransaction(options) {\n await this.execute({\n database: options.database,\n statement: 'BEGIN TRANSACTION',\n });\n }\n async commitTransaction(options) {\n await this.execute({\n database: options.database,\n statement: 'COMMIT',\n });\n }\n async rollbackTransaction(options) {\n await this.execute({\n database: options.database,\n statement: 'ROLLBACK',\n });\n }\n /**\n * Generate a random authentication token\n */\n generateToken() {\n return Array.from(crypto.getRandomValues(new Uint8Array(32)))\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n }\n /**\n * Get last insert row ID\n */\n getLastInsertId(db) {\n try {\n const result = db.exec('SELECT last_insert_rowid()');\n if (result.length > 0 && result[0].values.length > 0) {\n return result[0].values[0][0];\n }\n }\n catch (_a) {\n // Ignore error\n }\n return -1;\n }\n /**\n * Save database to IndexedDB\n */\n async saveToIndexedDB(dbName, data) {\n return new Promise((resolve, reject) => {\n const request = indexedDB.open('CapacitorNativeSQL', 1);\n request.onerror = () => reject(request.error);\n request.onupgradeneeded = (event) => {\n const db = event.target.result;\n if (!db.objectStoreNames.contains('databases')) {\n db.createObjectStore('databases');\n }\n };\n request.onsuccess = () => {\n const db = request.result;\n const transaction = db.transaction(['databases'], 'readwrite');\n const store = transaction.objectStore('databases');\n const putRequest = store.put(data, dbName);\n putRequest.onsuccess = () => {\n db.close();\n resolve();\n };\n putRequest.onerror = () => {\n db.close();\n reject(putRequest.error);\n };\n };\n });\n }\n /**\n * Load database from IndexedDB\n */\n async loadFromIndexedDB(dbName) {\n return new Promise((resolve, reject) => {\n const request = indexedDB.open('CapacitorNativeSQL', 1);\n request.onerror = () => reject(request.error);\n request.onupgradeneeded = (event) => {\n const db = event.target.result;\n if (!db.objectStoreNames.contains('databases')) {\n db.createObjectStore('databases');\n }\n };\n request.onsuccess = () => {\n const db = request.result;\n const transaction = db.transaction(['databases'], 'readonly');\n const store = transaction.objectStore('databases');\n const getRequest = store.get(dbName);\n getRequest.onsuccess = () => {\n db.close();\n resolve(getRequest.result || null);\n };\n getRequest.onerror = () => {\n db.close();\n reject(getRequest.error);\n };\n };\n });\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n}\n"],"names":["IsolationLevel","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;AACWA;IACX,CAAC,UAAU,cAAc,EAAE;IAC3B,IAAI,cAAc,CAAC,iBAAiB,CAAC,GAAG,kBAAkB;IAC1D,IAAI,cAAc,CAAC,eAAe,CAAC,GAAG,gBAAgB;IACtD,IAAI,cAAc,CAAC,gBAAgB,CAAC,GAAG,iBAAiB;IACxD,IAAI,cAAc,CAAC,cAAc,CAAC,GAAG,cAAc;IACnD,CAAC,EAAEA,sBAAc,KAAKA,sBAAc,GAAG,EAAE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pD,gBAAgB,UAAU,CAAC,SAAS,GAAG,MAAM;IAC7C,oBAAoB,EAAE,CAAC,KAAK,EAAE;IAC9B,oBAAoB,OAAO,CAAC,UAAU,CAAC,MAAM,IAAI,IAAI,CAAC;IACtD,gBAAgB,CAAC;IACjB,gBAAgB,UAAU,CAAC,OAAO,GAAG,MAAM;IAC3C,oBAAoB,EAAE,CAAC,KAAK,EAAE;IAC9B,oBAAoB,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC;IAC5C,gBAAgB,CAAC;IACjB,YAAY,CAAC;IACb,QAAQ,CAAC,CAAC;IACV,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ;;;;;;;;;;;;;;;;;;"}
|
|
@@ -10,7 +10,7 @@ import SQLite3
|
|
|
10
10
|
*/
|
|
11
11
|
@objc(CapgoCapacitorFastSqlPlugin)
|
|
12
12
|
public class CapgoCapacitorFastSqlPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
13
|
-
private let pluginVersion: String = "8.0.
|
|
13
|
+
private let pluginVersion: String = "8.0.13"
|
|
14
14
|
public let identifier = "CapgoCapacitorFastSqlPlugin"
|
|
15
15
|
public let jsName = "CapgoCapacitorFastSql"
|
|
16
16
|
public let pluginMethods: [CAPPluginMethod] = [
|
|
@@ -33,6 +33,13 @@ public class CapgoCapacitorFastSqlPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
33
33
|
return
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
let encrypted = call.getBool("encrypted") ?? false
|
|
37
|
+
let encryptionKey = call.getString("encryptionKey")
|
|
38
|
+
if encrypted && (encryptionKey == nil || encryptionKey?.isEmpty == true) {
|
|
39
|
+
call.reject("Encryption key is required when encryption is enabled")
|
|
40
|
+
return
|
|
41
|
+
}
|
|
42
|
+
|
|
36
43
|
// Check if already connected
|
|
37
44
|
if databases[database] != nil {
|
|
38
45
|
if let server = server {
|
|
@@ -50,7 +57,7 @@ public class CapgoCapacitorFastSqlPlugin: CAPPlugin, CAPBridgedPlugin {
|
|
|
50
57
|
let dbPath = try getDatabasePath(database)
|
|
51
58
|
|
|
52
59
|
// Open database
|
|
53
|
-
let db = try SQLDatabase(path: dbPath)
|
|
60
|
+
let db = try SQLDatabase(path: dbPath, encrypted: encrypted, encryptionKey: encryptionKey)
|
|
54
61
|
databases[database] = db
|
|
55
62
|
|
|
56
63
|
// Start HTTP server if not already running
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import Foundation
|
|
2
2
|
import Capacitor
|
|
3
|
+
#if canImport(SQLCipher)
|
|
4
|
+
import SQLCipher
|
|
5
|
+
#else
|
|
3
6
|
import SQLite3
|
|
7
|
+
#endif
|
|
4
8
|
|
|
5
9
|
// SQLite constants that aren't imported to Swift
|
|
6
10
|
private let SQLITE_STATIC = unsafeBitCast(0, to: sqlite3_destructor_type.self)
|
|
@@ -14,7 +18,7 @@ class SQLDatabase {
|
|
|
14
18
|
private let path: String
|
|
15
19
|
private var inTransaction = false
|
|
16
20
|
|
|
17
|
-
init(path: String) throws {
|
|
21
|
+
init(path: String, encrypted: Bool = false, encryptionKey: String? = nil) throws {
|
|
18
22
|
self.path = path
|
|
19
23
|
|
|
20
24
|
let flags = SQLITE_OPEN_CREATE | SQLITE_OPEN_READWRITE | SQLITE_OPEN_FULLMUTEX
|
|
@@ -24,8 +28,41 @@ class SQLDatabase {
|
|
|
24
28
|
throw SQLError.openFailed(message: String(cString: sqlite3_errmsg(db)))
|
|
25
29
|
}
|
|
26
30
|
|
|
31
|
+
guard let db = db else {
|
|
32
|
+
throw SQLError.openFailed(message: "Failed to open database")
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var needsClose = true
|
|
36
|
+
defer {
|
|
37
|
+
if needsClose {
|
|
38
|
+
sqlite3_close(db)
|
|
39
|
+
self.db = nil
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if encrypted {
|
|
44
|
+
guard let key = encryptionKey, !key.isEmpty else {
|
|
45
|
+
throw SQLError.encryptionKeyMissing
|
|
46
|
+
}
|
|
47
|
+
#if canImport(SQLCipher)
|
|
48
|
+
guard let keyData = key.data(using: .utf8) else {
|
|
49
|
+
throw SQLError.encryptionFailed(message: "Invalid encryption key encoding")
|
|
50
|
+
}
|
|
51
|
+
let keyResult = keyData.withUnsafeBytes { bytes in
|
|
52
|
+
sqlite3_key(db, bytes.baseAddress, Int32(keyData.count))
|
|
53
|
+
}
|
|
54
|
+
if keyResult != SQLITE_OK {
|
|
55
|
+
let error = String(cString: sqlite3_errmsg(db))
|
|
56
|
+
throw SQLError.encryptionFailed(message: error)
|
|
57
|
+
}
|
|
58
|
+
#else
|
|
59
|
+
throw SQLError.encryptionUnavailable
|
|
60
|
+
#endif
|
|
61
|
+
}
|
|
62
|
+
|
|
27
63
|
// Enable foreign keys
|
|
28
64
|
try execute(statement: "PRAGMA foreign_keys = ON", params: [])
|
|
65
|
+
needsClose = false
|
|
29
66
|
}
|
|
30
67
|
|
|
31
68
|
func close() {
|
|
@@ -210,6 +247,36 @@ enum SQLError: Error {
|
|
|
210
247
|
case prepareFailed(message: String)
|
|
211
248
|
case bindFailed(message: String)
|
|
212
249
|
case executeFailed(message: String)
|
|
250
|
+
case encryptionKeyMissing
|
|
251
|
+
case encryptionUnavailable
|
|
252
|
+
case encryptionFailed(message: String)
|
|
213
253
|
case transactionAlreadyActive
|
|
214
254
|
case noTransactionActive
|
|
215
255
|
}
|
|
256
|
+
|
|
257
|
+
extension SQLError: LocalizedError {
|
|
258
|
+
var errorDescription: String? {
|
|
259
|
+
switch self {
|
|
260
|
+
case .notOpen:
|
|
261
|
+
return "Database is not open"
|
|
262
|
+
case .openFailed(let message):
|
|
263
|
+
return "Failed to open database: \(message)"
|
|
264
|
+
case .prepareFailed(let message):
|
|
265
|
+
return "Failed to prepare statement: \(message)"
|
|
266
|
+
case .bindFailed(let message):
|
|
267
|
+
return "Failed to bind parameter: \(message)"
|
|
268
|
+
case .executeFailed(let message):
|
|
269
|
+
return "Failed to execute statement: \(message)"
|
|
270
|
+
case .encryptionKeyMissing:
|
|
271
|
+
return "Encryption key is required when encryption is enabled"
|
|
272
|
+
case .encryptionUnavailable:
|
|
273
|
+
return "Encryption is not available in this build"
|
|
274
|
+
case .encryptionFailed(let message):
|
|
275
|
+
return "Failed to set encryption key: \(message)"
|
|
276
|
+
case .transactionAlreadyActive:
|
|
277
|
+
return "Transaction already active"
|
|
278
|
+
case .noTransactionActive:
|
|
279
|
+
return "No transaction active"
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/capacitor-fast-sql",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.13",
|
|
4
4
|
"description": "High-performance native SQLite plugin with custom protocol for efficient sync operations and IndexedDB replacement",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|