cozy-client 27.22.2 → 27.24.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 +1 -1
- package/dist/authentication/mobile.native.js +19 -2
- package/dist/helpers.spec.js +6 -2
- package/dist/hooks/helpers/useIsMounted.js +23 -0
- package/dist/hooks/helpers/useSafeState.js +34 -0
- package/dist/hooks/index.js +9 -1
- package/dist/hooks/useQuery.js +2 -11
- package/dist/hooks/useQueryAll.js +78 -0
- package/dist/hooks/useQueryAll.spec.jsx +81 -0
- package/dist/models/document/locales/fr.json +1 -1
- package/dist/types.js +5 -0
- package/package.json +2 -2
- package/types/hooks/helpers/useIsMounted.d.ts +2 -0
- package/types/hooks/helpers/useSafeState.d.ts +2 -0
- package/types/hooks/index.d.ts +1 -0
- package/types/hooks/useQuery.d.ts +4 -39
- package/types/hooks/useQueryAll.d.ts +12 -0
- package/types/types.d.ts +14 -0
package/dist/CozyClient.js
CHANGED
|
@@ -2537,7 +2537,7 @@ var CozyClient = /*#__PURE__*/function () {
|
|
|
2537
2537
|
CozyClient.hooks = CozyClient.hooks || {};
|
|
2538
2538
|
CozyClient.fetchPolicies = _policies.default; //COZY_CLIENT_VERSION_PACKAGE in replaced by babel. See babel config
|
|
2539
2539
|
|
|
2540
|
-
CozyClient.version = "27.
|
|
2540
|
+
CozyClient.version = "27.24.0";
|
|
2541
2541
|
|
|
2542
2542
|
_microee.default.mixin(CozyClient);
|
|
2543
2543
|
|
|
@@ -17,15 +17,24 @@ var _reactNative = require("react-native");
|
|
|
17
17
|
|
|
18
18
|
//@ts-ignore
|
|
19
19
|
//@ts-ignore
|
|
20
|
-
|
|
20
|
+
var USER_CANCELED = 'USER_CANCELED';
|
|
21
21
|
/**
|
|
22
22
|
* Opens a ReactNative InAppBrowser
|
|
23
23
|
* and resolves with the URL containing
|
|
24
24
|
* the token
|
|
25
25
|
*
|
|
26
|
+
* When the user close the InAppBrowser, the promise
|
|
27
|
+
* rejects with USER_CANCELED message
|
|
28
|
+
*
|
|
29
|
+
* When the redirection URL contains `error=access_denied`
|
|
30
|
+
* the promise rejects with USER_CANCELED message. This means
|
|
31
|
+
* that the user closed the authorization popup
|
|
32
|
+
*
|
|
26
33
|
* @param {string} url
|
|
27
34
|
* @returns {Promise}
|
|
35
|
+
* @throws Will throw an "USER_CANCELED" message when the user cancel the authorization process
|
|
28
36
|
*/
|
|
37
|
+
|
|
29
38
|
var authenticateWithReactNativeInAppBrowser = /*#__PURE__*/function () {
|
|
30
39
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(url) {
|
|
31
40
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
@@ -43,11 +52,12 @@ var authenticateWithReactNativeInAppBrowser = /*#__PURE__*/function () {
|
|
|
43
52
|
enableBarCollapsing: false,
|
|
44
53
|
// Android Properties
|
|
45
54
|
showTitle: true,
|
|
46
|
-
toolbarColor: '#
|
|
55
|
+
toolbarColor: '#8e9094',
|
|
47
56
|
secondaryToolbarColor: 'black',
|
|
48
57
|
enableUrlBarHiding: true,
|
|
49
58
|
enableDefaultShare: true,
|
|
50
59
|
forceCloseOnRedirection: false,
|
|
60
|
+
showInRecents: true,
|
|
51
61
|
// Specify full animation resource identifier(package:anim/name)
|
|
52
62
|
// or only resource name(in case of animation bundled with app).
|
|
53
63
|
animations: {
|
|
@@ -56,6 +66,10 @@ var authenticateWithReactNativeInAppBrowser = /*#__PURE__*/function () {
|
|
|
56
66
|
endEnter: 'slide_in_left',
|
|
57
67
|
endExit: 'slide_out_right'
|
|
58
68
|
}
|
|
69
|
+
}).then(function (result) {
|
|
70
|
+
if (result.type === 'cancel') {
|
|
71
|
+
reject(USER_CANCELED);
|
|
72
|
+
}
|
|
59
73
|
});
|
|
60
74
|
|
|
61
75
|
var removeListener = function removeListener() {
|
|
@@ -67,6 +81,7 @@ var authenticateWithReactNativeInAppBrowser = /*#__PURE__*/function () {
|
|
|
67
81
|
var sanitizedUrl = url;
|
|
68
82
|
var accessCode = /\?access_code=(.+)$/.test(url);
|
|
69
83
|
var state = /\?state=(.+)$/.test(url);
|
|
84
|
+
var closeSignal = /\?error=access_denied$/.test(url);
|
|
70
85
|
|
|
71
86
|
if (accessCode || state) {
|
|
72
87
|
if (_reactNative.Platform.OS === 'ios') {
|
|
@@ -87,6 +102,8 @@ var authenticateWithReactNativeInAppBrowser = /*#__PURE__*/function () {
|
|
|
87
102
|
removeListener();
|
|
88
103
|
|
|
89
104
|
_reactNativeInappbrowserReborn.InAppBrowser.close();
|
|
105
|
+
} else if (closeSignal) {
|
|
106
|
+
reject(USER_CANCELED);
|
|
90
107
|
}
|
|
91
108
|
};
|
|
92
109
|
|
package/dist/helpers.spec.js
CHANGED
|
@@ -155,6 +155,10 @@ describe('rootCozyUrl', () => {
|
|
|
155
155
|
enableFetchMocks()
|
|
156
156
|
})
|
|
157
157
|
|
|
158
|
+
beforeEach(() => {
|
|
159
|
+
fetch.resetMocks()
|
|
160
|
+
})
|
|
161
|
+
|
|
158
162
|
afterAll(() => {
|
|
159
163
|
disableFetchMocks()
|
|
160
164
|
})
|
|
@@ -354,7 +358,7 @@ describe('rootCozyUrl', () => {
|
|
|
354
358
|
|
|
355
359
|
it('expects an http or https protocol', async () => {
|
|
356
360
|
fetch.mockOnceIf(
|
|
357
|
-
'ftp://camillenimbus.com',
|
|
361
|
+
'ftp://camillenimbus.com/.well-known/change-password',
|
|
358
362
|
{},
|
|
359
363
|
{
|
|
360
364
|
status: 200
|
|
@@ -368,7 +372,7 @@ describe('rootCozyUrl', () => {
|
|
|
368
372
|
|
|
369
373
|
it('rejects if URL points to a valid cozy-stack but no valid Cozy instance', async () => {
|
|
370
374
|
fetch.mockOnceIf(
|
|
371
|
-
'https://missing.mycozy.cloud',
|
|
375
|
+
'https://missing.mycozy.cloud/.well-known/change-password',
|
|
372
376
|
{},
|
|
373
377
|
{
|
|
374
378
|
status: 404
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
// @ts-nocheck
|
|
11
|
+
var useIsMounted = function useIsMounted() {
|
|
12
|
+
var mounted = (0, _react.useRef)();
|
|
13
|
+
(0, _react.useEffect)(function () {
|
|
14
|
+
mounted.current = true;
|
|
15
|
+
return function () {
|
|
16
|
+
mounted.current = false;
|
|
17
|
+
};
|
|
18
|
+
}, []);
|
|
19
|
+
return mounted;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
var _default = useIsMounted;
|
|
23
|
+
exports.default = _default;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
|
|
12
|
+
var _react = require("react");
|
|
13
|
+
|
|
14
|
+
var _useIsMounted = _interopRequireDefault(require("./useIsMounted"));
|
|
15
|
+
|
|
16
|
+
var useSafeState = function useSafeState(initialState) {
|
|
17
|
+
var mounted = (0, _useIsMounted.default)();
|
|
18
|
+
|
|
19
|
+
var _useState = (0, _react.useState)(initialState),
|
|
20
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
21
|
+
state = _useState2[0],
|
|
22
|
+
setState = _useState2[1];
|
|
23
|
+
|
|
24
|
+
var setSafeState = (0, _react.useCallback)(function (newState) {
|
|
25
|
+
if (mounted.current) {
|
|
26
|
+
setState(newState);
|
|
27
|
+
}
|
|
28
|
+
}, [] // eslint-disable-line react-hooks/exhaustive-deps
|
|
29
|
+
);
|
|
30
|
+
return [state, setSafeState];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
var _default = useSafeState;
|
|
34
|
+
exports.default = _default;
|
package/dist/hooks/index.js
CHANGED
|
@@ -41,6 +41,12 @@ Object.defineProperty(exports, "useAppsInMaintenance", {
|
|
|
41
41
|
return _useAppsInMaintenance.default;
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
|
+
Object.defineProperty(exports, "useQueryAll", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function get() {
|
|
47
|
+
return _useQueryAll.default;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
44
50
|
|
|
45
51
|
var _useAppLinkWithStoreFallback = _interopRequireDefault(require("./useAppLinkWithStoreFallback"));
|
|
46
52
|
|
|
@@ -52,4 +58,6 @@ var _useClient = _interopRequireDefault(require("./useClient"));
|
|
|
52
58
|
|
|
53
59
|
var _useQuery = _interopRequireDefault(require("./useQuery"));
|
|
54
60
|
|
|
55
|
-
var _useAppsInMaintenance = _interopRequireDefault(require("./useAppsInMaintenance"));
|
|
61
|
+
var _useAppsInMaintenance = _interopRequireDefault(require("./useAppsInMaintenance"));
|
|
62
|
+
|
|
63
|
+
var _useQueryAll = _interopRequireDefault(require("./useQueryAll"));
|
package/dist/hooks/useQuery.js
CHANGED
|
@@ -43,17 +43,8 @@ var generateFetchMoreQueryDefinition = function generateFetchMoreQueryDefinition
|
|
|
43
43
|
/**
|
|
44
44
|
* Fetches a queryDefinition and returns the queryState
|
|
45
45
|
*
|
|
46
|
-
* @param
|
|
47
|
-
*
|
|
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
|
|
53
|
-
* a single doc instead of an array for single doc queries. Defaults to false for backward
|
|
54
|
-
* compatibility but will be set to true in the future.
|
|
55
|
-
* @property {Function} onError - Callback if the query is errored
|
|
56
|
-
*
|
|
46
|
+
* @param {QueryDefinition} queryDefinition - Definition created with Q()
|
|
47
|
+
* @param {QueryOptions} options - Options created with Q()
|
|
57
48
|
* @returns {UseQueryReturnValue}
|
|
58
49
|
*/
|
|
59
50
|
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
|
|
14
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
|
+
|
|
16
|
+
var _react = require("react");
|
|
17
|
+
|
|
18
|
+
var _types = require("../types");
|
|
19
|
+
|
|
20
|
+
var _dsl = require("../queries/dsl");
|
|
21
|
+
|
|
22
|
+
var _useQuery = _interopRequireDefault(require("./useQuery"));
|
|
23
|
+
|
|
24
|
+
var _useSafeState3 = _interopRequireDefault(require("./helpers/useSafeState"));
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Fetches a queryDefinition and run fetchMore on the query until the query is fully loaded
|
|
28
|
+
*
|
|
29
|
+
* @param {QueryDefinition} queryDefinition - Definition created with Q()
|
|
30
|
+
* @param {QueryOptions} options - Options created with Q()
|
|
31
|
+
* @returns {UseQueryReturnValue}
|
|
32
|
+
*/
|
|
33
|
+
var useQueryAll = function useQueryAll(queryDefinition, options) {
|
|
34
|
+
var _useSafeState = (0, _useSafeState3.default)(false),
|
|
35
|
+
_useSafeState2 = (0, _slicedToArray2.default)(_useSafeState, 2),
|
|
36
|
+
fetching = _useSafeState2[0],
|
|
37
|
+
setFetching = _useSafeState2[1];
|
|
38
|
+
|
|
39
|
+
var res = (0, _useQuery.default)(queryDefinition, options);
|
|
40
|
+
(0, _react.useEffect)(function () {
|
|
41
|
+
var checkToFetchMore = /*#__PURE__*/function () {
|
|
42
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
43
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
44
|
+
while (1) {
|
|
45
|
+
switch (_context.prev = _context.next) {
|
|
46
|
+
case 0:
|
|
47
|
+
if (!(res.fetchStatus === 'loaded' && res.hasMore && !fetching)) {
|
|
48
|
+
_context.next = 5;
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
setFetching(true);
|
|
53
|
+
_context.next = 4;
|
|
54
|
+
return res.fetchMore();
|
|
55
|
+
|
|
56
|
+
case 4:
|
|
57
|
+
setFetching(false);
|
|
58
|
+
|
|
59
|
+
case 5:
|
|
60
|
+
case "end":
|
|
61
|
+
return _context.stop();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}, _callee);
|
|
65
|
+
}));
|
|
66
|
+
|
|
67
|
+
return function checkToFetchMore() {
|
|
68
|
+
return _ref.apply(this, arguments);
|
|
69
|
+
};
|
|
70
|
+
}();
|
|
71
|
+
|
|
72
|
+
checkToFetchMore(); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
73
|
+
}, [res.hasMore, res.fetchStatus, fetching]);
|
|
74
|
+
return res;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
var _default = useQueryAll;
|
|
78
|
+
exports.default = _default;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { renderHook } from '@testing-library/react-hooks'
|
|
3
|
+
|
|
4
|
+
import { Q } from '../queries/dsl'
|
|
5
|
+
import { createMockClient } from '../mock'
|
|
6
|
+
import CozyProvider from '../Provider'
|
|
7
|
+
|
|
8
|
+
import useQueryAll from './useQueryAll'
|
|
9
|
+
|
|
10
|
+
const sleep = delay => new Promise(resolve => setTimeout(resolve, delay))
|
|
11
|
+
|
|
12
|
+
describe('useQueryAll', () => {
|
|
13
|
+
const setup = ({ todosResult }) => {
|
|
14
|
+
const client = createMockClient({
|
|
15
|
+
queries: {
|
|
16
|
+
todos: todosResult
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
client.query.mockImplementation(async () => {
|
|
20
|
+
// give a little time for hook to be re-rendered several times
|
|
21
|
+
await sleep(10)
|
|
22
|
+
return {
|
|
23
|
+
data: [{ _id: '2', done: false }],
|
|
24
|
+
next: false
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
const wrapper = ({ children }) => (
|
|
28
|
+
<CozyProvider client={client}>{children}</CozyProvider>
|
|
29
|
+
)
|
|
30
|
+
const query = Q('io.cozy.todos')
|
|
31
|
+
const options = {
|
|
32
|
+
as: 'todos'
|
|
33
|
+
}
|
|
34
|
+
const hook = renderHook(() => useQueryAll(query, options), {
|
|
35
|
+
wrapper
|
|
36
|
+
})
|
|
37
|
+
return { client, wrapper, hook }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
it('should run only 1 fetch more even if the hook is rendered-multiple times', () => {
|
|
41
|
+
const {
|
|
42
|
+
client,
|
|
43
|
+
hook: { result, rerender }
|
|
44
|
+
} = setup({
|
|
45
|
+
todosResult: {
|
|
46
|
+
data: [{ _id: '1', done: true }],
|
|
47
|
+
next: true,
|
|
48
|
+
doctype: 'io.cozy.todos'
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
expect(result.error).toBeFalsy()
|
|
52
|
+
rerender()
|
|
53
|
+
rerender()
|
|
54
|
+
rerender()
|
|
55
|
+
rerender()
|
|
56
|
+
|
|
57
|
+
// one for the initial query and one for the fetchMore
|
|
58
|
+
expect(client.query).toHaveBeenCalledTimes(2)
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('should not run fetch if there are no more results', () => {
|
|
62
|
+
const {
|
|
63
|
+
client,
|
|
64
|
+
hook: { result, rerender }
|
|
65
|
+
} = setup({
|
|
66
|
+
todosResult: {
|
|
67
|
+
data: [{ _id: '1', done: true }],
|
|
68
|
+
next: false,
|
|
69
|
+
doctype: 'io.cozy.todos'
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
expect(result.error).toBeFalsy()
|
|
73
|
+
rerender()
|
|
74
|
+
rerender()
|
|
75
|
+
rerender()
|
|
76
|
+
rerender()
|
|
77
|
+
|
|
78
|
+
// one for the initial query and one for the fetchMore
|
|
79
|
+
expect(client.query).toHaveBeenCalledTimes(1)
|
|
80
|
+
})
|
|
81
|
+
})
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"phone_invoice": "Facture de téléphone",
|
|
72
72
|
"isp_invoice": "Facture d'internet",
|
|
73
73
|
"telecom_invoice": "Facture de télécom",
|
|
74
|
-
"energy_invoice": "Facture d'
|
|
74
|
+
"energy_invoice": "Facture d'énergie",
|
|
75
75
|
"water_invoice": "Facture d'eau",
|
|
76
76
|
"web_service_invoice": "Facture de service web",
|
|
77
77
|
"appliance_invoice": "Facture d'électroménager",
|
package/dist/types.js
CHANGED
|
@@ -87,6 +87,11 @@ var _dsl = require("./queries/dsl");
|
|
|
87
87
|
* @property {AutoUpdateOptions} [autoUpdate] - Options for the query auto update
|
|
88
88
|
* @property {string} [update] - Does not seem to be used
|
|
89
89
|
* @property {Function} [onError] - Callback when the query is errored
|
|
90
|
+
* @property {boolean} [enabled=true] - If set to false, the query won't be executed
|
|
91
|
+
* @property {object} [hydrated=true] - Whether documents should be returned already hydrated
|
|
92
|
+
* @property {object} [singleDocData] - If true, the "data" returned will be
|
|
93
|
+
* a single doc instead of an array for single doc queries. Defaults to false for backward
|
|
94
|
+
* compatibility but will be set to true in the future.
|
|
90
95
|
*/
|
|
91
96
|
|
|
92
97
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cozy-client",
|
|
3
|
-
"version": "27.
|
|
3
|
+
"version": "27.24.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.node.js",
|
|
6
6
|
"browser": "dist/index.js",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"react-native-ios11-devicecheck": "https://github.com/cozy/react-native-devicecheck#app-attest-v0.1"
|
|
72
72
|
},
|
|
73
73
|
"sideEffects": false,
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "1b797059e18e7acfca9666ae8292dabe05a4eaff"
|
|
75
75
|
}
|
package/types/hooks/index.d.ts
CHANGED
|
@@ -4,3 +4,4 @@ export { default as useFetchShortcut } from "./useFetchShortcut";
|
|
|
4
4
|
export { default as useClient } from "./useClient";
|
|
5
5
|
export { default as useQuery } from "./useQuery";
|
|
6
6
|
export { default as useAppsInMaintenance } from "./useAppsInMaintenance";
|
|
7
|
+
export { default as useQueryAll } from "./useQueryAll";
|
|
@@ -2,47 +2,12 @@ export function useQueries(querySpecs: any): {};
|
|
|
2
2
|
export default useQuery;
|
|
3
3
|
/**
|
|
4
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
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Fetches a queryDefinition and returns the queryState
|
|
32
|
-
*
|
|
33
|
-
* @param {QueryDefinition} queryDefinition - Definition created with Q()
|
|
34
|
-
*
|
|
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
|
|
40
|
-
* a single doc instead of an array for single doc queries. Defaults to false for backward
|
|
41
|
-
* compatibility but will be set to true in the future.
|
|
42
|
-
* @property {Function} onError - Callback if the query is errored
|
|
43
5
|
*
|
|
6
|
+
* @param {QueryDefinition} queryDefinition - Definition created with Q()
|
|
7
|
+
* @param {QueryOptions} options - Options created with Q()
|
|
44
8
|
* @returns {UseQueryReturnValue}
|
|
45
9
|
*/
|
|
46
|
-
declare function useQuery(queryDefinition: QueryDefinition, options:
|
|
10
|
+
declare function useQuery(queryDefinition: QueryDefinition, options: QueryOptions): UseQueryReturnValue;
|
|
47
11
|
import { QueryDefinition } from "../queries/dsl";
|
|
12
|
+
import { QueryOptions } from "../types";
|
|
48
13
|
import { UseQueryReturnValue } from "../types";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default useQueryAll;
|
|
2
|
+
/**
|
|
3
|
+
* Fetches a queryDefinition and run fetchMore on the query until the query is fully loaded
|
|
4
|
+
*
|
|
5
|
+
* @param {QueryDefinition} queryDefinition - Definition created with Q()
|
|
6
|
+
* @param {QueryOptions} options - Options created with Q()
|
|
7
|
+
* @returns {UseQueryReturnValue}
|
|
8
|
+
*/
|
|
9
|
+
declare function useQueryAll(queryDefinition: QueryDefinition, options: QueryOptions): UseQueryReturnValue;
|
|
10
|
+
import { QueryDefinition } from "../queries/dsl";
|
|
11
|
+
import { QueryOptions } from "../types";
|
|
12
|
+
import { UseQueryReturnValue } from "../types";
|
package/types/types.d.ts
CHANGED
|
@@ -68,6 +68,20 @@ export type QueryOptions = {
|
|
|
68
68
|
* - Callback when the query is errored
|
|
69
69
|
*/
|
|
70
70
|
onError?: Function;
|
|
71
|
+
/**
|
|
72
|
+
* - If set to false, the query won't be executed
|
|
73
|
+
*/
|
|
74
|
+
enabled?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* - Whether documents should be returned already hydrated
|
|
77
|
+
*/
|
|
78
|
+
hydrated?: object;
|
|
79
|
+
/**
|
|
80
|
+
* - If true, the "data" returned will be
|
|
81
|
+
* a single doc instead of an array for single doc queries. Defaults to false for backward
|
|
82
|
+
* compatibility but will be set to true in the future.
|
|
83
|
+
*/
|
|
84
|
+
singleDocData?: object;
|
|
71
85
|
};
|
|
72
86
|
export type FetchMoreAble = {
|
|
73
87
|
fetchMore: Function;
|