cozy-client 51.5.0 → 51.6.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.
@@ -3026,7 +3026,7 @@ var CozyClient = /*#__PURE__*/function () {
3026
3026
  CozyClient.hooks = CozyClient.hooks || {};
3027
3027
  CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
3028
3028
 
3029
- CozyClient.version = "51.5.0";
3029
+ CozyClient.version = "51.6.1";
3030
3030
 
3031
3031
  _microee.default.mixin(CozyClient);
3032
3032
 
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.isForeignPaper = exports.makeExpirationDescription = exports.makeExpiresInMessage = exports.makeExpiredMessage = exports.formatContactValue = exports.getTranslatedNameForContact = exports.formatOtherMetadataValue = exports.getTranslatedNameForOtherMetadata = exports.formatInformationMetadataValue = exports.getTranslatedNameForInformationMetadata = exports.formatDateMetadataValue = exports.getTranslatedNameForDateMetadata = exports.getMetadataQualificationType = exports.formatMetadataQualification = exports.isExpiringSoon = exports.isExpired = exports.computeExpirationNoticeLink = exports.computeExpirationNoticeDate = exports.computeExpirationDate = exports.isExpiring = exports.KNOWN_BILLS_ATTRIBUTES_NAMES = exports.KNOWN_OTHER_METADATA_NAMES = exports.KNOWN_INFORMATION_METADATA_NAMES = exports.KNOWN_DATE_METADATA_NAMES = void 0;
8
+ exports.isForeignPaper = exports.makeExpirationDescription = exports.makeExpiresInMessage = exports.makeExpiredMessage = exports.formatContactValue = exports.getTranslatedNameForContact = exports.formatOtherMetadataValue = exports.getTranslatedNameForOtherMetadata = exports.formatInformationMetadataValue = exports.getTranslatedNameForInformationMetadata = exports.formatDateMetadataValue = exports.getTranslatedNameForDateMetadata = exports.getMetadataQualificationType = exports.formatMetadataQualification = exports.makeMetadataQualification = exports.isExpiringSoon = exports.isExpired = exports.computeExpirationNoticeLink = exports.computeExpirationNoticeDate = exports.computeExpirationDate = exports.isExpiring = exports.KNOWN_BILLS_ATTRIBUTES_NAMES = exports.KNOWN_OTHER_METADATA_NAMES = exports.KNOWN_INFORMATION_METADATA_NAMES = exports.KNOWN_DATE_METADATA_NAMES = void 0;
9
9
 
10
10
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
11
 
@@ -289,6 +289,8 @@ var makeMetadataQualification = function makeMetadataQualification(_ref) {
289
289
  */
290
290
 
291
291
 
292
+ exports.makeMetadataQualification = makeMetadataQualification;
293
+
292
294
  var formatMetadataQualification = function formatMetadataQualification(metadata) {
293
295
  var dates = KNOWN_DATE_METADATA_NAMES.map(function (dateName) {
294
296
  return makeMetadataQualification({
@@ -194,6 +194,66 @@ describe('Expiration', () => {
194
194
  )
195
195
  })
196
196
 
197
+ describe('makeMetadataQualification', () => {
198
+ it('should return formatted metadata', () => {
199
+ const fakeMetadata = {
200
+ number: '111111',
201
+ AObtentionDate: '2029-12-01T23:00:00.000Z',
202
+ expirationDate: '2029-12-05T23:00:00.000Z'
203
+ }
204
+
205
+ const res = paperModel.makeMetadataQualification({
206
+ metadata: fakeMetadata,
207
+ knownMetadataPath: 'expirationDate'
208
+ })
209
+
210
+ expect(res).toEqual({
211
+ name: 'expirationDate',
212
+ value: '2029-12-05T23:00:00.000Z'
213
+ })
214
+ })
215
+
216
+ it('should return formatted metadata only if matching label', () => {
217
+ const fakeMetadata = {
218
+ number: '111111',
219
+ AObtentionDate: '2029-12-01T23:00:00.000Z',
220
+ BObtentionDate: '2029-12-02T23:00:00.000Z',
221
+ CObtentionDate: '2029-12-03T23:00:00.000Z',
222
+ expirationDate: '2029-12-05T23:00:00.000Z',
223
+ referencedDate: '2029-12-06T23:00:00.000Z',
224
+ issueDate: '2029-12-07T23:00:00.000Z',
225
+ shootingDate: '2029-12-08T23:00:00.000Z',
226
+ date: '2029-12-09T23:00:00.000Z',
227
+ datetime: '2029-12-10T23:00:00.000Z',
228
+ qualification: { label: 'fake_label' },
229
+ page: 'front',
230
+ contact: 'Alice Durand',
231
+ noticePeriod: ''
232
+ }
233
+
234
+ const metadataLabels = [
235
+ 'AObtentionDate',
236
+ 'BObtentionDate',
237
+ 'CObtentionDate',
238
+ 'DObtentionDate'
239
+ ]
240
+
241
+ const res = metadataLabels.map(dateName =>
242
+ paperModel.makeMetadataQualification({
243
+ metadata: fakeMetadata,
244
+ knownMetadataPath: dateName
245
+ })
246
+ )
247
+
248
+ expect(res).toEqual([
249
+ { name: 'AObtentionDate', value: '2029-12-01T23:00:00.000Z' },
250
+ { name: 'BObtentionDate', value: '2029-12-02T23:00:00.000Z' },
251
+ { name: 'CObtentionDate', value: '2029-12-03T23:00:00.000Z' },
252
+ null
253
+ ])
254
+ })
255
+ })
256
+
197
257
  describe('formatMetadataQualification', () => {
198
258
  it('should return correctly formatted metadata', () => {
199
259
  const fakeMetadata = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "51.5.0",
3
+ "version": "51.6.1",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.node.js",
6
6
  "browser": "dist/index.js",
@@ -18,7 +18,7 @@
18
18
  "@types/jest": "^26.0.20",
19
19
  "@types/lodash": "^4.14.170",
20
20
  "btoa": "^1.2.1",
21
- "cozy-stack-client": "^51.0.0",
21
+ "cozy-stack-client": "^51.6.0",
22
22
  "date-fns": "2.29.3",
23
23
  "json-stable-stringify": "^1.0.1",
24
24
  "lodash": "^4.17.13",
@@ -72,5 +72,5 @@
72
72
  "react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
73
73
  },
74
74
  "sideEffects": false,
75
- "gitHead": "e945d5996d306a54d14a41a7103a6e8e90260560"
75
+ "gitHead": "b46c9c9248b140429972790624fa46b1b547226f"
76
76
  }
@@ -8,6 +8,14 @@ export function computeExpirationNoticeDate(file: IOCozyFile): Date | null;
8
8
  export function computeExpirationNoticeLink(file: IOCozyFile): string | null;
9
9
  export function isExpired(file: IOCozyFile): boolean;
10
10
  export function isExpiringSoon(file: IOCozyFile): boolean;
11
+ export function makeMetadataQualification({ metadata, knownMetadataPath, value }: {
12
+ metadata: any;
13
+ knownMetadataPath: string;
14
+ value: string | null;
15
+ }): {
16
+ name: string;
17
+ value: string | null;
18
+ };
11
19
  export function formatMetadataQualification(metadata: any): {
12
20
  name: string;
13
21
  value: string | null;