@capacitor-community/sqlite 6.0.1 → 6.0.2

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.
Files changed (32) hide show
  1. package/README.md +71 -91
  2. package/android/build.gradle +1 -1
  3. package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java +12 -16
  4. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +2 -1
  5. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ImportFromJson.java +73 -69
  6. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsDownloadFromHTTP.java +13 -12
  7. package/dist/esm/definitions.js +1 -3
  8. package/dist/esm/definitions.js.map +1 -1
  9. package/dist/esm/index.js +1 -1
  10. package/dist/esm/index.js.map +1 -1
  11. package/dist/esm/web.js.map +1 -1
  12. package/dist/plugin.cjs.js +2 -4
  13. package/dist/plugin.cjs.js.map +1 -1
  14. package/dist/plugin.js +2 -4
  15. package/dist/plugin.js.map +1 -1
  16. package/electron/dist/plugin.js +56 -144
  17. package/electron/dist/plugin.js.map +1 -1
  18. package/electron/rollup.config.js +1 -3
  19. package/ios/Plugin/CapacitorSQLite.swift +5 -5
  20. package/ios/Plugin/Database.swift +1 -1
  21. package/ios/Plugin/ImportExportJson/ExportToJson.swift +7 -7
  22. package/ios/Plugin/Models/KeychainServices.swift +1 -1
  23. package/ios/Plugin/Utils/UtilsBinding.swift +2 -2
  24. package/ios/Plugin/Utils/UtilsDelete.swift +4 -4
  25. package/ios/Plugin/Utils/UtilsDownloadFromHTTP.swift +2 -2
  26. package/ios/Plugin/Utils/UtilsDrop.swift +1 -1
  27. package/ios/Plugin/Utils/UtilsSQLCipher.swift +17 -17
  28. package/ios/Plugin/Utils/UtilsSQLStatement.swift +120 -121
  29. package/package.json +23 -21
  30. package/src/definitions.ts +44 -128
  31. package/src/index.ts +4 -8
  32. package/src/web.ts +60 -132
package/src/web.ts CHANGED
@@ -37,55 +37,37 @@ import type {
37
37
  capSQLiteExtensionEnable,
38
38
  } from './definitions';
39
39
 
40
- export class CapacitorSQLiteWeb
41
- extends WebPlugin
42
- implements CapacitorSQLitePlugin
43
- {
40
+ export class CapacitorSQLiteWeb extends WebPlugin implements CapacitorSQLitePlugin {
44
41
  private jeepSqliteElement: any = null;
45
42
  private isWebStoreOpen = false;
46
43
 
47
44
  async initWebStore(): Promise<void> {
48
- await customElements.whenDefined('jeep-sqlite')
45
+ await customElements.whenDefined('jeep-sqlite');
46
+
47
+ this.jeepSqliteElement = document.querySelector('jeep-sqlite');
48
+ this.ensureJeepSqliteIsAvailable();
49
+
50
+ this.jeepSqliteElement.addEventListener('jeepSqliteImportProgress', (event: CustomEvent) => {
51
+ this.notifyListeners('sqliteImportProgressEvent', event.detail);
52
+ });
53
+ this.jeepSqliteElement.addEventListener('jeepSqliteExportProgress', (event: CustomEvent) => {
54
+ this.notifyListeners('sqliteExportProgressEvent', event.detail);
55
+ });
56
+ this.jeepSqliteElement.addEventListener('jeepSqliteHTTPRequestEnded', (event: CustomEvent) => {
57
+ this.notifyListeners('sqliteHTTPRequestEndedEvent', event.detail);
58
+ });
59
+ this.jeepSqliteElement.addEventListener('jeepSqlitePickDatabaseEnded', (event: CustomEvent) => {
60
+ this.notifyListeners('sqlitePickDatabaseEndedEvent', event.detail);
61
+ });
62
+ this.jeepSqliteElement.addEventListener('jeepSqliteSaveDatabaseToDisk', (event: CustomEvent) => {
63
+ this.notifyListeners('sqliteSaveDatabaseToDiskEvent', event.detail);
64
+ });
49
65
 
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
- );
83
-
84
- if (!this.isWebStoreOpen) {
85
- this.isWebStoreOpen = await this.jeepSqliteElement.isStoreOpen();
86
- }
66
+ if (!this.isWebStoreOpen) {
67
+ this.isWebStoreOpen = await this.jeepSqliteElement.isStoreOpen();
68
+ }
87
69
 
88
- return;
70
+ return;
89
71
  }
90
72
 
91
73
  async saveToStore(options: capSQLiteOptions): Promise<void> {
@@ -99,9 +81,7 @@ export class CapacitorSQLiteWeb
99
81
  throw new Error(`${err}`);
100
82
  }
101
83
  }
