@capacitor-community/sqlite 3.4.2-5 → 3.4.3-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 (33) hide show
  1. package/README.md +46 -4
  2. package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLite.java +41 -2
  3. package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java +26 -0
  4. package/android/src/main/java/com/getcapacitor/community/database/sqlite/NotificationCenter.java +1 -1
  5. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +220 -7
  6. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ExportToJson.java +102 -86
  7. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ImportFromJson.java +127 -38
  8. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/UtilsJson.java +90 -0
  9. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsUpgrade.java +8 -4
  10. package/dist/esm/definitions.d.ts +17 -1
  11. package/dist/esm/definitions.js +22 -28
  12. package/dist/esm/definitions.js.map +1 -1
  13. package/dist/esm/web.d.ts +20 -11
  14. package/dist/esm/web.js +288 -473
  15. package/dist/esm/web.js.map +1 -1
  16. package/dist/plugin.cjs.js +286 -477
  17. package/dist/plugin.cjs.js.map +1 -1
  18. package/dist/plugin.js +1036 -1227
  19. package/dist/plugin.js.map +1 -1
  20. package/electron/dist/plugin.js +589 -744
  21. package/electron/dist/plugin.js.map +1 -1
  22. package/ios/Plugin/CapacitorSQLite.swift +34 -1
  23. package/ios/Plugin/CapacitorSQLitePlugin.m +1 -0
  24. package/ios/Plugin/CapacitorSQLitePlugin.swift +25 -0
  25. package/ios/Plugin/Database.swift +29 -1
  26. package/ios/Plugin/Extensions/String.swift +8 -0
  27. package/ios/Plugin/ImportExportJson/ExportToJson.swift +190 -32
  28. package/ios/Plugin/ImportExportJson/ImportFromJson.swift +73 -38
  29. package/ios/Plugin/Utils/UtilsDrop.swift +2 -2
  30. package/ios/Plugin/Utils/UtilsJson.swift +68 -1
  31. package/ios/Plugin/Utils/UtilsSQLCipher.swift +277 -29
  32. package/ios/Plugin/Utils/UtilsUpgrade.swift +33 -13
  33. package/package.json +6 -6
