cozy-client 48.7.0 → 48.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.
@@ -2830,7 +2830,7 @@ var CozyClient = /*#__PURE__*/function () {
2830
2830
  CozyClient.hooks = CozyClient.hooks || {};
2831
2831
  CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
2832
2832
 
2833
- CozyClient.version = "48.7.0";
2833
+ CozyClient.version = "48.9.0";
2834
2834
 
2835
2835
  _microee.default.mixin(CozyClient);
2836
2836
 
@@ -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.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.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
 
@@ -585,5 +585,22 @@ var makeExpirationDescription = function makeExpirationDescription(expirationDat
585
585
  duration: distance
586
586
  });
587
587
  };
588
+ /**
589
+ * @param {IOCozyFile} file - io.cozy.files document
590
+ * @returns {boolean}
591
+ */
592
+
593
+
594
+ exports.makeExpirationDescription = makeExpirationDescription;
595
+
596
+ var isForeignPaper = function isForeignPaper(file) {
597
+ var _file$metadata13;
598
+
599
+ if ((_file$metadata13 = file.metadata) !== null && _file$metadata13 !== void 0 && _file$metadata13.country) {
600
+ return file.metadata.country.toLowerCase() !== 'fr';
601
+ }
602
+
603
+ return false;
604
+ };
588
605
 
589
- exports.makeExpirationDescription = makeExpirationDescription;
606
+ exports.isForeignPaper = isForeignPaper;
@@ -9,17 +9,20 @@ import * as paperModel from './paper'
9
9
  * @param {string} [param.expirationDate] - expiration date of file
10
10
  * @param {string} [param.referencedDate] - reference date of file
11
11
  * @param {string} [param.noticePeriod] - period before send notification
12
+ * @param {object} [param.metadata] - metadata of file
12
13
  */
13
14
  const buildMockFile = ({
14
15
  qualificationLabel,
15
16
  expirationDate,
16
17
  referencedDate,
17
- noticePeriod
18
+ noticePeriod,
19
+ metadata = {}
18
20
  }) => {
19
21
  return /** @type {import('../types').IOCozyFile} */ ({
20
22
  name: qualificationLabel,
21
23
  created_at: '2022-09-01T00:00:00.000Z',
22
24
  metadata: {
25
+ ...metadata,
23
26
  qualification: { label: qualificationLabel },
24
27
  ...(expirationDate && { expirationDate }),
25
28
  ...(referencedDate && { referencedDate }),
@@ -43,7 +46,18 @@ describe('Expiration', () => {
43
46
  const fakeNationalIdCardFile = buildMockFile({
44
47
  qualificationLabel: 'national_id_card',
45
48
  expirationDate: '2022-09-23T11:35:58.118Z',
46
- noticePeriod: '90'
49
+ noticePeriod: '90',
50
+ metadata: {
51
+ country: 'FR'
52
+ }
53
+ })
54
+ const fakeForeignNationalIdCardFile = buildMockFile({
55
+ qualificationLabel: 'national_id_card',
56
+ expirationDate: '2022-09-23T11:35:58.118Z',
57
+ noticePeriod: '90',
58
+ metadata: {
59
+ country: 'BE'
60
+ }
47
61
  })
48
62
  const fakePassportFile = buildMockFile({
49
63
  qualificationLabel: 'passport',
@@ -263,4 +277,18 @@ describe('Expiration', () => {
263
277
  expect(res).toEqual('France')
264
278
  })
265
279
  })
280
+
281
+ describe('isForeignPaper', () => {
282
+ it('should return true if the paper is a foreign paper', () => {
283
+ const res = paperModel.isForeignPaper(fakeForeignNationalIdCardFile)
284
+
285
+ expect(res).toBe(true)
286
+ })
287
+
288
+ it('should return false if the paper is not a foreign paper', () => {
289
+ const res = paperModel.isForeignPaper(fakeNationalIdCardFile)
290
+
291
+ expect(res).toBe(false)
292
+ })
293
+ })
266
294
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "48.7.0",
3
+ "version": "48.9.0",
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": "^48.6.0",
21
+ "cozy-stack-client": "^48.9.0",
22
22
  "date-fns": "2.29.3",
23
23
  "json-stable-stringify": "^1.0.1",
24
24
  "lodash": "^4.17.13",
@@ -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": "75f074966513ae524d0df226581fcc33c367bf3a"
78
+ "gitHead": "26f1206b6e5db65bd7da40cb7714d6bc94d00cf9"
79
79
  }
@@ -49,5 +49,6 @@ export function makeExpiresInMessage(expirationDate: string, { lang }: {
49
49
  export function makeExpirationDescription(expirationDate: string, { lang }: {
50
50
  lang: string;
51
51
  }): string;
52
+ export function isForeignPaper(file: IOCozyFile): boolean;
52
53
  export type IOCozyFile = import("../types").CozyClientDocument & import("../types").FileDocument;
53
54
  export type MetadataQualificationType = "other" | "date" | "contact" | "information" | "bills";