cozy-client 59.4.0 → 60.1.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/CozyClient.js +180 -341
- package/dist/CozyClient.spec.js +69 -14
- package/dist/Query.spec.jsx +2 -0
- package/dist/__tests__/fixtures.js +17 -1
- package/dist/hooks/useQuery.js +3 -1
- package/dist/hooks/useQuery.spec.jsx +3 -1
- package/dist/links/StackLink.js +13 -2
- package/dist/links/StackLink.spec.js +20 -5
- package/dist/models/file.spec.js +4 -2
- package/dist/queries/dsl.js +18 -1
- package/dist/storage.js +5 -0
- package/dist/store/__snapshots__/queries.spec.js.snap +60 -0
- package/dist/store/queries.js +3 -1
- package/dist/store/selector.js +138 -0
- package/dist/store/selector.spec.js +238 -0
- package/dist/store.spec.js +3 -1
- package/dist/types.js +9 -2
- package/package.json +3 -3
- package/types/CozyClient.d.ts +15 -27
- package/types/__tests__/fixtures.d.ts +39 -17
- package/types/queries/dsl.d.ts +11 -0
- package/types/storage.d.ts +4 -0
- package/types/store/selector.d.ts +1 -0
- package/types/types.d.ts +19 -2
package/dist/CozyClient.js
CHANGED
|
@@ -152,7 +152,7 @@ var DOC_UPDATE = 'update';
|
|
|
152
152
|
* @property {string} [uri]
|
|
153
153
|
* @property {object} [stackClient]
|
|
154
154
|
* @property {boolean} [warningForCustomHandlers]
|
|
155
|
-
* @property {boolean} [autoHydrate]
|
|
155
|
+
* @property {boolean} [autoHydrate] - If set to true, all documents will be hydrated w.r.t. the provided schema's relationships, even if the relationship does not exist on the doc.
|
|
156
156
|
* @property {boolean} [backgroundFetching] - If set to true, backgroundFetching will be enabled by default on every query. Meaning that, when the fetchStatus has already been loaded, it won't be updated during future fetches. Instead, a `isFetching` attribute will be used to indicate when background fetching is started.
|
|
157
157
|
* @property {object} [oauth]
|
|
158
158
|
* @property {Function} [onTokenRefresh]
|
|
@@ -163,8 +163,7 @@ var DOC_UPDATE = 'update';
|
|
|
163
163
|
* @property {import("./types").AppMetadata} [appMetadata] - Metadata about the application that will be used in ensureCozyMetadata
|
|
164
164
|
* @property {import("./types").ClientCapabilities} [capabilities] - Capabilities sent by the stack
|
|
165
165
|
* @property {boolean} [useCustomStore=false] - If set to true, the client will not instantiate a Redux store automatically. Use this if you want to merge cozy-client's store with your own redux store. Note will have to call `setStore` eventually. See [here](https://docs.cozy.io/en/cozy-client/react-integration/#1b-use-your-own-redux-store) for more information.
|
|
166
|
-
* @property {boolean} [disableStoreForQueries=false] - If set to true, the client will not leverage the redux store to execute queries and store data.
|
|
167
|
-
|
|
166
|
+
* @property {boolean} [disableStoreForQueries=false] - If set to true, the client will not leverage the redux store to execute queries and store data.
|
|
168
167
|
* @property {import('./performances/types').PerformanceAPI} [performanceApi] - The performance API that can be used to measure performances
|
|
169
168
|
*/
|
|
170
169
|
|
|
@@ -317,6 +316,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
317
316
|
this.ensureStore();
|
|
318
317
|
}
|
|
319
318
|
|
|
319
|
+
this.autoHydrate = _options.autoHydrate || false;
|
|
320
320
|
this.disableStoreForQueries = _options.disableStoreForQueries || false;
|
|
321
321
|
}
|
|
322
322
|
/**
|
|
@@ -723,13 +723,15 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
723
723
|
* a [DocumentCollection]{@link https://docs.cozy.io/en/cozy-client/api/cozy-stack-client/#DocumentCollection} instance.
|
|
724
724
|
*
|
|
725
725
|
* @param {string} doctype The collection doctype.
|
|
726
|
+
* @param {object} options Options to pass to the collection
|
|
726
727
|
* @returns {import("./types").DocumentCollection} Collection corresponding to the doctype
|
|
727
728
|
*/
|
|
728
729
|
|
|
729
730
|
}, {
|
|
730
731
|
key: "collection",
|
|
731
732
|
value: function collection(doctype) {
|
|
732
|
-
|
|
733
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
734
|
+
return this.getStackClient().collection(doctype, options);
|
|
733
735
|
}
|
|
734
736
|
}, {
|
|
735
737
|
key: "fetch",
|
|
@@ -1804,169 +1806,6 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
1804
1806
|
|
|
1805
1807
|
return requestQuery;
|
|
1806
1808
|
}()
|
|
1807
|
-
/**
|
|
1808
|
-
* Save the document or array of documents into the persisted storage (if any)
|
|
1809
|
-
*
|
|
1810
|
-
* @private
|
|
1811
|
-
* @param {CozyClientDocument | Array<CozyClientDocument>} data - Document or array of documents to be saved
|
|
1812
|
-
* @returns {Promise<void>}
|
|
1813
|
-
*/
|
|
1814
|
-
|
|
1815
|
-
}, {
|
|
1816
|
-
key: "persistVirtualDocuments",
|
|
1817
|
-
value: function () {
|
|
1818
|
-
var _persistVirtualDocuments = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(definition, data) {
|
|
1819
|
-
var enforceList, enforce, documentsToPersist, _iterator5, _step5, _document;
|
|
1820
|
-
|
|
1821
|
-
return _regenerator.default.wrap(function _callee15$(_context15) {
|
|
1822
|
-
while (1) {
|
|
1823
|
-
switch (_context15.prev = _context15.next) {
|
|
1824
|
-
case 0:
|
|
1825
|
-
enforceList = ['io.cozy.files.shortcuts'];
|
|
1826
|
-
enforce = enforceList.includes(definition.doctype);
|
|
1827
|
-
|
|
1828
|
-
if (!(definition.doctype === 'io.cozy.apps_registry')) {
|
|
1829
|
-
_context15.next = 6;
|
|
1830
|
-
break;
|
|
1831
|
-
}
|
|
1832
|
-
|
|
1833
|
-
_context15.next = 5;
|
|
1834
|
-
return this.persistVirtualDocument({
|
|
1835
|
-
_type: 'io.cozy.apps_registry',
|
|
1836
|
-
_id: definition.id,
|
|
1837
|
-
// @ts-ignore
|
|
1838
|
-
cozyPouchData: data
|
|
1839
|
-
}, enforce);
|
|
1840
|
-
|
|
1841
|
-
case 5:
|
|
1842
|
-
return _context15.abrupt("return", _context15.sent);
|
|
1843
|
-
|
|
1844
|
-
case 6:
|
|
1845
|
-
if (Array.isArray(data)) {
|
|
1846
|
-
_context15.next = 11;
|
|
1847
|
-
break;
|
|
1848
|
-
}
|
|
1849
|
-
|
|
1850
|
-
_context15.next = 9;
|
|
1851
|
-
return this.persistVirtualDocument(data, enforce);
|
|
1852
|
-
|
|
1853
|
-
case 9:
|
|
1854
|
-
_context15.next = 29;
|
|
1855
|
-
break;
|
|
1856
|
-
|
|
1857
|
-
case 11:
|
|
1858
|
-
documentsToPersist = data.filter(function (document) {
|
|
1859
|
-
var _document$meta;
|
|
1860
|
-
|
|
1861
|
-
if (!document || document.cozyLocalOnly) {
|
|
1862
|
-
return false;
|
|
1863
|
-
}
|
|
1864
|
-
|
|
1865
|
-
if (!((_document$meta = document.meta) !== null && _document$meta !== void 0 && _document$meta.rev) && !document._rev || enforce) {
|
|
1866
|
-
return true;
|
|
1867
|
-
}
|
|
1868
|
-
|
|
1869
|
-
return false;
|
|
1870
|
-
});
|
|
1871
|
-
_iterator5 = _createForOfIteratorHelper(documentsToPersist);
|
|
1872
|
-
_context15.prev = 13;
|
|
1873
|
-
|
|
1874
|
-
_iterator5.s();
|
|
1875
|
-
|
|
1876
|
-
case 15:
|
|
1877
|
-
if ((_step5 = _iterator5.n()).done) {
|
|
1878
|
-
_context15.next = 21;
|
|
1879
|
-
break;
|
|
1880
|
-
}
|
|
1881
|
-
|
|
1882
|
-
_document = _step5.value;
|
|
1883
|
-
_context15.next = 19;
|
|
1884
|
-
return this.persistVirtualDocument(_document, enforce);
|
|
1885
|
-
|
|
1886
|
-
case 19:
|
|
1887
|
-
_context15.next = 15;
|
|
1888
|
-
break;
|
|
1889
|
-
|
|
1890
|
-
case 21:
|
|
1891
|
-
_context15.next = 26;
|
|
1892
|
-
break;
|
|
1893
|
-
|
|
1894
|
-
case 23:
|
|
1895
|
-
_context15.prev = 23;
|
|
1896
|
-
_context15.t0 = _context15["catch"](13);
|
|
1897
|
-
|
|
1898
|
-
_iterator5.e(_context15.t0);
|
|
1899
|
-
|
|
1900
|
-
case 26:
|
|
1901
|
-
_context15.prev = 26;
|
|
1902
|
-
|
|
1903
|
-
_iterator5.f();
|
|
1904
|
-
|
|
1905
|
-
return _context15.finish(26);
|
|
1906
|
-
|
|
1907
|
-
case 29:
|
|
1908
|
-
case "end":
|
|
1909
|
-
return _context15.stop();
|
|
1910
|
-
}
|
|
1911
|
-
}
|
|
1912
|
-
}, _callee15, this, [[13, 23, 26, 29]]);
|
|
1913
|
-
}));
|
|
1914
|
-
|
|
1915
|
-
function persistVirtualDocuments(_x17, _x18) {
|
|
1916
|
-
return _persistVirtualDocuments.apply(this, arguments);
|
|
1917
|
-
}
|
|
1918
|
-
|
|
1919
|
-
return persistVirtualDocuments;
|
|
1920
|
-
}()
|
|
1921
|
-
/**
|
|
1922
|
-
* Save the document or array of documents into the persisted storage (if any)
|
|
1923
|
-
*
|
|
1924
|
-
* @private
|
|
1925
|
-
* @param {CozyClientDocument} document - Document to be saved
|
|
1926
|
-
* @param {boolean} enforce - When true, save the document even if `meta.rev` or `_rev` exist
|
|
1927
|
-
* @returns {Promise<void>}
|
|
1928
|
-
*/
|
|
1929
|
-
|
|
1930
|
-
}, {
|
|
1931
|
-
key: "persistVirtualDocument",
|
|
1932
|
-
value: function () {
|
|
1933
|
-
var _persistVirtualDocument = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16(document, enforce) {
|
|
1934
|
-
var _document$meta2;
|
|
1935
|
-
|
|
1936
|
-
return _regenerator.default.wrap(function _callee16$(_context16) {
|
|
1937
|
-
while (1) {
|
|
1938
|
-
switch (_context16.prev = _context16.next) {
|
|
1939
|
-
case 0:
|
|
1940
|
-
if (!(!document || document.cozyLocalOnly)) {
|
|
1941
|
-
_context16.next = 2;
|
|
1942
|
-
break;
|
|
1943
|
-
}
|
|
1944
|
-
|
|
1945
|
-
return _context16.abrupt("return");
|
|
1946
|
-
|
|
1947
|
-
case 2:
|
|
1948
|
-
if (!(!((_document$meta2 = document.meta) !== null && _document$meta2 !== void 0 && _document$meta2.rev) && !document._rev || enforce)) {
|
|
1949
|
-
_context16.next = 5;
|
|
1950
|
-
break;
|
|
1951
|
-
}
|
|
1952
|
-
|
|
1953
|
-
_context16.next = 5;
|
|
1954
|
-
return this.chain.persistCozyData(document);
|
|
1955
|
-
|
|
1956
|
-
case 5:
|
|
1957
|
-
case "end":
|
|
1958
|
-
return _context16.stop();
|
|
1959
|
-
}
|
|
1960
|
-
}
|
|
1961
|
-
}, _callee16, this);
|
|
1962
|
-
}));
|
|
1963
|
-
|
|
1964
|
-
function persistVirtualDocument(_x19, _x20) {
|
|
1965
|
-
return _persistVirtualDocument.apply(this, arguments);
|
|
1966
|
-
}
|
|
1967
|
-
|
|
1968
|
-
return persistVirtualDocument;
|
|
1969
|
-
}()
|
|
1970
1809
|
/**
|
|
1971
1810
|
* Fetch relationships for a response (can be several docs).
|
|
1972
1811
|
* Fills the `relationships` attribute of each documents.
|
|
@@ -1981,23 +1820,23 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
1981
1820
|
}, {
|
|
1982
1821
|
key: "fetchRelationships",
|
|
1983
1822
|
value: function () {
|
|
1984
|
-
var _fetchRelationships = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
1823
|
+
var _fetchRelationships = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee15(response, relationshipsByName) {
|
|
1985
1824
|
var _this5 = this;
|
|
1986
1825
|
|
|
1987
|
-
var isSingleDoc, responseDocs, queryDefToDocIdAndRel, documents, definitions, optimizedDefinitions, responses, uniqueDocuments, included, relationshipsByDocId,
|
|
1826
|
+
var isSingleDoc, responseDocs, queryDefToDocIdAndRel, documents, definitions, optimizedDefinitions, responses, uniqueDocuments, included, relationshipsByDocId, _iterator5, _step5, _step5$value, def, resp, docIdAndRel, _docIdAndRel, docId, relName;
|
|
1988
1827
|
|
|
1989
|
-
return _regenerator.default.wrap(function
|
|
1828
|
+
return _regenerator.default.wrap(function _callee15$(_context15) {
|
|
1990
1829
|
while (1) {
|
|
1991
|
-
switch (
|
|
1830
|
+
switch (_context15.prev = _context15.next) {
|
|
1992
1831
|
case 0:
|
|
1993
1832
|
isSingleDoc = !Array.isArray(response.data);
|
|
1994
1833
|
|
|
1995
1834
|
if (!(!isSingleDoc && response.data.length === 0)) {
|
|
1996
|
-
|
|
1835
|
+
_context15.next = 3;
|
|
1997
1836
|
break;
|
|
1998
1837
|
}
|
|
1999
1838
|
|
|
2000
|
-
return
|
|
1839
|
+
return _context15.abrupt("return", response);
|
|
2001
1840
|
|
|
2002
1841
|
case 3:
|
|
2003
1842
|
responseDocs = isSingleDoc ? [response.data] : response.data;
|
|
@@ -2017,7 +1856,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2017
1856
|
if (queryDef instanceof _dsl.QueryDefinition) {
|
|
2018
1857
|
definitions.push(queryDef);
|
|
2019
1858
|
} else {
|
|
2020
|
-
documents.push(
|
|
1859
|
+
documents.push(doc);
|
|
2021
1860
|
}
|
|
2022
1861
|
} catch (_unused) {// eslint-disable-next-line
|
|
2023
1862
|
// We do not crash completely if one the relationship behaves badly and
|
|
@@ -2027,13 +1866,13 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2027
1866
|
}); // Definitions can be in optimized/regrouped in case of HasMany relationships.
|
|
2028
1867
|
|
|
2029
1868
|
optimizedDefinitions = (0, _optimize.default)(definitions);
|
|
2030
|
-
|
|
1869
|
+
_context15.next = 11;
|
|
2031
1870
|
return Promise.all(optimizedDefinitions.map(function (req) {
|
|
2032
1871
|
return _this5.chain.request(req);
|
|
2033
1872
|
}));
|
|
2034
1873
|
|
|
2035
1874
|
case 11:
|
|
2036
|
-
responses =
|
|
1875
|
+
responses = _context15.sent;
|
|
2037
1876
|
// "Included" documents will be stored in the `documents` store
|
|
2038
1877
|
uniqueDocuments = (0, _uniqBy.default)((0, _flatten.default)(documents), '_id');
|
|
2039
1878
|
included = (0, _flatten.default)(responses.map(function (r) {
|
|
@@ -2046,11 +1885,11 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2046
1885
|
// storing the document. This makes the data easier to manipulate for the front-end.
|
|
2047
1886
|
|
|
2048
1887
|
relationshipsByDocId = {};
|
|
2049
|
-
|
|
1888
|
+
_iterator5 = _createForOfIteratorHelper((0, _zip.default)(optimizedDefinitions, responses));
|
|
2050
1889
|
|
|
2051
1890
|
try {
|
|
2052
|
-
for (
|
|
2053
|
-
|
|
1891
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
1892
|
+
_step5$value = (0, _slicedToArray2.default)(_step5.value, 2), def = _step5$value[0], resp = _step5$value[1];
|
|
2054
1893
|
docIdAndRel = queryDefToDocIdAndRel.get(def);
|
|
2055
1894
|
|
|
2056
1895
|
if (docIdAndRel) {
|
|
@@ -2060,24 +1899,24 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2060
1899
|
}
|
|
2061
1900
|
}
|
|
2062
1901
|
} catch (err) {
|
|
2063
|
-
|
|
1902
|
+
_iterator5.e(err);
|
|
2064
1903
|
} finally {
|
|
2065
|
-
|
|
1904
|
+
_iterator5.f();
|
|
2066
1905
|
}
|
|
2067
1906
|
|
|
2068
|
-
return
|
|
1907
|
+
return _context15.abrupt("return", _objectSpread(_objectSpread({}, (0, _helpers.attachRelationships)(response, relationshipsByDocId)), {}, {
|
|
2069
1908
|
included: included
|
|
2070
1909
|
}));
|
|
2071
1910
|
|
|
2072
1911
|
case 18:
|
|
2073
1912
|
case "end":
|
|
2074
|
-
return
|
|
1913
|
+
return _context15.stop();
|
|
2075
1914
|
}
|
|
2076
1915
|
}
|
|
2077
|
-
},
|
|
1916
|
+
}, _callee15);
|
|
2078
1917
|
}));
|
|
2079
1918
|
|
|
2080
|
-
function fetchRelationships(
|
|
1919
|
+
function fetchRelationships(_x17, _x18) {
|
|
2081
1920
|
return _fetchRelationships.apply(this, arguments);
|
|
2082
1921
|
}
|
|
2083
1922
|
|
|
@@ -2086,47 +1925,47 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2086
1925
|
}, {
|
|
2087
1926
|
key: "requestMutation",
|
|
2088
1927
|
value: function () {
|
|
2089
|
-
var _requestMutation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
1928
|
+
var _requestMutation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee16(definition, options) {
|
|
2090
1929
|
var _this6 = this;
|
|
2091
1930
|
|
|
2092
1931
|
var _definition, first, rest, firstResponse;
|
|
2093
1932
|
|
|
2094
|
-
return _regenerator.default.wrap(function
|
|
1933
|
+
return _regenerator.default.wrap(function _callee16$(_context16) {
|
|
2095
1934
|
while (1) {
|
|
2096
|
-
switch (
|
|
1935
|
+
switch (_context16.prev = _context16.next) {
|
|
2097
1936
|
case 0:
|
|
2098
1937
|
if (!Array.isArray(definition)) {
|
|
2099
|
-
|
|
1938
|
+
_context16.next = 8;
|
|
2100
1939
|
break;
|
|
2101
1940
|
}
|
|
2102
1941
|
|
|
2103
1942
|
_definition = (0, _toArray2.default)(definition), first = _definition[0], rest = _definition.slice(1);
|
|
2104
|
-
|
|
1943
|
+
_context16.next = 4;
|
|
2105
1944
|
return this.requestMutation(first);
|
|
2106
1945
|
|
|
2107
1946
|
case 4:
|
|
2108
|
-
firstResponse =
|
|
2109
|
-
|
|
1947
|
+
firstResponse = _context16.sent;
|
|
1948
|
+
_context16.next = 7;
|
|
2110
1949
|
return Promise.all(rest.map(function (def) {
|
|
2111
1950
|
var mutationDef = typeof def === 'function' ? def(firstResponse) : def;
|
|
2112
1951
|
return _this6.requestMutation(mutationDef);
|
|
2113
1952
|
}));
|
|
2114
1953
|
|
|
2115
1954
|
case 7:
|
|
2116
|
-
return
|
|
1955
|
+
return _context16.abrupt("return", firstResponse);
|
|
2117
1956
|
|
|
2118
1957
|
case 8:
|
|
2119
|
-
return
|
|
1958
|
+
return _context16.abrupt("return", this.chain.request(definition, options));
|
|
2120
1959
|
|
|
2121
1960
|
case 9:
|
|
2122
1961
|
case "end":
|
|
2123
|
-
return
|
|
1962
|
+
return _context16.stop();
|
|
2124
1963
|
}
|
|
2125
1964
|
}
|
|
2126
|
-
},
|
|
1965
|
+
}, _callee16, this);
|
|
2127
1966
|
}));
|
|
2128
1967
|
|
|
2129
|
-
function requestMutation(
|
|
1968
|
+
function requestMutation(_x19, _x20) {
|
|
2130
1969
|
return _requestMutation.apply(this, arguments);
|
|
2131
1970
|
}
|
|
2132
1971
|
|
|
@@ -2159,10 +1998,6 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2159
1998
|
value: function hydrateDocuments(doctype, documents) {
|
|
2160
1999
|
var _this8 = this;
|
|
2161
2000
|
|
|
2162
|
-
if (this.options.autoHydrate === false) {
|
|
2163
|
-
return documents;
|
|
2164
|
-
}
|
|
2165
|
-
|
|
2166
2001
|
var schema = this.schema.getDoctypeSchema(doctype);
|
|
2167
2002
|
var relationships = schema.relationships;
|
|
2168
2003
|
|
|
@@ -2193,29 +2028,22 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2193
2028
|
}
|
|
2194
2029
|
|
|
2195
2030
|
var schema = schemaArg || this.schema.getDoctypeSchema(document._type);
|
|
2196
|
-
|
|
2031
|
+
var hydratedRelationships = this.hydrateRelationships(document, schema.relationships);
|
|
2032
|
+
return _objectSpread(_objectSpread({}, document), hydratedRelationships);
|
|
2197
2033
|
}
|
|
2198
2034
|
}, {
|
|
2199
2035
|
key: "hydrateRelationships",
|
|
2200
2036
|
value: function hydrateRelationships(document, schemaRelationships) {
|
|
2037
|
+
var _this9 = this;
|
|
2038
|
+
|
|
2201
2039
|
var methods = this.getRelationshipStoreAccessors();
|
|
2202
2040
|
return (0, _mapValues.default)(schemaRelationships, function (assoc, name) {
|
|
2203
|
-
|
|
2204
|
-
});
|
|
2205
|
-
}
|
|
2206
|
-
/**
|
|
2207
|
-
* Creates (locally) a new document for the given doctype.
|
|
2208
|
-
* This document is hydrated : its relationships are there
|
|
2209
|
-
* and working.
|
|
2210
|
-
*/
|
|
2041
|
+
var _this9$options, _document$relationshi;
|
|
2211
2042
|
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
_type: doctype
|
|
2217
|
-
};
|
|
2218
|
-
return this.hydrateDocument(obj);
|
|
2043
|
+
if ((_this9$options = _this9.options) !== null && _this9$options !== void 0 && _this9$options.autoHydrate || (_document$relationshi = document.relationships) !== null && _document$relationshi !== void 0 && _document$relationshi[name]) {
|
|
2044
|
+
return (0, _associations.create)(document, assoc, methods);
|
|
2045
|
+
}
|
|
2046
|
+
});
|
|
2219
2047
|
}
|
|
2220
2048
|
}, {
|
|
2221
2049
|
key: "generateRandomId",
|
|
@@ -2243,20 +2071,20 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2243
2071
|
}, {
|
|
2244
2072
|
key: "getRelationshipStoreAccessors",
|
|
2245
2073
|
value: function getRelationshipStoreAccessors() {
|
|
2246
|
-
var
|
|
2074
|
+
var _this10 = this;
|
|
2247
2075
|
|
|
2248
2076
|
if (!this.storeAccesors) {
|
|
2249
2077
|
this.storeAccessors = {
|
|
2250
2078
|
get: this.getDocumentFromState.bind(this),
|
|
2251
2079
|
save: function save(document, opts) {
|
|
2252
|
-
return
|
|
2080
|
+
return _this10.save.call(_this10, document, opts);
|
|
2253
2081
|
},
|
|
2254
2082
|
dispatch: this.dispatch.bind(this),
|
|
2255
2083
|
query: function query(def, opts) {
|
|
2256
|
-
return
|
|
2084
|
+
return _this10.query.call(_this10, def, opts);
|
|
2257
2085
|
},
|
|
2258
2086
|
mutate: function mutate(def, opts) {
|
|
2259
|
-
return
|
|
2087
|
+
return _this10.mutate.call(_this10, def, opts);
|
|
2260
2088
|
}
|
|
2261
2089
|
};
|
|
2262
2090
|
}
|
|
@@ -2307,7 +2135,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2307
2135
|
*
|
|
2308
2136
|
* @param {string} id - Id of the query (set via Query.props.as)
|
|
2309
2137
|
* @param {object} options - Options
|
|
2310
|
-
* @param {boolean} [options.hydrated] - Whether documents should be returned already hydrated
|
|
2138
|
+
* @param {boolean} [options.hydrated] - Whether documents should be returned already hydrated
|
|
2311
2139
|
* @param {object} [options.singleDocData] - If true, the "data" returned will be
|
|
2312
2140
|
* a single doc instead of an array for single doc queries. Defaults to false for backward
|
|
2313
2141
|
* compatibility but will be set to true in the future.
|
|
@@ -2319,22 +2147,33 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2319
2147
|
key: "getQueryFromState",
|
|
2320
2148
|
value: function getQueryFromState(id) {
|
|
2321
2149
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2322
|
-
var
|
|
2323
|
-
|
|
2150
|
+
var singleDocData = options.singleDocData || false; // `hydrated` has priority over global `autoHydrate`
|
|
2151
|
+
|
|
2152
|
+
var shouldHydrate = options.hydrated !== undefined ? options.hydrated : this.options.autoHydrate;
|
|
2324
2153
|
|
|
2325
2154
|
try {
|
|
2155
|
+
var _this$schema$getDocty;
|
|
2156
|
+
|
|
2326
2157
|
var queryResults = (0, _store.getQueryFromState)(this.store.getState(), id);
|
|
2327
2158
|
var doctype = queryResults.definition && queryResults.definition.doctype;
|
|
2328
2159
|
var isSingleDocQuery = queryResults.definition && queryResults.definition.id;
|
|
2329
2160
|
|
|
2330
|
-
if (!
|
|
2161
|
+
if (!shouldHydrate && !singleDocData) {
|
|
2331
2162
|
// Early return let's us preserve reference equality in the simple case
|
|
2332
2163
|
return queryResults;
|
|
2333
2164
|
}
|
|
2334
2165
|
|
|
2335
|
-
var
|
|
2166
|
+
var hydratedData = shouldHydrate && doctype ? this.hydrateDocuments(doctype, queryResults.data) : queryResults.data;
|
|
2167
|
+
var relationships = (_this$schema$getDocty = this.schema.getDoctypeSchema(doctype)) === null || _this$schema$getDocty === void 0 ? void 0 : _this$schema$getDocty.relationships;
|
|
2168
|
+
var relationshipNames = relationships ? Object.keys(relationships) : null; // The `data` array contains the hydrated data with the relationships, if any.
|
|
2169
|
+
// The `storeData` array contains the documents from the store: this is useful to preserve
|
|
2170
|
+
// referential equality, to be later evaluated to determine whether or not the
|
|
2171
|
+
// documents had changed.
|
|
2172
|
+
|
|
2336
2173
|
return _objectSpread(_objectSpread({}, queryResults), {}, {
|
|
2337
|
-
data: isSingleDocQuery && singleDocData ?
|
|
2174
|
+
data: isSingleDocQuery && singleDocData ? hydratedData[0] : hydratedData,
|
|
2175
|
+
storeData: isSingleDocQuery && singleDocData ? queryResults.data[0] : queryResults.data,
|
|
2176
|
+
relationshipNames: relationshipNames
|
|
2338
2177
|
});
|
|
2339
2178
|
} catch (e) {
|
|
2340
2179
|
_logger.default.warn("Could not get query from state. queryId: ".concat(id, ", error: ").concat(e.message));
|
|
@@ -2384,34 +2223,34 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2384
2223
|
}, {
|
|
2385
2224
|
key: "startOAuthFlow",
|
|
2386
2225
|
value: function () {
|
|
2387
|
-
var _startOAuthFlow = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
2226
|
+
var _startOAuthFlow = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(openURLCallback) {
|
|
2388
2227
|
var stackClient;
|
|
2389
|
-
return _regenerator.default.wrap(function
|
|
2228
|
+
return _regenerator.default.wrap(function _callee17$(_context17) {
|
|
2390
2229
|
while (1) {
|
|
2391
|
-
switch (
|
|
2230
|
+
switch (_context17.prev = _context17.next) {
|
|
2392
2231
|
case 0:
|
|
2393
2232
|
stackClient = this.getStackClient();
|
|
2394
|
-
|
|
2233
|
+
_context17.next = 3;
|
|
2395
2234
|
return stackClient.register();
|
|
2396
2235
|
|
|
2397
2236
|
case 3:
|
|
2398
|
-
|
|
2237
|
+
_context17.next = 5;
|
|
2399
2238
|
return this.certifyFlagship();
|
|
2400
2239
|
|
|
2401
2240
|
case 5:
|
|
2402
|
-
return
|
|
2241
|
+
return _context17.abrupt("return", this.authorize({
|
|
2403
2242
|
openURLCallback: openURLCallback
|
|
2404
2243
|
}));
|
|
2405
2244
|
|
|
2406
2245
|
case 6:
|
|
2407
2246
|
case "end":
|
|
2408
|
-
return
|
|
2247
|
+
return _context17.stop();
|
|
2409
2248
|
}
|
|
2410
2249
|
}
|
|
2411
|
-
},
|
|
2250
|
+
}, _callee17, this);
|
|
2412
2251
|
}));
|
|
2413
2252
|
|
|
2414
|
-
function startOAuthFlow(
|
|
2253
|
+
function startOAuthFlow(_x21) {
|
|
2415
2254
|
return _startOAuthFlow.apply(this, arguments);
|
|
2416
2255
|
}
|
|
2417
2256
|
|
|
@@ -2426,28 +2265,28 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2426
2265
|
}, {
|
|
2427
2266
|
key: "certifyFlagship",
|
|
2428
2267
|
value: function () {
|
|
2429
|
-
var _certifyFlagship2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
2268
|
+
var _certifyFlagship2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18() {
|
|
2430
2269
|
var stackClient;
|
|
2431
|
-
return _regenerator.default.wrap(function
|
|
2270
|
+
return _regenerator.default.wrap(function _callee18$(_context18) {
|
|
2432
2271
|
while (1) {
|
|
2433
|
-
switch (
|
|
2272
|
+
switch (_context18.prev = _context18.next) {
|
|
2434
2273
|
case 0:
|
|
2435
2274
|
stackClient = this.getStackClient();
|
|
2436
2275
|
|
|
2437
2276
|
if (!stackClient.oauthOptions.shouldRequireFlagshipPermissions) {
|
|
2438
|
-
|
|
2277
|
+
_context18.next = 4;
|
|
2439
2278
|
break;
|
|
2440
2279
|
}
|
|
2441
2280
|
|
|
2442
|
-
|
|
2281
|
+
_context18.next = 4;
|
|
2443
2282
|
return (0, _flagshipCertification.certifyFlagship)(stackClient.oauthOptions.certificationConfig, this);
|
|
2444
2283
|
|
|
2445
2284
|
case 4:
|
|
2446
2285
|
case "end":
|
|
2447
|
-
return
|
|
2286
|
+
return _context18.stop();
|
|
2448
2287
|
}
|
|
2449
2288
|
}
|
|
2450
|
-
},
|
|
2289
|
+
}, _callee18, this);
|
|
2451
2290
|
}));
|
|
2452
2291
|
|
|
2453
2292
|
function certifyFlagship() {
|
|
@@ -2471,7 +2310,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2471
2310
|
}, {
|
|
2472
2311
|
key: "authorize",
|
|
2473
2312
|
value: function () {
|
|
2474
|
-
var _authorize = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
2313
|
+
var _authorize = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19() {
|
|
2475
2314
|
var _ref7,
|
|
2476
2315
|
_ref7$openURLCallback,
|
|
2477
2316
|
openURLCallback,
|
|
@@ -2488,14 +2327,14 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2488
2327
|
code,
|
|
2489
2328
|
token,
|
|
2490
2329
|
_stackClient,
|
|
2491
|
-
|
|
2330
|
+
_args19 = arguments;
|
|
2492
2331
|
|
|
2493
|
-
return _regenerator.default.wrap(function
|
|
2332
|
+
return _regenerator.default.wrap(function _callee19$(_context19) {
|
|
2494
2333
|
while (1) {
|
|
2495
|
-
switch (
|
|
2334
|
+
switch (_context19.prev = _context19.next) {
|
|
2496
2335
|
case 0:
|
|
2497
|
-
_ref7 =
|
|
2498
|
-
|
|
2336
|
+
_ref7 = _args19.length > 0 && _args19[0] !== undefined ? _args19[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;
|
|
2337
|
+
_context19.prev = 1;
|
|
2499
2338
|
codeVerifier = pkceCodes.codeVerifier, codeChallenge = pkceCodes.codeChallenge;
|
|
2500
2339
|
stackClient = this.getStackClient();
|
|
2501
2340
|
stateCode = stackClient.generateStateCode();
|
|
@@ -2505,19 +2344,19 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2505
2344
|
sessionCode: sessionCode,
|
|
2506
2345
|
codeChallenge: codeChallenge
|
|
2507
2346
|
});
|
|
2508
|
-
|
|
2347
|
+
_context19.next = 8;
|
|
2509
2348
|
return openURLCallback(url);
|
|
2510
2349
|
|
|
2511
2350
|
case 8:
|
|
2512
|
-
redirectedURL =
|
|
2351
|
+
redirectedURL = _context19.sent;
|
|
2513
2352
|
code = stackClient.getAccessCodeFromURL(redirectedURL, stateCode);
|
|
2514
|
-
|
|
2353
|
+
_context19.next = 12;
|
|
2515
2354
|
return stackClient.fetchAccessToken(code, undefined, undefined, codeVerifier);
|
|
2516
2355
|
|
|
2517
2356
|
case 12:
|
|
2518
|
-
token =
|
|
2357
|
+
token = _context19.sent;
|
|
2519
2358
|
stackClient.setToken(token);
|
|
2520
|
-
return
|
|
2359
|
+
return _context19.abrupt("return", {
|
|
2521
2360
|
token: token,
|
|
2522
2361
|
infos: stackClient.oauthOptions,
|
|
2523
2362
|
client: stackClient.oauthOptions // for compat with Authentication comp reasons
|
|
@@ -2525,24 +2364,24 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2525
2364
|
});
|
|
2526
2365
|
|
|
2527
2366
|
case 17:
|
|
2528
|
-
|
|
2529
|
-
|
|
2367
|
+
_context19.prev = 17;
|
|
2368
|
+
_context19.t0 = _context19["catch"](1);
|
|
2530
2369
|
|
|
2531
2370
|
/* if REGISTRATION_ABORT is emited, we have to unregister the client. */
|
|
2532
|
-
if (
|
|
2371
|
+
if (_context19.t0.message === _const.REGISTRATION_ABORT) {
|
|
2533
2372
|
_stackClient = this.getStackClient();
|
|
2534
2373
|
|
|
2535
2374
|
_stackClient.unregister();
|
|
2536
2375
|
}
|
|
2537
2376
|
|
|
2538
|
-
throw
|
|
2377
|
+
throw _context19.t0;
|
|
2539
2378
|
|
|
2540
2379
|
case 21:
|
|
2541
2380
|
case "end":
|
|
2542
|
-
return
|
|
2381
|
+
return _context19.stop();
|
|
2543
2382
|
}
|
|
2544
2383
|
}
|
|
2545
|
-
},
|
|
2384
|
+
}, _callee19, this, [[1, 17]]);
|
|
2546
2385
|
}));
|
|
2547
2386
|
|
|
2548
2387
|
function authorize() {
|
|
@@ -2617,27 +2456,27 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2617
2456
|
}, {
|
|
2618
2457
|
key: "checkForRevocation",
|
|
2619
2458
|
value: function () {
|
|
2620
|
-
var _checkForRevocation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
2621
|
-
return _regenerator.default.wrap(function
|
|
2459
|
+
var _checkForRevocation = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20() {
|
|
2460
|
+
return _regenerator.default.wrap(function _callee20$(_context20) {
|
|
2622
2461
|
while (1) {
|
|
2623
|
-
switch (
|
|
2462
|
+
switch (_context20.prev = _context20.next) {
|
|
2624
2463
|
case 0:
|
|
2625
2464
|
if (!(this.stackClient instanceof _cozyStackClient.OAuthClient)) {
|
|
2626
|
-
|
|
2465
|
+
_context20.next = 4;
|
|
2627
2466
|
break;
|
|
2628
2467
|
}
|
|
2629
2468
|
|
|
2630
|
-
return
|
|
2469
|
+
return _context20.abrupt("return", this.stackClient.checkForRevocation());
|
|
2631
2470
|
|
|
2632
2471
|
case 4:
|
|
2633
2472
|
throw 'checkForRevocation is only implemented for OAutClient';
|
|
2634
2473
|
|
|
2635
2474
|
case 5:
|
|
2636
2475
|
case "end":
|
|
2637
|
-
return
|
|
2476
|
+
return _context20.stop();
|
|
2638
2477
|
}
|
|
2639
2478
|
}
|
|
2640
|
-
},
|
|
2479
|
+
}, _callee20, this);
|
|
2641
2480
|
}));
|
|
2642
2481
|
|
|
2643
2482
|
function checkForRevocation() {
|
|
@@ -2793,17 +2632,17 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2793
2632
|
}, {
|
|
2794
2633
|
key: "loadInstanceOptionsFromStack",
|
|
2795
2634
|
value: function () {
|
|
2796
|
-
var _loadInstanceOptionsFromStack = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
2635
|
+
var _loadInstanceOptionsFromStack = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee21() {
|
|
2797
2636
|
var results, capabilitiesData, instanceData;
|
|
2798
|
-
return _regenerator.default.wrap(function
|
|
2637
|
+
return _regenerator.default.wrap(function _callee21$(_context21) {
|
|
2799
2638
|
while (1) {
|
|
2800
|
-
switch (
|
|
2639
|
+
switch (_context21.prev = _context21.next) {
|
|
2801
2640
|
case 0:
|
|
2802
|
-
|
|
2641
|
+
_context21.next = 2;
|
|
2803
2642
|
return Promise.all([this.query((0, _dsl.Q)('io.cozy.settings').getById('io.cozy.settings.capabilities')), this.query((0, _dsl.Q)('io.cozy.settings').getById('io.cozy.settings.instance'))]);
|
|
2804
2643
|
|
|
2805
2644
|
case 2:
|
|
2806
|
-
results =
|
|
2645
|
+
results = _context21.sent;
|
|
2807
2646
|
capabilitiesData = results[0].data;
|
|
2808
2647
|
instanceData = results[1].data;
|
|
2809
2648
|
this.instanceOptions = {
|
|
@@ -2815,10 +2654,10 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2815
2654
|
|
|
2816
2655
|
case 7:
|
|
2817
2656
|
case "end":
|
|
2818
|
-
return
|
|
2657
|
+
return _context21.stop();
|
|
2819
2658
|
}
|
|
2820
2659
|
}
|
|
2821
|
-
},
|
|
2660
|
+
}, _callee21, this);
|
|
2822
2661
|
}));
|
|
2823
2662
|
|
|
2824
2663
|
function loadInstanceOptionsFromStack() {
|
|
@@ -2838,7 +2677,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2838
2677
|
}, {
|
|
2839
2678
|
key: "setData",
|
|
2840
2679
|
value: function setData(data) {
|
|
2841
|
-
var
|
|
2680
|
+
var _this11 = this;
|
|
2842
2681
|
|
|
2843
2682
|
this.ensureStore();
|
|
2844
2683
|
Object.entries(data).forEach(function (_ref9) {
|
|
@@ -2846,7 +2685,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2846
2685
|
doctype = _ref10[0],
|
|
2847
2686
|
data = _ref10[1];
|
|
2848
2687
|
|
|
2849
|
-
|
|
2688
|
+
_this11.dispatch((0, _store.receiveQueryResult)(null, {
|
|
2850
2689
|
data: data
|
|
2851
2690
|
}));
|
|
2852
2691
|
});
|
|
@@ -2895,12 +2734,12 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2895
2734
|
}, {
|
|
2896
2735
|
key: "setLinks",
|
|
2897
2736
|
value: function () {
|
|
2898
|
-
var _setLinks = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
2899
|
-
var
|
|
2737
|
+
var _setLinks = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee22(links) {
|
|
2738
|
+
var _iterator6, _step6, link;
|
|
2900
2739
|
|
|
2901
|
-
return _regenerator.default.wrap(function
|
|
2740
|
+
return _regenerator.default.wrap(function _callee22$(_context22) {
|
|
2902
2741
|
while (1) {
|
|
2903
|
-
switch (
|
|
2742
|
+
switch (_context22.prev = _context22.next) {
|
|
2904
2743
|
case 0:
|
|
2905
2744
|
this.links = links ? links : [new _StackLink.default({
|
|
2906
2745
|
performanceApi: this.performanceApi
|
|
@@ -2909,64 +2748,64 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2909
2748
|
this.chain = (0, _CozyLink.chain)(this.links);
|
|
2910
2749
|
|
|
2911
2750
|
if (!this.isLogged) {
|
|
2912
|
-
|
|
2751
|
+
_context22.next = 22;
|
|
2913
2752
|
break;
|
|
2914
2753
|
}
|
|
2915
2754
|
|
|
2916
2755
|
// If the client is already logged, it means this method is called manually, after
|
|
2917
2756
|
// a client instanciation.
|
|
2918
2757
|
// Thus, we call the link's onLogin methods
|
|
2919
|
-
|
|
2920
|
-
|
|
2758
|
+
_iterator6 = _createForOfIteratorHelper(this.links);
|
|
2759
|
+
_context22.prev = 5;
|
|
2921
2760
|
|
|
2922
|
-
|
|
2761
|
+
_iterator6.s();
|
|
2923
2762
|
|
|
2924
2763
|
case 7:
|
|
2925
|
-
if ((
|
|
2926
|
-
|
|
2764
|
+
if ((_step6 = _iterator6.n()).done) {
|
|
2765
|
+
_context22.next = 14;
|
|
2927
2766
|
break;
|
|
2928
2767
|
}
|
|
2929
2768
|
|
|
2930
|
-
link =
|
|
2769
|
+
link = _step6.value;
|
|
2931
2770
|
|
|
2932
2771
|
if (!link.onLogin) {
|
|
2933
|
-
|
|
2772
|
+
_context22.next = 12;
|
|
2934
2773
|
break;
|
|
2935
2774
|
}
|
|
2936
2775
|
|
|
2937
|
-
|
|
2776
|
+
_context22.next = 12;
|
|
2938
2777
|
return link.onLogin();
|
|
2939
2778
|
|
|
2940
2779
|
case 12:
|
|
2941
|
-
|
|
2780
|
+
_context22.next = 7;
|
|
2942
2781
|
break;
|
|
2943
2782
|
|
|
2944
2783
|
case 14:
|
|
2945
|
-
|
|
2784
|
+
_context22.next = 19;
|
|
2946
2785
|
break;
|
|
2947
2786
|
|
|
2948
2787
|
case 16:
|
|
2949
|
-
|
|
2950
|
-
|
|
2788
|
+
_context22.prev = 16;
|
|
2789
|
+
_context22.t0 = _context22["catch"](5);
|
|
2951
2790
|
|
|
2952
|
-
|
|
2791
|
+
_iterator6.e(_context22.t0);
|
|
2953
2792
|
|
|
2954
2793
|
case 19:
|
|
2955
|
-
|
|
2794
|
+
_context22.prev = 19;
|
|
2956
2795
|
|
|
2957
|
-
|
|
2796
|
+
_iterator6.f();
|
|
2958
2797
|
|
|
2959
|
-
return
|
|
2798
|
+
return _context22.finish(19);
|
|
2960
2799
|
|
|
2961
2800
|
case 22:
|
|
2962
2801
|
case "end":
|
|
2963
|
-
return
|
|
2802
|
+
return _context22.stop();
|
|
2964
2803
|
}
|
|
2965
2804
|
}
|
|
2966
|
-
},
|
|
2805
|
+
}, _callee22, this, [[5, 16, 19, 22]]);
|
|
2967
2806
|
}));
|
|
2968
2807
|
|
|
2969
|
-
function setLinks(
|
|
2808
|
+
function setLinks(_x22) {
|
|
2970
2809
|
return _setLinks.apply(this, arguments);
|
|
2971
2810
|
}
|
|
2972
2811
|
|
|
@@ -2986,22 +2825,22 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2986
2825
|
}, {
|
|
2987
2826
|
key: "getSettings",
|
|
2988
2827
|
value: function () {
|
|
2989
|
-
var _getSettings2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
2990
|
-
return _regenerator.default.wrap(function
|
|
2828
|
+
var _getSettings2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee23(slug, keys) {
|
|
2829
|
+
return _regenerator.default.wrap(function _callee23$(_context23) {
|
|
2991
2830
|
while (1) {
|
|
2992
|
-
switch (
|
|
2831
|
+
switch (_context23.prev = _context23.next) {
|
|
2993
2832
|
case 0:
|
|
2994
|
-
return
|
|
2833
|
+
return _context23.abrupt("return", (0, _helpers2.getSettings)(this, slug, keys));
|
|
2995
2834
|
|
|
2996
2835
|
case 1:
|
|
2997
2836
|
case "end":
|
|
2998
|
-
return
|
|
2837
|
+
return _context23.stop();
|
|
2999
2838
|
}
|
|
3000
2839
|
}
|
|
3001
|
-
},
|
|
2840
|
+
}, _callee23, this);
|
|
3002
2841
|
}));
|
|
3003
2842
|
|
|
3004
|
-
function getSettings(
|
|
2843
|
+
function getSettings(_x23, _x24) {
|
|
3005
2844
|
return _getSettings2.apply(this, arguments);
|
|
3006
2845
|
}
|
|
3007
2846
|
|
|
@@ -3024,22 +2863,22 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
3024
2863
|
}, {
|
|
3025
2864
|
key: "saveAfterFetchSettings",
|
|
3026
2865
|
value: function () {
|
|
3027
|
-
var _saveAfterFetchSettings2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
3028
|
-
return _regenerator.default.wrap(function
|
|
2866
|
+
var _saveAfterFetchSettings2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee24(slug, itemsOrSetter, setterKeys) {
|
|
2867
|
+
return _regenerator.default.wrap(function _callee24$(_context24) {
|
|
3029
2868
|
while (1) {
|
|
3030
|
-
switch (
|
|
2869
|
+
switch (_context24.prev = _context24.next) {
|
|
3031
2870
|
case 0:
|
|
3032
|
-
return
|
|
2871
|
+
return _context24.abrupt("return", (0, _helpers2.saveAfterFetchSettings)(this, slug, itemsOrSetter, setterKeys));
|
|
3033
2872
|
|
|
3034
2873
|
case 1:
|
|
3035
2874
|
case "end":
|
|
3036
|
-
return
|
|
2875
|
+
return _context24.stop();
|
|
3037
2876
|
}
|
|
3038
2877
|
}
|
|
3039
|
-
},
|
|
2878
|
+
}, _callee24, this);
|
|
3040
2879
|
}));
|
|
3041
2880
|
|
|
3042
|
-
function saveAfterFetchSettings(
|
|
2881
|
+
function saveAfterFetchSettings(_x25, _x26, _x27) {
|
|
3043
2882
|
return _saveAfterFetchSettings2.apply(this, arguments);
|
|
3044
2883
|
}
|
|
3045
2884
|
|
|
@@ -3057,46 +2896,46 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
3057
2896
|
}, {
|
|
3058
2897
|
key: "resetQuery",
|
|
3059
2898
|
value: function () {
|
|
3060
|
-
var _resetQuery2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
2899
|
+
var _resetQuery2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee25(queryId) {
|
|
3061
2900
|
var query;
|
|
3062
|
-
return _regenerator.default.wrap(function
|
|
2901
|
+
return _regenerator.default.wrap(function _callee25$(_context25) {
|
|
3063
2902
|
while (1) {
|
|
3064
|
-
switch (
|
|
2903
|
+
switch (_context25.prev = _context25.next) {
|
|
3065
2904
|
case 0:
|
|
3066
|
-
|
|
2905
|
+
_context25.prev = 0;
|
|
3067
2906
|
|
|
3068
2907
|
if ((0, _store.isQueryExisting)(this.store.getState(), queryId)) {
|
|
3069
|
-
|
|
2908
|
+
_context25.next = 3;
|
|
3070
2909
|
break;
|
|
3071
2910
|
}
|
|
3072
2911
|
|
|
3073
|
-
return
|
|
2912
|
+
return _context25.abrupt("return", Promise.resolve(null));
|
|
3074
2913
|
|
|
3075
2914
|
case 3:
|
|
3076
2915
|
this.dispatch((0, _store.resetQuery)(queryId));
|
|
3077
2916
|
query = this.getQueryFromState(queryId);
|
|
3078
|
-
|
|
2917
|
+
_context25.next = 7;
|
|
3079
2918
|
return this.query(query.definition, {
|
|
3080
2919
|
as: queryId
|
|
3081
2920
|
});
|
|
3082
2921
|
|
|
3083
2922
|
case 7:
|
|
3084
|
-
return
|
|
2923
|
+
return _context25.abrupt("return", _context25.sent);
|
|
3085
2924
|
|
|
3086
2925
|
case 10:
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
throw
|
|
2926
|
+
_context25.prev = 10;
|
|
2927
|
+
_context25.t0 = _context25["catch"](0);
|
|
2928
|
+
throw _context25.t0;
|
|
3090
2929
|
|
|
3091
2930
|
case 13:
|
|
3092
2931
|
case "end":
|
|
3093
|
-
return
|
|
2932
|
+
return _context25.stop();
|
|
3094
2933
|
}
|
|
3095
2934
|
}
|
|
3096
|
-
},
|
|
2935
|
+
}, _callee25, this, [[0, 10]]);
|
|
3097
2936
|
}));
|
|
3098
2937
|
|
|
3099
|
-
function resetQuery(
|
|
2938
|
+
function resetQuery(_x28) {
|
|
3100
2939
|
return _resetQuery2.apply(this, arguments);
|
|
3101
2940
|
}
|
|
3102
2941
|
|
|
@@ -3124,22 +2963,22 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
3124
2963
|
}, {
|
|
3125
2964
|
key: "fromOldOAuthClient",
|
|
3126
2965
|
value: function () {
|
|
3127
|
-
var _fromOldOAuthClient = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
2966
|
+
var _fromOldOAuthClient = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee26(oldClient, options) {
|
|
3128
2967
|
var credentials, oauthOptions, client;
|
|
3129
|
-
return _regenerator.default.wrap(function
|
|
2968
|
+
return _regenerator.default.wrap(function _callee26$(_context26) {
|
|
3130
2969
|
while (1) {
|
|
3131
|
-
switch (
|
|
2970
|
+
switch (_context26.prev = _context26.next) {
|
|
3132
2971
|
case 0:
|
|
3133
2972
|
if (!oldClient._oauth) {
|
|
3134
|
-
|
|
2973
|
+
_context26.next = 12;
|
|
3135
2974
|
break;
|
|
3136
2975
|
}
|
|
3137
2976
|
|
|
3138
|
-
|
|
2977
|
+
_context26.next = 3;
|
|
3139
2978
|
return oldClient.authorize();
|
|
3140
2979
|
|
|
3141
2980
|
case 3:
|
|
3142
|
-
credentials =
|
|
2981
|
+
credentials = _context26.sent;
|
|
3143
2982
|
oauthOptions = {
|
|
3144
2983
|
oauth: credentials.client,
|
|
3145
2984
|
token: credentials.token,
|
|
@@ -3150,28 +2989,28 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
3150
2989
|
}, oauthOptions), options));
|
|
3151
2990
|
|
|
3152
2991
|
if (!client.loginPromise) {
|
|
3153
|
-
|
|
2992
|
+
_context26.next = 9;
|
|
3154
2993
|
break;
|
|
3155
2994
|
}
|
|
3156
2995
|
|
|
3157
|
-
|
|
2996
|
+
_context26.next = 9;
|
|
3158
2997
|
return client.loginPromise;
|
|
3159
2998
|
|
|
3160
2999
|
case 9:
|
|
3161
|
-
return
|
|
3000
|
+
return _context26.abrupt("return", client);
|
|
3162
3001
|
|
|
3163
3002
|
case 12:
|
|
3164
3003
|
throw new Error('Cannot instantiate a new client: old client is not an OAuth client. CozyClient.fromOldClient might be more suitable.');
|
|
3165
3004
|
|
|
3166
3005
|
case 13:
|
|
3167
3006
|
case "end":
|
|
3168
|
-
return
|
|
3007
|
+
return _context26.stop();
|
|
3169
3008
|
}
|
|
3170
3009
|
}
|
|
3171
|
-
},
|
|
3010
|
+
}, _callee26);
|
|
3172
3011
|
}));
|
|
3173
3012
|
|
|
3174
|
-
function fromOldOAuthClient(
|
|
3013
|
+
function fromOldOAuthClient(_x29, _x30) {
|
|
3175
3014
|
return _fromOldOAuthClient.apply(this, arguments);
|
|
3176
3015
|
}
|
|
3177
3016
|
|
|
@@ -3264,7 +3103,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
3264
3103
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
3265
3104
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
3266
3105
|
|
|
3267
|
-
CozyClient.version = "
|
|
3106
|
+
CozyClient.version = "60.1.0";
|
|
3268
3107
|
|
|
3269
3108
|
_microee.default.mixin(CozyClient);
|
|
3270
3109
|
|