package/dist/esm/web.js CHANGED
@@ -2,562 +2,350 @@ import { WebPlugin } from '@capacitor/core';
2
2
  export class CapacitorSQLiteWeb extends WebPlugin {
3
3
  constructor() {
4
4
  super(...arguments);
5
- this.sqliteEl = null;
6
- this.isStoreOpen = false;
5
+ this.jeepSqliteElement = null;
6
+ this.isWebStoreOpen = false;
7
7
  }
8
8
  async initWebStore() {
9
9
  await customElements.whenDefined('jeep-sqlite');
10
- this.sqliteEl = document.querySelector('jeep-sqlite');
11
- if (this.sqliteEl != null) {
12
- this.sqliteEl.addEventListener('jeepSqliteImportProgress', (event) => {
13
- this.notifyListeners('sqliteImportProgressEvent', event.detail);
14
- });
15
- this.sqliteEl.addEventListener('jeepSqliteExportProgress', (event) => {
16
- this.notifyListeners('sqliteExportProgressEvent', event.detail);
17
- });
18
- if (!this.isStoreOpen)
19
- this.isStoreOpen = await this.sqliteEl.isStoreOpen();
20
- return Promise.resolve();
21
- }
22
- else {
23
- return Promise.reject('InitWeb: this.sqliteEl is null');
24
- }
10
+ this.jeepSqliteElement = document.querySelector('jeep-sqlite');
11
+ this.ensureJeepSqliteIsAvailable();
12
+ this.jeepSqliteElement.addEventListener('jeepSqliteImportProgress', (event) => {
13
+ this.notifyListeners('sqliteImportProgressEvent', event.detail);
14
+ });
15
+ this.jeepSqliteElement.addEventListener('jeepSqliteExportProgress', (event) => {
16
+ this.notifyListeners('sqliteExportProgressEvent', event.detail);
17
+ });
18
+ if (!this.isWebStoreOpen) {
19
+ this.isWebStoreOpen = await this.jeepSqliteElement.isStoreOpen();
20
+ }
21
+ return;
25
22
  }
26
23
  async saveToStore(options) {
27
- if (this.sqliteEl != null) {
28
- if (this.isStoreOpen) {
29
- try {
30
- await this.sqliteEl.saveToStore(options);
31
- return Promise.resolve();
32
- }
33
- catch (err) {
34
- return Promise.reject(`${err}`);
35
- }
36
- }
37
- else {
38
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
39
- }
40
- }
41
- else {
42
- throw this.unimplemented('Not implemented on web.');
43
- }
44
- }
45
- async echo(options) {
46
- if (this.sqliteEl != null) {
47
- const echo = await this.sqliteEl.echo(options);
48
- return echo;
24
+ this.ensureJeepSqliteIsAvailable();
25
+ this.ensureWebstoreIsOpen();
26
+ try {
27
+ await this.jeepSqliteElement.saveToStore(options);
28
+ return;
49
29
  }
50
- else {
51
- throw this.unimplemented('Not implemented on web.');
30
+ catch (err) {
31
+ throw new Error(`${err}`);
52
32
  }
53
33
  }
54
- async isSecretStored() {
55
- throw this.unimplemented('Not implemented on web.');
56
- }
57
- async setEncryptionSecret(options) {
58
- console.log('setEncryptionSecret', options);
59
- throw this.unimplemented('Not implemented on web.');
60
- }
61
- async changeEncryptionSecret(options) {
62
- console.log('changeEncryptionSecret', options);
63
- throw this.unimplemented('Not implemented on web.');
64
- }
65
- async getNCDatabasePath(options) {
66
- console.log('getNCDatabasePath', options);
67
- throw this.unimplemented('Not implemented on web.');
68
- }
69
- async createNCConnection(options) {
70
- console.log('createNCConnection', options);
71
- throw this.unimplemented('Not implemented on web.');
72
- }
73
- async closeNCConnection(options) {
74
- console.log('closeNCConnection', options);
75
- throw this.unimplemented('Not implemented on web.');
76
- }
77
- async isNCDatabase(options) {
78
- console.log('isNCDatabase', options);
79
- throw this.unimplemented('Not implemented on web.');
34
+ async echo(options) {
35
+ this.ensureJeepSqliteIsAvailable();
36
+ const echoResult = await this.jeepSqliteElement.echo(options);
37
+ return echoResult;
80
38
  }
81
39
  async createConnection(options) {
82
- if (this.sqliteEl != null) {
83
- if (this.isStoreOpen) {
84
- try {
85
- await this.sqliteEl.createConnection(options);
86
- return Promise.resolve();
87
- }
88
- catch (err) {
89
- return Promise.reject(`${err}`);
90
- }
91
- }
92
- else {
93
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
94
- }
95
- }
96
- else {
97
- throw this.unimplemented('Not implemented on web.');
40
+ this.ensureJeepSqliteIsAvailable();
41
+ this.ensureWebstoreIsOpen();
42
+ try {
43
+ await this.jeepSqliteElement.createConnection(options);
44
+ return;
45
+ }
46
+ catch (err) {
47
+ throw new Error(`${err}`);
98
48
  }
99
49
  }
100
50
  async open(options) {
101
- if (this.sqliteEl != null) {
102
- if (this.isStoreOpen) {
103
- try {
104
- await this.sqliteEl.open(options);
105
- return Promise.resolve();
106
- }
107
- catch (err) {
108
- return Promise.reject(`${err}`);
109
- }
110
- }
111
- else {
112
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
113
- }
114
- }
115
- else {
116
- throw this.unimplemented('Not implemented on web.');
51
+ this.ensureJeepSqliteIsAvailable();
52
+ this.ensureWebstoreIsOpen();
53
+ try {
54
+ await this.jeepSqliteElement.open(options);
55
+ return;
56
+ }
57
+ catch (err) {
58
+ throw new Error(`${err}`);
117
59
  }
118
60
  }
119
61
  async closeConnection(options) {
120
- if (this.sqliteEl != null) {
121
- if (this.isStoreOpen) {
122
- try {
123
- await this.sqliteEl.closeConnection(options);
124
- return Promise.resolve();
125
- }
126
- catch (err) {
127
- return Promise.reject(`${err}`);
128
- }
129
- }
130
- else {
131
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
132
- }
133
- }
134
- else {
135
- throw this.unimplemented('Not implemented on web.');
62
+ this.ensureJeepSqliteIsAvailable();
63
+ this.ensureWebstoreIsOpen();
64
+ try {
65
+ await this.jeepSqliteElement.closeConnection(options);
66
+ return;
67
+ }
68
+ catch (err) {
69
+ throw new Error(`${err}`);
136
70
  }
137
- }
138
- async getUrl() {
139
- throw this.unimplemented('Not implemented on web.');
140
71
  }
141
72
  async getVersion(options) {
142
- if (this.sqliteEl != null) {
143
- if (this.isStoreOpen) {
144
- try {
145
- const ret = await this.sqliteEl.getVersion(options);
146
- return Promise.resolve(ret);
147
- }
148
- catch (err) {
149
- return Promise.reject(`${err}`);
150
- }
151
- }
152
- else {
153
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
154
- }
155
- }
156
- else {
157
- throw this.unimplemented('Not implemented on web.');
73
+ this.ensureJeepSqliteIsAvailable();
74
+ this.ensureWebstoreIsOpen();
75
+ try {
76
+ const versionResult = await this.jeepSqliteElement.getVersion(options);
77
+ return versionResult;
78
+ }
79
+ catch (err) {
80
+ throw new Error(`${err}`);
158
81
  }
159
82
  }
160
83
  async checkConnectionsConsistency(options) {
161
- if (this.sqliteEl != null) {
162
- try {
163
- const ret = await this.sqliteEl.checkConnectionsConsistency(options);
164
- return Promise.resolve(ret);
165
- }
166
- catch (err) {
167
- return Promise.reject(`${err}`);
168
- }
84
+ this.ensureJeepSqliteIsAvailable();
85
+ try {
86
+ const consistencyResult = await this.jeepSqliteElement.checkConnectionsConsistency(options);
87
+ return consistencyResult;
169
88
  }
170
- else {
171
- throw this.unimplemented('Not implemented on web.');
89
+ catch (err) {
90
+ throw new Error(`${err}`);
172
91
  }
173
92
  }
174
93
  async close(options) {
175
- if (this.sqliteEl != null) {
176
- if (this.isStoreOpen) {
177
- try {
178
- await this.sqliteEl.close(options);
179
- return Promise.resolve();
180
- }
181
- catch (err) {
182
- return Promise.reject(`${err}`);
183
- }
184
- }
185
- else {
186
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
187
- }
188
- }
189
- else {
190
- throw this.unimplemented('Not implemented on web.');
94
+ this.ensureJeepSqliteIsAvailable();
95
+ this.ensureWebstoreIsOpen();
96
+ try {
97
+ await this.jeepSqliteElement.close(options);
98
+ return;
99
+ }
100
+ catch (err) {
101
+ throw new Error(`${err}`);
191
102
  }
192
103
  }
193
104
  async getTableList(options) {
194
- if (this.sqliteEl != null) {
195
- if (this.isStoreOpen) {
196
- try {
197
- const res = await this.sqliteEl.getTableList(options);
198
- return Promise.resolve(res);
199
- }
200
- catch (err) {
201
- return Promise.reject(`${err}`);
202
- }
203
- }
204
- else {
205
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
206
- }
207
- }
208
- else {
209
- throw this.unimplemented('Not implemented on web.');
105
+ this.ensureJeepSqliteIsAvailable();
106
+ this.ensureWebstoreIsOpen();
107
+ try {
108
+ const tableListResult = await this.jeepSqliteElement.getTableList(options);
109
+ return tableListResult;
110
+ }
111
+ catch (err) {
112
+ throw new Error(`${err}`);
210
113
  }
211
114
  }
212
115
  async execute(options) {
213
- if (this.sqliteEl != null) {
214
- if (this.isStoreOpen) {
215
- try {
216
- const ret = await this.sqliteEl.execute(options);
217
- return Promise.resolve(ret);
218
- }
219
- catch (err) {
220
- return Promise.reject(`${err}`);
221
- }
222
- }
223
- else {
224
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
225
- }
226
- }
227
- else {
228
- throw this.unimplemented('Not implemented on web.');
116
+ this.ensureJeepSqliteIsAvailable();
117
+ this.ensureWebstoreIsOpen();
118
+ try {
119
+ const executeResult = await this.jeepSqliteElement.execute(options);
120
+ return executeResult;
121
+ }
122
+ catch (err) {
123
+ throw new Error(`${err}`);
229
124
  }
230
125
  }
231
126
  async executeSet(options) {
232
- if (this.sqliteEl != null) {
233
- if (this.isStoreOpen) {
234
- try {
235
- const ret = await this.sqliteEl.executeSet(options);
236
- return Promise.resolve(ret);
237
- }
238
- catch (err) {
239
- return Promise.reject(`${err}`);
240
- }
241
- }
242
- else {
243
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
244
- }
245
- }
246
- else {
247
- throw this.unimplemented('Not implemented on web.');
127
+ this.ensureJeepSqliteIsAvailable();
128
+ this.ensureWebstoreIsOpen();
129
+ try {
130
+ const executeResult = await this.jeepSqliteElement.executeSet(options);
131
+ return executeResult;
132
+ }
133
+ catch (err) {
134
+ throw new Error(`${err}`);
248
135
  }
249
136
  }
250
137
  async run(options) {
251
- if (this.sqliteEl != null) {
252
- if (this.isStoreOpen) {
253
- try {
254
- const ret = await this.sqliteEl.run(options);
255
- return Promise.resolve(ret);
256
- }
257
- catch (err) {
258
- return Promise.reject(`${err}`);
259
- }
260
- }
261
- else {
262
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
263
- }
264
- }
265
- else {
266
- throw this.unimplemented('Not implemented on web.');
138
+ this.ensureJeepSqliteIsAvailable();
139
+ this.ensureWebstoreIsOpen();
140
+ try {
141
+ const runResult = await this.jeepSqliteElement.run(options);
142
+ return runResult;
143
+ }
144
+ catch (err) {
145
+ throw new Error(`${err}`);
267
146
  }
268
147
  }
269
148
  async query(options) {
270
- if (this.sqliteEl != null) {
271
- if (this.isStoreOpen) {
272
- try {
273
- const ret = await this.sqliteEl.query(options);
274
- return Promise.resolve(ret);
275
- }
276
- catch (err) {
277
- return Promise.reject(`${err}`);
278
- }
279
- }
280
- else {
281
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
282
- }
283
- }
284
- else {
285
- throw this.unimplemented('Not implemented on web.');
149
+ this.ensureJeepSqliteIsAvailable();
150
+ this.ensureWebstoreIsOpen();
151
+ try {
152
+ const queryResult = await this.jeepSqliteElement.query(options);
153
+ return queryResult;
154
+ }
155
+ catch (err) {
156
+ throw new Error(`${err}`);
286
157
  }
287
158
  }
288
159
  async isDBExists(options) {
289
- if (this.sqliteEl != null) {
290
- if (this.isStoreOpen) {
291
- try {
292
- const ret = await this.sqliteEl.isDBExists(options);
293
- return Promise.resolve(ret);
294
- }
295
- catch (err) {
296
- return Promise.reject(`${err}`);
297
- }
298
- }
299
- else {
300
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
301
- }
302
- }
303
- else {
304
- throw this.unimplemented('Not implemented on web.');
160
+ this.ensureJeepSqliteIsAvailable();
161
+ this.ensureWebstoreIsOpen();
162
+ try {
163
+ const dbExistsResult = await this.jeepSqliteElement.isDBExists(options);
164
+ return dbExistsResult;
165
+ }
166
+ catch (err) {
167
+ throw new Error(`${err}`);
305
168
  }
306
169
  }
307
170
  async isDBOpen(options) {
308
- if (this.sqliteEl != null) {
309
- if (this.isStoreOpen) {
310
- try {
311
- const ret = await this.sqliteEl.isDBOpen(options);
312
- return Promise.resolve(ret);
313
- }
314
- catch (err) {
315
- return Promise.reject(`${err}`);
316
- }
317
- }
318
- else {
319
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
320
- }
321
- }
322
- else {
323
- throw this.unimplemented('Not implemented on web.');
171
+ this.ensureJeepSqliteIsAvailable();
172
+ this.ensureWebstoreIsOpen();
173
+ try {
174
+ const isDBOpenResult = await this.jeepSqliteElement.isDBOpen(options);
175
+ return isDBOpenResult;
176
+ }
177
+ catch (err) {
178
+ throw new Error(`${err}`);
324
179
  }
325
180
  }
326
181
  async isDatabase(options) {
327
- if (this.sqliteEl != null) {
328
- if (!this.isStoreOpen)
329
- this.isStoreOpen = await this.sqliteEl.isStoreOpen();
330
- if (this.isStoreOpen) {
331
- try {
332
- const ret = await this.sqliteEl.isDatabase(options);
333
- return Promise.resolve(ret);
334
- }
335
- catch (err) {
336
- return Promise.reject(`${err}`);
337
- }
338
- }
339
- else {
340
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
341
- }
342
- }
343
- else {
344
- throw this.unimplemented('Not implemented on web.');
182
+ this.ensureJeepSqliteIsAvailable();
183
+ this.ensureWebstoreIsOpen();
184
+ try {
185
+ const isDatabaseResult = await this.jeepSqliteElement.isDatabase(options);
186
+ return isDatabaseResult;
187
+ }
188
+ catch (err) {
189
+ throw new Error(`${err}`);
345
190
  }
346
191
  }
347
192
  async isTableExists(options) {
348
- if (this.sqliteEl != null) {
349
- if (this.isStoreOpen) {
350
- try {
351
- const ret = await this.sqliteEl.isTableExists(options);
352
- return Promise.resolve(ret);
353
- }
354
- catch (err) {
355
- return Promise.reject(`${err}`);
356
- }
357
- }
358
- else {
359
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
360
- }
361
- }
362
- else {
363
- throw this.unimplemented('Not implemented on web.');
193
+ this.ensureJeepSqliteIsAvailable();
194
+ this.ensureWebstoreIsOpen();
195
+ try {
196
+ const tableExistsResult = await this.jeepSqliteElement.isTableExists(options);
197
+ return tableExistsResult;
198
+ }
199
+ catch (err) {
200
+ throw new Error(`${err}`);
364
201
  }
365
202
  }
366
203
  async deleteDatabase(options) {
367
- if (this.sqliteEl != null) {
368
- if (this.isStoreOpen) {
369
- try {
370
- await this.sqliteEl.deleteDatabase(options);
371
- return Promise.resolve();
372
- }
373
- catch (err) {
374
- return Promise.reject(`${err}`);
375
- }
376
- }
377
- else {
378
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
379
- }
380
- }
381
- else {
382
- throw this.unimplemented('Not implemented on web.');
204
+ this.ensureJeepSqliteIsAvailable();
205
+ this.ensureWebstoreIsOpen();
206
+ try {
207
+ await this.jeepSqliteElement.deleteDatabase(options);
208
+ return;
209
+ }
210
+ catch (err) {
211
+ throw new Error(`${err}`);
383
212
  }
384
213
  }
385
214
  async isJsonValid(options) {
386
- if (this.sqliteEl != null) {
387
- if (!this.isStoreOpen)
388
- this.isStoreOpen = await this.sqliteEl.isStoreOpen();
389
- if (this.isStoreOpen) {
390
- try {
391
- const ret = await this.sqliteEl.isJsonValid(options);
392
- return Promise.resolve(ret);
393
- }
394
- catch (err) {
395
- return Promise.reject(`${err}`);
396
- }
397
- }
398
- else {
399
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
400
- }
401
- }
402
- else {
403
- throw this.unimplemented('Not implemented on web.');
215
+ this.ensureJeepSqliteIsAvailable();
216
+ this.ensureWebstoreIsOpen();
217
+ try {
218
+ const isJsonValidResult = await this.jeepSqliteElement.isJsonValid(options);
219
+ return isJsonValidResult;
220
+ }
221
+ catch (err) {
222
+ throw new Error(`${err}`);
404
223
  }
405
224
  }
406
225
  async importFromJson(options) {
407
- if (this.sqliteEl != null) {
408
- if (!this.isStoreOpen)
409
- this.isStoreOpen = await this.sqliteEl.isStoreOpen();
410
- if (this.isStoreOpen) {
411
- try {
412
- const ret = await this.sqliteEl.importFromJson(options);
413
- return Promise.resolve(ret);
414
- }
415
- catch (err) {
416
- return Promise.reject(`${err}`);
417
- }
418
- }
419
- else {
420
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
421
- }
422
- }
423
- else {
424
- throw this.unimplemented('Not implemented on web.');
226
+ this.ensureJeepSqliteIsAvailable();
227
+ this.ensureWebstoreIsOpen();
228
+ try {
229
+ const importFromJsonResult = await this.jeepSqliteElement.importFromJson(options);
230
+ return importFromJsonResult;
231
+ }
232
+ catch (err) {
233
+ throw new Error(`${err}`);
425
234
  }
426
235
  }
427
236
  async exportToJson(options) {
428
- if (this.sqliteEl != null) {
429
- if (this.isStoreOpen) {
430
- try {
431
- const ret = await this.sqliteEl.exportToJson(options);
432
- return Promise.resolve(ret);
433
- }
434
- catch (err) {
435
- return Promise.reject(`${err}`);
436
- }
437
- }
438
- else {
439
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
440
- }
441
- }
442
- else {
443
- throw this.unimplemented('Not implemented on web.');
237
+ this.ensureJeepSqliteIsAvailable();
238
+ this.ensureWebstoreIsOpen();
239
+ try {
240
+ const exportToJsonResult = await this.jeepSqliteElement.exportToJson(options);
241
+ return exportToJsonResult;
242
+ }
243
+ catch (err) {
244
+ throw new Error(`${err}`);
444
245
  }
445
246
  }
446
247
  async createSyncTable(options) {
447
- if (this.sqliteEl != null) {
448
- if (this.isStoreOpen) {
449
- try {
450
- const ret = await this.sqliteEl.createSyncTable(options);
451
- return Promise.resolve(ret);
452
- }
453
- catch (err) {
454
- return Promise.reject(`${err}`);
455
- }
456
- }
457
- else {
458
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
459
- }
460
- }
461
- else {
462
- throw this.unimplemented('Not implemented on web.');
248
+ this.ensureJeepSqliteIsAvailable();
249
+ this.ensureWebstoreIsOpen();
250
+ try {
251
+ const createSyncTableResult = await this.jeepSqliteElement.createSyncTable(options);
252
+ return createSyncTableResult;
253
+ }
254
+ catch (err) {
255
+ throw new Error(`${err}`);
463
256
  }
464
257
  }
465
258
  async setSyncDate(options) {
466
- if (this.sqliteEl != null) {
467
- if (this.isStoreOpen) {
468
- try {
469
- await this.sqliteEl.setSyncDate(options);
470
- return Promise.resolve();
471
- }
472
- catch (err) {
473
- return Promise.reject(`${err}`);
474
- }
475
- }
476
- else {
477
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
478
- }
479
- }
480
- else {
481
- throw this.unimplemented('Not implemented on web.');
259
+ this.ensureJeepSqliteIsAvailable();
260
+ this.ensureWebstoreIsOpen();
261
+ try {
262
+ await this.jeepSqliteElement.setSyncDate(options);
263
+ return;
264
+ }
265
+ catch (err) {
266
+ throw new Error(`${err}`);
482
267
  }
483
268
  }
484
269
  async getSyncDate(options) {
485
- if (this.sqliteEl != null) {
486
- if (this.isStoreOpen) {
487
- try {
488
- const ret = await this.sqliteEl.getSyncDate(options);
489
- return Promise.resolve(ret);
490
- }
491
- catch (err) {
492
- return Promise.reject(`${err}`);
493
- }
494
- }
495
- else {
496
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
497
- }
498
- }
499
- else {
500
- throw this.unimplemented('Not implemented on web.');
270
+ this.ensureJeepSqliteIsAvailable();
271
+ this.ensureWebstoreIsOpen();
272
+ try {
273
+ const getSyncDateResult = await this.jeepSqliteElement.getSyncDate(options);
274
+ return getSyncDateResult;
275
+ }
276
+ catch (err) {
277
+ throw new Error(`${err}`);
278
+ }
279
+ }
280
+ async deleteExportedRows(options) {
281
+ this.ensureJeepSqliteIsAvailable();
282
+ this.ensureWebstoreIsOpen();
283
+ try {
284
+ await this.jeepSqliteElement.deleteExportedRows(options);
285
+ return;
286
+ }
287
+ catch (err) {
288
+ throw new Error(`${err}`);
501
289
  }
502
290
  }
503
291
  async addUpgradeStatement(options) {
504
- if (this.sqliteEl != null) {
505
- if (this.isStoreOpen) {
506
- try {
507
- await this.sqliteEl.addUpgradeStatement(options);
508
- return Promise.resolve();
509
- }
510
- catch (err) {
511
- return Promise.reject(`${err}`);
512
- }
513
- }
514
- else {
515
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
516
- }
517
- }
518
- else {
519
- throw this.unimplemented('Not implemented on web.');
292
+ this.ensureJeepSqliteIsAvailable();
293
+ this.ensureWebstoreIsOpen();
294
+ try {
295
+ await this.jeepSqliteElement.addUpgradeStatement(options);
296
+ return;
297
+ }
298
+ catch (err) {
299
+ throw new Error(`${err}`);
520
300
  }
521
301
  }
522
302
  async copyFromAssets(options) {
523
- if (this.sqliteEl != null) {
524
- if (this.isStoreOpen) {
525
- try {
526
- await this.sqliteEl.copyFromAssets(options);
527
- return Promise.resolve();
528
- }
529
- catch (err) {
530
- return Promise.reject(`${err}`);
531
- }
532
- }
533
- else {
534
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
535
- }
536
- }
537
- else {
538
- throw this.unimplemented('Not implemented on web.');
303
+ this.ensureJeepSqliteIsAvailable();
304
+ this.ensureWebstoreIsOpen();
305
+ try {
306
+ await this.jeepSqliteElement.copyFromAssets(options);
307
+ return;
308
+ }
309
+ catch (err) {
310
+ throw new Error(`${err}`);
539
311
  }
540
312
  }
541
313
  async getDatabaseList() {
542
- if (this.sqliteEl != null) {
543
- if (!this.isStoreOpen)
544
- this.isStoreOpen = await this.sqliteEl.isStoreOpen();
545
- if (this.isStoreOpen) {
546
- try {
547
- const ret = await this.sqliteEl.getDatabaseList();
548
- return Promise.resolve(ret);
549
- }
550
- catch (err) {
551
- return Promise.reject(`${err}`);
552
- }
553
- }
554
- else {
555
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
556
- }
557
- }
558
- else {
559
- throw this.unimplemented('Not implemented on web.');
560
- }
314
+ this.ensureJeepSqliteIsAvailable();
315
+ this.ensureWebstoreIsOpen();
316
+ try {
317
+ const databaseListResult = await this.jeepSqliteElement.getDatabaseList();
318
+ return databaseListResult;
319
+ }
320
+ catch (err) {
321
+ throw new Error(`${err}`);
322
+ }
323
+ }
324
+ /**
325
+ * Checks if the `jeep-sqlite` element is present in the DOM.
326
+ * If it's not in the DOM, this method throws an Error.
327
+ *
328
+ * Attention: This will always fail, if the `intWebStore()` method wasn't called before.
329
+ */
330
+ ensureJeepSqliteIsAvailable() {
331
+ if (this.jeepSqliteElement === null) {
332
+ throw new Error(`The jeep-sqlite element is not present in the DOM! Please check the @capacitor-community/sqlite documentation for instructions regarding the web platform.`);
333
+ }
334
+ }
335
+ ensureWebstoreIsOpen() {
336
+ if (!this.isWebStoreOpen) {
337
+ /**
338
+ * if (!this.isWebStoreOpen)
339
+ this.isWebStoreOpen = await this.jeepSqliteElement.isStoreOpen();
340
+ */
341
+ throw new Error('WebStore is not open yet. You have to call "initWebStore()" first.');
342
+ }
343
+ }
344
+ ////////////////////////////////////
345
+ ////// UNIMPLEMENTED METHODS
346
+ ////////////////////////////////////
347
+ async getUrl() {
348
+ throw this.unimplemented('Not implemented on web.');
561
349
  }
562
350
  async getMigratableDbList(options) {
563
351
  console.log('getMigratableDbList', options);
@@ -571,5 +359,32 @@ export class CapacitorSQLiteWeb extends WebPlugin {
571
359
  console.log('deleteOldDatabases', options);
572
360
  throw this.unimplemented('Not implemented on web.');
573
361
  }
362
+ async isSecretStored() {
363
+ throw this.unimplemented('Not implemented on web.');
364
+ }
365
+ async setEncryptionSecret(options) {
366
+ console.log('setEncryptionSecret', options);
367
+ throw this.unimplemented('Not implemented on web.');
368
+ }
369
+ async changeEncryptionSecret(options) {
370
+ console.log('changeEncryptionSecret', options);
371
+ throw this.unimplemented('Not implemented on web.');
372
+ }
373
+ async getNCDatabasePath(options) {
374
+ console.log('getNCDatabasePath', options);
375
+ throw this.unimplemented('Not implemented on web.');
376
+ }
377
+ async createNCConnection(options) {
378
+ console.log('createNCConnection', options);
379
+ throw this.unimplemented('Not implemented on web.');
380
+ }
381
+ async closeNCConnection(options) {
382
+ console.log('closeNCConnection', options);
383
+ throw this.unimplemented('Not implemented on web.');
384
+ }
385
+ async isNCDatabase(options) {
386
+ console.log('isNCDatabase', options);
387
+ throw this.unimplemented('Not implemented on web.');
388
+ }
574
389
  }
575
390
  //# sourceMappingURL=web.js.map