cozy-client 46.1.0 → 46.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
CHANGED
|
@@ -2705,7 +2705,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2705
2705
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
2706
2706
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
2707
2707
|
|
|
2708
|
-
CozyClient.version = "46.1.
|
|
2708
|
+
CozyClient.version = "46.1.1";
|
|
2709
2709
|
|
|
2710
2710
|
_microee.default.mixin(CozyClient);
|
|
2711
2711
|
|
|
@@ -15,7 +15,9 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
|
|
|
15
15
|
|
|
16
16
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _set = _interopRequireDefault(require("lodash/set"));
|
|
19
|
+
|
|
20
|
+
var _difference = _interopRequireDefault(require("lodash/difference"));
|
|
19
21
|
|
|
20
22
|
var qualificationModel = _interopRequireWildcard(require("../../assets/qualifications.json"));
|
|
21
23
|
|
|
@@ -153,16 +155,16 @@ var Qualification = /*#__PURE__*/function () {
|
|
|
153
155
|
}
|
|
154
156
|
}
|
|
155
157
|
|
|
156
|
-
var missingSubjects = (0,
|
|
158
|
+
var missingSubjects = (0, _difference.default)(this.subjects, attributes.subjects);
|
|
157
159
|
|
|
158
160
|
if (missingSubjects.length > 0) {
|
|
159
161
|
throw new Error("The subjects for the label ".concat(this.label, " should include ").concat(this.subjects, ". ") + "Please use this or open an issue on https://github.com/cozy/cozy-client/issues");
|
|
160
162
|
}
|
|
161
163
|
|
|
162
|
-
var extraSubjects = (0,
|
|
164
|
+
var extraSubjects = (0, _difference.default)(attributes.subjects, this.subjects);
|
|
163
165
|
|
|
164
166
|
if (extraSubjects.length > 0) {
|
|
165
|
-
var unknownSubjects = (0,
|
|
167
|
+
var unknownSubjects = (0, _difference.default)(extraSubjects, qualificationModel.subjectsKnownValues);
|
|
166
168
|
if (unknownSubjects.length > 0) _logger.default.info("These subjects are not listed among the known values: ".concat(unknownSubjects, ". ") + "Please open an issue on https://github.com/cozy/cozy-client/issues");
|
|
167
169
|
}
|
|
168
170
|
}
|
|
@@ -271,23 +273,29 @@ var setQualification = function setQualification(document, qualification) {
|
|
|
271
273
|
throw new Error('You must set a label to qualify');
|
|
272
274
|
}
|
|
273
275
|
|
|
274
|
-
return (0,
|
|
276
|
+
return (0, _set.default)(document, 'metadata.qualification', qualification);
|
|
275
277
|
};
|
|
276
278
|
/**
|
|
277
279
|
* Helper to get the qualification from a document
|
|
278
280
|
*
|
|
279
281
|
* @param {object} document - The document
|
|
280
|
-
* @returns {Qualification} - The document qualification
|
|
281
|
-
*
|
|
282
|
+
* @returns {Qualification|null} - The document qualification
|
|
282
283
|
*/
|
|
283
284
|
|
|
284
285
|
|
|
285
286
|
exports.setQualification = setQualification;
|
|
286
287
|
|
|
287
288
|
var getQualification = function getQualification(document) {
|
|
288
|
-
var
|
|
289
|
-
|
|
290
|
-
|
|
289
|
+
var _document$metadata;
|
|
290
|
+
|
|
291
|
+
var docQualification = document === null || document === void 0 ? void 0 : (_document$metadata = document.metadata) === null || _document$metadata === void 0 ? void 0 : _document$metadata.qualification;
|
|
292
|
+
|
|
293
|
+
if (docQualification) {
|
|
294
|
+
var qualification = new Qualification(docQualification.label, docQualification.qualification);
|
|
295
|
+
return qualification.toQualification();
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return null;
|
|
291
299
|
};
|
|
292
300
|
|
|
293
301
|
exports.getQualification = getQualification;
|
|
@@ -77,6 +77,14 @@ describe('document qualification', () => {
|
|
|
77
77
|
const fileQualification = getQualification(fileDoc)
|
|
78
78
|
expect(fileQualification).toEqual(qualification)
|
|
79
79
|
})
|
|
80
|
+
it("should return null if the file qualification doesn't exist", () => {
|
|
81
|
+
const fileDoc = {
|
|
82
|
+
_id: '123',
|
|
83
|
+
metadata: {}
|
|
84
|
+
}
|
|
85
|
+
const fileQualification = getQualification(fileDoc)
|
|
86
|
+
expect(fileQualification).toEqual(null)
|
|
87
|
+
})
|
|
80
88
|
|
|
81
89
|
it('should set the correct qualification', () => {
|
|
82
90
|
const fileDoc = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "46.1.
|
|
3
|
+
"version": "46.1.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
|
|
76
76
|
},
|
|
77
77
|
"sideEffects": false,
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "1ed9d9c1d15c984365a301e5a01a06f064c93671"
|
|
79
79
|
}
|
|
@@ -94,7 +94,7 @@ export namespace Qualification {
|
|
|
94
94
|
function getByLabel(label: string): Qualification;
|
|
95
95
|
}
|
|
96
96
|
export function setQualification(document: object, qualification: Qualification): object;
|
|
97
|
-
export function getQualification(document: object): Qualification;
|
|
97
|
+
export function getQualification(document: object): Qualification | null;
|
|
98
98
|
export type QualificationAttributes = {
|
|
99
99
|
/**
|
|
100
100
|
* - The qualification label.
|