@dhis2/app-service-data 3.11.3 → 3.12.0-alpha.2

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.
Files changed (113) hide show
  1. package/build/cjs/__tests__/integration.test.js +6 -15
  2. package/build/cjs/__tests__/mutations.test.js +4 -11
  3. package/build/cjs/engine/DataEngine.js +4 -14
  4. package/build/cjs/engine/DataEngine.test.js +0 -2
  5. package/build/cjs/engine/helpers/getMutationFetchType.js +0 -2
  6. package/build/cjs/engine/helpers/getMutationFetchType.test.js +0 -1
  7. package/build/cjs/engine/helpers/resolveDynamicQuery.js +0 -2
  8. package/build/cjs/engine/helpers/resolveDynamicQuery.test.js +3 -4
  9. package/build/cjs/engine/helpers/validate.js +0 -21
  10. package/build/cjs/engine/helpers/validate.test.js +0 -1
  11. package/build/cjs/engine/index.js +0 -18
  12. package/build/cjs/engine/types/FetchError.js +3 -8
  13. package/build/cjs/engine/types/FetchError.test.js +0 -1
  14. package/build/cjs/engine/types/InvalidQueryError.js +3 -8
  15. package/build/cjs/index.js +0 -2
  16. package/build/cjs/links/CustomDataLink.js +3 -17
  17. package/build/cjs/links/CustomDataLink.test.js +0 -1
  18. package/build/cjs/links/ErrorLink.js +3 -7
  19. package/build/cjs/links/RestAPILink/fetchData.js +12 -22
  20. package/build/cjs/links/RestAPILink/fetchData.test.js +0 -2
  21. package/build/cjs/links/RestAPILink/metadataResources.js +9 -7
  22. package/build/cjs/links/RestAPILink/path.js +0 -3
  23. package/build/cjs/links/RestAPILink/path.test.js +0 -1
  24. package/build/cjs/links/RestAPILink/queryToRequestOptions/multipartFormDataMatchers.js +9 -14
  25. package/build/cjs/links/RestAPILink/queryToRequestOptions/multipartFormDataMatchers.test.js +0 -1
  26. package/build/cjs/links/RestAPILink/queryToRequestOptions/requestContentType.js +4 -31
  27. package/build/cjs/links/RestAPILink/queryToRequestOptions/requestContentType.test.js +0 -1
  28. package/build/cjs/links/RestAPILink/queryToRequestOptions/textPlainMatchers.js +22 -39
  29. package/build/cjs/links/RestAPILink/queryToRequestOptions/textPlainMatchers.test.js +0 -1
  30. package/build/cjs/links/RestAPILink/queryToRequestOptions/xWwwFormUrlencodedMatchers.js +0 -2
  31. package/build/cjs/links/RestAPILink/queryToRequestOptions/xWwwFormUrlencodedMatchers.test.js +0 -1
  32. package/build/cjs/links/RestAPILink/queryToRequestOptions.js +0 -9
  33. package/build/cjs/links/RestAPILink/queryToRequestOptions.test.js +0 -1
  34. package/build/cjs/links/RestAPILink/queryToResourcePath.js +3 -24
  35. package/build/cjs/links/RestAPILink/queryToResourcePath.test.js +2 -4
  36. package/build/cjs/links/RestAPILink/validateQuery.js +4 -18
  37. package/build/cjs/links/RestAPILink/validateQuery.test.js +0 -1
  38. package/build/cjs/links/RestAPILink.js +3 -14
  39. package/build/cjs/links/RestAPILink.test.js +0 -2
  40. package/build/cjs/links/index.js +0 -6
  41. package/build/cjs/react/components/CustomDataProvider.js +3 -12
  42. package/build/cjs/react/components/DataMutation.js +1 -4
  43. package/build/cjs/react/components/DataProvider.js +11 -16
  44. package/build/cjs/react/components/DataProvider.test.js +2 -9
  45. package/build/cjs/react/components/DataQuery.js +1 -4
  46. package/build/cjs/react/context/DataContext.js +2 -8
  47. package/build/cjs/react/context/defaultContext.js +2 -6
  48. package/build/cjs/react/context/defaultContext.test.js +0 -1
  49. package/build/cjs/react/hooks/mergeAndCompareVariables.js +4 -6
  50. package/build/cjs/react/hooks/mergeAndCompareVariables.test.js +2 -3
  51. package/build/cjs/react/hooks/stableVariablesHash.js +11 -16
  52. package/build/cjs/react/hooks/stableVariablesHash.test.js +0 -1
  53. package/build/cjs/react/hooks/useDataEngine.js +0 -4
  54. package/build/cjs/react/hooks/useDataMutation.js +0 -7
  55. package/build/cjs/react/hooks/useDataMutation.test.js +42 -71
  56. package/build/cjs/react/hooks/useDataQuery.js +26 -44
  57. package/build/cjs/react/hooks/useDataQuery.test.js +318 -374
  58. package/build/cjs/react/hooks/useQueryExecutor.js +6 -14
  59. package/build/cjs/react/hooks/useQueryExecutor.test.js +42 -45
  60. package/build/cjs/react/hooks/useStaticInput.js +0 -3
  61. package/build/cjs/react/hooks/useStaticInput.test.js +8 -10
  62. package/build/cjs/react/index.js +0 -11
  63. package/build/cjs/setupRTL.js +1 -2
  64. package/build/es/__tests__/integration.test.js +4 -8
  65. package/build/es/__tests__/mutations.test.js +2 -4
  66. package/build/es/engine/DataEngine.js +3 -8
  67. package/build/es/engine/DataEngine.test.js +0 -1
  68. package/build/es/engine/helpers/resolveDynamicQuery.test.js +3 -3
  69. package/build/es/engine/helpers/validate.js +0 -13
  70. package/build/es/engine/types/FetchError.js +3 -6
  71. package/build/es/engine/types/InvalidQueryError.js +3 -6
  72. package/build/es/links/CustomDataLink.js +3 -15
  73. package/build/es/links/ErrorLink.js +3 -5
  74. package/build/es/links/RestAPILink/fetchData.js +12 -16
  75. package/build/es/links/RestAPILink/metadataResources.js +8 -3
  76. package/build/es/links/RestAPILink/path.js +0 -1
  77. package/build/es/links/RestAPILink/queryToRequestOptions/multipartFormDataMatchers.js +9 -4
  78. package/build/es/links/RestAPILink/queryToRequestOptions/requestContentType.js +2 -19
  79. package/build/es/links/RestAPILink/queryToRequestOptions/textPlainMatchers.js +22 -19
  80. package/build/es/links/RestAPILink/queryToRequestOptions.js +0 -7
  81. package/build/es/links/RestAPILink/queryToResourcePath.js +3 -21
  82. package/build/es/links/RestAPILink/queryToResourcePath.test.js +2 -3
  83. package/build/es/links/RestAPILink/validateQuery.js +4 -16
  84. package/build/es/links/RestAPILink.js +3 -8
  85. package/build/es/react/components/CustomDataProvider.js +2 -2
  86. package/build/es/react/components/DataMutation.js +1 -1
  87. package/build/es/react/components/DataProvider.js +9 -3
  88. package/build/es/react/components/DataProvider.test.js +1 -1
  89. package/build/es/react/components/DataQuery.js +1 -1
  90. package/build/es/react/hooks/mergeAndCompareVariables.js +4 -3
  91. package/build/es/react/hooks/mergeAndCompareVariables.test.js +2 -1
  92. package/build/es/react/hooks/stableVariablesHash.js +11 -14
  93. package/build/es/react/hooks/useDataMutation.test.js +17 -39
  94. package/build/es/react/hooks/useDataQuery.js +26 -37
  95. package/build/es/react/hooks/useDataQuery.test.js +268 -318
  96. package/build/es/react/hooks/useQueryExecutor.js +6 -9
  97. package/build/es/react/hooks/useQueryExecutor.test.js +33 -34
  98. package/build/es/react/hooks/useStaticInput.test.js +6 -6
  99. package/build/es/setupRTL.js +1 -1
  100. package/build/types/engine/types/ExecuteOptions.d.ts +1 -1
  101. package/build/types/engine/types/FetchError.d.ts +2 -2
  102. package/build/types/engine/types/JsonValue.d.ts +1 -1
  103. package/build/types/engine/types/Mutation.d.ts +2 -2
  104. package/build/types/engine/types/PossiblyDynamic.d.ts +1 -1
  105. package/build/types/engine/types/Query.d.ts +3 -3
  106. package/build/types/engine/types/QueryParameters.d.ts +4 -4
  107. package/build/types/links/CustomDataLink.d.ts +2 -2
  108. package/build/types/links/RestAPILink/queryToRequestOptions/requestContentType.d.ts +1 -1
  109. package/build/types/links/RestAPILink/queryToRequestOptions.d.ts +1 -1
  110. package/build/types/react/components/DataProvider.d.ts +2 -11
  111. package/build/types/react/hooks/mergeAndCompareVariables.d.ts +1 -1
  112. package/build/types/types.d.ts +6 -6
  113. package/package.json +5 -5
