@capacitor-community/sqlite 3.3.2 → 3.3.3-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.
Files changed (37) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +28 -2
  3. package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLite.java +105 -7
  4. package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java +126 -4
  5. package/android/src/main/java/com/getcapacitor/community/database/sqlite/RetHandler.java +48 -0
  6. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +75 -47
  7. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/JsonIndex.java +5 -4
  8. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsFile.java +9 -0
  9. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsNCDatabase.java +26 -0
  10. package/dist/esm/definitions.d.ts +131 -2
  11. package/dist/esm/definitions.js +74 -0
  12. package/dist/esm/definitions.js.map +1 -1
  13. package/dist/esm/web.d.ts +6 -1
  14. package/dist/esm/web.js +19 -0
  15. package/dist/esm/web.js.map +1 -1
  16. package/dist/plugin.cjs.js +93 -0
  17. package/dist/plugin.cjs.js.map +1 -1
  18. package/dist/plugin.js +93 -0
  19. package/dist/plugin.js.map +1 -1
  20. package/electron/dist/plugin.js +20 -1
  21. package/electron/dist/plugin.js.map +1 -1
  22. package/ios/Plugin/CapacitorSQLite.swift +139 -20
  23. package/ios/Plugin/CapacitorSQLitePlugin.m +5 -0
  24. package/ios/Plugin/CapacitorSQLitePlugin.swift +269 -64
  25. package/ios/Plugin/Database.swift +63 -28
  26. package/ios/Plugin/ImportExportJson/ImportFromJson.swift +2 -1
  27. package/ios/Plugin/ImportExportJson/JsonSQLite.swift +1 -1
  28. package/ios/Plugin/ReturnHandler.swift +25 -0
  29. package/ios/Plugin/SqliteConfig.swift +10 -0
  30. package/ios/Plugin/Utils/UtilsEncryption.swift +10 -7
  31. package/ios/Plugin/Utils/UtilsFile.swift +195 -33
  32. package/ios/Plugin/Utils/UtilsMigrate.swift +11 -44
  33. package/ios/Plugin/Utils/UtilsNCDatabase.swift +31 -0
  34. package/ios/Plugin/Utils/UtilsSQLCipher.swift +29 -24
  35. package/ios/Plugin/Utils/UtilsSecret.swift +22 -8
  36. package/ios/Plugin/Utils/UtilsUpgrade.swift +6 -2
  37. package/package.json +5 -5
@@ -5,7 +5,7 @@ import Capacitor
5
5
  // swiftlint:disable file_length
6
6
  // swiftlint:disable type_body_length
