cozy-client 41.9.0 → 42.0.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/dist/CozyClient.js
CHANGED
|
@@ -2703,7 +2703,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2703
2703
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
2704
2704
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
2705
2705
|
|
|
2706
|
-
CozyClient.version = "
|
|
2706
|
+
CozyClient.version = "42.0.0";
|
|
2707
2707
|
|
|
2708
2708
|
_microee.default.mixin(CozyClient);
|
|
2709
2709
|
|
|
@@ -7,65 +7,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _useQuery2 = _interopRequireDefault(require("./useQuery"));
|
|
11
11
|
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
-
|
|
16
|
-
var _react = require("react");
|
|
17
|
-
|
|
18
|
-
var _registry = _interopRequireDefault(require("../registry"));
|
|
12
|
+
var _dsl = require("../queries/dsl");
|
|
19
13
|
|
|
20
14
|
var _CozyClient = _interopRequireDefault(require("../CozyClient"));
|
|
21
15
|
|
|
16
|
+
var DEFAULT_CACHE_TIMEOUT_QUERIES = 10 * 60 * 1000; // 10 minutes
|
|
17
|
+
|
|
22
18
|
/**
|
|
23
19
|
* Returns all apps in maintenance
|
|
24
20
|
*
|
|
25
|
-
* @param {CozyClient} client CozyClient instance
|
|
26
|
-
*
|
|
27
21
|
* @returns {import("../types").AppsDoctype[]} An array with all apps in maintenance
|
|
28
22
|
*/
|
|
29
|
-
var useAppsInMaintenance = function useAppsInMaintenance(client) {
|
|
30
|
-
var _useState = (0, _react.useState)([]),
|
|
31
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
32
|
-
appsInMaintenance = _useState2[0],
|
|
33
|
-
setAppsInMaintenance = _useState2[1];
|
|
34
|
-
|
|
35
|
-
(0, _react.useEffect)(function () {
|
|
36
|
-
var fetchData = /*#__PURE__*/function () {
|
|
37
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
38
|
-
var registry, newAppsInMaintenance;
|
|
39
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
40
|
-
while (1) {
|
|
41
|
-
switch (_context.prev = _context.next) {
|
|
42
|
-
case 0:
|
|
43
|
-
registry = new _registry.default({
|
|
44
|
-
client: client
|
|
45
|
-
});
|
|
46
|
-
_context.next = 3;
|
|
47
|
-
return registry.fetchAppsInMaintenance();
|
|
48
|
-
|
|
49
|
-
case 3:
|
|
50
|
-
newAppsInMaintenance = _context.sent;
|
|
51
|
-
setAppsInMaintenance(newAppsInMaintenance || []);
|
|
52
|
-
|
|
53
|
-
case 5:
|
|
54
|
-
case "end":
|
|
55
|
-
return _context.stop();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}, _callee);
|
|
59
|
-
}));
|
|
60
23
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
24
|
+
var useAppsInMaintenance = function useAppsInMaintenance() {
|
|
25
|
+
var _useQuery = (0, _useQuery2.default)((0, _dsl.Q)('io.cozy.apps_registry').getById('maintenance'), {
|
|
26
|
+
as: 'io.cozy.apps_registry/maintenance',
|
|
27
|
+
fetchPolicy: _CozyClient.default.fetchPolicies.olderThan(DEFAULT_CACHE_TIMEOUT_QUERIES),
|
|
28
|
+
singleDocData: false
|
|
29
|
+
}),
|
|
30
|
+
appsInMaintenance = _useQuery.data;
|
|
65
31
|
|
|
66
|
-
|
|
67
|
-
}, [client]);
|
|
68
|
-
return appsInMaintenance;
|
|
32
|
+
return appsInMaintenance || [];
|
|
69
33
|
};
|
|
70
34
|
|
|
71
35
|
var _default = useAppsInMaintenance;
|
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
import { renderHook } from '@testing-library/react-hooks'
|
|
2
2
|
import useAppsInMaintenance from './useAppsInMaintenance'
|
|
3
|
-
import
|
|
3
|
+
import { createMockClient } from '../mock'
|
|
4
|
+
import { makeWrapper } from '../testing/utils'
|
|
4
5
|
|
|
5
6
|
const appsInMaintenance = [
|
|
6
7
|
{
|
|
8
|
+
_id: 'caissedepargne1',
|
|
7
9
|
slug: 'caissedepargne1'
|
|
8
10
|
},
|
|
9
|
-
{
|
|
11
|
+
{
|
|
12
|
+
_id: 'boursorama',
|
|
13
|
+
slug: 'boursorama'
|
|
14
|
+
}
|
|
10
15
|
]
|
|
11
16
|
|
|
12
|
-
const mockClient =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
{ slug: 'boursorama' }
|
|
20
|
-
])
|
|
17
|
+
const mockClient = createMockClient({
|
|
18
|
+
queries: {
|
|
19
|
+
'io.cozy.apps_registry/maintenance': {
|
|
20
|
+
data: appsInMaintenance,
|
|
21
|
+
doctype: 'io.cozy.apps_registry'
|
|
22
|
+
}
|
|
21
23
|
}
|
|
22
24
|
})
|
|
23
25
|
|
|
24
26
|
describe('useAppsInMaintenance', () => {
|
|
25
|
-
it('should return apps in maintenance',
|
|
26
|
-
const { result
|
|
27
|
-
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
expect(result.current).
|
|
27
|
+
it('should return apps in maintenance', () => {
|
|
28
|
+
const { result } = renderHook(() => useAppsInMaintenance(), {
|
|
29
|
+
wrapper: makeWrapper(mockClient)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
expect(result.current).toMatchObject(appsInMaintenance)
|
|
31
33
|
})
|
|
32
34
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "42.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@types/jest": "^26.0.20",
|
|
19
19
|
"@types/lodash": "^4.14.170",
|
|
20
20
|
"btoa": "^1.2.1",
|
|
21
|
-
"cozy-stack-client": "^
|
|
21
|
+
"cozy-stack-client": "^42.0.0",
|
|
22
22
|
"date-fns": "2.29.3",
|
|
23
23
|
"json-stable-stringify": "^1.0.1",
|
|
24
24
|
"lodash": "^4.17.13",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
|
|
76
76
|
},
|
|
77
77
|
"sideEffects": false,
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "05dd6d3e85a2adee4dcfdf8e427dc87f3f39f4c7"
|
|
79
79
|
}
|
|
@@ -2,9 +2,6 @@ export default useAppsInMaintenance;
|
|
|
2
2
|
/**
|
|
3
3
|
* Returns all apps in maintenance
|
|
4
4
|
*
|
|
5
|
-
* @param {CozyClient} client CozyClient instance
|
|
6
|
-
*
|
|
7
5
|
* @returns {import("../types").AppsDoctype[]} An array with all apps in maintenance
|
|
8
6
|
*/
|
|
9
|
-
declare function useAppsInMaintenance(
|
|
10
|
-
import CozyClient from "../CozyClient";
|
|
7
|
+
declare function useAppsInMaintenance(): import("../types").AppsDoctype[];
|