@@ -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 = (_ref) => {
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 = { ...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]); // Don't include immediate or refetch as deps, otherwise unintentional refetches
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-hooks';
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 (_ref) => {
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 waitForNextUpdate();
49
- expect(result.current).toMatchObject({
50
- called: true,
51
- loading: false,
52
- data: 42
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 waitForNextUpdate();
77
- expect(result.current).toMatchObject({
78
- called: true,
79
- loading: false,
80
- data: 42
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 waitForNextUpdate();
105
- expect(result.current).toMatchObject({
106
- called: true,
107
- loading: false,
108
- error: testError
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((_ref2) => {
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 waitForNextUpdate();
140
- expect(result.current).toMatchObject({
141
- called: true,
142
- loading: false,
143
- data: 42
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-hooks';
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((_ref) => {
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((_ref2) => {
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((_ref3) => {
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((_ref4) => {
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((_ref5) => {
132
+ } = renderHook(_ref5 => {
133
133
  let {
134
134
  value
135
135
  } = _ref5;
@@ -1,4 +1,4 @@
1
- import '@testing-library/jest-dom/extend-expect';
1
+ import '@testing-library/jest-dom';
2
2
  process.on('unhandledRejection', err => {
3
3
  throw err;
4
4
  });
@@ -1,6 +1,6 @@
1
1
  import { FetchError } from './FetchError';
2
2
  import { QueryVariables } from './Query';
3
- export declare type FetchType = 'create' | 'read' | 'update' | 'json-patch' | 'replace' | 'delete';
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 declare type FetchErrorTypeName = 'network' | 'unknown' | 'access' | 'aborted';
2
- export declare type FetchErrorDetails = {
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,4 +1,4 @@
1
- export declare type JsonValue = boolean | number | string | null | JsonArray | JsonMap;
1
+ export type JsonValue = boolean | number | string | null | JsonArray | JsonMap;
2
2
  export interface JsonMap {
3
3
  [key: string]: JsonValue;
4
4
  }
@@ -1,6 +1,6 @@
1
1
  import { FetchError } from './FetchError';
2
2
  import { ResourceQuery, QueryVariables } from './Query';
3
- export declare type MutationType = 'create' | 'update' | 'json-patch' | 'replace' | 'delete';
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 declare type Mutation = CreateMutation | UpdateMutation | DeleteMutation;
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 declare type PossiblyDynamic<Type, InputType> = Type | ((input: InputType) => Type);
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 declare type QueryVariables = Record<string, any>;
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 declare type Query = Record<string, ResourceQuery>;
18
- export declare type QueryResult = JsonMap;
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
- declare type QueryParameterSingularValue = string | number | boolean;
1
+ type QueryParameterSingularValue = string | number | boolean;
2
2
  interface QueryParameterAliasedValue {
3
3
  [name: string]: QueryParameterSingularValue;
4
4
  }
5
- declare type QueryParameterSingularOrAliasedValue = QueryParameterSingularValue | QueryParameterAliasedValue;
6
- declare type QueryParameterMultipleValue = QueryParameterSingularOrAliasedValue[];
7
- export declare type QueryParameterValue = QueryParameterSingularValue | QueryParameterAliasedValue | QueryParameterMultipleValue | undefined;
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 declare type CustomResourceFactory = (type: FetchType, query: ResolvedResourceQuery, options?: DataEngineLinkExecuteOptions) => Promise<JsonValue | undefined>;
3
- export declare type CustomResource = JsonValue | CustomResourceFactory;
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
- declare type RequestContentType = 'application/json' | 'application/json-patch+json' | 'text/plain' | 'multipart/form-data' | 'application/x-www-form-urlencoded' | null;
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 | undefined) => RequestInit;
2
+ export declare const queryToRequestOptions: (type: FetchType, query: ResolvedResourceQuery, signal?: AbortSignal) => RequestInit;
@@ -1,18 +1,9 @@
1
+ import { type QueryClientConfig } from '@tanstack/react-query';
1
2
  import React from 'react';
2
3
  export interface ProviderInput {
3
4
  baseUrl?: string;
4
5
  apiVersion?: number;
5
6
  children: React.ReactNode;
6
7
  }
7
- export declare const queryClientOptions: {
8
- defaultOptions: {
9
- queries: {
10
- retry: boolean;
11
- retryOnMount: boolean;
12
- refetchOnMount: boolean;
13
- refetchOnWindowFocus: boolean;
14
- refetchOnReconnect: boolean;
15
- };
16
- };
17
- };
8
+ export declare const queryClientOptions: QueryClientConfig;
18
9
  export declare const DataProvider: (props: ProviderInput) => JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import type { QueryVariables } from '../../engine';
2
- export declare const mergeAndCompareVariables: (previousVariables?: QueryVariables | undefined, newVariables?: QueryVariables | undefined, previousHash?: string | undefined) => {
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;
@@ -10,11 +10,11 @@ export interface ContextInput {
10
10
  baseUrl: string;
11
11
  apiVersion: number;
12
12
  }
13
- export declare type RefetchOptions = QueryVariables;
14
- export declare type RefetchFunction<ReturnType> = (options?: RefetchOptions) => Promise<ReturnType>;
15
- export declare type QueryRefetchFunction = RefetchFunction<QueryResult>;
16
- export declare type MutationFunction = RefetchFunction<JsonValue>;
17
- export declare type ExecuteFunction<T> = (options: QueryExecuteOptions) => Promise<T>;
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 declare type MutationRenderInput = [MutationFunction, MutationState];
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.11.3",
3
+ "version": "3.12.0-alpha.2",
4
4
  "main": "./build/cjs/index.js",
5
5
  "module": "./build/es/index.js",
6
6
  "types": "build/types/index.d.ts",
@@ -32,12 +32,12 @@
32
32
  "coverage": "yarn test --coverage"
33
33
  },
34
34
  "dependencies": {
35
- "react-query": "^3.13.11"
35
+ "@tanstack/react-query": "^4.36.1"
36
36
  },
37
37
  "peerDependencies": {
38
- "@dhis2/app-service-config": "3.11.3",
38
+ "@dhis2/app-service-config": "3.12.0-alpha.2",
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
  }