@capacitor-community/sqlite 5.0.8 → 5.2.4

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.
@@ -122,32 +122,32 @@ export interface CapacitorSQLitePlugin {
122
122
  close(options: capSQLiteOptions): Promise<void>;
123
123
  /**
124
124
  * Begin Database Transaction
125
- * @param options
125
+ * @param options
126
126
  * @returns capSQLiteChanges
127
127
  * @since 5.0.7
128
128
  */
129
129
  beginTransaction(options: capSQLiteOptions): Promise<capSQLiteChanges>;
130
130
  /**
131
131
  * Commit Database Transaction
132
- * @param options
132
+ * @param options
133
133
  * @returns capSQLiteChanges
134
134
  * @since 5.0.7
135
135
  */
136
136
  commitTransaction(options: capSQLiteOptions): Promise<capSQLiteChanges>;
137
- /**
137
+ /**
138
138
  * Rollback Database Transaction
139
- * @param options
139
+ * @param options
140
140
  * @returns capSQLiteChanges
141
141
  * @since 5.0.7
142
142
  */
143
143
  rollbackTransaction(options: capSQLiteOptions): Promise<capSQLiteChanges>;
144
144
  /**
145
145
  * Is Database Transaction Active
146
- * @param options
146
+ * @param options
147
147
  * @returns capSQLiteResult
148
148
  * @since 5.0.7
149
149
  */
150
- isTransactionActive(options: capSQLiteOptions): Promise<capSQLiteResult>;
150
+ isTransactionActive(options: capSQLiteOptions): Promise<capSQLiteResult>;
151
151
  /**
152
152
  * Load a SQlite extension
153
153
  * @param options :capSQLiteExtensionPath
@@ -417,6 +417,7 @@ export interface capSetSecretOptions {
417
417
  */
418
418
  passphrase?: string;
419
419
  }
420
+
420
421
  export interface capChangeSecretOptions {
421
422
  /**
422
423
  * The new passphrase for Encrypted Databases
@@ -566,7 +567,6 @@ export interface capSQLiteExecuteOptions {
566
567
  * @since 5.0.7
567
568
  */
568
569
  isSQL92?: boolean;
569
-
570
570
  }
571
571
  export interface capSQLiteSetOptions {
572
572
  /**
@@ -707,7 +707,7 @@ export interface capSQLiteExportOptions {
707
707
  * default false
708
708
  * @since 5.0.8
709
709
  */
710
- encrypted?: boolean
710
+ encrypted?: boolean;
711
711
  }
