cozy-client 27.2.0 → 27.4.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 +44 -0
- package/dist/CozyClient.js +41 -4
- package/dist/CozyClient.spec.js +48 -1
- package/dist/authentication/mobile.native.js +16 -1
- package/dist/hooks/useQuery.js +9 -6
- package/dist/hooks/useQuery.spec.jsx +33 -2
- package/dist/models/document/documentTypeData.js +119 -0
- package/dist/models/document/documentTypeDataHelpers.js +41 -0
- package/dist/models/document/documentTypeDataHelpers.spec.jsx +28 -0
- package/dist/models/document/index.js +40 -0
- package/dist/models/document/locales/en.json +107 -0
- package/dist/models/document/locales/fr.json +107 -0
- package/dist/models/document/locales/index.js +40 -0
- package/dist/models/{document.js → document/qualification.js} +1 -1
- package/dist/models/{document.spec.js → document/qualification.spec.js} +6 -2
- package/dist/models/file.js +2 -2
- package/dist/models/file.spec.js +1 -1
- package/dist/types.js +44 -1
- package/package.json +3 -2
- package/types/CozyClient.d.ts +15 -1
- package/types/hooks/useQuery.d.ts +36 -12
- package/types/models/document/documentTypeData.d.ts +5 -0
- package/types/models/document/documentTypeDataHelpers.d.ts +3 -0
- package/types/models/document/index.d.ts +7 -0
- package/types/models/document/locales/index.d.ts +6 -0
- package/types/models/{document.d.ts → document/qualification.d.ts} +0 -0
- package/types/types.d.ts +29 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,50 @@
|
|
|
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.4.0](https://github.com/cozy/cozy-client/compare/v27.3.2...v27.4.0) (2021-11-25)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* onError Callback ([c5f65d3](https://github.com/cozy/cozy-client/commit/c5f65d33e0ab29a22b409365151173a3b7645b56))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [27.3.2](https://github.com/cozy/cozy-client/compare/v27.3.1...v27.3.2) (2021-11-17)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* Login on RN iOS ([4b85b47](https://github.com/cozy/cozy-client/commit/4b85b475bf0c5b32f94a06e524fa7f0f5011f90e))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## [27.3.1](https://github.com/cozy/cozy-client/compare/v27.3.0...v27.3.1) (2021-11-16)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
|
|
33
|
+
* Export Qualification ([3472bce](https://github.com/cozy/cozy-client/commit/3472bcec6ab3e19353a290e79189bf09c34b38b8))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# [27.3.0](https://github.com/cozy/cozy-client/compare/v27.2.0...v27.3.0) (2021-11-16)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Features
|
|
43
|
+
|
|
44
|
+
* Add node-polyglot package ([964b05d](https://github.com/cozy/cozy-client/commit/964b05d031c233f73640218f83469b2791a73fde))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
6
50
|
# [27.2.0](https://github.com/cozy/cozy-client/compare/v27.1.0...v27.2.0) (2021-11-15)
|
|
7
51
|
|
|
8
52
|
|
package/dist/CozyClient.js
CHANGED
|
@@ -128,7 +128,7 @@ var DOC_UPDATE = 'update';
|
|
|
128
128
|
* @property {boolean} [autoHydrate]
|
|
129
129
|
* @property {object} [oauth]
|
|
130
130
|
* @property {Function} [onTokenRefresh]
|
|
131
|
-
* @property {Function} [
|
|
131
|
+
* @property {Function} [onError] - Default callback if a query is errored
|
|
132
132
|
* @property {Link} [link] - Backward compatibility
|
|
133
133
|
* @property {Array<Link>} [links] - List of links
|
|
134
134
|
* @property {object} [schema] - Schema description for each doctypes
|
|
@@ -1276,10 +1276,32 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
1276
1276
|
case 24:
|
|
1277
1277
|
_context8.prev = 24;
|
|
1278
1278
|
_context8.t0 = _context8["catch"](15);
|
|
1279
|
-
this.dispatch((0, _store.receiveQueryError)(queryId, _context8.t0));
|
|
1279
|
+
this.dispatch((0, _store.receiveQueryError)(queryId, _context8.t0)); // specific onError
|
|
1280
|
+
|
|
1281
|
+
if (!options.onError) {
|
|
1282
|
+
_context8.next = 31;
|
|
1283
|
+
break;
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
options.onError(_context8.t0); // defaulted onError
|
|
1287
|
+
|
|
1288
|
+
_context8.next = 36;
|
|
1289
|
+
break;
|
|
1290
|
+
|
|
1291
|
+
case 31:
|
|
1292
|
+
if (!this.options.onError) {
|
|
1293
|
+
_context8.next = 35;
|
|
1294
|
+
break;
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
this.options.onError(_context8.t0);
|
|
1298
|
+
_context8.next = 36;
|
|
1299
|
+
break;
|
|
1300
|
+
|
|
1301
|
+
case 35:
|
|
1280
1302
|
throw _context8.t0;
|
|
1281
1303
|
|
|
1282
|
-
case
|
|
1304
|
+
case 36:
|
|
1283
1305
|
case "end":
|
|
1284
1306
|
return _context8.stop();
|
|
1285
1307
|
}
|
|
@@ -2256,6 +2278,21 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2256
2278
|
}));
|
|
2257
2279
|
});
|
|
2258
2280
|
}
|
|
2281
|
+
/**
|
|
2282
|
+
* At any time put an error function
|
|
2283
|
+
*
|
|
2284
|
+
* @param {Function} [onError] - Set a callback for queries which are errored
|
|
2285
|
+
*/
|
|
2286
|
+
|
|
2287
|
+
}, {
|
|
2288
|
+
key: "setOnError",
|
|
2289
|
+
value: function setOnError(onError) {
|
|
2290
|
+
if (this.options && this.options.onError) {
|
|
2291
|
+
throw new Error('On Error is already defined');
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
this.options.onError = onError;
|
|
2295
|
+
}
|
|
2259
2296
|
}, {
|
|
2260
2297
|
key: "toJSON",
|
|
2261
2298
|
value: function toJSON() {
|
|
@@ -2415,7 +2452,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2415
2452
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
2416
2453
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
2417
2454
|
|
|
2418
|
-
CozyClient.version = "27.
|
|
2455
|
+
CozyClient.version = "27.4.0";
|
|
2419
2456
|
|
|
2420
2457
|
_microee.default.mixin(CozyClient);
|
|
2421
2458
|
|
package/dist/CozyClient.spec.js
CHANGED
|
@@ -162,7 +162,6 @@ describe('CozyClient initialization', () => {
|
|
|
162
162
|
})
|
|
163
163
|
}
|
|
164
164
|
const client = await CozyClient.fromOldOAuthClient(oldClient)
|
|
165
|
-
console.log({ stackClient: client.stackClient })
|
|
166
165
|
expect(client.stackClient.uri).toBe(url)
|
|
167
166
|
expect(client.stackClient.oauthOptions.clientID).toBe(oauth.clientID)
|
|
168
167
|
expect(client.stackClient.token.accessToken).toBe(token.accessToken)
|
|
@@ -1402,6 +1401,54 @@ describe('CozyClient', () => {
|
|
|
1402
1401
|
receiveQueryResult('allTodos', fakeResponse)
|
|
1403
1402
|
)
|
|
1404
1403
|
})
|
|
1404
|
+
|
|
1405
|
+
const setupOnError = () => {
|
|
1406
|
+
const error = new TypeError('Failed to fetch')
|
|
1407
|
+
requestHandler.mockReturnValueOnce(Promise.reject(error))
|
|
1408
|
+
const onError = jest.fn().mockReturnValueOnce(() => true)
|
|
1409
|
+
return onError
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
it('should call onError callback when an error is thrown. Callback passed as argument', async () => {
|
|
1413
|
+
const onError = setupOnError()
|
|
1414
|
+
|
|
1415
|
+
await client.query(query, { as: 'allTodos', onError })
|
|
1416
|
+
expect(onError).toBeCalled()
|
|
1417
|
+
})
|
|
1418
|
+
|
|
1419
|
+
it('should call onError callback when an error is catched. It is passed during instantiation', async () => {
|
|
1420
|
+
const onError = setupOnError()
|
|
1421
|
+
const client = new CozyClient({ onError })
|
|
1422
|
+
|
|
1423
|
+
await client.query(query, { as: 'allTodos' })
|
|
1424
|
+
expect(onError).toBeCalled()
|
|
1425
|
+
})
|
|
1426
|
+
|
|
1427
|
+
it('should call onError callback when an error is catched. It is passed with setOnError', async () => {
|
|
1428
|
+
const onError = setupOnError()
|
|
1429
|
+
client.setOnError(onError)
|
|
1430
|
+
|
|
1431
|
+
await client.query(query, { as: 'allTodos' })
|
|
1432
|
+
expect(onError).toBeCalled()
|
|
1433
|
+
})
|
|
1434
|
+
|
|
1435
|
+
it('should throw an error when we call setOnError twice (or several times)', async () => {
|
|
1436
|
+
const client = new CozyClient({})
|
|
1437
|
+
const onError = () => true
|
|
1438
|
+
|
|
1439
|
+
const funcShouldThrow = () => client.setOnError(onError)
|
|
1440
|
+
expect(funcShouldThrow).not.toThrow()
|
|
1441
|
+
expect(funcShouldThrow).toThrow('On Error is already defined')
|
|
1442
|
+
})
|
|
1443
|
+
|
|
1444
|
+
it('should throw an error when there is no onError callback', async () => {
|
|
1445
|
+
const error = new TypeError('Failed to fetch')
|
|
1446
|
+
requestHandler.mockReturnValueOnce(Promise.reject(error))
|
|
1447
|
+
|
|
1448
|
+
await expect(client.query(query, { as: 'allTodos' })).rejects.toThrow(
|
|
1449
|
+
'Failed to fetch'
|
|
1450
|
+
)
|
|
1451
|
+
})
|
|
1405
1452
|
})
|
|
1406
1453
|
|
|
1407
1454
|
describe('queryAll', () => {
|
|
@@ -64,11 +64,26 @@ var authenticateWithReactNativeInAppBrowser = /*#__PURE__*/function () {
|
|
|
64
64
|
|
|
65
65
|
var linkListener = function linkListener(_ref2) {
|
|
66
66
|
var url = _ref2.url;
|
|
67
|
+
var sanitizedUrl = url;
|
|
67
68
|
var accessCode = /\?access_code=(.+)$/.test(url);
|
|
68
69
|
var state = /\?state=(.+)$/.test(url);
|
|
69
70
|
|
|
70
71
|
if (accessCode || state) {
|
|
71
|
-
|
|
72
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
73
|
+
// On iOS, the # added to the URL by the stack for security
|
|
74
|
+
// reason is encoded to %23. Because of this, URL().searchParams
|
|
75
|
+
// is not working as expected since %23 is added to the param
|
|
76
|
+
// instead of being ignored and assigned to the hash.
|
|
77
|
+
// Let's convert back %23 to # manually.
|
|
78
|
+
// I think the issue is related to Linking component but didn't
|
|
79
|
+
// find any issues on github about it. Need to make a simple
|
|
80
|
+
// reproduction case to create the issue.
|
|
81
|
+
if (url.endsWith('%23')) {
|
|
82
|
+
sanitizedUrl = url.replace(/%23$/, '#');
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
resolve(sanitizedUrl);
|
|
72
87
|
removeListener();
|
|
73
88
|
|
|
74
89
|
_reactNativeInappbrowserReborn.InAppBrowser.close();
|
package/dist/hooks/useQuery.js
CHANGED
|
@@ -25,6 +25,8 @@ var _types = require("../types");
|
|
|
25
25
|
|
|
26
26
|
var _context = require("../context");
|
|
27
27
|
|
|
28
|
+
var _dsl = require("../queries/dsl");
|
|
29
|
+
|
|
28
30
|
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; }
|
|
29
31
|
|
|
30
32
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -41,15 +43,16 @@ var generateFetchMoreQueryDefinition = function generateFetchMoreQueryDefinition
|
|
|
41
43
|
/**
|
|
42
44
|
* Fetches a queryDefinition and returns the queryState
|
|
43
45
|
*
|
|
44
|
-
* @param {
|
|
46
|
+
* @param {QueryDefinition} queryDefinition - Definition created with Q()
|
|
45
47
|
*
|
|
46
|
-
* @
|
|
47
|
-
* @
|
|
48
|
-
* @
|
|
49
|
-
* @
|
|
50
|
-
* @
|
|
48
|
+
* @typedef {object} UseQueryOptions
|
|
49
|
+
* @property {object} as - Name for the query [required]
|
|
50
|
+
* @property {boolean} enabled - If set to false, the query won't be executed
|
|
51
|
+
* @property {object} fetchPolicy - Fetch policy
|
|
52
|
+
* @property {object} singleDocData - If true, the "data" returned will be
|
|
51
53
|
* a single doc instead of an array for single doc queries. Defaults to false for backward
|
|
52
54
|
* compatibility but will be set to true in the future.
|
|
55
|
+
* @property {Function} onError - Callback if the query is errored
|
|
53
56
|
*
|
|
54
57
|
* @returns {UseQueryReturnValue}
|
|
55
58
|
*/
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import { renderHook } from '@testing-library/react-hooks'
|
|
2
2
|
|
|
3
|
+
import CozyClient from '../CozyClient'
|
|
4
|
+
import CozyLink from '../CozyLink'
|
|
3
5
|
import useQuery, { useQueries } from './useQuery'
|
|
4
6
|
import { Q } from '../queries/dsl'
|
|
5
7
|
|
|
6
8
|
import { setupClient, makeWrapper } from '../testing/utils'
|
|
7
9
|
import simpsonsFixture from '../testing/simpsons.json'
|
|
8
10
|
|
|
9
|
-
const setupQuery = ({
|
|
10
|
-
|
|
11
|
+
const setupQuery = ({
|
|
12
|
+
customClient,
|
|
13
|
+
queryDefinition,
|
|
14
|
+
queryOptions,
|
|
15
|
+
storeQueries
|
|
16
|
+
}) => {
|
|
17
|
+
const client = customClient || setupClient({ queries: storeQueries })
|
|
11
18
|
const hookResult = renderHook(() => useQuery(queryDefinition, queryOptions), {
|
|
12
19
|
wrapper: makeWrapper(client)
|
|
13
20
|
})
|
|
@@ -159,6 +166,30 @@ describe('use query', () => {
|
|
|
159
166
|
expect(lastCallArgs).toMatchObject({ skip: current.data.length })
|
|
160
167
|
expect(fetchMoreResult).toEqual({ data: null })
|
|
161
168
|
})
|
|
169
|
+
|
|
170
|
+
it('should call onError callback when an error is thrown. Callback passed as argument', async () => {
|
|
171
|
+
jest.spyOn(console, 'error').mockImplementation(() => null)
|
|
172
|
+
const requestHandler = jest.fn()
|
|
173
|
+
const client = new CozyClient({
|
|
174
|
+
links: [new CozyLink(requestHandler)]
|
|
175
|
+
})
|
|
176
|
+
const error = new TypeError('Failed to fetch')
|
|
177
|
+
requestHandler.mockReturnValue(Promise.reject(error))
|
|
178
|
+
const onError = jest.fn().mockReturnValue(() => true)
|
|
179
|
+
setupQuery({
|
|
180
|
+
customClient: client,
|
|
181
|
+
queryOptions: {
|
|
182
|
+
as: 'fake-query',
|
|
183
|
+
onError
|
|
184
|
+
},
|
|
185
|
+
queryDefinition: () => Q('io.cozy.todos')
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
// TODO find a better alternative
|
|
189
|
+
setTimeout(() => {
|
|
190
|
+
expect(onError).toBeCalled()
|
|
191
|
+
}, 100)
|
|
192
|
+
})
|
|
162
193
|
})
|
|
163
194
|
|
|
164
195
|
describe('use queries', () => {
|
|
@@ -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,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "Qualification", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _qualification.Qualification;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "setQualification", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function get() {
|
|
17
|
+
return _qualification.setQualification;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "getQualification", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function get() {
|
|
23
|
+
return _qualification.getQualification;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
exports.helpers = exports.themes = exports.locales = void 0;
|
|
27
|
+
|
|
28
|
+
var _qualification = require("./qualification");
|
|
29
|
+
|
|
30
|
+
var locales = _interopRequireWildcard(require("./locales"));
|
|
31
|
+
|
|
32
|
+
exports.locales = locales;
|
|
33
|
+
|
|
34
|
+
var themes = _interopRequireWildcard(require("./documentTypeData"));
|
|
35
|
+
|
|
36
|
+
exports.themes = themes;
|
|
37
|
+
|
|
38
|
+
var helpers = _interopRequireWildcard(require("./documentTypeDataHelpers"));
|
|
39
|
+
|
|
40
|
+
exports.helpers = helpers;
|
|
@@ -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("
|
|
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 {
|
|
2
|
-
|
|
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(() => {
|
package/dist/models/file.js
CHANGED
|
@@ -24,7 +24,7 @@ var _has = _interopRequireDefault(require("lodash/has"));
|
|
|
24
24
|
|
|
25
25
|
var _trimEnd = _interopRequireDefault(require("lodash/trimEnd"));
|
|
26
26
|
|
|
27
|
-
var
|
|
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,
|
|
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:
|
package/dist/models/file.spec.js
CHANGED
|
@@ -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
|
package/dist/types.js
CHANGED
|
@@ -85,7 +85,8 @@ var _dsl = require("./queries/dsl");
|
|
|
85
85
|
* @property {string} [as] - Name of the query
|
|
86
86
|
* @property {Function} [fetchPolicy] - Fetch policy to bypass fetching based on what's already inside the state. See "Fetch policies"
|
|
87
87
|
* @property {AutoUpdateOptions} [autoUpdate] - Options for the query auto update
|
|
88
|
-
* @property {string} [
|
|
88
|
+
* @property {string} [update] - Does not seem to be used
|
|
89
|
+
* @property {Function} [onError] - Callback when the query is errored
|
|
89
90
|
*/
|
|
90
91
|
|
|
91
92
|
/**
|
|
@@ -230,5 +231,47 @@ var _dsl = require("./queries/dsl");
|
|
|
230
231
|
* @property {string?} error?
|
|
231
232
|
* @property {string?} reason?
|
|
232
233
|
*/
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* @typedef {object} Theme
|
|
237
|
+
* @property {string} id
|
|
238
|
+
* @property {string} label
|
|
239
|
+
* @property {string} icon
|
|
240
|
+
* @property {Array<QualificationAttributes>} items
|
|
241
|
+
* @property {Array<string>} [defaultItems]
|
|
242
|
+
*
|
|
243
|
+
* @typedef {Array<Theme>} ThemesList
|
|
244
|
+
*
|
|
245
|
+
* @typedef {'identity'|'family'|'work_study'|'health'|'home'|'transport'|'finance'|'invoice'} ThemesLabels
|
|
246
|
+
*/
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* @typedef {object} QualificationAttributes
|
|
250
|
+
* @property {string} label
|
|
251
|
+
* @property {string} [purpose]
|
|
252
|
+
* @property {string} [sourceCategory]
|
|
253
|
+
* @property {string} [sourceSubCategory]
|
|
254
|
+
* @property {Array<string>} [subjects]
|
|
255
|
+
*/
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* @typedef {'identity_photo'|'national_id_card'|'passport'|'residence_permit'|'family_record_book'|'birth_certificate'|'driver_license'|'other_identity_document'} IdentityLabel
|
|
259
|
+
*
|
|
260
|
+
* @typedef {'family_record_book'|'birth_certificate'|'wedding'|'pacs'|'divorce'|'large_family_card'|'caf'|'other_family_document'} FamilyLabel
|
|
261
|
+
*
|
|
262
|
+
* @typedef {'diploma'|'work_contract'|'pay_sheet'|'unemployment_benefit'|'pension'|'other_revenue'|'gradebook'|'student_card'|'resume'|'motivation_letter'|'other_work_document'} WorkStudyLabels
|
|
263
|
+
*
|
|
264
|
+
* @typedef {'health_certificate'|'health_book'|'national_health_insurance_card'|'health_insurance_card'|'prescription'|'health_invoice'} HealthLabels
|
|
265
|
+
*
|
|
266
|
+
* @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
|
|
267
|
+
*
|
|
268
|
+
* @typedef {'driver_license'|'vehicle_registration'|'car_insurance'|'mechanic_invoice'|'transport_invoice'|'other_transport_document'} TransportLabels
|
|
269
|
+
*
|
|
270
|
+
* @typedef {'tax_return'|'tax_notice'|'tax_timetable'|'receipt'|'other_tax_document'|'bank_details'|'bank_statement'|'loan_agreement'|'other_bank_document'} FinanceLabels
|
|
271
|
+
*
|
|
272
|
+
* @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
|
|
273
|
+
*
|
|
274
|
+
* @typedef {IdentityLabel|FamilyLabel|WorkStudyLabels|HealthLabels|HomeLabels|TransportLabels|FinanceLabels|InvoiceLabels} ItemsLabels
|
|
275
|
+
*/
|
|
233
276
|
var _default = {};
|
|
234
277
|
exports.default = _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "27.
|
|
3
|
+
"version": "27.4.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -26,6 +26,7 @@
|
|
|
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": "
|
|
72
|
+
"gitHead": "1ab42dff2e9088f4a3daff29866ad7a22b093791"
|
|
72
73
|
}
|
package/types/CozyClient.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ export type ClientOptions = {
|
|
|
10
10
|
autoHydrate?: boolean;
|
|
11
11
|
oauth?: object;
|
|
12
12
|
onTokenRefresh?: Function;
|
|
13
|
+
/**
|
|
14
|
+
* - Default callback if a query is errored
|
|
15
|
+
*/
|
|
16
|
+
onError?: Function;
|
|
13
17
|
/**
|
|
14
18
|
* - Schema description for each doctypes
|
|
15
19
|
*/
|
|
@@ -39,7 +43,7 @@ export type ClientOptions = {
|
|
|
39
43
|
* @property {boolean} [autoHydrate]
|
|
40
44
|
* @property {object} [oauth]
|
|
41
45
|
* @property {Function} [onTokenRefresh]
|
|
42
|
-
* @property {Function} [
|
|
46
|
+
* @property {Function} [onError] - Default callback if a query is errored
|
|
43
47
|
* @property {Link} [link] - Backward compatibility
|
|
44
48
|
* @property {Array<Link>} [links] - List of links
|
|
45
49
|
* @property {object} [schema] - Schema description for each doctypes
|
|
@@ -146,6 +150,10 @@ declare class CozyClient {
|
|
|
146
150
|
autoHydrate?: boolean;
|
|
147
151
|
oauth?: object;
|
|
148
152
|
onTokenRefresh?: Function;
|
|
153
|
+
/**
|
|
154
|
+
* - Default callback if a query is errored
|
|
155
|
+
*/
|
|
156
|
+
onError?: Function;
|
|
149
157
|
/**
|
|
150
158
|
* - If set to false, the client will not instantiate a Redux store automatically. Use this if you want to merge cozy-client's store with your own redux store. See [here](https://docs.cozy.io/en/cozy-client/react-integration/#1b-use-your-own-redux-store) for more information.
|
|
151
159
|
*/
|
|
@@ -640,6 +648,12 @@ declare class CozyClient {
|
|
|
640
648
|
* @param {object} data - Data that is inserted in the store. Shape: { doctype: [data] }
|
|
641
649
|
*/
|
|
642
650
|
setData(data: object): void;
|
|
651
|
+
/**
|
|
652
|
+
* At any time put an error function
|
|
653
|
+
*
|
|
654
|
+
* @param {Function} [onError] - Set a callback for queries which are errored
|
|
655
|
+
*/
|
|
656
|
+
setOnError(onError?: Function): void;
|
|
643
657
|
toJSON(): SnapshotClient;
|
|
644
658
|
}
|
|
645
659
|
declare namespace CozyClient {
|
|
@@ -1,24 +1,48 @@
|
|
|
1
1
|
export function useQueries(querySpecs: any): {};
|
|
2
2
|
export default useQuery;
|
|
3
|
+
/**
|
|
4
|
+
* Fetches a queryDefinition and returns the queryState
|
|
5
|
+
*/
|
|
6
|
+
export type UseQueryOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* - Name for the query [required]
|
|
9
|
+
*/
|
|
10
|
+
as: object;
|
|
11
|
+
/**
|
|
12
|
+
* - If set to false, the query won't be executed
|
|
13
|
+
*/
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* - Fetch policy
|
|
17
|
+
*/
|
|
18
|
+
fetchPolicy: object;
|
|
19
|
+
/**
|
|
20
|
+
* - If true, the "data" returned will be
|
|
21
|
+
* a single doc instead of an array for single doc queries. Defaults to false for backward
|
|
22
|
+
* compatibility but will be set to true in the future.
|
|
23
|
+
*/
|
|
24
|
+
singleDocData: object;
|
|
25
|
+
/**
|
|
26
|
+
* - Callback if the query is errored
|
|
27
|
+
*/
|
|
28
|
+
onError: Function;
|
|
29
|
+
};
|
|
3
30
|
/**
|
|
4
31
|
* Fetches a queryDefinition and returns the queryState
|
|
5
32
|
*
|
|
6
|
-
* @param {
|
|
33
|
+
* @param {QueryDefinition} queryDefinition - Definition created with Q()
|
|
7
34
|
*
|
|
8
|
-
* @
|
|
9
|
-
* @
|
|
10
|
-
* @
|
|
11
|
-
* @
|
|
12
|
-
* @
|
|
35
|
+
* @typedef {object} UseQueryOptions
|
|
36
|
+
* @property {object} as - Name for the query [required]
|
|
37
|
+
* @property {boolean} enabled - If set to false, the query won't be executed
|
|
38
|
+
* @property {object} fetchPolicy - Fetch policy
|
|
39
|
+
* @property {object} singleDocData - If true, the "data" returned will be
|
|
13
40
|
* a single doc instead of an array for single doc queries. Defaults to false for backward
|
|
14
41
|
* compatibility but will be set to true in the future.
|
|
42
|
+
* @property {Function} onError - Callback if the query is errored
|
|
15
43
|
*
|
|
16
44
|
* @returns {UseQueryReturnValue}
|
|
17
45
|
*/
|
|
18
|
-
declare function useQuery(queryDefinition:
|
|
19
|
-
|
|
20
|
-
enabled: boolean;
|
|
21
|
-
fetchPolicy: object;
|
|
22
|
-
singleDocData: object;
|
|
23
|
-
}): UseQueryReturnValue;
|
|
46
|
+
declare function useQuery(queryDefinition: QueryDefinition, options: any): UseQueryReturnValue;
|
|
47
|
+
import { QueryDefinition } from "../queries/dsl";
|
|
24
48
|
import { UseQueryReturnValue } from "../types";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Qualification } from "./qualification";
|
|
2
|
+
import { setQualification } from "./qualification";
|
|
3
|
+
import { getQualification } from "./qualification";
|
|
4
|
+
import * as locales from "./locales";
|
|
5
|
+
import * as themes from "./documentTypeData";
|
|
6
|
+
import * as helpers from "./documentTypeDataHelpers";
|
|
7
|
+
export { Qualification, setQualification, getQualification, locales, themes, helpers };
|
|
File without changes
|
package/types/types.d.ts
CHANGED
|
@@ -64,6 +64,10 @@ export type QueryOptions = {
|
|
|
64
64
|
* - Does not seem to be used
|
|
65
65
|
*/
|
|
66
66
|
update?: string;
|
|
67
|
+
/**
|
|
68
|
+
* - Callback when the query is errored
|
|
69
|
+
*/
|
|
70
|
+
onError?: Function;
|
|
67
71
|
};
|
|
68
72
|
export type FetchMoreAble = {
|
|
69
73
|
fetchMore: Function;
|
|
@@ -272,4 +276,29 @@ export type CouchDBBulkResult = {
|
|
|
272
276
|
*/
|
|
273
277
|
reason: string | null;
|
|
274
278
|
};
|
|
279
|
+
export type Theme = {
|
|
280
|
+
id: string;
|
|
281
|
+
label: string;
|
|
282
|
+
icon: string;
|
|
283
|
+
items: Array<QualificationAttributes>;
|
|
284
|
+
defaultItems?: Array<string>;
|
|
285
|
+
};
|
|
286
|
+
export type ThemesList = Theme[];
|
|
287
|
+
export type ThemesLabels = "transport" | "identity" | "family" | "work_study" | "health" | "home" | "finance" | "invoice";
|
|
288
|
+
export type QualificationAttributes = {
|
|
289
|
+
label: string;
|
|
290
|
+
purpose?: string;
|
|
291
|
+
sourceCategory?: string;
|
|
292
|
+
sourceSubCategory?: string;
|
|
293
|
+
subjects?: Array<string>;
|
|
294
|
+
};
|
|
295
|
+
export type IdentityLabel = "identity_photo" | "national_id_card" | "passport" | "residence_permit" | "family_record_book" | "birth_certificate" | "driver_license" | "other_identity_document";
|
|
296
|
+
export type FamilyLabel = "family_record_book" | "birth_certificate" | "wedding" | "pacs" | "divorce" | "large_family_card" | "caf" | "other_family_document";
|
|
297
|
+
export type WorkStudyLabels = "resume" | "diploma" | "work_contract" | "pay_sheet" | "unemployment_benefit" | "pension" | "other_revenue" | "gradebook" | "student_card" | "motivation_letter" | "other_work_document";
|
|
298
|
+
export type HealthLabels = "health_certificate" | "health_book" | "national_health_insurance_card" | "health_insurance_card" | "prescription" | "health_invoice";
|
|
299
|
+
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";
|
|
300
|
+
export type TransportLabels = "driver_license" | "vehicle_registration" | "car_insurance" | "mechanic_invoice" | "transport_invoice" | "other_transport_document";
|
|
301
|
+
export type FinanceLabels = "tax_return" | "tax_notice" | "tax_timetable" | "receipt" | "other_tax_document" | "bank_details" | "bank_statement" | "loan_agreement" | "other_bank_document";
|
|
302
|
+
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";
|
|
303
|
+
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
304
|
import { QueryDefinition } from "./queries/dsl";
|