@capacitor-community/sqlite 4.6.3-4 → 4.8.0-0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-community/sqlite",
3
- "version": "4.6.3-4",
3
+ "version": "4.8.0-0",
4
4
  "description": "Community plugin for native & electron SQLite databases",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -56,11 +56,11 @@
56
56
  "prepublishOnly": "npm run build && npm run build-electron && npm run docgen"
57
57
  },
58
58
  "devDependencies": {
59
- "@capacitor/android": "^4.6.3",
60
- "@capacitor/cli": "^4.6.3",
61
- "@capacitor/core": "^4.6.3",
59
+ "@capacitor/android": "^4.8.0",
60
+ "@capacitor/cli": "^4.8.0",
61
+ "@capacitor/core": "^4.8.0",
62
62
  "@capacitor/docgen": "^0.0.17",
63
- "@capacitor/ios": "^4.6.3",
63
+ "@capacitor/ios": "^4.8.0",
64
64
  "@ionic/eslint-config": "^0.3.0",
65
65
  "@ionic/prettier-config": "^1.0.1",
66
66
  "@ionic/swiftlint-config": "^1.1.2",
@@ -95,6 +95,6 @@
95
95
  }
96
96
  },
97
97
  "dependencies": {
98
- "jeep-sqlite": "^2.0.0"
98
+ "jeep-sqlite": "^2.3.3"
99
99
  }
100
100
  }
@@ -21,6 +21,24 @@ export interface CapacitorSQLitePlugin {
21
21
  */
22
22
 
23
23
  saveToStore(options: capSQLiteOptions): Promise<void>;
24
+ /**
25
+ * Get database from local disk and save it to store
26
+ *
27
+ * @param options: capSQLiteLocalDiskOptions
28
+ * @return Promise<void>
29
+ * @since 4.6.3
30
+ */
31
+
32
+ getFromLocalDiskToStore(options: capSQLiteLocalDiskOptions): Promise<void>;
33
+ /**
34
+ * Save database to local disk
35
+ *
36
+ * @param options: capSQLiteOptions
37
+ * @return Promise<void>
38
+ * @since 4.6.3
39
+ */
40
+
41
+ saveToLocalDisk(options: capSQLiteOptions): Promise<void>;
24
42
  /**
25
43
  * Check if a passphrase exists in a secure store
26
44
  *
@@ -570,6 +588,14 @@ export interface capSQLiteFromAssetsOptions {
570
588
  */
571
589
  overwrite?: boolean;
572
590
  }
591
+ export interface capSQLiteLocalDiskOptions {
592
+ /**
593
+ * Set the overwrite mode for saving the database from local disk to store
594
+ * "true"/"false" default to "true"
595
+ *
596
+ */
597
+ overwrite?: boolean;
598
+ }
573
599
  export interface capSQLiteHTTPOptions {
574
600
  /**
575
601
  * The url of the database or the zipped database(s)
@@ -856,6 +882,22 @@ export interface capJsonProgressListener {
856
882
  */
857
883
  progress?: string;
858
884
  }
