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