cozy-client 60.1.0 → 60.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CozyClient.js +49 -26
- package/package.json +2 -2
- package/types/CozyClient.d.ts +14 -4
package/dist/CozyClient.js
CHANGED
|
@@ -1207,7 +1207,11 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
1207
1207
|
}
|
|
1208
1208
|
|
|
1209
1209
|
return [saveMutation, function (response) {
|
|
1210
|
-
var
|
|
1210
|
+
var schema = _this3.schema.getDoctypeSchema(response.data._type);
|
|
1211
|
+
|
|
1212
|
+
var doc = _this3.hydrateDocument(response.data, schema, {
|
|
1213
|
+
forceHydratation: true
|
|
1214
|
+
});
|
|
1211
1215
|
|
|
1212
1216
|
return Object.entries(referencesByName).map(function (_ref3) {
|
|
1213
1217
|
var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
|
@@ -1990,6 +1994,8 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
1990
1994
|
*
|
|
1991
1995
|
* @param {string} doctype - Doctype of the documents being hydrated
|
|
1992
1996
|
* @param {Array<import("./types").CozyClientDocument>} documents - Documents to be hydrated
|
|
1997
|
+
* @param {object} [options] - Options
|
|
1998
|
+
* @param {boolean} [options.forceHydratation=false] - 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.
|
|
1993
1999
|
* @returns {Array<import("./types").HydratedDocument>}
|
|
1994
2000
|
*/
|
|
1995
2001
|
|
|
@@ -1998,12 +2004,18 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
1998
2004
|
value: function hydrateDocuments(doctype, documents) {
|
|
1999
2005
|
var _this8 = this;
|
|
2000
2006
|
|
|
2007
|
+
var _ref7 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
2008
|
+
_ref7$forceHydratatio = _ref7.forceHydratation,
|
|
2009
|
+
forceHydratation = _ref7$forceHydratatio === void 0 ? false : _ref7$forceHydratatio;
|
|
2010
|
+
|
|
2001
2011
|
var schema = this.schema.getDoctypeSchema(doctype);
|
|
2002
2012
|
var relationships = schema.relationships;
|
|
2003
2013
|
|
|
2004
2014
|
if (relationships) {
|
|
2005
2015
|
return documents.map(function (doc) {
|
|
2006
|
-
return _this8.hydrateDocument(doc, schema
|
|
2016
|
+
return _this8.hydrateDocument(doc, schema, {
|
|
2017
|
+
forceHydratation: forceHydratation
|
|
2018
|
+
});
|
|
2007
2019
|
});
|
|
2008
2020
|
} else {
|
|
2009
2021
|
return documents;
|
|
@@ -2016,31 +2028,42 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2016
2028
|
* the relationship
|
|
2017
2029
|
*
|
|
2018
2030
|
* @param {import("./types").CozyClientDocument} document - for which relationships must be resolved
|
|
2019
|
-
* @param {Schema} [schemaArg] -
|
|
2031
|
+
* @param {Schema} [schemaArg] - The schema describing the relationships
|
|
2032
|
+
* @param {object} [options] - Options
|
|
2033
|
+
* @param {boolean} [options.forceHydratation=false] - If set to true, the doc will be hydrated w.r.t. the provided schema's relationships, even if the relationship does not exist on the doc.
|
|
2020
2034
|
* @returns {import("./types").HydratedDocument}
|
|
2021
2035
|
*/
|
|
2022
2036
|
|
|
2023
2037
|
}, {
|
|
2024
2038
|
key: "hydrateDocument",
|
|
2025
2039
|
value: function hydrateDocument(document, schemaArg) {
|
|
2040
|
+
var _ref8 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
2041
|
+
_ref8$forceHydratatio = _ref8.forceHydratation,
|
|
2042
|
+
forceHydratation = _ref8$forceHydratatio === void 0 ? false : _ref8$forceHydratatio;
|
|
2043
|
+
|
|
2026
2044
|
if (!document) {
|
|
2027
2045
|
return document;
|
|
2028
2046
|
}
|
|
2029
2047
|
|
|
2030
2048
|
var schema = schemaArg || this.schema.getDoctypeSchema(document._type);
|
|
2031
|
-
var
|
|
2049
|
+
var shouldForceHydrate = this.options.autoHydrate || forceHydratation;
|
|
2050
|
+
var hydratedRelationships = this.hydrateRelationships(document, schema.relationships, {
|
|
2051
|
+
forceHydratation: shouldForceHydrate
|
|
2052
|
+
});
|
|
2032
2053
|
return _objectSpread(_objectSpread({}, document), hydratedRelationships);
|
|
2033
2054
|
}
|
|
2034
2055
|
}, {
|
|
2035
2056
|
key: "hydrateRelationships",
|
|
2036
2057
|
value: function hydrateRelationships(document, schemaRelationships) {
|
|
2037
|
-
var
|
|
2058
|
+
var _ref9 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
|
|
2059
|
+
_ref9$forceHydratatio = _ref9.forceHydratation,
|
|
2060
|
+
forceHydratation = _ref9$forceHydratatio === void 0 ? false : _ref9$forceHydratatio;
|
|
2038
2061
|
|
|
2039
2062
|
var methods = this.getRelationshipStoreAccessors();
|
|
2040
2063
|
return (0, _mapValues.default)(schemaRelationships, function (assoc, name) {
|
|
2041
|
-
var
|
|
2064
|
+
var _document$relationshi;
|
|
2042
2065
|
|
|
2043
|
-
if (
|
|
2066
|
+
if (forceHydratation || (_document$relationshi = document.relationships) !== null && _document$relationshi !== void 0 && _document$relationshi[name]) {
|
|
2044
2067
|
return (0, _associations.create)(document, assoc, methods);
|
|
2045
2068
|
}
|
|
2046
2069
|
});
|
|
@@ -2071,20 +2094,20 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2071
2094
|
}, {
|
|
2072
2095
|
key: "getRelationshipStoreAccessors",
|
|
2073
2096
|
value: function getRelationshipStoreAccessors() {
|
|
2074
|
-
var
|
|
2097
|
+
var _this9 = this;
|
|
2075
2098
|
|
|
2076
2099
|
if (!this.storeAccesors) {
|
|
2077
2100
|
this.storeAccessors = {
|
|
2078
2101
|
get: this.getDocumentFromState.bind(this),
|
|
2079
2102
|
save: function save(document, opts) {
|
|
2080
|
-
return
|
|
2103
|
+
return _this9.save.call(_this9, document, opts);
|
|
2081
2104
|
},
|
|
2082
2105
|
dispatch: this.dispatch.bind(this),
|
|
2083
2106
|
query: function query(def, opts) {
|
|
2084
|
-
return
|
|
2107
|
+
return _this9.query.call(_this9, def, opts);
|
|
2085
2108
|
},
|
|
2086
2109
|
mutate: function mutate(def, opts) {
|
|
2087
|
-
return
|
|
2110
|
+
return _this9.mutate.call(_this9, def, opts);
|
|
2088
2111
|
}
|
|
2089
2112
|
};
|
|
2090
2113
|
}
|
|
@@ -2311,12 +2334,12 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2311
2334
|
key: "authorize",
|
|
2312
2335
|
value: function () {
|
|
2313
2336
|
var _authorize = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19() {
|
|
2314
|
-
var
|
|
2315
|
-
|
|
2337
|
+
var _ref10,
|
|
2338
|
+
_ref10$openURLCallbac,
|
|
2316
2339
|
openURLCallback,
|
|
2317
|
-
|
|
2340
|
+
_ref10$sessionCode,
|
|
2318
2341
|
sessionCode,
|
|
2319
|
-
|
|
2342
|
+
_ref10$pkceCodes,
|
|
2320
2343
|
pkceCodes,
|
|
2321
2344
|
codeVerifier,
|
|
2322
2345
|
codeChallenge,
|
|
@@ -2333,7 +2356,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2333
2356
|
while (1) {
|
|
2334
2357
|
switch (_context19.prev = _context19.next) {
|
|
2335
2358
|
case 0:
|
|
2336
|
-
|
|
2359
|
+
_ref10 = _args19.length > 0 && _args19[0] !== undefined ? _args19[0] : {}, _ref10$openURLCallbac = _ref10.openURLCallback, openURLCallback = _ref10$openURLCallbac === void 0 ? _mobile.authFunction : _ref10$openURLCallbac, _ref10$sessionCode = _ref10.sessionCode, sessionCode = _ref10$sessionCode === void 0 ? undefined : _ref10$sessionCode, _ref10$pkceCodes = _ref10.pkceCodes, pkceCodes = _ref10$pkceCodes === void 0 ? {} : _ref10$pkceCodes;
|
|
2337
2360
|
_context19.prev = 1;
|
|
2338
2361
|
codeVerifier = pkceCodes.codeVerifier, codeChallenge = pkceCodes.codeChallenge;
|
|
2339
2362
|
stackClient = this.getStackClient();
|
|
@@ -2430,9 +2453,9 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2430
2453
|
}, {
|
|
2431
2454
|
key: "setStore",
|
|
2432
2455
|
value: function setStore(store) {
|
|
2433
|
-
var
|
|
2434
|
-
|
|
2435
|
-
force =
|
|
2456
|
+
var _ref11 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
2457
|
+
_ref11$force = _ref11.force,
|
|
2458
|
+
force = _ref11$force === void 0 ? false : _ref11$force;
|
|
2436
2459
|
|
|
2437
2460
|
if (store === undefined) {
|
|
2438
2461
|
throw new Error('Store is undefined');
|
|
@@ -2677,15 +2700,15 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2677
2700
|
}, {
|
|
2678
2701
|
key: "setData",
|
|
2679
2702
|
value: function setData(data) {
|
|
2680
|
-
var
|
|
2703
|
+
var _this10 = this;
|
|
2681
2704
|
|
|
2682
2705
|
this.ensureStore();
|
|
2683
|
-
Object.entries(data).forEach(function (
|
|
2684
|
-
var
|
|
2685
|
-
doctype =
|
|
2686
|
-
data =
|
|
2706
|
+
Object.entries(data).forEach(function (_ref12) {
|
|
2707
|
+
var _ref13 = (0, _slicedToArray2.default)(_ref12, 2),
|
|
2708
|
+
doctype = _ref13[0],
|
|
2709
|
+
data = _ref13[1];
|
|
2687
2710
|
|
|
2688
|
-
|
|
2711
|
+
_this10.dispatch((0, _store.receiveQueryResult)(null, {
|
|
2689
2712
|
data: data
|
|
2690
2713
|
}));
|
|
2691
2714
|
});
|
|
@@ -3103,7 +3126,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
3103
3126
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
3104
3127
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
3105
3128
|
|
|
3106
|
-
CozyClient.version = "60.1.
|
|
3129
|
+
CozyClient.version = "60.1.1";
|
|
3107
3130
|
|
|
3108
3131
|
_microee.default.mixin(CozyClient);
|
|
3109
3132
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "60.1.
|
|
3
|
+
"version": "60.1.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"react-native-ios11-devicecheck": "^0.0.3"
|
|
75
75
|
},
|
|
76
76
|
"sideEffects": false,
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "a944c176ad97aa07f7145d97642716a9dc231990"
|
|
78
78
|
}
|
package/types/CozyClient.d.ts
CHANGED
|
@@ -584,9 +584,13 @@ declare class CozyClient {
|
|
|
584
584
|
*
|
|
585
585
|
* @param {string} doctype - Doctype of the documents being hydrated
|
|
586
586
|
* @param {Array<import("./types").CozyClientDocument>} documents - Documents to be hydrated
|
|
587
|
+
* @param {object} [options] - Options
|
|
588
|
+
* @param {boolean} [options.forceHydratation=false] - 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.
|
|
587
589
|
* @returns {Array<import("./types").HydratedDocument>}
|
|
588
590
|
*/
|
|
589
|
-
hydrateDocuments(doctype: string, documents: Array<import("./types").CozyClientDocument
|
|
591
|
+
hydrateDocuments(doctype: string, documents: Array<import("./types").CozyClientDocument>, { forceHydratation }?: {
|
|
592
|
+
forceHydratation?: boolean;
|
|
593
|
+
}): Array<import("./types").HydratedDocument>;
|
|
590
594
|
/**
|
|
591
595
|
* Resolves relationships on a document.
|
|
592
596
|
*
|
|
@@ -594,11 +598,17 @@ declare class CozyClient {
|
|
|
594
598
|
* the relationship
|
|
595
599
|
*
|
|
596
600
|
* @param {import("./types").CozyClientDocument} document - for which relationships must be resolved
|
|
597
|
-
* @param {Schema} [schemaArg] -
|
|
601
|
+
* @param {Schema} [schemaArg] - The schema describing the relationships
|
|
602
|
+
* @param {object} [options] - Options
|
|
603
|
+
* @param {boolean} [options.forceHydratation=false] - If set to true, the doc will be hydrated w.r.t. the provided schema's relationships, even if the relationship does not exist on the doc.
|
|
598
604
|
* @returns {import("./types").HydratedDocument}
|
|
599
605
|
*/
|
|
600
|
-
hydrateDocument(document: import("./types").CozyClientDocument, schemaArg?: Schema
|
|
601
|
-
|
|
606
|
+
hydrateDocument(document: import("./types").CozyClientDocument, schemaArg?: Schema, { forceHydratation }?: {
|
|
607
|
+
forceHydratation?: boolean;
|
|
608
|
+
}): import("./types").HydratedDocument;
|
|
609
|
+
hydrateRelationships(document: any, schemaRelationships: any, { forceHydratation }?: {
|
|
610
|
+
forceHydratation?: boolean;
|
|
611
|
+
}): {
|
|
602
612
|
[x: string]: any;
|
|
603
613
|
};
|
|
604
614
|
generateRandomId(): string;
|