885
+ export interface capHttpRequestEndedListener {
886
+ /**
887
+ * Message
888
+ */
889
+ message?: string;
890
+ }
891
+ export interface capPickOrSaveDatabaseEndedListener {
892
+ /**
893
+ * Pick Database's name
894
+ */
895
+ db_name?: string;
896
+ /**
897
+ * Message
898
+ */
899
+ message?: string;
900
+ }
859
901
  export interface capSQLiteVersionUpgrade {
860
902
  toVersion: number;
861
903
  statements: string[];
@@ -878,6 +920,22 @@ export interface ISQLiteConnection {
878
920
  * @since 3.2.3-1
879
921
  */
880
922
  saveToStore(database: string): Promise<void>;
923
+ /**
924
+ * Get database from local disk and save it to store
925
+ *
926
+ * @param overwrite: boolean
927
+ * @return Promise<void>
928
+ * @since 4.6.3
929
+ */
930
+ getFromLocalDiskToStore(overwrite: boolean): Promise<void>;
931
+ /**
932
+ * Save database to local disk
933
+ *
934
+ * @param database: string
935
+ * @return Promise<void>
936
+ * @since 4.6.3
937
+ */
938
+ saveToLocalDisk(database: string): Promise<void>;
881
939
  /**
882
940
  * Echo a value
883
941
  * @param value
@@ -1170,6 +1228,25 @@ export class SQLiteConnection implements ISQLiteConnection {
1170
1228
  return Promise.reject(err);
1171
1229
  }
1172
1230
  }
1231
+ async saveToLocalDisk(database: string): Promise<void> {
1232
+ try {
1233
+ await this.sqlite.saveToLocalDisk({ database });
1234
+ return Promise.resolve();
1235
+ } catch (err) {
1236
+ return Promise.reject(err);
1237
+ }
1238
+ }
1239
+ async getFromLocalDiskToStore(overwrite?: boolean): Promise<void> {
1240
+ const mOverwrite: boolean = overwrite != null ? overwrite : true;
1241
+
1242
+ try {
1243
+ await this.sqlite.getFromLocalDiskToStore({ overwrite: mOverwrite });
1244
+ return Promise.resolve();
1245
+ } catch (err) {
1246
+ return Promise.reject(err);
1247
+ }
1248
+ }
1249
+
1173
1250
  async echo(value: string): Promise<capEchoResult> {
1174
1251
  try {
1175
1252
  const res = await this.sqlite.echo({ value });
package/src/web.ts CHANGED
@@ -16,6 +16,7 @@ import type {
16
16
  capSQLiteExportOptions,
17
17
  capSQLiteFromAssetsOptions,
18
18
  capSQLiteHTTPOptions,
19
+ capSQLiteLocalDiskOptions,
19
20
  capSQLiteImportOptions,
20
21
  capSQLiteJson,
21
22
  capSQLiteOptions,
@@ -59,6 +60,24 @@ export class CapacitorSQLiteWeb
59
60
  this.notifyListeners('sqliteExportProgressEvent', event.detail);
60
61
  },
61
62
  );
63
+ this.jeepSqliteElement.addEventListener(
64
+ 'jeepSqliteHTTPRequestEnded',
65
+ (event: CustomEvent) => {
66
+ this.notifyListeners('sqliteHTTPRequestEndedEvent', event.detail);
67
+ },
68
+ );
69
+ this.jeepSqliteElement.addEventListener(
70
+ 'jeepSqlitePickDatabaseEnded',
71
+ (event: CustomEvent) => {
72
+ this.notifyListeners('sqlitePickDatabaseEndedEvent', event.detail);
73
+ },
74
+ );
75
+ this.jeepSqliteElement.addEventListener(
76
+ 'jeepSqliteSaveDatabaseToDisk',
77
+ (event: CustomEvent) => {
78
+ this.notifyListeners('sqliteSaveDatabaseToDiskEvent', event.detail);
79
+ },
80
+ );
62
81
 
63
82
  if (!this.isWebStoreOpen) {
64
83
  this.isWebStoreOpen = await this.jeepSqliteElement.isStoreOpen();
@@ -78,6 +97,30 @@ export class CapacitorSQLiteWeb
78
97
  throw new Error(`${err}`);
79
98
  }
80
99
  }
100
+ async getFromLocalDiskToStore(
101
+ options: capSQLiteLocalDiskOptions,
102
+ ): Promise<void> {
103
+ this.ensureJeepSqliteIsAvailable();
104
+ this.ensureWebstoreIsOpen();
105
+
106
+ try {
107
+ await this.jeepSqliteElement.getFromLocalDiskToStore(options);
108
+ return;
109
+ } catch (err) {
110
+ throw new Error(`${err}`);
111
+ }
112
+ }
113
+ async saveToLocalDisk(options: capSQLiteOptions): Promise<void> {
114
+ this.ensureJeepSqliteIsAvailable();
115
+ this.ensureWebstoreIsOpen();
116
+
117
+ try {
118
+ await this.jeepSqliteElement.saveToLocalDisk(options);
119
+ return;
120
+ } catch (err) {
121
+ throw new Error(`${err}`);
122
+ }
123
+ }
81
124
 
82
125
  async echo(options: capEchoOptions): Promise<capEchoResult> {
83
126
  this.ensureJeepSqliteIsAvailable();