@capacitor-community/sqlite 3.4.2-4 → 3.4.3-1

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