@dhis2/app-service-data 3.11.2 → 3.12.0-alpha.1
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/build/cjs/__tests__/integration.test.js +6 -15
- package/build/cjs/__tests__/mutations.test.js +4 -11
- package/build/cjs/engine/DataEngine.js +4 -14
- package/build/cjs/engine/DataEngine.test.js +0 -2
- package/build/cjs/engine/helpers/getMutationFetchType.js +0 -2
- package/build/cjs/engine/helpers/getMutationFetchType.test.js +0 -1
- package/build/cjs/engine/helpers/resolveDynamicQuery.js +0 -2
- package/build/cjs/engine/helpers/resolveDynamicQuery.test.js +3 -4
- package/build/cjs/engine/helpers/validate.js +0 -21
- package/build/cjs/engine/helpers/validate.test.js +0 -1
- package/build/cjs/engine/index.js +0 -18
- package/build/cjs/engine/types/FetchError.js +3 -8
- package/build/cjs/engine/types/FetchError.test.js +0 -1
- package/build/cjs/engine/types/InvalidQueryError.js +3 -8
- package/build/cjs/index.js +0 -2
- package/build/cjs/links/CustomDataLink.js +3 -17
- package/build/cjs/links/CustomDataLink.test.js +0 -1
- package/build/cjs/links/ErrorLink.js +3 -7
- package/build/cjs/links/RestAPILink/fetchData.js +12 -22
- package/build/cjs/links/RestAPILink/fetchData.test.js +0 -2
- package/build/cjs/links/RestAPILink/metadataResources.js +9 -7
- package/build/cjs/links/RestAPILink/path.js +0 -3
- package/build/cjs/links/RestAPILink/path.test.js +0 -1
- package/build/cjs/links/RestAPILink/queryToRequestOptions/multipartFormDataMatchers.js +9 -14
- package/build/cjs/links/RestAPILink/queryToRequestOptions/multipartFormDataMatchers.test.js +0 -1
- package/build/cjs/links/RestAPILink/queryToRequestOptions/requestContentType.js +4 -31
- package/build/cjs/links/RestAPILink/queryToRequestOptions/requestContentType.test.js +0 -1
- package/build/cjs/links/RestAPILink/queryToRequestOptions/textPlainMatchers.js +24 -40
- package/build/cjs/links/RestAPILink/queryToRequestOptions/textPlainMatchers.test.js +10 -1
- package/build/cjs/links/RestAPILink/queryToRequestOptions/xWwwFormUrlencodedMatchers.js +0 -2
- package/build/cjs/links/RestAPILink/queryToRequestOptions/xWwwFormUrlencodedMatchers.test.js +0 -1
- package/build/cjs/links/RestAPILink/queryToRequestOptions.js +0 -9
- package/build/cjs/links/RestAPILink/queryToRequestOptions.test.js +0 -1
- package/build/cjs/links/RestAPILink/queryToResourcePath.js +3 -24
- package/build/cjs/links/RestAPILink/queryToResourcePath.test.js +2 -4
- package/build/cjs/links/RestAPILink/validateQuery.js +4 -18
- package/build/cjs/links/RestAPILink/validateQuery.test.js +0 -1
- package/build/cjs/links/RestAPILink.js +3 -14
- package/build/cjs/links/RestAPILink.test.js +0 -2
- package/build/cjs/links/index.js +0 -6
- package/build/cjs/react/components/CustomDataProvider.js +2 -11
- package/build/cjs/react/components/DataMutation.js +1 -4
- package/build/cjs/react/components/DataProvider.js +5 -14
- package/build/cjs/react/components/DataProvider.test.js +2 -9
- package/build/cjs/react/components/DataQuery.js +1 -4
- package/build/cjs/react/context/DataContext.js +2 -8
- package/build/cjs/react/context/defaultContext.js +2 -6
- package/build/cjs/react/context/defaultContext.test.js +0 -1
- package/build/cjs/react/hooks/mergeAndCompareVariables.js +4 -6
- package/build/cjs/react/hooks/mergeAndCompareVariables.test.js +2 -3
- package/build/cjs/react/hooks/stableVariablesHash.js +11 -16
- package/build/cjs/react/hooks/stableVariablesHash.test.js +0 -1
- package/build/cjs/react/hooks/useDataEngine.js +0 -4
- package/build/cjs/react/hooks/useDataMutation.js +0 -7
- package/build/cjs/react/hooks/useDataMutation.test.js +42 -71
- package/build/cjs/react/hooks/useDataQuery.js +11 -22
- package/build/cjs/react/hooks/useDataQuery.test.js +318 -374
- package/build/cjs/react/hooks/useQueryExecutor.js +6 -14
- package/build/cjs/react/hooks/useQueryExecutor.test.js +42 -45
- package/build/cjs/react/hooks/useStaticInput.js +0 -3
- package/build/cjs/react/hooks/useStaticInput.test.js +8 -10
- package/build/cjs/react/index.js +0 -11
- package/build/cjs/setupRTL.js +1 -2
- package/build/es/__tests__/integration.test.js +4 -8
- package/build/es/__tests__/mutations.test.js +2 -4
- package/build/es/engine/DataEngine.js +3 -8
- package/build/es/engine/DataEngine.test.js +0 -1
- package/build/es/engine/helpers/resolveDynamicQuery.test.js +3 -3
- package/build/es/engine/helpers/validate.js +0 -13
- package/build/es/engine/types/FetchError.js +3 -6
- package/build/es/engine/types/InvalidQueryError.js +3 -6
- package/build/es/links/CustomDataLink.js +3 -15
- package/build/es/links/ErrorLink.js +3 -5
- package/build/es/links/RestAPILink/fetchData.js +12 -16
- package/build/es/links/RestAPILink/metadataResources.js +8 -3
- package/build/es/links/RestAPILink/path.js +0 -1
- package/build/es/links/RestAPILink/queryToRequestOptions/multipartFormDataMatchers.js +9 -4
- package/build/es/links/RestAPILink/queryToRequestOptions/requestContentType.js +2 -19
- package/build/es/links/RestAPILink/queryToRequestOptions/textPlainMatchers.js +24 -20
- package/build/es/links/RestAPILink/queryToRequestOptions/textPlainMatchers.test.js +10 -0
- package/build/es/links/RestAPILink/queryToRequestOptions.js +0 -7
- package/build/es/links/RestAPILink/queryToResourcePath.js +3 -21
- package/build/es/links/RestAPILink/queryToResourcePath.test.js +2 -3
- package/build/es/links/RestAPILink/validateQuery.js +4 -16
- package/build/es/links/RestAPILink.js +3 -8
- package/build/es/react/components/CustomDataProvider.js +1 -1
- package/build/es/react/components/DataMutation.js +1 -1
- package/build/es/react/components/DataProvider.js +3 -1
- package/build/es/react/components/DataProvider.test.js +1 -1
- package/build/es/react/components/DataQuery.js +1 -1
- package/build/es/react/hooks/mergeAndCompareVariables.js +4 -3
- package/build/es/react/hooks/mergeAndCompareVariables.test.js +2 -1
- package/build/es/react/hooks/stableVariablesHash.js +11 -14
- package/build/es/react/hooks/useDataMutation.test.js +17 -39
- package/build/es/react/hooks/useDataQuery.js +11 -15
- package/build/es/react/hooks/useDataQuery.test.js +268 -318
- package/build/es/react/hooks/useQueryExecutor.js +6 -9
- package/build/es/react/hooks/useQueryExecutor.test.js +33 -34
- package/build/es/react/hooks/useStaticInput.test.js +6 -6
- package/build/es/setupRTL.js +1 -1
- package/build/types/engine/types/ExecuteOptions.d.ts +1 -1
- package/build/types/engine/types/FetchError.d.ts +2 -2
- package/build/types/engine/types/JsonValue.d.ts +1 -1
- package/build/types/engine/types/Mutation.d.ts +2 -2
- package/build/types/engine/types/PossiblyDynamic.d.ts +1 -1
- package/build/types/engine/types/Query.d.ts +3 -3
- package/build/types/engine/types/QueryParameters.d.ts +4 -4
- package/build/types/links/CustomDataLink.d.ts +2 -2
- package/build/types/links/RestAPILink/queryToRequestOptions/requestContentType.d.ts +1 -1
- package/build/types/links/RestAPILink/queryToRequestOptions.d.ts +1 -1
- package/build/types/react/hooks/mergeAndCompareVariables.d.ts +1 -1
- package/build/types/types.d.ts +6 -6
- package/package.json +4 -4
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState, useCallback, useRef, useEffect } from 'react';
|
|
2
2
|
import { FetchError } from '../../engine';
|
|
3
3
|
import { useStaticInput } from './useStaticInput';
|
|
4
|
-
export const useQueryExecutor =
|
|
4
|
+
export const useQueryExecutor = _ref => {
|
|
5
5
|
let {
|
|
6
6
|
execute,
|
|
7
7
|
variables: initialVariables,
|
|
@@ -38,14 +38,13 @@ export const useQueryExecutor = (_ref) => {
|
|
|
38
38
|
called: true,
|
|
39
39
|
loading: true
|
|
40
40
|
} : state);
|
|
41
|
-
|
|
42
41
|
if (singular) {
|
|
43
42
|
abort(); // Cleanup any in-progress fetches
|
|
44
43
|
}
|
|
45
|
-
|
|
46
44
|
const controller = new AbortController();
|
|
47
45
|
abortControllersRef.current.push(controller);
|
|
48
|
-
variables.current = {
|
|
46
|
+
variables.current = {
|
|
47
|
+
...variables.current,
|
|
49
48
|
...newVariables
|
|
50
49
|
};
|
|
51
50
|
const options = {
|
|
@@ -63,7 +62,6 @@ export const useQueryExecutor = (_ref) => {
|
|
|
63
62
|
});
|
|
64
63
|
return data;
|
|
65
64
|
}
|
|
66
|
-
|
|
67
65
|
return new Promise(() => undefined); // Wait forever
|
|
68
66
|
}).catch(error => {
|
|
69
67
|
if (!controller.signal.aborted) {
|
|
@@ -73,17 +71,16 @@ export const useQueryExecutor = (_ref) => {
|
|
|
73
71
|
error
|
|
74
72
|
});
|
|
75
73
|
}
|
|
76
|
-
|
|
77
74
|
return new Promise(() => undefined); // Don't throw errors in refetch promises, wait forever
|
|
78
75
|
});
|
|
79
|
-
}, [abort, onComplete, onError, singular, theExecute]);
|
|
80
|
-
// may be triggered by changes to input, i.e. recreating the onComplete callback
|
|
76
|
+
}, [abort, onComplete, onError, singular, theExecute]);
|
|
81
77
|
|
|
78
|
+
// Don't include immediate or refetch as deps, otherwise unintentional refetches
|
|
79
|
+
// may be triggered by changes to input, i.e. recreating the onComplete callback
|
|
82
80
|
useEffect(() => {
|
|
83
81
|
if (immediate) {
|
|
84
82
|
refetch();
|
|
85
83
|
}
|
|
86
|
-
|
|
87
84
|
return abort;
|
|
88
85
|
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
89
86
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { renderHook, act } from '@testing-library/react
|
|
1
|
+
import { renderHook, act, waitFor } from '@testing-library/react';
|
|
2
2
|
import { useQueryExecutor } from './useQueryExecutor';
|
|
3
3
|
const testError = new Error('TEST ERROR');
|
|
4
4
|
let theSignal;
|
|
5
|
-
const execute = jest.fn(async
|
|
5
|
+
const execute = jest.fn(async _ref => {
|
|
6
6
|
let {
|
|
7
7
|
signal
|
|
8
8
|
} = _ref;
|
|
@@ -33,8 +33,7 @@ describe('useQueryExecutor', () => {
|
|
|
33
33
|
});
|
|
34
34
|
it('When immediate, should start with called true and loading true', async () => {
|
|
35
35
|
const {
|
|
36
|
-
result
|
|
37
|
-
waitForNextUpdate
|
|
36
|
+
result
|
|
38
37
|
} = renderHook(() => useQueryExecutor({
|
|
39
38
|
execute,
|
|
40
39
|
immediate: true,
|
|
@@ -45,17 +44,17 @@ describe('useQueryExecutor', () => {
|
|
|
45
44
|
called: true,
|
|
46
45
|
loading: true
|
|
47
46
|
});
|
|
48
|
-
await
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
await waitFor(() => {
|
|
48
|
+
expect(result.current).toMatchObject({
|
|
49
|
+
called: true,
|
|
50
|
+
loading: false,
|
|
51
|
+
data: 42
|
|
52
|
+
});
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
55
|
it('Should start when refetch called (if not immediate)', async () => {
|
|
56
56
|
const {
|
|
57
|
-
result
|
|
58
|
-
waitForNextUpdate
|
|
57
|
+
result
|
|
59
58
|
} = renderHook(() => useQueryExecutor({
|
|
60
59
|
execute,
|
|
61
60
|
immediate: false,
|
|
@@ -73,17 +72,17 @@ describe('useQueryExecutor', () => {
|
|
|
73
72
|
called: true,
|
|
74
73
|
loading: true
|
|
75
74
|
});
|
|
76
|
-
await
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
75
|
+
await waitFor(() => {
|
|
76
|
+
expect(result.current).toMatchObject({
|
|
77
|
+
called: true,
|
|
78
|
+
loading: false,
|
|
79
|
+
data: 42
|
|
80
|
+
});
|
|
81
81
|
});
|
|
82
82
|
});
|
|
83
83
|
it('Should report an error when execute fails', async () => {
|
|
84
84
|
const {
|
|
85
|
-
result
|
|
86
|
-
waitForNextUpdate
|
|
85
|
+
result
|
|
87
86
|
} = renderHook(() => useQueryExecutor({
|
|
88
87
|
execute: failingExecute,
|
|
89
88
|
immediate: false,
|
|
@@ -101,19 +100,19 @@ describe('useQueryExecutor', () => {
|
|
|
101
100
|
called: true,
|
|
102
101
|
loading: true
|
|
103
102
|
});
|
|
104
|
-
await
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
await waitFor(() => {
|
|
104
|
+
expect(result.current).toMatchObject({
|
|
105
|
+
called: true,
|
|
106
|
+
loading: false,
|
|
107
|
+
error: testError
|
|
108
|
+
});
|
|
109
109
|
});
|
|
110
110
|
});
|
|
111
111
|
it("Shouldn't abort+refetch when inputs change on subsequent renders", async () => {
|
|
112
112
|
const {
|
|
113
113
|
result,
|
|
114
|
-
waitForNextUpdate,
|
|
115
114
|
rerender
|
|
116
|
-
} = renderHook(
|
|
115
|
+
} = renderHook(_ref2 => {
|
|
117
116
|
let {
|
|
118
117
|
onComplete
|
|
119
118
|
} = _ref2;
|
|
@@ -136,19 +135,19 @@ describe('useQueryExecutor', () => {
|
|
|
136
135
|
rerender({
|
|
137
136
|
onComplete: () => null
|
|
138
137
|
});
|
|
139
|
-
await
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
138
|
+
await waitFor(() => {
|
|
139
|
+
expect(result.current).toMatchObject({
|
|
140
|
+
called: true,
|
|
141
|
+
loading: false,
|
|
142
|
+
data: 42
|
|
143
|
+
});
|
|
144
|
+
expect(theSignal && theSignal.aborted).toBe(false);
|
|
145
|
+
expect(execute).toHaveBeenCalledTimes(1);
|
|
144
146
|
});
|
|
145
|
-
expect(theSignal && theSignal.aborted).toBe(false);
|
|
146
|
-
expect(execute).toHaveBeenCalledTimes(1);
|
|
147
147
|
});
|
|
148
148
|
it('Should respect abort signal', async () => {
|
|
149
149
|
const {
|
|
150
|
-
result
|
|
151
|
-
waitForNextUpdate
|
|
150
|
+
result
|
|
152
151
|
} = renderHook(() => useQueryExecutor({
|
|
153
152
|
execute,
|
|
154
153
|
immediate: false,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { renderHook, act } from '@testing-library/react
|
|
1
|
+
import { renderHook, act } from '@testing-library/react';
|
|
2
2
|
import { useStaticInput } from './useStaticInput';
|
|
3
3
|
describe('useStaticInput', () => {
|
|
4
4
|
const originalWarn = console.warn;
|
|
@@ -19,7 +19,7 @@ describe('useStaticInput', () => {
|
|
|
19
19
|
const {
|
|
20
20
|
result,
|
|
21
21
|
rerender
|
|
22
|
-
} = renderHook(
|
|
22
|
+
} = renderHook(_ref => {
|
|
23
23
|
let {
|
|
24
24
|
value
|
|
25
25
|
} = _ref;
|
|
@@ -40,7 +40,7 @@ describe('useStaticInput', () => {
|
|
|
40
40
|
const {
|
|
41
41
|
result,
|
|
42
42
|
rerender
|
|
43
|
-
} = renderHook(
|
|
43
|
+
} = renderHook(_ref2 => {
|
|
44
44
|
let {
|
|
45
45
|
value
|
|
46
46
|
} = _ref2;
|
|
@@ -68,7 +68,7 @@ describe('useStaticInput', () => {
|
|
|
68
68
|
const {
|
|
69
69
|
result,
|
|
70
70
|
rerender
|
|
71
|
-
} = renderHook(
|
|
71
|
+
} = renderHook(_ref3 => {
|
|
72
72
|
let {
|
|
73
73
|
value
|
|
74
74
|
} = _ref3;
|
|
@@ -93,7 +93,7 @@ describe('useStaticInput', () => {
|
|
|
93
93
|
const {
|
|
94
94
|
result,
|
|
95
95
|
rerender
|
|
96
|
-
} = renderHook(
|
|
96
|
+
} = renderHook(_ref4 => {
|
|
97
97
|
let {
|
|
98
98
|
value
|
|
99
99
|
} = _ref4;
|
|
@@ -129,7 +129,7 @@ describe('useStaticInput', () => {
|
|
|
129
129
|
const {
|
|
130
130
|
result,
|
|
131
131
|
rerender
|
|
132
|
-
} = renderHook(
|
|
132
|
+
} = renderHook(_ref5 => {
|
|
133
133
|
let {
|
|
134
134
|
value
|
|
135
135
|
} = _ref5;
|
package/build/es/setupRTL.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FetchError } from './FetchError';
|
|
2
2
|
import { QueryVariables } from './Query';
|
|
3
|
-
export
|
|
3
|
+
export type FetchType = 'create' | 'read' | 'update' | 'json-patch' | 'replace' | 'delete';
|
|
4
4
|
export interface QueryExecuteOptions {
|
|
5
5
|
variables?: QueryVariables;
|
|
6
6
|
signal?: AbortSignal;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export type FetchErrorTypeName = 'network' | 'unknown' | 'access' | 'aborted';
|
|
2
|
+
export type FetchErrorDetails = {
|
|
3
3
|
httpStatus?: string;
|
|
4
4
|
httpStatusCode?: number;
|
|
5
5
|
status?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FetchError } from './FetchError';
|
|
2
2
|
import { ResourceQuery, QueryVariables } from './Query';
|
|
3
|
-
export
|
|
3
|
+
export type MutationType = 'create' | 'update' | 'json-patch' | 'replace' | 'delete';
|
|
4
4
|
export interface MutationData {
|
|
5
5
|
[key: string]: any;
|
|
6
6
|
}
|
|
@@ -21,7 +21,7 @@ export interface DeleteMutation extends BaseMutation {
|
|
|
21
21
|
type: 'delete';
|
|
22
22
|
id: string;
|
|
23
23
|
}
|
|
24
|
-
export
|
|
24
|
+
export type Mutation = CreateMutation | UpdateMutation | DeleteMutation;
|
|
25
25
|
export interface MutationOptions {
|
|
26
26
|
variables?: QueryVariables;
|
|
27
27
|
onError?: (error: FetchError) => any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type PossiblyDynamic<Type, InputType> = Type | ((input: InputType) => Type);
|
|
@@ -2,7 +2,7 @@ import { FetchError } from './FetchError';
|
|
|
2
2
|
import { JsonMap } from './JsonValue';
|
|
3
3
|
import { PossiblyDynamic } from './PossiblyDynamic';
|
|
4
4
|
import { QueryParameters } from './QueryParameters';
|
|
5
|
-
export
|
|
5
|
+
export type QueryVariables = Record<string, any>;
|
|
6
6
|
export interface ResourceQuery {
|
|
7
7
|
resource: string;
|
|
8
8
|
id?: PossiblyDynamic<string, QueryVariables>;
|
|
@@ -14,8 +14,8 @@ export interface ResolvedResourceQuery extends ResourceQuery {
|
|
|
14
14
|
data?: any;
|
|
15
15
|
params?: QueryParameters;
|
|
16
16
|
}
|
|
17
|
-
export
|
|
18
|
-
export
|
|
17
|
+
export type Query = Record<string, ResourceQuery>;
|
|
18
|
+
export type QueryResult = JsonMap;
|
|
19
19
|
export interface QueryOptions<TQueryResult = QueryResult> {
|
|
20
20
|
variables?: QueryVariables;
|
|
21
21
|
onComplete?: (data: TQueryResult) => void;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
type QueryParameterSingularValue = string | number | boolean;
|
|
2
2
|
interface QueryParameterAliasedValue {
|
|
3
3
|
[name: string]: QueryParameterSingularValue;
|
|
4
4
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
5
|
+
type QueryParameterSingularOrAliasedValue = QueryParameterSingularValue | QueryParameterAliasedValue;
|
|
6
|
+
type QueryParameterMultipleValue = QueryParameterSingularOrAliasedValue[];
|
|
7
|
+
export type QueryParameterValue = QueryParameterSingularValue | QueryParameterAliasedValue | QueryParameterMultipleValue | undefined;
|
|
8
8
|
export interface QueryParameters {
|
|
9
9
|
pageSize?: number;
|
|
10
10
|
[key: string]: QueryParameterValue;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataEngineLink, DataEngineLinkExecuteOptions, FetchType, JsonValue, ResolvedResourceQuery } from '../engine';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type CustomResourceFactory = (type: FetchType, query: ResolvedResourceQuery, options?: DataEngineLinkExecuteOptions) => Promise<JsonValue | undefined>;
|
|
3
|
+
export type CustomResource = JsonValue | CustomResourceFactory;
|
|
4
4
|
export interface CustomData {
|
|
5
5
|
[resourceName: string]: CustomResource;
|
|
6
6
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ResolvedResourceQuery, FetchType } from '../../../engine';
|
|
2
|
-
|
|
2
|
+
type RequestContentType = 'application/json' | 'application/json-patch+json' | 'text/plain' | 'multipart/form-data' | 'application/x-www-form-urlencoded' | null;
|
|
3
3
|
export declare const requestContentType: (type: FetchType, query: ResolvedResourceQuery) => null | RequestContentType;
|
|
4
4
|
export declare const requestHeadersForContentType: (contentType: RequestContentType) => undefined | Record<'Content-Type', string>;
|
|
5
5
|
export declare const requestBodyForContentType: (contentType: RequestContentType, { data }: ResolvedResourceQuery) => undefined | string | FormData | URLSearchParams;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ResolvedResourceQuery, FetchType } from '../../engine';
|
|
2
|
-
export declare const queryToRequestOptions: (type: FetchType, query: ResolvedResourceQuery, signal?: AbortSignal
|
|
2
|
+
export declare const queryToRequestOptions: (type: FetchType, query: ResolvedResourceQuery, signal?: AbortSignal) => RequestInit;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { QueryVariables } from '../../engine';
|
|
2
|
-
export declare const mergeAndCompareVariables: (previousVariables?: QueryVariables
|
|
2
|
+
export declare const mergeAndCompareVariables: (previousVariables?: QueryVariables, newVariables?: QueryVariables, previousHash?: string) => {
|
|
3
3
|
identical: boolean;
|
|
4
4
|
mergedVariablesHash: string | undefined;
|
|
5
5
|
mergedVariables: QueryVariables | undefined;
|
package/build/types/types.d.ts
CHANGED
|
@@ -10,11 +10,11 @@ export interface ContextInput {
|
|
|
10
10
|
baseUrl: string;
|
|
11
11
|
apiVersion: number;
|
|
12
12
|
}
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
16
|
-
export
|
|
17
|
-
export
|
|
13
|
+
export type RefetchOptions = QueryVariables;
|
|
14
|
+
export type RefetchFunction<ReturnType> = (options?: RefetchOptions) => Promise<ReturnType>;
|
|
15
|
+
export type QueryRefetchFunction = RefetchFunction<QueryResult>;
|
|
16
|
+
export type MutationFunction = RefetchFunction<JsonValue>;
|
|
17
|
+
export type ExecuteFunction<T> = (options: QueryExecuteOptions) => Promise<T>;
|
|
18
18
|
export interface ExecuteHookInput<ReturnType> {
|
|
19
19
|
execute: ExecuteFunction<ReturnType>;
|
|
20
20
|
variables: QueryVariables;
|
|
@@ -50,4 +50,4 @@ export interface MutationState {
|
|
|
50
50
|
error?: FetchError;
|
|
51
51
|
data?: JsonValue;
|
|
52
52
|
}
|
|
53
|
-
export
|
|
53
|
+
export type MutationRenderInput = [MutationFunction, MutationState];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2/app-service-data",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.12.0-alpha.1",
|
|
4
4
|
"main": "./build/cjs/index.js",
|
|
5
5
|
"module": "./build/es/index.js",
|
|
6
6
|
"types": "build/types/index.d.ts",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"react-query": "^3.13.11"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@dhis2/app-service-config": "3.
|
|
38
|
+
"@dhis2/app-service-config": "3.12.0-alpha.1",
|
|
39
39
|
"prop-types": "^15.7.2",
|
|
40
|
-
"react": "^16.8",
|
|
41
|
-
"react-dom": "^16.8"
|
|
40
|
+
"react": "^16.8 || ^18",
|
|
41
|
+
"react-dom": "^16.8 || ^18"
|
|
42
42
|
}
|
|
43
43
|
}
|