7
7
  public class CapacitorSQLitePlugin: CAPPlugin {
8
- private let implementation = CapacitorSQLite()
8
+ private var implementation: CapacitorSQLite?
9
9
  private let modeList: [String] = ["no-encryption", "encryption", "secret", "newsecret", "wrongsecret"]
10
10
  private let retHandler: ReturnHandler = ReturnHandler()
11
11
  private var versionUpgrades: [String: [Int: [String: Any]]] = [:]
@@ -13,6 +13,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
13
13
  var exportObserver: Any?
14
14
 
15
15
  override public func load() {
16
+ self.implementation = CapacitorSQLite(config: sqliteConfig())
16
17
  self.addObserversToNotificationCenter()
17
18
  }
18
19
  deinit {
@@ -24,16 +25,18 @@ public class CapacitorSQLitePlugin: CAPPlugin {
24
25
 
25
26
  @objc func echo(_ call: CAPPluginCall) {
26
27
  let value = call.getString("value") ?? ""
27
- call.resolve([
28
- "value": implementation.echo(value)
29
- ])
28
+ if let retValue: String = implementation?.echo(value) {
29
+ call.resolve([
30
+ "value": retValue
31
+ ])
32
+ }
30
33
  }
31
34
 
32
35
  // MARK: - IsSecretStored
33
36
 
34
37
  @objc func isSecretStored(_ call: CAPPluginCall) {
35
38
  do {
36
- let res = try implementation.isSecretStored()
39
+ let res = try implementation?.isSecretStored()
37
40
  var bRes: Bool = false
38
41
  if res == 1 {
39
42
  bRes = true
@@ -64,7 +67,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
64
67
  return
65
68
  }
66
69
  do {
67
- try implementation.setEncryptionSecret(passphrase: passphrase)
70
+ try implementation?.setEncryptionSecret(passphrase: passphrase)
68
71
  retHandler.rResult(call: call)
69
72
  return
70
73
  } catch CapacitorSQLiteError.failed(let message) {
@@ -96,7 +99,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
96
99
  return
97
100
  }
98
101
  do {
99
- try implementation.changeEncryptionSecret(passphrase: passphrase, oldPassphrase: oldPassphrase)
102
+ try implementation?.changeEncryptionSecret(passphrase: passphrase, oldPassphrase: oldPassphrase)
100
103
  retHandler.rResult(call: call)
101
104
  return
102
105
  } catch CapacitorSQLiteError.failed(let message) {
@@ -135,11 +138,11 @@ public class CapacitorSQLitePlugin: CAPPlugin {
135
138
  upgDict = cUpgDict
136
139
  }
137
140
  do {
138
- try implementation.createConnection(dbName,
139
- encrypted: encrypted,
140
- mode: inMode,
141
- version: version,
142
- vUpgDict: upgDict)
141
+ try implementation?.createConnection(dbName,
142
+ encrypted: encrypted,
143
+ mode: inMode,
144
+ version: version,
145
+ vUpgDict: upgDict)
143
146
  retHandler.rResult(call: call)
144
147
  return
145
148
  } catch CapacitorSQLiteError.failed(let message) {
@@ -164,7 +167,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
164
167
  return
165
168
  }
166
169
  do {
167
- try implementation.open(dbName)
170
+ try implementation?.open(dbName)
168
171
  retHandler.rResult(call: call)
169
172
  return
170
173
  } catch CapacitorSQLiteError.failed(let message) {
@@ -189,7 +192,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
189
192
  return
190
193
  }
191
194
  do {
192
- try implementation.close(dbName)
195
+ try implementation?.close(dbName)
193
196
  retHandler.rResult(call: call)
194
197
  return
195
198
  } catch CapacitorSQLiteError.failed(let message) {
@@ -204,6 +207,39 @@ public class CapacitorSQLitePlugin: CAPPlugin {
204
207
  }
205
208
  }
206
209
 
210
+ // MARK: - GetUrl
211
+
212
+ @objc func getUrl(_ call: CAPPluginCall) {
213
+ guard let dbName = call.options["database"] as? String else {
214
+ retHandler.rResult(
215
+ call: call,
216
+ message: "GetUrl: Must provide a database name")
217
+ return
218
+ }
219
+ do {
220
+ let res: String = try implementation?.getUrl(dbName) ?? ""
221
+ if res.count > 0 {
222
+ retHandler.rUrl(call: call, ret: res)
223
+ return
224
+ } else {
225
+ retHandler.rUrl(
226
+ call: call, ret: "",
227
+ message: "getUrl: No path returned")
228
+ return
229
+ }
230
+ } catch CapacitorSQLiteError.failed(let message) {
231
+ retHandler.rUrl(
232
+ call: call, ret: "",
233
+ message: "getUrl: \(message)")
234
+ return
235
+ } catch let error {
236
+ retHandler.rUrl(
237
+ call: call, ret: "",
238
+ message: "getUrl: \(error)")
239
+ return
240
+ }
241
+ }
242
+
207
243
  // MARK: - getVersion
208
244
 
209
245
  @objc func getVersion(_ call: CAPPluginCall) {
@@ -214,9 +250,15 @@ public class CapacitorSQLitePlugin: CAPPlugin {
214
250
  return
215
251
  }
216
252
  do {
217
- let version: NSNumber = try implementation.getVersion(dbName)
218
- retHandler.rVersion(call: call, ret: version)
219
- return
253
+ if let version: NSNumber = try implementation?
254
+ .getVersion(dbName) {
255
+ retHandler.rVersion(call: call, ret: version)
256
+ return
257
+ } else {
258
+ let msg = "GetVersion: Does not return a valid version"
259
+ retHandler.rVersion(call: call, message: msg)
260
+ return
261
+ }
220
262
  } catch CapacitorSQLiteError.failed(let message) {
221
263
  let msg = "GetVersion: \(message)"
222
264
  retHandler.rVersion(call: call, message: msg)
@@ -239,7 +281,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
239
281
  return
240
282
  }
241
283
  do {
242
- try implementation.closeConnection(dbName)
284
+ try implementation?.closeConnection(dbName)
243
285
  retHandler.rResult(call: call)
244
286
  return
245
287
  } catch CapacitorSQLiteError.failed(let message) {
@@ -266,7 +308,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
266
308
  return
267
309
  }
268
310
  do {
269
- let res = try implementation.checkConnectionsConsistency(dbNames)
311
+ let res = try implementation?.checkConnectionsConsistency(dbNames)
270
312
  var bRes: Bool = false
271
313
  if res == 1 {
272
314
  bRes = true
@@ -291,7 +333,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
291
333
  return
292
334
  }
293
335
  do {
294
- let res = try implementation.isDatabase(dbName)
336
+ let res = try implementation?.isDatabase(dbName)
295
337
  var bRes: Bool = false
296
338
  if res == 1 {
297
339
  bRes = true
@@ -326,7 +368,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
326
368
  return
327
369
  }
328
370
  do {
329
- let res = try implementation.isTableExists(dbName, tableName: tableName)
371
+ let res = try implementation?.isTableExists(dbName, tableName: tableName)
330
372
  var bRes: Bool = false
331
373
  if res == 1 {
332
374
  bRes = true
@@ -349,7 +391,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
349
391
  @objc func getDatabaseList(_ call: CAPPluginCall) {
350
392
 
351
393
  do {
352
- let res = try implementation.getDatabaseList()
394
+ let res = try implementation?.getDatabaseList() ?? []
353
395
  retHandler.rValues(call: call, ret: res)
354
396
  return
355
397
  } catch CapacitorSQLiteError.failed(let message) {
@@ -376,7 +418,8 @@ public class CapacitorSQLitePlugin: CAPPlugin {
376
418
  }
377
419
 
378
420
  do {
379
- let res = try implementation.getMigratableDbList(dbFolder)
421
+ let res = try implementation?
422
+ .getMigratableDbList(dbFolder) ?? []
380
423
  retHandler.rValues(call: call, ret: res)
381
424
  return
382
425
  } catch CapacitorSQLiteError.failed(let message) {
@@ -406,7 +449,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
406
449
  }
407
450
  }
408
451
  do {
409
- try implementation.addSQLiteSuffix(folderPath, dbList: dbList)
452
+ try implementation?.addSQLiteSuffix(folderPath, dbList: dbList)
410
453
  retHandler.rResult(call: call)
411
454
  return
412
455
  } catch CapacitorSQLiteError.failed(let message) {
@@ -435,7 +478,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
435
478
  }
436
479
  }
437
480
  do {
438
- try implementation.deleteOldDatabases(folderPath, dbList: dbList)
481
+ try implementation?.deleteOldDatabases(folderPath, dbList: dbList)
439
482
  retHandler.rResult(call: call)
440
483
  return
441
484
  } catch CapacitorSQLiteError.failed(let message) {
@@ -470,10 +513,17 @@ public class CapacitorSQLitePlugin: CAPPlugin {
470
513
  return
471
514
  }
472
515
  do {
473
- let res = try implementation.execute(dbName, statements: statements,
474
- transaction: transaction)
475
- retHandler.rChanges(call: call, ret: res)
476
- return
516
+ if let res = try implementation?
517
+ .execute(dbName, statements: statements,
518
+ transaction: transaction) {
519
+ retHandler.rChanges(call: call, ret: res)
520
+ return
521
+ } else {
522
+ retHandler.rChanges(
523
+ call: call, ret: ["changes": -1],
524
+ message: "Execute: Does not return a valid execute")
525
+ return
526
+ }
477
527
  } catch CapacitorSQLiteError.failed(let message) {
478
528
  retHandler.rChanges(
479
529
  call: call, ret: ["changes": -1],
@@ -526,10 +576,17 @@ public class CapacitorSQLitePlugin: CAPPlugin {
526
576
  }
527
577
  let transaction: Bool = call.getBool("transaction") ?? true
528
578
  do {
529
- let res = try implementation.executeSet(dbName, set: set,
530
- transaction: transaction)
531
- retHandler.rChanges(call: call, ret: res)
532
- return
579
+ if let res = try implementation?.executeSet(dbName, set: set,
580
+ transaction: transaction) {
581
+ retHandler.rChanges(call: call, ret: res)
582
+ return
583
+ } else {
584
+ retHandler.rChanges(
585
+ call: call, ret: ["changes": -1],
586
+ message: "ExecuteSet: Does not return a valid executeSet")
587
+ return
588
+
589
+ }
533
590
  } catch CapacitorSQLiteError.failed(let message) {
534
591
  retHandler.rChanges(
535
592
  call: call, ret: ["changes": -1],
@@ -547,6 +604,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
547
604
 
548
605
  // MARK: - Run
549
606
 
607
+ // swiftlint:disable function_body_length
550
608
  @objc func run(_ call: CAPPluginCall) {
551
609
  guard let dbName = call.options["database"] as? String else {
552
610
  retHandler.rChanges(
@@ -572,13 +630,19 @@ public class CapacitorSQLitePlugin: CAPPlugin {
572
630
  }
573
631
  let transaction: Bool = call.getBool("transaction") ?? true
574
632
  do {
575
- let res = try
576
- implementation.run(dbName,
577
- statement: statement,
578
- values: values,
579
- transaction: transaction)
580
- retHandler.rChanges(call: call, ret: res)
581
- return
633
+ if let res = try
634
+ implementation?.run(dbName,
635
+ statement: statement,
636
+ values: values,
637
+ transaction: transaction) {
638
+ retHandler.rChanges(call: call, ret: res)
639
+ return
640
+ } else {
641
+ retHandler.rChanges(
642
+ call: call, ret: ["changes": -1],
643
+ message: "Run: Does not return a valid run")
644
+ return
645
+ }
582
646
  } catch CapacitorSQLiteError.failed(let message) {
583
647
  retHandler.rChanges(
584
648
  call: call, ret: ["changes": -1],
@@ -592,9 +656,11 @@ public class CapacitorSQLitePlugin: CAPPlugin {
592
656
  }
593
657
 
594
658
  }
659
+ // swiftlint:enable function_body_length
595
660
 
596
661
  // MARK: - Query
597
662
 
663
+ // swiftlint:disable function_body_length
598
664
  @objc func query(_ call: CAPPluginCall) {
599
665
  guard let dbName = call.options["database"]
600
666
  as? String else {
@@ -622,12 +688,19 @@ public class CapacitorSQLitePlugin: CAPPlugin {
622
688
 
623
689
  }
624
690
  do {
625
- let res = try
626
- implementation.query(dbName,
627
- statement: statement,
628
- values: values)
629
- retHandler.rValues(call: call, ret: res)
630
- return
691
+ if let res = try
692
+ implementation?.query(dbName,
693
+ statement: statement,
694
+ values: values) {
695
+ retHandler.rValues(call: call, ret: res)
696
+ return
697
+ } else {
698
+ retHandler.rValues(
699
+ call: call, ret: [],
700
+ message: "Query: Does not return a valid query")
701
+ return
702
+
703
+ }
631
704
  } catch CapacitorSQLiteError.failed(let message) {
632
705
  retHandler.rValues(
633
706
  call: call, ret: [],
@@ -641,6 +714,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
641
714
  }
642
715
 
643
716
  }
717
+ // swiftlint:enable function_body_length
644
718
 
645
719
  // MARK: - isDBExists
646
720
 
@@ -653,7 +727,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
653
727
  return
654
728
  }
655
729
  do {
656
- let res = try implementation.isDBExists(dbName)
730
+ let res = try implementation?.isDBExists(dbName)
657
731
  var bRes: Bool = false
658
732
  if res == 1 {
659
733
  bRes = true
@@ -683,7 +757,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
683
757
  return
684
758
  }
685
759
  do {
686
- let res = try implementation.isDBOpen(dbName)
760
+ let res = try implementation?.isDBOpen(dbName)
687
761
  var bRes: Bool = false
688
762
  if res == 1 {
689
763
  bRes = true
@@ -712,7 +786,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
712
786
  return
713
787
  }
714
788
  do {
715
- try implementation.deleteDatabase(dbName)
789
+ try implementation?.deleteDatabase(dbName)
716
790
  retHandler.rResult(call: call)
717
791
  return
718
792
  } catch CapacitorSQLiteError.failed(let message) {
@@ -737,7 +811,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
737
811
  return
738
812
  }
739
813
  do {
740
- try implementation.isJsonValid(parsingData)
814
+ try implementation?.isJsonValid(parsingData)
741
815
  retHandler.rResult(call: call, ret: true)
742
816
  return
743
817
  } catch CapacitorSQLiteError.failed(let message) {
@@ -762,7 +836,8 @@ public class CapacitorSQLitePlugin: CAPPlugin {
762
836
  return
763
837
  }
764
838
  do {
765
- let res: [String: Int] = try implementation.importFromJson(parsingData)
839
+ let res: [String: Int] = try implementation?
840
+ .importFromJson(parsingData) ?? ["changes": -1]
766
841
  retHandler.rChanges(call: call, ret: res)
767
842
  return
768
843
  } catch CapacitorSQLiteError.failed(let message) {
@@ -808,8 +883,8 @@ public class CapacitorSQLitePlugin: CAPPlugin {
808
883
  }
809
884
 
810
885
  do {
811
- let res: [String: Any] = try implementation
812
- .exportToJson(dbName, expMode: expMode)
886
+ let res: [String: Any] = try implementation?
887
+ .exportToJson(dbName, expMode: expMode) ?? [:]
813
888
  retHandler.rJsonSQLite(call: call, ret: res)
814
889
  return
815
890
  } catch CapacitorSQLiteError.failed(let message) {
@@ -837,8 +912,8 @@ public class CapacitorSQLitePlugin: CAPPlugin {
837
912
  return
838
913
  }
839
914
  do {
840
- let res: NSNumber = try implementation
841
- .createSyncTable(dbName)
915
+ let res: NSNumber = try implementation?
916
+ .createSyncTable(dbName) ?? -1
842
917
  retHandler.rChanges(call: call,
843
918
  ret: ["changes": Int(truncating: res)])
844
919
  return
@@ -872,7 +947,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
872
947
  return
873
948
  }
874
949
  do {
875
- try implementation.setSyncDate( dbName, syncDate: syncDate)
950
+ try implementation?.setSyncDate( dbName, syncDate: syncDate)
876
951
  retHandler.rResult(call: call)
877
952
  return
878
953
  } catch CapacitorSQLiteError.failed(let message) {
@@ -896,7 +971,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
896
971
  return
897
972
  }
898
973
  do {
899
- let res: NSNumber = try implementation.getSyncDate( dbName)
974
+ let res: NSNumber = try implementation?.getSyncDate( dbName) ?? 0
900
975
  retHandler.rSyncDate(call: call,
901
976
  ret: Int64(truncating: res))
902
977
  return
@@ -928,12 +1003,17 @@ public class CapacitorSQLitePlugin: CAPPlugin {
928
1003
  return
929
1004
  }
930
1005
  do {
931
- let upgVersionDict: [Int: [String: Any]] = try
932
- implementation.addUpgradeStatement(dbName,
933
- upgrade: upgrade)
934
- versionUpgrades = ["\(dbName)": upgVersionDict]
935
- retHandler.rResult(call: call)
936
- return
1006
+ if let upgVersionDict: [Int: [String: Any]] = try
1007
+ implementation?.addUpgradeStatement(dbName,
1008
+ upgrade: upgrade) {
1009
+ versionUpgrades = ["\(dbName)": upgVersionDict]
1010
+ retHandler.rResult(call: call)
1011
+ return
1012
+ } else {
1013
+ let msg = "addUpgradeStatement: Error in returned upgVersionDict"
1014
+ retHandler.rResult(call: call, message: msg)
1015
+ return
1016
+ }
937
1017
  } catch CapacitorSQLiteError.failed(let message) {
938
1018
  let msg = "addUpgradeStatement: \(message)"
939
1019
  retHandler.rResult(call: call, message: msg)
@@ -952,7 +1032,7 @@ public class CapacitorSQLitePlugin: CAPPlugin {
952
1032
  let overwrite: Bool = call.getBool("overwrite") ?? true
953
1033
 
954
1034
  do {
955
- try implementation.copyFromAssets(overwrite: overwrite)
1035
+ try implementation?.copyFromAssets(overwrite: overwrite)
956
1036
  retHandler.rResult(call: call)
957
1037
  return
958
1038
  } catch CapacitorSQLiteError.failed(let message) {
@@ -966,6 +1046,123 @@ public class CapacitorSQLitePlugin: CAPPlugin {
966
1046
  }
967
1047
  }
968
1048
 
1049
+ // MARK: - getNCDatabasePath
1050
+
1051
+ @objc func getNCDatabasePath(_ call: CAPPluginCall) {
1052
+ guard let folderPath = call.options["path"] as? String else {
1053
+ retHandler.rPath(call: call, ret: "",
1054
+ message: "getNCDatabasePath: Must provide a folder path")
1055
+ return
1056
+ }
1057
+ guard let dbName = call.options["database"] as? String else {
1058
+ retHandler.rPath(call: call, ret: "",
1059
+ message: "getNCDatabasePath: Must provide a database name")
1060
+ return
1061
+ }
1062
+ do {
1063
+
1064
+ if let path: String = try implementation?
1065
+ .getNCDatabasePath(folderPath, dbName: dbName) {
1066
+ retHandler.rPath(call: call, ret: path)
1067
+ return
1068
+ } else {
1069
+ let msg = "getNCDatabasePath: Does not return a NC path"
1070
+ retHandler.rPath(call: call, ret: "", message: msg)
1071
+ return
1072
+
1073
+ }
1074
+ } catch CapacitorSQLiteError.failed(let message) {
1075
+ let msg = "getNCDatabasePath: \(message)"
1076
+ retHandler.rPath(call: call, ret: "", message: msg)
1077
+ return
1078
+ } catch let error {
1079
+ retHandler.rPath(call: call, ret: "",
1080
+ message: "getNCDatabasePath: \(error)")
1081
+ return
1082
+ }
1083
+ }
1084
+
1085
+ // MARK: - CreateNCConnection
1086
+
1087
+ @objc func createNCConnection(_ call: CAPPluginCall) {
1088
+ guard let dbPath = call.options["databasePath"] as? String else {
1089
+ retHandler.rResult(
1090
+ call: call,
1091
+ message: "CreateNCConnection: Must provide a database path")
1092
+ return
1093
+ }
1094
+ let version: Int = call.getInt("version") ?? 1
1095
+ do {
1096
+ try implementation?.createNCConnection(dbPath,
1097
+ version: version)
1098
+ retHandler.rResult(call: call)
1099
+ return
1100
+ } catch CapacitorSQLiteError.failed(let message) {
1101
+ let msg = "CreateNCConnection: \(message)"
1102
+ retHandler.rResult(call: call, message: msg)
1103
+ return
1104
+ } catch let error {
1105
+ retHandler.rResult(
1106
+ call: call,
1107
+ message: "CreateNCConnection: \(error)")
1108
+ return
1109
+ }
1110
+ }
1111
+
1112
+ // MARK: - CloseNCConnection
1113
+
1114
+ @objc func closeNCConnection(_ call: CAPPluginCall) {
1115
+ guard let dbPath = call.options["databasePath"] as? String else {
1116
+ retHandler.rResult(
1117
+ call: call,
1118
+ message: "CloseNCConnection: Must provide a database path")
1119
+ return
1120
+ }
1121
+ do {
1122
+ try implementation?.closeNCConnection(dbPath)
1123
+ retHandler.rResult(call: call)
1124
+ return
1125
+ } catch CapacitorSQLiteError.failed(let message) {
1126
+ let msg = "CloseNCConnection: \(message)"
1127
+ retHandler.rResult(call: call, message: msg)
1128
+ return
1129
+ } catch let error {
1130
+ retHandler.rResult(
1131
+ call: call,
1132
+ message: "CloseNCConnection: \(error)")
1133
+ return
1134
+ }
1135
+ }
1136
+
1137
+ // MARK: - IsNCDatabase
1138
+
1139
+ @objc func isNCDatabase(_ call: CAPPluginCall) {
1140
+ guard let dbPath = call.options["databasePath"] as? String else {
1141
+ retHandler.rResult(
1142
+ call: call, ret: false,
1143
+ message: "isNCDatabase: Must provide a database path")
1144
+ return
1145
+ }
1146
+ do {
1147
+ let res = try implementation?.isNCDatabase(dbPath)
1148
+ var bRes: Bool = false
1149
+ if res == 1 {
1150
+ bRes = true
1151
+ }
1152
+ retHandler.rResult(call: call, ret: bRes)
1153
+ } catch CapacitorSQLiteError.failed(let message) {
1154
+ let msg = "isNCDatabase: \(message)"
1155
+ retHandler.rResult(call: call, message: msg)
1156
+ return
1157
+ } catch let error {
1158
+ retHandler.rResult(
1159
+ call: call,
1160
+ message: "isNCDatabase: \(error)")
1161
+ return
1162
+ }
1163
+
1164
+ }
1165
+
969
1166
  // MARK: - Add Observers
970
1167
 
971
1168
  @objc func addObserversToNotificationCenter() {
@@ -992,6 +1189,14 @@ public class CapacitorSQLitePlugin: CAPPlugin {
992
1189
  return
993
1190
  }
994
1191
  }
1192
+ private func sqliteConfig() -> SqliteConfig {
1193
+ var config = SqliteConfig()
1194
+
1195
+ if let iosDatabaseLocation = getConfigValue("iosDatabaseLocation") as? String {
1196
+ config.iosDatabaseLocation = iosDatabaseLocation
1197
+ }
1198
+ return config
1199
+ }
995
1200
 
996
1201
  }
997
1202
  // swiftlint:enable type_body_length