@capacitor-community/sqlite 5.0.5-2 → 5.0.6

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 (44) hide show
  1. package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLite.java +118 -156
  2. package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java +81 -249
  3. package/android/src/main/java/com/getcapacitor/community/database/sqlite/NotificationCenter.java +1 -1
  4. package/android/src/main/java/com/getcapacitor/community/database/sqlite/RetHandler.java +0 -12
  5. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +184 -40
  6. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ExportToJson.java +141 -135
  7. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ImportFromJson.java +2 -1
  8. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/UtilsEncryption.java +111 -0
  9. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsBiometric.java +0 -4
  10. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsFile.java +30 -18
  11. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsMigrate.java +12 -4
  12. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsNCDatabase.java +4 -1
  13. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsSQLCipher.java +8 -6
  14. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsSQLite.java +14 -28
  15. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsSecret.java +3 -4
  16. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsUpgrade.java +0 -1
  17. package/dist/esm/definitions.d.ts +91 -4
  18. package/dist/esm/definitions.js +79 -19
  19. package/dist/esm/definitions.js.map +1 -1
  20. package/dist/esm/web.d.ts +3 -1
  21. package/dist/esm/web.js +8 -0
  22. package/dist/esm/web.js.map +1 -1
  23. package/dist/plugin.cjs.js +87 -19
  24. package/dist/plugin.cjs.js.map +1 -1
  25. package/dist/plugin.js +87 -19
  26. package/dist/plugin.js.map +1 -1
  27. package/electron/dist/plugin.js +333 -148
  28. package/electron/dist/plugin.js.map +1 -1
  29. package/electron/rollup.config.js +2 -0
  30. package/ios/Plugin/CapacitorSQLite.swift +125 -92
  31. package/ios/Plugin/CapacitorSQLitePlugin.swift +6 -3
  32. package/ios/Plugin/Database.swift +45 -19
  33. package/ios/Plugin/ImportExportJson/ExportToJson.swift +10 -5
  34. package/ios/Plugin/ImportExportJson/ImportData.swift +434 -0
  35. package/ios/Plugin/ImportExportJson/ImportFromJson.swift +47 -59
  36. package/ios/Plugin/ImportExportJson/JsonSQLite.swift +7 -0
  37. package/ios/Plugin/Utils/UtilsDownloadFromHTTP.swift +61 -61
  38. package/ios/Plugin/Utils/UtilsDrop.swift +2 -1
  39. package/ios/Plugin/Utils/UtilsJson.swift +123 -1
  40. package/ios/Plugin/Utils/UtilsSQLCipher.swift +254 -23
  41. package/ios/Plugin/Utils/UtilsUpgrade.swift +0 -1
  42. package/package.json +2 -2
  43. package/src/definitions.ts +171 -18
  44. package/src/web.ts +10 -0
