@capacitor-community/sqlite 6.0.0-beta.2 → 6.0.1-dev.094dcaf.1724913257
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 +66 -90
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +2 -1
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ImportFromJson.java +63 -57
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsDownloadFromHTTP.java +13 -12
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.js.map +1 -1
- package/electron/dist/plugin.js +5 -9
- package/electron/dist/plugin.js.map +1 -1
- package/ios/Plugin/Utils/UtilsDownloadFromHTTP.swift +9 -7
- package/ios/Plugin/Utils/UtilsFile.swift +8 -5
- package/package.json +1 -1
- package/src/definitions.ts +5 -7
- package/src/web.ts +39 -42
|
@@ -158,14 +158,17 @@ class UtilsDownloadFromHTTP {
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
class func extractDBFiles(from zipFile: URL, completion: @escaping ([URL], Error?) -> Void) {
|
|
161
|
-
DispatchQueue.global().async {
|
|
161
|
+
DispatchQueue.global().async(execute: {
|
|
162
162
|
var dbFiles: [URL] = []
|
|
163
163
|
|
|
164
164
|
do {
|
|
165
165
|
let destinationURL = zipFile.deletingLastPathComponent()
|
|
166
166
|
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
guard let archive = Archive(url: zipFile, accessMode: .read) else {
|
|
168
|
+
let msg = "Failed in reading Archive"
|
|
169
|
+
completion([], UtilsDownloadError.invalidArchive(message: msg))
|
|
170
|
+
return
|
|
171
|
+
}
|
|
169
172
|
|
|
170
173
|
for entry in archive where entry.type == .file {
|
|
171
174
|
let fileURL = destinationURL.appendingPathComponent(entry.path)
|
|
@@ -176,15 +179,14 @@ class UtilsDownloadFromHTTP {
|
|
|
176
179
|
dbFiles.append(fileURL)
|
|
177
180
|
}
|
|
178
181
|
}
|
|
179
|
-
|
|
180
182
|
// Delete the zip file
|
|
181
183
|
try FileManager.default.removeItem(at: zipFile)
|
|
182
184
|
|
|
183
185
|
completion(dbFiles, nil)
|
|
184
186
|
} catch {
|
|
185
|
-
|
|
186
|
-
completion([], UtilsDownloadError.invalidArchive(message: msg))
|
|
187
|
+
completion([], error)
|
|
187
188
|
}
|
|
188
|
-
}
|
|
189
|
+
})
|
|
190
|
+
|
|
189
191
|
}
|
|
190
192
|
}
|
|
@@ -421,13 +421,15 @@ class UtilsFile {
|
|
|
421
421
|
|
|
422
422
|
}
|
|
423
423
|
|
|
424
|
-
class func unzipToDatabase(fromURL: URL, databaseLocation: String, zip: String,
|
|
424
|
+
class func unzipToDatabase(fromURL: URL, databaseLocation: String, zip: String,
|
|
425
|
+
overwrite: Bool) throws {
|
|
425
426
|
do {
|
|
426
427
|
let zipAsset: URL = fromURL.appendingPathComponent(zip)
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
428
|
+
guard let archive = Archive(url: zipAsset, accessMode: .read) else {
|
|
429
|
+
let msg = "Error: Read Archive: \(zipAsset) failed"
|
|
430
|
+
print("\(msg)")
|
|
431
|
+
throw UtilsFileError.unzipToDatabaseFailed(message: msg)
|
|
432
|
+
}
|
|
431
433
|
let uDb: URL = try getFolderURL(folderPath: databaseLocation)
|
|
432
434
|
for entry in archive {
|
|
433
435
|
let dbEntry = setPathSuffix(sDb: entry.path)
|
|
@@ -440,6 +442,7 @@ class UtilsFile {
|
|
|
440
442
|
}
|
|
441
443
|
_ = try archive.extract(entry, to: zipCopy)
|
|
442
444
|
}
|
|
445
|
+
|
|
443
446
|
} catch {
|
|
444
447
|
let msg = "Error: Extracting \(entry.path) from archive failed \(error.localizedDescription)"
|
|
445
448
|
print("\(msg)")
|
package/package.json
CHANGED
package/src/definitions.ts
CHANGED
|
@@ -1137,13 +1137,13 @@ export interface ISQLiteConnection {
|
|
|
1137
1137
|
/**
|
|
1138
1138
|
* Add the upgrade Statement for database version upgrading
|
|
1139
1139
|
* @param database
|
|
1140
|
-
* @param upgrade @since 5.6.4
|
|
1140
|
+
* @param upgrade @since 5.6.4
|
|
1141
1141
|
* @returns Promise<void>
|
|
1142
1142
|
* @since 2.9.0 refactor
|
|
1143
1143
|
*/
|
|
1144
1144
|
addUpgradeStatement(
|
|
1145
1145
|
database: string,
|
|
1146
|
-
upgrade: capSQLiteVersionUpgrade[]
|
|
1146
|
+
upgrade: capSQLiteVersionUpgrade[],
|
|
1147
1147
|
): Promise<void>;
|
|
1148
1148
|
/**
|
|
1149
1149
|
* Create a connection to a database
|
|
@@ -1457,7 +1457,7 @@ export class SQLiteConnection implements ISQLiteConnection {
|
|
|
1457
1457
|
}
|
|
1458
1458
|
async addUpgradeStatement(
|
|
1459
1459
|
database: string,
|
|
1460
|
-
upgrade: capSQLiteVersionUpgrade[]
|
|
1460
|
+
upgrade: capSQLiteVersionUpgrade[],
|
|
1461
1461
|
): Promise<void> {
|
|
1462
1462
|
try {
|
|
1463
1463
|
if (database.endsWith('.db')) database = database.slice(0, -3);
|
|
@@ -2408,13 +2408,11 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
2408
2408
|
database: this.dbName,
|
|
2409
2409
|
});
|
|
2410
2410
|
if (!isActive) {
|
|
2411
|
-
return Promise.reject(
|
|
2412
|
-
'After Begin Transaction, no transaction active',
|
|
2413
|
-
);
|
|
2411
|
+
return Promise.reject('After Begin Transaction, no transaction active');
|
|
2414
2412
|
}
|
|
2415
2413
|
try {
|
|
2416
2414
|
for (const task of txn) {
|
|
2417
|
-
if(typeof task !== 'object' || !('statement' in task)) {
|
|
2415
|
+
if (typeof task !== 'object' || !('statement' in task)) {
|
|
2418
2416
|
throw new Error('Error a task.statement must be provided');
|
|
2419
2417
|
}
|
|
2420
2418
|
if ('values' in task && task.values && task.values.length > 0) {
|
package/src/web.ts
CHANGED
|
@@ -45,47 +45,47 @@ export class CapacitorSQLiteWeb
|
|
|
45
45
|
private isWebStoreOpen = false;
|
|
46
46
|
|
|
47
47
|
async initWebStore(): Promise<void> {
|
|
48
|
-
|
|
48
|
+
await customElements.whenDefined('jeep-sqlite');
|
|
49
|
+
|
|
50
|
+
this.jeepSqliteElement = document.querySelector('jeep-sqlite');
|
|
51
|
+
this.ensureJeepSqliteIsAvailable();
|
|
52
|
+
|
|
53
|
+
this.jeepSqliteElement.addEventListener(
|
|
54
|
+
'jeepSqliteImportProgress',
|
|
55
|
+
(event: CustomEvent) => {
|
|
56
|
+
this.notifyListeners('sqliteImportProgressEvent', event.detail);
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
this.jeepSqliteElement.addEventListener(
|
|
60
|
+
'jeepSqliteExportProgress',
|
|
61
|
+
(event: CustomEvent) => {
|
|
62
|
+
this.notifyListeners('sqliteExportProgressEvent', event.detail);
|
|
63
|
+
},
|
|
64
|
+
);
|
|
65
|
+
this.jeepSqliteElement.addEventListener(
|
|
66
|
+
'jeepSqliteHTTPRequestEnded',
|
|
67
|
+
(event: CustomEvent) => {
|
|
68
|
+
this.notifyListeners('sqliteHTTPRequestEndedEvent', event.detail);
|
|
69
|
+
},
|
|
70
|
+
);
|
|
71
|
+
this.jeepSqliteElement.addEventListener(
|
|
72
|
+
'jeepSqlitePickDatabaseEnded',
|
|
73
|
+
(event: CustomEvent) => {
|
|
74
|
+
this.notifyListeners('sqlitePickDatabaseEndedEvent', event.detail);
|
|
75
|
+
},
|
|
76
|
+
);
|
|
77
|
+
this.jeepSqliteElement.addEventListener(
|
|
78
|
+
'jeepSqliteSaveDatabaseToDisk',
|
|
79
|
+
(event: CustomEvent) => {
|
|
80
|
+
this.notifyListeners('sqliteSaveDatabaseToDiskEvent', event.detail);
|
|
81
|
+
},
|
|
82
|
+
);
|
|
49
83
|
|
|
50
|
-
|
|
51
|
-
this.
|
|
52
|
-
|
|
53
|
-
this.jeepSqliteElement.addEventListener(
|
|
54
|
-
'jeepSqliteImportProgress',
|
|
55
|
-
(event: CustomEvent) => {
|
|
56
|
-
this.notifyListeners('sqliteImportProgressEvent', event.detail);
|
|
57
|
-
},
|
|
58
|
-
);
|
|
59
|
-
this.jeepSqliteElement.addEventListener(
|
|
60
|
-
'jeepSqliteExportProgress',
|
|
61
|
-
(event: CustomEvent) => {
|
|
62
|
-
this.notifyListeners('sqliteExportProgressEvent', event.detail);
|
|
63
|
-
},
|
|
64
|
-
);
|
|
65
|
-
this.jeepSqliteElement.addEventListener(
|
|
66
|
-
'jeepSqliteHTTPRequestEnded',
|
|
67
|
-
(event: CustomEvent) => {
|
|
68
|
-
this.notifyListeners('sqliteHTTPRequestEndedEvent', event.detail);
|
|
69
|
-
},
|
|
70
|
-
);
|
|
71
|
-
this.jeepSqliteElement.addEventListener(
|
|
72
|
-
'jeepSqlitePickDatabaseEnded',
|
|
73
|
-
(event: CustomEvent) => {
|
|
74
|
-
this.notifyListeners('sqlitePickDatabaseEndedEvent', event.detail);
|
|
75
|
-
},
|
|
76
|
-
);
|
|
77
|
-
this.jeepSqliteElement.addEventListener(
|
|
78
|
-
'jeepSqliteSaveDatabaseToDisk',
|
|
79
|
-
(event: CustomEvent) => {
|
|
80
|
-
this.notifyListeners('sqliteSaveDatabaseToDiskEvent', event.detail);
|
|
81
|
-
},
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
if (!this.isWebStoreOpen) {
|
|
85
|
-
this.isWebStoreOpen = await this.jeepSqliteElement.isStoreOpen();
|
|
86
|
-
}
|
|
84
|
+
if (!this.isWebStoreOpen) {
|
|
85
|
+
this.isWebStoreOpen = await this.jeepSqliteElement.isStoreOpen();
|
|
86
|
+
}
|
|
87
87
|
|
|
88
|
-
|
|
88
|
+
return;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
async saveToStore(options: capSQLiteOptions): Promise<void> {
|
|
@@ -204,7 +204,6 @@ export class CapacitorSQLiteWeb
|
|
|
204
204
|
} catch (err) {
|
|
205
205
|
throw new Error(`${err}`);
|
|
206
206
|
}
|
|
207
|
-
|
|
208
207
|
}
|
|
209
208
|
async beginTransaction(options: capSQLiteOptions): Promise<capSQLiteChanges> {
|
|
210
209
|
this.ensureJeepSqliteIsAvailable();
|
|
@@ -285,7 +284,6 @@ export class CapacitorSQLiteWeb
|
|
|
285
284
|
} catch (err) {
|
|
286
285
|
throw new Error(`${err}`);
|
|
287
286
|
}
|
|
288
|
-
|
|
289
287
|
}
|
|
290
288
|
|
|
291
289
|
async executeSet(options: capSQLiteSetOptions): Promise<capSQLiteChanges> {
|
|
@@ -555,7 +553,6 @@ export class CapacitorSQLiteWeb
|
|
|
555
553
|
}
|
|
556
554
|
}
|
|
557
555
|
|
|
558
|
-
|
|
559
556
|
////////////////////////////////////
|
|
560
557
|
////// UNIMPLEMENTED METHODS
|
|
561
558
|
////////////////////////////////////
|