@navios/react-query 0.3.0 → 0.5.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/CHANGELOG.md +74 -0
- package/README.md +13 -7
- package/dist/src/client/declare-client.d.mts +70 -0
- package/dist/src/client/declare-client.d.mts.map +1 -0
- package/dist/src/client/index.d.mts +3 -0
- package/dist/src/client/index.d.mts.map +1 -0
- package/dist/src/client/types.d.mts +287 -0
- package/dist/src/client/types.d.mts.map +1 -0
- package/dist/src/common/index.d.mts +2 -0
- package/dist/src/common/index.d.mts.map +1 -0
- package/dist/src/common/types.d.mts +21 -0
- package/dist/src/common/types.d.mts.map +1 -0
- package/dist/src/declare-client.d.mts +4 -4
- package/dist/src/declare-client.d.mts.map +1 -1
- package/dist/src/index.d.mts +13 -8
- package/dist/src/index.d.mts.map +1 -1
- package/dist/src/make-mutation.d.mts +1 -1
- package/dist/src/make-mutation.d.mts.map +1 -1
- package/dist/src/mutation/index.d.mts +4 -0
- package/dist/src/mutation/index.d.mts.map +1 -0
- package/dist/src/mutation/key-creator.d.mts +36 -0
- package/dist/src/mutation/key-creator.d.mts.map +1 -0
- package/dist/src/mutation/make-hook.d.mts +25 -0
- package/dist/src/mutation/make-hook.d.mts.map +1 -0
- package/dist/src/mutation/types.d.mts +50 -0
- package/dist/src/mutation/types.d.mts.map +1 -0
- package/dist/src/query/index.d.mts +5 -0
- package/dist/src/query/index.d.mts.map +1 -0
- package/dist/src/query/key-creator.d.mts +17 -0
- package/dist/src/query/key-creator.d.mts.map +1 -0
- package/dist/src/query/make-infinite-options.d.mts +23 -0
- package/dist/src/query/make-infinite-options.d.mts.map +1 -0
- package/dist/src/query/make-options.d.mts +24 -0
- package/dist/src/query/make-options.d.mts.map +1 -0
- package/dist/src/query/types.d.mts +83 -0
- package/dist/src/query/types.d.mts.map +1 -0
- package/dist/src/types/client-endpoint-helper.d.mts +1 -1
- package/dist/src/types/client-endpoint-helper.d.mts.map +1 -1
- package/dist/src/types/client-instance.d.mts +15 -15
- package/dist/src/types/client-instance.d.mts.map +1 -1
- package/dist/src/types/mutation-args.d.mts +3 -3
- package/dist/src/types/mutation-args.d.mts.map +1 -1
- package/dist/src/types/query-args.d.mts +3 -3
- package/dist/src/types/query-args.d.mts.map +1 -1
- package/dist/src/types/query-helpers.d.mts +2 -2
- package/dist/src/types/query-helpers.d.mts.map +1 -1
- package/dist/src/types.d.mts +4 -4
- package/dist/src/types.d.mts.map +1 -1
- package/dist/src/utils/query-key-creator.d.mts +3 -3
- package/dist/src/utils/query-key-creator.d.mts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/lib/_tsup-dts-rollup.d.mts +512 -262
- package/lib/_tsup-dts-rollup.d.ts +512 -262
- package/lib/index.d.mts +26 -19
- package/lib/index.d.ts +26 -19
- package/lib/index.js +92 -66
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +92 -68
- package/lib/index.mjs.map +1 -1
- package/package.json +8 -8
- package/project.json +9 -1
- package/src/__tests__/client-type-check.spec.mts +2 -2
- package/src/__tests__/declare-client.spec.mts +2 -2
- package/src/__tests__/make-mutation.spec.mts +2 -2
- package/src/__tests__/makeDataTag.spec.mts +2 -2
- package/src/__tests__/makeInfiniteQueryOptions.spec.mts +2 -3
- package/src/__tests__/makeQueryOptions.spec.mts +2 -2
- package/src/{declare-client.mts → client/declare-client.mts} +96 -36
- package/src/client/index.mts +2 -0
- package/src/{types/client-instance.mts → client/types.mts} +442 -160
- package/src/common/index.mts +1 -0
- package/src/common/types.mts +31 -0
- package/src/index.mts +28 -8
- package/src/mutation/index.mts +3 -0
- package/src/mutation/key-creator.mts +64 -0
- package/src/{make-mutation.mts → mutation/make-hook.mts} +20 -9
- package/src/mutation/types.mts +106 -0
- package/src/query/index.mts +4 -0
- package/src/{utils/query-key-creator.mts → query/key-creator.mts} +22 -52
- package/src/{make-infinite-query-options.mts → query/make-infinite-options.mts} +29 -15
- package/src/{make-query-options.mts → query/make-options.mts} +26 -25
- package/src/query/types.mts +163 -0
- package/dist/tsdown.config.d.mts +0 -3
- package/dist/tsdown.config.d.mts.map +0 -1
- package/dist/tsup.config.d.mts +0 -3
- package/dist/tsup.config.d.mts.map +0 -1
- package/dist/vitest.config.d.mts +0 -3
- package/dist/vitest.config.d.mts.map +0 -1
- package/src/types/client-endpoint-helper.mts +0 -29
- package/src/types/index.mts +0 -7
- package/src/types/mutation-args.mts +0 -10
- package/src/types/mutation-helpers.mts +0 -13
- package/src/types/query-args.mts +0 -8
- package/src/types/query-helpers.mts +0 -34
- package/src/types/query-url-params-args.mts +0 -6
- package/src/types.mts +0 -118
- package/src/utils/mutation-key.creator.mts +0 -65
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
BaseEndpointConfig,
|
|
3
|
+
EndpointFunctionArgs,
|
|
4
|
+
HttpMethod,
|
|
3
5
|
UrlHasParams,
|
|
4
6
|
UrlParams,
|
|
5
7
|
Util_FlatObject,
|
|
@@ -12,16 +14,57 @@ import type {
|
|
|
12
14
|
UseSuspenseInfiniteQueryOptions,
|
|
13
15
|
UseSuspenseQueryOptions,
|
|
14
16
|
} from '@tanstack/react-query'
|
|
15
|
-
import type {
|
|
17
|
+
import type { z, ZodObject, ZodType } from 'zod/v4'
|
|
16
18
|
|
|
17
|
-
import type { ProcessResponseFunction, Split } from '../types.mjs'
|
|
18
|
-
import type {
|
|
19
|
-
import type {
|
|
20
|
-
import type { MutationHelpers } from './mutation-helpers.mjs'
|
|
21
|
-
import type { ClientQueryArgs } from './query-args.mjs'
|
|
22
|
-
import type { QueryHelpers } from './query-helpers.mjs'
|
|
19
|
+
import type { ProcessResponseFunction, Split } from '../common/types.mjs'
|
|
20
|
+
import type { MutationArgs, MutationHelpers } from '../mutation/types.mjs'
|
|
21
|
+
import type { QueryArgs, QueryHelpers } from '../query/types.mjs'
|
|
23
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Helper type that attaches the endpoint to query/mutation results.
|
|
25
|
+
*/
|
|
26
|
+
export type EndpointHelper<
|
|
27
|
+
Method extends HttpMethod = HttpMethod,
|
|
28
|
+
Url extends string = string,
|
|
29
|
+
RequestSchema = unknown,
|
|
30
|
+
ResponseSchema extends z.ZodType = z.ZodType,
|
|
31
|
+
QuerySchema = unknown,
|
|
32
|
+
> = {
|
|
33
|
+
endpoint: ((
|
|
34
|
+
params: Util_FlatObject<
|
|
35
|
+
EndpointFunctionArgs<Url, QuerySchema, RequestSchema>
|
|
36
|
+
>,
|
|
37
|
+
) => Promise<z.output<ResponseSchema>>) & {
|
|
38
|
+
config: BaseEndpointConfig<
|
|
39
|
+
Method,
|
|
40
|
+
Url,
|
|
41
|
+
QuerySchema,
|
|
42
|
+
ResponseSchema,
|
|
43
|
+
RequestSchema
|
|
44
|
+
>
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Legacy export for backwards compatibility
|
|
49
|
+
/** @deprecated Use EndpointHelper instead */
|
|
50
|
+
export type ClientEndpointHelper<
|
|
51
|
+
Method extends HttpMethod = HttpMethod,
|
|
52
|
+
Url extends string = string,
|
|
53
|
+
RequestSchema = unknown,
|
|
54
|
+
ResponseSchema extends z.ZodType = z.ZodType,
|
|
55
|
+
QuerySchema = unknown,
|
|
56
|
+
> = EndpointHelper<Method, Url, RequestSchema, ResponseSchema, QuerySchema>
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The main client instance interface.
|
|
60
|
+
* Provides methods for creating queries, infinite queries, and mutations.
|
|
61
|
+
*/
|
|
24
62
|
export interface ClientInstance {
|
|
63
|
+
// ============================================================================
|
|
64
|
+
// QUERY METHODS
|
|
65
|
+
// ============================================================================
|
|
66
|
+
|
|
67
|
+
// Standard query methods (GET, HEAD, OPTIONS) without query schema
|
|
25
68
|
query<
|
|
26
69
|
Method extends 'GET' | 'HEAD' | 'OPTIONS' = 'GET',
|
|
27
70
|
Url extends string = string,
|
|
@@ -33,7 +76,7 @@ export interface ClientInstance {
|
|
|
33
76
|
responseSchema: Response
|
|
34
77
|
processResponse?: (data: z.output<Response>) => Result
|
|
35
78
|
}): ((
|
|
36
|
-
params: Util_FlatObject<
|
|
79
|
+
params: Util_FlatObject<QueryArgs<Url, undefined>>,
|
|
37
80
|
) => UseSuspenseQueryOptions<
|
|
38
81
|
Result,
|
|
39
82
|
Error,
|
|
@@ -41,12 +84,13 @@ export interface ClientInstance {
|
|
|
41
84
|
DataTag<Split<Url, '/'>, Result, Error>
|
|
42
85
|
>) &
|
|
43
86
|
QueryHelpers<Url, undefined, Result> &
|
|
44
|
-
|
|
87
|
+
EndpointHelper<Method, Url, undefined, Response>
|
|
45
88
|
|
|
89
|
+
// Standard query methods (GET, HEAD, OPTIONS) with query schema
|
|
46
90
|
query<
|
|
47
91
|
Method extends 'GET' | 'HEAD' | 'OPTIONS' = 'GET',
|
|
48
92
|
Url extends string = string,
|
|
49
|
-
QuerySchema extends
|
|
93
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
50
94
|
Response extends ZodType = ZodType,
|
|
51
95
|
Result = z.output<Response>,
|
|
52
96
|
>(config: {
|
|
@@ -56,7 +100,7 @@ export interface ClientInstance {
|
|
|
56
100
|
responseSchema: Response
|
|
57
101
|
processResponse?: (data: z.output<Response>) => Result
|
|
58
102
|
}): ((
|
|
59
|
-
params: Util_FlatObject<
|
|
103
|
+
params: Util_FlatObject<QueryArgs<Url, QuerySchema>>,
|
|
60
104
|
) => UseSuspenseQueryOptions<
|
|
61
105
|
Result,
|
|
62
106
|
Error,
|
|
@@ -64,12 +108,67 @@ export interface ClientInstance {
|
|
|
64
108
|
DataTag<Split<Url, '/'>, Result, Error>
|
|
65
109
|
>) &
|
|
66
110
|
QueryHelpers<Url, QuerySchema, Result> &
|
|
67
|
-
|
|
111
|
+
EndpointHelper<Method, Url, undefined, Response, QuerySchema>
|
|
112
|
+
|
|
113
|
+
// POST query methods (for search endpoints) without query schema
|
|
114
|
+
query<
|
|
115
|
+
Method extends 'POST' = 'POST',
|
|
116
|
+
Url extends string = string,
|
|
117
|
+
RequestSchema extends ZodType = ZodType,
|
|
118
|
+
Response extends ZodType = ZodType,
|
|
119
|
+
Result = z.output<Response>,
|
|
120
|
+
>(config: {
|
|
121
|
+
method: Method
|
|
122
|
+
url: Url
|
|
123
|
+
requestSchema: RequestSchema
|
|
124
|
+
responseSchema: Response
|
|
125
|
+
processResponse?: (data: z.output<Response>) => Result
|
|
126
|
+
}): ((
|
|
127
|
+
params: Util_FlatObject<QueryArgs<Url, undefined, RequestSchema>>,
|
|
128
|
+
) => UseSuspenseQueryOptions<
|
|
129
|
+
Result,
|
|
130
|
+
Error,
|
|
131
|
+
Result,
|
|
132
|
+
DataTag<Split<Url, '/'>, Result, Error>
|
|
133
|
+
>) &
|
|
134
|
+
QueryHelpers<Url, undefined, Result, false, RequestSchema> &
|
|
135
|
+
EndpointHelper<Method, Url, RequestSchema, Response>
|
|
136
|
+
|
|
137
|
+
// POST query methods (for search endpoints) with query schema
|
|
138
|
+
query<
|
|
139
|
+
Method extends 'POST' = 'POST',
|
|
140
|
+
Url extends string = string,
|
|
141
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
142
|
+
RequestSchema extends ZodType = ZodType,
|
|
143
|
+
Response extends ZodType = ZodType,
|
|
144
|
+
Result = z.output<Response>,
|
|
145
|
+
>(config: {
|
|
146
|
+
method: Method
|
|
147
|
+
url: Url
|
|
148
|
+
querySchema: QuerySchema
|
|
149
|
+
requestSchema: RequestSchema
|
|
150
|
+
responseSchema: Response
|
|
151
|
+
processResponse?: (data: z.output<Response>) => Result
|
|
152
|
+
}): ((
|
|
153
|
+
params: Util_FlatObject<QueryArgs<Url, QuerySchema, RequestSchema>>,
|
|
154
|
+
) => UseSuspenseQueryOptions<
|
|
155
|
+
Result,
|
|
156
|
+
Error,
|
|
157
|
+
Result,
|
|
158
|
+
DataTag<Split<Url, '/'>, Result, Error>
|
|
159
|
+
>) &
|
|
160
|
+
QueryHelpers<Url, QuerySchema, Result, false, RequestSchema> &
|
|
161
|
+
EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
|
|
162
|
+
|
|
163
|
+
// ============================================================================
|
|
164
|
+
// INFINITE QUERY METHODS
|
|
165
|
+
// ============================================================================
|
|
68
166
|
|
|
167
|
+
// Standard infiniteQuery methods (GET, HEAD, OPTIONS)
|
|
69
168
|
infiniteQuery<
|
|
70
169
|
Method extends 'GET' | 'HEAD' | 'OPTIONS' = 'GET',
|
|
71
170
|
Url extends string = string,
|
|
72
|
-
QuerySchema extends
|
|
171
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
73
172
|
Response extends ZodType = ZodType,
|
|
74
173
|
PageResult = z.output<Response>,
|
|
75
174
|
Result = InfiniteData<PageResult>,
|
|
@@ -92,23 +191,67 @@ export interface ClientInstance {
|
|
|
92
191
|
allPageParams: z.infer<QuerySchema>[] | undefined,
|
|
93
192
|
) => z.input<QuerySchema>
|
|
94
193
|
}): ((
|
|
95
|
-
params: Util_FlatObject<
|
|
194
|
+
params: Util_FlatObject<QueryArgs<Url, QuerySchema>>,
|
|
96
195
|
) => UseSuspenseInfiniteQueryOptions<
|
|
97
196
|
PageResult,
|
|
98
197
|
Error,
|
|
99
198
|
Result,
|
|
100
|
-
PageResult,
|
|
101
199
|
DataTag<Split<Url, '/'>, PageResult, Error>,
|
|
102
200
|
z.output<QuerySchema>
|
|
103
201
|
>) &
|
|
104
202
|
QueryHelpers<Url, QuerySchema, PageResult, true> &
|
|
105
|
-
|
|
203
|
+
EndpointHelper<Method, Url, undefined, Response, QuerySchema>
|
|
204
|
+
|
|
205
|
+
// POST infiniteQuery methods (for search endpoints)
|
|
206
|
+
infiniteQuery<
|
|
207
|
+
Method extends 'POST' = 'POST',
|
|
208
|
+
Url extends string = string,
|
|
209
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
210
|
+
RequestSchema extends ZodType = ZodType,
|
|
211
|
+
Response extends ZodType = ZodType,
|
|
212
|
+
PageResult = z.output<Response>,
|
|
213
|
+
Result = InfiniteData<PageResult>,
|
|
214
|
+
>(config: {
|
|
215
|
+
method: Method
|
|
216
|
+
url: Url
|
|
217
|
+
querySchema: QuerySchema
|
|
218
|
+
requestSchema: RequestSchema
|
|
219
|
+
responseSchema: Response
|
|
220
|
+
processResponse?: (data: z.output<Response>) => PageResult
|
|
221
|
+
getNextPageParam: (
|
|
222
|
+
lastPage: PageResult,
|
|
223
|
+
allPages: PageResult[],
|
|
224
|
+
lastPageParam: z.infer<QuerySchema> | undefined,
|
|
225
|
+
allPageParams: z.infer<QuerySchema>[] | undefined,
|
|
226
|
+
) => z.input<QuerySchema> | undefined
|
|
227
|
+
getPreviousPageParam?: (
|
|
228
|
+
firstPage: PageResult,
|
|
229
|
+
allPages: PageResult[],
|
|
230
|
+
lastPageParam: z.infer<QuerySchema> | undefined,
|
|
231
|
+
allPageParams: z.infer<QuerySchema>[] | undefined,
|
|
232
|
+
) => z.input<QuerySchema>
|
|
233
|
+
}): ((
|
|
234
|
+
params: Util_FlatObject<QueryArgs<Url, QuerySchema, RequestSchema>>,
|
|
235
|
+
) => UseSuspenseInfiniteQueryOptions<
|
|
236
|
+
PageResult,
|
|
237
|
+
Error,
|
|
238
|
+
Result,
|
|
239
|
+
DataTag<Split<Url, '/'>, PageResult, Error>,
|
|
240
|
+
z.output<QuerySchema>
|
|
241
|
+
>) &
|
|
242
|
+
QueryHelpers<Url, QuerySchema, PageResult, true, RequestSchema> &
|
|
243
|
+
EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
|
|
244
|
+
|
|
245
|
+
// ============================================================================
|
|
246
|
+
// MUTATION METHODS (POST, PUT, PATCH)
|
|
247
|
+
// ============================================================================
|
|
106
248
|
|
|
249
|
+
// With useKey, requestSchema, and querySchema
|
|
107
250
|
mutation<
|
|
108
251
|
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
109
252
|
Url extends string = string,
|
|
110
253
|
RequestSchema extends ZodType = ZodType,
|
|
111
|
-
QuerySchema extends
|
|
254
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
112
255
|
Response extends ZodType = ZodType,
|
|
113
256
|
ReqResult = z.output<Response>,
|
|
114
257
|
Result = unknown,
|
|
@@ -126,17 +269,13 @@ export interface ClientInstance {
|
|
|
126
269
|
onSuccess?: (
|
|
127
270
|
queryClient: QueryClient,
|
|
128
271
|
data: NoInfer<Result>,
|
|
129
|
-
variables: Util_FlatObject<
|
|
130
|
-
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
131
|
-
>,
|
|
272
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
|
|
132
273
|
context: Context,
|
|
133
274
|
) => void | Promise<void>
|
|
134
275
|
onError?: (
|
|
135
276
|
queryClient: QueryClient,
|
|
136
277
|
error: Error,
|
|
137
|
-
variables: Util_FlatObject<
|
|
138
|
-
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
139
|
-
>,
|
|
278
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
|
|
140
279
|
context: Context,
|
|
141
280
|
) => void | Promise<void>
|
|
142
281
|
}): ((
|
|
@@ -144,16 +283,17 @@ export interface ClientInstance {
|
|
|
144
283
|
) => UseMutationResult<
|
|
145
284
|
Result,
|
|
146
285
|
Error,
|
|
147
|
-
|
|
286
|
+
MutationArgs<Url, RequestSchema, QuerySchema>
|
|
148
287
|
>) &
|
|
149
288
|
MutationHelpers<Url, Result> &
|
|
150
|
-
|
|
289
|
+
EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
|
|
151
290
|
|
|
291
|
+
// Without useKey, with requestSchema and querySchema
|
|
152
292
|
mutation<
|
|
153
293
|
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
154
294
|
Url extends string = string,
|
|
155
295
|
RequestSchema extends ZodType = ZodType,
|
|
156
|
-
QuerySchema extends
|
|
296
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
157
297
|
Response extends ZodType = ZodType,
|
|
158
298
|
ReqResult = z.output<Response>,
|
|
159
299
|
Result = unknown,
|
|
@@ -169,26 +309,24 @@ export interface ClientInstance {
|
|
|
169
309
|
onSuccess?: (
|
|
170
310
|
queryClient: QueryClient,
|
|
171
311
|
data: NoInfer<Result>,
|
|
172
|
-
variables: Util_FlatObject<
|
|
173
|
-
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
174
|
-
>,
|
|
312
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
|
|
175
313
|
context: Context,
|
|
176
314
|
) => void | Promise<void>
|
|
177
315
|
onError?: (
|
|
178
316
|
queryClient: QueryClient,
|
|
179
317
|
error: Error,
|
|
180
|
-
variables: Util_FlatObject<
|
|
181
|
-
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
182
|
-
>,
|
|
318
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
|
|
183
319
|
context: Context,
|
|
184
320
|
) => void | Promise<void>
|
|
185
321
|
}): (() => UseMutationResult<
|
|
186
322
|
Result,
|
|
187
323
|
Error,
|
|
188
|
-
|
|
324
|
+
MutationArgs<Url, RequestSchema, QuerySchema>
|
|
189
325
|
>) &
|
|
190
|
-
|
|
326
|
+
MutationHelpers<Url, Result> &
|
|
327
|
+
EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
|
|
191
328
|
|
|
329
|
+
// Without useKey, with requestSchema only
|
|
192
330
|
mutation<
|
|
193
331
|
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
194
332
|
Url extends string = string,
|
|
@@ -207,27 +345,24 @@ export interface ClientInstance {
|
|
|
207
345
|
onSuccess?: (
|
|
208
346
|
queryClient: QueryClient,
|
|
209
347
|
data: NoInfer<Result>,
|
|
210
|
-
variables: Util_FlatObject<
|
|
211
|
-
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
212
|
-
>,
|
|
348
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
213
349
|
context: Context,
|
|
214
350
|
) => void | Promise<void>
|
|
215
351
|
onError?: (
|
|
216
352
|
queryClient: QueryClient,
|
|
217
353
|
error: Error,
|
|
218
|
-
variables: Util_FlatObject<
|
|
219
|
-
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
220
|
-
>,
|
|
354
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
221
355
|
context: Context,
|
|
222
356
|
) => void | Promise<void>
|
|
223
357
|
}): (() => UseMutationResult<
|
|
224
358
|
Result,
|
|
225
359
|
Error,
|
|
226
|
-
|
|
360
|
+
MutationArgs<Url, RequestSchema, undefined>
|
|
227
361
|
>) &
|
|
228
362
|
MutationHelpers<Url, Result> &
|
|
229
|
-
|
|
363
|
+
EndpointHelper<Method, Url, RequestSchema, Response>
|
|
230
364
|
|
|
365
|
+
// With useKey and requestSchema only
|
|
231
366
|
mutation<
|
|
232
367
|
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
233
368
|
Url extends string = string,
|
|
@@ -248,17 +383,13 @@ export interface ClientInstance {
|
|
|
248
383
|
onSuccess?: (
|
|
249
384
|
queryClient: QueryClient,
|
|
250
385
|
data: NoInfer<Result>,
|
|
251
|
-
variables: Util_FlatObject<
|
|
252
|
-
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
253
|
-
>,
|
|
386
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
254
387
|
context: Context,
|
|
255
388
|
) => void | Promise<void>
|
|
256
389
|
onError?: (
|
|
257
390
|
queryClient: QueryClient,
|
|
258
391
|
error: Error,
|
|
259
|
-
variables: Util_FlatObject<
|
|
260
|
-
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
261
|
-
>,
|
|
392
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
262
393
|
context: Context,
|
|
263
394
|
) => void | Promise<void>
|
|
264
395
|
}): ((
|
|
@@ -266,15 +397,20 @@ export interface ClientInstance {
|
|
|
266
397
|
) => UseMutationResult<
|
|
267
398
|
Result,
|
|
268
399
|
Error,
|
|
269
|
-
|
|
400
|
+
MutationArgs<Url, RequestSchema, undefined>
|
|
270
401
|
>) &
|
|
271
402
|
MutationHelpers<Url, Result> &
|
|
272
|
-
|
|
403
|
+
EndpointHelper<Method, Url, RequestSchema, Response>
|
|
404
|
+
|
|
405
|
+
// ============================================================================
|
|
406
|
+
// DELETE MUTATION METHODS
|
|
407
|
+
// ============================================================================
|
|
273
408
|
|
|
409
|
+
// DELETE with useKey and querySchema
|
|
274
410
|
mutation<
|
|
275
411
|
Method extends 'DELETE' = 'DELETE',
|
|
276
412
|
Url extends string = string,
|
|
277
|
-
QuerySchema extends
|
|
413
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
278
414
|
Response extends ZodType = ZodType,
|
|
279
415
|
ReqResult = z.output<Response>,
|
|
280
416
|
Result = unknown,
|
|
@@ -291,17 +427,13 @@ export interface ClientInstance {
|
|
|
291
427
|
onSuccess?: (
|
|
292
428
|
queryClient: QueryClient,
|
|
293
429
|
data: NoInfer<Result>,
|
|
294
|
-
variables: Util_FlatObject<
|
|
295
|
-
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
296
|
-
>,
|
|
430
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
|
|
297
431
|
context: Context,
|
|
298
432
|
) => void | Promise<void>
|
|
299
433
|
onError?: (
|
|
300
434
|
queryClient: QueryClient,
|
|
301
435
|
error: Error,
|
|
302
|
-
variables: Util_FlatObject<
|
|
303
|
-
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
304
|
-
>,
|
|
436
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
|
|
305
437
|
context: Context,
|
|
306
438
|
) => void | Promise<void>
|
|
307
439
|
}): ((
|
|
@@ -309,15 +441,16 @@ export interface ClientInstance {
|
|
|
309
441
|
) => UseMutationResult<
|
|
310
442
|
Result,
|
|
311
443
|
Error,
|
|
312
|
-
|
|
444
|
+
MutationArgs<Url, undefined, QuerySchema>
|
|
313
445
|
>) &
|
|
314
446
|
MutationHelpers<Url, Result> &
|
|
315
|
-
|
|
447
|
+
EndpointHelper<Method, Url, undefined, Response, QuerySchema>
|
|
316
448
|
|
|
449
|
+
// DELETE without useKey, with querySchema
|
|
317
450
|
mutation<
|
|
318
451
|
Method extends 'DELETE' = 'DELETE',
|
|
319
452
|
Url extends string = string,
|
|
320
|
-
QuerySchema extends
|
|
453
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
321
454
|
Response extends ZodType = ZodType,
|
|
322
455
|
ReqResult = z.output<Response>,
|
|
323
456
|
Result = unknown,
|
|
@@ -332,26 +465,24 @@ export interface ClientInstance {
|
|
|
332
465
|
onSuccess?: (
|
|
333
466
|
queryClient: QueryClient,
|
|
334
467
|
data: NoInfer<Result>,
|
|
335
|
-
variables: Util_FlatObject<
|
|
336
|
-
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
337
|
-
>,
|
|
468
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
|
|
338
469
|
context: Context,
|
|
339
470
|
) => void | Promise<void>
|
|
340
471
|
onError?: (
|
|
341
472
|
queryClient: QueryClient,
|
|
342
473
|
error: Error,
|
|
343
|
-
variables: Util_FlatObject<
|
|
344
|
-
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
345
|
-
>,
|
|
474
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
|
|
346
475
|
context: Context,
|
|
347
476
|
) => void | Promise<void>
|
|
348
477
|
}): (() => UseMutationResult<
|
|
349
478
|
Result,
|
|
350
479
|
Error,
|
|
351
|
-
|
|
480
|
+
MutationArgs<Url, undefined, QuerySchema>
|
|
352
481
|
>) &
|
|
353
|
-
|
|
482
|
+
MutationHelpers<Url, Result> &
|
|
483
|
+
EndpointHelper<Method, Url, undefined, Response, QuerySchema>
|
|
354
484
|
|
|
485
|
+
// DELETE with useKey only (no schemas)
|
|
355
486
|
mutation<
|
|
356
487
|
Method extends 'DELETE' = 'DELETE',
|
|
357
488
|
Url extends string = string,
|
|
@@ -370,13 +501,13 @@ export interface ClientInstance {
|
|
|
370
501
|
onSuccess?: (
|
|
371
502
|
queryClient: QueryClient,
|
|
372
503
|
data: NoInfer<Result>,
|
|
373
|
-
variables: Util_FlatObject<
|
|
504
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
|
|
374
505
|
context: Context,
|
|
375
506
|
) => void | Promise<void>
|
|
376
507
|
onError?: (
|
|
377
508
|
queryClient: QueryClient,
|
|
378
509
|
error: Error,
|
|
379
|
-
variables: Util_FlatObject<
|
|
510
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
|
|
380
511
|
context: Context,
|
|
381
512
|
) => void | Promise<void>
|
|
382
513
|
}): ((
|
|
@@ -384,11 +515,12 @@ export interface ClientInstance {
|
|
|
384
515
|
) => UseMutationResult<
|
|
385
516
|
Result,
|
|
386
517
|
Error,
|
|
387
|
-
|
|
518
|
+
MutationArgs<Url, undefined, undefined>
|
|
388
519
|
>) &
|
|
389
520
|
MutationHelpers<Url, Result> &
|
|
390
|
-
|
|
521
|
+
EndpointHelper<Method, Url, undefined, Response>
|
|
391
522
|
|
|
523
|
+
// DELETE without useKey (no schemas)
|
|
392
524
|
mutation<
|
|
393
525
|
Method extends 'DELETE' = 'DELETE',
|
|
394
526
|
Url extends string = string,
|
|
@@ -405,37 +537,42 @@ export interface ClientInstance {
|
|
|
405
537
|
onSuccess?: (
|
|
406
538
|
queryClient: QueryClient,
|
|
407
539
|
data: NoInfer<Result>,
|
|
408
|
-
variables: Util_FlatObject<
|
|
540
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
|
|
409
541
|
context: Context,
|
|
410
542
|
) => void | Promise<void>
|
|
411
543
|
onError?: (
|
|
412
544
|
queryClient: QueryClient,
|
|
413
545
|
error: Error,
|
|
414
|
-
variables: Util_FlatObject<
|
|
546
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
|
|
415
547
|
context: Context,
|
|
416
548
|
) => void | Promise<void>
|
|
417
549
|
}): (() => UseMutationResult<
|
|
418
550
|
Result,
|
|
419
551
|
Error,
|
|
420
|
-
|
|
552
|
+
MutationArgs<Url, undefined, undefined>
|
|
421
553
|
>) &
|
|
422
|
-
|
|
554
|
+
MutationHelpers<Url, Result> &
|
|
555
|
+
EndpointHelper<Method, Url, undefined, Response>
|
|
556
|
+
|
|
557
|
+
// ============================================================================
|
|
558
|
+
// FROM ENDPOINT METHODS
|
|
559
|
+
// ============================================================================
|
|
423
560
|
|
|
424
561
|
queryFromEndpoint<
|
|
425
562
|
Method extends 'GET' | 'HEAD' | 'OPTIONS' = 'GET',
|
|
426
563
|
Url extends string = string,
|
|
427
|
-
QuerySchema extends
|
|
564
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
428
565
|
Response extends ZodType = ZodType,
|
|
429
566
|
Result = z.output<Response>,
|
|
430
567
|
>(
|
|
431
|
-
endpoint:
|
|
568
|
+
endpoint: {
|
|
432
569
|
config: BaseEndpointConfig<Method, Url, QuerySchema, Response>
|
|
433
570
|
},
|
|
434
571
|
options?: {
|
|
435
572
|
processResponse?: (data: z.output<Response>) => Result
|
|
436
573
|
},
|
|
437
574
|
): (
|
|
438
|
-
params:
|
|
575
|
+
params: Util_FlatObject<QueryArgs<Url, QuerySchema>>,
|
|
439
576
|
) => UseSuspenseQueryOptions<
|
|
440
577
|
Result,
|
|
441
578
|
Error,
|
|
@@ -450,14 +587,14 @@ export interface ClientInstance {
|
|
|
450
587
|
Response extends ZodType = ZodType,
|
|
451
588
|
Result = z.output<Response>,
|
|
452
589
|
>(
|
|
453
|
-
endpoint:
|
|
590
|
+
endpoint: {
|
|
454
591
|
config: BaseEndpointConfig<Method, Url, undefined, Response>
|
|
455
592
|
},
|
|
456
593
|
options?: {
|
|
457
594
|
processResponse?: (data: z.output<Response>) => Result
|
|
458
595
|
},
|
|
459
596
|
): ((
|
|
460
|
-
params:
|
|
597
|
+
params: Util_FlatObject<QueryArgs<Url, undefined>>,
|
|
461
598
|
) => UseSuspenseQueryOptions<
|
|
462
599
|
Result,
|
|
463
600
|
Error,
|
|
@@ -469,12 +606,12 @@ export interface ClientInstance {
|
|
|
469
606
|
infiniteQueryFromEndpoint<
|
|
470
607
|
Method extends 'GET' | 'HEAD' | 'OPTIONS' = 'GET',
|
|
471
608
|
Url extends string = string,
|
|
472
|
-
QuerySchema extends
|
|
609
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
473
610
|
Response extends ZodType = ZodType,
|
|
474
611
|
PageResult = z.output<Response>,
|
|
475
612
|
Result = InfiniteData<PageResult>,
|
|
476
613
|
>(
|
|
477
|
-
endpoint:
|
|
614
|
+
endpoint: {
|
|
478
615
|
config: BaseEndpointConfig<Method, Url, QuerySchema, Response>
|
|
479
616
|
},
|
|
480
617
|
options: {
|
|
@@ -493,29 +630,32 @@ export interface ClientInstance {
|
|
|
493
630
|
) => z.input<QuerySchema>
|
|
494
631
|
},
|
|
495
632
|
): ((
|
|
496
|
-
params:
|
|
633
|
+
params: Util_FlatObject<QueryArgs<Url, QuerySchema>>,
|
|
497
634
|
) => UseSuspenseInfiniteQueryOptions<
|
|
498
635
|
PageResult,
|
|
499
636
|
Error,
|
|
500
637
|
Result,
|
|
501
|
-
PageResult,
|
|
502
638
|
DataTag<Split<Url, '/'>, PageResult, Error>,
|
|
503
639
|
z.output<QuerySchema>
|
|
504
640
|
>) &
|
|
505
641
|
QueryHelpers<Url, QuerySchema, PageResult, true>
|
|
506
642
|
|
|
643
|
+
// ============================================================================
|
|
644
|
+
// MUTATION FROM ENDPOINT METHODS (POST, PUT, PATCH)
|
|
645
|
+
// ============================================================================
|
|
646
|
+
|
|
507
647
|
mutationFromEndpoint<
|
|
508
648
|
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
509
649
|
Url extends string = string,
|
|
510
650
|
RequestSchema extends ZodType = ZodType,
|
|
511
|
-
QuerySchema extends
|
|
651
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
512
652
|
Response extends ZodType = ZodType,
|
|
513
653
|
ReqResult = z.output<Response>,
|
|
514
654
|
Result = unknown,
|
|
515
655
|
Context = unknown,
|
|
516
656
|
UseKey extends true = true,
|
|
517
657
|
>(
|
|
518
|
-
endpoint:
|
|
658
|
+
endpoint: {
|
|
519
659
|
config: BaseEndpointConfig<
|
|
520
660
|
Method,
|
|
521
661
|
Url,
|
|
@@ -532,7 +672,7 @@ export interface ClientInstance {
|
|
|
532
672
|
queryClient: QueryClient,
|
|
533
673
|
data: NoInfer<Result>,
|
|
534
674
|
variables: Util_FlatObject<
|
|
535
|
-
|
|
675
|
+
MutationArgs<Url, RequestSchema, QuerySchema>
|
|
536
676
|
>,
|
|
537
677
|
context: Context,
|
|
538
678
|
) => void | Promise<void>
|
|
@@ -540,20 +680,20 @@ export interface ClientInstance {
|
|
|
540
680
|
queryClient: QueryClient,
|
|
541
681
|
error: Error,
|
|
542
682
|
variables: Util_FlatObject<
|
|
543
|
-
|
|
683
|
+
MutationArgs<Url, RequestSchema, QuerySchema>
|
|
544
684
|
>,
|
|
545
685
|
context: Context,
|
|
546
686
|
) => void | Promise<void>
|
|
547
687
|
},
|
|
548
688
|
): ((
|
|
549
|
-
params:
|
|
689
|
+
params: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
|
|
550
690
|
) => UseMutationResult<
|
|
551
691
|
Result,
|
|
552
692
|
Error,
|
|
553
|
-
|
|
693
|
+
MutationArgs<Url, RequestSchema, QuerySchema>
|
|
554
694
|
>) &
|
|
555
695
|
MutationHelpers<Url, Result> &
|
|
556
|
-
|
|
696
|
+
EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
|
|
557
697
|
|
|
558
698
|
mutationFromEndpoint<
|
|
559
699
|
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
@@ -565,7 +705,7 @@ export interface ClientInstance {
|
|
|
565
705
|
Context = unknown,
|
|
566
706
|
UseKey extends true = true,
|
|
567
707
|
>(
|
|
568
|
-
endpoint:
|
|
708
|
+
endpoint: {
|
|
569
709
|
config: BaseEndpointConfig<
|
|
570
710
|
Method,
|
|
571
711
|
Url,
|
|
@@ -581,41 +721,37 @@ export interface ClientInstance {
|
|
|
581
721
|
onSuccess?: (
|
|
582
722
|
queryClient: QueryClient,
|
|
583
723
|
data: NoInfer<Result>,
|
|
584
|
-
variables: Util_FlatObject<
|
|
585
|
-
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
586
|
-
>,
|
|
724
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
587
725
|
context: Context,
|
|
588
726
|
) => void | Promise<void>
|
|
589
727
|
onError?: (
|
|
590
728
|
queryClient: QueryClient,
|
|
591
729
|
error: Error,
|
|
592
|
-
variables: Util_FlatObject<
|
|
593
|
-
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
594
|
-
>,
|
|
730
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
595
731
|
context: Context,
|
|
596
732
|
) => void | Promise<void>
|
|
597
733
|
},
|
|
598
734
|
): ((
|
|
599
|
-
params:
|
|
735
|
+
params: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
600
736
|
) => UseMutationResult<
|
|
601
737
|
Result,
|
|
602
738
|
Error,
|
|
603
|
-
|
|
739
|
+
MutationArgs<Url, RequestSchema, undefined>
|
|
604
740
|
>) &
|
|
605
741
|
MutationHelpers<Url, Result> &
|
|
606
|
-
|
|
742
|
+
EndpointHelper<Method, Url, RequestSchema, Response, undefined>
|
|
607
743
|
|
|
608
744
|
mutationFromEndpoint<
|
|
609
745
|
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
610
746
|
Url extends string = string,
|
|
611
747
|
RequestSchema extends ZodType = ZodType,
|
|
612
|
-
QuerySchema extends
|
|
748
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
613
749
|
Response extends ZodType = ZodType,
|
|
614
750
|
ReqResult = z.output<Response>,
|
|
615
751
|
Result = unknown,
|
|
616
752
|
Context = unknown,
|
|
617
753
|
>(
|
|
618
|
-
endpoint:
|
|
754
|
+
endpoint: {
|
|
619
755
|
config: BaseEndpointConfig<
|
|
620
756
|
Method,
|
|
621
757
|
Url,
|
|
@@ -631,7 +767,7 @@ export interface ClientInstance {
|
|
|
631
767
|
queryClient: QueryClient,
|
|
632
768
|
data: NoInfer<Result>,
|
|
633
769
|
variables: Util_FlatObject<
|
|
634
|
-
|
|
770
|
+
MutationArgs<Url, RequestSchema, QuerySchema>
|
|
635
771
|
>,
|
|
636
772
|
context: Context,
|
|
637
773
|
) => void | Promise<void>
|
|
@@ -639,17 +775,19 @@ export interface ClientInstance {
|
|
|
639
775
|
queryClient: QueryClient,
|
|
640
776
|
error: Error,
|
|
641
777
|
variables: Util_FlatObject<
|
|
642
|
-
|
|
778
|
+
MutationArgs<Url, RequestSchema, QuerySchema>
|
|
643
779
|
>,
|
|
644
780
|
context: Context,
|
|
645
781
|
) => void | Promise<void>
|
|
646
782
|
},
|
|
647
|
-
): ((
|
|
783
|
+
): ((
|
|
784
|
+
params: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
|
|
785
|
+
) => UseMutationResult<
|
|
648
786
|
Result,
|
|
649
787
|
Error,
|
|
650
|
-
|
|
788
|
+
MutationArgs<Url, RequestSchema, QuerySchema>
|
|
651
789
|
>) &
|
|
652
|
-
|
|
790
|
+
EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
|
|
653
791
|
|
|
654
792
|
mutationFromEndpoint<
|
|
655
793
|
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
@@ -660,7 +798,7 @@ export interface ClientInstance {
|
|
|
660
798
|
Result = unknown,
|
|
661
799
|
Context = unknown,
|
|
662
800
|
>(
|
|
663
|
-
endpoint:
|
|
801
|
+
endpoint: {
|
|
664
802
|
config: BaseEndpointConfig<
|
|
665
803
|
Method,
|
|
666
804
|
Url,
|
|
@@ -675,38 +813,40 @@ export interface ClientInstance {
|
|
|
675
813
|
onSuccess?: (
|
|
676
814
|
queryClient: QueryClient,
|
|
677
815
|
data: NoInfer<Result>,
|
|
678
|
-
variables: Util_FlatObject<
|
|
679
|
-
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
680
|
-
>,
|
|
816
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
681
817
|
context: Context,
|
|
682
818
|
) => void | Promise<void>
|
|
683
819
|
onError?: (
|
|
684
820
|
queryClient: QueryClient,
|
|
685
821
|
error: Error,
|
|
686
|
-
variables: Util_FlatObject<
|
|
687
|
-
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
688
|
-
>,
|
|
822
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
689
823
|
context: Context,
|
|
690
824
|
) => void | Promise<void>
|
|
691
825
|
},
|
|
692
|
-
): ((
|
|
826
|
+
): ((
|
|
827
|
+
params: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
828
|
+
) => UseMutationResult<
|
|
693
829
|
Result,
|
|
694
830
|
Error,
|
|
695
|
-
|
|
831
|
+
MutationArgs<Url, RequestSchema, undefined>
|
|
696
832
|
>) &
|
|
697
|
-
|
|
833
|
+
EndpointHelper<Method, Url, RequestSchema, Response, undefined>
|
|
834
|
+
|
|
835
|
+
// ============================================================================
|
|
836
|
+
// DELETE MUTATION FROM ENDPOINT METHODS
|
|
837
|
+
// ============================================================================
|
|
698
838
|
|
|
699
839
|
mutationFromEndpoint<
|
|
700
840
|
Method extends 'DELETE' = 'DELETE',
|
|
701
841
|
Url extends string = string,
|
|
702
|
-
QuerySchema extends
|
|
842
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
703
843
|
Response extends ZodType = ZodType,
|
|
704
844
|
ReqResult = z.output<Response>,
|
|
705
845
|
Result = unknown,
|
|
706
846
|
Context = unknown,
|
|
707
847
|
UseKey extends true = true,
|
|
708
848
|
>(
|
|
709
|
-
endpoint:
|
|
849
|
+
endpoint: {
|
|
710
850
|
config: BaseEndpointConfig<Method, Url, QuerySchema, Response>
|
|
711
851
|
},
|
|
712
852
|
mutationOptions: {
|
|
@@ -716,29 +856,25 @@ export interface ClientInstance {
|
|
|
716
856
|
onSuccess?: (
|
|
717
857
|
queryClient: QueryClient,
|
|
718
858
|
data: NoInfer<Result>,
|
|
719
|
-
variables: Util_FlatObject<
|
|
720
|
-
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
721
|
-
>,
|
|
859
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
|
|
722
860
|
context: Context,
|
|
723
861
|
) => void | Promise<void>
|
|
724
862
|
onError?: (
|
|
725
863
|
queryClient: QueryClient,
|
|
726
864
|
error: Error,
|
|
727
|
-
variables: Util_FlatObject<
|
|
728
|
-
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
729
|
-
>,
|
|
865
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
|
|
730
866
|
context: Context,
|
|
731
867
|
) => void | Promise<void>
|
|
732
868
|
},
|
|
733
869
|
): ((
|
|
734
|
-
params:
|
|
870
|
+
params: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
|
|
735
871
|
) => UseMutationResult<
|
|
736
872
|
Result,
|
|
737
873
|
Error,
|
|
738
|
-
|
|
874
|
+
MutationArgs<Url, undefined, QuerySchema>
|
|
739
875
|
>) &
|
|
740
876
|
MutationHelpers<Url, Result> &
|
|
741
|
-
|
|
877
|
+
EndpointHelper<Method, Url, undefined, Response, QuerySchema>
|
|
742
878
|
|
|
743
879
|
mutationFromEndpoint<
|
|
744
880
|
Method extends 'DELETE' = 'DELETE',
|
|
@@ -749,7 +885,7 @@ export interface ClientInstance {
|
|
|
749
885
|
Context = unknown,
|
|
750
886
|
UseKey extends true = true,
|
|
751
887
|
>(
|
|
752
|
-
endpoint:
|
|
888
|
+
endpoint: {
|
|
753
889
|
config: BaseEndpointConfig<Method, Url, undefined, Response>
|
|
754
890
|
},
|
|
755
891
|
mutationOptions: {
|
|
@@ -759,40 +895,36 @@ export interface ClientInstance {
|
|
|
759
895
|
onSuccess?: (
|
|
760
896
|
queryClient: QueryClient,
|
|
761
897
|
data: NoInfer<Result>,
|
|
762
|
-
variables: Util_FlatObject<
|
|
763
|
-
ClientMutationArgs<Url, undefined, undefined>
|
|
764
|
-
>,
|
|
898
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
|
|
765
899
|
context: Context,
|
|
766
900
|
) => void | Promise<void>
|
|
767
901
|
onError?: (
|
|
768
902
|
queryClient: QueryClient,
|
|
769
903
|
error: Error,
|
|
770
|
-
variables: Util_FlatObject<
|
|
771
|
-
ClientMutationArgs<Url, undefined, undefined>
|
|
772
|
-
>,
|
|
904
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
|
|
773
905
|
context: Context,
|
|
774
906
|
) => void | Promise<void>
|
|
775
907
|
},
|
|
776
908
|
): ((
|
|
777
|
-
params:
|
|
909
|
+
params: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
|
|
778
910
|
) => UseMutationResult<
|
|
779
911
|
Result,
|
|
780
912
|
Error,
|
|
781
|
-
|
|
913
|
+
MutationArgs<Url, undefined, undefined>
|
|
782
914
|
>) &
|
|
783
915
|
MutationHelpers<Url, Result> &
|
|
784
|
-
|
|
916
|
+
EndpointHelper<Method, Url, undefined, Response, undefined>
|
|
785
917
|
|
|
786
918
|
mutationFromEndpoint<
|
|
787
919
|
Method extends 'DELETE' = 'DELETE',
|
|
788
920
|
Url extends string = string,
|
|
789
|
-
QuerySchema extends
|
|
921
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
790
922
|
Response extends ZodType = ZodType,
|
|
791
923
|
ReqResult = z.output<Response>,
|
|
792
924
|
Result = unknown,
|
|
793
925
|
Context = unknown,
|
|
794
926
|
>(
|
|
795
|
-
endpoint:
|
|
927
|
+
endpoint: {
|
|
796
928
|
config: BaseEndpointConfig<Method, Url, QuerySchema, Response>
|
|
797
929
|
},
|
|
798
930
|
mutationOptions: {
|
|
@@ -801,26 +933,24 @@ export interface ClientInstance {
|
|
|
801
933
|
onSuccess?: (
|
|
802
934
|
queryClient: QueryClient,
|
|
803
935
|
data: NoInfer<Result>,
|
|
804
|
-
variables: Util_FlatObject<
|
|
805
|
-
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
806
|
-
>,
|
|
936
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
|
|
807
937
|
context: Context,
|
|
808
938
|
) => void | Promise<void>
|
|
809
939
|
onError?: (
|
|
810
940
|
queryClient: QueryClient,
|
|
811
941
|
error: Error,
|
|
812
|
-
variables: Util_FlatObject<
|
|
813
|
-
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
814
|
-
>,
|
|
942
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
|
|
815
943
|
context: Context,
|
|
816
944
|
) => void | Promise<void>
|
|
817
945
|
},
|
|
818
|
-
): ((
|
|
946
|
+
): ((
|
|
947
|
+
params: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
|
|
948
|
+
) => UseMutationResult<
|
|
819
949
|
Result,
|
|
820
950
|
Error,
|
|
821
|
-
|
|
951
|
+
MutationArgs<Url, undefined, QuerySchema>
|
|
822
952
|
>) &
|
|
823
|
-
|
|
953
|
+
EndpointHelper<Method, Url, undefined, Response, QuerySchema>
|
|
824
954
|
|
|
825
955
|
mutationFromEndpoint<
|
|
826
956
|
Method extends 'DELETE' = 'DELETE',
|
|
@@ -830,7 +960,7 @@ export interface ClientInstance {
|
|
|
830
960
|
Result = unknown,
|
|
831
961
|
Context = unknown,
|
|
832
962
|
>(
|
|
833
|
-
endpoint:
|
|
963
|
+
endpoint: {
|
|
834
964
|
config: BaseEndpointConfig<Method, Url, undefined, Response>
|
|
835
965
|
},
|
|
836
966
|
mutationOptions: {
|
|
@@ -839,26 +969,178 @@ export interface ClientInstance {
|
|
|
839
969
|
onSuccess?: (
|
|
840
970
|
queryClient: QueryClient,
|
|
841
971
|
data: NoInfer<Result>,
|
|
842
|
-
variables: Util_FlatObject<
|
|
843
|
-
ClientMutationArgs<Url, undefined, undefined>
|
|
844
|
-
>,
|
|
972
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
|
|
845
973
|
context: Context,
|
|
846
974
|
) => void | Promise<void>
|
|
847
975
|
onError?: (
|
|
848
976
|
queryClient: QueryClient,
|
|
849
977
|
error: Error,
|
|
850
|
-
variables: Util_FlatObject<
|
|
851
|
-
ClientMutationArgs<Url, undefined, undefined>
|
|
852
|
-
>,
|
|
978
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
|
|
853
979
|
context: Context,
|
|
854
980
|
) => void | Promise<void>
|
|
855
981
|
},
|
|
856
982
|
): ((
|
|
983
|
+
params: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
|
|
984
|
+
) => UseMutationResult<
|
|
985
|
+
Result,
|
|
986
|
+
Error,
|
|
987
|
+
MutationArgs<Url, undefined, undefined>
|
|
988
|
+
>) &
|
|
989
|
+
EndpointHelper<Method, Url, undefined, Response, undefined>
|
|
990
|
+
|
|
991
|
+
// ============================================================================
|
|
992
|
+
// MULTIPART MUTATION METHODS
|
|
993
|
+
// ============================================================================
|
|
994
|
+
|
|
995
|
+
multipartMutation<
|
|
996
|
+
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
997
|
+
Url extends string = string,
|
|
998
|
+
RequestSchema extends ZodType = ZodType,
|
|
999
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
1000
|
+
Response extends ZodType = ZodType,
|
|
1001
|
+
ReqResult = z.output<Response>,
|
|
1002
|
+
Result = unknown,
|
|
1003
|
+
Context = unknown,
|
|
1004
|
+
UseKey extends true = true,
|
|
1005
|
+
>(config: {
|
|
1006
|
+
method: Method
|
|
1007
|
+
url: Url
|
|
1008
|
+
useKey: UseKey
|
|
1009
|
+
requestSchema: RequestSchema
|
|
1010
|
+
querySchema: QuerySchema
|
|
1011
|
+
responseSchema: Response
|
|
1012
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
1013
|
+
useContext?: () => Context
|
|
1014
|
+
onSuccess?: (
|
|
1015
|
+
queryClient: QueryClient,
|
|
1016
|
+
data: NoInfer<Result>,
|
|
1017
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
|
|
1018
|
+
context: Context,
|
|
1019
|
+
) => void | Promise<void>
|
|
1020
|
+
onError?: (
|
|
1021
|
+
queryClient: QueryClient,
|
|
1022
|
+
error: Error,
|
|
1023
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
|
|
1024
|
+
context: Context,
|
|
1025
|
+
) => void | Promise<void>
|
|
1026
|
+
}): ((
|
|
1027
|
+
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
1028
|
+
) => UseMutationResult<
|
|
1029
|
+
Result,
|
|
1030
|
+
Error,
|
|
1031
|
+
MutationArgs<Url, RequestSchema, QuerySchema>
|
|
1032
|
+
>) &
|
|
1033
|
+
MutationHelpers<Url, Result> &
|
|
1034
|
+
EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
|
|
1035
|
+
|
|
1036
|
+
multipartMutation<
|
|
1037
|
+
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
1038
|
+
Url extends string = string,
|
|
1039
|
+
RequestSchema extends ZodType = ZodType,
|
|
1040
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
1041
|
+
Response extends ZodType = ZodType,
|
|
1042
|
+
ReqResult = z.output<Response>,
|
|
1043
|
+
Result = unknown,
|
|
1044
|
+
Context = unknown,
|
|
1045
|
+
>(config: {
|
|
1046
|
+
method: Method
|
|
1047
|
+
url: Url
|
|
1048
|
+
requestSchema: RequestSchema
|
|
1049
|
+
querySchema: QuerySchema
|
|
1050
|
+
responseSchema: Response
|
|
1051
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
1052
|
+
useContext?: () => Context
|
|
1053
|
+
onSuccess?: (
|
|
1054
|
+
queryClient: QueryClient,
|
|
1055
|
+
data: NoInfer<Result>,
|
|
1056
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
|
|
1057
|
+
context: Context,
|
|
1058
|
+
) => void | Promise<void>
|
|
1059
|
+
onError?: (
|
|
1060
|
+
queryClient: QueryClient,
|
|
1061
|
+
error: Error,
|
|
1062
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
|
|
1063
|
+
context: Context,
|
|
1064
|
+
) => void | Promise<void>
|
|
1065
|
+
}): (() => UseMutationResult<
|
|
1066
|
+
Result,
|
|
1067
|
+
Error,
|
|
1068
|
+
MutationArgs<Url, RequestSchema, QuerySchema>
|
|
1069
|
+
>) &
|
|
1070
|
+
MutationHelpers<Url, Result> &
|
|
1071
|
+
EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
|
|
1072
|
+
|
|
1073
|
+
multipartMutation<
|
|
1074
|
+
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
1075
|
+
Url extends string = string,
|
|
1076
|
+
RequestSchema extends ZodType = ZodType,
|
|
1077
|
+
Response extends ZodType = ZodType,
|
|
1078
|
+
ReqResult = z.output<Response>,
|
|
1079
|
+
Result = unknown,
|
|
1080
|
+
Context = unknown,
|
|
1081
|
+
>(config: {
|
|
1082
|
+
method: Method
|
|
1083
|
+
url: Url
|
|
1084
|
+
requestSchema: RequestSchema
|
|
1085
|
+
responseSchema: Response
|
|
1086
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
1087
|
+
useContext?: () => Context
|
|
1088
|
+
onSuccess?: (
|
|
1089
|
+
queryClient: QueryClient,
|
|
1090
|
+
data: NoInfer<Result>,
|
|
1091
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
1092
|
+
context: Context,
|
|
1093
|
+
) => void | Promise<void>
|
|
1094
|
+
onError?: (
|
|
1095
|
+
queryClient: QueryClient,
|
|
1096
|
+
error: Error,
|
|
1097
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
1098
|
+
context: Context,
|
|
1099
|
+
) => void | Promise<void>
|
|
1100
|
+
}): (() => UseMutationResult<
|
|
1101
|
+
Result,
|
|
1102
|
+
Error,
|
|
1103
|
+
MutationArgs<Url, RequestSchema, undefined>
|
|
1104
|
+
>) &
|
|
1105
|
+
MutationHelpers<Url, Result> &
|
|
1106
|
+
EndpointHelper<Method, Url, RequestSchema, Response>
|
|
1107
|
+
|
|
1108
|
+
multipartMutation<
|
|
1109
|
+
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
1110
|
+
Url extends string = string,
|
|
1111
|
+
RequestSchema extends ZodType = ZodType,
|
|
1112
|
+
Response extends ZodType = ZodType,
|
|
1113
|
+
ReqResult = z.output<Response>,
|
|
1114
|
+
Result = unknown,
|
|
1115
|
+
Context = unknown,
|
|
1116
|
+
UseKey extends true = true,
|
|
1117
|
+
>(config: {
|
|
1118
|
+
method: Method
|
|
1119
|
+
url: Url
|
|
1120
|
+
useKey: UseKey
|
|
1121
|
+
requestSchema: RequestSchema
|
|
1122
|
+
responseSchema: Response
|
|
1123
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
1124
|
+
useContext?: () => Context
|
|
1125
|
+
onSuccess?: (
|
|
1126
|
+
queryClient: QueryClient,
|
|
1127
|
+
data: NoInfer<Result>,
|
|
1128
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
1129
|
+
context: Context,
|
|
1130
|
+
) => void | Promise<void>
|
|
1131
|
+
onError?: (
|
|
1132
|
+
queryClient: QueryClient,
|
|
1133
|
+
error: Error,
|
|
1134
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
1135
|
+
context: Context,
|
|
1136
|
+
) => void | Promise<void>
|
|
1137
|
+
}): ((
|
|
857
1138
|
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
858
1139
|
) => UseMutationResult<
|
|
859
1140
|
Result,
|
|
860
1141
|
Error,
|
|
861
|
-
|
|
1142
|
+
MutationArgs<Url, RequestSchema, undefined>
|
|
862
1143
|
>) &
|
|
863
|
-
|
|
1144
|
+
MutationHelpers<Url, Result> &
|
|
1145
|
+
EndpointHelper<Method, Url, RequestSchema, Response>
|
|
864
1146
|
}
|