@@ -0,0 +1,434 @@
1
+ //
2
+ // ImportData.swift
3
+ // CapacitorCommunitySqlite
4
+ //
5
+ // Created by Quéau Jean Pierre on 23/07/2023.
6
+ //
7
+
8
+ import Foundation
9
+
10
+ // swiftlint:disable file_length
11
+ public class ImportData {
12
+ var jsonSQLite: [JsonSQLite]
13
+ var jsonDict: [String: Any]
14
+
15
+ init(jsonSQLite: JsonSQLite) {
16
+ self.jsonSQLite = [jsonSQLite]
17
+ self.jsonDict = [:]
18
+ }
19
+ init(jsonDict: [String: Any]) {
20
+ self.jsonSQLite = []
21
+ self.jsonDict = jsonDict
22
+ }
23
+
24
+ var database: String {
25
+ var mDatabase = ""
26
+ mDatabase = jsonSQLite.count > 0 ? jsonSQLite[0].database : ""
27
+ if !jsonDict.isEmpty {
28
+ if let mDBName = jsonDict["database"] as? String {
29
+ mDatabase = mDBName
30
+ }
31
+ }
32
+ return mDatabase
33
+ }
34
+ var mode: String {
35
+ var mMode = ""
36
+ mMode = jsonSQLite.count > 0 ? jsonSQLite[0].mode : ""
37
+ if !jsonDict.isEmpty {
38
+ if let nMode = jsonDict["mode"] as? String {
39
+ mMode = nMode
40
+ }
41
+ }
42
+ return mMode
43
+ }
44
+ var encrypted: Bool {
45
+ var mEnc = false
46
+ mEnc = jsonSQLite.count > 0 ? jsonSQLite[0].encrypted : false
47
+ if !jsonDict.isEmpty {
48
+ if let nEnc = jsonDict["encrypted"] as? Bool {
49
+ mEnc = nEnc
50
+ }
51
+ }
52
+ return mEnc
53
+ }
54
+ var overwrite: Bool {
55
+ var mOve = false
56
+ if jsonSQLite.count > 0 {
57
+ if let nOve = jsonSQLite[0].overwrite {
58
+ mOve = nOve
59
+ }
60
+ }
61
+
62
+ if !jsonDict.isEmpty {
63
+ if let nOve = jsonDict["overwrite"] as? Bool {
64
+ mOve = nOve
65
+ }
66
+ }
67
+ return mOve
68
+ }
69
+ var version: Int {
70
+ var mVer = 1
71
+ mVer = jsonSQLite.count > 0 ? jsonSQLite[0].version : 1
72
+ if !jsonDict.isEmpty {
73
+ if let nVer = jsonDict["version"] as? Int {
74
+ mVer = nVer
75
+ }
76
+ }
77
+ return mVer
78
+ }
79
+ var tables: [ImportTable] {
80
+ var fTab: [ImportTable] = []
81
+ if jsonSQLite.count > 0 {
82
+ let mTables = jsonSQLite[0].tables
83
+ for table in mTables {
84
+ let mTab: ImportTable = ImportTable(jsonTable: [table])
85
+ fTab.append(mTab)
86
+ }
87
+ }
88
+ if !jsonDict.isEmpty {
89
+ if let mTables = jsonDict["tables"] as? [[String: Any]] {
90
+ for table in mTables {
91
+ let mTab: ImportTable = ImportTable(tableDict: table)
92
+ fTab.append(mTab)
93
+ }
94
+ }
95
+ }
96
+ return fTab
97
+ }
98
+ var views: [ImportView]? {
99
+ var fView: [ImportView] = []
100
+ if jsonSQLite.count > 0 {
101
+ if let mViews = jsonSQLite[0].views {
102
+ for view in mViews {
103
+ let mVw: ImportView = ImportView(jsonView: [view])
104
+ fView.append(mVw)
105
+ }
106
+ }
107
+ }
108
+ if !jsonDict.isEmpty {
109
+ if let mViews = jsonDict["views"] as? [[String: Any]] {
110
+ for view in mViews {
111
+ let mVw: ImportView = ImportView(viewDict: view)
112
+ fView.append(mVw)
113
+ }
114
+ }
115
+ }
116
+ return fView
117
+ }
118
+ }
119
+ public class ImportTable {
120
+ var jsonTable: [JsonTable]
121
+ var tableDict: [String: Any]
122
+
123
+ init(jsonTable: [JsonTable]) {
124
+ self.jsonTable = jsonTable
125
+ self.tableDict = [:]
126
+ }
127
+ init(tableDict: [String: Any]) {
128
+ self.jsonTable = []
129
+ self.tableDict = tableDict
130
+ }
131
+
132
+ var name: String {
133
+ var mName = ""
134
+ mName = jsonTable.count > 0 ? jsonTable[0].name : ""
135
+ if !tableDict.isEmpty {
136
+ if let nName = tableDict["name"] as? String {
137
+ mName = nName
138
+ }
139
+ }
140
+ return mName
141
+ }
142
+
143
+ var schema: [ImportColumn]? {
144
+ var mSchema: [ImportColumn] = []
145
+ if jsonTable.count > 0 {
146
+ if let nSchema = jsonTable[0].schema {
147
+ for schm in nSchema {
148
+ let nSchm: ImportColumn = ImportColumn(jsonColumn: [schm])
149
+ mSchema.append(nSchm)
150
+ }
151
+ }
152
+
153
+ }
154
+ if !tableDict.isEmpty {
155
+ if let nSchema = tableDict["schema"] as? [[String: Any]] {
156
+ for schm in nSchema {
157
+ let nSchm: ImportColumn =
158
+ ImportColumn(columnDict: schm)
159
+ mSchema.append(nSchm)
160
+ }
161
+ }
162
+ }
163
+ return mSchema
164
+ }
165
+ var indexes: [ImportIndex]? {
166
+ var mIndexes: [ImportIndex] = []
167
+ if jsonTable.count > 0 {
168
+ if let nIndexes = jsonTable[0].indexes {
169
+ for nIdx in nIndexes {
170
+ let nIndex: ImportIndex = ImportIndex(jsonIndex: [nIdx])
171
+ mIndexes.append(nIndex)
172
+ }
173
+ }
174
+
175
+ }
176
+ if !tableDict.isEmpty {
177
+ if let nIndexes = tableDict["indexes"] as? [[String: Any]] {
178
+ for nIdx in nIndexes {
179
+ let nIndex: ImportIndex = ImportIndex(indexDict: nIdx)
180
+ mIndexes.append(nIndex)
181
+ }
182
+ }
183
+ }
184
+ return mIndexes
185
+ }
186
+ var triggers: [ImportTrigger]? {
187
+ var mTrigs: [ImportTrigger] = []
188
+ if jsonTable.count > 0 {
189
+ if let nTrigs = jsonTable[0].triggers {
190
+ for mTrig in nTrigs {
191
+ let nTrig: ImportTrigger = ImportTrigger(jsonTrigger: [mTrig])
192
+ mTrigs.append(nTrig)
193
+ }
194
+ }
195
+
196
+ }
197
+ if !tableDict.isEmpty {
198
+ if let nTrigs = tableDict["triggers"] as? [[String: Any]] {
199
+ for mTrig in nTrigs {
200
+ let nTrig: ImportTrigger = ImportTrigger(triggerDict: mTrig)
201
+ mTrigs.append(nTrig)
202
+ }
203
+ }
204
+ }
205
+ return mTrigs
206
+
207
+ }
208
+
209
+ var values: [[Any]]? {
210
+ var mValues: [[Any]] = []
211
+ if jsonTable.count > 0 {
212
+ if let nValues = jsonTable[0].values {
213
+ for row in nValues {
214
+ let nrow = UtilsJson.getValuesFromRow(rowValues: row)
215
+ mValues.append(nrow)
216
+ }
217
+ }
218
+ }
219
+ if !tableDict.isEmpty {
220
+ if let nValues = tableDict["values"] as? [[Any]] {
221
+ mValues = nValues
222
+ }
223
+ }
224
+ return mValues
225
+ }
226
+
227
+ }
228
+ public class ImportColumn {
229
+ var jsonColumn: [JsonColumn]
230
+ var columnDict: [String: Any]
231
+
232
+ init(jsonColumn: [JsonColumn]) {
233
+ self.jsonColumn = jsonColumn
234
+ self.columnDict = [:]
235
+ }
236
+ init(columnDict: [String: Any]) {
237
+ self.jsonColumn = []
238
+ self.columnDict = columnDict
239
+ }
240
+ var column: String? {
241
+ var mCol = ""
242
+ if jsonColumn.count > 0 {
243
+ if let nCol = jsonColumn[0].column {
244
+ mCol = nCol
245
+ }
246
+ }
247
+ if !columnDict.isEmpty {
248
+ if let nCol = columnDict["column"] as? String {
249
+ mCol = nCol
250
+ }
251
+ }
252
+ return mCol
253
+ }
254
+ var value: String {
255
+ var mVal = ""
256
+ mVal = jsonColumn.count > 0 ? jsonColumn[0].value : ""
257
+ if !columnDict.isEmpty {
258
+ if let nVal = columnDict["value"] as? String {
259
+ mVal = nVal
260
+ }
261
+ }
262
+ return mVal
263
+ }
264
+ var foreignkey: String? {
265
+ var mFK = ""
266
+ if jsonColumn.count > 0 {
267
+ if let nFK = jsonColumn[0].foreignkey {
268
+ mFK = nFK
269
+ }
270
+ }
271
+ if !columnDict.isEmpty {
272
+ if let nFK = columnDict["foreignkey"] as? String {
273
+ mFK = nFK
274
+ }
275
+ }
276
+ return mFK
277
+ }
278
+ var constraint: String? {
279
+ var mCon = ""
280
+ if jsonColumn.count > 0 {
281
+ if let nCon = jsonColumn[0].constraint {
282
+ mCon = nCon
283
+ }
284
+ }
285
+ if !columnDict.isEmpty {
286
+ if let nCon = columnDict["constraint"] as? String {
287
+ mCon = nCon
288
+ }
289
+ }
290
+ return mCon
291
+ }
292
+ }
293
+ public class ImportIndex {
294
+ var jsonIndex: [JsonIndex]
295
+ var indexDict: [String: Any]
296
+
297
+ init(jsonIndex: [JsonIndex]) {
298
+ self.jsonIndex = jsonIndex
299
+ self.indexDict = [:]
300
+ }
301
+ init(indexDict: [String: Any]) {
302
+ self.jsonIndex = []
303
+ self.indexDict = indexDict
304
+ }
305
+ var mode: String? {
306
+ var mMode = ""
307
+ if jsonIndex.count > 0 {
308
+ if let nMode = jsonIndex[0].mode {
309
+ mMode = nMode
310
+ }
311
+ }
312
+ if !indexDict.isEmpty {
313
+ if let nMode = indexDict["mode"] as? String {
314
+ mMode = nMode
315
+ }
316
+ }
317
+ return mMode
318
+ }
319
+ var value: String {
320
+ var mVal = ""
321
+ mVal = jsonIndex.count > 0 ? jsonIndex[0].value : ""
322
+ if !indexDict.isEmpty {
323
+ if let nVal = indexDict["value"] as? String {
324
+ mVal = nVal
325
+ }
326
+ }
327
+ return mVal
328
+ }
329
+ var name: String {
330
+ var mName = ""
331
+ mName = jsonIndex.count > 0 ? jsonIndex[0].name : ""
332
+ if !indexDict.isEmpty {
333
+ if let nName = indexDict["name"] as? String {
334
+ mName = nName
335
+ }
336
+ }
337
+ return mName
338
+ }
339
+ }
340
+ public class ImportTrigger {
341
+ var jsonTrigger: [JsonTrigger]
342
+ var triggerDict: [String: Any]
343
+
344
+ init(jsonTrigger: [JsonTrigger]) {
345
+ self.jsonTrigger = jsonTrigger
346
+ self.triggerDict = [:]
347
+ }
348
+ init(triggerDict: [String: Any]) {
349
+ self.jsonTrigger = []
350
+ self.triggerDict = triggerDict
351
+ }
352
+ var name: String {
353
+ var mName = ""
354
+ mName = jsonTrigger.count > 0 ? jsonTrigger[0].name : ""
355
+ if !triggerDict.isEmpty {
356
+ if let nName = triggerDict["name"] as? String {
357
+ mName = nName
358
+ }
359
+ }
360
+ return mName
361
+ }
362
+ var timeevent: String {
363
+ var mTime = ""
364
+ mTime = jsonTrigger.count > 0 ? jsonTrigger[0].timeevent : ""
365
+ if !triggerDict.isEmpty {
366
+ if let nTime = triggerDict["timeevent"] as? String {
367
+ mTime = nTime
368
+ }
369
+ }
370
+ return mTime
371
+ }
372
+ var logic: String {
373
+ var mLog = ""
374
+ mLog = jsonTrigger.count > 0 ? jsonTrigger[0].logic : ""
375
+ if !triggerDict.isEmpty {
376
+ if let nLog = triggerDict["logic"] as? String {
377
+ mLog = nLog
378
+ }
379
+ }
380
+ return mLog
381
+ }
382
+ var condition: String? {
383
+ var mCon = ""
384
+ if jsonTrigger.count > 0 {
385
+ if let nCon = jsonTrigger[0].condition {
386
+ mCon = nCon
387
+ }
388
+ }
389
+ if !triggerDict.isEmpty {
390
+ if let nCon = triggerDict["condition"] as? String {
391
+ mCon = nCon
392
+ }
393
+ }
394
+ return mCon
395
+ }
396
+
397
+ }
398
+
399
+ public class ImportView {
400
+ var jsonView: [JsonView]
401
+ var viewDict: [String: Any]
402
+
403
+ init(jsonView: [JsonView]) {
404
+ self.jsonView = jsonView
405
+ self.viewDict = [:]
406
+ }
407
+ init(viewDict: [String: Any]) {
408
+ self.jsonView = []
409
+ self.viewDict = viewDict
410
+ }
411
+
412
+ var name: String {
413
+ var mName = ""
414
+ mName = jsonView.count > 0 ? jsonView[0].name : ""
415
+ if !viewDict.isEmpty {
416
+ if let nName = viewDict["name"] as? String {
417
+ mName = nName
418
+ }
419
+ }
420
+ return mName
421
+ }
422
+ var value: String {
423
+ var mValue = ""
424
+ mValue = jsonView.count > 0 ? jsonView[0].value : ""
425
+ if !viewDict.isEmpty {
426
+ if let nView = viewDict["value"] as? String {
427
+ mValue = nView
428
+ }
429
+ }
430
+ return mValue
431
+ }
432
+
433
+ }
434
+ // swiftlint:enable file_length