cozy-client 27.0.0 → 27.3.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,47 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [27.3.0](https://github.com/cozy/cozy-client/compare/v27.2.0...v27.3.0) (2021-11-16)
7
+
8
+
9
+ ### Features
10
+
11
+ * Add node-polyglot package ([964b05d](https://github.com/cozy/cozy-client/commit/964b05d031c233f73640218f83469b2791a73fde))
12
+
13
+
14
+
15
+
16
+
17
+ # [27.2.0](https://github.com/cozy/cozy-client/compare/v27.1.0...v27.2.0) (2021-11-15)
18
+
19
+
20
+ ### Features
21
+
22
+ * Be more explicit on query warning messages ([8d9b896](https://github.com/cozy/cozy-client/commit/8d9b896693f94898e610a79da69dda6bc0ad6f0a))
23
+
24
+
25
+
26
+
27
+
28
+ # [27.1.0](https://github.com/cozy/cozy-client/compare/v27.0.1...v27.1.0) (2021-11-04)
29
+
30
+ **Note:** Version bump only for package cozy-client
31
+
32
+
33
+
34
+
35
+
36
+ ## [27.0.1](https://github.com/cozy/cozy-client/compare/v27.0.0...v27.0.1) (2021-11-04)
37
+
38
+
39
+ ### Bug Fixes
40
+
41
+ * Build new OAuth client from old OAuth client ([a8ecfd0](https://github.com/cozy/cozy-client/commit/a8ecfd0344d86ba7c45e2589442bb836ba274a89))
42
+
43
+
44
+
45
+
46
+
6
47
  # [27.0.0](https://github.com/cozy/cozy-client/compare/v26.0.2...v27.0.0) (2021-11-03)
7
48
 
8
49
  **Note:** Version bump only for package cozy-client
@@ -360,6 +360,7 @@ var CozyClient = /*#__PURE__*/function () {
360
360
  * a client with a cookie-based instance of cozy-client-js.
361
361
  *
362
362
  * @param {OldCozyClient} oldClient - An instance of the deprecated cozy-client
363
+ * @param {object} options - CozyStackClient options
363
364
  * @returns {CozyClient}
364
365
  */
365
366
 
@@ -699,7 +700,7 @@ var CozyClient = /*#__PURE__*/function () {
699
700
  }, {
700
701
  key: "get",
701
702
  value: function get(doctype, id) {
702
- console.warn('client.get(doctype, id) is deprecated, please use Q(doctype).getById(id) to build the same query.');
703
+ console.warn("client.get(".concat(doctype, ", id) is deprecated, please use Q(").concat(doctype, ").getById(id) to build the same query."));
703
704
  return new _dsl.QueryDefinition({
704
705
  doctype: doctype,
705
706
  id: id
@@ -2276,7 +2277,8 @@ var CozyClient = /*#__PURE__*/function () {
2276
2277
  *
2277
2278
  * Warning: unlike other instantiators, this one needs to be awaited.
2278
2279
  *
2279
- * @param {OldCozyClient} oldClient - An instance of the deprecated cozy-client
2280
+ * @param {OldCozyClient} oldClient - An OAuth instance of the deprecated cozy-client
2281
+ * @param {object} options - CozyStackClient options
2280
2282
  * @returns {Promise<CozyClient>} An instance of a client, configured from the old client
2281
2283
  */
2282
2284
 
@@ -2284,30 +2286,32 @@ var CozyClient = /*#__PURE__*/function () {
2284
2286
  key: "fromOldOAuthClient",
2285
2287
  value: function () {
2286
2288
  var _fromOldOAuthClient = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee17(oldClient, options) {
2287
- var hasOauthCreds, token;
2289
+ var credentials, oauthOptions;
2288
2290
  return _regenerator.default.wrap(function _callee17$(_context17) {
2289
2291
  while (1) {
2290
2292
  switch (_context17.prev = _context17.next) {
2291
2293
  case 0:
2292
- hasOauthCreds = oldClient._oauth && oldClient._authcreds != null;
2293
-
2294
- if (!hasOauthCreds) {
2294
+ if (!oldClient._oauth) {
2295
2295
  _context17.next = 8;
2296
2296
  break;
2297
2297
  }
2298
2298
 
2299
- _context17.next = 4;
2300
- return oldClient._authcreds;
2299
+ _context17.next = 3;
2300
+ return oldClient.authorize();
2301
2301
 
2302
- case 4:
2303
- token = _context17.sent.token;
2304
- return _context17.abrupt("return", new CozyClient(_objectSpread({
2305
- uri: oldClient._url,
2306
- token: token
2307
- }, options)));
2302
+ case 3:
2303
+ credentials = _context17.sent;
2304
+ oauthOptions = {
2305
+ oauth: credentials.client,
2306
+ token: credentials.token,
2307
+ scope: credentials.token.scope
2308
+ };
2309
+ return _context17.abrupt("return", new CozyClient(_objectSpread(_objectSpread({
2310
+ uri: oldClient._url
2311
+ }, oauthOptions), options)));
2308
2312
 
2309
2313
  case 8:
2310
- throw new Error('Old client does not have _oauth or _authcreds, cannot instantiate a new client, check if CozyClient.fromOldClient is more suitable');
2314
+ throw new Error('Cannot instantiate a new client: old client is not an OAuth client. CozyClient.fromOldClient might be more suitable.');
2311
2315
 
2312
2316
  case 9:
2313
2317
  case "end":
@@ -2411,7 +2415,7 @@ var CozyClient = /*#__PURE__*/function () {
2411
2415
  CozyClient.hooks = CozyClient.hooks || {};
2412
2416
  CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
2413
2417
 
2414
- CozyClient.version = "27.0.0";
2418
+ CozyClient.version = "27.3.0";
2415
2419
 
2416
2420
  _microee.default.mixin(CozyClient);
2417
2421
 
@@ -143,17 +143,30 @@ describe('CozyClient initialization', () => {
143
143
  it('can be instantiated from an oauth-based old client', async () => {
144
144
  // Not using a real cozy-client-js here not to have to add it as a dep
145
145
  const url = 'https://testcozy.mycozy.cloud'
146
- const token = 'Registration-token'
146
+ const oauth = {
147
+ clientID: 'my-client'
148
+ // ... other OAuth client attributes
149
+ }
150
+ const token = {
151
+ tokenType: 'bearer',
152
+ accessToken: 'access-token',
153
+ refreshToken: 'refresh-token',
154
+ scope: ['io.cozy.files']
155
+ }
147
156
  const oldClient = {
148
157
  _url: url,
149
158
  _oauth: true,
150
- _authcreds: Promise.resolve({
159
+ authorize: () => ({
160
+ client: oauth,
151
161
  token
152
162
  })
153
163
  }
154
164
  const client = await CozyClient.fromOldOAuthClient(oldClient)
165
+ console.log({ stackClient: client.stackClient })
155
166
  expect(client.stackClient.uri).toBe(url)
156
- expect(client.stackClient.token.token).toBe(token)
167
+ expect(client.stackClient.oauthOptions.clientID).toBe(oauth.clientID)
168
+ expect(client.stackClient.token.accessToken).toBe(token.accessToken)
169
+ expect(client.stackClient.scope).toBe(token.scope)
157
170
  })
158
171
 
159
172
  it('can be instantiated from dataset injected by the Stack in DOM', async () => {
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.themesList = void 0;
7
+
8
+ var _qualification = require("./qualification");
9
+
10
+ var _types = require("../../types");
11
+
12
+ /**
13
+ *
14
+ * @param {Array<ItemsLabels>} labels - Array of items labels
15
+ * @returns {Array<QualificationAttributes>}
16
+ */
17
+ var buildItemsByLabel = function buildItemsByLabel(labels) {
18
+ return labels.map(function (label) {
19
+ try {
20
+ return _qualification.Qualification.getByLabel(label);
21
+ } catch (e) {
22
+ console.log('error', e); // eslint-disable-line no-console
23
+
24
+ return null;
25
+ }
26
+ }).filter(function (item) {
27
+ return item;
28
+ });
29
+ };
30
+ /**
31
+ * @type {Array<IdentityLabel>}
32
+ */
33
+
34
+
35
+ var identityLabels = ['identity_photo', 'national_id_card', 'passport', 'residence_permit', 'family_record_book', 'birth_certificate', 'driver_license', 'other_identity_document'];
36
+ /**
37
+ * @type {Array<FamilyLabel>}
38
+ */
39
+
40
+ var familyLabels = ['family_record_book', 'birth_certificate', 'wedding', 'pacs', 'divorce', 'large_family_card', 'caf', 'other_family_document'];
41
+ /**
42
+ * @type {Array<WorkStudyLabels>}
43
+ */
44
+
45
+ var workStudyLabels = ['diploma', 'work_contract', 'pay_sheet', 'unemployment_benefit', 'pension', 'other_revenue', 'gradebook', 'student_card', 'resume', 'motivation_letter', 'other_work_document'];
46
+ /**
47
+ * @type {Array<HealthLabels>}
48
+ */
49
+
50
+ var healthLabels = ['health_certificate', 'health_book', 'national_health_insurance_card', 'health_insurance_card', 'prescription', 'health_invoice'];
51
+ /**
52
+ * @type {Array<HomeLabels>}
53
+ */
54
+
55
+ var homeLabels = ['phone_invoice', 'isp_invoice', 'telecom_invoice', 'energy_invoice', 'water_invoice', 'house_sale_agreeement', 'building_permit', 'technical_diagnostic_record', 'lease', 'rent_receipt', 'house_insurance', 'work_quote', 'work_invoice', 'other_house_document'];
56
+ /**
57
+ * @type {Array<TransportLabels>}
58
+ */
59
+
60
+ var transportLabels = ['driver_license', 'vehicle_registration', 'car_insurance', 'mechanic_invoice', 'transport_invoice', 'other_transport_document'];
61
+ /**
62
+ * @type {Array<FinanceLabels>}
63
+ */
64
+
65
+ var financeLabels = ['tax_return', 'tax_notice', 'tax_timetable', 'receipt', 'other_tax_document', 'bank_details', 'bank_statement', 'loan_agreement', 'other_bank_document'];
66
+ /**
67
+ * @type {Array<InvoiceLabels>}
68
+ */
69
+
70
+ var invoiceLabels = ['phone_invoice', 'isp_invoice', 'telecom_invoice', 'energy_invoice', 'water_invoice', 'appliance_invoice', 'web_service_invoice', 'restaurant_invoice', 'work_invoice', 'transport_invoice', 'health_invoice', 'other_invoice'];
71
+ /**
72
+ * @type {ThemesList}
73
+ */
74
+
75
+ var themesList = [{
76
+ id: 'theme1',
77
+ label: 'identity',
78
+ icon: 'people',
79
+ items: buildItemsByLabel(identityLabels),
80
+ defaultItems: ['birth_certificate']
81
+ }, {
82
+ id: 'theme2',
83
+ label: 'family',
84
+ icon: 'team',
85
+ items: buildItemsByLabel(familyLabels),
86
+ defaultItems: ['family_record_book']
87
+ }, {
88
+ id: 'theme3',
89
+ label: 'work_study',
90
+ icon: 'company',
91
+ items: buildItemsByLabel(workStudyLabels)
92
+ }, {
93
+ id: 'theme4',
94
+ label: 'health',
95
+ icon: 'heart',
96
+ items: buildItemsByLabel(healthLabels)
97
+ }, {
98
+ id: 'theme5',
99
+ label: 'home',
100
+ icon: 'home',
101
+ items: buildItemsByLabel(homeLabels)
102
+ }, {
103
+ id: 'theme6',
104
+ label: 'transport',
105
+ icon: 'car',
106
+ items: buildItemsByLabel(transportLabels),
107
+ defaultItems: ['driver_license']
108
+ }, {
109
+ id: 'theme7',
110
+ label: 'finance',
111
+ icon: 'bank',
112
+ items: buildItemsByLabel(financeLabels)
113
+ }, {
114
+ id: 'theme8',
115
+ label: 'invoice',
116
+ icon: 'bill',
117
+ items: buildItemsByLabel(invoiceLabels)
118
+ }];
119
+ exports.themesList = themesList;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getThemeByItem = void 0;
7
+
8
+ var _types = require("../../types");
9
+
10
+ var _documentTypeData = require("./documentTypeData");
11
+
12
+ /**
13
+ * @param {QualificationAttributes} item - Qualification item
14
+ * @returns {Theme|undefined}
15
+ */
16
+ var findDefaultItemTheme = function findDefaultItemTheme(item) {
17
+ return _documentTypeData.themesList.find(function (theme) {
18
+ return theme.defaultItems && theme.defaultItems.includes(item.label);
19
+ });
20
+ };
21
+ /**
22
+ * @param {QualificationAttributes} item - Qualification item
23
+ * @returns {Theme|undefined}
24
+ */
25
+
26
+
27
+ var getThemeByItem = function getThemeByItem(item) {
28
+ var defaultTheme = findDefaultItemTheme(item);
29
+
30
+ if (defaultTheme) {
31
+ return defaultTheme;
32
+ }
33
+
34
+ return _documentTypeData.themesList.find(function (theme) {
35
+ return theme.items.some(function (it) {
36
+ return it.label === item.label;
37
+ });
38
+ });
39
+ };
40
+
41
+ exports.getThemeByItem = getThemeByItem;
@@ -0,0 +1,28 @@
1
+ import { getThemeByItem } from './documentTypeDataHelpers'
2
+
3
+ describe('DocumentTypeDataHelpers', () => {
4
+ it('should test getThemeByItem and return defaultTheme', () => {
5
+ const item = {
6
+ label: 'family_record_book',
7
+ purpose: 'attestation',
8
+ sourceCategory: 'gov',
9
+ sourceSubCategory: 'civil_registration',
10
+ subjects: ['family'],
11
+ defaultTheme: 'theme2'
12
+ }
13
+ const theme = getThemeByItem(item)
14
+ expect(theme.id).toBe('theme2')
15
+ })
16
+
17
+ it('should test getThemeByItem and return the theme if no defaultTheme', () => {
18
+ const item = {
19
+ label: 'residence_permit',
20
+ purpose: 'attestation',
21
+ sourceCategory: 'gov',
22
+ sourceSubCategory: 'immigration',
23
+ subjects: ['permit', 'identity']
24
+ }
25
+ const theme = getThemeByItem(item)
26
+ expect(theme.id).toBe('theme1')
27
+ })
28
+ })
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.helpers = exports.themes = exports.locales = exports.default = void 0;
9
+
10
+ var qualification = _interopRequireWildcard(require("./qualification"));
11
+
12
+ var locales = _interopRequireWildcard(require("./locales"));
13
+
14
+ exports.locales = locales;
15
+
16
+ var themes = _interopRequireWildcard(require("./documentTypeData"));
17
+
18
+ exports.themes = themes;
19
+
20
+ var helpers = _interopRequireWildcard(require("./documentTypeDataHelpers"));
21
+
22
+ exports.helpers = helpers;
23
+ var _default = qualification;
24
+ exports.default = _default;
@@ -0,0 +1,107 @@
1
+ {
2
+ "Scan": {
3
+ "scan_a_doc": "Scan a doc",
4
+ "save_doc": "Save the doc",
5
+ "filename": "Filename",
6
+ "save": "Save",
7
+ "cancel": "Cancel",
8
+ "qualify": "Describe",
9
+ "apply": "Apply",
10
+ "error": {
11
+ "offline": "You are currently offline and you can't use this functionality. Please, try again later.",
12
+ "uploading": "You are already uploading a file. Please wait until the end of this upload and try again.",
13
+ "generic": "Something went wrong. Please try again."
14
+ },
15
+ "successful": {
16
+ "qualified_ok": "You just have successfully described your file! "
17
+ },
18
+
19
+ "items": {
20
+ "identity": "Identity",
21
+ "family": "Family",
22
+ "work_study": "Work",
23
+ "health": "Health",
24
+ "home": "Home",
25
+ "transport": "Transport",
26
+ "invoice": "Invoice",
27
+ "others": "Others",
28
+ "identity_photo": "Identity photo",
29
+ "national_id_card": "ID card",
30
+ "passport": "Passeport",
31
+ "residence_permit": "Residence permit",
32
+ "family_record_book": "Family record book",
33
+ "birth_certificate": "Birth certificate",
34
+ "driver_license": "Driving license",
35
+ "other_identity_document": "Other identity",
36
+ "wedding": "Wedding contract",
37
+ "pacs": "Civil union",
38
+ "divorce": "Divorce",
39
+ "large_family_card": " Large Family Card",
40
+ "caf": "Social benefit",
41
+ "other_family_document": "Other family document",
42
+ "diploma": "Diploma",
43
+ "work_contract": "Work contract",
44
+ "pay_sheet": "Pay sheet",
45
+ "unemployment_benefit": "Unemployment benefit",
46
+ "pension": "Pension",
47
+ "other_revenue": "Other revenues",
48
+ "gradebook": "Gradebook",
49
+ "student_card": "Student card",
50
+ "resume": "Resume",
51
+ "motivation_letter": "Motivation letter",
52
+ "other_work_document": "Other work document",
53
+ "health_book": "Health book",
54
+ "health_certificate": "Health/Vaccination certificate",
55
+ "national_health_insurance_card": "National insurance card",
56
+ "health_insurance_card": "Insurance card",
57
+ "prescription": "Prescription",
58
+ "health_invoice": "Health invoice",
59
+ "other_health_document": "Other health document",
60
+ "vehicle_registration": "Vehicle registration",
61
+ "car_insurance": "Car insurance certificate",
62
+ "mechanic_invoice": "Repair bill",
63
+ "transport_invoice": "Transport invoice",
64
+ "other_transport_document": "Other transport document",
65
+ "phone_invoice": "Phone invoice",
66
+ "isp_invoice": "ISP invoice",
67
+ "telecom_invoice": "Telecom invoice",
68
+ "energy_invoice": "Energy invoice",
69
+ "water_invoice": "Water invoice",
70
+ "web_service_invoice": "Web service invoice",
71
+ "appliance_invoice": "Appliance invoice",
72
+ "restaurant_invoice": "Restaurant invoice",
73
+ "house_sale_agreeement": "House sale agreement",
74
+ "building_permit": "Building permit",
75
+ "technical_diagnostic_record": "Technical diagnostic record",
76
+ "lease": "Lease",
77
+ "house_insurance": "Home insurance",
78
+ "rent_receipt": "Rent receipt",
79
+ "work_quote": "Work quote",
80
+ "work_invoice": "Work invoice",
81
+ "other_house_document": "Other house document",
82
+ "tax_return": "Tax return",
83
+ "tax_notice": "Tax notice",
84
+ "tax_timetable": "Payment Plans Installment Agreements",
85
+ "receipt": "Receipt",
86
+ "other_tax_document": "Other tax document",
87
+ "bank_details": "IBAN",
88
+ "bank_statement": "Bank statement",
89
+ "loan_agreement": "Loan agreement",
90
+ "other_bank_document": "Other banking document",
91
+ "invoices": "Invoices",
92
+ "other_invoice": "Other invoice"
93
+ },
94
+ "themes": {
95
+ "identity": "Identity",
96
+ "family": "Family",
97
+ "work_study": "Work",
98
+ "health": "Health",
99
+ "home": "Home",
100
+ "transport": "Transport",
101
+ "invoice": "Invoice",
102
+ "others": "Others",
103
+ "undefined": "Undefined",
104
+ "finance": "Finance"
105
+ }
106
+ }
107
+ }
@@ -0,0 +1,107 @@
1
+ {
2
+ "Scan": {
3
+ "scan_a_doc": "Numériser un doc",
4
+ "save_doc": "Enregistrer le document",
5
+ "filename": "Nom du fichier",
6
+ "save": "Sauvegarder",
7
+ "cancel": "Annuler",
8
+ "qualify": "Qualifier",
9
+ "apply": "Appliquer",
10
+ "error": {
11
+ "offline": "Vous êtes actuellement déconnecté, vous ne pouvez donc pas utiliser cette fonctionnalité. Connectez-vous à internet et recommencez. ",
12
+ "uploading": "Vous avez déjà un fichier en cours de téléchargement. Attendez la fin et recommencez.",
13
+ "generic": "Un problème est survenu. Veuillez réessayer. "
14
+ },
15
+ "successful": {
16
+ "qualified_ok": "Vous venez de qualifier votre fichier avec succès !"
17
+ },
18
+
19
+ "items": {
20
+ "identity": "Identité",
21
+ "family": "Famille",
22
+ "work_study": "Travail",
23
+ "health": "Santé",
24
+ "home": "Logement",
25
+ "transport": "Transport",
26
+ "invoice": "Factures",
27
+ "others": "Autres",
28
+ "identity_photo": "Photo d'identité",
29
+ "national_id_card": "Carte d'identité",
30
+ "passport": "Passeport",
31
+ "residence_permit": "Titre de séjour",
32
+ "family_record_book": "Livret de famille",
33
+ "birth_certificate": "Certificat de naissance",
34
+ "driver_license": "Permis",
35
+ "other_identity_document": "Autre identité",
36
+ "wedding": "Contrat de mariage",
37
+ "pacs": "Attestation de PACS",
38
+ "divorce": "Attestation de divorce",
39
+ "large_family_card": "Carte famille nombreuse",
40
+ "caf": "CAF",
41
+ "other_family_document": "Autre document de famille",
42
+ "diploma": "Diplôme",
43
+ "work_contract": "Contrat de travail",
44
+ "pay_sheet": "Fiche de paie",
45
+ "unemployment_benefit": "Allocations chômage",
46
+ "pension": "Retraite",
47
+ "other_revenue": "Autres revenues",
48
+ "gradebook": "Bulletin de notes",
49
+ "student_card": "Carte d'étudiant",
50
+ "resume": "CV",
51
+ "motivation_letter": "Lettre de motivation",
52
+ "other_work_document": "Autre document de travail",
53
+ "health_book": "Carnet de santé",
54
+ "health_certificate": "Certificat de santé/vaccination",
55
+ "national_health_insurance_card": "Carte vitale",
56
+ "health_insurance_card": "Carte de mutuelle",
57
+ "prescription": "Ordonnance",
58
+ "health_invoice": "Facture médicale",
59
+ "other_health_document": "Autre document de santé",
60
+ "vehicle_registration": "Carte grise",
61
+ "car_insurance": "Attestation d'assurance auto",
62
+ "mechanic_invoice": "Facture de réparation",
63
+ "transport_invoice": "Facture de transport",
64
+ "other_transport_document": "Autre document de transport",
65
+ "phone_invoice": "Facture de téléphone",
66
+ "isp_invoice": "Facture d'internet",
67
+ "telecom_invoice": "Facture de télécom",
68
+ "energy_invoice": "Facture d'électricité",
69
+ "water_invoice": "Facture d'eau",
70
+ "web_service_invoice": "Facture de service web",
71
+ "appliance_invoice": "Facture d'électroménager",
72
+ "restaurant_invoice": "Facture de restaurant",
73
+ "house_sale_agreeement": "Compromis de vente",
74
+ "building_permit": "Permis de construire",
75
+ "technical_diagnostic_record": "Dossier de diagnostic technique",
76
+ "lease": "Bail",
77
+ "house_insurance": "Assurance logement",
78
+ "rent_receipt": "Quittance de loyer",
79
+ "work_quote": "Devis de travaux",
80
+ "work_invoice": "Facture de travaux",
81
+ "other_house_document": "Autre document de logement",
82
+ "tax_return": "Déclaration d'impôt",
83
+ "tax_notice": "Avis d'imposition",
84
+ "tax_timetable": "Echéancier d'imposition",
85
+ "receipt": "Accusé de réception",
86
+ "other_tax_document": "Autre document d'impôt",
87
+ "bank_details": "IBAN",
88
+ "bank_statement": "Relevé de compte",
89
+ "loan_agreement": "Contrat de prêt",
90
+ "other_bank_document": "Autre document bancaire",
91
+ "invoices": "Factures",
92
+ "other_invoice": "Autre facture"
93
+ },
94
+ "themes": {
95
+ "identity": "Identité",
96
+ "family": "Famille",
97
+ "work_study": "Travail",
98
+ "health": "Santé",
99
+ "home": "Logement",
100
+ "transport": "Transport",
101
+ "invoice": "Factures",
102
+ "others": "Autres",
103
+ "undefined": "Indéfini",
104
+ "finance": "Finances"
105
+ }
106
+ }
107
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.getBoundT = void 0;
9
+
10
+ var _nodePolyglot = _interopRequireDefault(require("node-polyglot"));
11
+
12
+ var polyglots = {};
13
+ var langs = ['fr', 'en'];
14
+
15
+ for (var _i = 0, _langs = langs; _i < _langs.length; _i++) {
16
+ var lang = _langs[_i];
17
+ var locales = {};
18
+
19
+ try {
20
+ locales = require("./".concat(lang, ".json"));
21
+ } catch (e) {// eslint-disable-line no-empty-block
22
+ }
23
+
24
+ var polyglot = new _nodePolyglot.default();
25
+ polyglot.extend(locales);
26
+ polyglots[lang] = polyglot;
27
+ }
28
+ /**
29
+ *
30
+ * @param {string} lang - fr, en, etc
31
+ * @returns {(key: string) => string}
32
+ */
33
+
34
+
35
+ var getBoundT = function getBoundT(lang) {
36
+ var polyglot = polyglots[lang] || polyglots['en'];
37
+ return polyglot.t.bind(polyglot);
38
+ };
39
+
40
+ exports.getBoundT = getBoundT;
@@ -17,7 +17,7 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
17
17
 
18
18
  var _lodash = require("lodash");
19
19
 
20
- var qualificationModel = _interopRequireWildcard(require("../assets/qualifications.json"));
20
+ var qualificationModel = _interopRequireWildcard(require("../../assets/qualifications.json"));
21
21
 
22
22
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
23
23
 
@@ -1,5 +1,9 @@
1
- import { Qualification, setQualification, getQualification } from './document'
2
- import * as qualificationModel from '../assets/qualifications.json'
1
+ import {
2
+ Qualification,
3
+ setQualification,
4
+ getQualification
5
+ } from './qualification'
6
+ import * as qualificationModel from '../../assets/qualifications.json'
3
7
 
4
8
  describe('document qualification', () => {
5
9
  beforeEach(() => {
@@ -24,7 +24,7 @@ var _has = _interopRequireDefault(require("lodash/has"));
24
24
 
25
25
  var _trimEnd = _interopRequireDefault(require("lodash/trimEnd"));
26
26
 
27
- var _document = require("./document");
27
+ var _qualification = require("./document/qualification");
28
28
 
29
29
  var _dsl = require("../queries/dsl");
30
30
 
@@ -320,7 +320,7 @@ var saveFileQualification = /*#__PURE__*/function () {
320
320
  while (1) {
321
321
  switch (_context.prev = _context.next) {
322
322
  case 0:
323
- qualifiedFile = (0, _document.setQualification)(file, qualification);
323
+ qualifiedFile = (0, _qualification.setQualification)(file, qualification);
324
324
  return _context.abrupt("return", client.collection(_const.DOCTYPE_FILES).updateMetadataAttribute(file._id, qualifiedFile.metadata));
325
325
 
326
326
  case 2:
@@ -1,5 +1,5 @@
1
1
  import * as fileModel from './file'
2
- import { Qualification } from './document'
2
+ import { Qualification } from './document/qualification'
3
3
  import { QueryDefinition } from '../queries/dsl'
4
4
  const CozyClient = require('cozy-client/dist/CozyClient').default
5
5
  const CozyStackClient = require('cozy-stack-client').default
@@ -47,7 +47,7 @@ var contact = _interopRequireWildcard(require("./contact"));
47
47
 
48
48
  exports.contact = contact;
49
49
 
50
- var document = _interopRequireWildcard(require("./document"));
50
+ var document = _interopRequireWildcard(require("./document/index"));
51
51
 
52
52
  exports.document = document;
53
53
 
@@ -120,13 +120,13 @@ var QueryDefinition = /*#__PURE__*/function () {
120
120
  }
121
121
 
122
122
  if (_sort.length > fieldsToIndex.length) {
123
- console.warn('You should not sort on non-indexed fields');
123
+ console.warn("You should not sort on non-indexed fields.\n\n Sort: ".concat(JSON.stringify(_sort), "\n\n Indexed fields: ").concat(fieldsToIndex));
124
124
  return;
125
125
  }
126
126
 
127
127
  for (var i = 0; i < _sort.length; i++) {
128
128
  if (Object.keys(_sort[i])[0] !== fieldsToIndex[i]) {
129
- console.warn('The sort order should be the same than the indexed fields');
129
+ console.warn("The sort order should be the same than the indexed fields.\n\n Sort: ".concat(JSON.stringify(_sort), "\n\n Indexed fields: ").concat(fieldsToIndex, "\n"));
130
130
  return;
131
131
  }
132
132
  }
@@ -146,13 +146,13 @@ var QueryDefinition = /*#__PURE__*/function () {
146
146
  var hasExistsFalse = (0, _findKey.default)(selector, ['$exists', false]);
147
147
 
148
148
  if (hasExistsFalse) {
149
- console.warn('The "$exists: false" predicate should be defined as a partial index for better performance');
149
+ console.warn("The \"$exists: false\" predicate should be defined as a partial index for better performance.\n\n Selector: ".concat(selector));
150
150
  }
151
151
 
152
152
  var hasNe = (0, _findKey.default)(selector, '$ne');
153
153
 
154
154
  if (hasNe) {
155
- console.info('The use of the $ne operator is more efficient with a partial index.');
155
+ console.info("The use of the $ne operator is more efficient with a partial index.\n\n Selector: ".concat(selector));
156
156
  }
157
157
  }
158
158
  /**
package/dist/types.js CHANGED
@@ -230,5 +230,47 @@ var _dsl = require("./queries/dsl");
230
230
  * @property {string?} error?
231
231
  * @property {string?} reason?
232
232
  */
233
+
234
+ /**
235
+ * @typedef {object} Theme
236
+ * @property {string} id
237
+ * @property {string} label
238
+ * @property {string} icon
239
+ * @property {Array<QualificationAttributes>} items
240
+ * @property {Array<string>} [defaultItems]
241
+ *
242
+ * @typedef {Array<Theme>} ThemesList
243
+ *
244
+ * @typedef {'identity'|'family'|'work_study'|'health'|'home'|'transport'|'finance'|'invoice'} ThemesLabels
245
+ */
246
+
247
+ /**
248
+ * @typedef {object} QualificationAttributes
249
+ * @property {string} label
250
+ * @property {string} [purpose]
251
+ * @property {string} [sourceCategory]
252
+ * @property {string} [sourceSubCategory]
253
+ * @property {Array<string>} [subjects]
254
+ */
255
+
256
+ /**
257
+ * @typedef {'identity_photo'|'national_id_card'|'passport'|'residence_permit'|'family_record_book'|'birth_certificate'|'driver_license'|'other_identity_document'} IdentityLabel
258
+ *
259
+ * @typedef {'family_record_book'|'birth_certificate'|'wedding'|'pacs'|'divorce'|'large_family_card'|'caf'|'other_family_document'} FamilyLabel
260
+ *
261
+ * @typedef {'diploma'|'work_contract'|'pay_sheet'|'unemployment_benefit'|'pension'|'other_revenue'|'gradebook'|'student_card'|'resume'|'motivation_letter'|'other_work_document'} WorkStudyLabels
262
+ *
263
+ * @typedef {'health_certificate'|'health_book'|'national_health_insurance_card'|'health_insurance_card'|'prescription'|'health_invoice'} HealthLabels
264
+ *
265
+ * @typedef {'phone_invoice'|'isp_invoice'|'telecom_invoice'|'energy_invoice'|'water_invoice'|'house_sale_agreeement'|'building_permit'|'technical_diagnostic_record'|'lease'|'rent_receipt'|'house_insurance'|'work_quote'|'work_invoice'|'other_house_document'} HomeLabels
266
+ *
267
+ * @typedef {'driver_license'|'vehicle_registration'|'car_insurance'|'mechanic_invoice'|'transport_invoice'|'other_transport_document'} TransportLabels
268
+ *
269
+ * @typedef {'tax_return'|'tax_notice'|'tax_timetable'|'receipt'|'other_tax_document'|'bank_details'|'bank_statement'|'loan_agreement'|'other_bank_document'} FinanceLabels
270
+ *
271
+ * @typedef {'phone_invoice'|'isp_invoice'|'telecom_invoice'|'energy_invoice'|'water_invoice'|'appliance_invoice'|'web_service_invoice'|'restaurant_invoice'|'work_invoice'|'transport_invoice'|'health_invoice'|'other_invoice'} InvoiceLabels
272
+ *
273
+ * @typedef {IdentityLabel|FamilyLabel|WorkStudyLabels|HealthLabels|HomeLabels|TransportLabels|FinanceLabels|InvoiceLabels} ItemsLabels
274
+ */
233
275
  var _default = {};
234
276
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cozy-client",
3
- "version": "27.0.0",
3
+ "version": "27.3.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.node.js",
6
6
  "browser": "dist/index.js",
@@ -21,11 +21,12 @@
21
21
  "cozy-device-helper": "^1.12.0",
22
22
  "cozy-flags": "2.7.1",
23
23
  "cozy-logger": "^1.6.0",
24
- "cozy-stack-client": "^27.0.0",
24
+ "cozy-stack-client": "^27.1.0",
25
25
  "json-stable-stringify": "^1.0.1",
26
26
  "lodash": "^4.17.13",
27
27
  "microee": "^0.0.6",
28
28
  "node-fetch": "^2.6.1",
29
+ "node-polyglot": "2.4.2",
29
30
  "open": "7.4.2",
30
31
  "prop-types": "^15.6.2",
31
32
  "react-redux": "^7.2.0",
@@ -68,5 +69,5 @@
68
69
  "react-native-inappbrowser-reborn": "^3.5.1"
69
70
  },
70
71
  "sideEffects": false,
71
- "gitHead": "eb3e306e97d0447509e8ac6a3f1012c2e1070a04"
72
+ "gitHead": "a425c10bf4937c815beee378cfeca7a13ce728c2"
72
73
  }
@@ -61,19 +61,21 @@ declare class CozyClient {
61
61
  * a client with a cookie-based instance of cozy-client-js.
62
62
  *
63
63
  * @param {OldCozyClient} oldClient - An instance of the deprecated cozy-client
64
+ * @param {object} options - CozyStackClient options
64
65
  * @returns {CozyClient}
65
66
  */
66
- static fromOldClient(oldClient: OldCozyClient, options: any): CozyClient;
67
+ static fromOldClient(oldClient: OldCozyClient, options: object): CozyClient;
67
68
  /**
68
69
  * To help with the transition from cozy-client-js to cozy-client, it is possible to instantiate
69
70
  * a client with an OAuth-based instance of cozy-client-js.
70
71
  *
71
72
  * Warning: unlike other instantiators, this one needs to be awaited.
72
73
  *
73
- * @param {OldCozyClient} oldClient - An instance of the deprecated cozy-client
74
+ * @param {OldCozyClient} oldClient - An OAuth instance of the deprecated cozy-client
75
+ * @param {object} options - CozyStackClient options
74
76
  * @returns {Promise<CozyClient>} An instance of a client, configured from the old client
75
77
  */
76
- static fromOldOAuthClient(oldClient: OldCozyClient, options: any): Promise<CozyClient>;
78
+ static fromOldOAuthClient(oldClient: OldCozyClient, options: object): Promise<CozyClient>;
77
79
  /**
78
80
  * In konnector/service context, CozyClient can be instantiated from
79
81
  * environment variables
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @type {ThemesList}
3
+ */
4
+ export const themesList: ThemesList;
5
+ import { ThemesList } from "../../types";
@@ -0,0 +1,3 @@
1
+ export function getThemeByItem(item: QualificationAttributes): Theme | undefined;
2
+ import { QualificationAttributes } from "../../types";
3
+ import { Theme } from "../../types";
@@ -0,0 +1,6 @@
1
+ export default qualification;
2
+ import * as qualification from "./qualification";
3
+ import * as locales from "./locales";
4
+ import * as themes from "./documentTypeData";
5
+ import * as helpers from "./documentTypeDataHelpers";
6
+ export { locales, themes, helpers };
@@ -0,0 +1,6 @@
1
+ /**
2
+ *
3
+ * @param {string} lang - fr, en, etc
4
+ * @returns {(key: string) => string}
5
+ */
6
+ export function getBoundT(lang: string): (key: string) => string;
package/types/types.d.ts CHANGED
@@ -272,4 +272,29 @@ export type CouchDBBulkResult = {
272
272
  */
273
273
  reason: string | null;
274
274
  };
275
+ export type Theme = {
276
+ id: string;
277
+ label: string;
278
+ icon: string;
279
+ items: Array<QualificationAttributes>;
280
+ defaultItems?: Array<string>;
281
+ };
282
+ export type ThemesList = Theme[];
283
+ export type ThemesLabels = "transport" | "identity" | "family" | "work_study" | "health" | "home" | "finance" | "invoice";
284
+ export type QualificationAttributes = {
285
+ label: string;
286
+ purpose?: string;
287
+ sourceCategory?: string;
288
+ sourceSubCategory?: string;
289
+ subjects?: Array<string>;
290
+ };
291
+ export type IdentityLabel = "identity_photo" | "national_id_card" | "passport" | "residence_permit" | "family_record_book" | "birth_certificate" | "driver_license" | "other_identity_document";
292
+ export type FamilyLabel = "family_record_book" | "birth_certificate" | "wedding" | "pacs" | "divorce" | "large_family_card" | "caf" | "other_family_document";
293
+ export type WorkStudyLabels = "resume" | "diploma" | "work_contract" | "pay_sheet" | "unemployment_benefit" | "pension" | "other_revenue" | "gradebook" | "student_card" | "motivation_letter" | "other_work_document";
294
+ export type HealthLabels = "health_certificate" | "health_book" | "national_health_insurance_card" | "health_insurance_card" | "prescription" | "health_invoice";
295
+ export type HomeLabels = "phone_invoice" | "isp_invoice" | "telecom_invoice" | "energy_invoice" | "water_invoice" | "house_sale_agreeement" | "building_permit" | "technical_diagnostic_record" | "lease" | "rent_receipt" | "house_insurance" | "work_quote" | "work_invoice" | "other_house_document";
296
+ export type TransportLabels = "driver_license" | "vehicle_registration" | "car_insurance" | "mechanic_invoice" | "transport_invoice" | "other_transport_document";
297
+ export type FinanceLabels = "tax_return" | "tax_notice" | "tax_timetable" | "receipt" | "other_tax_document" | "bank_details" | "bank_statement" | "loan_agreement" | "other_bank_document";
298
+ export type InvoiceLabels = "health_invoice" | "phone_invoice" | "isp_invoice" | "telecom_invoice" | "energy_invoice" | "water_invoice" | "work_invoice" | "transport_invoice" | "appliance_invoice" | "web_service_invoice" | "restaurant_invoice" | "other_invoice";
299
+ export type ItemsLabels = "resume" | "identity_photo" | "national_id_card" | "passport" | "residence_permit" | "family_record_book" | "birth_certificate" | "driver_license" | "other_identity_document" | "wedding" | "pacs" | "divorce" | "large_family_card" | "caf" | "other_family_document" | "diploma" | "work_contract" | "pay_sheet" | "unemployment_benefit" | "pension" | "other_revenue" | "gradebook" | "student_card" | "motivation_letter" | "other_work_document" | "health_certificate" | "health_book" | "national_health_insurance_card" | "health_insurance_card" | "prescription" | "health_invoice" | "phone_invoice" | "isp_invoice" | "telecom_invoice" | "energy_invoice" | "water_invoice" | "house_sale_agreeement" | "building_permit" | "technical_diagnostic_record" | "lease" | "rent_receipt" | "house_insurance" | "work_quote" | "work_invoice" | "other_house_document" | "vehicle_registration" | "car_insurance" | "mechanic_invoice" | "transport_invoice" | "other_transport_document" | "tax_return" | "tax_notice" | "tax_timetable" | "receipt" | "other_tax_document" | "bank_details" | "bank_statement" | "loan_agreement" | "other_bank_document" | "appliance_invoice" | "web_service_invoice" | "restaurant_invoice" | "other_invoice";
275
300
  import { QueryDefinition } from "./queries/dsl";