@tramvai/react-query 2.49.3 → 2.50.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/README.md +10 -9
- package/lib/baseQuery/types.d.ts +11 -3
- package/lib/index.es.js +59 -40
- package/lib/index.js +64 -46
- package/lib/infiniteQuery/create.d.ts +2 -1
- package/lib/infiniteQuery/types.d.ts +9 -5
- package/lib/infiniteQuery/use.d.ts +3 -2
- package/lib/mutation/create.d.ts +2 -1
- package/lib/mutation/mutation.test-types.d.ts +1 -0
- package/lib/mutation/types.d.ts +17 -7
- package/lib/mutation/use.d.ts +5 -4
- package/lib/query/create.d.ts +2 -1
- package/lib/query/types.d.ts +9 -5
- package/lib/query/use.d.ts +4 -3
- package/lib/shared/resolveDI.d.ts +3 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -92,15 +92,16 @@ As a parameter `key` you can use:
|
|
|
92
92
|
|
|
93
93
|
- a string, such as `key: 'query-name'`
|
|
94
94
|
- an array where any serializable data can be used as elements, for example `key: ['query-name', false, { bar: 'baz }]`
|
|
95
|
-
- a function that takes the parameters with which `query` is called and returns a string - `key: (options) => 'query-name'`
|
|
96
|
-
- a function that accepts parameters, with which `query` is called, and returns an array, where any serializable data can be used as elements - `key: (options) => ['query-name', options, { bar: 'baz' }]`
|
|
95
|
+
- a function that takes the parameters with which `query` is called and returns a string - `key: (this: { deps }, options) => 'query-name'`. Where through `this.deps` you can get resolved deps for the query.
|
|
96
|
+
- a function that accepts parameters, with which `query` is called, and returns an array, where any serializable data can be used as elements - `key: (this: { deps }, options) => ['query-name', options, { bar: 'baz' }]`
|
|
97
97
|
|
|
98
98
|
```ts
|
|
99
99
|
import { createQuery, useQuery } from '@tramvai/react-query';
|
|
100
100
|
|
|
101
101
|
const query = createQuery({
|
|
102
102
|
key: (id: number) => ['user', id],
|
|
103
|
-
|
|
103
|
+
async fn(id) {
|
|
104
|
+
const { apiClient } = this.deps;
|
|
104
105
|
const { payload } = await apiClient.get(`api/user/${id}`);
|
|
105
106
|
|
|
106
107
|
return payload;
|
|
@@ -143,10 +144,8 @@ React Hook for working with the list of `Query` objects
|
|
|
143
144
|
import { useQueries } from '@tramvai/react-query';
|
|
144
145
|
|
|
145
146
|
export function Component() {
|
|
146
|
-
const [
|
|
147
|
-
|
|
148
|
-
{ data: data2, isLoading: isLoading2 },
|
|
149
|
-
] = useQueries([query1, query2]);
|
|
147
|
+
const [{ data: data1, isLoading: isLoading1 }, { data: data2, isLoading: isLoading2 }] =
|
|
148
|
+
useQueries([query1, query2]);
|
|
150
149
|
|
|
151
150
|
return (
|
|
152
151
|
<div>
|
|
@@ -166,7 +165,8 @@ import { createInfiniteQuery } from '@tramvai/react-query';
|
|
|
166
165
|
|
|
167
166
|
const query = createInfiniteQuery({
|
|
168
167
|
key: 'list',
|
|
169
|
-
|
|
168
|
+
async fn(_, start = 0) {
|
|
169
|
+
const { apiClient } = this.deps;
|
|
170
170
|
const { payload } = await apiClient.get<Response>('api/list', {
|
|
171
171
|
query: {
|
|
172
172
|
count: 30,
|
|
@@ -229,7 +229,8 @@ import { createMutation } from '@tramvai/react-query';
|
|
|
229
229
|
|
|
230
230
|
const mutation = createMutation({
|
|
231
231
|
key: 'post',
|
|
232
|
-
|
|
232
|
+
async fn(_, data: string) {
|
|
233
|
+
const { apiClient } = this.deps;
|
|
233
234
|
const { payload } = await apiClient.post('api/post', {
|
|
234
235
|
body: {
|
|
235
236
|
data,
|
package/lib/baseQuery/types.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type { ActionConditionsParameters, ActionContext, TramvaiAction } from '@tramvai/core';
|
|
2
2
|
import type { QueryKey as ReactQueryKey, QueryOptions } from '@tanstack/react-query';
|
|
3
|
+
import type { Container, ProvideDepsIterator, ProviderDeps } from '@tinkoff/dippy';
|
|
3
4
|
export declare const QUERY_PARAMETERS = "__query_parameters__";
|
|
5
|
+
export interface ReactQueryContext<Deps extends ProviderDeps> {
|
|
6
|
+
deps: ProvideDepsIterator<Deps>;
|
|
7
|
+
}
|
|
4
8
|
export type ReactQueryKeyOrString = ReactQueryKey | string;
|
|
5
|
-
export type QueryKey<Options> = ((options: Options) => ReactQueryKeyOrString) | ReactQueryKeyOrString;
|
|
6
|
-
export interface BaseCreateQueryOptions<Options, Deps> {
|
|
7
|
-
key: QueryKey<Options>;
|
|
9
|
+
export type QueryKey<Options, Deps extends ProviderDeps> = ((this: ReactQueryContext<Deps>, options: Options) => ReactQueryKeyOrString) | ReactQueryKeyOrString;
|
|
10
|
+
export interface BaseCreateQueryOptions<Options, Deps extends ProviderDeps> {
|
|
11
|
+
key: QueryKey<Options, Deps>;
|
|
8
12
|
fn: Function;
|
|
9
13
|
deps?: Deps;
|
|
10
14
|
conditions?: ActionConditionsParameters;
|
|
@@ -12,6 +16,10 @@ export interface BaseCreateQueryOptions<Options, Deps> {
|
|
|
12
16
|
export interface BaseQuery<Options, TCreateQuery, TQuery, TUseQuery> {
|
|
13
17
|
[QUERY_PARAMETERS]: TCreateQuery;
|
|
14
18
|
fork(options: TUseQuery): TQuery;
|
|
19
|
+
raw(di: Container, options?: Options): TUseQuery;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated pass di as first parameter instead of context
|
|
22
|
+
*/
|
|
15
23
|
raw(context: ActionContext, options?: Options): TUseQuery;
|
|
16
24
|
prefetchAction(options?: Options): TramvaiAction<[], Promise<void>, any>;
|
|
17
25
|
}
|
package/lib/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import identity from '@tinkoff/utils/function/identity';
|
|
2
|
-
import
|
|
2
|
+
import { Container, DI_TOKEN } from '@tinkoff/dippy';
|
|
3
3
|
import { declareAction } from '@tramvai/core';
|
|
4
4
|
import { QUERY_CLIENT_TOKEN } from '@tramvai/module-react-query';
|
|
5
5
|
import { CONTEXT_TOKEN } from '@tramvai/tokens-common';
|
|
@@ -7,8 +7,8 @@ import isArray from '@tinkoff/utils/is/array';
|
|
|
7
7
|
import { useMemo } from 'react';
|
|
8
8
|
import { useQuery as useQuery$1, useQueries as useQueries$1, useInfiniteQuery as useInfiniteQuery$1, useMutation as useMutation$1 } from '@tanstack/react-query';
|
|
9
9
|
export { useQueryClient } from '@tanstack/react-query';
|
|
10
|
-
import { useConsumerContext } from '@tramvai/state';
|
|
11
10
|
import { useShallowEqual } from '@tinkoff/react-hooks';
|
|
11
|
+
import { useDiContainer } from '@tramvai/react';
|
|
12
12
|
|
|
13
13
|
const QUERY_PARAMETERS = '__query_parameters__';
|
|
14
14
|
const isQuery = (arg) => {
|
|
@@ -22,13 +22,23 @@ const normalizeKey = (key) => {
|
|
|
22
22
|
return [key];
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
// @TODO: v3: leave only di container in next major
|
|
26
|
+
const resolveDI = (diOrContext) => {
|
|
27
|
+
return diOrContext instanceof Container
|
|
28
|
+
? diOrContext
|
|
29
|
+
: diOrContext.di;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const convertToRawQuery$1 = (query, di, options) => {
|
|
33
|
+
const { key = identity, fn, deps = {}, conditions, queryOptions } = query[QUERY_PARAMETERS];
|
|
34
|
+
const resolvedDeps = di.getOfDeps(deps);
|
|
35
|
+
const ctx = { deps: resolvedDeps };
|
|
36
|
+
const rawQueryKey = typeof key === 'function' ? key.call(ctx, options) : key;
|
|
37
|
+
const queryKey = normalizeKey(rawQueryKey);
|
|
28
38
|
const actionWrapper = declareAction({
|
|
29
39
|
name: 'queryExecution',
|
|
30
40
|
async fn() {
|
|
31
|
-
return fn(options,
|
|
41
|
+
return fn.call(ctx, options, ctx.deps);
|
|
32
42
|
},
|
|
33
43
|
deps,
|
|
34
44
|
conditions,
|
|
@@ -41,6 +51,7 @@ const convertToRawQuery$1 = (query, context, options) => {
|
|
|
41
51
|
conditions,
|
|
42
52
|
},
|
|
43
53
|
queryFn: () => {
|
|
54
|
+
const context = di.get(CONTEXT_TOKEN);
|
|
44
55
|
return context.executeAction(actionWrapper);
|
|
45
56
|
},
|
|
46
57
|
};
|
|
@@ -58,17 +69,17 @@ const createQuery = (queryParameters) => {
|
|
|
58
69
|
},
|
|
59
70
|
});
|
|
60
71
|
},
|
|
61
|
-
raw: (
|
|
62
|
-
return convertToRawQuery$1(query,
|
|
72
|
+
raw: (diOrContext, options) => {
|
|
73
|
+
return convertToRawQuery$1(query, resolveDI(diOrContext), options);
|
|
63
74
|
},
|
|
64
75
|
prefetchAction: (options) => {
|
|
65
76
|
return declareAction({
|
|
66
77
|
name: 'queryPrefetch',
|
|
67
78
|
fn() {
|
|
68
|
-
return this.deps.queryClient.prefetchQuery(convertToRawQuery$1(query, this.deps.
|
|
79
|
+
return this.deps.queryClient.prefetchQuery(convertToRawQuery$1(query, this.deps.di, options));
|
|
69
80
|
},
|
|
70
81
|
deps: {
|
|
71
|
-
|
|
82
|
+
di: DI_TOKEN,
|
|
72
83
|
queryClient: QUERY_CLIENT_TOKEN,
|
|
73
84
|
},
|
|
74
85
|
conditions,
|
|
@@ -78,10 +89,10 @@ const createQuery = (queryParameters) => {
|
|
|
78
89
|
return declareAction({
|
|
79
90
|
name: 'queryFetch',
|
|
80
91
|
fn() {
|
|
81
|
-
return this.deps.queryClient.fetchQuery(convertToRawQuery$1(query, this.deps.
|
|
92
|
+
return this.deps.queryClient.fetchQuery(convertToRawQuery$1(query, this.deps.di, options));
|
|
82
93
|
},
|
|
83
94
|
deps: {
|
|
84
|
-
|
|
95
|
+
di: DI_TOKEN,
|
|
85
96
|
queryClient: QUERY_CLIENT_TOKEN,
|
|
86
97
|
},
|
|
87
98
|
conditions,
|
|
@@ -92,36 +103,39 @@ const createQuery = (queryParameters) => {
|
|
|
92
103
|
};
|
|
93
104
|
|
|
94
105
|
function useQuery(query, options) {
|
|
95
|
-
const
|
|
106
|
+
const di = useDiContainer();
|
|
96
107
|
const resultQuery = useMemo(() => {
|
|
97
108
|
if (isQuery(query)) {
|
|
98
|
-
return query.raw(
|
|
109
|
+
return query.raw(di, options);
|
|
99
110
|
}
|
|
100
111
|
return query;
|
|
101
|
-
}, [query,
|
|
112
|
+
}, [query, di, options]);
|
|
102
113
|
return useQuery$1(resultQuery);
|
|
103
114
|
}
|
|
104
115
|
function useQueries(queries) {
|
|
105
|
-
const
|
|
116
|
+
const di = useDiContainer();
|
|
106
117
|
const memoQueries = useShallowEqual(queries);
|
|
107
118
|
const resultQueries = useMemo(() => {
|
|
108
119
|
return memoQueries.map((query) => {
|
|
109
120
|
if (isQuery(query)) {
|
|
110
|
-
return query.raw(
|
|
121
|
+
return query.raw(di);
|
|
111
122
|
}
|
|
112
123
|
return query;
|
|
113
124
|
});
|
|
114
|
-
}, [memoQueries,
|
|
125
|
+
}, [memoQueries, di]);
|
|
115
126
|
return useQueries$1({ queries: resultQueries });
|
|
116
127
|
}
|
|
117
128
|
|
|
118
|
-
const convertToRawQuery = (query,
|
|
119
|
-
const { key = identity, fn, getNextPageParam, getPreviousPageParam, deps, conditions, infiniteQueryOptions, } = query[QUERY_PARAMETERS];
|
|
120
|
-
const
|
|
129
|
+
const convertToRawQuery = (query, di, options) => {
|
|
130
|
+
const { key = identity, fn, getNextPageParam, getPreviousPageParam, deps = {}, conditions, infiniteQueryOptions, } = query[QUERY_PARAMETERS];
|
|
131
|
+
const resolvedDeps = di.getOfDeps(deps);
|
|
132
|
+
const ctx = { deps: resolvedDeps };
|
|
133
|
+
const rawQueryKey = typeof key === 'function' ? key.call(ctx, options) : key;
|
|
134
|
+
const queryKey = normalizeKey(rawQueryKey);
|
|
121
135
|
const actionWrapper = declareAction({
|
|
122
136
|
name: 'infiniteQueryExecution',
|
|
123
137
|
async fn(pageParam) {
|
|
124
|
-
return fn(options, pageParam,
|
|
138
|
+
return fn.call(ctx, options, pageParam, ctx.deps);
|
|
125
139
|
},
|
|
126
140
|
conditionsFailResult: 'reject',
|
|
127
141
|
deps,
|
|
@@ -136,6 +150,7 @@ const convertToRawQuery = (query, context, options) => {
|
|
|
136
150
|
conditions,
|
|
137
151
|
},
|
|
138
152
|
queryFn: ({ pageParam }) => {
|
|
153
|
+
const context = di.get(CONTEXT_TOKEN);
|
|
139
154
|
return context.executeAction(actionWrapper, pageParam);
|
|
140
155
|
},
|
|
141
156
|
};
|
|
@@ -153,17 +168,17 @@ const createInfiniteQuery = (queryParameters) => {
|
|
|
153
168
|
},
|
|
154
169
|
});
|
|
155
170
|
},
|
|
156
|
-
raw: (
|
|
157
|
-
return convertToRawQuery(query,
|
|
171
|
+
raw: (diOrContext, options) => {
|
|
172
|
+
return convertToRawQuery(query, resolveDI(diOrContext), options);
|
|
158
173
|
},
|
|
159
174
|
prefetchAction: (options) => {
|
|
160
175
|
return declareAction({
|
|
161
176
|
name: 'infiniteQueryPrefetch',
|
|
162
177
|
fn() {
|
|
163
|
-
return this.deps.queryClient.prefetchInfiniteQuery(convertToRawQuery(query, this.deps.
|
|
178
|
+
return this.deps.queryClient.prefetchInfiniteQuery(convertToRawQuery(query, this.deps.di, options));
|
|
164
179
|
},
|
|
165
180
|
deps: {
|
|
166
|
-
|
|
181
|
+
di: DI_TOKEN,
|
|
167
182
|
queryClient: QUERY_CLIENT_TOKEN,
|
|
168
183
|
},
|
|
169
184
|
conditions,
|
|
@@ -173,10 +188,10 @@ const createInfiniteQuery = (queryParameters) => {
|
|
|
173
188
|
return declareAction({
|
|
174
189
|
name: 'infiniteQueryFetch',
|
|
175
190
|
fn() {
|
|
176
|
-
return this.deps.queryClient.fetchInfiniteQuery(convertToRawQuery(query, this.deps.
|
|
191
|
+
return this.deps.queryClient.fetchInfiniteQuery(convertToRawQuery(query, this.deps.di, options));
|
|
177
192
|
},
|
|
178
193
|
deps: {
|
|
179
|
-
|
|
194
|
+
di: DI_TOKEN,
|
|
180
195
|
queryClient: QUERY_CLIENT_TOKEN,
|
|
181
196
|
},
|
|
182
197
|
conditions,
|
|
@@ -187,13 +202,13 @@ const createInfiniteQuery = (queryParameters) => {
|
|
|
187
202
|
};
|
|
188
203
|
|
|
189
204
|
function useInfiniteQuery(query, options) {
|
|
190
|
-
const
|
|
205
|
+
const di = useDiContainer();
|
|
191
206
|
const resultQuery = useMemo(() => {
|
|
192
207
|
if (isQuery(query)) {
|
|
193
|
-
return query.raw(
|
|
208
|
+
return query.raw(di, options);
|
|
194
209
|
}
|
|
195
210
|
return query;
|
|
196
|
-
}, [query,
|
|
211
|
+
}, [query, di, options]);
|
|
197
212
|
return useInfiniteQuery$1(resultQuery);
|
|
198
213
|
}
|
|
199
214
|
|
|
@@ -202,13 +217,16 @@ const isMutation = (arg) => {
|
|
|
202
217
|
return MUTATION_PARAMETERS in arg;
|
|
203
218
|
};
|
|
204
219
|
|
|
205
|
-
const convertToRawMutation = (mutation,
|
|
206
|
-
const { key = identity, fn, deps, conditions, mutationOptions } = mutation[MUTATION_PARAMETERS];
|
|
207
|
-
const
|
|
220
|
+
const convertToRawMutation = (mutation, di, options) => {
|
|
221
|
+
const { key = identity, fn, deps = {}, conditions, mutationOptions, } = mutation[MUTATION_PARAMETERS];
|
|
222
|
+
const resolvedDeps = di.getOfDeps(deps);
|
|
223
|
+
const ctx = { deps: resolvedDeps };
|
|
224
|
+
const rawMutationKey = typeof key === 'function' ? key.call(ctx, options) : key;
|
|
225
|
+
const mutationKey = normalizeKey(rawMutationKey);
|
|
208
226
|
const actionWrapper = declareAction({
|
|
209
227
|
name: 'mutationExecution',
|
|
210
228
|
async fn(variables) {
|
|
211
|
-
return fn(options, variables,
|
|
229
|
+
return fn.call(ctx, options, variables, ctx.deps);
|
|
212
230
|
},
|
|
213
231
|
deps,
|
|
214
232
|
conditions,
|
|
@@ -218,6 +236,7 @@ const convertToRawMutation = (mutation, context, options) => {
|
|
|
218
236
|
...mutationOptions,
|
|
219
237
|
mutationKey,
|
|
220
238
|
mutationFn: (variables) => {
|
|
239
|
+
const context = di.get(CONTEXT_TOKEN);
|
|
221
240
|
return context.executeAction(actionWrapper, variables);
|
|
222
241
|
},
|
|
223
242
|
};
|
|
@@ -235,21 +254,21 @@ const createMutation = (mutationParameters) => {
|
|
|
235
254
|
},
|
|
236
255
|
});
|
|
237
256
|
},
|
|
238
|
-
raw: (
|
|
239
|
-
return convertToRawMutation(mutation,
|
|
257
|
+
raw: (diOrContext, options) => {
|
|
258
|
+
return convertToRawMutation(mutation, resolveDI(diOrContext), options);
|
|
240
259
|
},
|
|
241
260
|
};
|
|
242
261
|
return mutation;
|
|
243
262
|
};
|
|
244
263
|
|
|
245
264
|
const useMutation = (mutation, options) => {
|
|
246
|
-
const
|
|
265
|
+
const di = useDiContainer();
|
|
247
266
|
const resultMutation = useMemo(() => {
|
|
248
267
|
if (isMutation(mutation)) {
|
|
249
|
-
return mutation.raw(
|
|
268
|
+
return mutation.raw(di, options);
|
|
250
269
|
}
|
|
251
270
|
return mutation;
|
|
252
|
-
}, [mutation,
|
|
271
|
+
}, [mutation, di, options]);
|
|
253
272
|
return useMutation$1(resultMutation);
|
|
254
273
|
};
|
|
255
274
|
|
package/lib/index.js
CHANGED
|
@@ -3,20 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var identity = require('@tinkoff/utils/function/identity');
|
|
6
|
-
var
|
|
6
|
+
var dippy = require('@tinkoff/dippy');
|
|
7
7
|
var core = require('@tramvai/core');
|
|
8
8
|
var moduleReactQuery = require('@tramvai/module-react-query');
|
|
9
9
|
var tokensCommon = require('@tramvai/tokens-common');
|
|
10
10
|
var isArray = require('@tinkoff/utils/is/array');
|
|
11
|
-
var react = require('react');
|
|
11
|
+
var react$1 = require('react');
|
|
12
12
|
var reactQuery = require('@tanstack/react-query');
|
|
13
|
-
var state = require('@tramvai/state');
|
|
14
13
|
var reactHooks = require('@tinkoff/react-hooks');
|
|
14
|
+
var react = require('@tramvai/react');
|
|
15
15
|
|
|
16
16
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
17
|
|
|
18
18
|
var identity__default = /*#__PURE__*/_interopDefaultLegacy(identity);
|
|
19
|
-
var applyOrReturn__default = /*#__PURE__*/_interopDefaultLegacy(applyOrReturn);
|
|
20
19
|
var isArray__default = /*#__PURE__*/_interopDefaultLegacy(isArray);
|
|
21
20
|
|
|
22
21
|
const QUERY_PARAMETERS = '__query_parameters__';
|
|
@@ -31,13 +30,23 @@ const normalizeKey = (key) => {
|
|
|
31
30
|
return [key];
|
|
32
31
|
};
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
// @TODO: v3: leave only di container in next major
|
|
34
|
+
const resolveDI = (diOrContext) => {
|
|
35
|
+
return diOrContext instanceof dippy.Container
|
|
36
|
+
? diOrContext
|
|
37
|
+
: diOrContext.di;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const convertToRawQuery$1 = (query, di, options) => {
|
|
41
|
+
const { key = identity__default["default"], fn, deps = {}, conditions, queryOptions } = query[QUERY_PARAMETERS];
|
|
42
|
+
const resolvedDeps = di.getOfDeps(deps);
|
|
43
|
+
const ctx = { deps: resolvedDeps };
|
|
44
|
+
const rawQueryKey = typeof key === 'function' ? key.call(ctx, options) : key;
|
|
45
|
+
const queryKey = normalizeKey(rawQueryKey);
|
|
37
46
|
const actionWrapper = core.declareAction({
|
|
38
47
|
name: 'queryExecution',
|
|
39
48
|
async fn() {
|
|
40
|
-
return fn(options,
|
|
49
|
+
return fn.call(ctx, options, ctx.deps);
|
|
41
50
|
},
|
|
42
51
|
deps,
|
|
43
52
|
conditions,
|
|
@@ -50,6 +59,7 @@ const convertToRawQuery$1 = (query, context, options) => {
|
|
|
50
59
|
conditions,
|
|
51
60
|
},
|
|
52
61
|
queryFn: () => {
|
|
62
|
+
const context = di.get(tokensCommon.CONTEXT_TOKEN);
|
|
53
63
|
return context.executeAction(actionWrapper);
|
|
54
64
|
},
|
|
55
65
|
};
|
|
@@ -67,17 +77,17 @@ const createQuery = (queryParameters) => {
|
|
|
67
77
|
},
|
|
68
78
|
});
|
|
69
79
|
},
|
|
70
|
-
raw: (
|
|
71
|
-
return convertToRawQuery$1(query,
|
|
80
|
+
raw: (diOrContext, options) => {
|
|
81
|
+
return convertToRawQuery$1(query, resolveDI(diOrContext), options);
|
|
72
82
|
},
|
|
73
83
|
prefetchAction: (options) => {
|
|
74
84
|
return core.declareAction({
|
|
75
85
|
name: 'queryPrefetch',
|
|
76
86
|
fn() {
|
|
77
|
-
return this.deps.queryClient.prefetchQuery(convertToRawQuery$1(query, this.deps.
|
|
87
|
+
return this.deps.queryClient.prefetchQuery(convertToRawQuery$1(query, this.deps.di, options));
|
|
78
88
|
},
|
|
79
89
|
deps: {
|
|
80
|
-
|
|
90
|
+
di: dippy.DI_TOKEN,
|
|
81
91
|
queryClient: moduleReactQuery.QUERY_CLIENT_TOKEN,
|
|
82
92
|
},
|
|
83
93
|
conditions,
|
|
@@ -87,10 +97,10 @@ const createQuery = (queryParameters) => {
|
|
|
87
97
|
return core.declareAction({
|
|
88
98
|
name: 'queryFetch',
|
|
89
99
|
fn() {
|
|
90
|
-
return this.deps.queryClient.fetchQuery(convertToRawQuery$1(query, this.deps.
|
|
100
|
+
return this.deps.queryClient.fetchQuery(convertToRawQuery$1(query, this.deps.di, options));
|
|
91
101
|
},
|
|
92
102
|
deps: {
|
|
93
|
-
|
|
103
|
+
di: dippy.DI_TOKEN,
|
|
94
104
|
queryClient: moduleReactQuery.QUERY_CLIENT_TOKEN,
|
|
95
105
|
},
|
|
96
106
|
conditions,
|
|
@@ -101,36 +111,39 @@ const createQuery = (queryParameters) => {
|
|
|
101
111
|
};
|
|
102
112
|
|
|
103
113
|
function useQuery(query, options) {
|
|
104
|
-
const
|
|
105
|
-
const resultQuery = react.useMemo(() => {
|
|
114
|
+
const di = react.useDiContainer();
|
|
115
|
+
const resultQuery = react$1.useMemo(() => {
|
|
106
116
|
if (isQuery(query)) {
|
|
107
|
-
return query.raw(
|
|
117
|
+
return query.raw(di, options);
|
|
108
118
|
}
|
|
109
119
|
return query;
|
|
110
|
-
}, [query,
|
|
120
|
+
}, [query, di, options]);
|
|
111
121
|
return reactQuery.useQuery(resultQuery);
|
|
112
122
|
}
|
|
113
123
|
function useQueries(queries) {
|
|
114
|
-
const
|
|
124
|
+
const di = react.useDiContainer();
|
|
115
125
|
const memoQueries = reactHooks.useShallowEqual(queries);
|
|
116
|
-
const resultQueries = react.useMemo(() => {
|
|
126
|
+
const resultQueries = react$1.useMemo(() => {
|
|
117
127
|
return memoQueries.map((query) => {
|
|
118
128
|
if (isQuery(query)) {
|
|
119
|
-
return query.raw(
|
|
129
|
+
return query.raw(di);
|
|
120
130
|
}
|
|
121
131
|
return query;
|
|
122
132
|
});
|
|
123
|
-
}, [memoQueries,
|
|
133
|
+
}, [memoQueries, di]);
|
|
124
134
|
return reactQuery.useQueries({ queries: resultQueries });
|
|
125
135
|
}
|
|
126
136
|
|
|
127
|
-
const convertToRawQuery = (query,
|
|
128
|
-
const { key = identity__default["default"], fn, getNextPageParam, getPreviousPageParam, deps, conditions, infiniteQueryOptions, } = query[QUERY_PARAMETERS];
|
|
129
|
-
const
|
|
137
|
+
const convertToRawQuery = (query, di, options) => {
|
|
138
|
+
const { key = identity__default["default"], fn, getNextPageParam, getPreviousPageParam, deps = {}, conditions, infiniteQueryOptions, } = query[QUERY_PARAMETERS];
|
|
139
|
+
const resolvedDeps = di.getOfDeps(deps);
|
|
140
|
+
const ctx = { deps: resolvedDeps };
|
|
141
|
+
const rawQueryKey = typeof key === 'function' ? key.call(ctx, options) : key;
|
|
142
|
+
const queryKey = normalizeKey(rawQueryKey);
|
|
130
143
|
const actionWrapper = core.declareAction({
|
|
131
144
|
name: 'infiniteQueryExecution',
|
|
132
145
|
async fn(pageParam) {
|
|
133
|
-
return fn(options, pageParam,
|
|
146
|
+
return fn.call(ctx, options, pageParam, ctx.deps);
|
|
134
147
|
},
|
|
135
148
|
conditionsFailResult: 'reject',
|
|
136
149
|
deps,
|
|
@@ -145,6 +158,7 @@ const convertToRawQuery = (query, context, options) => {
|
|
|
145
158
|
conditions,
|
|
146
159
|
},
|
|
147
160
|
queryFn: ({ pageParam }) => {
|
|
161
|
+
const context = di.get(tokensCommon.CONTEXT_TOKEN);
|
|
148
162
|
return context.executeAction(actionWrapper, pageParam);
|
|
149
163
|
},
|
|
150
164
|
};
|
|
@@ -162,17 +176,17 @@ const createInfiniteQuery = (queryParameters) => {
|
|
|
162
176
|
},
|
|
163
177
|
});
|
|
164
178
|
},
|
|
165
|
-
raw: (
|
|
166
|
-
return convertToRawQuery(query,
|
|
179
|
+
raw: (diOrContext, options) => {
|
|
180
|
+
return convertToRawQuery(query, resolveDI(diOrContext), options);
|
|
167
181
|
},
|
|
168
182
|
prefetchAction: (options) => {
|
|
169
183
|
return core.declareAction({
|
|
170
184
|
name: 'infiniteQueryPrefetch',
|
|
171
185
|
fn() {
|
|
172
|
-
return this.deps.queryClient.prefetchInfiniteQuery(convertToRawQuery(query, this.deps.
|
|
186
|
+
return this.deps.queryClient.prefetchInfiniteQuery(convertToRawQuery(query, this.deps.di, options));
|
|
173
187
|
},
|
|
174
188
|
deps: {
|
|
175
|
-
|
|
189
|
+
di: dippy.DI_TOKEN,
|
|
176
190
|
queryClient: moduleReactQuery.QUERY_CLIENT_TOKEN,
|
|
177
191
|
},
|
|
178
192
|
conditions,
|
|
@@ -182,10 +196,10 @@ const createInfiniteQuery = (queryParameters) => {
|
|
|
182
196
|
return core.declareAction({
|
|
183
197
|
name: 'infiniteQueryFetch',
|
|
184
198
|
fn() {
|
|
185
|
-
return this.deps.queryClient.fetchInfiniteQuery(convertToRawQuery(query, this.deps.
|
|
199
|
+
return this.deps.queryClient.fetchInfiniteQuery(convertToRawQuery(query, this.deps.di, options));
|
|
186
200
|
},
|
|
187
201
|
deps: {
|
|
188
|
-
|
|
202
|
+
di: dippy.DI_TOKEN,
|
|
189
203
|
queryClient: moduleReactQuery.QUERY_CLIENT_TOKEN,
|
|
190
204
|
},
|
|
191
205
|
conditions,
|
|
@@ -196,13 +210,13 @@ const createInfiniteQuery = (queryParameters) => {
|
|
|
196
210
|
};
|
|
197
211
|
|
|
198
212
|
function useInfiniteQuery(query, options) {
|
|
199
|
-
const
|
|
200
|
-
const resultQuery = react.useMemo(() => {
|
|
213
|
+
const di = react.useDiContainer();
|
|
214
|
+
const resultQuery = react$1.useMemo(() => {
|
|
201
215
|
if (isQuery(query)) {
|
|
202
|
-
return query.raw(
|
|
216
|
+
return query.raw(di, options);
|
|
203
217
|
}
|
|
204
218
|
return query;
|
|
205
|
-
}, [query,
|
|
219
|
+
}, [query, di, options]);
|
|
206
220
|
return reactQuery.useInfiniteQuery(resultQuery);
|
|
207
221
|
}
|
|
208
222
|
|
|
@@ -211,13 +225,16 @@ const isMutation = (arg) => {
|
|
|
211
225
|
return MUTATION_PARAMETERS in arg;
|
|
212
226
|
};
|
|
213
227
|
|
|
214
|
-
const convertToRawMutation = (mutation,
|
|
215
|
-
const { key = identity__default["default"], fn, deps, conditions, mutationOptions } = mutation[MUTATION_PARAMETERS];
|
|
216
|
-
const
|
|
228
|
+
const convertToRawMutation = (mutation, di, options) => {
|
|
229
|
+
const { key = identity__default["default"], fn, deps = {}, conditions, mutationOptions, } = mutation[MUTATION_PARAMETERS];
|
|
230
|
+
const resolvedDeps = di.getOfDeps(deps);
|
|
231
|
+
const ctx = { deps: resolvedDeps };
|
|
232
|
+
const rawMutationKey = typeof key === 'function' ? key.call(ctx, options) : key;
|
|
233
|
+
const mutationKey = normalizeKey(rawMutationKey);
|
|
217
234
|
const actionWrapper = core.declareAction({
|
|
218
235
|
name: 'mutationExecution',
|
|
219
236
|
async fn(variables) {
|
|
220
|
-
return fn(options, variables,
|
|
237
|
+
return fn.call(ctx, options, variables, ctx.deps);
|
|
221
238
|
},
|
|
222
239
|
deps,
|
|
223
240
|
conditions,
|
|
@@ -227,6 +244,7 @@ const convertToRawMutation = (mutation, context, options) => {
|
|
|
227
244
|
...mutationOptions,
|
|
228
245
|
mutationKey,
|
|
229
246
|
mutationFn: (variables) => {
|
|
247
|
+
const context = di.get(tokensCommon.CONTEXT_TOKEN);
|
|
230
248
|
return context.executeAction(actionWrapper, variables);
|
|
231
249
|
},
|
|
232
250
|
};
|
|
@@ -244,21 +262,21 @@ const createMutation = (mutationParameters) => {
|
|
|
244
262
|
},
|
|
245
263
|
});
|
|
246
264
|
},
|
|
247
|
-
raw: (
|
|
248
|
-
return convertToRawMutation(mutation,
|
|
265
|
+
raw: (diOrContext, options) => {
|
|
266
|
+
return convertToRawMutation(mutation, resolveDI(diOrContext), options);
|
|
249
267
|
},
|
|
250
268
|
};
|
|
251
269
|
return mutation;
|
|
252
270
|
};
|
|
253
271
|
|
|
254
272
|
const useMutation = (mutation, options) => {
|
|
255
|
-
const
|
|
256
|
-
const resultMutation = react.useMemo(() => {
|
|
273
|
+
const di = react.useDiContainer();
|
|
274
|
+
const resultMutation = react$1.useMemo(() => {
|
|
257
275
|
if (isMutation(mutation)) {
|
|
258
|
-
return mutation.raw(
|
|
276
|
+
return mutation.raw(di, options);
|
|
259
277
|
}
|
|
260
278
|
return mutation;
|
|
261
|
-
}, [mutation,
|
|
279
|
+
}, [mutation, di, options]);
|
|
262
280
|
return reactQuery.useMutation(resultMutation);
|
|
263
281
|
};
|
|
264
282
|
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import type { ProviderDeps } from '@tinkoff/dippy';
|
|
1
2
|
import type { CreateInfiniteQueryOptions, InfiniteQuery } from './types';
|
|
2
|
-
export declare const createInfiniteQuery: <Options = unknown, PageParam = unknown, Result = unknown, Deps =
|
|
3
|
+
export declare const createInfiniteQuery: <Options = unknown, PageParam = unknown, Result = unknown, Deps extends ProviderDeps = {}>(queryParameters: CreateInfiniteQueryOptions<Options, PageParam, Result, Deps>) => InfiniteQuery<Options, PageParam, Result, Deps>;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import type { ProvideDepsIterator } from '@tinkoff/dippy';
|
|
1
|
+
import type { ProvideDepsIterator, ProviderDeps } from '@tinkoff/dippy';
|
|
2
2
|
import type { UseInfiniteQueryOptions, InfiniteData } from '@tanstack/react-query';
|
|
3
3
|
import type { TramvaiAction } from '@tramvai/core';
|
|
4
|
-
import type { BaseCreateQueryOptions, BaseQuery } from '../baseQuery/types';
|
|
5
|
-
export interface CreateInfiniteQueryOptions<Options, PageParam, Result, Deps> extends BaseCreateQueryOptions<Options, Deps> {
|
|
4
|
+
import type { BaseCreateQueryOptions, BaseQuery, ReactQueryContext } from '../baseQuery/types';
|
|
5
|
+
export interface CreateInfiniteQueryOptions<Options, PageParam, Result, Deps extends ProviderDeps> extends BaseCreateQueryOptions<Options, Deps> {
|
|
6
6
|
infiniteQueryOptions?: UseInfiniteQueryOptions<Result, Error>;
|
|
7
|
-
fn: (options: Options, pageParam: PageParam,
|
|
7
|
+
fn: (this: ReactQueryContext<Deps>, options: Options, pageParam: PageParam,
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated use this.deps instead
|
|
10
|
+
*/
|
|
11
|
+
deps: ProvideDepsIterator<Deps>) => Promise<Result>;
|
|
8
12
|
getNextPageParam?: (lastPage: Result, allPages: Result[]) => PageParam;
|
|
9
13
|
getPreviousPageParam?: (firstPage: Result, allPages: Result[]) => PageParam;
|
|
10
14
|
}
|
|
11
|
-
export type InfiniteQuery<Options, PageParam, Result, Deps> = BaseQuery<Options, CreateInfiniteQueryOptions<Options, PageParam, Result, Deps>, InfiniteQuery<Options, PageParam, Result, Deps>, UseInfiniteQueryOptions<Result, Error>> & {
|
|
15
|
+
export type InfiniteQuery<Options, PageParam, Result, Deps extends ProviderDeps> = BaseQuery<Options, CreateInfiniteQueryOptions<Options, PageParam, Result, Deps>, InfiniteQuery<Options, PageParam, Result, Deps>, UseInfiniteQueryOptions<Result, Error>> & {
|
|
12
16
|
fetchAction(options?: Options): TramvaiAction<[], Promise<InfiniteData<Result>>, any>;
|
|
13
17
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { InfiniteQueryObserverResult, UseInfiniteQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import type { ProviderDeps } from '@tinkoff/dippy';
|
|
2
3
|
import type { InfiniteQuery } from './types';
|
|
3
|
-
declare function useInfiniteQuery<Options extends void, PageParam, Result, Deps>(query: UseInfiniteQueryOptions<Result, Error> | InfiniteQuery<Options, PageParam, Result, Deps>): InfiniteQueryObserverResult<Result, Error>;
|
|
4
|
-
declare function useInfiniteQuery<Options, PageParam, Result, Deps>(query: UseInfiniteQueryOptions<Result, Error> | InfiniteQuery<Options, PageParam, Result, Deps>, options: Options): InfiniteQueryObserverResult<Result, Error>;
|
|
4
|
+
declare function useInfiniteQuery<Options extends void, PageParam, Result, Deps extends ProviderDeps>(query: UseInfiniteQueryOptions<Result, Error> | InfiniteQuery<Options, PageParam, Result, Deps>): InfiniteQueryObserverResult<Result, Error>;
|
|
5
|
+
declare function useInfiniteQuery<Options, PageParam, Result, Deps extends ProviderDeps>(query: UseInfiniteQueryOptions<Result, Error> | InfiniteQuery<Options, PageParam, Result, Deps>, options: Options): InfiniteQueryObserverResult<Result, Error>;
|
|
5
6
|
export { useInfiniteQuery };
|
package/lib/mutation/create.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import type { ProviderDeps } from '@tinkoff/dippy';
|
|
1
2
|
import type { CreateMutationOptions, Mutation, MutationKey } from './types';
|
|
2
|
-
export declare const createMutation: <Options, Variables, Result, Deps, Key extends MutationKey<Options>>(mutationParameters: CreateMutationOptions<Options, Variables, Result, Deps, Key>) => Mutation<Options, Variables, Result, Deps, Key>;
|
|
3
|
+
export declare const createMutation: <Options, Variables, Result, Deps extends ProviderDeps = {}, Key extends MutationKey<Options, Deps> = MutationKey<Options, Deps>>(mutationParameters: CreateMutationOptions<Options, Variables, Result, Deps, Key>) => Mutation<Options, Variables, Result, Deps, Key>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/mutation/types.d.ts
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
import type { ActionConditionsParameters, ActionContext } from '@tramvai/core';
|
|
2
|
-
import type { ProvideDepsIterator } from '@tinkoff/dippy';
|
|
2
|
+
import type { Container, ProvideDepsIterator, ProviderDeps } from '@tinkoff/dippy';
|
|
3
3
|
import type { MutationKey as ReactMutationKey, MutationOptions, UseMutationOptions } from '@tanstack/react-query';
|
|
4
|
+
import type { ReactQueryContext } from '../baseQuery/types';
|
|
4
5
|
export declare const MUTATION_PARAMETERS = "__mutations_parameters__";
|
|
5
|
-
export type
|
|
6
|
-
export
|
|
6
|
+
export type ReactMutationKeyOrString = ReactMutationKey | string;
|
|
7
|
+
export type MutationKey<Options, Deps extends ProviderDeps> = ((this: ReactQueryContext<Deps>, options?: Options) => ReactMutationKeyOrString) | ReactMutationKeyOrString;
|
|
8
|
+
export interface CreateMutationOptions<Options, Variables, Result, Deps extends ProviderDeps, Key extends MutationKey<Options, Deps>> {
|
|
7
9
|
key?: Key;
|
|
8
10
|
mutationOptions?: UseMutationOptions<Result, any, Variables>;
|
|
9
|
-
fn: (options: Options | undefined, variables: Variables,
|
|
10
|
-
|
|
11
|
+
fn: (this: ReactQueryContext<Deps>, options: Options | undefined, variables: Variables,
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated use this.deps instead
|
|
14
|
+
*/
|
|
15
|
+
deps: ProvideDepsIterator<Deps>) => Promise<Result>;
|
|
16
|
+
deps?: Deps;
|
|
11
17
|
conditions?: ActionConditionsParameters;
|
|
12
18
|
}
|
|
13
|
-
export interface Mutation<Options, Variables, Result, Deps, Key extends MutationKey<Options>> {
|
|
19
|
+
export interface Mutation<Options, Variables, Result, Deps extends ProviderDeps, Key extends MutationKey<Options, Deps>> {
|
|
14
20
|
[MUTATION_PARAMETERS]: CreateMutationOptions<Options, Variables, Result, Deps, Key>;
|
|
15
21
|
fork(options: MutationOptions<Result, Error, Variables, any>): Mutation<Options, Variables, Result, Deps, Key>;
|
|
22
|
+
raw(di: Container, options?: Options): UseMutationOptions<Result, Error, Variables>;
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated pass di as first parameter instead of context
|
|
25
|
+
*/
|
|
16
26
|
raw(context: ActionContext, options?: Options): UseMutationOptions<Result, Error, Variables>;
|
|
17
27
|
}
|
|
18
|
-
export declare const isMutation: <Options, Variables, Result, Deps, Key extends MutationKey<Options>>(arg: Mutation<Options, Variables, Result, Deps, Key> | MutationOptions<Result, any, Variables, any>) => arg is Mutation<Options, Variables, Result, Deps, Key>;
|
|
28
|
+
export declare const isMutation: <Options, Variables, Result, Deps extends ProviderDeps, Key extends MutationKey<Options, Deps>>(arg: Mutation<Options, Variables, Result, Deps, Key> | MutationOptions<Result, any, Variables, any>) => arg is Mutation<Options, Variables, Result, Deps, Key>;
|
package/lib/mutation/use.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { UseMutationOptions, UseMutationResult
|
|
2
|
-
import type {
|
|
1
|
+
import type { UseMutationOptions, UseMutationResult } from '@tanstack/react-query';
|
|
2
|
+
import type { ProviderDeps } from '@tinkoff/dippy';
|
|
3
|
+
import type { Mutation, MutationKey } from './types';
|
|
3
4
|
interface UseMutation {
|
|
4
|
-
<Options, Variables, Result, Deps, Key extends
|
|
5
|
-
<Options, Variables, Result, Deps, Key extends
|
|
5
|
+
<Options, Variables, Result, Deps extends ProviderDeps, Key extends MutationKey<Options, Deps>>(Mutation: UseMutationOptions<Result, any, Variables> | Mutation<Options, Variables, Result, Deps, Key>, options: Options): UseMutationResult<Result, any, Variables>;
|
|
6
|
+
<Options, Variables, Result, Deps extends ProviderDeps, Key extends MutationKey<Options, Deps>>(Mutation: UseMutationOptions<Result, any, Variables> | Mutation<Options, Variables, Result, Deps, Key>): UseMutationResult<Result, any, Variables>;
|
|
6
7
|
}
|
|
7
8
|
export declare const useMutation: UseMutation;
|
|
8
9
|
export {};
|
package/lib/query/create.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import type { ProviderDeps } from '@tinkoff/dippy';
|
|
1
2
|
import type { CreateQueryOptions, Query } from './types';
|
|
2
|
-
export declare const createQuery: <Options = unknown, Result = unknown, Deps =
|
|
3
|
+
export declare const createQuery: <Options = unknown, Result = unknown, Deps extends ProviderDeps = {}>(queryParameters: CreateQueryOptions<Options, Result, Deps>) => Query<Options, Result, Deps>;
|
package/lib/query/types.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import type { ProvideDepsIterator } from '@tinkoff/dippy';
|
|
1
|
+
import type { ProvideDepsIterator, ProviderDeps } from '@tinkoff/dippy';
|
|
2
2
|
import type { UseQueryOptions } from '@tanstack/react-query';
|
|
3
3
|
import type { TramvaiAction } from '@tramvai/core';
|
|
4
|
-
import type { BaseCreateQueryOptions, BaseQuery } from '../baseQuery/types';
|
|
5
|
-
export interface CreateQueryOptions<Options, Result, Deps> extends BaseCreateQueryOptions<Options, Deps> {
|
|
4
|
+
import type { BaseCreateQueryOptions, BaseQuery, ReactQueryContext } from '../baseQuery/types';
|
|
5
|
+
export interface CreateQueryOptions<Options, Result, Deps extends ProviderDeps> extends BaseCreateQueryOptions<Options, Deps> {
|
|
6
6
|
queryOptions?: UseQueryOptions<Result, Error>;
|
|
7
|
-
fn: (options: Options,
|
|
7
|
+
fn: (this: ReactQueryContext<Deps>, options: Options,
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated use this.deps instead
|
|
10
|
+
*/
|
|
11
|
+
deps: ProvideDepsIterator<Deps>) => Promise<Result>;
|
|
8
12
|
}
|
|
9
|
-
export type Query<Options, Result, Deps> = BaseQuery<Options, CreateQueryOptions<Options, Result, Deps>, Query<Options, Result, Deps>, UseQueryOptions<Result, Error>> & {
|
|
13
|
+
export type Query<Options, Result, Deps extends ProviderDeps> = BaseQuery<Options, CreateQueryOptions<Options, Result, Deps>, Query<Options, Result, Deps>, UseQueryOptions<Result, Error>> & {
|
|
10
14
|
fetchAction(options?: Options): TramvaiAction<[], Promise<Result>, any>;
|
|
11
15
|
};
|
package/lib/query/use.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { UseQueryOptions, QueryObserverResult } from '@tanstack/react-query';
|
|
2
|
+
import type { ProviderDeps } from '@tinkoff/dippy';
|
|
2
3
|
import type { Query } from './types';
|
|
3
|
-
declare function useQuery<Options extends void, Result, Deps>(query: UseQueryOptions<Result, Error> | Query<Options, Result, Deps>): QueryObserverResult<Result, Error>;
|
|
4
|
-
declare function useQuery<Options, Result, Deps>(query: UseQueryOptions<Result, Error> | Query<Options, Result, Deps>, options: Options): QueryObserverResult<Result, Error>;
|
|
5
|
-
declare function useQueries<Result, Deps>(queries: Array<UseQueryOptions<Result, Error> | Query<any, Result, Deps>>): import("@tanstack/react-query").UseQueryResult<unknown extends Result ? Result : Result, Error>[];
|
|
4
|
+
declare function useQuery<Options extends void, Result, Deps extends ProviderDeps>(query: UseQueryOptions<Result, Error> | Query<Options, Result, Deps>): QueryObserverResult<Result, Error>;
|
|
5
|
+
declare function useQuery<Options, Result, Deps extends ProviderDeps>(query: UseQueryOptions<Result, Error> | Query<Options, Result, Deps>, options: Options): QueryObserverResult<Result, Error>;
|
|
6
|
+
declare function useQueries<Result, Deps extends ProviderDeps>(queries: Array<UseQueryOptions<Result, Error> | Query<any, Result, Deps>>): import("@tanstack/react-query").UseQueryResult<unknown extends Result ? Result : Result, Error>[];
|
|
6
7
|
export { useQuery, useQueries };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/react-query",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.50.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@tinkoff/react-hooks": "0.1.4",
|
|
22
|
-
"@tramvai/core": "2.
|
|
23
|
-
"@tramvai/module-react-query": "2.
|
|
24
|
-
"@tramvai/
|
|
25
|
-
"@tramvai/tokens-common": "2.
|
|
22
|
+
"@tramvai/core": "2.50.0",
|
|
23
|
+
"@tramvai/module-react-query": "2.50.0",
|
|
24
|
+
"@tramvai/react": "2.50.0",
|
|
25
|
+
"@tramvai/tokens-common": "2.50.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@tinkoff/dippy": "0.8.9",
|