cozy-pouch-link 49.4.0 → 49.6.0
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/CozyPouchLink.js +262 -177
- package/dist/types.js +21 -0
- package/package.json +3 -3
- package/types/CozyPouchLink.d.ts +17 -0
- package/types/types.d.ts +3 -0
package/dist/CozyPouchLink.js
CHANGED
|
@@ -722,6 +722,91 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
722
722
|
|
|
723
723
|
return request;
|
|
724
724
|
}()
|
|
725
|
+
/**
|
|
726
|
+
* Get PouchDB changes
|
|
727
|
+
* See https://pouchdb.com/api.html#changes
|
|
728
|
+
*
|
|
729
|
+
* @param {string} doctype - The PouchDB database's doctype
|
|
730
|
+
* @param {object} options - The changes options. See https://pouchdb.com/api.html#changes
|
|
731
|
+
* @returns {Promise<import('./types').PouchDBChangesResults>} The changes
|
|
732
|
+
*/
|
|
733
|
+
|
|
734
|
+
}, {
|
|
735
|
+
key: "getChanges",
|
|
736
|
+
value: function () {
|
|
737
|
+
var _getChanges = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(doctype, options) {
|
|
738
|
+
var pouch;
|
|
739
|
+
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
740
|
+
while (1) {
|
|
741
|
+
switch (_context7.prev = _context7.next) {
|
|
742
|
+
case 0:
|
|
743
|
+
if (doctype) {
|
|
744
|
+
_context7.next = 2;
|
|
745
|
+
break;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
return _context7.abrupt("return", null);
|
|
749
|
+
|
|
750
|
+
case 2:
|
|
751
|
+
pouch = this.getPouch(doctype);
|
|
752
|
+
return _context7.abrupt("return", pouch.changes(options));
|
|
753
|
+
|
|
754
|
+
case 4:
|
|
755
|
+
case "end":
|
|
756
|
+
return _context7.stop();
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
}, _callee7, this);
|
|
760
|
+
}));
|
|
761
|
+
|
|
762
|
+
function getChanges(_x5, _x6) {
|
|
763
|
+
return _getChanges.apply(this, arguments);
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
return getChanges;
|
|
767
|
+
}()
|
|
768
|
+
/**
|
|
769
|
+
* Get PouchDB database info
|
|
770
|
+
* See https://pouchdb.com/api.html#database_information
|
|
771
|
+
*
|
|
772
|
+
* @param {string} doctype - The PouchDB database's doctype
|
|
773
|
+
* @returns {Promise<import('./types').PouchDBInfo>} The db info
|
|
774
|
+
*/
|
|
775
|
+
|
|
776
|
+
}, {
|
|
777
|
+
key: "getDbInfo",
|
|
778
|
+
value: function () {
|
|
779
|
+
var _getDbInfo = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8(doctype) {
|
|
780
|
+
var pouch;
|
|
781
|
+
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
782
|
+
while (1) {
|
|
783
|
+
switch (_context8.prev = _context8.next) {
|
|
784
|
+
case 0:
|
|
785
|
+
if (doctype) {
|
|
786
|
+
_context8.next = 2;
|
|
787
|
+
break;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
return _context8.abrupt("return", null);
|
|
791
|
+
|
|
792
|
+
case 2:
|
|
793
|
+
pouch = this.getPouch(doctype);
|
|
794
|
+
return _context8.abrupt("return", pouch.info());
|
|
795
|
+
|
|
796
|
+
case 4:
|
|
797
|
+
case "end":
|
|
798
|
+
return _context8.stop();
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
}, _callee8, this);
|
|
802
|
+
}));
|
|
803
|
+
|
|
804
|
+
function getDbInfo(_x7) {
|
|
805
|
+
return _getDbInfo.apply(this, arguments);
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
return getDbInfo;
|
|
809
|
+
}()
|
|
725
810
|
}, {
|
|
726
811
|
key: "sanitizeJsonApi",
|
|
727
812
|
value: function sanitizeJsonApi(data) {
|
|
@@ -748,42 +833,42 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
748
833
|
}, {
|
|
749
834
|
key: "persistCozyData",
|
|
750
835
|
value: function () {
|
|
751
|
-
var _persistCozyData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
836
|
+
var _persistCozyData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(data) {
|
|
752
837
|
var forward,
|
|
753
838
|
sanitizedDoc,
|
|
754
839
|
oldDoc,
|
|
755
840
|
db,
|
|
756
|
-
|
|
757
|
-
return _regenerator.default.wrap(function
|
|
841
|
+
_args9 = arguments;
|
|
842
|
+
return _regenerator.default.wrap(function _callee9$(_context9) {
|
|
758
843
|
while (1) {
|
|
759
|
-
switch (
|
|
844
|
+
switch (_context9.prev = _context9.next) {
|
|
760
845
|
case 0:
|
|
761
|
-
forward =
|
|
846
|
+
forward = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : doNothing;
|
|
762
847
|
sanitizedDoc = this.sanitizeJsonApi(data);
|
|
763
848
|
sanitizedDoc.cozyLocalOnly = true;
|
|
764
|
-
|
|
849
|
+
_context9.next = 5;
|
|
765
850
|
return this.getExistingDocument(data._id, data._type);
|
|
766
851
|
|
|
767
852
|
case 5:
|
|
768
|
-
oldDoc =
|
|
853
|
+
oldDoc = _context9.sent;
|
|
769
854
|
|
|
770
855
|
if (oldDoc) {
|
|
771
856
|
sanitizedDoc._rev = oldDoc._rev;
|
|
772
857
|
}
|
|
773
858
|
|
|
774
859
|
db = this.pouches.getPouch(data._type);
|
|
775
|
-
|
|
860
|
+
_context9.next = 10;
|
|
776
861
|
return db.put(sanitizedDoc);
|
|
777
862
|
|
|
778
863
|
case 10:
|
|
779
864
|
case "end":
|
|
780
|
-
return
|
|
865
|
+
return _context9.stop();
|
|
781
866
|
}
|
|
782
867
|
}
|
|
783
|
-
},
|
|
868
|
+
}, _callee9, this);
|
|
784
869
|
}));
|
|
785
870
|
|
|
786
|
-
function persistCozyData(
|
|
871
|
+
function persistCozyData(_x8) {
|
|
787
872
|
return _persistCozyData.apply(this, arguments);
|
|
788
873
|
}
|
|
789
874
|
|
|
@@ -802,48 +887,48 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
802
887
|
}, {
|
|
803
888
|
key: "getExistingDocument",
|
|
804
889
|
value: function () {
|
|
805
|
-
var _getExistingDocument = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
890
|
+
var _getExistingDocument = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10(id, type) {
|
|
806
891
|
var throwIfNotFound,
|
|
807
892
|
db,
|
|
808
893
|
existingDoc,
|
|
809
|
-
|
|
810
|
-
return _regenerator.default.wrap(function
|
|
894
|
+
_args10 = arguments;
|
|
895
|
+
return _regenerator.default.wrap(function _callee10$(_context10) {
|
|
811
896
|
while (1) {
|
|
812
|
-
switch (
|
|
897
|
+
switch (_context10.prev = _context10.next) {
|
|
813
898
|
case 0:
|
|
814
|
-
throwIfNotFound =
|
|
815
|
-
|
|
899
|
+
throwIfNotFound = _args10.length > 2 && _args10[2] !== undefined ? _args10[2] : false;
|
|
900
|
+
_context10.prev = 1;
|
|
816
901
|
db = this.pouches.getPouch(type);
|
|
817
|
-
|
|
902
|
+
_context10.next = 5;
|
|
818
903
|
return db.get(id);
|
|
819
904
|
|
|
820
905
|
case 5:
|
|
821
|
-
existingDoc =
|
|
822
|
-
return
|
|
906
|
+
existingDoc = _context10.sent;
|
|
907
|
+
return _context10.abrupt("return", existingDoc);
|
|
823
908
|
|
|
824
909
|
case 9:
|
|
825
|
-
|
|
826
|
-
|
|
910
|
+
_context10.prev = 9;
|
|
911
|
+
_context10.t0 = _context10["catch"](1);
|
|
827
912
|
|
|
828
|
-
if (!(
|
|
829
|
-
|
|
913
|
+
if (!(_context10.t0.name === 'not_found' && !throwIfNotFound)) {
|
|
914
|
+
_context10.next = 15;
|
|
830
915
|
break;
|
|
831
916
|
}
|
|
832
917
|
|
|
833
|
-
return
|
|
918
|
+
return _context10.abrupt("return", null);
|
|
834
919
|
|
|
835
920
|
case 15:
|
|
836
|
-
throw
|
|
921
|
+
throw _context10.t0;
|
|
837
922
|
|
|
838
923
|
case 16:
|
|
839
924
|
case "end":
|
|
840
|
-
return
|
|
925
|
+
return _context10.stop();
|
|
841
926
|
}
|
|
842
927
|
}
|
|
843
|
-
},
|
|
928
|
+
}, _callee10, this, [[1, 9]]);
|
|
844
929
|
}));
|
|
845
930
|
|
|
846
|
-
function getExistingDocument(
|
|
931
|
+
function getExistingDocument(_x9, _x10) {
|
|
847
932
|
return _getExistingDocument.apply(this, arguments);
|
|
848
933
|
}
|
|
849
934
|
|
|
@@ -861,34 +946,34 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
861
946
|
}, {
|
|
862
947
|
key: "needsToWaitWarmup",
|
|
863
948
|
value: function () {
|
|
864
|
-
var _needsToWaitWarmup = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
865
|
-
return _regenerator.default.wrap(function
|
|
949
|
+
var _needsToWaitWarmup = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee11(doctype) {
|
|
950
|
+
return _regenerator.default.wrap(function _callee11$(_context11) {
|
|
866
951
|
while (1) {
|
|
867
|
-
switch (
|
|
952
|
+
switch (_context11.prev = _context11.next) {
|
|
868
953
|
case 0:
|
|
869
954
|
if (!(this.doctypesReplicationOptions && this.doctypesReplicationOptions[doctype] && this.doctypesReplicationOptions[doctype].warmupQueries)) {
|
|
870
|
-
|
|
955
|
+
_context11.next = 4;
|
|
871
956
|
break;
|
|
872
957
|
}
|
|
873
958
|
|
|
874
|
-
|
|
959
|
+
_context11.next = 3;
|
|
875
960
|
return this.pouches.areQueriesWarmedUp(doctype, this.doctypesReplicationOptions[doctype].warmupQueries);
|
|
876
961
|
|
|
877
962
|
case 3:
|
|
878
|
-
return
|
|
963
|
+
return _context11.abrupt("return", !_context11.sent);
|
|
879
964
|
|
|
880
965
|
case 4:
|
|
881
|
-
return
|
|
966
|
+
return _context11.abrupt("return", false);
|
|
882
967
|
|
|
883
968
|
case 5:
|
|
884
969
|
case "end":
|
|
885
|
-
return
|
|
970
|
+
return _context11.stop();
|
|
886
971
|
}
|
|
887
972
|
}
|
|
888
|
-
},
|
|
973
|
+
}, _callee11, this);
|
|
889
974
|
}));
|
|
890
975
|
|
|
891
|
-
function needsToWaitWarmup(
|
|
976
|
+
function needsToWaitWarmup(_x11) {
|
|
892
977
|
return _needsToWaitWarmup.apply(this, arguments);
|
|
893
978
|
}
|
|
894
979
|
|
|
@@ -913,7 +998,7 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
913
998
|
}, {
|
|
914
999
|
key: "createIndex",
|
|
915
1000
|
value: function () {
|
|
916
|
-
var _createIndex = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
1001
|
+
var _createIndex = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(fields) {
|
|
917
1002
|
var _ref2,
|
|
918
1003
|
partialFilter,
|
|
919
1004
|
indexName,
|
|
@@ -921,16 +1006,16 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
921
1006
|
absName,
|
|
922
1007
|
db,
|
|
923
1008
|
index,
|
|
924
|
-
|
|
1009
|
+
_args12 = arguments;
|
|
925
1010
|
|
|
926
|
-
return _regenerator.default.wrap(function
|
|
1011
|
+
return _regenerator.default.wrap(function _callee12$(_context12) {
|
|
927
1012
|
while (1) {
|
|
928
|
-
switch (
|
|
1013
|
+
switch (_context12.prev = _context12.next) {
|
|
929
1014
|
case 0:
|
|
930
|
-
_ref2 =
|
|
1015
|
+
_ref2 = _args12.length > 1 && _args12[1] !== undefined ? _args12[1] : {}, partialFilter = _ref2.partialFilter, indexName = _ref2.indexName, doctype = _ref2.doctype;
|
|
931
1016
|
absName = "".concat(doctype, "/").concat(indexName);
|
|
932
1017
|
db = this.pouches.getPouch(doctype);
|
|
933
|
-
|
|
1018
|
+
_context12.next = 5;
|
|
934
1019
|
return db.createIndex({
|
|
935
1020
|
index: {
|
|
936
1021
|
fields: fields,
|
|
@@ -941,19 +1026,19 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
941
1026
|
});
|
|
942
1027
|
|
|
943
1028
|
case 5:
|
|
944
|
-
index =
|
|
1029
|
+
index = _context12.sent;
|
|
945
1030
|
this.indexes[absName] = index;
|
|
946
|
-
return
|
|
1031
|
+
return _context12.abrupt("return", index);
|
|
947
1032
|
|
|
948
1033
|
case 8:
|
|
949
1034
|
case "end":
|
|
950
|
-
return
|
|
1035
|
+
return _context12.stop();
|
|
951
1036
|
}
|
|
952
1037
|
}
|
|
953
|
-
},
|
|
1038
|
+
}, _callee12, this);
|
|
954
1039
|
}));
|
|
955
1040
|
|
|
956
|
-
function createIndex(
|
|
1041
|
+
function createIndex(_x12) {
|
|
957
1042
|
return _createIndex.apply(this, arguments);
|
|
958
1043
|
}
|
|
959
1044
|
|
|
@@ -992,11 +1077,11 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
992
1077
|
}, {
|
|
993
1078
|
key: "ensureIndex",
|
|
994
1079
|
value: function () {
|
|
995
|
-
var _ensureIndex = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
1080
|
+
var _ensureIndex = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(doctype, options) {
|
|
996
1081
|
var indexedFields, partialFilter, indexName, existingIndex;
|
|
997
|
-
return _regenerator.default.wrap(function
|
|
1082
|
+
return _regenerator.default.wrap(function _callee13$(_context13) {
|
|
998
1083
|
while (1) {
|
|
999
|
-
switch (
|
|
1084
|
+
switch (_context13.prev = _context13.next) {
|
|
1000
1085
|
case 0:
|
|
1001
1086
|
indexedFields = options.indexedFields, partialFilter = options.partialFilter;
|
|
1002
1087
|
|
|
@@ -1019,11 +1104,11 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
1019
1104
|
existingIndex = this.findExistingIndex(doctype, options, indexName);
|
|
1020
1105
|
|
|
1021
1106
|
if (existingIndex) {
|
|
1022
|
-
|
|
1107
|
+
_context13.next = 10;
|
|
1023
1108
|
break;
|
|
1024
1109
|
}
|
|
1025
1110
|
|
|
1026
|
-
|
|
1111
|
+
_context13.next = 7;
|
|
1027
1112
|
return this.createIndex(indexedFields, {
|
|
1028
1113
|
partialFilter: partialFilter,
|
|
1029
1114
|
indexName: indexName,
|
|
@@ -1031,20 +1116,20 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
1031
1116
|
});
|
|
1032
1117
|
|
|
1033
1118
|
case 7:
|
|
1034
|
-
return
|
|
1119
|
+
return _context13.abrupt("return", _context13.sent);
|
|
1035
1120
|
|
|
1036
1121
|
case 10:
|
|
1037
|
-
return
|
|
1122
|
+
return _context13.abrupt("return", existingIndex);
|
|
1038
1123
|
|
|
1039
1124
|
case 11:
|
|
1040
1125
|
case "end":
|
|
1041
|
-
return
|
|
1126
|
+
return _context13.stop();
|
|
1042
1127
|
}
|
|
1043
1128
|
}
|
|
1044
|
-
},
|
|
1129
|
+
}, _callee13, this);
|
|
1045
1130
|
}));
|
|
1046
1131
|
|
|
1047
|
-
function ensureIndex(
|
|
1132
|
+
function ensureIndex(_x13, _x14) {
|
|
1048
1133
|
return _ensureIndex.apply(this, arguments);
|
|
1049
1134
|
}
|
|
1050
1135
|
|
|
@@ -1053,67 +1138,67 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
1053
1138
|
}, {
|
|
1054
1139
|
key: "executeQuery",
|
|
1055
1140
|
value: function () {
|
|
1056
|
-
var _executeQuery = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
1141
|
+
var _executeQuery = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(_ref3) {
|
|
1057
1142
|
var doctype, selector, sort, fields, limit, id, ids, skip, indexedFields, partialFilter, db, res, withRows, findSelector, findOpts, index;
|
|
1058
|
-
return _regenerator.default.wrap(function
|
|
1143
|
+
return _regenerator.default.wrap(function _callee14$(_context14) {
|
|
1059
1144
|
while (1) {
|
|
1060
|
-
switch (
|
|
1145
|
+
switch (_context14.prev = _context14.next) {
|
|
1061
1146
|
case 0:
|
|
1062
1147
|
doctype = _ref3.doctype, selector = _ref3.selector, sort = _ref3.sort, fields = _ref3.fields, limit = _ref3.limit, id = _ref3.id, ids = _ref3.ids, skip = _ref3.skip, indexedFields = _ref3.indexedFields, partialFilter = _ref3.partialFilter;
|
|
1063
1148
|
db = this.getPouch(doctype);
|
|
1064
1149
|
|
|
1065
1150
|
if (!id) {
|
|
1066
|
-
|
|
1151
|
+
_context14.next = 9;
|
|
1067
1152
|
break;
|
|
1068
1153
|
}
|
|
1069
1154
|
|
|
1070
|
-
|
|
1155
|
+
_context14.next = 5;
|
|
1071
1156
|
return db.get(id);
|
|
1072
1157
|
|
|
1073
1158
|
case 5:
|
|
1074
|
-
res =
|
|
1159
|
+
res = _context14.sent;
|
|
1075
1160
|
withRows = false;
|
|
1076
|
-
|
|
1161
|
+
_context14.next = 38;
|
|
1077
1162
|
break;
|
|
1078
1163
|
|
|
1079
1164
|
case 9:
|
|
1080
1165
|
if (!ids) {
|
|
1081
|
-
|
|
1166
|
+
_context14.next = 18;
|
|
1082
1167
|
break;
|
|
1083
1168
|
}
|
|
1084
1169
|
|
|
1085
|
-
|
|
1170
|
+
_context14.next = 12;
|
|
1086
1171
|
return allDocs(db, {
|
|
1087
1172
|
include_docs: true,
|
|
1088
1173
|
keys: ids
|
|
1089
1174
|
});
|
|
1090
1175
|
|
|
1091
1176
|
case 12:
|
|
1092
|
-
res =
|
|
1177
|
+
res = _context14.sent;
|
|
1093
1178
|
res = withoutDesignDocuments(res);
|
|
1094
1179
|
res.total_rows = null; // pouch indicates the total number of docs in res.total_rows, even though we use "keys". Setting it to null avoids cozy-client thinking there are more docs to fetch.
|
|
1095
1180
|
|
|
1096
1181
|
withRows = true;
|
|
1097
|
-
|
|
1182
|
+
_context14.next = 38;
|
|
1098
1183
|
break;
|
|
1099
1184
|
|
|
1100
1185
|
case 18:
|
|
1101
1186
|
if (!(!selector && !partialFilter && !fields && !sort)) {
|
|
1102
|
-
|
|
1187
|
+
_context14.next = 26;
|
|
1103
1188
|
break;
|
|
1104
1189
|
}
|
|
1105
1190
|
|
|
1106
|
-
|
|
1191
|
+
_context14.next = 21;
|
|
1107
1192
|
return allDocs(db, {
|
|
1108
1193
|
include_docs: true,
|
|
1109
1194
|
limit: limit
|
|
1110
1195
|
});
|
|
1111
1196
|
|
|
1112
1197
|
case 21:
|
|
1113
|
-
res =
|
|
1198
|
+
res = _context14.sent;
|
|
1114
1199
|
res = withoutDesignDocuments(res);
|
|
1115
1200
|
withRows = true;
|
|
1116
|
-
|
|
1201
|
+
_context14.next = 38;
|
|
1117
1202
|
break;
|
|
1118
1203
|
|
|
1119
1204
|
case 26:
|
|
@@ -1132,26 +1217,26 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
1132
1217
|
limit: limit,
|
|
1133
1218
|
skip: skip
|
|
1134
1219
|
};
|
|
1135
|
-
|
|
1220
|
+
_context14.next = 30;
|
|
1136
1221
|
return this.ensureIndex(doctype, _objectSpread(_objectSpread({}, findOpts), {}, {
|
|
1137
1222
|
indexedFields: indexedFields,
|
|
1138
1223
|
partialFilter: partialFilter
|
|
1139
1224
|
}));
|
|
1140
1225
|
|
|
1141
1226
|
case 30:
|
|
1142
|
-
index =
|
|
1227
|
+
index = _context14.sent;
|
|
1143
1228
|
findOpts.use_index = index.id;
|
|
1144
|
-
|
|
1229
|
+
_context14.next = 34;
|
|
1145
1230
|
return find(db, findOpts);
|
|
1146
1231
|
|
|
1147
1232
|
case 34:
|
|
1148
|
-
res =
|
|
1233
|
+
res = _context14.sent;
|
|
1149
1234
|
res.offset = skip;
|
|
1150
1235
|
res.limit = limit;
|
|
1151
1236
|
withRows = true;
|
|
1152
1237
|
|
|
1153
1238
|
case 38:
|
|
1154
|
-
return
|
|
1239
|
+
return _context14.abrupt("return", jsonapi.fromPouchResult({
|
|
1155
1240
|
res: res,
|
|
1156
1241
|
withRows: withRows,
|
|
1157
1242
|
doctype: doctype,
|
|
@@ -1160,13 +1245,13 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
1160
1245
|
|
|
1161
1246
|
case 39:
|
|
1162
1247
|
case "end":
|
|
1163
|
-
return
|
|
1248
|
+
return _context14.stop();
|
|
1164
1249
|
}
|
|
1165
1250
|
}
|
|
1166
|
-
},
|
|
1251
|
+
}, _callee14, this);
|
|
1167
1252
|
}));
|
|
1168
1253
|
|
|
1169
|
-
function executeQuery(
|
|
1254
|
+
function executeQuery(_x15) {
|
|
1170
1255
|
return _executeQuery.apply(this, arguments);
|
|
1171
1256
|
}
|
|
1172
1257
|
|
|
@@ -1175,61 +1260,61 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
1175
1260
|
}, {
|
|
1176
1261
|
key: "executeMutation",
|
|
1177
1262
|
value: function () {
|
|
1178
|
-
var _executeMutation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
1263
|
+
var _executeMutation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(mutation, result, forward) {
|
|
1179
1264
|
var pouchRes;
|
|
1180
|
-
return _regenerator.default.wrap(function
|
|
1265
|
+
return _regenerator.default.wrap(function _callee15$(_context15) {
|
|
1181
1266
|
while (1) {
|
|
1182
|
-
switch (
|
|
1267
|
+
switch (_context15.prev = _context15.next) {
|
|
1183
1268
|
case 0:
|
|
1184
|
-
|
|
1185
|
-
|
|
1269
|
+
_context15.t0 = mutation.mutationType;
|
|
1270
|
+
_context15.next = _context15.t0 === _cozyClient.MutationTypes.CREATE_DOCUMENT ? 3 : _context15.t0 === _cozyClient.MutationTypes.UPDATE_DOCUMENT ? 7 : _context15.t0 === _cozyClient.MutationTypes.UPDATE_DOCUMENTS ? 11 : _context15.t0 === _cozyClient.MutationTypes.DELETE_DOCUMENT ? 15 : _context15.t0 === _cozyClient.MutationTypes.ADD_REFERENCES_TO ? 19 : 23;
|
|
1186
1271
|
break;
|
|
1187
1272
|
|
|
1188
1273
|
case 3:
|
|
1189
|
-
|
|
1274
|
+
_context15.next = 5;
|
|
1190
1275
|
return this.createDocument(mutation);
|
|
1191
1276
|
|
|
1192
1277
|
case 5:
|
|
1193
|
-
pouchRes =
|
|
1194
|
-
return
|
|
1278
|
+
pouchRes = _context15.sent;
|
|
1279
|
+
return _context15.abrupt("break", 24);
|
|
1195
1280
|
|
|
1196
1281
|
case 7:
|
|
1197
|
-
|
|
1282
|
+
_context15.next = 9;
|
|
1198
1283
|
return this.updateDocument(mutation);
|
|
1199
1284
|
|
|
1200
1285
|
case 9:
|
|
1201
|
-
pouchRes =
|
|
1202
|
-
return
|
|
1286
|
+
pouchRes = _context15.sent;
|
|
1287
|
+
return _context15.abrupt("break", 24);
|
|
1203
1288
|
|
|
1204
1289
|
case 11:
|
|
1205
|
-
|
|
1290
|
+
_context15.next = 13;
|
|
1206
1291
|
return this.updateDocuments(mutation);
|
|
1207
1292
|
|
|
1208
1293
|
case 13:
|
|
1209
|
-
pouchRes =
|
|
1210
|
-
return
|
|
1294
|
+
pouchRes = _context15.sent;
|
|
1295
|
+
return _context15.abrupt("break", 24);
|
|
1211
1296
|
|
|
1212
1297
|
case 15:
|
|
1213
|
-
|
|
1298
|
+
_context15.next = 17;
|
|
1214
1299
|
return this.deleteDocument(mutation);
|
|
1215
1300
|
|
|
1216
1301
|
case 17:
|
|
1217
|
-
pouchRes =
|
|
1218
|
-
return
|
|
1302
|
+
pouchRes = _context15.sent;
|
|
1303
|
+
return _context15.abrupt("break", 24);
|
|
1219
1304
|
|
|
1220
1305
|
case 19:
|
|
1221
|
-
|
|
1306
|
+
_context15.next = 21;
|
|
1222
1307
|
return this.addReferencesTo(mutation);
|
|
1223
1308
|
|
|
1224
1309
|
case 21:
|
|
1225
|
-
pouchRes =
|
|
1226
|
-
return
|
|
1310
|
+
pouchRes = _context15.sent;
|
|
1311
|
+
return _context15.abrupt("break", 24);
|
|
1227
1312
|
|
|
1228
1313
|
case 23:
|
|
1229
|
-
return
|
|
1314
|
+
return _context15.abrupt("return", forward(mutation, result));
|
|
1230
1315
|
|
|
1231
1316
|
case 24:
|
|
1232
|
-
return
|
|
1317
|
+
return _context15.abrupt("return", jsonapi.fromPouchResult({
|
|
1233
1318
|
res: pouchRes,
|
|
1234
1319
|
withRows: false,
|
|
1235
1320
|
doctype: (0, _cozyClient.getDoctypeFromOperation)(mutation),
|
|
@@ -1238,13 +1323,13 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
1238
1323
|
|
|
1239
1324
|
case 25:
|
|
1240
1325
|
case "end":
|
|
1241
|
-
return
|
|
1326
|
+
return _context15.stop();
|
|
1242
1327
|
}
|
|
1243
1328
|
}
|
|
1244
|
-
},
|
|
1329
|
+
}, _callee15, this);
|
|
1245
1330
|
}));
|
|
1246
1331
|
|
|
1247
|
-
function executeMutation(
|
|
1332
|
+
function executeMutation(_x16, _x17, _x18) {
|
|
1248
1333
|
return _executeMutation.apply(this, arguments);
|
|
1249
1334
|
}
|
|
1250
1335
|
|
|
@@ -1253,28 +1338,28 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
1253
1338
|
}, {
|
|
1254
1339
|
key: "createDocument",
|
|
1255
1340
|
value: function () {
|
|
1256
|
-
var _createDocument = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
1341
|
+
var _createDocument = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16(mutation) {
|
|
1257
1342
|
var res;
|
|
1258
|
-
return _regenerator.default.wrap(function
|
|
1343
|
+
return _regenerator.default.wrap(function _callee16$(_context16) {
|
|
1259
1344
|
while (1) {
|
|
1260
|
-
switch (
|
|
1345
|
+
switch (_context16.prev = _context16.next) {
|
|
1261
1346
|
case 0:
|
|
1262
|
-
|
|
1347
|
+
_context16.next = 2;
|
|
1263
1348
|
return this.dbMethod('post', mutation);
|
|
1264
1349
|
|
|
1265
1350
|
case 2:
|
|
1266
|
-
res =
|
|
1267
|
-
return
|
|
1351
|
+
res = _context16.sent;
|
|
1352
|
+
return _context16.abrupt("return", parseMutationResult(mutation.document, res));
|
|
1268
1353
|
|
|
1269
1354
|
case 4:
|
|
1270
1355
|
case "end":
|
|
1271
|
-
return
|
|
1356
|
+
return _context16.stop();
|
|
1272
1357
|
}
|
|
1273
1358
|
}
|
|
1274
|
-
},
|
|
1359
|
+
}, _callee16, this);
|
|
1275
1360
|
}));
|
|
1276
1361
|
|
|
1277
|
-
function createDocument(
|
|
1362
|
+
function createDocument(_x19) {
|
|
1278
1363
|
return _createDocument.apply(this, arguments);
|
|
1279
1364
|
}
|
|
1280
1365
|
|
|
@@ -1283,28 +1368,28 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
1283
1368
|
}, {
|
|
1284
1369
|
key: "updateDocument",
|
|
1285
1370
|
value: function () {
|
|
1286
|
-
var _updateDocument = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
1371
|
+
var _updateDocument = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(mutation) {
|
|
1287
1372
|
var res;
|
|
1288
|
-
return _regenerator.default.wrap(function
|
|
1373
|
+
return _regenerator.default.wrap(function _callee17$(_context17) {
|
|
1289
1374
|
while (1) {
|
|
1290
|
-
switch (
|
|
1375
|
+
switch (_context17.prev = _context17.next) {
|
|
1291
1376
|
case 0:
|
|
1292
|
-
|
|
1377
|
+
_context17.next = 2;
|
|
1293
1378
|
return this.dbMethod('put', mutation);
|
|
1294
1379
|
|
|
1295
1380
|
case 2:
|
|
1296
|
-
res =
|
|
1297
|
-
return
|
|
1381
|
+
res = _context17.sent;
|
|
1382
|
+
return _context17.abrupt("return", parseMutationResult(mutation.document, res));
|
|
1298
1383
|
|
|
1299
1384
|
case 4:
|
|
1300
1385
|
case "end":
|
|
1301
|
-
return
|
|
1386
|
+
return _context17.stop();
|
|
1302
1387
|
}
|
|
1303
1388
|
}
|
|
1304
|
-
},
|
|
1389
|
+
}, _callee17, this);
|
|
1305
1390
|
}));
|
|
1306
1391
|
|
|
1307
|
-
function updateDocument(
|
|
1392
|
+
function updateDocument(_x20) {
|
|
1308
1393
|
return _updateDocument.apply(this, arguments);
|
|
1309
1394
|
}
|
|
1310
1395
|
|
|
@@ -1313,18 +1398,18 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
1313
1398
|
}, {
|
|
1314
1399
|
key: "updateDocuments",
|
|
1315
1400
|
value: function () {
|
|
1316
|
-
var _updateDocuments = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
1401
|
+
var _updateDocuments = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18(mutation) {
|
|
1317
1402
|
var docs, bulkResponse, updatedDocs;
|
|
1318
|
-
return _regenerator.default.wrap(function
|
|
1403
|
+
return _regenerator.default.wrap(function _callee18$(_context18) {
|
|
1319
1404
|
while (1) {
|
|
1320
|
-
switch (
|
|
1405
|
+
switch (_context18.prev = _context18.next) {
|
|
1321
1406
|
case 0:
|
|
1322
1407
|
docs = mutation.documents;
|
|
1323
|
-
|
|
1408
|
+
_context18.next = 3;
|
|
1324
1409
|
return this.dbMethod('bulkDocs', mutation);
|
|
1325
1410
|
|
|
1326
1411
|
case 3:
|
|
1327
|
-
bulkResponse =
|
|
1412
|
+
bulkResponse = _context18.sent;
|
|
1328
1413
|
updatedDocs = (0, _zipWith.default)(bulkResponse, docs, function (bulkResult, originalDoc) {
|
|
1329
1414
|
return _objectSpread(_objectSpread({}, originalDoc), {}, {
|
|
1330
1415
|
_id: bulkResult.id,
|
|
@@ -1335,24 +1420,24 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
1335
1420
|
if (!bulkResponse.find(function (x) {
|
|
1336
1421
|
return !x.ok;
|
|
1337
1422
|
})) {
|
|
1338
|
-
|
|
1423
|
+
_context18.next = 7;
|
|
1339
1424
|
break;
|
|
1340
1425
|
}
|
|
1341
1426
|
|
|
1342
1427
|
throw new _cozyClient.BulkEditError(bulkResponse, updatedDocs);
|
|
1343
1428
|
|
|
1344
1429
|
case 7:
|
|
1345
|
-
return
|
|
1430
|
+
return _context18.abrupt("return", updatedDocs);
|
|
1346
1431
|
|
|
1347
1432
|
case 8:
|
|
1348
1433
|
case "end":
|
|
1349
|
-
return
|
|
1434
|
+
return _context18.stop();
|
|
1350
1435
|
}
|
|
1351
1436
|
}
|
|
1352
|
-
},
|
|
1437
|
+
}, _callee18, this);
|
|
1353
1438
|
}));
|
|
1354
1439
|
|
|
1355
|
-
function updateDocuments(
|
|
1440
|
+
function updateDocuments(_x21) {
|
|
1356
1441
|
return _updateDocuments.apply(this, arguments);
|
|
1357
1442
|
}
|
|
1358
1443
|
|
|
@@ -1361,33 +1446,33 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
1361
1446
|
}, {
|
|
1362
1447
|
key: "deleteDocument",
|
|
1363
1448
|
value: function () {
|
|
1364
|
-
var _deleteDocument = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
1449
|
+
var _deleteDocument = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19(mutation) {
|
|
1365
1450
|
var res, document;
|
|
1366
|
-
return _regenerator.default.wrap(function
|
|
1451
|
+
return _regenerator.default.wrap(function _callee19$(_context19) {
|
|
1367
1452
|
while (1) {
|
|
1368
|
-
switch (
|
|
1453
|
+
switch (_context19.prev = _context19.next) {
|
|
1369
1454
|
case 0:
|
|
1370
|
-
|
|
1455
|
+
_context19.next = 2;
|
|
1371
1456
|
return this.dbMethod('remove', mutation);
|
|
1372
1457
|
|
|
1373
1458
|
case 2:
|
|
1374
|
-
res =
|
|
1459
|
+
res = _context19.sent;
|
|
1375
1460
|
document = _objectSpread(_objectSpread({}, mutation.document), {}, {
|
|
1376
1461
|
_id: res.id,
|
|
1377
1462
|
_rev: res.rev,
|
|
1378
1463
|
_deleted: true
|
|
1379
1464
|
});
|
|
1380
|
-
return
|
|
1465
|
+
return _context19.abrupt("return", parseMutationResult(document, res));
|
|
1381
1466
|
|
|
1382
1467
|
case 5:
|
|
1383
1468
|
case "end":
|
|
1384
|
-
return
|
|
1469
|
+
return _context19.stop();
|
|
1385
1470
|
}
|
|
1386
1471
|
}
|
|
1387
|
-
},
|
|
1472
|
+
}, _callee19, this);
|
|
1388
1473
|
}));
|
|
1389
1474
|
|
|
1390
|
-
function deleteDocument(
|
|
1475
|
+
function deleteDocument(_x22) {
|
|
1391
1476
|
return _deleteDocument.apply(this, arguments);
|
|
1392
1477
|
}
|
|
1393
1478
|
|
|
@@ -1396,22 +1481,22 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
1396
1481
|
}, {
|
|
1397
1482
|
key: "addReferencesTo",
|
|
1398
1483
|
value: function () {
|
|
1399
|
-
var _addReferencesTo = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
1400
|
-
return _regenerator.default.wrap(function
|
|
1484
|
+
var _addReferencesTo = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20(mutation) {
|
|
1485
|
+
return _regenerator.default.wrap(function _callee20$(_context20) {
|
|
1401
1486
|
while (1) {
|
|
1402
|
-
switch (
|
|
1487
|
+
switch (_context20.prev = _context20.next) {
|
|
1403
1488
|
case 0:
|
|
1404
1489
|
throw new Error('addReferencesTo is not implemented in CozyPouchLink');
|
|
1405
1490
|
|
|
1406
1491
|
case 1:
|
|
1407
1492
|
case "end":
|
|
1408
|
-
return
|
|
1493
|
+
return _context20.stop();
|
|
1409
1494
|
}
|
|
1410
1495
|
}
|
|
1411
|
-
},
|
|
1496
|
+
}, _callee20);
|
|
1412
1497
|
}));
|
|
1413
1498
|
|
|
1414
|
-
function addReferencesTo(
|
|
1499
|
+
function addReferencesTo(_x23) {
|
|
1415
1500
|
return _addReferencesTo.apply(this, arguments);
|
|
1416
1501
|
}
|
|
1417
1502
|
|
|
@@ -1420,66 +1505,66 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
1420
1505
|
}, {
|
|
1421
1506
|
key: "dbMethod",
|
|
1422
1507
|
value: function () {
|
|
1423
|
-
var _dbMethod = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
1508
|
+
var _dbMethod = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21(method, mutation) {
|
|
1424
1509
|
var doctype, doc, docs, db, res;
|
|
1425
|
-
return _regenerator.default.wrap(function
|
|
1510
|
+
return _regenerator.default.wrap(function _callee21$(_context21) {
|
|
1426
1511
|
while (1) {
|
|
1427
|
-
switch (
|
|
1512
|
+
switch (_context21.prev = _context21.next) {
|
|
1428
1513
|
case 0:
|
|
1429
1514
|
doctype = (0, _cozyClient.getDoctypeFromOperation)(mutation);
|
|
1430
1515
|
doc = mutation.document, docs = mutation.documents;
|
|
1431
1516
|
db = this.getPouch(doctype);
|
|
1432
|
-
|
|
1517
|
+
_context21.prev = 3;
|
|
1433
1518
|
|
|
1434
1519
|
if (!docs) {
|
|
1435
|
-
|
|
1520
|
+
_context21.next = 10;
|
|
1436
1521
|
break;
|
|
1437
1522
|
}
|
|
1438
1523
|
|
|
1439
|
-
|
|
1524
|
+
_context21.next = 7;
|
|
1440
1525
|
return db[method](docs.map(function (doc) {
|
|
1441
1526
|
return sanitized(doc);
|
|
1442
1527
|
}));
|
|
1443
1528
|
|
|
1444
1529
|
case 7:
|
|
1445
|
-
res =
|
|
1446
|
-
|
|
1530
|
+
res = _context21.sent;
|
|
1531
|
+
_context21.next = 17;
|
|
1447
1532
|
break;
|
|
1448
1533
|
|
|
1449
1534
|
case 10:
|
|
1450
1535
|
if (!doc) {
|
|
1451
|
-
|
|
1536
|
+
_context21.next = 16;
|
|
1452
1537
|
break;
|
|
1453
1538
|
}
|
|
1454
1539
|
|
|
1455
|
-
|
|
1540
|
+
_context21.next = 13;
|
|
1456
1541
|
return db[method](sanitized(doc));
|
|
1457
1542
|
|
|
1458
1543
|
case 13:
|
|
1459
|
-
res =
|
|
1460
|
-
|
|
1544
|
+
res = _context21.sent;
|
|
1545
|
+
_context21.next = 17;
|
|
1461
1546
|
break;
|
|
1462
1547
|
|
|
1463
1548
|
case 16:
|
|
1464
1549
|
throw new Error('A mutation should either have document or documents member.');
|
|
1465
1550
|
|
|
1466
1551
|
case 17:
|
|
1467
|
-
return
|
|
1552
|
+
return _context21.abrupt("return", res);
|
|
1468
1553
|
|
|
1469
1554
|
case 20:
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
throw new Error("Coud not apply mutation: ".concat(
|
|
1555
|
+
_context21.prev = 20;
|
|
1556
|
+
_context21.t0 = _context21["catch"](3);
|
|
1557
|
+
throw new Error("Coud not apply mutation: ".concat(_context21.t0.message));
|
|
1473
1558
|
|
|
1474
1559
|
case 23:
|
|
1475
1560
|
case "end":
|
|
1476
|
-
return
|
|
1561
|
+
return _context21.stop();
|
|
1477
1562
|
}
|
|
1478
1563
|
}
|
|
1479
|
-
},
|
|
1564
|
+
}, _callee21, this, [[3, 20]]);
|
|
1480
1565
|
}));
|
|
1481
1566
|
|
|
1482
|
-
function dbMethod(
|
|
1567
|
+
function dbMethod(_x24, _x25) {
|
|
1483
1568
|
return _dbMethod.apply(this, arguments);
|
|
1484
1569
|
}
|
|
1485
1570
|
|
|
@@ -1488,29 +1573,29 @@ var PouchLink = /*#__PURE__*/function (_CozyLink) {
|
|
|
1488
1573
|
}, {
|
|
1489
1574
|
key: "syncImmediately",
|
|
1490
1575
|
value: function () {
|
|
1491
|
-
var _syncImmediately = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
1492
|
-
return _regenerator.default.wrap(function
|
|
1576
|
+
var _syncImmediately = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee22() {
|
|
1577
|
+
return _regenerator.default.wrap(function _callee22$(_context22) {
|
|
1493
1578
|
while (1) {
|
|
1494
|
-
switch (
|
|
1579
|
+
switch (_context22.prev = _context22.next) {
|
|
1495
1580
|
case 0:
|
|
1496
1581
|
if (this.pouches) {
|
|
1497
|
-
|
|
1582
|
+
_context22.next = 3;
|
|
1498
1583
|
break;
|
|
1499
1584
|
}
|
|
1500
1585
|
|
|
1501
1586
|
_logger.default.warn('Cannot sync immediately, no PouchManager');
|
|
1502
1587
|
|
|
1503
|
-
return
|
|
1588
|
+
return _context22.abrupt("return");
|
|
1504
1589
|
|
|
1505
1590
|
case 3:
|
|
1506
1591
|
this.pouches.syncImmediately();
|
|
1507
1592
|
|
|
1508
1593
|
case 4:
|
|
1509
1594
|
case "end":
|
|
1510
|
-
return
|
|
1595
|
+
return _context22.stop();
|
|
1511
1596
|
}
|
|
1512
1597
|
}
|
|
1513
|
-
},
|
|
1598
|
+
}, _callee22, this);
|
|
1514
1599
|
}));
|
|
1515
1600
|
|
|
1516
1601
|
function syncImmediately() {
|
package/dist/types.js
CHANGED
|
@@ -76,5 +76,26 @@ exports.default = void 0;
|
|
|
76
76
|
* @property {string} name - The ddoc's name
|
|
77
77
|
* @property {'exists'|'created'} result - If the index has been created or if it already exists
|
|
78
78
|
*/
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* @typedef {object} PouchDBInfo
|
|
82
|
+
* @param {string} db_name - The database name
|
|
83
|
+
* @param {number} doc_count - The number of doc in the database
|
|
84
|
+
* @param {number} update_seq - The sequence number
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @typedef {object} PouchDBChangesResults
|
|
89
|
+
* @param {Array<PouchDBChanges>} results - The changes results
|
|
90
|
+
* @param {number} last_seq - The last sequence number
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @typedef {object} PouchDBChanges
|
|
95
|
+
* @param {string} id - The doc id
|
|
96
|
+
* @param {boolean} deleted - Whether or not the change is a deleted doc
|
|
97
|
+
* @param {Array<object>} changes - The list of changes revisions
|
|
98
|
+
* @param {object} doc - The changed doc
|
|
99
|
+
*/
|
|
79
100
|
var _default = {};
|
|
80
101
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-pouch-link",
|
|
3
|
-
"version": "49.
|
|
3
|
+
"version": "49.6.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"url": "git+https://github.com/cozy/cozy-client.git"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"cozy-client": "^49.
|
|
16
|
+
"cozy-client": "^49.6.0",
|
|
17
17
|
"pouchdb-browser": "^7.2.2",
|
|
18
18
|
"pouchdb-find": "^7.2.2"
|
|
19
19
|
},
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"typecheck": "tsc -p tsconfig.json"
|
|
40
40
|
},
|
|
41
41
|
"sideEffects": false,
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "ca70ddbfd2c7a5e942a5625fec57f1c96d467460"
|
|
43
43
|
}
|
package/types/CozyPouchLink.d.ts
CHANGED
|
@@ -130,6 +130,23 @@ declare class PouchLink extends CozyLink {
|
|
|
130
130
|
getSyncInfo(doctype: any): import("./types").SyncInfo;
|
|
131
131
|
getPouch(doctype: any): any;
|
|
132
132
|
supportsOperation(operation: any): boolean;
|
|
133
|
+
/**
|
|
134
|
+
* Get PouchDB changes
|
|
135
|
+
* See https://pouchdb.com/api.html#changes
|
|
136
|
+
*
|
|
137
|
+
* @param {string} doctype - The PouchDB database's doctype
|
|
138
|
+
* @param {object} options - The changes options. See https://pouchdb.com/api.html#changes
|
|
139
|
+
* @returns {Promise<import('./types').PouchDBChangesResults>} The changes
|
|
140
|
+
*/
|
|
141
|
+
getChanges(doctype: string, options: object): Promise<import('./types').PouchDBChangesResults>;
|
|
142
|
+
/**
|
|
143
|
+
* Get PouchDB database info
|
|
144
|
+
* See https://pouchdb.com/api.html#database_information
|
|
145
|
+
*
|
|
146
|
+
* @param {string} doctype - The PouchDB database's doctype
|
|
147
|
+
* @returns {Promise<import('./types').PouchDBInfo>} The db info
|
|
148
|
+
*/
|
|
149
|
+
getDbInfo(doctype: string): Promise<import('./types').PouchDBInfo>;
|
|
133
150
|
sanitizeJsonApi(data: any): Pick<Pick<any, string | number | symbol>, string | number | symbol>;
|
|
134
151
|
/**
|
|
135
152
|
* Retrieve the existing document from Pouch
|