cozy-client 45.8.1 → 45.9.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.
@@ -2703,7 +2703,7 @@ var CozyClient = /*#__PURE__*/function () {
2703
2703
  CozyClient.hooks = CozyClient.hooks || {};
2704
2704
  CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
2705
2705
 
2706
- CozyClient.version = "45.8.1";
2706
+ CozyClient.version = "45.9.0";
2707
2707
 
2708
2708
  _microee.default.mixin(CozyClient);
2709
2709
 
@@ -60,14 +60,41 @@ var Qualification = /*#__PURE__*/function () {
60
60
  * @type {string?}
61
61
  */
62
62
  this.label = qualification.label;
63
- /**
64
- * @type {string?}
65
- */
63
+ var purpose = attributes.purpose || qualification.purpose;
66
64
 
67
- this.purpose = attributes.purpose || qualification.purpose;
68
- this.sourceCategory = attributes.sourceCategory || qualification.sourceCategory;
69
- this.sourceSubCategory = attributes.sourceSubCategory || qualification.sourceSubCategory;
70
- this.subjects = attributes.subjects || qualification.subjects;
65
+ if (purpose) {
66
+ /**
67
+ * @type {string?}
68
+ */
69
+ this.purpose = purpose;
70
+ }
71
+
72
+ var sourceCategory = attributes.sourceCategory || qualification.sourceCategory;
73
+
74
+ if (sourceCategory) {
75
+ /**
76
+ * @type {string?}
77
+ */
78
+ this.sourceCategory = sourceCategory;
79
+ }
80
+
81
+ var sourceSubCategory = attributes.sourceSubCategory || qualification.sourceSubCategory;
82
+
83
+ if (sourceSubCategory) {
84
+ /**
85
+ * @type {string?}
86
+ */
87
+ this.sourceSubCategory = sourceSubCategory;
88
+ }
89
+
90
+ var subjects = attributes.subjects || qualification.subjects;
91
+
92
+ if (subjects) {
93
+ /**
94
+ * @type {Array<string>?}
95
+ */
96
+ this.subjects = subjects;
97
+ }
71
98
  } else {
72
99
  throw new Error("No qualification found for the label ".concat(label));
73
100
  }
@@ -6,6 +6,42 @@ import {
6
6
  import * as qualificationModel from '../../assets/qualifications.json'
7
7
  import logger from '../../logger'
8
8
 
9
+ jest.mock('../../assets/qualifications.json', () => ({
10
+ qualifications: [
11
+ {
12
+ label: 'isp_invoice',
13
+ purpose: 'invoice',
14
+ sourceCategory: 'telecom',
15
+ sourceSubCategory: 'internet',
16
+ subjects: ['subscription']
17
+ },
18
+ {
19
+ label: 'national_id_card',
20
+ purpose: 'attestation',
21
+ sourceCategory: 'gov',
22
+ sourceSubCategory: 'civil_registration',
23
+ subjects: ['identity']
24
+ },
25
+ {
26
+ label: 'health_invoice',
27
+ purpose: 'invoice',
28
+ sourceCategory: 'health'
29
+ },
30
+ {
31
+ label: 'other_identity_document',
32
+ purpose: 'attestation',
33
+ subjects: ['identity']
34
+ },
35
+ {
36
+ label: 'dummy_empty'
37
+ }
38
+ ],
39
+ purposeKnownValues: ['attestation', 'invoice'],
40
+ sourceCategoryKnownValues: ['telecom', 'health', 'gov'],
41
+ sourceSubCategoryKnownValues: ['civil_registration', 'internet'],
42
+ subjectsKnownValues: ['identity', 'subscription']
43
+ }))
44
+
9
45
  describe('document qualification', () => {
10
46
  beforeEach(() => {
11
47
  jest.spyOn(logger, 'warn').mockImplementation(() => jest.fn())
@@ -133,6 +169,17 @@ describe('qualifications items', () => {
133
169
  })
134
170
  })
135
171
 
172
+ it('should not have undefined attributes', () => {
173
+ const qualification = Qualification.getByLabel('dummy_empty')
174
+ expect(Object.hasOwn(qualification, 'purpose')).toBe(false)
175
+ expect(Object.hasOwn(qualification, 'sourceCategory')).toBe(false)
176
+ expect(Object.hasOwn(qualification, 'sourceSubCategory')).toBe(false)
177
+ expect(Object.hasOwn(qualification, 'subjects')).toBe(false)
178
+ Object.keys(qualification).forEach(key => {
179
+ expect(qualification[key]).toBeDefined()
180
+ })
181
+ })
182
+
136
183
  it('should define authorized attributes', () => {
137
184
  qualificationModel.qualifications.forEach(q => {
138
185
  if (q.purpose) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "45.8.1",
3
+ "version": "45.9.0",
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": "9dc765092e0dca01942a6a1d2c9a57e7325c1291"
78
+ "gitHead": "08333a1ee09c530fd2677a1a516605d524d0c07a"
79
79
  }
@@ -29,9 +29,18 @@ export class Qualification {
29
29
  * @type {string?}
30
30
  */
31
31
  purpose: string | null;
32
- sourceCategory: string;
33
- sourceSubCategory: string;
34
- subjects: string[];
32
+ /**
33
+ * @type {string?}
34
+ */
35
+ sourceCategory: string | null;
36
+ /**
37
+ * @type {string?}
38
+ */
39
+ sourceSubCategory: string | null;
40
+ /**
41
+ * @type {Array<string>?}
42
+ */
43
+ subjects: Array<string> | null;
35
44
  /**
36
45
  * Check the given qualification attributes respects the following rules:
37
46
  * - For the given label, if a purpose, sourceCategory or sourceSubCategory