@capacitor-community/sqlite 3.4.2 → 3.4.3-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.
Files changed (31) hide show
  1. package/README.md +42 -2
  2. package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLite.java +41 -2
  3. package/android/src/main/java/com/getcapacitor/community/database/sqlite/CapacitorSQLitePlugin.java +26 -0
  4. package/android/src/main/java/com/getcapacitor/community/database/sqlite/NotificationCenter.java +1 -1
  5. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/Database.java +220 -7
  6. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ExportToJson.java +100 -3
  7. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/ImportExportJson/ImportFromJson.java +37 -34
  8. package/android/src/main/java/com/getcapacitor/community/database/sqlite/SQLite/UtilsUpgrade.java +8 -4
  9. package/dist/esm/definitions.d.ts +17 -1
  10. package/dist/esm/definitions.js +9 -17
  11. package/dist/esm/definitions.js.map +1 -1
  12. package/dist/esm/web.d.ts +20 -11
  13. package/dist/esm/web.js +288 -473
  14. package/dist/esm/web.js.map +1 -1
  15. package/dist/plugin.cjs.js +273 -466
  16. package/dist/plugin.cjs.js.map +1 -1
  17. package/dist/plugin.js +1036 -1229
  18. package/dist/plugin.js.map +1 -1
  19. package/electron/dist/plugin.js +1147 -1032
  20. package/electron/dist/plugin.js.map +1 -1
  21. package/ios/Plugin/CapacitorSQLite.swift +34 -1
  22. package/ios/Plugin/CapacitorSQLitePlugin.m +1 -0
  23. package/ios/Plugin/CapacitorSQLitePlugin.swift +25 -0
  24. package/ios/Plugin/Database.swift +29 -1
  25. package/ios/Plugin/Extensions/String.swift +8 -0
  26. package/ios/Plugin/ImportExportJson/ExportToJson.swift +154 -25
  27. package/ios/Plugin/ImportExportJson/ImportFromJson.swift +53 -27
  28. package/ios/Plugin/Utils/UtilsDrop.swift +2 -2
  29. package/ios/Plugin/Utils/UtilsSQLCipher.swift +277 -8
  30. package/ios/Plugin/Utils/UtilsUpgrade.swift +33 -13
  31. package/package.json +6 -6
@@ -574,6 +574,15 @@ class SQLiteDBConnection {
574
574
  return Promise.reject(err);
575
575
  }
576
576
  }
