@capacitor-community/sqlite 5.0.7 → 5.2.3
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 +11 -1
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLite.java +3 -2
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java +3 -1
- package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +2 -2
- package/dist/esm/definitions.d.ts +21 -2
- package/dist/esm/definitions.js +2 -1
- package/dist/esm/definitions.js.map +1 -1
- package/dist/plugin.cjs.js +2 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +2 -1
- package/dist/plugin.js.map +1 -1
- package/electron/dist/plugin.js +5 -4
- package/electron/dist/plugin.js.map +1 -1
- package/ios/Plugin/CapacitorSQLite.swift +4 -2
- package/ios/Plugin/CapacitorSQLitePlugin.swift +3 -1
- package/ios/Plugin/Database.swift +3 -2
- package/ios/Plugin/Utils/UtilsDelete.swift +3 -3
- package/ios/Plugin/Utils/UtilsSQLCipher.swift +3 -2
- package/package.json +8 -5
- package/src/definitions.ts +25 -4
|
@@ -1285,7 +1285,7 @@ enum CapacitorSQLiteError: Error {
|
|
|
1285
1285
|
|
|
1286
1286
|
// MARK: - exportToJson
|
|
1287
1287
|
|
|
1288
|
-
@objc func exportToJson(_ dbName: String, expMode: String, readonly: Bool)
|
|
1288
|
+
@objc func exportToJson(_ dbName: String, expMode: String, readonly: Bool, encrypted: Bool)
|
|
1289
1289
|
throws -> [String: Any] {
|
|
1290
1290
|
if isInit {
|
|
1291
1291
|
let mDbName = CapacitorSQLite.getDatabaseName(dbName: dbName)
|
|
@@ -1298,7 +1298,9 @@ enum CapacitorSQLiteError: Error {
|
|
|
1298
1298
|
|
|
1299
1299
|
do {
|
|
1300
1300
|
let res: [String: Any] = try
|
|
1301
|
-
mDb.exportToJson(
|
|
1301
|
+
mDb.exportToJson(
|
|
1302
|
+
expMode: expMode,
|
|
1303
|
+
isEncrypted: encrypted)
|
|
1302
1304
|
if res.count == 0 {
|
|
1303
1305
|
var msg: String = "return Object is empty "
|
|
1304
1306
|
msg.append("No data to synchronize")
|
|
@@ -1214,11 +1214,13 @@ public class CapacitorSQLitePlugin: CAPPlugin {
|
|
|
1214
1214
|
return
|
|
1215
1215
|
}
|
|
1216
1216
|
let readOnly: Bool = call.getBool("readonly") ?? false
|
|
1217
|
+
let encrypted: Bool = call.getBool("encrypted") ?? false
|
|
1217
1218
|
|
|
1218
1219
|
do {
|
|
1219
1220
|
let res: [String: Any] = try implementation?
|
|
1220
1221
|
.exportToJson(dbName, expMode: expMode,
|
|
1221
|
-
readonly: readOnly
|
|
1222
|
+
readonly: readOnly,
|
|
1223
|
+
encrypted: encrypted) ?? [:]
|
|
1222
1224
|
retHandler.rJsonSQLite(call: call, ret: res)
|
|
1223
1225
|
return
|
|
1224
1226
|
} catch CapacitorSQLiteError.failed(let message) {
|
|
@@ -652,7 +652,8 @@ class Database {
|
|
|
652
652
|
|
|
653
653
|
// MARK: - ExportToJson
|
|
654
654
|
|
|
655
|
-
func exportToJson(expMode: String
|
|
655
|
+
func exportToJson(expMode: String, isEncrypted: Bool)
|
|
656
|
+
throws -> [String: Any] {
|
|
656
657
|
var retObj: [String: Any] = [:]
|
|
657
658
|
|
|
658
659
|
do {
|
|
@@ -670,7 +671,7 @@ class Database {
|
|
|
670
671
|
"expMode": expMode, "version": dbVersion]
|
|
671
672
|
retObj = try ExportToJson
|
|
672
673
|
.createExportObject(mDB: self, data: data)
|
|
673
|
-
if isEncryption && encrypted {
|
|
674
|
+
if isEncryption && encrypted && isEncrypted {
|
|
674
675
|
retObj["overwrite"] = true
|
|
675
676
|
let base64Str = try UtilsJson.encryptDictionaryToBase64(
|
|
676
677
|
retObj,
|
|
@@ -33,7 +33,7 @@ class UtilsDelete {
|
|
|
33
33
|
initColNames: [String],
|
|
34
34
|
values: [Any]) throws -> Bool {
|
|
35
35
|
do {
|
|
36
|
-
|
|
36
|
+
let retBool: Bool = true
|
|
37
37
|
let result = try getReferences(mDB: mDB,
|
|
38
38
|
tableName: tableName)
|
|
39
39
|
let references = result.retRefs
|
|
@@ -95,8 +95,8 @@ class UtilsDelete {
|
|
|
95
95
|
continue
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
let updTableName: String = tableNameWithRefs
|
|
99
|
+
let updColNames: [String] = withRefsNames
|
|
100
100
|
var results: (setStmt: String, uWhereStmt: String)
|
|
101
101
|
results.uWhereStmt = ""
|
|
102
102
|
results.setStmt = ""
|
|
@@ -665,8 +665,9 @@ class UtilsSQLCipher {
|
|
|
665
665
|
"WHERE Statement"
|
|
666
666
|
throw UtilsSQLCipherError.deleteSQL(message: msg)
|
|
667
667
|
}
|
|
668
|
-
|
|
669
|
-
|
|
668
|
+
/*
|
|
669
|
+
let curTime = UtilsDelete.getCurrentTimeAsInteger()
|
|
670
|
+
*/
|
|
670
671
|
let setStmt = "sql_deleted = 1"
|
|
671
672
|
// Find REFERENCIES if any and update the sql_deleted
|
|
672
673
|
// column
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor-community/sqlite",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.3",
|
|
4
4
|
"description": "Community plugin for native & electron SQLite databases",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
],
|
|
18
18
|
"author": "Jean Pierre Quéau",
|
|
19
19
|
"license": "MIT",
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=16.0.0"
|
|
22
|
+
},
|
|
20
23
|
"repository": {
|
|
21
24
|
"type": "git",
|
|
22
25
|
"url": "git+https://github.com/capacitor-community/sqlite.git"
|
|
@@ -56,11 +59,11 @@
|
|
|
56
59
|
"prepublishOnly": "npm run build && npm run build-electron && npm run docgen"
|
|
57
60
|
},
|
|
58
61
|
"devDependencies": {
|
|
59
|
-
"@capacitor/android": "^5.
|
|
60
|
-
"@capacitor/cli": "^5.
|
|
61
|
-
"@capacitor/core": "^5.
|
|
62
|
+
"@capacitor/android": "^5.2.3",
|
|
63
|
+
"@capacitor/cli": "^5.2.3",
|
|
64
|
+
"@capacitor/core": "^5.2.3",
|
|
62
65
|
"@capacitor/docgen": "^0.0.17",
|
|
63
|
-
"@capacitor/ios": "^5.
|
|
66
|
+
"@capacitor/ios": "^5.2.3",
|
|
64
67
|
"@ionic/eslint-config": "^0.3.0",
|
|
65
68
|
"@ionic/prettier-config": "^1.0.1",
|
|
66
69
|
"@ionic/swiftlint-config": "^1.1.2",
|
package/src/definitions.ts
CHANGED
|
@@ -699,6 +699,15 @@ export interface capSQLiteExportOptions {
|
|
|
699
699
|
* @since 4.1.0-7
|
|
700
700
|
*/
|
|
701
701
|
readonly?: boolean;
|
|
702
|
+
/**
|
|
703
|
+
* Encrypted
|
|
704
|
+
* When your database is encrypted
|
|
705
|
+
* Choose the export Json Object
|
|
706
|
+
* Encrypted (true) / Unencrypted (false)
|
|
707
|
+
* default false
|
|
708
|
+
* @since 5.0.8
|
|
709
|
+
*/
|
|
710
|
+
encrypted?: boolean
|
|
702
711
|
}
|
|
703
712
|
export interface capSQLiteFromAssetsOptions {
|
|
704
713
|
/**
|
|
@@ -1610,8 +1619,8 @@ export class SQLiteConnection implements ISQLiteConnection {
|
|
|
1610
1619
|
async checkConnectionsConsistency(): Promise<capSQLiteResult> {
|
|
1611
1620
|
try {
|
|
1612
1621
|
const keys = [...this._connectionDict.keys()];
|
|
1613
|
-
const openModes = [];
|
|
1614
|
-
const dbNames = [];
|
|
1622
|
+
const openModes: string[] = [];
|
|
1623
|
+
const dbNames: string[] = [];
|
|
1615
1624
|
for (const key of keys) {
|
|
1616
1625
|
openModes.push(key.substring(0, 2));
|
|
1617
1626
|
dbNames.push(key.substring(3));
|
|
@@ -1850,6 +1859,8 @@ export interface ISQLiteDBConnection {
|
|
|
1850
1859
|
/**
|
|
1851
1860
|
* Execute SQLite DB Connection Statements
|
|
1852
1861
|
* @param statements
|
|
1862
|
+
* @param transaction (optional)
|
|
1863
|
+
* @param isSQL92 (optional)
|
|
1853
1864
|
* @returns Promise<capSQLiteChanges>
|
|
1854
1865
|
* @since 2.9.0 refactor
|
|
1855
1866
|
*/
|
|
@@ -1858,6 +1869,7 @@ export interface ISQLiteDBConnection {
|
|
|
1858
1869
|
* Execute SQLite DB Connection Query
|
|
1859
1870
|
* @param statement
|
|
1860
1871
|
* @param values (optional)
|
|
1872
|
+
* @param isSQL92 (optional)
|
|
1861
1873
|
* @returns Promise<Promise<DBSQLiteValues>
|
|
1862
1874
|
* @since 2.9.0 refactor
|
|
1863
1875
|
*/
|
|
@@ -1866,6 +1878,9 @@ export interface ISQLiteDBConnection {
|
|
|
1866
1878
|
* Execute SQLite DB Connection Raw Statement
|
|
1867
1879
|
* @param statement
|
|
1868
1880
|
* @param values (optional)
|
|
1881
|
+
* @param transaction (optional)
|
|
1882
|
+
* @param returnMode (optional)
|
|
1883
|
+
* @param isSQL92 (optional)
|
|
1869
1884
|
* @returns Promise<capSQLiteChanges>
|
|
1870
1885
|
* @since 2.9.0 refactor
|
|
1871
1886
|
*/
|
|
@@ -1879,6 +1894,9 @@ export interface ISQLiteDBConnection {
|
|
|
1879
1894
|
/**
|
|
1880
1895
|
* Execute SQLite DB Connection Set
|
|
1881
1896
|
* @param set
|
|
1897
|
+
* @param transaction (optional)
|
|
1898
|
+
* @param returnMode (optional)
|
|
1899
|
+
* @param isSQL92 (optional)
|
|
1882
1900
|
* @returns Promise<capSQLiteChanges>
|
|
1883
1901
|
* @since 2.9.0 refactor
|
|
1884
1902
|
*/
|
|
@@ -1939,10 +1957,11 @@ export interface ISQLiteDBConnection {
|
|
|
1939
1957
|
/**
|
|
1940
1958
|
* Export the given database to a JSON Object
|
|
1941
1959
|
* @param mode
|
|
1960
|
+
* @param encrypted (optional) since 5.0.8 not for Web platform
|
|
1942
1961
|
* @returns Promise<capSQLiteJson>
|
|
1943
1962
|
* @since 2.9.0 refactor
|
|
1944
1963
|
*/
|
|
1945
|
-
exportToJson(mode: string): Promise<capSQLiteJson>;
|
|
1964
|
+
exportToJson(mode: string, encrypted?: boolean): Promise<capSQLiteJson>;
|
|
1946
1965
|
/**
|
|
1947
1966
|
* Remove rows with sql_deleted = 1 after an export
|
|
1948
1967
|
* @returns Promise<void>
|
|
@@ -1980,6 +1999,7 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
1980
1999
|
}
|
|
1981
2000
|
|
|
1982
2001
|
async open(): Promise<void> {
|
|
2002
|
+
|
|
1983
2003
|
try {
|
|
1984
2004
|
await this.sqlite.open({
|
|
1985
2005
|
database: this.dbName,
|
|
@@ -2316,12 +2336,13 @@ export class SQLiteDBConnection implements ISQLiteDBConnection {
|
|
|
2316
2336
|
return Promise.reject(err);
|
|
2317
2337
|
}
|
|
2318
2338
|
}
|
|
2319
|
-
async exportToJson(mode: string): Promise<capSQLiteJson> {
|
|
2339
|
+
async exportToJson(mode: string, encrypted = false): Promise<capSQLiteJson> {
|
|
2320
2340
|
try {
|
|
2321
2341
|
const res: any = await this.sqlite.exportToJson({
|
|
2322
2342
|
database: this.dbName,
|
|
2323
2343
|
jsonexportmode: mode,
|
|
2324
2344
|
readonly: this.readonly,
|
|
2345
|
+
encrypted: encrypted,
|
|
2325
2346
|
});
|
|
2326
2347
|
return Promise.resolve(res);
|
|
2327
2348
|
} catch (err) {
|