cozy-client 46.9.1 → 46.10.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.
@@ -2782,7 +2782,7 @@ var CozyClient = /*#__PURE__*/function () {
2782
2782
  CozyClient.hooks = CozyClient.hooks || {};
2783
2783
  CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
2784
2784
 
2785
- CozyClient.version = "46.9.1";
2785
+ CozyClient.version = "46.10.0";
2786
2786
 
2787
2787
  _microee.default.mixin(CozyClient);
2788
2788
 
@@ -63,7 +63,7 @@ var getInitials = function getInitials(contact) {
63
63
  /**
64
64
  * Returns the contact's main email
65
65
  *
66
- * @param {object} contact - A contact
66
+ * @param {import('../types').IOCozyContact} contact - A contact
67
67
  * @returns {string} - The contact's main email
68
68
  */
69
69
 
@@ -76,7 +76,7 @@ var getPrimaryEmail = function getPrimaryEmail(contact) {
76
76
  /**
77
77
  * Returns the contact's main cozy
78
78
  *
79
- * @param {object} contact - A contact
79
+ * @param {import('../types').IOCozyContact} contact - A contact
80
80
  * @returns {string} - The contact's main cozy
81
81
  */
82
82
 
@@ -89,7 +89,7 @@ var getPrimaryCozy = function getPrimaryCozy(contact) {
89
89
  /**
90
90
  * Returns the contact's main cozy url without protocol
91
91
  *
92
- * @param {object} contact - A contact
92
+ * @param {import('../types').IOCozyContact} contact - A contact
93
93
  * @returns {string} - The contact's main cozy url
94
94
  */
95
95
 
@@ -107,7 +107,7 @@ var getPrimaryCozyDomain = function getPrimaryCozyDomain(contact) {
107
107
  /**
108
108
  * Returns the contact's main phone number
109
109
  *
110
- * @param {object} contact - A contact
110
+ * @param {import('../types').IOCozyContact} contact - A contact
111
111
  * @returns {string} - The contact's main phone number
112
112
  */
113
113
 
@@ -120,7 +120,7 @@ var getPrimaryPhone = function getPrimaryPhone(contact) {
120
120
  /**
121
121
  * Returns the contact's main address
122
122
  *
123
- * @param {object} contact - A contact
123
+ * @param {import('../types').IOCozyContact} contact - A contact
124
124
  * @returns {string} - The contact's main address
125
125
  */
126
126
 
@@ -140,7 +140,7 @@ var defaultFullnameAttributes = ['namePrefix', 'givenName', 'additionalName', 'f
140
140
  /**
141
141
  * Makes fullname from contact name
142
142
  *
143
- * @param {object} contact - A contact
143
+ * @param {import('../types').IOCozyContact} contact - A contact
144
144
  * @param {{ attributesFullname: FullnameAttributes[] }} [opts] - Options
145
145
  * @returns {string} - The contact's fullname
146
146
  */
@@ -161,7 +161,7 @@ var makeFullname = function makeFullname(contact, opts) {
161
161
  /**
162
162
  * Returns the contact's fullname
163
163
  *
164
- * @param {object} contact - A contact
164
+ * @param {import('../types').IOCozyContact} contact - A contact
165
165
  * @returns {string} - The contact's fullname
166
166
  */
167
167
 
@@ -178,7 +178,7 @@ var getFullname = function getFullname(contact) {
178
178
  /**
179
179
  * Makes displayName from contact data
180
180
  *
181
- * @param {*} contact - A contact
181
+ * @param {import('../types').IOCozyContact} contact - A contact
182
182
  * @param {{ attributesFullname: FullnameAttributes[] }} [opts] - Options
183
183
  * @returns {string} - The contact's displayName
184
184
  */
@@ -208,7 +208,7 @@ var makeDisplayName = function makeDisplayName(contact, opts) {
208
208
  /**
209
209
  * Returns a display name for the contact
210
210
  *
211
- * @param {object} contact - A contact
211
+ * @param {import('../types').IOCozyContact} contact - A contact
212
212
  * @returns {string} - the contact's display name
213
213
  **/
214
214
 
@@ -225,7 +225,7 @@ var getDisplayName = function getDisplayName(contact) {
225
225
  /**
226
226
  * Makes 'byFamilyNameGivenNameEmailCozyUrl' index of a contact
227
227
  *
228
- * @param {object} contact - A contact
228
+ * @param {import('../types').IOCozyContact} contact - A contact
229
229
  * @returns {string} - the contact's 'byFamilyNameGivenNameEmailCozyUrl' index
230
230
  */
231
231
 
@@ -244,7 +244,7 @@ var makeDefaultSortIndexValue = function makeDefaultSortIndexValue(contact) {
244
244
  /**
245
245
  * Returns 'byFamilyNameGivenNameEmailCozyUrl' index of a contact
246
246
  *
247
- * @param {object} contact - A contact
247
+ * @param {import('../types').IOCozyContact} contact - A contact
248
248
  * @returns {string} - the contact's 'byFamilyNameGivenNameEmailCozyUrl' index
249
249
  */
250
250
 
@@ -264,7 +264,7 @@ var getDefaultSortIndexValue = function getDefaultSortIndexValue(contact) {
264
264
  * Returns 'byFamilyNameGivenNameEmailCozyUrl' index of a contact
265
265
  *
266
266
  * @deprecated Prefer to use getDefaultSortIndexValue.
267
- * @param {object} contact - A contact
267
+ * @param {import('../types').IOCozyContact} contact - A contact
268
268
  * @returns {string} - the contact's 'byFamilyNameGivenNameEmailCozyUrl' index
269
269
  */
270
270
 
@@ -157,6 +157,11 @@
157
157
  "undefined": "Undefined",
158
158
  "work_study": "Work & Study"
159
159
  },
160
+ "expiration": {
161
+ "expired": "Expired",
162
+ "expiresIn": "Expires in %{duration}",
163
+ "description": "This document expires in %{duration}, consider renewing it"
164
+ },
160
165
  "qualification": {
161
166
  "date": {
162
167
  "title": {
@@ -157,6 +157,11 @@
157
157
  "undefined": "Indéfini",
158
158
  "work_study": "Travail & Études"
159
159
  },
160
+ "expiration": {
161
+ "expired": "Expiré",
162
+ "expiresIn": "Expire dans %{duration}",
163
+ "description": "Ce document expire dans %{duration}, pensez à le renouveler"
164
+ },
160
165
  "qualification": {
161
166
  "date": {
162
167
  "title": {
@@ -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.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_OTHER_METADATA_NAMES = exports.KNOWN_INFORMATION_METADATA_NAMES = exports.KNOWN_DATE_METADATA_NAMES = void 0;
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_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
 
@@ -13,6 +13,10 @@ var _add = _interopRequireDefault(require("date-fns/add"));
13
13
 
14
14
  var _sub = _interopRequireDefault(require("date-fns/sub"));
15
15
 
16
+ var _formatDistanceToNowStrict = _interopRequireDefault(require("date-fns/formatDistanceToNowStrict"));
17
+
18
+ var _fr = _interopRequireDefault(require("date-fns/locale/fr"));
19
+
16
20
  var _locales = require("./document/locales");
17
21
 
18
22
  var _contact = require("./contact");
@@ -508,5 +512,61 @@ var formatContactValue = function formatContactValue(contacts) {
508
512
  return "".concat((0, _contact.getDisplayName)(contact));
509
513
  }).join(', ') : '';
510
514
  };
515
+ /**
516
+ * @param {Object} options - Options
517
+ * @param {string} options.lang - Lang requested for the translation
518
+ * @returns {string}
519
+ */
520
+
521
+
522
+ exports.formatContactValue = formatContactValue;
523
+
524
+ var makeExpiredMessage = function makeExpiredMessage(_ref9) {
525
+ var lang = _ref9.lang;
526
+ var t = (0, _locales.getLocalizer)(lang);
527
+ return t('Scan.expiration.expired');
528
+ };
529
+ /**
530
+ * @param {string} expirationDate - Expiration date
531
+ * @param {Object} options - Options
532
+ * @param {string} options.lang - Lang requested for the translation
533
+ * @returns {string}
534
+ */
535
+
536
+
537
+ exports.makeExpiredMessage = makeExpiredMessage;
538
+
539
+ var makeExpiresInMessage = function makeExpiresInMessage(expirationDate, _ref10) {
540
+ var lang = _ref10.lang;
541
+ var t = (0, _locales.getLocalizer)(lang);
542
+ var distance = (0, _formatDistanceToNowStrict.default)(new Date(expirationDate), {
543
+ locale: lang === 'fr' ? _fr.default : undefined // fallbacks to english if undefined
544
+
545
+ });
546
+ return t('Scan.expiration.expiresIn', {
547
+ duration: distance
548
+ });
549
+ };
550
+ /**
551
+ * @param {string} expirationDate - Expiration date
552
+ * @param {Object} options - Options
553
+ * @param {string} options.lang - Lang requested for the translation
554
+ * @returns {string}
555
+ */
556
+
557
+
558
+ exports.makeExpiresInMessage = makeExpiresInMessage;
559
+
560
+ var makeExpirationDescription = function makeExpirationDescription(expirationDate, _ref11) {
561
+ var lang = _ref11.lang;
562
+ var t = (0, _locales.getLocalizer)(lang);
563
+ var distance = (0, _formatDistanceToNowStrict.default)(new Date(expirationDate), {
564
+ locale: lang === 'fr' ? _fr.default : undefined // fallbacks to english if undefined
565
+
566
+ });
567
+ return t('Scan.expiration.description', {
568
+ duration: distance
569
+ });
570
+ };
511
571
 
512
- exports.formatContactValue = formatContactValue;
572
+ exports.makeExpirationDescription = makeExpirationDescription;
package/dist/types.js CHANGED
@@ -483,7 +483,8 @@ var _dsl = require("./queries/dsl");
483
483
  /**
484
484
  * @typedef {object} ContactEmail
485
485
  * @property {string} address - Email address
486
- * @property {string} [type] - A user-provided localized type of email address (example: "Work", "Home", "Other")
486
+ * @property {string} [type] - A user-provided localized type (example: `"Personal"`, `"Professional"`, `"Other"`)
487
+ * @property {'work'|'home'} [label] - A keyword to identify the type, must be `work|home`
487
488
  * @property {boolean} [primary] - Indicates a preferred-use address
488
489
  */
489
490
 
@@ -513,7 +514,8 @@ var _dsl = require("./queries/dsl");
513
514
  * @property {string} [number] - Lane number
514
515
  * @property {string} [code] - Postal code
515
516
  * @property {string} [country] - Country name
516
- * @property {string} [type] - A user-provided localized type of address (example: "Work", "Home", "Other")
517
+ * @property {string} [type] - A user-provided localized type (example: `"Personal"`, `"Professional"`, `"Other"`)
518
+ * @property {'work'|'home'} [label] - A keyword to identify the type, must be `work|home`
517
519
  * @property {boolean} [primary] - Indicates a preferred-use address
518
520
  * @property {ContactExtendedAddress} [extendedAddress]
519
521
  * @property {string} [formattedAddress] - Unstructured version of the address
@@ -523,7 +525,8 @@ var _dsl = require("./queries/dsl");
523
525
  /**
524
526
  * @typedef {object} ContactPhone
525
527
  * @property {string} number - Phone number
526
- * @property {string} [type] - A user-provided localized type of phone number (example: "Work", "Home", "Other")
528
+ * @property {string} [type] - A user-provided localized type (example: `"Personal"`, `"Professional"`, `"Other"`), could be provided by Contacts app too as `voice|fax|cell`
529
+ * @property {'work'|'home'} [label] - A keyword to identify the type, must be `work|home`
527
530
  * @property {boolean} [primary] - Indicates a preferred-use number
528
531
  *
529
532
  */
@@ -531,7 +534,8 @@ var _dsl = require("./queries/dsl");
531
534
  /**
532
535
  * @typedef {object} ContactCozy
533
536
  * @property {string} url
534
- * @property {string} [label] - A user-provided localized type of instance
537
+ * @property {string} [type] - A user-provided localized type (example: `"Personal"`, `"Professional"`, `"Other"`)
538
+ * @property {'work'|'home'} [label] - A keyword to identify the type, must be `work|home`
535
539
  * @property {boolean} [primary] - Indicates a preferred-use instance
536
540
  *
537
541
  */
@@ -552,11 +556,13 @@ var _dsl = require("./queries/dsl");
552
556
  * @property {string} [fullname] - Unstructured representation of the name (example: "Dr. Gregory House, M.D.")
553
557
  * @property {ContactName} [name] - Structured representation of the name
554
558
  * @property {string} [birthday] - Birthday (example: "1959-05-15")
559
+ * @property {'male'|'female'} [gender] - Gender (example: "female")
555
560
  * @property {string} [note] - Note
556
561
  * @property {Array<ContactEmail>} [email] - Email addresses
557
562
  * @property {Array<ContactAddress>} [address] - Addresses
558
563
  * @property {Array<ContactPhone>} [phone] - Phone numbers
559
564
  * @property {Array<ContactCozy>} [cozy] - Cozy instances
565
+ * @property {string} [url] - Cozy instance url (deprecated)
560
566
  * @property {string} company - Company
561
567
  * @property {string} jobTitle - Job title
562
568
  * @property {boolean} [trashed] - true if the contact is marked for removal and will be deleted soon (e.g. after remote deletion is confirmed)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "46.9.1",
3
+ "version": "46.10.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": "24ff9fa1c4abd0573c1f49fce91155732e657d46"
78
+ "gitHead": "97faf6da325ae1051675f67dd455090cdc88f17c"
79
79
  }
@@ -1,21 +1,21 @@
1
1
  export const CONTACTS_DOCTYPE: "io.cozy.contacts";
2
2
  export function getPrimaryOrFirst(property: any): (obj: any) => any;
3
3
  export function getInitials(contact: import('../types').IOCozyContact): string;
4
- export function getPrimaryEmail(contact: object): string;
5
- export function getPrimaryCozy(contact: object): string;
6
- export function getPrimaryCozyDomain(contact: object): string;
7
- export function getPrimaryPhone(contact: object): string;
8
- export function getPrimaryAddress(contact: object): string;
9
- export function makeFullname(contact: object, opts?: {
4
+ export function getPrimaryEmail(contact: import('../types').IOCozyContact): string;
5
+ export function getPrimaryCozy(contact: import('../types').IOCozyContact): string;
6
+ export function getPrimaryCozyDomain(contact: import('../types').IOCozyContact): string;
7
+ export function getPrimaryPhone(contact: import('../types').IOCozyContact): string;
8
+ export function getPrimaryAddress(contact: import('../types').IOCozyContact): string;
9
+ export function makeFullname(contact: import('../types').IOCozyContact, opts?: {
10
10
  attributesFullname: FullnameAttributes[];
11
11
  }): string;
12
- export function getFullname(contact: object): string;
13
- export function makeDisplayName(contact: any, opts?: {
12
+ export function getFullname(contact: import('../types').IOCozyContact): string;
13
+ export function makeDisplayName(contact: import('../types').IOCozyContact, opts?: {
14
14
  attributesFullname: FullnameAttributes[];
15
15
  }): string;
16
- export function getDisplayName(contact: object): string;
17
- export function makeDefaultSortIndexValue(contact: object): string;
18
- export function getDefaultSortIndexValue(contact: object): string;
19
- export function getIndexByFamilyNameGivenNameEmailCozyUrl(contact: object): string;
16
+ export function getDisplayName(contact: import('../types').IOCozyContact): string;
17
+ export function makeDefaultSortIndexValue(contact: import('../types').IOCozyContact): string;
18
+ export function getDefaultSortIndexValue(contact: import('../types').IOCozyContact): string;
19
+ export function getIndexByFamilyNameGivenNameEmailCozyUrl(contact: import('../types').IOCozyContact): string;
20
20
  export function isContact(doc: object): boolean;
21
21
  export type FullnameAttributes = "namePrefix" | "givenName" | "additionalName" | "familyName" | "nameSuffix";
@@ -39,5 +39,14 @@ export function getTranslatedNameForContact({ lang }: {
39
39
  lang: string;
40
40
  }): string;
41
41
  export function formatContactValue(contacts: object[]): string;
42
+ export function makeExpiredMessage({ lang }: {
43
+ lang: string;
44
+ }): string;
45
+ export function makeExpiresInMessage(expirationDate: string, { lang }: {
46
+ lang: string;
47
+ }): string;
48
+ export function makeExpirationDescription(expirationDate: string, { lang }: {
49
+ lang: string;
50
+ }): string;
42
51
  export type IOCozyFile = import("../types").CozyClientDocument & import("../types").FileDocument;
43
52
  export type MetadataQualificationType = "other" | "date" | "contact" | "information";
package/types/types.d.ts CHANGED
@@ -861,9 +861,13 @@ export type ContactEmail = {
861
861
  */
862
862
  address: string;
863
863
  /**
864
- * - A user-provided localized type of email address (example: "Work", "Home", "Other")
864
+ * - A user-provided localized type (example: `"Personal"`, `"Professional"`, `"Other"`)
865
865
  */
866
866
  type?: string;
867
+ /**
868
+ * - A keyword to identify the type, must be `work|home`
869
+ */
870
+ label?: 'work' | 'home';
867
871
  /**
868
872
  * - Indicates a preferred-use address
869
873
  */
@@ -939,9 +943,13 @@ export type ContactAddress = {
939
943
  */
940
944
  country?: string;
941
945
  /**
942
- * - A user-provided localized type of address (example: "Work", "Home", "Other")
946
+ * - A user-provided localized type (example: `"Personal"`, `"Professional"`, `"Other"`)
943
947
  */
944
948
  type?: string;
949
+ /**
950
+ * - A keyword to identify the type, must be `work|home`
951
+ */
952
+ label?: 'work' | 'home';
945
953
  /**
946
954
  * - Indicates a preferred-use address
947
955
  */
@@ -959,9 +967,13 @@ export type ContactPhone = {
959
967
  */
960
968
  number: string;
961
969
  /**
962
- * - A user-provided localized type of phone number (example: "Work", "Home", "Other")
970
+ * - A user-provided localized type (example: `"Personal"`, `"Professional"`, `"Other"`), could be provided by Contacts app too as `voice|fax|cell`
963
971
  */
964
972
  type?: string;
973
+ /**
974
+ * - A keyword to identify the type, must be `work|home`
975
+ */
976
+ label?: 'work' | 'home';
965
977
  /**
966
978
  * - Indicates a preferred-use number
967
979
  */
@@ -970,9 +982,13 @@ export type ContactPhone = {
970
982
  export type ContactCozy = {
971
983
  url: string;
972
984
  /**
973
- * - A user-provided localized type of instance
985
+ * - A user-provided localized type (example: `"Personal"`, `"Professional"`, `"Other"`)
974
986
  */
975
- label?: string;
987
+ type?: string;
988
+ /**
989
+ * - A keyword to identify the type, must be `work|home`
990
+ */
991
+ label?: 'work' | 'home';
976
992
  /**
977
993
  * - Indicates a preferred-use instance
978
994
  */
@@ -1015,6 +1031,10 @@ export type ContactDocument = {
1015
1031
  * - Birthday (example: "1959-05-15")
1016
1032
  */
1017
1033
  birthday?: string;
1034
+ /**
1035
+ * - Gender (example: "female")
1036
+ */
1037
+ gender?: 'male' | 'female';
1018
1038
  /**
1019
1039
  * - Note
1020
1040
  */
@@ -1035,6 +1055,10 @@ export type ContactDocument = {
1035
1055
  * - Cozy instances
1036
1056
  */
1037
1057
  cozy?: Array<ContactCozy>;
1058
+ /**
1059
+ * - Cozy instance url (deprecated)
1060
+ */
1061
+ url?: string;
1038
1062
  /**
1039
1063
  * - Company
1040
1064
  */