577
+ async deleteExportedRows() {
578
+ try {
579
+ await this.sqlite.deleteExportedRows({ database: this.dbName });
580
+ return Promise.resolve();
581
+ }
582
+ catch (err) {
583
+ return Promise.reject(err);
584
+ }
585
+ }
577
586
  async executeTransaction(txn) {
578
587
  try {
579
588
  const ret = await this.sqlite.execute({
@@ -630,23 +639,6 @@ class SQLiteDBConnection {
630
639
  }
631
640
  }
632
641
  }
633
- /*
634
- if (Object.keys(res.values[0]).includes("ios_columns")) {
635
- const columnList = res.values[0]["ios_columns"];
636
- console.log(`in DBconnection query ${columnList}`);
637
- const iosRes = []
638
- for (let i = 1; i < res.values.length; i++) {
639
- const rowJson = res.values[i];
640
- const resRowJson = {};
641
- for (const item of columnList) {
642
- resRowJson[item] = rowJson[item];
643
- }
644
- console.log(`resRowJson: ${JSON.stringify(resRowJson)}`)
645
- iosRes.push(resRowJson);
646
- }
647
- console.log(`iosRes ${JSON.stringify(iosRes)}`);
648
- }
649
- */
650
642
 
651
643
  const CapacitorSQLite = core.registerPlugin('CapacitorSQLite', {
652
644
  web: () => Promise.resolve().then(function () { return web; }).then(m => new m.CapacitorSQLiteWeb()),
@@ -656,563 +648,351 @@ const CapacitorSQLite = core.registerPlugin('CapacitorSQLite', {
656
648
  class CapacitorSQLiteWeb extends core.WebPlugin {
657
649
  constructor() {
658
650
  super(...arguments);
659
- this.sqliteEl = null;
660
- this.isStoreOpen = false;
651
+ this.jeepSqliteElement = null;
652
+ this.isWebStoreOpen = false;
661
653
  }
662
654
  async initWebStore() {
663
655
  await customElements.whenDefined('jeep-sqlite');
664
- this.sqliteEl = document.querySelector('jeep-sqlite');
665
- if (this.sqliteEl != null) {
666
- this.sqliteEl.addEventListener('jeepSqliteImportProgress', (event) => {
667
- this.notifyListeners('sqliteImportProgressEvent', event.detail);
668
- });
669
- this.sqliteEl.addEventListener('jeepSqliteExportProgress', (event) => {
670
- this.notifyListeners('sqliteExportProgressEvent', event.detail);
671
- });
672
- if (!this.isStoreOpen)
673
- this.isStoreOpen = await this.sqliteEl.isStoreOpen();
674
- return Promise.resolve();
675
- }
676
- else {
677
- return Promise.reject('InitWeb: this.sqliteEl is null');
678
- }
656
+ this.jeepSqliteElement = document.querySelector('jeep-sqlite');
657
+ this.ensureJeepSqliteIsAvailable();
658
+ this.jeepSqliteElement.addEventListener('jeepSqliteImportProgress', (event) => {
659
+ this.notifyListeners('sqliteImportProgressEvent', event.detail);
660
+ });
661
+ this.jeepSqliteElement.addEventListener('jeepSqliteExportProgress', (event) => {
662
+ this.notifyListeners('sqliteExportProgressEvent', event.detail);
663
+ });
664
+ if (!this.isWebStoreOpen) {
665
+ this.isWebStoreOpen = await this.jeepSqliteElement.isStoreOpen();
666
+ }
667
+ return;
679
668
  }
680
669
  async saveToStore(options) {
681
- if (this.sqliteEl != null) {
682
- if (this.isStoreOpen) {
683
- try {
684
- await this.sqliteEl.saveToStore(options);
685
- return Promise.resolve();
686
- }
687
- catch (err) {
688
- return Promise.reject(`${err}`);
689
- }
690
- }
691
- else {
692
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
693
- }
670
+ this.ensureJeepSqliteIsAvailable();
671
+ this.ensureWebstoreIsOpen();
672
+ try {
673
+ await this.jeepSqliteElement.saveToStore(options);
674
+ return;
694
675
  }
695
- else {
696
- throw this.unimplemented('Not implemented on web.');
676
+ catch (err) {
677
+ throw new Error(`${err}`);
697
678
  }
698
679
  }
699
680
  async echo(options) {
700
- if (this.sqliteEl != null) {
701
- const echo = await this.sqliteEl.echo(options);
702
- return echo;
703
- }
704
- else {
705
- throw this.unimplemented('Not implemented on web.');
706
- }
707
- }
708
- async isSecretStored() {
709
- throw this.unimplemented('Not implemented on web.');
710
- }
711
- async setEncryptionSecret(options) {
712
- console.log('setEncryptionSecret', options);
713
- throw this.unimplemented('Not implemented on web.');
714
- }
715
- async changeEncryptionSecret(options) {
716
- console.log('changeEncryptionSecret', options);
717
- throw this.unimplemented('Not implemented on web.');
718
- }
719
- async getNCDatabasePath(options) {
720
- console.log('getNCDatabasePath', options);
721
- throw this.unimplemented('Not implemented on web.');
722
- }
723
- async createNCConnection(options) {
724
- console.log('createNCConnection', options);
725
- throw this.unimplemented('Not implemented on web.');
726
- }
727
- async closeNCConnection(options) {
728
- console.log('closeNCConnection', options);
729
- throw this.unimplemented('Not implemented on web.');
730
- }
731
- async isNCDatabase(options) {
732
- console.log('isNCDatabase', options);
733
- throw this.unimplemented('Not implemented on web.');
681
+ this.ensureJeepSqliteIsAvailable();
682
+ const echoResult = await this.jeepSqliteElement.echo(options);
683
+ return echoResult;
734
684
  }
735
685
  async createConnection(options) {
736
- if (this.sqliteEl != null) {
737
- if (this.isStoreOpen) {
738
- try {
739
- await this.sqliteEl.createConnection(options);
740
- return Promise.resolve();
741
- }
742
- catch (err) {
743
- return Promise.reject(`${err}`);
744
- }
745
- }
746
- else {
747
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
748
- }
686
+ this.ensureJeepSqliteIsAvailable();
687
+ this.ensureWebstoreIsOpen();
688
+ try {
689
+ await this.jeepSqliteElement.createConnection(options);
690
+ return;
749
691
  }
750
- else {
751
- throw this.unimplemented('Not implemented on web.');
692
+ catch (err) {
693
+ throw new Error(`${err}`);
752
694
  }
753
695
  }
754
696
  async open(options) {
755
- if (this.sqliteEl != null) {
756
- if (this.isStoreOpen) {
757
- try {
758
- await this.sqliteEl.open(options);
759
- return Promise.resolve();
760
- }
761
- catch (err) {
762
- return Promise.reject(`${err}`);
763
- }
764
- }
765
- else {
766
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
767
- }
697
+ this.ensureJeepSqliteIsAvailable();
698
+ this.ensureWebstoreIsOpen();
699
+ try {
700
+ await this.jeepSqliteElement.open(options);
701
+ return;
768
702
  }
769
- else {
770
- throw this.unimplemented('Not implemented on web.');
703
+ catch (err) {
704
+ throw new Error(`${err}`);
771
705
  }
772
706
  }
773
707
  async closeConnection(options) {
774
- if (this.sqliteEl != null) {
775
- if (this.isStoreOpen) {
776
- try {
777
- await this.sqliteEl.closeConnection(options);
778
- return Promise.resolve();
779
- }
780
- catch (err) {
781
- return Promise.reject(`${err}`);
782
- }
783
- }
784
- else {
785
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
786
- }
708
+ this.ensureJeepSqliteIsAvailable();
709
+ this.ensureWebstoreIsOpen();
710
+ try {
711
+ await this.jeepSqliteElement.closeConnection(options);
712
+ return;
787
713
  }
788
- else {
789
- throw this.unimplemented('Not implemented on web.');
714
+ catch (err) {
715
+ throw new Error(`${err}`);
790
716
  }
791
717
  }
792
- async getUrl() {
793
- throw this.unimplemented('Not implemented on web.');
794
- }
795
718
  async getVersion(options) {
796
- if (this.sqliteEl != null) {
797
- if (this.isStoreOpen) {
798
- try {
799
- const ret = await this.sqliteEl.getVersion(options);
800
- return Promise.resolve(ret);
801
- }
802
- catch (err) {
803
- return Promise.reject(`${err}`);
804
- }
805
- }
806
- else {
807
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
808
- }
719
+ this.ensureJeepSqliteIsAvailable();
720
+ this.ensureWebstoreIsOpen();
721
+ try {
722
+ const versionResult = await this.jeepSqliteElement.getVersion(options);
723
+ return versionResult;
809
724
  }
810
- else {
811
- throw this.unimplemented('Not implemented on web.');
725
+ catch (err) {
726
+ throw new Error(`${err}`);
812
727
  }
813
728
  }
814
729
  async checkConnectionsConsistency(options) {
815
- if (this.sqliteEl != null) {
816
- try {
817
- const ret = await this.sqliteEl.checkConnectionsConsistency(options);
818
- return Promise.resolve(ret);
819
- }
820
- catch (err) {
821
- return Promise.reject(`${err}`);
822
- }
730
+ this.ensureJeepSqliteIsAvailable();
731
+ try {
732
+ const consistencyResult = await this.jeepSqliteElement.checkConnectionsConsistency(options);
733
+ return consistencyResult;
823
734
  }
824
- else {
825
- throw this.unimplemented('Not implemented on web.');
735
+ catch (err) {
736
+ throw new Error(`${err}`);
826
737
  }
827
738
  }
828
739
  async close(options) {
829
- if (this.sqliteEl != null) {
830
- if (this.isStoreOpen) {
831
- try {
832
- await this.sqliteEl.close(options);
833
- return Promise.resolve();
834
- }
835
- catch (err) {
836
- return Promise.reject(`${err}`);
837
- }
838
- }
839
- else {
840
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
841
- }
740
+ this.ensureJeepSqliteIsAvailable();
741
+ this.ensureWebstoreIsOpen();
742
+ try {
743
+ await this.jeepSqliteElement.close(options);
744
+ return;
842
745
  }
843
- else {
844
- throw this.unimplemented('Not implemented on web.');
746
+ catch (err) {
747
+ throw new Error(`${err}`);
845
748
  }
846
749
  }
847
750
  async getTableList(options) {
848
- if (this.sqliteEl != null) {
849
- if (this.isStoreOpen) {
850
- try {
851
- const res = await this.sqliteEl.getTableList(options);
852
- return Promise.resolve(res);
853
- }
854
- catch (err) {
855
- return Promise.reject(`${err}`);
856
- }
857
- }
858
- else {
859
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
860
- }
751
+ this.ensureJeepSqliteIsAvailable();
752
+ this.ensureWebstoreIsOpen();
753
+ try {
754
+ const tableListResult = await this.jeepSqliteElement.getTableList(options);
755
+ return tableListResult;
861
756
  }
862
- else {
863
- throw this.unimplemented('Not implemented on web.');
757
+ catch (err) {
758
+ throw new Error(`${err}`);
864
759
  }
865
760
  }
866
761
  async execute(options) {
867
- if (this.sqliteEl != null) {
868
- if (this.isStoreOpen) {
869
- try {
870
- const ret = await this.sqliteEl.execute(options);
871
- return Promise.resolve(ret);
872
- }
873
- catch (err) {
874
- return Promise.reject(`${err}`);
875
- }
876
- }
877
- else {
878
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
879
- }
762
+ this.ensureJeepSqliteIsAvailable();
763
+ this.ensureWebstoreIsOpen();
764
+ try {
765
+ const executeResult = await this.jeepSqliteElement.execute(options);
766
+ return executeResult;
880
767
  }
881
- else {
882
- throw this.unimplemented('Not implemented on web.');
768
+ catch (err) {
769
+ throw new Error(`${err}`);
883
770
  }
884
771
  }
885
772
  async executeSet(options) {
886
- if (this.sqliteEl != null) {
887
- if (this.isStoreOpen) {
888
- try {
889
- const ret = await this.sqliteEl.executeSet(options);
890
- return Promise.resolve(ret);
891
- }
892
- catch (err) {
893
- return Promise.reject(`${err}`);
894
- }
895
- }
896
- else {
897
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
898
- }
773
+ this.ensureJeepSqliteIsAvailable();
774
+ this.ensureWebstoreIsOpen();
775
+ try {
776
+ const executeResult = await this.jeepSqliteElement.executeSet(options);
777
+ return executeResult;
899
778
  }
900
- else {
901
- throw this.unimplemented('Not implemented on web.');
779
+ catch (err) {
780
+ throw new Error(`${err}`);
902
781
  }
903
782
  }
904
783
  async run(options) {
905
- if (this.sqliteEl != null) {
906
- if (this.isStoreOpen) {
907
- try {
908
- const ret = await this.sqliteEl.run(options);
909
- return Promise.resolve(ret);
910
- }
911
- catch (err) {
912
- return Promise.reject(`${err}`);
913
- }
914
- }
915
- else {
916
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
917
- }
784
+ this.ensureJeepSqliteIsAvailable();
785
+ this.ensureWebstoreIsOpen();
786
+ try {
787
+ const runResult = await this.jeepSqliteElement.run(options);
788
+ return runResult;
918
789
  }
919
- else {
920
- throw this.unimplemented('Not implemented on web.');
790
+ catch (err) {
791
+ throw new Error(`${err}`);
921
792
  }
922
793
  }
923
794
  async query(options) {
924
- if (this.sqliteEl != null) {
925
- if (this.isStoreOpen) {
926
- try {
927
- const ret = await this.sqliteEl.query(options);
928
- return Promise.resolve(ret);
929
- }
930
- catch (err) {
931
- return Promise.reject(`${err}`);
932
- }
933
- }
934
- else {
935
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
936
- }
795
+ this.ensureJeepSqliteIsAvailable();
796
+ this.ensureWebstoreIsOpen();
797
+ try {
798
+ const queryResult = await this.jeepSqliteElement.query(options);
799
+ return queryResult;
937
800
  }
938
- else {
939
- throw this.unimplemented('Not implemented on web.');
801
+ catch (err) {
802
+ throw new Error(`${err}`);
940
803
  }
941
804
  }
942
805
  async isDBExists(options) {
943
- if (this.sqliteEl != null) {
944
- if (this.isStoreOpen) {
945
- try {
946
- const ret = await this.sqliteEl.isDBExists(options);
947
- return Promise.resolve(ret);
948
- }
949
- catch (err) {
950
- return Promise.reject(`${err}`);
951
- }
952
- }
953
- else {
954
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
955
- }
806
+ this.ensureJeepSqliteIsAvailable();
807
+ this.ensureWebstoreIsOpen();
808
+ try {
809
+ const dbExistsResult = await this.jeepSqliteElement.isDBExists(options);
810
+ return dbExistsResult;
956
811
  }
957
- else {
958
- throw this.unimplemented('Not implemented on web.');
812
+ catch (err) {
813
+ throw new Error(`${err}`);
959
814
  }
960
815
  }
961
816
  async isDBOpen(options) {
962
- if (this.sqliteEl != null) {
963
- if (this.isStoreOpen) {
964
- try {
965
- const ret = await this.sqliteEl.isDBOpen(options);
966
- return Promise.resolve(ret);
967
- }
968
- catch (err) {
969
- return Promise.reject(`${err}`);
970
- }
971
- }
972
- else {
973
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
974
- }
817
+ this.ensureJeepSqliteIsAvailable();
818
+ this.ensureWebstoreIsOpen();
819
+ try {
820
+ const isDBOpenResult = await this.jeepSqliteElement.isDBOpen(options);
821
+ return isDBOpenResult;
975
822
  }
976
- else {
977
- throw this.unimplemented('Not implemented on web.');
823
+ catch (err) {
824
+ throw new Error(`${err}`);
978
825
  }
979
826
  }
980
827
  async isDatabase(options) {
981
- if (this.sqliteEl != null) {
982
- if (!this.isStoreOpen)
983
- this.isStoreOpen = await this.sqliteEl.isStoreOpen();
984
- if (this.isStoreOpen) {
985
- try {
986
- const ret = await this.sqliteEl.isDatabase(options);
987
- return Promise.resolve(ret);
988
- }
989
- catch (err) {
990
- return Promise.reject(`${err}`);
991
- }
992
- }
993
- else {
994
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
995
- }
828
+ this.ensureJeepSqliteIsAvailable();
829
+ this.ensureWebstoreIsOpen();
830
+ try {
831
+ const isDatabaseResult = await this.jeepSqliteElement.isDatabase(options);
832
+ return isDatabaseResult;
996
833
  }
997
- else {
998
- throw this.unimplemented('Not implemented on web.');
834
+ catch (err) {
835
+ throw new Error(`${err}`);
999
836
  }
1000
837
  }
1001
838
  async isTableExists(options) {
1002
- if (this.sqliteEl != null) {
1003
- if (this.isStoreOpen) {
1004
- try {
1005
- const ret = await this.sqliteEl.isTableExists(options);
1006
- return Promise.resolve(ret);
1007
- }
1008
- catch (err) {
1009
- return Promise.reject(`${err}`);
1010
- }
1011
- }
1012
- else {
1013
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
1014
- }
839
+ this.ensureJeepSqliteIsAvailable();
840
+ this.ensureWebstoreIsOpen();
841
+ try {
842
+ const tableExistsResult = await this.jeepSqliteElement.isTableExists(options);
843
+ return tableExistsResult;
1015
844
  }
1016
- else {
1017
- throw this.unimplemented('Not implemented on web.');
845
+ catch (err) {
846
+ throw new Error(`${err}`);
1018
847
  }
1019
848
  }
1020
849
  async deleteDatabase(options) {
1021
- if (this.sqliteEl != null) {
1022
- if (this.isStoreOpen) {
1023
- try {
1024
- await this.sqliteEl.deleteDatabase(options);
1025
- return Promise.resolve();
1026
- }
1027
- catch (err) {
1028
- return Promise.reject(`${err}`);
1029
- }
1030
- }
1031
- else {
1032
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
1033
- }
850
+ this.ensureJeepSqliteIsAvailable();
851
+ this.ensureWebstoreIsOpen();
852
+ try {
853
+ await this.jeepSqliteElement.deleteDatabase(options);
854
+ return;
1034
855
  }
1035
- else {
1036
- throw this.unimplemented('Not implemented on web.');
856
+ catch (err) {
857
+ throw new Error(`${err}`);
1037
858
  }
1038
859
  }
1039
860
  async isJsonValid(options) {
1040
- if (this.sqliteEl != null) {
1041
- if (!this.isStoreOpen)
1042
- this.isStoreOpen = await this.sqliteEl.isStoreOpen();
1043
- if (this.isStoreOpen) {
1044
- try {
1045
- const ret = await this.sqliteEl.isJsonValid(options);
1046
- return Promise.resolve(ret);
1047
- }
1048
- catch (err) {
1049
- return Promise.reject(`${err}`);
1050
- }
1051
- }
1052
- else {
1053
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
1054
- }
861
+ this.ensureJeepSqliteIsAvailable();
862
+ this.ensureWebstoreIsOpen();
863
+ try {
864
+ const isJsonValidResult = await this.jeepSqliteElement.isJsonValid(options);
865
+ return isJsonValidResult;
1055
866
  }
1056
- else {
1057
- throw this.unimplemented('Not implemented on web.');
867
+ catch (err) {
868
+ throw new Error(`${err}`);
1058
869
  }
1059
870
  }
1060
871
  async importFromJson(options) {
1061
- if (this.sqliteEl != null) {
1062
- if (!this.isStoreOpen)
1063
- this.isStoreOpen = await this.sqliteEl.isStoreOpen();
1064
- if (this.isStoreOpen) {
1065
- try {
1066
- const ret = await this.sqliteEl.importFromJson(options);
1067
- return Promise.resolve(ret);
1068
- }
1069
- catch (err) {
1070
- return Promise.reject(`${err}`);
1071
- }
1072
- }
1073
- else {
1074
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
1075
- }
872
+ this.ensureJeepSqliteIsAvailable();
873
+ this.ensureWebstoreIsOpen();
874
+ try {
875
+ const importFromJsonResult = await this.jeepSqliteElement.importFromJson(options);
876
+ return importFromJsonResult;
1076
877
  }
1077
- else {
1078
- throw this.unimplemented('Not implemented on web.');
878
+ catch (err) {
879
+ throw new Error(`${err}`);
1079
880
  }
1080
881
  }
1081
882
  async exportToJson(options) {
1082
- if (this.sqliteEl != null) {
1083
- if (this.isStoreOpen) {
1084
- try {
1085
- const ret = await this.sqliteEl.exportToJson(options);
1086
- return Promise.resolve(ret);
1087
- }
1088
- catch (err) {
1089
- return Promise.reject(`${err}`);
1090
- }
1091
- }
1092
- else {
1093
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
1094
- }
883
+ this.ensureJeepSqliteIsAvailable();
884
+ this.ensureWebstoreIsOpen();
885
+ try {
886
+ const exportToJsonResult = await this.jeepSqliteElement.exportToJson(options);
887
+ return exportToJsonResult;
1095
888
  }
1096
- else {
1097
- throw this.unimplemented('Not implemented on web.');
889
+ catch (err) {
890
+ throw new Error(`${err}`);
1098
891
  }
1099
892
  }
1100
893
  async createSyncTable(options) {
1101
- if (this.sqliteEl != null) {
1102
- if (this.isStoreOpen) {
1103
- try {
1104
- const ret = await this.sqliteEl.createSyncTable(options);
1105
- return Promise.resolve(ret);
1106
- }
1107
- catch (err) {
1108
- return Promise.reject(`${err}`);
1109
- }
1110
- }
1111
- else {
1112
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
1113
- }
894
+ this.ensureJeepSqliteIsAvailable();
895
+ this.ensureWebstoreIsOpen();
896
+ try {
897
+ const createSyncTableResult = await this.jeepSqliteElement.createSyncTable(options);
898
+ return createSyncTableResult;
1114
899
  }
1115
- else {
1116
- throw this.unimplemented('Not implemented on web.');
900
+ catch (err) {
901
+ throw new Error(`${err}`);
1117
902
  }
1118
903
  }
1119
904
  async setSyncDate(options) {
1120
- if (this.sqliteEl != null) {
1121
- if (this.isStoreOpen) {
1122
- try {
1123
- await this.sqliteEl.setSyncDate(options);
1124
- return Promise.resolve();
1125
- }
1126
- catch (err) {
1127
- return Promise.reject(`${err}`);
1128
- }
1129
- }
1130
- else {
1131
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
1132
- }
905
+ this.ensureJeepSqliteIsAvailable();
906
+ this.ensureWebstoreIsOpen();
907
+ try {
908
+ await this.jeepSqliteElement.setSyncDate(options);
909
+ return;
1133
910
  }
1134
- else {
1135
- throw this.unimplemented('Not implemented on web.');
911
+ catch (err) {
912
+ throw new Error(`${err}`);
1136
913
  }
1137
914
  }
1138
915
  async getSyncDate(options) {
1139
- if (this.sqliteEl != null) {
1140
- if (this.isStoreOpen) {
1141
- try {
1142
- const ret = await this.sqliteEl.getSyncDate(options);
1143
- return Promise.resolve(ret);
1144
- }
1145
- catch (err) {
1146
- return Promise.reject(`${err}`);
1147
- }
1148
- }
1149
- else {
1150
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
1151
- }
916
+ this.ensureJeepSqliteIsAvailable();
917
+ this.ensureWebstoreIsOpen();
918
+ try {
919
+ const getSyncDateResult = await this.jeepSqliteElement.getSyncDate(options);
920
+ return getSyncDateResult;
1152
921
  }
1153
- else {
1154
- throw this.unimplemented('Not implemented on web.');
922
+ catch (err) {
923
+ throw new Error(`${err}`);
924
+ }
925
+ }
926
+ async deleteExportedRows(options) {
927
+ this.ensureJeepSqliteIsAvailable();
928
+ this.ensureWebstoreIsOpen();
929
+ try {
930
+ await this.jeepSqliteElement.deleteExportedRows(options);
931
+ return;
932
+ }
933
+ catch (err) {
934
+ throw new Error(`${err}`);
1155
935
  }
1156
936
  }
1157
937
  async addUpgradeStatement(options) {
1158
- if (this.sqliteEl != null) {
1159
- if (this.isStoreOpen) {
1160
- try {
1161
- await this.sqliteEl.addUpgradeStatement(options);
1162
- return Promise.resolve();
1163
- }
1164
- catch (err) {
1165
- return Promise.reject(`${err}`);
1166
- }
1167
- }
1168
- else {
1169
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
1170
- }
938
+ this.ensureJeepSqliteIsAvailable();
939
+ this.ensureWebstoreIsOpen();
940
+ try {
941
+ await this.jeepSqliteElement.addUpgradeStatement(options);
942
+ return;
1171
943
  }
1172
- else {
1173
- throw this.unimplemented('Not implemented on web.');
944
+ catch (err) {
945
+ throw new Error(`${err}`);
1174
946
  }
1175
947
  }
1176
948
  async copyFromAssets(options) {
1177
- if (this.sqliteEl != null) {
1178
- if (this.isStoreOpen) {
1179
- try {
1180
- await this.sqliteEl.copyFromAssets(options);
1181
- return Promise.resolve();
1182
- }
1183
- catch (err) {
1184
- return Promise.reject(`${err}`);
1185
- }
1186
- }
1187
- else {
1188
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
1189
- }
949
+ this.ensureJeepSqliteIsAvailable();
950
+ this.ensureWebstoreIsOpen();
951
+ try {
952
+ await this.jeepSqliteElement.copyFromAssets(options);
953
+ return;
1190
954
  }
1191
- else {
1192
- throw this.unimplemented('Not implemented on web.');
955
+ catch (err) {
956
+ throw new Error(`${err}`);
1193
957
  }
1194
958
  }
1195
959
  async getDatabaseList() {
1196
- if (this.sqliteEl != null) {
1197
- if (!this.isStoreOpen)
1198
- this.isStoreOpen = await this.sqliteEl.isStoreOpen();
1199
- if (this.isStoreOpen) {
1200
- try {
1201
- const ret = await this.sqliteEl.getDatabaseList();
1202
- return Promise.resolve(ret);
1203
- }
1204
- catch (err) {
1205
- return Promise.reject(`${err}`);
1206
- }
1207
- }
1208
- else {
1209
- return Promise.reject(`Store "jeepSqliteStore" failed to open`);
1210
- }
960
+ this.ensureJeepSqliteIsAvailable();
961
+ this.ensureWebstoreIsOpen();
962
+ try {
963
+ const databaseListResult = await this.jeepSqliteElement.getDatabaseList();
964
+ return databaseListResult;
1211
965
  }
1212
- else {
1213
- throw this.unimplemented('Not implemented on web.');
966
+ catch (err) {
967
+ throw new Error(`${err}`);
1214
968
  }
1215
969
  }
970
+ /**
971
+ * Checks if the `jeep-sqlite` element is present in the DOM.
972
+ * If it's not in the DOM, this method throws an Error.
973
+ *
974
+ * Attention: This will always fail, if the `intWebStore()` method wasn't called before.
975
+ */
976
+ ensureJeepSqliteIsAvailable() {
977
+ if (this.jeepSqliteElement === null) {
978
+ throw new Error(`The jeep-sqlite element is not present in the DOM! Please check the @capacitor-community/sqlite documentation for instructions regarding the web platform.`);
979
+ }
980
+ }
981
+ ensureWebstoreIsOpen() {
982
+ if (!this.isWebStoreOpen) {
983
+ /**
984
+ * if (!this.isWebStoreOpen)
985
+ this.isWebStoreOpen = await this.jeepSqliteElement.isStoreOpen();
986
+ */
987
+ throw new Error('WebStore is not open yet. You have to call "initWebStore()" first.');
988
+ }
989
+ }
990
+ ////////////////////////////////////
991
+ ////// UNIMPLEMENTED METHODS
992
+ ////////////////////////////////////
993
+ async getUrl() {
994
+ throw this.unimplemented('Not implemented on web.');
995
+ }
1216
996
  async getMigratableDbList(options) {
1217
997
  console.log('getMigratableDbList', options);
1218
998
  throw this.unimplemented('Not implemented on web.');
@@ -1225,11 +1005,38 @@ class CapacitorSQLiteWeb extends core.WebPlugin {
1225
1005
  console.log('deleteOldDatabases', options);
1226
1006
  throw this.unimplemented('Not implemented on web.');
1227
1007
  }
1008
+ async isSecretStored() {
1009
+ throw this.unimplemented('Not implemented on web.');
1010
+ }
1011
+ async setEncryptionSecret(options) {
1012
+ console.log('setEncryptionSecret', options);
1013
+ throw this.unimplemented('Not implemented on web.');
1014
+ }
1015
+ async changeEncryptionSecret(options) {
1016
+ console.log('changeEncryptionSecret', options);
1017
+ throw this.unimplemented('Not implemented on web.');
1018
+ }
1019
+ async getNCDatabasePath(options) {
1020
+ console.log('getNCDatabasePath', options);
1021
+ throw this.unimplemented('Not implemented on web.');
1022
+ }
1023
+ async createNCConnection(options) {
1024
+ console.log('createNCConnection', options);
1025
+ throw this.unimplemented('Not implemented on web.');
1026
+ }
1027
+ async closeNCConnection(options) {
1028
+ console.log('closeNCConnection', options);
1029
+ throw this.unimplemented('Not implemented on web.');
1030
+ }
1031
+ async isNCDatabase(options) {
1032
+ console.log('isNCDatabase', options);
1033
+ throw this.unimplemented('Not implemented on web.');
1034
+ }
1228
1035
  }
1229
1036
 
1230
1037
  var web = /*#__PURE__*/Object.freeze({
1231
- __proto__: null,
1232
- CapacitorSQLiteWeb: CapacitorSQLiteWeb
1038
+ __proto__: null,
1039
+ CapacitorSQLiteWeb: CapacitorSQLiteWeb
1233
1040
  });
1234
1041
 
1235
1042
  exports.CapacitorSQLite = CapacitorSQLite;