102
- async getFromLocalDiskToStore(
103
- options: capSQLiteLocalDiskOptions,
104
- ): Promise<void> {
84
+ async getFromLocalDiskToStore(options: capSQLiteLocalDiskOptions): Promise<void> {
105
85
  this.ensureJeepSqliteIsAvailable();
106
86
  this.ensureWebstoreIsOpen();
107
87
 
@@ -172,22 +152,18 @@ export class CapacitorSQLiteWeb
172
152
  this.ensureWebstoreIsOpen();
173
153
 
174
154
  try {
175
- const versionResult: capVersionResult =
176
- await this.jeepSqliteElement.getVersion(options);
155
+ const versionResult: capVersionResult = await this.jeepSqliteElement.getVersion(options);
177
156
  return versionResult;
178
157
  } catch (err) {
179
158
  throw new Error(`${err}`);
180
159
  }
181
160
  }
182
161
 
183
- async checkConnectionsConsistency(
184
- options: capAllConnectionsOptions,
185
- ): Promise<capSQLiteResult> {
162
+ async checkConnectionsConsistency(options: capAllConnectionsOptions): Promise<capSQLiteResult> {
186
163
  this.ensureJeepSqliteIsAvailable();
187
164
 
188
165
  try {
189
- const consistencyResult: capSQLiteResult =
190
- await this.jeepSqliteElement.checkConnectionsConsistency(options);
166
+ const consistencyResult: capSQLiteResult = await this.jeepSqliteElement.checkConnectionsConsistency(options);
191
167
  return consistencyResult;
192
168
  } catch (err) {
193
169
  throw new Error(`${err}`);
@@ -204,57 +180,46 @@ export class CapacitorSQLiteWeb
204
180
  } catch (err) {
205
181
  throw new Error(`${err}`);
206
182
  }
207
-
208
183
  }
209
184
  async beginTransaction(options: capSQLiteOptions): Promise<capSQLiteChanges> {
210
185
  this.ensureJeepSqliteIsAvailable();
211
186
  this.ensureWebstoreIsOpen();
212
187
 
213
188
  try {
214
- const changes: capSQLiteChanges =
215
- await this.jeepSqliteElement.beginTransaction(options);
189
+ const changes: capSQLiteChanges = await this.jeepSqliteElement.beginTransaction(options);
216
190
  return changes;
217
191
  } catch (err) {
218
192
  throw new Error(`${err}`);
219
193
  }
220
194
  }
221
- async commitTransaction(
222
- options: capSQLiteOptions,
223
- ): Promise<capSQLiteChanges> {
195
+ async commitTransaction(options: capSQLiteOptions): Promise<capSQLiteChanges> {
224
196
  this.ensureJeepSqliteIsAvailable();
225
197
  this.ensureWebstoreIsOpen();
226
198
 
227
199
  try {
228
- const changes: capSQLiteChanges =
229
- await this.jeepSqliteElement.commitTransaction(options);
200
+ const changes: capSQLiteChanges = await this.jeepSqliteElement.commitTransaction(options);
230
201
  return changes;
231
202
  } catch (err) {
232
203
  throw new Error(`${err}`);
233
204
  }
234
205
  }
235
- async rollbackTransaction(
236
- options: capSQLiteOptions,
237
- ): Promise<capSQLiteChanges> {
206
+ async rollbackTransaction(options: capSQLiteOptions): Promise<capSQLiteChanges> {
238
207
  this.ensureJeepSqliteIsAvailable();
239
208
  this.ensureWebstoreIsOpen();
240
209
 
241
210
  try {
242
- const changes: capSQLiteChanges =
243
- await this.jeepSqliteElement.rollbackTransaction(options);
211
+ const changes: capSQLiteChanges = await this.jeepSqliteElement.rollbackTransaction(options);
244
212
  return changes;
245
213
  } catch (err) {
246
214
  throw new Error(`${err}`);
247
215
  }
248
216
  }
249
- async isTransactionActive(
250
- options: capSQLiteOptions,
251
- ): Promise<capSQLiteResult> {
217
+ async isTransactionActive(options: capSQLiteOptions): Promise<capSQLiteResult> {
252
218
  this.ensureJeepSqliteIsAvailable();
253
219
  this.ensureWebstoreIsOpen();
254
220
 
255
221
  try {
256
- const result: capSQLiteResult =
257
- await this.jeepSqliteElement.isTransactionActive(options);
222
+ const result: capSQLiteResult = await this.jeepSqliteElement.isTransactionActive(options);
258
223
  return result;
259
224
  } catch (err) {
260
225
  throw new Error(`${err}`);
@@ -266,8 +231,7 @@ export class CapacitorSQLiteWeb
266
231
  this.ensureWebstoreIsOpen();
267
232
 
268
233
  try {
269
- const tableListResult: capSQLiteValues =
270
- await this.jeepSqliteElement.getTableList(options);
234
+ const tableListResult: capSQLiteValues = await this.jeepSqliteElement.getTableList(options);
271
235
  return tableListResult;
272
236
  } catch (err) {
273
237
  throw new Error(`${err}`);
@@ -279,13 +243,11 @@ export class CapacitorSQLiteWeb
279
243
  this.ensureWebstoreIsOpen();
280
244
 
281
245
  try {
282
- const executeResult: capSQLiteChanges =
283
- await this.jeepSqliteElement.execute(options);
246
+ const executeResult: capSQLiteChanges = await this.jeepSqliteElement.execute(options);
284
247
  return executeResult;
285
248
  } catch (err) {
286
249
  throw new Error(`${err}`);
287
250
  }
288
-
289
251
  }
290
252
 
291
253
  async executeSet(options: capSQLiteSetOptions): Promise<capSQLiteChanges> {
@@ -293,8 +255,7 @@ export class CapacitorSQLiteWeb
293
255
  this.ensureWebstoreIsOpen();
294
256
 
295
257
  try {
296
- const executeResult: capSQLiteChanges =
297
- await this.jeepSqliteElement.executeSet(options);
258
+ const executeResult: capSQLiteChanges = await this.jeepSqliteElement.executeSet(options);
298
259
  return executeResult;
299
260
  } catch (err) {
300
261
  throw new Error(`${err}`);
@@ -306,9 +267,7 @@ export class CapacitorSQLiteWeb
306
267
  this.ensureWebstoreIsOpen();
307
268
 
308
269
  try {
309
- const runResult: capSQLiteChanges = await this.jeepSqliteElement.run(
310
- options,
311
- );
270
+ const runResult: capSQLiteChanges = await this.jeepSqliteElement.run(options);
312
271
  return runResult;
313
272
  } catch (err) {
314
273
  throw new Error(`${err}`);
@@ -319,9 +278,7 @@ export class CapacitorSQLiteWeb
319
278
  this.ensureWebstoreIsOpen();
320
279
 
321
280
  try {
322
- const queryResult: capSQLiteValues = await this.jeepSqliteElement.query(
323
- options,
324
- );
281
+ const queryResult: capSQLiteValues = await this.jeepSqliteElement.query(options);
325
282
  return queryResult;
326
283
  } catch (err) {
327
284
  throw new Error(`${err}`);
@@ -332,8 +289,7 @@ export class CapacitorSQLiteWeb
332
289
  this.ensureWebstoreIsOpen();
333
290
 
334
291
  try {
335
- const dbExistsResult: capSQLiteResult =
336
- await this.jeepSqliteElement.isDBExists(options);
292
+ const dbExistsResult: capSQLiteResult = await this.jeepSqliteElement.isDBExists(options);
337
293
  return dbExistsResult;
338
294
  } catch (err) {
339
295
  throw new Error(`${err}`);
@@ -345,8 +301,7 @@ export class CapacitorSQLiteWeb
345
301
  this.ensureWebstoreIsOpen();
346
302
 
347
303
  try {
348
- const isDBOpenResult: capSQLiteResult =
349
- await this.jeepSqliteElement.isDBOpen(options);
304
+ const isDBOpenResult: capSQLiteResult = await this.jeepSqliteElement.isDBOpen(options);
350
305
  return isDBOpenResult;
351
306
  } catch (err) {
352
307
  throw new Error(`${err}`);
@@ -358,24 +313,19 @@ export class CapacitorSQLiteWeb
358
313
  this.ensureWebstoreIsOpen();
359
314
 
360
315
  try {
361
- const isDatabaseResult: capSQLiteResult =
362
- await this.jeepSqliteElement.isDatabase(options);
316
+ const isDatabaseResult: capSQLiteResult = await this.jeepSqliteElement.isDatabase(options);
363
317
  return isDatabaseResult;
364
318
  } catch (err) {
365
319
  throw new Error(`${err}`);
366
320
  }
367
321
  }
368
322
 
369
- async isTableExists(
370
- options: capSQLiteTableOptions,
371
- ): Promise<capSQLiteResult> {
323
+ async isTableExists(options: capSQLiteTableOptions): Promise<capSQLiteResult> {
372
324
  this.ensureJeepSqliteIsAvailable();
373
325
  this.ensureWebstoreIsOpen();
374
326
 
375
327
  try {
376
- const tableExistsResult = await this.jeepSqliteElement.isTableExists(
377
- options,
378
- );
328
+ const tableExistsResult = await this.jeepSqliteElement.isTableExists(options);
379
329
  return tableExistsResult;
380
330
  } catch (err) {
381
331
  throw new Error(`${err}`);
@@ -397,24 +347,19 @@ export class CapacitorSQLiteWeb
397
347
  this.ensureWebstoreIsOpen();
398
348
 
399
349
  try {
400
- const isJsonValidResult = await this.jeepSqliteElement.isJsonValid(
401
- options,
402
- );
350
+ const isJsonValidResult = await this.jeepSqliteElement.isJsonValid(options);
403
351
  return isJsonValidResult;
404
352
  } catch (err) {
405
353
  throw new Error(`${err}`);
406
354
  }
407
355
  }
408
356
 
409
- async importFromJson(
410
- options: capSQLiteImportOptions,
411
- ): Promise<capSQLiteChanges> {
357
+ async importFromJson(options: capSQLiteImportOptions): Promise<capSQLiteChanges> {
412
358
  this.ensureJeepSqliteIsAvailable();
413
359
  this.ensureWebstoreIsOpen();
414
360
 
415
361
  try {
416
- const importFromJsonResult: capSQLiteChanges =
417
- await this.jeepSqliteElement.importFromJson(options);
362
+ const importFromJsonResult: capSQLiteChanges = await this.jeepSqliteElement.importFromJson(options);
418
363
  return importFromJsonResult;
419
364
  } catch (err) {
420
365
  throw new Error(`${err}`);
@@ -426,8 +371,7 @@ export class CapacitorSQLiteWeb
426
371
  this.ensureWebstoreIsOpen();
427
372
 
428
373
  try {
429
- const exportToJsonResult: capSQLiteJson =
430
- await this.jeepSqliteElement.exportToJson(options);
374
+ const exportToJsonResult: capSQLiteJson = await this.jeepSqliteElement.exportToJson(options);
431
375
  return exportToJsonResult;
432
376
  } catch (err) {
433
377
  throw new Error(`${err}`);
@@ -438,8 +382,7 @@ export class CapacitorSQLiteWeb
438
382
  this.ensureWebstoreIsOpen();
439
383
 
440
384
  try {
441
- const createSyncTableResult: capSQLiteChanges =
442
- await this.jeepSqliteElement.createSyncTable(options);
385
+ const createSyncTableResult: capSQLiteChanges = await this.jeepSqliteElement.createSyncTable(options);
443
386
  return createSyncTableResult;
444
387
  } catch (err) {
445
388
  throw new Error(`${err}`);
@@ -462,8 +405,7 @@ export class CapacitorSQLiteWeb
462
405
  this.ensureWebstoreIsOpen();
463
406
 
464
407
  try {
465
- const getSyncDateResult: capSQLiteSyncDate =
466
- await this.jeepSqliteElement.getSyncDate(options);
408
+ const getSyncDateResult: capSQLiteSyncDate = await this.jeepSqliteElement.getSyncDate(options);
467
409
  return getSyncDateResult;
468
410
  } catch (err) {
469
411
  throw new Error(`${err}`);
@@ -521,8 +463,7 @@ export class CapacitorSQLiteWeb
521
463
  this.ensureWebstoreIsOpen();
522
464
 
523
465
  try {
524
- const databaseListResult: capSQLiteValues =
525
- await this.jeepSqliteElement.getDatabaseList();
466
+ const databaseListResult: capSQLiteValues = await this.jeepSqliteElement.getDatabaseList();
526
467
  return databaseListResult;
527
468
  } catch (err) {
528
469
  throw new Error(`${err}`);
@@ -538,7 +479,7 @@ export class CapacitorSQLiteWeb
538
479
  private ensureJeepSqliteIsAvailable() {
539
480
  if (this.jeepSqliteElement === null) {
540
481
  throw new Error(
541
- `The jeep-sqlite element is not present in the DOM! Please check the @capacitor-community/sqlite documentation for instructions regarding the web platform.`,
482
+ `The jeep-sqlite element is not present in the DOM! Please check the @capacitor-community/sqlite documentation for instructions regarding the web platform.`
542
483
  );
543
484
  }
544
485
  }
@@ -549,13 +490,10 @@ export class CapacitorSQLiteWeb
549
490
  * if (!this.isWebStoreOpen)
550
491
  this.isWebStoreOpen = await this.jeepSqliteElement.isStoreOpen();
551
492
  */
552
- throw new Error(
553
- 'WebStore is not open yet. You have to call "initWebStore()" first.',
554
- );
493
+ throw new Error('WebStore is not open yet. You have to call "initWebStore()" first.');
555
494
  }
556
495
  }
557
496
 
558
-
559
497
  ////////////////////////////////////
560
498
  ////// UNIMPLEMENTED METHODS
561
499
  ////////////////////////////////////
@@ -564,9 +502,7 @@ export class CapacitorSQLiteWeb
564
502
  throw this.unimplemented('Not implemented on web.');
565
503
  }
566
504
 
567
- async getMigratableDbList(
568
- options: capSQLitePathOptions,
569
- ): Promise<capSQLiteValues> {
505
+ async getMigratableDbList(options: capSQLitePathOptions): Promise<capSQLiteValues> {
570
506
  console.log('getMigratableDbList', options);
571
507
  throw this.unimplemented('Not implemented on web.');
572
508
  }
@@ -581,9 +517,7 @@ export class CapacitorSQLiteWeb
581
517
  throw this.unimplemented('Not implemented on web.');
582
518
  }
583
519
 
584
- async moveDatabasesAndAddSuffix(
585
- options: capSQLitePathOptions,
586
- ): Promise<void> {
520
+ async moveDatabasesAndAddSuffix(options: capSQLitePathOptions): Promise<void> {
587
521
  console.log('moveDatabasesAndAddSuffix', options);
588
522
  throw this.unimplemented('Not implemented on web.');
589
523
  }
@@ -607,16 +541,12 @@ export class CapacitorSQLiteWeb
607
541
  throw this.unimplemented('Not implemented on web.');
608
542
  }
609
543
 
610
- async checkEncryptionSecret(
611
- options: capSetSecretOptions,
612
- ): Promise<capSQLiteResult> {
544
+ async checkEncryptionSecret(options: capSetSecretOptions): Promise<capSQLiteResult> {
613
545
  console.log('checkEncryptionPassPhrase', options);
614
546
  throw this.unimplemented('Not implemented on web.');
615
547
  }
616
548
 
617
- async getNCDatabasePath(
618
- options: capNCDatabasePathOptions,
619
- ): Promise<capNCDatabasePathResult> {
549
+ async getNCDatabasePath(options: capNCDatabasePathOptions): Promise<capNCDatabasePathResult> {
620
550
  console.log('getNCDatabasePath', options);
621
551
  throw this.unimplemented('Not implemented on web.');
622
552
  }
@@ -636,9 +566,7 @@ export class CapacitorSQLiteWeb
636
566
  throw this.unimplemented('Not implemented on web.');
637
567
  }
638
568
 
639
- async isDatabaseEncrypted(
640
- options: capSQLiteOptions,
641
- ): Promise<capSQLiteResult> {
569
+ async isDatabaseEncrypted(options: capSQLiteOptions): Promise<capSQLiteResult> {
642
570
  console.log('isDatabaseEncrypted', options);
643
571
  throw this.unimplemented('Not implemented on web.');
644
572
  }