@navios/react-query 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +80 -0
- package/dist/src/client/__type-tests__/client-instance.spec-d.d.mts +2 -0
- package/dist/src/client/__type-tests__/client-instance.spec-d.d.mts.map +1 -0
- 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 +301 -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/index.d.mts +13 -8
- package/dist/src/index.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/tsconfig.tsbuildinfo +1 -1
- package/lib/_tsup-dts-rollup.d.mts +514 -250
- package/lib/_tsup-dts-rollup.d.ts +514 -250
- 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 +7 -7
- package/project.json +9 -1
- package/src/__tests__/client-type-check.spec.mts +1 -1
- package/src/__tests__/declare-client.spec.mts +1 -1
- package/src/__tests__/make-mutation.spec.mts +1 -1
- package/src/__tests__/makeDataTag.spec.mts +1 -1
- package/src/__tests__/makeInfiniteQueryOptions.spec.mts +1 -2
- package/src/__tests__/makeQueryOptions.spec.mts +1 -1
- package/src/client/__type-tests__/client-instance.spec-d.mts +702 -0
- package/src/{declare-client.mts → client/declare-client.mts} +93 -33
- package/src/client/index.mts +2 -0
- package/src/{types/client-instance.mts → client/types.mts} +423 -149
- 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} +19 -8
- 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 -48
- package/src/{make-infinite-query-options.mts → query/make-infinite-options.mts} +28 -14
- 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,
|
|
@@ -14,14 +16,55 @@ import type {
|
|
|
14
16
|
} from '@tanstack/react-query'
|
|
15
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,8 +84,9 @@ 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,
|
|
@@ -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,8 +108,63 @@ 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>
|
|
68
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
|
+
// ============================================================================
|
|
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,
|
|
@@ -92,7 +191,7 @@ 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,
|
|
@@ -101,8 +200,53 @@ export interface ClientInstance {
|
|
|
101
200
|
z.output<QuerySchema>
|
|
102
201
|
>) &
|
|
103
202
|
QueryHelpers<Url, QuerySchema, PageResult, true> &
|
|
104
|
-
|
|
203
|
+
EndpointHelper<Method, Url, undefined, Response, QuerySchema>
|
|
105
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
|
+
// ============================================================================
|
|
248
|
+
|
|
249
|
+
// With useKey, requestSchema, and querySchema
|
|
106
250
|
mutation<
|
|
107
251
|
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
108
252
|
Url extends string = string,
|
|
@@ -125,17 +269,13 @@ export interface ClientInstance {
|
|
|
125
269
|
onSuccess?: (
|
|
126
270
|
queryClient: QueryClient,
|
|
127
271
|
data: NoInfer<Result>,
|
|
128
|
-
variables: Util_FlatObject<
|
|
129
|
-
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
130
|
-
>,
|
|
272
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
|
|
131
273
|
context: Context,
|
|
132
274
|
) => void | Promise<void>
|
|
133
275
|
onError?: (
|
|
134
276
|
queryClient: QueryClient,
|
|
135
277
|
error: Error,
|
|
136
|
-
variables: Util_FlatObject<
|
|
137
|
-
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
138
|
-
>,
|
|
278
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
|
|
139
279
|
context: Context,
|
|
140
280
|
) => void | Promise<void>
|
|
141
281
|
}): ((
|
|
@@ -143,11 +283,12 @@ export interface ClientInstance {
|
|
|
143
283
|
) => UseMutationResult<
|
|
144
284
|
Result,
|
|
145
285
|
Error,
|
|
146
|
-
|
|
286
|
+
MutationArgs<Url, RequestSchema, QuerySchema>
|
|
147
287
|
>) &
|
|
148
288
|
MutationHelpers<Url, Result> &
|
|
149
|
-
|
|
289
|
+
EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
|
|
150
290
|
|
|
291
|
+
// Without useKey, with requestSchema and querySchema
|
|
151
292
|
mutation<
|
|
152
293
|
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
153
294
|
Url extends string = string,
|
|
@@ -168,26 +309,24 @@ export interface ClientInstance {
|
|
|
168
309
|
onSuccess?: (
|
|
169
310
|
queryClient: QueryClient,
|
|
170
311
|
data: NoInfer<Result>,
|
|
171
|
-
variables: Util_FlatObject<
|
|
172
|
-
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
173
|
-
>,
|
|
312
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
|
|
174
313
|
context: Context,
|
|
175
314
|
) => void | Promise<void>
|
|
176
315
|
onError?: (
|
|
177
316
|
queryClient: QueryClient,
|
|
178
317
|
error: Error,
|
|
179
|
-
variables: Util_FlatObject<
|
|
180
|
-
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
181
|
-
>,
|
|
318
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
|
|
182
319
|
context: Context,
|
|
183
320
|
) => void | Promise<void>
|
|
184
321
|
}): (() => UseMutationResult<
|
|
185
322
|
Result,
|
|
186
323
|
Error,
|
|
187
|
-
|
|
324
|
+
MutationArgs<Url, RequestSchema, QuerySchema>
|
|
188
325
|
>) &
|
|
189
|
-
|
|
326
|
+
MutationHelpers<Url, Result> &
|
|
327
|
+
EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
|
|
190
328
|
|
|
329
|
+
// Without useKey, with requestSchema only
|
|
191
330
|
mutation<
|
|
192
331
|
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
193
332
|
Url extends string = string,
|
|
@@ -206,27 +345,24 @@ export interface ClientInstance {
|
|
|
206
345
|
onSuccess?: (
|
|
207
346
|
queryClient: QueryClient,
|
|
208
347
|
data: NoInfer<Result>,
|
|
209
|
-
variables: Util_FlatObject<
|
|
210
|
-
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
211
|
-
>,
|
|
348
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
212
349
|
context: Context,
|
|
213
350
|
) => void | Promise<void>
|
|
214
351
|
onError?: (
|
|
215
352
|
queryClient: QueryClient,
|
|
216
353
|
error: Error,
|
|
217
|
-
variables: Util_FlatObject<
|
|
218
|
-
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
219
|
-
>,
|
|
354
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
220
355
|
context: Context,
|
|
221
356
|
) => void | Promise<void>
|
|
222
357
|
}): (() => UseMutationResult<
|
|
223
358
|
Result,
|
|
224
359
|
Error,
|
|
225
|
-
|
|
360
|
+
MutationArgs<Url, RequestSchema, undefined>
|
|
226
361
|
>) &
|
|
227
362
|
MutationHelpers<Url, Result> &
|
|
228
|
-
|
|
363
|
+
EndpointHelper<Method, Url, RequestSchema, Response>
|
|
229
364
|
|
|
365
|
+
// With useKey and requestSchema only
|
|
230
366
|
mutation<
|
|
231
367
|
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
232
368
|
Url extends string = string,
|
|
@@ -247,29 +383,30 @@ export interface ClientInstance {
|
|
|
247
383
|
onSuccess?: (
|
|
248
384
|
queryClient: QueryClient,
|
|
249
385
|
data: NoInfer<Result>,
|
|
250
|
-
variables: Util_FlatObject<
|
|
251
|
-
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
252
|
-
>,
|
|
386
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
253
387
|
context: Context,
|
|
254
388
|
) => void | Promise<void>
|
|
255
389
|
onError?: (
|
|
256
390
|
queryClient: QueryClient,
|
|
257
391
|
error: Error,
|
|
258
|
-
variables: Util_FlatObject<
|
|
259
|
-
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
260
|
-
>,
|
|
392
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
261
393
|
context: Context,
|
|
262
394
|
) => void | Promise<void>
|
|
263
395
|
}): ((
|
|
264
|
-
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
396
|
+
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
265
397
|
) => UseMutationResult<
|
|
266
398
|
Result,
|
|
267
399
|
Error,
|
|
268
|
-
|
|
400
|
+
MutationArgs<Url, RequestSchema, undefined>
|
|
269
401
|
>) &
|
|
270
402
|
MutationHelpers<Url, Result> &
|
|
271
|
-
|
|
403
|
+
EndpointHelper<Method, Url, RequestSchema, Response>
|
|
272
404
|
|
|
405
|
+
// ============================================================================
|
|
406
|
+
// DELETE MUTATION METHODS
|
|
407
|
+
// ============================================================================
|
|
408
|
+
|
|
409
|
+
// DELETE with useKey and querySchema
|
|
273
410
|
mutation<
|
|
274
411
|
Method extends 'DELETE' = 'DELETE',
|
|
275
412
|
Url extends string = string,
|
|
@@ -290,29 +427,26 @@ export interface ClientInstance {
|
|
|
290
427
|
onSuccess?: (
|
|
291
428
|
queryClient: QueryClient,
|
|
292
429
|
data: NoInfer<Result>,
|
|
293
|
-
variables: Util_FlatObject<
|
|
294
|
-
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
295
|
-
>,
|
|
430
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
|
|
296
431
|
context: Context,
|
|
297
432
|
) => void | Promise<void>
|
|
298
433
|
onError?: (
|
|
299
434
|
queryClient: QueryClient,
|
|
300
435
|
error: Error,
|
|
301
|
-
variables: Util_FlatObject<
|
|
302
|
-
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
303
|
-
>,
|
|
436
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
|
|
304
437
|
context: Context,
|
|
305
438
|
) => void | Promise<void>
|
|
306
439
|
}): ((
|
|
307
|
-
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
440
|
+
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
308
441
|
) => UseMutationResult<
|
|
309
442
|
Result,
|
|
310
443
|
Error,
|
|
311
|
-
|
|
444
|
+
MutationArgs<Url, undefined, QuerySchema>
|
|
312
445
|
>) &
|
|
313
446
|
MutationHelpers<Url, Result> &
|
|
314
|
-
|
|
447
|
+
EndpointHelper<Method, Url, undefined, Response, QuerySchema>
|
|
315
448
|
|
|
449
|
+
// DELETE without useKey, with querySchema
|
|
316
450
|
mutation<
|
|
317
451
|
Method extends 'DELETE' = 'DELETE',
|
|
318
452
|
Url extends string = string,
|
|
@@ -331,26 +465,24 @@ export interface ClientInstance {
|
|
|
331
465
|
onSuccess?: (
|
|
332
466
|
queryClient: QueryClient,
|
|
333
467
|
data: NoInfer<Result>,
|
|
334
|
-
variables: Util_FlatObject<
|
|
335
|
-
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
336
|
-
>,
|
|
468
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
|
|
337
469
|
context: Context,
|
|
338
470
|
) => void | Promise<void>
|
|
339
471
|
onError?: (
|
|
340
472
|
queryClient: QueryClient,
|
|
341
473
|
error: Error,
|
|
342
|
-
variables: Util_FlatObject<
|
|
343
|
-
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
344
|
-
>,
|
|
474
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
|
|
345
475
|
context: Context,
|
|
346
476
|
) => void | Promise<void>
|
|
347
477
|
}): (() => UseMutationResult<
|
|
348
478
|
Result,
|
|
349
479
|
Error,
|
|
350
|
-
|
|
480
|
+
MutationArgs<Url, undefined, QuerySchema>
|
|
351
481
|
>) &
|
|
352
|
-
|
|
482
|
+
MutationHelpers<Url, Result> &
|
|
483
|
+
EndpointHelper<Method, Url, undefined, Response, QuerySchema>
|
|
353
484
|
|
|
485
|
+
// DELETE with useKey only (no schemas)
|
|
354
486
|
mutation<
|
|
355
487
|
Method extends 'DELETE' = 'DELETE',
|
|
356
488
|
Url extends string = string,
|
|
@@ -369,25 +501,26 @@ export interface ClientInstance {
|
|
|
369
501
|
onSuccess?: (
|
|
370
502
|
queryClient: QueryClient,
|
|
371
503
|
data: NoInfer<Result>,
|
|
372
|
-
variables: Util_FlatObject<
|
|
504
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
|
|
373
505
|
context: Context,
|
|
374
506
|
) => void | Promise<void>
|
|
375
507
|
onError?: (
|
|
376
508
|
queryClient: QueryClient,
|
|
377
509
|
error: Error,
|
|
378
|
-
variables: Util_FlatObject<
|
|
510
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
|
|
379
511
|
context: Context,
|
|
380
512
|
) => void | Promise<void>
|
|
381
513
|
}): ((
|
|
382
|
-
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
514
|
+
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
383
515
|
) => UseMutationResult<
|
|
384
516
|
Result,
|
|
385
517
|
Error,
|
|
386
|
-
|
|
518
|
+
MutationArgs<Url, undefined, undefined>
|
|
387
519
|
>) &
|
|
388
520
|
MutationHelpers<Url, Result> &
|
|
389
|
-
|
|
521
|
+
EndpointHelper<Method, Url, undefined, Response>
|
|
390
522
|
|
|
523
|
+
// DELETE without useKey (no schemas)
|
|
391
524
|
mutation<
|
|
392
525
|
Method extends 'DELETE' = 'DELETE',
|
|
393
526
|
Url extends string = string,
|
|
@@ -404,21 +537,26 @@ export interface ClientInstance {
|
|
|
404
537
|
onSuccess?: (
|
|
405
538
|
queryClient: QueryClient,
|
|
406
539
|
data: NoInfer<Result>,
|
|
407
|
-
variables: Util_FlatObject<
|
|
540
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
|
|
408
541
|
context: Context,
|
|
409
542
|
) => void | Promise<void>
|
|
410
543
|
onError?: (
|
|
411
544
|
queryClient: QueryClient,
|
|
412
545
|
error: Error,
|
|
413
|
-
variables: Util_FlatObject<
|
|
546
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
|
|
414
547
|
context: Context,
|
|
415
548
|
) => void | Promise<void>
|
|
416
549
|
}): (() => UseMutationResult<
|
|
417
550
|
Result,
|
|
418
551
|
Error,
|
|
419
|
-
|
|
552
|
+
MutationArgs<Url, undefined, undefined>
|
|
420
553
|
>) &
|
|
421
|
-
|
|
554
|
+
MutationHelpers<Url, Result> &
|
|
555
|
+
EndpointHelper<Method, Url, undefined, Response>
|
|
556
|
+
|
|
557
|
+
// ============================================================================
|
|
558
|
+
// FROM ENDPOINT METHODS
|
|
559
|
+
// ============================================================================
|
|
422
560
|
|
|
423
561
|
queryFromEndpoint<
|
|
424
562
|
Method extends 'GET' | 'HEAD' | 'OPTIONS' = 'GET',
|
|
@@ -427,14 +565,14 @@ export interface ClientInstance {
|
|
|
427
565
|
Response extends ZodType = ZodType,
|
|
428
566
|
Result = z.output<Response>,
|
|
429
567
|
>(
|
|
430
|
-
endpoint:
|
|
568
|
+
endpoint: {
|
|
431
569
|
config: BaseEndpointConfig<Method, Url, QuerySchema, Response>
|
|
432
570
|
},
|
|
433
571
|
options?: {
|
|
434
572
|
processResponse?: (data: z.output<Response>) => Result
|
|
435
573
|
},
|
|
436
574
|
): (
|
|
437
|
-
params:
|
|
575
|
+
params: Util_FlatObject<QueryArgs<Url, QuerySchema>>,
|
|
438
576
|
) => UseSuspenseQueryOptions<
|
|
439
577
|
Result,
|
|
440
578
|
Error,
|
|
@@ -449,14 +587,14 @@ export interface ClientInstance {
|
|
|
449
587
|
Response extends ZodType = ZodType,
|
|
450
588
|
Result = z.output<Response>,
|
|
451
589
|
>(
|
|
452
|
-
endpoint:
|
|
590
|
+
endpoint: {
|
|
453
591
|
config: BaseEndpointConfig<Method, Url, undefined, Response>
|
|
454
592
|
},
|
|
455
593
|
options?: {
|
|
456
594
|
processResponse?: (data: z.output<Response>) => Result
|
|
457
595
|
},
|
|
458
596
|
): ((
|
|
459
|
-
params:
|
|
597
|
+
params: Util_FlatObject<QueryArgs<Url, undefined>>,
|
|
460
598
|
) => UseSuspenseQueryOptions<
|
|
461
599
|
Result,
|
|
462
600
|
Error,
|
|
@@ -473,7 +611,7 @@ export interface ClientInstance {
|
|
|
473
611
|
PageResult = z.output<Response>,
|
|
474
612
|
Result = InfiniteData<PageResult>,
|
|
475
613
|
>(
|
|
476
|
-
endpoint:
|
|
614
|
+
endpoint: {
|
|
477
615
|
config: BaseEndpointConfig<Method, Url, QuerySchema, Response>
|
|
478
616
|
},
|
|
479
617
|
options: {
|
|
@@ -492,7 +630,7 @@ export interface ClientInstance {
|
|
|
492
630
|
) => z.input<QuerySchema>
|
|
493
631
|
},
|
|
494
632
|
): ((
|
|
495
|
-
params:
|
|
633
|
+
params: Util_FlatObject<QueryArgs<Url, QuerySchema>>,
|
|
496
634
|
) => UseSuspenseInfiniteQueryOptions<
|
|
497
635
|
PageResult,
|
|
498
636
|
Error,
|
|
@@ -502,6 +640,10 @@ export interface ClientInstance {
|
|
|
502
640
|
>) &
|
|
503
641
|
QueryHelpers<Url, QuerySchema, PageResult, true>
|
|
504
642
|
|
|
643
|
+
// ============================================================================
|
|
644
|
+
// MUTATION FROM ENDPOINT METHODS (POST, PUT, PATCH)
|
|
645
|
+
// ============================================================================
|
|
646
|
+
|
|
505
647
|
mutationFromEndpoint<
|
|
506
648
|
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
507
649
|
Url extends string = string,
|
|
@@ -513,7 +655,7 @@ export interface ClientInstance {
|
|
|
513
655
|
Context = unknown,
|
|
514
656
|
UseKey extends true = true,
|
|
515
657
|
>(
|
|
516
|
-
endpoint:
|
|
658
|
+
endpoint: {
|
|
517
659
|
config: BaseEndpointConfig<
|
|
518
660
|
Method,
|
|
519
661
|
Url,
|
|
@@ -530,7 +672,7 @@ export interface ClientInstance {
|
|
|
530
672
|
queryClient: QueryClient,
|
|
531
673
|
data: NoInfer<Result>,
|
|
532
674
|
variables: Util_FlatObject<
|
|
533
|
-
|
|
675
|
+
MutationArgs<Url, RequestSchema, QuerySchema>
|
|
534
676
|
>,
|
|
535
677
|
context: Context,
|
|
536
678
|
) => void | Promise<void>
|
|
@@ -538,20 +680,20 @@ export interface ClientInstance {
|
|
|
538
680
|
queryClient: QueryClient,
|
|
539
681
|
error: Error,
|
|
540
682
|
variables: Util_FlatObject<
|
|
541
|
-
|
|
683
|
+
MutationArgs<Url, RequestSchema, QuerySchema>
|
|
542
684
|
>,
|
|
543
685
|
context: Context,
|
|
544
686
|
) => void | Promise<void>
|
|
545
687
|
},
|
|
546
688
|
): ((
|
|
547
|
-
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
689
|
+
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
548
690
|
) => UseMutationResult<
|
|
549
691
|
Result,
|
|
550
692
|
Error,
|
|
551
|
-
|
|
693
|
+
MutationArgs<Url, RequestSchema, QuerySchema>
|
|
552
694
|
>) &
|
|
553
695
|
MutationHelpers<Url, Result> &
|
|
554
|
-
|
|
696
|
+
EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
|
|
555
697
|
|
|
556
698
|
mutationFromEndpoint<
|
|
557
699
|
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
@@ -563,7 +705,7 @@ export interface ClientInstance {
|
|
|
563
705
|
Context = unknown,
|
|
564
706
|
UseKey extends true = true,
|
|
565
707
|
>(
|
|
566
|
-
endpoint:
|
|
708
|
+
endpoint: {
|
|
567
709
|
config: BaseEndpointConfig<
|
|
568
710
|
Method,
|
|
569
711
|
Url,
|
|
@@ -579,29 +721,25 @@ export interface ClientInstance {
|
|
|
579
721
|
onSuccess?: (
|
|
580
722
|
queryClient: QueryClient,
|
|
581
723
|
data: NoInfer<Result>,
|
|
582
|
-
variables: Util_FlatObject<
|
|
583
|
-
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
584
|
-
>,
|
|
724
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
585
725
|
context: Context,
|
|
586
726
|
) => void | Promise<void>
|
|
587
727
|
onError?: (
|
|
588
728
|
queryClient: QueryClient,
|
|
589
729
|
error: Error,
|
|
590
|
-
variables: Util_FlatObject<
|
|
591
|
-
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
592
|
-
>,
|
|
730
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
593
731
|
context: Context,
|
|
594
732
|
) => void | Promise<void>
|
|
595
733
|
},
|
|
596
734
|
): ((
|
|
597
|
-
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
735
|
+
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
598
736
|
) => UseMutationResult<
|
|
599
737
|
Result,
|
|
600
738
|
Error,
|
|
601
|
-
|
|
739
|
+
MutationArgs<Url, RequestSchema, undefined>
|
|
602
740
|
>) &
|
|
603
741
|
MutationHelpers<Url, Result> &
|
|
604
|
-
|
|
742
|
+
EndpointHelper<Method, Url, RequestSchema, Response, undefined>
|
|
605
743
|
|
|
606
744
|
mutationFromEndpoint<
|
|
607
745
|
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
@@ -613,7 +751,7 @@ export interface ClientInstance {
|
|
|
613
751
|
Result = unknown,
|
|
614
752
|
Context = unknown,
|
|
615
753
|
>(
|
|
616
|
-
endpoint:
|
|
754
|
+
endpoint: {
|
|
617
755
|
config: BaseEndpointConfig<
|
|
618
756
|
Method,
|
|
619
757
|
Url,
|
|
@@ -629,7 +767,7 @@ export interface ClientInstance {
|
|
|
629
767
|
queryClient: QueryClient,
|
|
630
768
|
data: NoInfer<Result>,
|
|
631
769
|
variables: Util_FlatObject<
|
|
632
|
-
|
|
770
|
+
MutationArgs<Url, RequestSchema, QuerySchema>
|
|
633
771
|
>,
|
|
634
772
|
context: Context,
|
|
635
773
|
) => void | Promise<void>
|
|
@@ -637,7 +775,7 @@ export interface ClientInstance {
|
|
|
637
775
|
queryClient: QueryClient,
|
|
638
776
|
error: Error,
|
|
639
777
|
variables: Util_FlatObject<
|
|
640
|
-
|
|
778
|
+
MutationArgs<Url, RequestSchema, QuerySchema>
|
|
641
779
|
>,
|
|
642
780
|
context: Context,
|
|
643
781
|
) => void | Promise<void>
|
|
@@ -645,9 +783,9 @@ export interface ClientInstance {
|
|
|
645
783
|
): (() => UseMutationResult<
|
|
646
784
|
Result,
|
|
647
785
|
Error,
|
|
648
|
-
|
|
786
|
+
MutationArgs<Url, RequestSchema, QuerySchema>
|
|
649
787
|
>) &
|
|
650
|
-
|
|
788
|
+
EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
|
|
651
789
|
|
|
652
790
|
mutationFromEndpoint<
|
|
653
791
|
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
@@ -658,7 +796,7 @@ export interface ClientInstance {
|
|
|
658
796
|
Result = unknown,
|
|
659
797
|
Context = unknown,
|
|
660
798
|
>(
|
|
661
|
-
endpoint:
|
|
799
|
+
endpoint: {
|
|
662
800
|
config: BaseEndpointConfig<
|
|
663
801
|
Method,
|
|
664
802
|
Url,
|
|
@@ -673,26 +811,26 @@ export interface ClientInstance {
|
|
|
673
811
|
onSuccess?: (
|
|
674
812
|
queryClient: QueryClient,
|
|
675
813
|
data: NoInfer<Result>,
|
|
676
|
-
variables: Util_FlatObject<
|
|
677
|
-
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
678
|
-
>,
|
|
814
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
679
815
|
context: Context,
|
|
680
816
|
) => void | Promise<void>
|
|
681
817
|
onError?: (
|
|
682
818
|
queryClient: QueryClient,
|
|
683
819
|
error: Error,
|
|
684
|
-
variables: Util_FlatObject<
|
|
685
|
-
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
686
|
-
>,
|
|
820
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
687
821
|
context: Context,
|
|
688
822
|
) => void | Promise<void>
|
|
689
823
|
},
|
|
690
824
|
): (() => UseMutationResult<
|
|
691
825
|
Result,
|
|
692
826
|
Error,
|
|
693
|
-
|
|
827
|
+
MutationArgs<Url, RequestSchema, undefined>
|
|
694
828
|
>) &
|
|
695
|
-
|
|
829
|
+
EndpointHelper<Method, Url, RequestSchema, Response, undefined>
|
|
830
|
+
|
|
831
|
+
// ============================================================================
|
|
832
|
+
// DELETE MUTATION FROM ENDPOINT METHODS
|
|
833
|
+
// ============================================================================
|
|
696
834
|
|
|
697
835
|
mutationFromEndpoint<
|
|
698
836
|
Method extends 'DELETE' = 'DELETE',
|
|
@@ -704,7 +842,7 @@ export interface ClientInstance {
|
|
|
704
842
|
Context = unknown,
|
|
705
843
|
UseKey extends true = true,
|
|
706
844
|
>(
|
|
707
|
-
endpoint:
|
|
845
|
+
endpoint: {
|
|
708
846
|
config: BaseEndpointConfig<Method, Url, QuerySchema, Response>
|
|
709
847
|
},
|
|
710
848
|
mutationOptions: {
|
|
@@ -714,29 +852,23 @@ export interface ClientInstance {
|
|
|
714
852
|
onSuccess?: (
|
|
715
853
|
queryClient: QueryClient,
|
|
716
854
|
data: NoInfer<Result>,
|
|
717
|
-
variables: Util_FlatObject<
|
|
718
|
-
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
719
|
-
>,
|
|
855
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
|
|
720
856
|
context: Context,
|
|
721
857
|
) => void | Promise<void>
|
|
722
858
|
onError?: (
|
|
723
859
|
queryClient: QueryClient,
|
|
724
860
|
error: Error,
|
|
725
|
-
variables: Util_FlatObject<
|
|
726
|
-
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
727
|
-
>,
|
|
861
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
|
|
728
862
|
context: Context,
|
|
729
863
|
) => void | Promise<void>
|
|
730
864
|
},
|
|
731
|
-
): ((
|
|
732
|
-
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
733
|
-
) => UseMutationResult<
|
|
865
|
+
): (() => UseMutationResult<
|
|
734
866
|
Result,
|
|
735
867
|
Error,
|
|
736
|
-
|
|
868
|
+
MutationArgs<Url, undefined, QuerySchema>
|
|
737
869
|
>) &
|
|
738
870
|
MutationHelpers<Url, Result> &
|
|
739
|
-
|
|
871
|
+
EndpointHelper<Method, Url, undefined, Response, QuerySchema>
|
|
740
872
|
|
|
741
873
|
mutationFromEndpoint<
|
|
742
874
|
Method extends 'DELETE' = 'DELETE',
|
|
@@ -747,7 +879,7 @@ export interface ClientInstance {
|
|
|
747
879
|
Context = unknown,
|
|
748
880
|
UseKey extends true = true,
|
|
749
881
|
>(
|
|
750
|
-
endpoint:
|
|
882
|
+
endpoint: {
|
|
751
883
|
config: BaseEndpointConfig<Method, Url, undefined, Response>
|
|
752
884
|
},
|
|
753
885
|
mutationOptions: {
|
|
@@ -757,29 +889,25 @@ export interface ClientInstance {
|
|
|
757
889
|
onSuccess?: (
|
|
758
890
|
queryClient: QueryClient,
|
|
759
891
|
data: NoInfer<Result>,
|
|
760
|
-
variables: Util_FlatObject<
|
|
761
|
-
ClientMutationArgs<Url, undefined, undefined>
|
|
762
|
-
>,
|
|
892
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
|
|
763
893
|
context: Context,
|
|
764
894
|
) => void | Promise<void>
|
|
765
895
|
onError?: (
|
|
766
896
|
queryClient: QueryClient,
|
|
767
897
|
error: Error,
|
|
768
|
-
variables: Util_FlatObject<
|
|
769
|
-
ClientMutationArgs<Url, undefined, undefined>
|
|
770
|
-
>,
|
|
898
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
|
|
771
899
|
context: Context,
|
|
772
900
|
) => void | Promise<void>
|
|
773
901
|
},
|
|
774
902
|
): ((
|
|
775
|
-
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
903
|
+
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
776
904
|
) => UseMutationResult<
|
|
777
905
|
Result,
|
|
778
906
|
Error,
|
|
779
|
-
|
|
907
|
+
MutationArgs<Url, undefined, undefined>
|
|
780
908
|
>) &
|
|
781
909
|
MutationHelpers<Url, Result> &
|
|
782
|
-
|
|
910
|
+
EndpointHelper<Method, Url, undefined, Response, undefined>
|
|
783
911
|
|
|
784
912
|
mutationFromEndpoint<
|
|
785
913
|
Method extends 'DELETE' = 'DELETE',
|
|
@@ -790,7 +918,7 @@ export interface ClientInstance {
|
|
|
790
918
|
Result = unknown,
|
|
791
919
|
Context = unknown,
|
|
792
920
|
>(
|
|
793
|
-
endpoint:
|
|
921
|
+
endpoint: {
|
|
794
922
|
config: BaseEndpointConfig<Method, Url, QuerySchema, Response>
|
|
795
923
|
},
|
|
796
924
|
mutationOptions: {
|
|
@@ -799,26 +927,22 @@ export interface ClientInstance {
|
|
|
799
927
|
onSuccess?: (
|
|
800
928
|
queryClient: QueryClient,
|
|
801
929
|
data: NoInfer<Result>,
|
|
802
|
-
variables: Util_FlatObject<
|
|
803
|
-
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
804
|
-
>,
|
|
930
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
|
|
805
931
|
context: Context,
|
|
806
932
|
) => void | Promise<void>
|
|
807
933
|
onError?: (
|
|
808
934
|
queryClient: QueryClient,
|
|
809
935
|
error: Error,
|
|
810
|
-
variables: Util_FlatObject<
|
|
811
|
-
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
812
|
-
>,
|
|
936
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
|
|
813
937
|
context: Context,
|
|
814
938
|
) => void | Promise<void>
|
|
815
939
|
},
|
|
816
940
|
): (() => UseMutationResult<
|
|
817
941
|
Result,
|
|
818
942
|
Error,
|
|
819
|
-
|
|
943
|
+
MutationArgs<Url, undefined, QuerySchema>
|
|
820
944
|
>) &
|
|
821
|
-
|
|
945
|
+
EndpointHelper<Method, Url, undefined, Response, QuerySchema>
|
|
822
946
|
|
|
823
947
|
mutationFromEndpoint<
|
|
824
948
|
Method extends 'DELETE' = 'DELETE',
|
|
@@ -828,7 +952,7 @@ export interface ClientInstance {
|
|
|
828
952
|
Result = unknown,
|
|
829
953
|
Context = unknown,
|
|
830
954
|
>(
|
|
831
|
-
endpoint:
|
|
955
|
+
endpoint: {
|
|
832
956
|
config: BaseEndpointConfig<Method, Url, undefined, Response>
|
|
833
957
|
},
|
|
834
958
|
mutationOptions: {
|
|
@@ -837,26 +961,176 @@ export interface ClientInstance {
|
|
|
837
961
|
onSuccess?: (
|
|
838
962
|
queryClient: QueryClient,
|
|
839
963
|
data: NoInfer<Result>,
|
|
840
|
-
variables: Util_FlatObject<
|
|
841
|
-
ClientMutationArgs<Url, undefined, undefined>
|
|
842
|
-
>,
|
|
964
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
|
|
843
965
|
context: Context,
|
|
844
966
|
) => void | Promise<void>
|
|
845
967
|
onError?: (
|
|
846
968
|
queryClient: QueryClient,
|
|
847
969
|
error: Error,
|
|
848
|
-
variables: Util_FlatObject<
|
|
849
|
-
ClientMutationArgs<Url, undefined, undefined>
|
|
850
|
-
>,
|
|
970
|
+
variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
|
|
851
971
|
context: Context,
|
|
852
972
|
) => void | Promise<void>
|
|
853
973
|
},
|
|
854
|
-
): ((
|
|
855
|
-
|
|
974
|
+
): (() => UseMutationResult<
|
|
975
|
+
Result,
|
|
976
|
+
Error,
|
|
977
|
+
MutationArgs<Url, undefined, undefined>
|
|
978
|
+
>) &
|
|
979
|
+
EndpointHelper<Method, Url, undefined, Response, undefined>
|
|
980
|
+
|
|
981
|
+
// ============================================================================
|
|
982
|
+
// MULTIPART MUTATION METHODS
|
|
983
|
+
// ============================================================================
|
|
984
|
+
|
|
985
|
+
multipartMutation<
|
|
986
|
+
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
987
|
+
Url extends string = string,
|
|
988
|
+
RequestSchema extends ZodType = ZodType,
|
|
989
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
990
|
+
Response extends ZodType = ZodType,
|
|
991
|
+
ReqResult = z.output<Response>,
|
|
992
|
+
Result = unknown,
|
|
993
|
+
Context = unknown,
|
|
994
|
+
UseKey extends true = true,
|
|
995
|
+
>(config: {
|
|
996
|
+
method: Method
|
|
997
|
+
url: Url
|
|
998
|
+
useKey: UseKey
|
|
999
|
+
requestSchema: RequestSchema
|
|
1000
|
+
querySchema: QuerySchema
|
|
1001
|
+
responseSchema: Response
|
|
1002
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
1003
|
+
useContext?: () => Context
|
|
1004
|
+
onSuccess?: (
|
|
1005
|
+
queryClient: QueryClient,
|
|
1006
|
+
data: NoInfer<Result>,
|
|
1007
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
|
|
1008
|
+
context: Context,
|
|
1009
|
+
) => void | Promise<void>
|
|
1010
|
+
onError?: (
|
|
1011
|
+
queryClient: QueryClient,
|
|
1012
|
+
error: Error,
|
|
1013
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
|
|
1014
|
+
context: Context,
|
|
1015
|
+
) => void | Promise<void>
|
|
1016
|
+
}): ((
|
|
1017
|
+
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
856
1018
|
) => UseMutationResult<
|
|
857
1019
|
Result,
|
|
858
1020
|
Error,
|
|
859
|
-
|
|
1021
|
+
MutationArgs<Url, RequestSchema, QuerySchema>
|
|
860
1022
|
>) &
|
|
861
|
-
|
|
1023
|
+
MutationHelpers<Url, Result> &
|
|
1024
|
+
EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
|
|
1025
|
+
|
|
1026
|
+
multipartMutation<
|
|
1027
|
+
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
1028
|
+
Url extends string = string,
|
|
1029
|
+
RequestSchema extends ZodType = ZodType,
|
|
1030
|
+
QuerySchema extends ZodObject = ZodObject,
|
|
1031
|
+
Response extends ZodType = ZodType,
|
|
1032
|
+
ReqResult = z.output<Response>,
|
|
1033
|
+
Result = unknown,
|
|
1034
|
+
Context = unknown,
|
|
1035
|
+
>(config: {
|
|
1036
|
+
method: Method
|
|
1037
|
+
url: Url
|
|
1038
|
+
requestSchema: RequestSchema
|
|
1039
|
+
querySchema: QuerySchema
|
|
1040
|
+
responseSchema: Response
|
|
1041
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
1042
|
+
useContext?: () => Context
|
|
1043
|
+
onSuccess?: (
|
|
1044
|
+
queryClient: QueryClient,
|
|
1045
|
+
data: NoInfer<Result>,
|
|
1046
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
|
|
1047
|
+
context: Context,
|
|
1048
|
+
) => void | Promise<void>
|
|
1049
|
+
onError?: (
|
|
1050
|
+
queryClient: QueryClient,
|
|
1051
|
+
error: Error,
|
|
1052
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
|
|
1053
|
+
context: Context,
|
|
1054
|
+
) => void | Promise<void>
|
|
1055
|
+
}): (() => UseMutationResult<
|
|
1056
|
+
Result,
|
|
1057
|
+
Error,
|
|
1058
|
+
MutationArgs<Url, RequestSchema, QuerySchema>
|
|
1059
|
+
>) &
|
|
1060
|
+
MutationHelpers<Url, Result> &
|
|
1061
|
+
EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
|
|
1062
|
+
|
|
1063
|
+
multipartMutation<
|
|
1064
|
+
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
1065
|
+
Url extends string = string,
|
|
1066
|
+
RequestSchema extends ZodType = ZodType,
|
|
1067
|
+
Response extends ZodType = ZodType,
|
|
1068
|
+
ReqResult = z.output<Response>,
|
|
1069
|
+
Result = unknown,
|
|
1070
|
+
Context = unknown,
|
|
1071
|
+
>(config: {
|
|
1072
|
+
method: Method
|
|
1073
|
+
url: Url
|
|
1074
|
+
requestSchema: RequestSchema
|
|
1075
|
+
responseSchema: Response
|
|
1076
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
1077
|
+
useContext?: () => Context
|
|
1078
|
+
onSuccess?: (
|
|
1079
|
+
queryClient: QueryClient,
|
|
1080
|
+
data: NoInfer<Result>,
|
|
1081
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
1082
|
+
context: Context,
|
|
1083
|
+
) => void | Promise<void>
|
|
1084
|
+
onError?: (
|
|
1085
|
+
queryClient: QueryClient,
|
|
1086
|
+
error: Error,
|
|
1087
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
1088
|
+
context: Context,
|
|
1089
|
+
) => void | Promise<void>
|
|
1090
|
+
}): (() => UseMutationResult<
|
|
1091
|
+
Result,
|
|
1092
|
+
Error,
|
|
1093
|
+
MutationArgs<Url, RequestSchema, undefined>
|
|
1094
|
+
>) &
|
|
1095
|
+
MutationHelpers<Url, Result> &
|
|
1096
|
+
EndpointHelper<Method, Url, RequestSchema, Response>
|
|
1097
|
+
|
|
1098
|
+
multipartMutation<
|
|
1099
|
+
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
1100
|
+
Url extends string = string,
|
|
1101
|
+
RequestSchema extends ZodType = ZodType,
|
|
1102
|
+
Response extends ZodType = ZodType,
|
|
1103
|
+
ReqResult = z.output<Response>,
|
|
1104
|
+
Result = unknown,
|
|
1105
|
+
Context = unknown,
|
|
1106
|
+
UseKey extends true = true,
|
|
1107
|
+
>(config: {
|
|
1108
|
+
method: Method
|
|
1109
|
+
url: Url
|
|
1110
|
+
useKey: UseKey
|
|
1111
|
+
requestSchema: RequestSchema
|
|
1112
|
+
responseSchema: Response
|
|
1113
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
1114
|
+
useContext?: () => Context
|
|
1115
|
+
onSuccess?: (
|
|
1116
|
+
queryClient: QueryClient,
|
|
1117
|
+
data: NoInfer<Result>,
|
|
1118
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
1119
|
+
context: Context,
|
|
1120
|
+
) => void | Promise<void>
|
|
1121
|
+
onError?: (
|
|
1122
|
+
queryClient: QueryClient,
|
|
1123
|
+
error: Error,
|
|
1124
|
+
variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
|
|
1125
|
+
context: Context,
|
|
1126
|
+
) => void | Promise<void>
|
|
1127
|
+
}): ((
|
|
1128
|
+
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
1129
|
+
) => UseMutationResult<
|
|
1130
|
+
Result,
|
|
1131
|
+
Error,
|
|
1132
|
+
MutationArgs<Url, RequestSchema, undefined>
|
|
1133
|
+
>) &
|
|
1134
|
+
MutationHelpers<Url, Result> &
|
|
1135
|
+
EndpointHelper<Method, Url, RequestSchema, Response>
|
|
862
1136
|
}
|