712
712
  export interface capSQLiteFromAssetsOptions {
713
713
  /**
@@ -1088,6 +1088,7 @@ export interface ISQLiteConnection {
1088
1088
  * @since 3.0.0-beta.13
1089
1089
  */
1090
1090
  isSecretStored(): Promise<capSQLiteResult>;
1091
+
1091
1092
  /**
1092
1093
  * Set a passphrase in a secure store
1093
1094
  * @param passphrase
@@ -1114,7 +1115,7 @@ export interface ISQLiteConnection {
1114
1115
  clearEncryptionSecret(): Promise<void>;
1115
1116
  /**
1116
1117
  * Check the passphrase stored in a secure store
1117
- * @param passphrase
1118
+ * @param oldPassphrase
1118
1119
  * @returns Promise<capSQLiteResult>
1119
1120
  * @since 4.6.1
1120
1121
  */
@@ -1482,6 +1483,12 @@ export class SQLiteConnection implements ISQLiteConnection {
1482
1483
  const conn = new SQLiteDBConnection(database, readonly, this.sqlite);
1483
1484
  const connName = readonly ? `RO_${database}` : `RW_${database}`;
1484
1485
  this._connectionDict.set(connName, conn);
1486
+ /*
1487
+ console.log(`*** in createConnection connectionDict: ***`)
1488
+ this._connectionDict.forEach((connection, key) => {
1489
+ console.log(`Key: ${key}, Value: ${connection}`);
1490
+ });
1491
+ */
1485
1492
  return Promise.resolve(conn);
1486
1493
  } catch (err) {
1487
1494
  return Promise.reject(err);
@@ -1493,6 +1500,11 @@ export class SQLiteConnection implements ISQLiteConnection {
1493
1500
  await this.sqlite.closeConnection({ database, readonly });
1494
1501
  const connName = readonly ? `RO_${database}` : `RW_${database}`;
1495
1502
  this._connectionDict.delete(connName);
1503
+ /* console.log(`*** in closeConnection connectionDict: ***`)
1504
+ this._connectionDict.forEach((connection, key) => {
1505
+ console.log(`Key: ${key}, Value: ${connection}`);
1506
+ });
1507
+ */
1496
1508
  return Promise.resolve();
1497
1509
  } catch (err) {
1498
1510
  return Promise.reject(err);
@@ -1601,6 +1613,11 @@ export class SQLiteConnection implements ISQLiteConnection {
1601
1613
  async closeAllConnections(): Promise<void> {
1602
1614
  const delDict: Map<string, SQLiteDBConnection | null> = new Map();
1603
1615
  try {
1616
+ /* console.log(`*** in closeAllConnections connectionDict: ***`)
1617
+ this._connectionDict.forEach((connection, key) => {
1618
+ console.log(`Key: ${key}, Value: ${connection}`);
1619
+ });
1620
+ */
1604
1621
  for (const key of this._connectionDict.keys()) {
1605
1622
  const database = key.substring(3);
1606
1623
  const readonly = key.substring(0, 3) === 'RO_' ? true : false;
@@ -1613,6 +1630,7 @@ export class SQLiteConnection implements ISQLiteConnection {
1613
1630
  }
1614
1631
  return Promise.resolve();
1615
1632
  } catch (err) {
1633
+ console.log(`in definition closeAllConnections err: `, err);
1616
1634
  return Promise.reject(err);
1617
1635
  }
1618
1636
  }
@@ -1829,7 +1847,7 @@ export interface ISQLiteDBConnection {
1829
1847
  * @returns capSQLiteResult
1830
1848
  * @since 5.0.7
1831
1849
  */
1832
- isTransactionActive(): Promise<capSQLiteResult>;
1850
+ isTransactionActive(): Promise<capSQLiteResult>;
1833
1851
  /**
1834
1852
  * Get Database Url
1835
1853
  * @returns Promise<capSQLiteUrl>
@@ -1864,7 +1882,11 @@ export interface ISQLiteDBConnection {
1864
1882
  * @returns Promise<capSQLiteChanges>
1865
1883
  * @since 2.9.0 refactor
1866
1884
  */
1867
- execute(statements: string, transaction?: boolean, isSQL92?: boolean): Promise<capSQLiteChanges>;
1885
+ execute(
1886
+ statements: string,
1887
+ transaction?: boolean,
1888
+ isSQL92?: boolean,
1889
+ ): Promise<capSQLiteChanges>;
1868
1890
  /**
1869
1891
  * Execute SQLite DB Connection Query
1870
1892
  * @param statement
@@ -1873,7 +1895,11 @@ export interface ISQLiteDBConnection {
1873
1895
  * @returns Promise<Promise<DBSQLiteValues>
1874
1896
  * @since 2.9.0 refactor
1875
1897
  */
1876
- query(statement: string, values?: any[], isSQL92?: boolean): Promise<DBSQLiteValues>;
1898
+ query(
1899
+ statement: string,
1900
+ values?: any[],
1901
+ isSQL92?: boolean,
1902
+ ): Promise<DBSQLiteValues>;
1877
1903
  /**
1878
1904
  * Execute SQLite DB Connection Raw Statement
1879
1905
  * @param statement
@@ -1889,7 +1915,7 @@ export interface ISQLiteDBConnection {
1889
1915
  values?: any[],
1890
1916
  transaction?: boolean,
1891
1917
  returnMode?: string,
1892
- isSQL92?: boolean
1918
+ isSQL92?: boolean,
1893
1919
  ): Promise<capSQLiteChanges>;
1894
1920
  /**
1895
1921
  * Execute SQLite DB Connection Set
@@ -1904,7 +1930,7 @@ export interface ISQLiteDBConnection {
1904
1930
  set: capSQLiteSet[],
1905
1931
  transaction?: boolean,
1906
1932
  returnMode?: string,
1907
- isSQL92?: boolean
1933
+ isSQL92?: boolean,
1908
1934
  ): Promise<capSQLiteChanges>;
1909
1935
  /**
1910
1936
  * Check if a SQLite DB Connection exists
@@ -1978,7 +2004,7 @@ export interface ISQLiteDBConnection {
1978
2004
  */
1979
2005
  executeTransaction(
1980
2006
  txn: { statement: string; values?: any[] }[],
1981
- isSQL92: boolean
2007
+ isSQL92: boolean,
1982
2008
  ): Promise<capSQLiteChanges>;
1983
2009
  }
1984
2010
  /**
@@ -1999,9 +2025,6 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
1999
2025
  }
2000
2026
 
2001
2027
  async open(): Promise<void> {
2002
- const jeepSQlEL = document.querySelector("jeep-sqlite")
2003
- console.log(`in definition open jeepSQlEL: `,jeepSQlEL )
2004
-
2005
2028
  try {
2006
2029
  await this.sqlite.open({
2007
2030
  database: this.dbName,
@@ -2025,8 +2048,9 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
2025
2048
  }
2026
2049
  async beginTransaction(): Promise<capSQLiteChanges> {
2027
2050
  try {
2028
- const changes: capSQLiteChanges = await this.sqlite
2029
- .beginTransaction({database: this.dbName});
2051
+ const changes: capSQLiteChanges = await this.sqlite.beginTransaction({
2052
+ database: this.dbName,
2053
+ });
2030
2054
  return Promise.resolve(changes);
2031
2055
  } catch (err) {
2032
2056
  return Promise.reject(err);
@@ -2034,8 +2058,9 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
2034
2058
  }
2035
2059
  async commitTransaction(): Promise<capSQLiteChanges> {
2036
2060
  try {
2037
- const changes: capSQLiteChanges = await this.sqlite
2038
- .commitTransaction({database: this.dbName});
2061
+ const changes: capSQLiteChanges = await this.sqlite.commitTransaction({
2062
+ database: this.dbName,
2063
+ });
2039
2064
  return Promise.resolve(changes);
2040
2065
  } catch (err) {
2041
2066
  return Promise.reject(err);
@@ -2043,22 +2068,24 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
2043
2068
  }
2044
2069
  async rollbackTransaction(): Promise<capSQLiteChanges> {
2045
2070
  try {
2046
- const changes: capSQLiteChanges = await this.sqlite
2047
- .rollbackTransaction({database: this.dbName});
2071
+ const changes: capSQLiteChanges = await this.sqlite.rollbackTransaction({
2072
+ database: this.dbName,
2073
+ });
2048
2074
  return Promise.resolve(changes);
2049
2075
  } catch (err) {
2050
2076
  return Promise.reject(err);
2051
2077
  }
2052
- }
2078
+ }
2053
2079
  async isTransactionActive(): Promise<capSQLiteResult> {
2054
2080
  try {
2055
- const result: capSQLiteResult = await this.sqlite
2056
- .isTransactionActive({database: this.dbName});
2081
+ const result: capSQLiteResult = await this.sqlite.isTransactionActive({
2082
+ database: this.dbName,
2083
+ });
2057
2084
  return Promise.resolve(result);
2058
2085
  } catch (err) {
2059
2086
  return Promise.reject(err);
2060
2087
  }
2061
- }
2088
+ }
2062
2089
 
2063
2090
  async loadExtension(path: string): Promise<void> {
2064
2091
  try {
@@ -2121,7 +2148,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
2121
2148
  async execute(
2122
2149
  statements: string,
2123
2150
  transaction = true,
2124
- isSQL92 = true
2151
+ isSQL92 = true,
2125
2152
  ): Promise<capSQLiteChanges> {
2126
2153
  try {
2127
2154
  if (!this.readonly) {
@@ -2130,7 +2157,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
2130
2157
  statements: statements,
2131
2158
  transaction: transaction,
2132
2159
  readonly: false,
2133
- isSQL92: isSQL92
2160
+ isSQL92: isSQL92,
2134
2161
  });
2135
2162
  return Promise.resolve(res);
2136
2163
  } else {
@@ -2140,7 +2167,11 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
2140
2167
  return Promise.reject(err);
2141
2168
  }
2142
2169
  }
2143
- async query(statement: string, values?: any[], isSQL92 = true): Promise<DBSQLiteValues> {
2170
+ async query(
2171
+ statement: string,
2172
+ values?: any[],
2173
+ isSQL92 = true,
2174
+ ): Promise<DBSQLiteValues> {
2144
2175
  let res: any;
2145
2176
  try {
2146
2177
  if (values && values.length > 0) {
@@ -2149,7 +2180,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
2149
2180
  statement: statement,
2150
2181
  values: values,
2151
2182
  readonly: this.readonly,
2152
- isSql92 : true
2183
+ isSql92: true,
2153
2184
  });
2154
2185
  } else {
2155
2186
  res = await this.sqlite.query({
@@ -2157,7 +2188,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
2157
2188
  statement: statement,
2158
2189
  values: [],
2159
2190
  readonly: this.readonly,
2160
- isSQL92: isSQL92
2191
+ isSQL92: isSQL92,
2161
2192
  });
2162
2193
  }
2163
2194
 
@@ -2173,7 +2204,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
2173
2204
  values?: any[],
2174
2205
  transaction = true,
2175
2206
  returnMode = 'no',
2176
- isSQL92 = true
2207
+ isSQL92 = true,
2177
2208
  ): Promise<capSQLiteChanges> {
2178
2209
  let res: any;
2179
2210
  try {
@@ -2189,7 +2220,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
2189
2220
  transaction: transaction,
2190
2221
  readonly: false,
2191
2222
  returnMode: mRetMode,
2192
- isSQL92: true
2223
+ isSQL92: true,
2193
2224
  });
2194
2225
  // }
2195
2226
  } else {
@@ -2203,7 +2234,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
2203
2234
  transaction: transaction,
2204
2235
  readonly: false,
2205
2236
  returnMode: mRetMode,
2206
- isSQL92: isSQL92
2237
+ isSQL92: isSQL92,
2207
2238
  });
2208
2239
  }
2209
2240
  // reorder rows for ios
@@ -2220,7 +2251,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
2220
2251
  set: capSQLiteSet[],
2221
2252
  transaction = true,
2222
2253
  returnMode = 'no',
2223
- isSQL92 = true
2254
+ isSQL92 = true,
2224
2255
  ): Promise<capSQLiteChanges> {
2225
2256
  let res: any;
2226
2257
  try {
@@ -2231,7 +2262,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
2231
2262
  transaction: transaction,
2232
2263
  readonly: false,
2233
2264
  returnMode: returnMode,
2234
- isSQL92: isSQL92
2265
+ isSQL92: isSQL92,
2235
2266
  });
2236
2267
  // }
2237
2268
  // reorder rows for ios
@@ -2368,21 +2399,23 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
2368
2399
  }
2369
2400
 
2370
2401
  async executeTransaction(
2371
- txn: { statement: string; values?: any[]}[],
2372
- isSQL92 = true
2402
+ txn: { statement: string; values?: any[] }[],
2403
+ isSQL92 = true,
2373
2404
  ): Promise<capSQLiteChanges> {
2374
2405
  let changes = 0;
2375
2406
  let isActive = false;
2376
2407
  if (!this.readonly) {
2377
2408
  try {
2378
- await this.sqlite.beginTransaction({
2379
- database: this.dbName
2409
+ await this.sqlite.beginTransaction({
2410
+ database: this.dbName,
2380
2411
  });
2381
2412
  isActive = await this.sqlite.isTransactionActive({
2382
- database: this.dbName
2413
+ database: this.dbName,
2383
2414
  });
2384
- if(!isActive) {
2385
- return Promise.reject('After Begin Transaction, no transaction active');
2415
+ if (!isActive) {
2416
+ return Promise.reject(
2417
+ 'After Begin Transaction, no transaction active',
2418
+ );
2386
2419
  }
2387
2420
  } catch (err) {
2388
2421
  return Promise.reject(err);
@@ -2400,7 +2433,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
2400
2433
  transaction: false,
2401
2434
  readonly: false,
2402
2435
  returnMode: retMode,
2403
- isSQL92: isSQL92
2436
+ isSQL92: isSQL92,
2404
2437
  });
2405
2438
  if (ret.changes.changes <= 0) {
2406
2439
  throw new Error('Error in transaction method run ');
@@ -2414,7 +2447,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
2414
2447
  readonly: false,
2415
2448
  });
2416
2449
  isActive = await this.sqlite.isTransactionActive({
2417
- database: this.dbName
2450
+ database: this.dbName,
2418
2451
  });
2419
2452
  if (ret.changes.changes < 0) {
2420
2453
  throw new Error('Error in transaction method execute ');
@@ -2423,33 +2456,32 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
2423
2456
  }
2424
2457
  }
2425
2458
  isActive = await this.sqlite.isTransactionActive({
2426
- database: this.dbName
2459
+ database: this.dbName,
2427
2460
  });
2428
- if(isActive) {
2461
+ if (isActive) {
2429
2462
  const retC = await this.sqlite.commitTransaction({
2430
- database: this.dbName
2463
+ database: this.dbName,
2431
2464
  });
2432
2465
  changes += retC.changes.changes;
2433
2466
  }
2434
- const retChanges = {changes:{changes:changes}}
2467
+ const retChanges = { changes: { changes: changes } };
2435
2468
  return Promise.resolve(retChanges);
2436
2469
  } catch (err: any) {
2437
2470
  const msg = err.message ? err.message : err;
2438
2471
  isActive = await this.sqlite.isTransactionActive({
2439
- database: this.dbName
2472
+ database: this.dbName,
2440
2473
  });
2441
- if(isActive) {
2474
+ if (isActive) {
2442
2475
  await this.sqlite.rollbackTransaction({
2443
2476
  database: this.dbName,
2444
2477
  });
2445
2478
  }
2446
2479
  return Promise.reject(msg);
2447
2480
  }
2448
-
2449
2481
  } else {
2450
- return Promise.reject('not allowed in read-only mode');
2482
+ return Promise.reject('not allowed in read-only mode');
2451
2483
  }
2452
- }
2484
+ }
2453
2485
  private async reorderRows(res: any): Promise<any> {
2454
2486
  const retRes: any = res;
2455
2487
  if (res?.values && typeof res.values[0] === 'object') {
package/src/web.ts CHANGED
@@ -217,7 +217,9 @@ export class CapacitorSQLiteWeb
217
217
  throw new Error(`${err}`);
218
218
  }
219
219
  }
220
- async commitTransaction(options: capSQLiteOptions): Promise<capSQLiteChanges> {
220
+ async commitTransaction(
221
+ options: capSQLiteOptions,
222
+ ): Promise<capSQLiteChanges> {
221
223
  this.ensureJeepSqliteIsAvailable();
222
224
  this.ensureWebstoreIsOpen();
223
225
 
@@ -229,7 +231,9 @@ export class CapacitorSQLiteWeb
229
231
  throw new Error(`${err}`);
230
232
  }
231
233
  }
232
- async rollbackTransaction(options: capSQLiteOptions): Promise<capSQLiteChanges> {
234
+ async rollbackTransaction(
235
+ options: capSQLiteOptions,
236
+ ): Promise<capSQLiteChanges> {
233
237
  this.ensureJeepSqliteIsAvailable();
234
238
  this.ensureWebstoreIsOpen();
235
239
 
@@ -241,7 +245,9 @@ export class CapacitorSQLiteWeb
241
245
  throw new Error(`${err}`);
242
246
  }
243
247
  }
244
- async isTransactionActive(options: capSQLiteOptions): Promise<capSQLiteResult> {
248
+ async isTransactionActive(
249
+ options: capSQLiteOptions,
250
+ ): Promise<capSQLiteResult> {
245
251
  this.ensureJeepSqliteIsAvailable();
246
252
  this.ensureWebstoreIsOpen();
247
253
 
@@ -252,7 +258,7 @@ export class CapacitorSQLiteWeb
252
258
  } catch (err) {
253
259
  throw new Error(`${err}`);
254
260
  }
255
- }
261
+ }
256
262
 
257
263
  async getTableList(options: capSQLiteOptions): Promise<capSQLiteValues> {
258
264
  this.ensureJeepSqliteIsAvailable();