cozy-client 48.25.0 → 49.0.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.
@@ -138,6 +138,8 @@ var securiseUri = function securiseUri(uri) {
138
138
  var DOC_CREATION = 'creation';
139
139
  var DOC_UPDATE = 'update';
140
140
  /**
141
+ * @typedef {import("./types").CozyClientDocument} CozyClientDocument
142
+ *
141
143
  * @typedef {object} ClientOptions
142
144
  * @property {object} [client]
143
145
  * @property {object} [link]
@@ -1596,23 +1598,26 @@ var CozyClient = /*#__PURE__*/function () {
1596
1598
 
1597
1599
  case 2:
1598
1600
  mainResponse = _context11.sent;
1601
+ _context11.next = 5;
1602
+ return this.persistVirtualDocuments(definition, mainResponse.data);
1599
1603
 
1604
+ case 5:
1600
1605
  if (definition.includes) {
1601
- _context11.next = 5;
1606
+ _context11.next = 7;
1602
1607
  break;
1603
1608
  }
1604
1609
 
1605
1610
  return _context11.abrupt("return", mainResponse);
1606
1611
 
1607
- case 5:
1608
- _context11.next = 7;
1612
+ case 7:
1613
+ _context11.next = 9;
1609
1614
  return this.fetchRelationships(mainResponse, this.getIncludesRelationships(definition));
1610
1615
 
1611
- case 7:
1616
+ case 9:
1612
1617
  withIncluded = _context11.sent;
1613
1618
  return _context11.abrupt("return", withIncluded);
1614
1619
 
1615
- case 9:
1620
+ case 11:
1616
1621
  case "end":
1617
1622
  return _context11.stop();
1618
1623
  }
@@ -1626,6 +1631,156 @@ var CozyClient = /*#__PURE__*/function () {
1626
1631
 
1627
1632
  return requestQuery;
1628
1633
  }()
1634
+ /**
1635
+ * Save the document or array of documents into the persisted storage (if any)
1636
+ *
1637
+ * @private
1638
+ * @param {CozyClientDocument | Array<CozyClientDocument>} data - Document or array of documents to be saved
1639
+ * @returns {Promise<void>}
1640
+ */
1641
+
1642
+ }, {
1643
+ key: "persistVirtualDocuments",
1644
+ value: function () {
1645
+ var _persistVirtualDocuments = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(definition, data) {
1646
+ var enforceList, enforce, _iterator5, _step5, _document;
1647
+
1648
+ return _regenerator.default.wrap(function _callee12$(_context12) {
1649
+ while (1) {
1650
+ switch (_context12.prev = _context12.next) {
1651
+ case 0:
1652
+ enforceList = ['io.cozy.files.shortcuts'];
1653
+ enforce = enforceList.includes(definition.doctype);
1654
+
1655
+ if (!(definition.doctype === 'io.cozy.apps_registry')) {
1656
+ _context12.next = 6;
1657
+ break;
1658
+ }
1659
+
1660
+ _context12.next = 5;
1661
+ return this.persistVirtualDocument({
1662
+ _type: 'io.cozy.apps_registry',
1663
+ _id: definition.id,
1664
+ // @ts-ignore
1665
+ cozyPouchData: data
1666
+ }, enforce);
1667
+
1668
+ case 5:
1669
+ return _context12.abrupt("return", _context12.sent);
1670
+
1671
+ case 6:
1672
+ if (Array.isArray(data)) {
1673
+ _context12.next = 11;
1674
+ break;
1675
+ }
1676
+
1677
+ _context12.next = 9;
1678
+ return this.persistVirtualDocument(data, enforce);
1679
+
1680
+ case 9:
1681
+ _context12.next = 28;
1682
+ break;
1683
+
1684
+ case 11:
1685
+ _iterator5 = _createForOfIteratorHelper(data);
1686
+ _context12.prev = 12;
1687
+
1688
+ _iterator5.s();
1689
+
1690
+ case 14:
1691
+ if ((_step5 = _iterator5.n()).done) {
1692
+ _context12.next = 20;
1693
+ break;
1694
+ }
1695
+
1696
+ _document = _step5.value;
1697
+ _context12.next = 18;
1698
+ return this.persistVirtualDocument(_document, enforce);
1699
+
1700
+ case 18:
1701
+ _context12.next = 14;
1702
+ break;
1703
+
1704
+ case 20:
1705
+ _context12.next = 25;
1706
+ break;
1707
+
1708
+ case 22:
1709
+ _context12.prev = 22;
1710
+ _context12.t0 = _context12["catch"](12);
1711
+
1712
+ _iterator5.e(_context12.t0);
1713
+
1714
+ case 25:
1715
+ _context12.prev = 25;
1716
+
1717
+ _iterator5.f();
1718
+
1719
+ return _context12.finish(25);
1720
+
1721
+ case 28:
1722
+ case "end":
1723
+ return _context12.stop();
1724
+ }
1725
+ }
1726
+ }, _callee12, this, [[12, 22, 25, 28]]);
1727
+ }));
1728
+
1729
+ function persistVirtualDocuments(_x13, _x14) {
1730
+ return _persistVirtualDocuments.apply(this, arguments);
1731
+ }
1732
+
1733
+ return persistVirtualDocuments;
1734
+ }()
1735
+ /**
1736
+ * Save the document or array of documents into the persisted storage (if any)
1737
+ *
1738
+ * @private
1739
+ * @param {CozyClientDocument} document - Document to be saved
1740
+ * @param {boolean} enforce - When true, save the document even if `meta.rev` or `_rev` exist
1741
+ * @returns {Promise<void>}
1742
+ */
1743
+
1744
+ }, {
1745
+ key: "persistVirtualDocument",
1746
+ value: function () {
1747
+ var _persistVirtualDocument = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(document, enforce) {
1748
+ var _document$meta;
1749
+
1750
+ return _regenerator.default.wrap(function _callee13$(_context13) {
1751
+ while (1) {
1752
+ switch (_context13.prev = _context13.next) {
1753
+ case 0:
1754
+ if (!(!document || document.cozyLocalOnly)) {
1755
+ _context13.next = 2;
1756
+ break;
1757
+ }
1758
+
1759
+ return _context13.abrupt("return");
1760
+
1761
+ case 2:
1762
+ if (!(!((_document$meta = document.meta) !== null && _document$meta !== void 0 && _document$meta.rev) && !document._rev || enforce)) {
1763
+ _context13.next = 5;
1764
+ break;
1765
+ }
1766
+
1767
+ _context13.next = 5;
1768
+ return this.chain.persistCozyData(document);
1769
+
1770
+ case 5:
1771
+ case "end":
1772
+ return _context13.stop();
1773
+ }
1774
+ }
1775
+ }, _callee13, this);
1776
+ }));
1777
+
1778
+ function persistVirtualDocument(_x15, _x16) {
1779
+ return _persistVirtualDocument.apply(this, arguments);
1780
+ }
1781
+
1782
+ return persistVirtualDocument;
1783
+ }()
1629
1784
  /**
1630
1785
  * Fetch relationships for a response (can be several docs).
1631
1786
  * Fills the `relationships` attribute of each documents.
@@ -1640,23 +1795,23 @@ var CozyClient = /*#__PURE__*/function () {
1640
1795
  }, {
1641
1796
  key: "fetchRelationships",
1642
1797
  value: function () {
1643
- var _fetchRelationships = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(response, relationshipsByName) {
1798
+ var _fetchRelationships = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(response, relationshipsByName) {
1644
1799
  var _this5 = this;
1645
1800
 
1646
- var isSingleDoc, responseDocs, queryDefToDocIdAndRel, documents, definitions, optimizedDefinitions, responses, uniqueDocuments, included, relationshipsByDocId, _iterator5, _step5, _step5$value, def, resp, docIdAndRel, _docIdAndRel, docId, relName;
1801
+ var isSingleDoc, responseDocs, queryDefToDocIdAndRel, documents, definitions, optimizedDefinitions, responses, uniqueDocuments, included, relationshipsByDocId, _iterator6, _step6, _step6$value, def, resp, docIdAndRel, _docIdAndRel, docId, relName;
1647
1802
 
1648
- return _regenerator.default.wrap(function _callee12$(_context12) {
1803
+ return _regenerator.default.wrap(function _callee14$(_context14) {
1649
1804
  while (1) {
1650
- switch (_context12.prev = _context12.next) {
1805
+ switch (_context14.prev = _context14.next) {
1651
1806
  case 0:
1652
1807
  isSingleDoc = !Array.isArray(response.data);
1653
1808
 
1654
1809
  if (!(!isSingleDoc && response.data.length === 0)) {
1655
- _context12.next = 3;
1810
+ _context14.next = 3;
1656
1811
  break;
1657
1812
  }
1658
1813
 
1659
- return _context12.abrupt("return", response);
1814
+ return _context14.abrupt("return", response);
1660
1815
 
1661
1816
  case 3:
1662
1817
  responseDocs = isSingleDoc ? [response.data] : response.data;
@@ -1686,13 +1841,13 @@ var CozyClient = /*#__PURE__*/function () {
1686
1841
  }); // Definitions can be in optimized/regrouped in case of HasMany relationships.
1687
1842
 
1688
1843
  optimizedDefinitions = (0, _optimize.default)(definitions);
1689
- _context12.next = 11;
1844
+ _context14.next = 11;
1690
1845
  return Promise.all(optimizedDefinitions.map(function (req) {
1691
1846
  return _this5.chain.request(req);
1692
1847
  }));
1693
1848
 
1694
1849
  case 11:
1695
- responses = _context12.sent;
1850
+ responses = _context14.sent;
1696
1851
  // "Included" documents will be stored in the `documents` store
1697
1852
  uniqueDocuments = (0, _uniqBy.default)((0, _flatten.default)(documents), '_id');
1698
1853
  included = (0, _flatten.default)(responses.map(function (r) {
@@ -1705,11 +1860,11 @@ var CozyClient = /*#__PURE__*/function () {
1705
1860
  // storing the document. This makes the data easier to manipulate for the front-end.
1706
1861
 
1707
1862
  relationshipsByDocId = {};
1708
- _iterator5 = _createForOfIteratorHelper((0, _zip.default)(optimizedDefinitions, responses));
1863
+ _iterator6 = _createForOfIteratorHelper((0, _zip.default)(optimizedDefinitions, responses));
1709
1864
 
1710
1865
  try {
1711
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1712
- _step5$value = (0, _slicedToArray2.default)(_step5.value, 2), def = _step5$value[0], resp = _step5$value[1];
1866
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
1867
+ _step6$value = (0, _slicedToArray2.default)(_step6.value, 2), def = _step6$value[0], resp = _step6$value[1];
1713
1868
  docIdAndRel = queryDefToDocIdAndRel.get(def);
1714
1869
 
1715
1870
  if (docIdAndRel) {
@@ -1719,24 +1874,24 @@ var CozyClient = /*#__PURE__*/function () {
1719
1874
  }
1720
1875
  }
1721
1876
  } catch (err) {
1722
- _iterator5.e(err);
1877
+ _iterator6.e(err);
1723
1878
  } finally {
1724
- _iterator5.f();
1879
+ _iterator6.f();
1725
1880
  }
1726
1881
 
1727
- return _context12.abrupt("return", _objectSpread(_objectSpread({}, (0, _helpers.attachRelationships)(response, relationshipsByDocId)), {}, {
1882
+ return _context14.abrupt("return", _objectSpread(_objectSpread({}, (0, _helpers.attachRelationships)(response, relationshipsByDocId)), {}, {
1728
1883
  included: included
1729
1884
  }));
1730
1885
 
1731
1886
  case 18:
1732
1887
  case "end":
1733
- return _context12.stop();
1888
+ return _context14.stop();
1734
1889
  }
1735
1890
  }
1736
- }, _callee12);
1891
+ }, _callee14);
1737
1892
  }));
1738
1893
 
1739
- function fetchRelationships(_x13, _x14) {
1894
+ function fetchRelationships(_x17, _x18) {
1740
1895
  return _fetchRelationships.apply(this, arguments);
1741
1896
  }
1742
1897
 
@@ -1745,47 +1900,47 @@ var CozyClient = /*#__PURE__*/function () {
1745
1900
  }, {
1746
1901
  key: "requestMutation",
1747
1902
  value: function () {
1748
- var _requestMutation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee13(definition) {
1903
+ var _requestMutation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(definition) {
1749
1904
  var _this6 = this;
1750
1905
 
1751
1906
  var _definition, first, rest, firstResponse;
1752
1907
 
1753
- return _regenerator.default.wrap(function _callee13$(_context13) {
1908
+ return _regenerator.default.wrap(function _callee15$(_context15) {
1754
1909
  while (1) {
1755
- switch (_context13.prev = _context13.next) {
1910
+ switch (_context15.prev = _context15.next) {
1756
1911
  case 0:
1757
1912
  if (!Array.isArray(definition)) {
1758
- _context13.next = 8;
1913
+ _context15.next = 8;
1759
1914
  break;
1760
1915
  }
1761
1916
 
1762
1917
  _definition = (0, _toArray2.default)(definition), first = _definition[0], rest = _definition.slice(1);
1763
- _context13.next = 4;
1918
+ _context15.next = 4;
1764
1919
  return this.requestMutation(first);
1765
1920
 
1766
1921
  case 4:
1767
- firstResponse = _context13.sent;
1768
- _context13.next = 7;
1922
+ firstResponse = _context15.sent;
1923
+ _context15.next = 7;
1769
1924
  return Promise.all(rest.map(function (def) {
1770
1925
  var mutationDef = typeof def === 'function' ? def(firstResponse) : def;
1771
1926
  return _this6.requestMutation(mutationDef);
1772
1927
  }));
1773
1928
 
1774
1929
  case 7:
1775
- return _context13.abrupt("return", firstResponse);
1930
+ return _context15.abrupt("return", firstResponse);
1776
1931
 
1777
1932
  case 8:
1778
- return _context13.abrupt("return", this.chain.request(definition));
1933
+ return _context15.abrupt("return", this.chain.request(definition));
1779
1934
 
1780
1935
  case 9:
1781
1936
  case "end":
1782
- return _context13.stop();
1937
+ return _context15.stop();
1783
1938
  }
1784
1939
  }
1785
- }, _callee13, this);
1940
+ }, _callee15, this);
1786
1941
  }));
1787
1942
 
1788
- function requestMutation(_x15) {
1943
+ function requestMutation(_x19) {
1789
1944
  return _requestMutation.apply(this, arguments);
1790
1945
  }
1791
1946
 
@@ -2044,34 +2199,34 @@ var CozyClient = /*#__PURE__*/function () {
2044
2199
  }, {
2045
2200
  key: "startOAuthFlow",
2046
2201
  value: function () {
2047
- var _startOAuthFlow = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee14(openURLCallback) {
2202
+ var _startOAuthFlow = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16(openURLCallback) {
2048
2203
  var stackClient;
2049
- return _regenerator.default.wrap(function _callee14$(_context14) {
2204
+ return _regenerator.default.wrap(function _callee16$(_context16) {
2050
2205
  while (1) {
2051
- switch (_context14.prev = _context14.next) {
2206
+ switch (_context16.prev = _context16.next) {
2052
2207
  case 0:
2053
2208
  stackClient = this.getStackClient();
2054
- _context14.next = 3;
2209
+ _context16.next = 3;
2055
2210
  return stackClient.register();
2056
2211
 
2057
2212
  case 3:
2058
- _context14.next = 5;
2213
+ _context16.next = 5;
2059
2214
  return this.certifyFlagship();
2060
2215
 
2061
2216
  case 5:
2062
- return _context14.abrupt("return", this.authorize({
2217
+ return _context16.abrupt("return", this.authorize({
2063
2218
  openURLCallback: openURLCallback
2064
2219
  }));
2065
2220
 
2066
2221
  case 6:
2067
2222
  case "end":
2068
- return _context14.stop();
2223
+ return _context16.stop();
2069
2224
  }
2070
2225
  }
2071
- }, _callee14, this);
2226
+ }, _callee16, this);
2072
2227
  }));
2073
2228
 
2074
- function startOAuthFlow(_x16) {
2229
+ function startOAuthFlow(_x20) {
2075
2230
  return _startOAuthFlow.apply(this, arguments);
2076
2231
  }
2077
2232
 
@@ -2086,28 +2241,28 @@ var CozyClient = /*#__PURE__*/function () {
2086
2241
  }, {
2087
2242
  key: "certifyFlagship",
2088
2243
  value: function () {
2089
- var _certifyFlagship2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15() {
2244
+ var _certifyFlagship2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17() {
2090
2245
  var stackClient;
2091
- return _regenerator.default.wrap(function _callee15$(_context15) {
2246
+ return _regenerator.default.wrap(function _callee17$(_context17) {
2092
2247
  while (1) {
2093
- switch (_context15.prev = _context15.next) {
2248
+ switch (_context17.prev = _context17.next) {
2094
2249
  case 0:
2095
2250
  stackClient = this.getStackClient();
2096
2251
 
2097
2252
  if (!stackClient.oauthOptions.shouldRequireFlagshipPermissions) {
2098
- _context15.next = 4;
2253
+ _context17.next = 4;
2099
2254
  break;
2100
2255
  }
2101
2256
 
2102
- _context15.next = 4;
2257
+ _context17.next = 4;
2103
2258
  return (0, _flagshipCertification.certifyFlagship)(stackClient.oauthOptions.certificationConfig, this);
2104
2259
 
2105
2260
  case 4:
2106
2261
  case "end":
2107
- return _context15.stop();
2262
+ return _context17.stop();
2108
2263
  }
2109
2264
  }
2110
- }, _callee15, this);
2265
+ }, _callee17, this);
2111
2266
  }));
2112
2267
 
2113
2268
  function certifyFlagship() {
@@ -2131,7 +2286,7 @@ var CozyClient = /*#__PURE__*/function () {
2131
2286
  }, {
2132
2287
  key: "authorize",
2133
2288
  value: function () {
2134
- var _authorize = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16() {
2289
+ var _authorize = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18() {
2135
2290
  var _ref7,
2136
2291
  _ref7$openURLCallback,
2137
2292
  openURLCallback,
@@ -2148,14 +2303,14 @@ var CozyClient = /*#__PURE__*/function () {
2148
2303
  code,
2149
2304
  token,
2150
2305
  _stackClient,
2151
- _args16 = arguments;
2306
+ _args18 = arguments;
2152
2307
 
2153
- return _regenerator.default.wrap(function _callee16$(_context16) {
2308
+ return _regenerator.default.wrap(function _callee18$(_context18) {
2154
2309
  while (1) {
2155
- switch (_context16.prev = _context16.next) {
2310
+ switch (_context18.prev = _context18.next) {
2156
2311
  case 0:
2157
- _ref7 = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : {}, _ref7$openURLCallback = _ref7.openURLCallback, openURLCallback = _ref7$openURLCallback === void 0 ? _mobile.authFunction : _ref7$openURLCallback, _ref7$sessionCode = _ref7.sessionCode, sessionCode = _ref7$sessionCode === void 0 ? undefined : _ref7$sessionCode, _ref7$pkceCodes = _ref7.pkceCodes, pkceCodes = _ref7$pkceCodes === void 0 ? {} : _ref7$pkceCodes;
2158
- _context16.prev = 1;
2312
+ _ref7 = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {}, _ref7$openURLCallback = _ref7.openURLCallback, openURLCallback = _ref7$openURLCallback === void 0 ? _mobile.authFunction : _ref7$openURLCallback, _ref7$sessionCode = _ref7.sessionCode, sessionCode = _ref7$sessionCode === void 0 ? undefined : _ref7$sessionCode, _ref7$pkceCodes = _ref7.pkceCodes, pkceCodes = _ref7$pkceCodes === void 0 ? {} : _ref7$pkceCodes;
2313
+ _context18.prev = 1;
2159
2314
  codeVerifier = pkceCodes.codeVerifier, codeChallenge = pkceCodes.codeChallenge;
2160
2315
  stackClient = this.getStackClient();
2161
2316
  stateCode = stackClient.generateStateCode();
@@ -2165,19 +2320,19 @@ var CozyClient = /*#__PURE__*/function () {
2165
2320
  sessionCode: sessionCode,
2166
2321
  codeChallenge: codeChallenge
2167
2322
  });
2168
- _context16.next = 8;
2323
+ _context18.next = 8;
2169
2324
  return openURLCallback(url);
2170
2325
 
2171
2326
  case 8:
2172
- redirectedURL = _context16.sent;
2327
+ redirectedURL = _context18.sent;
2173
2328
  code = stackClient.getAccessCodeFromURL(redirectedURL, stateCode);
2174
- _context16.next = 12;
2329
+ _context18.next = 12;
2175
2330
  return stackClient.fetchAccessToken(code, undefined, undefined, codeVerifier);
2176
2331
 
2177
2332
  case 12:
2178
- token = _context16.sent;
2333
+ token = _context18.sent;
2179
2334
  stackClient.setToken(token);
2180
- return _context16.abrupt("return", {
2335
+ return _context18.abrupt("return", {
2181
2336
  token: token,
2182
2337
  infos: stackClient.oauthOptions,
2183
2338
  client: stackClient.oauthOptions // for compat with Authentication comp reasons
@@ -2185,24 +2340,24 @@ var CozyClient = /*#__PURE__*/function () {
2185
2340
  });
2186
2341
 
2187
2342
  case 17:
2188
- _context16.prev = 17;
2189
- _context16.t0 = _context16["catch"](1);
2343
+ _context18.prev = 17;
2344
+ _context18.t0 = _context18["catch"](1);
2190
2345
 
2191
2346
  /* if REGISTRATION_ABORT is emited, we have to unregister the client. */
2192
- if (_context16.t0.message === _const.REGISTRATION_ABORT) {
2347
+ if (_context18.t0.message === _const.REGISTRATION_ABORT) {
2193
2348
  _stackClient = this.getStackClient();
2194
2349
 
2195
2350
  _stackClient.unregister();
2196
2351
  }
2197
2352
 
2198
- throw _context16.t0;
2353
+ throw _context18.t0;
2199
2354
 
2200
2355
  case 21:
2201
2356
  case "end":
2202
- return _context16.stop();
2357
+ return _context18.stop();
2203
2358
  }
2204
2359
  }
2205
- }, _callee16, this, [[1, 17]]);
2360
+ }, _callee18, this, [[1, 17]]);
2206
2361
  }));
2207
2362
 
2208
2363
  function authorize() {
@@ -2277,27 +2432,27 @@ var CozyClient = /*#__PURE__*/function () {
2277
2432
  }, {
2278
2433
  key: "checkForRevocation",
2279
2434
  value: function () {
2280
- var _checkForRevocation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17() {
2281
- return _regenerator.default.wrap(function _callee17$(_context17) {
2435
+ var _checkForRevocation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19() {
2436
+ return _regenerator.default.wrap(function _callee19$(_context19) {
2282
2437
  while (1) {
2283
- switch (_context17.prev = _context17.next) {
2438
+ switch (_context19.prev = _context19.next) {
2284
2439
  case 0:
2285
2440
  if (!(this.stackClient instanceof _cozyStackClient.OAuthClient)) {
2286
- _context17.next = 4;
2441
+ _context19.next = 4;
2287
2442
  break;
2288
2443
  }
2289
2444
 
2290
- return _context17.abrupt("return", this.stackClient.checkForRevocation());
2445
+ return _context19.abrupt("return", this.stackClient.checkForRevocation());
2291
2446
 
2292
2447
  case 4:
2293
2448
  throw 'checkForRevocation is only implemented for OAutClient';
2294
2449
 
2295
2450
  case 5:
2296
2451
  case "end":
2297
- return _context17.stop();
2452
+ return _context19.stop();
2298
2453
  }
2299
2454
  }
2300
- }, _callee17, this);
2455
+ }, _callee19, this);
2301
2456
  }));
2302
2457
 
2303
2458
  function checkForRevocation() {
@@ -2453,40 +2608,38 @@ var CozyClient = /*#__PURE__*/function () {
2453
2608
  }, {
2454
2609
  key: "loadInstanceOptionsFromStack",
2455
2610
  value: function () {
2456
- var _loadInstanceOptionsFromStack = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18() {
2457
- var _instanceData$attribu, _instanceData$attribu2;
2458
-
2611
+ var _loadInstanceOptionsFromStack = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20() {
2459
2612
  var _yield$this$query, data, _yield$this$query2, instanceData;
2460
2613
 
2461
- return _regenerator.default.wrap(function _callee18$(_context18) {
2614
+ return _regenerator.default.wrap(function _callee20$(_context20) {
2462
2615
  while (1) {
2463
- switch (_context18.prev = _context18.next) {
2616
+ switch (_context20.prev = _context20.next) {
2464
2617
  case 0:
2465
- _context18.next = 2;
2618
+ _context20.next = 2;
2466
2619
  return this.query((0, _dsl.Q)('io.cozy.settings').getById('io.cozy.settings.capabilities'));
2467
2620
 
2468
2621
  case 2:
2469
- _yield$this$query = _context18.sent;
2622
+ _yield$this$query = _context20.sent;
2470
2623
  data = _yield$this$query.data;
2471
- _context18.next = 6;
2624
+ _context20.next = 6;
2472
2625
  return this.query((0, _dsl.Q)('io.cozy.settings').getById('io.cozy.settings.instance'));
2473
2626
 
2474
2627
  case 6:
2475
- _yield$this$query2 = _context18.sent;
2628
+ _yield$this$query2 = _context20.sent;
2476
2629
  instanceData = _yield$this$query2.data;
2477
2630
  this.instanceOptions = {
2478
- capabilities: data.attributes,
2479
- locale: (_instanceData$attribu = instanceData.attributes) === null || _instanceData$attribu === void 0 ? void 0 : _instanceData$attribu.locale,
2480
- tracking: (_instanceData$attribu2 = instanceData.attributes) === null || _instanceData$attribu2 === void 0 ? void 0 : _instanceData$attribu2.tracking
2631
+ capabilities: data,
2632
+ locale: instanceData.locale,
2633
+ tracking: instanceData.tracking
2481
2634
  };
2482
2635
  this.capabilities = this.instanceOptions.capabilities || null;
2483
2636
 
2484
2637
  case 10:
2485
2638
  case "end":
2486
- return _context18.stop();
2639
+ return _context20.stop();
2487
2640
  }
2488
2641
  }
2489
- }, _callee18, this);
2642
+ }, _callee20, this);
2490
2643
  }));
2491
2644
 
2492
2645
  function loadInstanceOptionsFromStack() {
@@ -2566,22 +2719,22 @@ var CozyClient = /*#__PURE__*/function () {
2566
2719
  }, {
2567
2720
  key: "getSettings",
2568
2721
  value: function () {
2569
- var _getSettings2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19(slug, keys) {
2570
- return _regenerator.default.wrap(function _callee19$(_context19) {
2722
+ var _getSettings2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21(slug, keys) {
2723
+ return _regenerator.default.wrap(function _callee21$(_context21) {
2571
2724
  while (1) {
2572
- switch (_context19.prev = _context19.next) {
2725
+ switch (_context21.prev = _context21.next) {
2573
2726
  case 0:
2574
- return _context19.abrupt("return", (0, _helpers2.getSettings)(this, slug, keys));
2727
+ return _context21.abrupt("return", (0, _helpers2.getSettings)(this, slug, keys));
2575
2728
 
2576
2729
  case 1:
2577
2730
  case "end":
2578
- return _context19.stop();
2731
+ return _context21.stop();
2579
2732
  }
2580
2733
  }
2581
- }, _callee19, this);
2734
+ }, _callee21, this);
2582
2735
  }));
2583
2736
 
2584
- function getSettings(_x17, _x18) {
2737
+ function getSettings(_x21, _x22) {
2585
2738
  return _getSettings2.apply(this, arguments);
2586
2739
  }
2587
2740
 
@@ -2604,22 +2757,22 @@ var CozyClient = /*#__PURE__*/function () {
2604
2757
  }, {
2605
2758
  key: "saveAfterFetchSettings",
2606
2759
  value: function () {
2607
- var _saveAfterFetchSettings2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20(slug, itemsOrSetter, setterKeys) {
2608
- return _regenerator.default.wrap(function _callee20$(_context20) {
2760
+ var _saveAfterFetchSettings2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee22(slug, itemsOrSetter, setterKeys) {
2761
+ return _regenerator.default.wrap(function _callee22$(_context22) {
2609
2762
  while (1) {
2610
- switch (_context20.prev = _context20.next) {
2763
+ switch (_context22.prev = _context22.next) {
2611
2764
  case 0:
2612
- return _context20.abrupt("return", (0, _helpers2.saveAfterFetchSettings)(this, slug, itemsOrSetter, setterKeys));
2765
+ return _context22.abrupt("return", (0, _helpers2.saveAfterFetchSettings)(this, slug, itemsOrSetter, setterKeys));
2613
2766
 
2614
2767
  case 1:
2615
2768
  case "end":
2616
- return _context20.stop();
2769
+ return _context22.stop();
2617
2770
  }
2618
2771
  }
2619
- }, _callee20, this);
2772
+ }, _callee22, this);
2620
2773
  }));
2621
2774
 
2622
- function saveAfterFetchSettings(_x19, _x20, _x21) {
2775
+ function saveAfterFetchSettings(_x23, _x24, _x25) {
2623
2776
  return _saveAfterFetchSettings2.apply(this, arguments);
2624
2777
  }
2625
2778
 
@@ -2637,46 +2790,46 @@ var CozyClient = /*#__PURE__*/function () {
2637
2790
  }, {
2638
2791
  key: "resetQuery",
2639
2792
  value: function () {
2640
- var _resetQuery2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21(queryId) {
2793
+ var _resetQuery2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee23(queryId) {
2641
2794
  var query;
2642
- return _regenerator.default.wrap(function _callee21$(_context21) {
2795
+ return _regenerator.default.wrap(function _callee23$(_context23) {
2643
2796
  while (1) {
2644
- switch (_context21.prev = _context21.next) {
2797
+ switch (_context23.prev = _context23.next) {
2645
2798
  case 0:
2646
- _context21.prev = 0;
2799
+ _context23.prev = 0;
2647
2800
 
2648
2801
  if ((0, _store.isQueryExisting)(this.store.getState(), queryId)) {
2649
- _context21.next = 3;
2802
+ _context23.next = 3;
2650
2803
  break;
2651
2804
  }
2652
2805
 
2653
- return _context21.abrupt("return", Promise.resolve(null));
2806
+ return _context23.abrupt("return", Promise.resolve(null));
2654
2807
 
2655
2808
  case 3:
2656
2809
  this.dispatch((0, _store.resetQuery)(queryId));
2657
2810
  query = this.getQueryFromState(queryId);
2658
- _context21.next = 7;
2811
+ _context23.next = 7;
2659
2812
  return this.query(query.definition, {
2660
2813
  as: queryId
2661
2814
  });
2662
2815
 
2663
2816
  case 7:
2664
- return _context21.abrupt("return", _context21.sent);
2817
+ return _context23.abrupt("return", _context23.sent);
2665
2818
 
2666
2819
  case 10:
2667
- _context21.prev = 10;
2668
- _context21.t0 = _context21["catch"](0);
2669
- throw _context21.t0;
2820
+ _context23.prev = 10;
2821
+ _context23.t0 = _context23["catch"](0);
2822
+ throw _context23.t0;
2670
2823
 
2671
2824
  case 13:
2672
2825
  case "end":
2673
- return _context21.stop();
2826
+ return _context23.stop();
2674
2827
  }
2675
2828
  }
2676
- }, _callee21, this, [[0, 10]]);
2829
+ }, _callee23, this, [[0, 10]]);
2677
2830
  }));
2678
2831
 
2679
- function resetQuery(_x22) {
2832
+ function resetQuery(_x26) {
2680
2833
  return _resetQuery2.apply(this, arguments);
2681
2834
  }
2682
2835
 
@@ -2704,22 +2857,22 @@ var CozyClient = /*#__PURE__*/function () {
2704
2857
  }, {
2705
2858
  key: "fromOldOAuthClient",
2706
2859
  value: function () {
2707
- var _fromOldOAuthClient = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee22(oldClient, options) {
2860
+ var _fromOldOAuthClient = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee24(oldClient, options) {
2708
2861
  var credentials, oauthOptions, client;
2709
- return _regenerator.default.wrap(function _callee22$(_context22) {
2862
+ return _regenerator.default.wrap(function _callee24$(_context24) {
2710
2863
  while (1) {
2711
- switch (_context22.prev = _context22.next) {
2864
+ switch (_context24.prev = _context24.next) {
2712
2865
  case 0:
2713
2866
  if (!oldClient._oauth) {
2714
- _context22.next = 12;
2867
+ _context24.next = 12;
2715
2868
  break;
2716
2869
  }
2717
2870
 
2718
- _context22.next = 3;
2871
+ _context24.next = 3;
2719
2872
  return oldClient.authorize();
2720
2873
 
2721
2874
  case 3:
2722
- credentials = _context22.sent;
2875
+ credentials = _context24.sent;
2723
2876
  oauthOptions = {
2724
2877
  oauth: credentials.client,
2725
2878
  token: credentials.token,
@@ -2730,28 +2883,28 @@ var CozyClient = /*#__PURE__*/function () {
2730
2883
  }, oauthOptions), options));
2731
2884
 
2732
2885
  if (!client.loginPromise) {
2733
- _context22.next = 9;
2886
+ _context24.next = 9;
2734
2887
  break;
2735
2888
  }
2736
2889
 
2737
- _context22.next = 9;
2890
+ _context24.next = 9;
2738
2891
  return client.loginPromise;
2739
2892
 
2740
2893
  case 9:
2741
- return _context22.abrupt("return", client);
2894
+ return _context24.abrupt("return", client);
2742
2895
 
2743
2896
  case 12:
2744
2897
  throw new Error('Cannot instantiate a new client: old client is not an OAuth client. CozyClient.fromOldClient might be more suitable.');
2745
2898
 
2746
2899
  case 13:
2747
2900
  case "end":
2748
- return _context22.stop();
2901
+ return _context24.stop();
2749
2902
  }
2750
2903
  }
2751
- }, _callee22);
2904
+ }, _callee24);
2752
2905
  }));
2753
2906
 
2754
- function fromOldOAuthClient(_x23, _x24) {
2907
+ function fromOldOAuthClient(_x27, _x28) {
2755
2908
  return _fromOldOAuthClient.apply(this, arguments);
2756
2909
  }
2757
2910
 
@@ -2844,7 +2997,7 @@ var CozyClient = /*#__PURE__*/function () {
2844
2997
  CozyClient.hooks = CozyClient.hooks || {};
2845
2998
  CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
2846
2999
 
2847
- CozyClient.version = "48.25.0";
3000
+ CozyClient.version = "49.0.0";
2848
3001
 
2849
3002
  _microee.default.mixin(CozyClient);
2850
3003