@navios/react-query 0.7.1 → 1.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/CHANGELOG.md +161 -1
  2. package/README.md +152 -4
  3. package/dist/src/__tests__/errorSchema.spec.d.mts +2 -0
  4. package/dist/src/__tests__/errorSchema.spec.d.mts.map +1 -0
  5. package/dist/src/client/__type-tests__/from-endpoint.spec-d.d.mts +2 -0
  6. package/dist/src/client/__type-tests__/from-endpoint.spec-d.d.mts.map +1 -0
  7. package/dist/src/client/__type-tests__/infinite-query.spec-d.d.mts +2 -0
  8. package/dist/src/client/__type-tests__/infinite-query.spec-d.d.mts.map +1 -0
  9. package/dist/src/client/__type-tests__/multipart-mutation.spec-d.d.mts +2 -0
  10. package/dist/src/client/__type-tests__/multipart-mutation.spec-d.d.mts.map +1 -0
  11. package/dist/src/client/__type-tests__/mutation.spec-d.d.mts +2 -0
  12. package/dist/src/client/__type-tests__/mutation.spec-d.d.mts.map +1 -0
  13. package/dist/src/client/__type-tests__/query.spec-d.d.mts +2 -0
  14. package/dist/src/client/__type-tests__/query.spec-d.d.mts.map +1 -0
  15. package/dist/src/client/declare-client.d.mts +15 -8
  16. package/dist/src/client/declare-client.d.mts.map +1 -1
  17. package/dist/src/client/types/from-endpoint.d.mts +130 -0
  18. package/dist/src/client/types/from-endpoint.d.mts.map +1 -0
  19. package/dist/src/client/types/helpers.d.mts +74 -0
  20. package/dist/src/client/types/helpers.d.mts.map +1 -0
  21. package/dist/src/client/types/index.d.mts +21 -0
  22. package/dist/src/client/types/index.d.mts.map +1 -0
  23. package/dist/src/client/types/infinite-query.d.mts +61 -0
  24. package/dist/src/client/types/infinite-query.d.mts.map +1 -0
  25. package/dist/src/client/types/multipart-mutation.d.mts +98 -0
  26. package/dist/src/client/types/multipart-mutation.d.mts.map +1 -0
  27. package/dist/src/client/types/mutation.d.mts +75 -0
  28. package/dist/src/client/types/mutation.d.mts.map +1 -0
  29. package/dist/src/client/types/query.d.mts +65 -0
  30. package/dist/src/client/types/query.d.mts.map +1 -0
  31. package/dist/src/client/types.d.mts +1 -608
  32. package/dist/src/client/types.d.mts.map +1 -1
  33. package/dist/src/common/types.d.mts +30 -3
  34. package/dist/src/common/types.d.mts.map +1 -1
  35. package/dist/src/mutation/index.d.mts +1 -0
  36. package/dist/src/mutation/index.d.mts.map +1 -1
  37. package/dist/src/mutation/make-hook.d.mts +42 -16
  38. package/dist/src/mutation/make-hook.d.mts.map +1 -1
  39. package/dist/src/mutation/optimistic.d.mts +166 -0
  40. package/dist/src/mutation/optimistic.d.mts.map +1 -0
  41. package/dist/src/mutation/types.d.mts +51 -19
  42. package/dist/src/mutation/types.d.mts.map +1 -1
  43. package/dist/src/query/index.d.mts +1 -0
  44. package/dist/src/query/index.d.mts.map +1 -1
  45. package/dist/src/query/key-creator.d.mts.map +1 -1
  46. package/dist/src/query/make-infinite-options.d.mts +3 -2
  47. package/dist/src/query/make-infinite-options.d.mts.map +1 -1
  48. package/dist/src/query/make-options.d.mts +42 -12
  49. package/dist/src/query/make-options.d.mts.map +1 -1
  50. package/dist/src/query/prefetch.d.mts +245 -0
  51. package/dist/src/query/prefetch.d.mts.map +1 -0
  52. package/dist/src/query/types.d.mts +35 -17
  53. package/dist/src/query/types.d.mts.map +1 -1
  54. package/dist/tsconfig.tsbuildinfo +1 -1
  55. package/lib/index.cjs +445 -28
  56. package/lib/index.cjs.map +1 -1
  57. package/lib/index.d.cts +1022 -599
  58. package/lib/index.d.cts.map +1 -1
  59. package/lib/index.d.mts +1019 -596
  60. package/lib/index.d.mts.map +1 -1
  61. package/lib/index.mjs +441 -29
  62. package/lib/index.mjs.map +1 -1
  63. package/package.json +3 -3
  64. package/src/__tests__/declare-client.spec.mts +1 -2
  65. package/src/__tests__/errorSchema.spec.mts +391 -0
  66. package/src/__tests__/make-mutation.spec.mts +6 -5
  67. package/src/__tests__/makeDataTag.spec.mts +2 -1
  68. package/src/__tests__/makeQueryOptions.spec.mts +2 -1
  69. package/src/client/__type-tests__/from-endpoint.spec-d.mts +550 -0
  70. package/src/client/__type-tests__/infinite-query.spec-d.mts +648 -0
  71. package/src/client/__type-tests__/multipart-mutation.spec-d.mts +725 -0
  72. package/src/client/__type-tests__/mutation.spec-d.mts +757 -0
  73. package/src/client/__type-tests__/query.spec-d.mts +701 -0
  74. package/src/client/declare-client.mts +59 -34
  75. package/src/client/types/from-endpoint.mts +345 -0
  76. package/src/client/types/helpers.mts +140 -0
  77. package/src/client/types/index.mts +26 -0
  78. package/src/client/types/infinite-query.mts +133 -0
  79. package/src/client/types/multipart-mutation.mts +264 -0
  80. package/src/client/types/mutation.mts +176 -0
  81. package/src/client/types/query.mts +132 -0
  82. package/src/client/types.mts +1 -1935
  83. package/src/common/types.mts +48 -3
  84. package/src/mutation/index.mts +1 -0
  85. package/src/mutation/make-hook.mts +171 -63
  86. package/src/mutation/optimistic.mts +294 -0
  87. package/src/mutation/types.mts +102 -29
  88. package/src/query/index.mts +1 -0
  89. package/src/query/key-creator.mts +24 -13
  90. package/src/query/make-infinite-options.mts +53 -10
  91. package/src/query/make-options.mts +184 -43
  92. package/src/query/prefetch.mts +326 -0
  93. package/src/query/types.mts +76 -16
  94. package/src/client/__type-tests__/client-instance.spec-d.mts +0 -852
@@ -1,1935 +1 @@
1
- import type {
2
- BaseEndpointConfig,
3
- BaseStreamConfig,
4
- EndpointFunctionArgs,
5
- HttpMethod,
6
- UrlHasParams,
7
- UrlParams,
8
- Util_FlatObject,
9
- } from '@navios/builder'
10
- import type {
11
- DataTag,
12
- InfiniteData,
13
- MutationFunctionContext,
14
- UseMutationResult,
15
- UseSuspenseInfiniteQueryOptions,
16
- UseSuspenseQueryOptions,
17
- } from '@tanstack/react-query'
18
- import type { z, ZodObject, ZodType } from 'zod/v4'
19
-
20
- import type { ProcessResponseFunction, Split } from '../common/types.mjs'
21
- import type { MutationArgs, MutationHelpers } from '../mutation/types.mjs'
22
- import type { QueryArgs, QueryHelpers } from '../query/types.mjs'
23
-
24
- /**
25
- * Helper type that attaches the endpoint to query/mutation results.
26
- */
27
- export type EndpointHelper<
28
- Method extends HttpMethod = HttpMethod,
29
- Url extends string = string,
30
- RequestSchema = unknown,
31
- ResponseSchema extends z.ZodType = z.ZodType,
32
- QuerySchema = unknown,
33
- > = {
34
- endpoint: ((
35
- params: Util_FlatObject<
36
- EndpointFunctionArgs<Url, QuerySchema, RequestSchema>
37
- >,
38
- ) => Promise<z.output<ResponseSchema>>) & {
39
- config: BaseEndpointConfig<
40
- Method,
41
- Url,
42
- QuerySchema,
43
- ResponseSchema,
44
- RequestSchema
45
- >
46
- }
47
- }
48
-
49
- // Legacy export for backwards compatibility
50
- /** @deprecated Use EndpointHelper instead */
51
- export type ClientEndpointHelper<
52
- Method extends HttpMethod = HttpMethod,
53
- Url extends string = string,
54
- RequestSchema = unknown,
55
- ResponseSchema extends z.ZodType = z.ZodType,
56
- QuerySchema = unknown,
57
- > = EndpointHelper<Method, Url, RequestSchema, ResponseSchema, QuerySchema>
58
-
59
- /**
60
- * Helper type that attaches a stream endpoint to mutation results.
61
- */
62
- export type StreamHelper<
63
- Method extends HttpMethod = HttpMethod,
64
- Url extends string = string,
65
- RequestSchema = unknown,
66
- QuerySchema = unknown,
67
- > = {
68
- endpoint: ((
69
- params: Util_FlatObject<
70
- EndpointFunctionArgs<Url, QuerySchema, RequestSchema>
71
- >,
72
- ) => Promise<Blob>) & {
73
- config: BaseStreamConfig<Method, Url, QuerySchema, RequestSchema>
74
- }
75
- }
76
-
77
- /**
78
- * The main client instance interface.
79
- * Provides methods for creating queries, infinite queries, and mutations.
80
- */
81
- export interface ClientInstance {
82
- // ============================================================================
83
- // QUERY METHODS
84
- // ============================================================================
85
-
86
- // Standard query methods (GET, HEAD, OPTIONS) without query schema
87
- query<
88
- Method extends 'GET' | 'HEAD' | 'OPTIONS' = 'GET',
89
- Url extends string = string,
90
- Response extends ZodType = ZodType,
91
- Result = z.output<Response>,
92
- >(config: {
93
- method: Method
94
- url: Url
95
- responseSchema: Response
96
- processResponse?: (data: z.output<Response>) => Result
97
- }): ((
98
- params: Util_FlatObject<QueryArgs<Url, undefined>>,
99
- ) => UseSuspenseQueryOptions<
100
- Result,
101
- Error,
102
- Result,
103
- DataTag<Split<Url, '/'>, Result, Error>
104
- >) &
105
- QueryHelpers<Url, undefined, Result> &
106
- EndpointHelper<Method, Url, undefined, Response>
107
-
108
- // Standard query methods (GET, HEAD, OPTIONS) with query schema
109
- query<
110
- Method extends 'GET' | 'HEAD' | 'OPTIONS' = 'GET',
111
- Url extends string = string,
112
- QuerySchema extends ZodObject = ZodObject,
113
- Response extends ZodType = ZodType,
114
- Result = z.output<Response>,
115
- >(config: {
116
- method: Method
117
- url: Url
118
- querySchema: QuerySchema
119
- responseSchema: Response
120
- processResponse?: (data: z.output<Response>) => Result
121
- }): ((
122
- params: Util_FlatObject<QueryArgs<Url, QuerySchema>>,
123
- ) => UseSuspenseQueryOptions<
124
- Result,
125
- Error,
126
- Result,
127
- DataTag<Split<Url, '/'>, Result, Error>
128
- >) &
129
- QueryHelpers<Url, QuerySchema, Result> &
130
- EndpointHelper<Method, Url, undefined, Response, QuerySchema>
131
-
132
- // POST query methods (for search endpoints) without query schema
133
- query<
134
- Method extends 'POST' = 'POST',
135
- Url extends string = string,
136
- RequestSchema extends ZodType = ZodType,
137
- Response extends ZodType = ZodType,
138
- Result = z.output<Response>,
139
- >(config: {
140
- method: Method
141
- url: Url
142
- requestSchema: RequestSchema
143
- responseSchema: Response
144
- processResponse?: (data: z.output<Response>) => Result
145
- }): ((
146
- params: Util_FlatObject<QueryArgs<Url, undefined, RequestSchema>>,
147
- ) => UseSuspenseQueryOptions<
148
- Result,
149
- Error,
150
- Result,
151
- DataTag<Split<Url, '/'>, Result, Error>
152
- >) &
153
- QueryHelpers<Url, undefined, Result, false, RequestSchema> &
154
- EndpointHelper<Method, Url, RequestSchema, Response>
155
-
156
- // POST query methods (for search endpoints) with query schema
157
- query<
158
- Method extends 'POST' = 'POST',
159
- Url extends string = string,
160
- QuerySchema extends ZodObject = ZodObject,
161
- RequestSchema extends ZodType = ZodType,
162
- Response extends ZodType = ZodType,
163
- Result = z.output<Response>,
164
- >(config: {
165
- method: Method
166
- url: Url
167
- querySchema: QuerySchema
168
- requestSchema: RequestSchema
169
- responseSchema: Response
170
- processResponse?: (data: z.output<Response>) => Result
171
- }): ((
172
- params: Util_FlatObject<QueryArgs<Url, QuerySchema, RequestSchema>>,
173
- ) => UseSuspenseQueryOptions<
174
- Result,
175
- Error,
176
- Result,
177
- DataTag<Split<Url, '/'>, Result, Error>
178
- >) &
179
- QueryHelpers<Url, QuerySchema, Result, false, RequestSchema> &
180
- EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
181
-
182
- // ============================================================================
183
- // INFINITE QUERY METHODS
184
- // ============================================================================
185
-
186
- // Standard infiniteQuery methods (GET, HEAD, OPTIONS)
187
- infiniteQuery<
188
- Method extends 'GET' | 'HEAD' | 'OPTIONS' = 'GET',
189
- Url extends string = string,
190
- QuerySchema extends ZodObject = ZodObject,
191
- Response extends ZodType = ZodType,
192
- PageResult = z.output<Response>,
193
- Result = InfiniteData<PageResult>,
194
- >(config: {
195
- method: Method
196
- url: Url
197
- querySchema: QuerySchema
198
- responseSchema: Response
199
- processResponse?: (data: z.output<Response>) => PageResult
200
- getNextPageParam: (
201
- lastPage: PageResult,
202
- allPages: PageResult[],
203
- lastPageParam: z.infer<QuerySchema> | undefined,
204
- allPageParams: z.infer<QuerySchema>[] | undefined,
205
- ) => z.input<QuerySchema> | undefined
206
- getPreviousPageParam?: (
207
- firstPage: PageResult,
208
- allPages: PageResult[],
209
- lastPageParam: z.infer<QuerySchema> | undefined,
210
- allPageParams: z.infer<QuerySchema>[] | undefined,
211
- ) => z.input<QuerySchema>
212
- }): ((
213
- params: Util_FlatObject<QueryArgs<Url, QuerySchema>>,
214
- ) => UseSuspenseInfiniteQueryOptions<
215
- PageResult,
216
- Error,
217
- Result,
218
- DataTag<Split<Url, '/'>, PageResult, Error>,
219
- z.output<QuerySchema>
220
- >) &
221
- QueryHelpers<Url, QuerySchema, PageResult, true> &
222
- EndpointHelper<Method, Url, undefined, Response, QuerySchema>
223
-
224
- // POST infiniteQuery methods (for search endpoints)
225
- infiniteQuery<
226
- Method extends 'POST' = 'POST',
227
- Url extends string = string,
228
- QuerySchema extends ZodObject = ZodObject,
229
- RequestSchema extends ZodType = ZodType,
230
- Response extends ZodType = ZodType,
231
- PageResult = z.output<Response>,
232
- Result = InfiniteData<PageResult>,
233
- >(config: {
234
- method: Method
235
- url: Url
236
- querySchema: QuerySchema
237
- requestSchema: RequestSchema
238
- responseSchema: Response
239
- processResponse?: (data: z.output<Response>) => PageResult
240
- getNextPageParam: (
241
- lastPage: PageResult,
242
- allPages: PageResult[],
243
- lastPageParam: z.infer<QuerySchema> | undefined,
244
- allPageParams: z.infer<QuerySchema>[] | undefined,
245
- ) => z.input<QuerySchema> | undefined
246
- getPreviousPageParam?: (
247
- firstPage: PageResult,
248
- allPages: PageResult[],
249
- lastPageParam: z.infer<QuerySchema> | undefined,
250
- allPageParams: z.infer<QuerySchema>[] | undefined,
251
- ) => z.input<QuerySchema>
252
- }): ((
253
- params: Util_FlatObject<QueryArgs<Url, QuerySchema, RequestSchema>>,
254
- ) => UseSuspenseInfiniteQueryOptions<
255
- PageResult,
256
- Error,
257
- Result,
258
- DataTag<Split<Url, '/'>, PageResult, Error>,
259
- z.output<QuerySchema>
260
- >) &
261
- QueryHelpers<Url, QuerySchema, PageResult, true, RequestSchema> &
262
- EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
263
-
264
- // ============================================================================
265
- // MUTATION METHODS (POST, PUT, PATCH)
266
- // ============================================================================
267
-
268
- // With useKey, requestSchema, and querySchema
269
- mutation<
270
- Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
271
- Url extends string = string,
272
- RequestSchema extends ZodType = ZodType,
273
- QuerySchema extends ZodObject = ZodObject,
274
- Response extends ZodType = ZodType,
275
- ReqResult = z.output<Response>,
276
- Result = unknown,
277
- OnMutateResult = unknown,
278
- Context = unknown,
279
- UseKey extends true = true,
280
- >(config: {
281
- method: Method
282
- url: Url
283
- useKey: UseKey
284
- requestSchema: RequestSchema
285
- querySchema: QuerySchema
286
- responseSchema: Response
287
- processResponse: ProcessResponseFunction<Result, ReqResult>
288
- useContext?: () => Context
289
- onMutate?: (
290
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
291
- context: Context & MutationFunctionContext,
292
- ) => OnMutateResult | Promise<OnMutateResult>
293
- onSuccess?: (
294
- data: NoInfer<Result>,
295
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
296
- context: Context &
297
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
298
- ) => void | Promise<void>
299
- onError?: (
300
- error: Error,
301
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
302
- context: Context &
303
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
304
- ) => void | Promise<void>
305
- onSettled?: (
306
- data: NoInfer<Result> | undefined,
307
- error: Error | null,
308
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
309
- context: Context &
310
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
311
- ) => void | Promise<void>
312
- }): ((
313
- params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
314
- ) => UseMutationResult<
315
- Result,
316
- Error,
317
- MutationArgs<Url, RequestSchema, QuerySchema>,
318
- OnMutateResult
319
- >) &
320
- MutationHelpers<Url, Result> &
321
- EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
322
-
323
- // Without useKey, with requestSchema and querySchema
324
- mutation<
325
- Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
326
- Url extends string = string,
327
- RequestSchema extends ZodType = ZodType,
328
- QuerySchema extends ZodObject = ZodObject,
329
- Response extends ZodType = ZodType,
330
- ReqResult = z.output<Response>,
331
- Result = unknown,
332
- OnMutateResult = unknown,
333
- Context = unknown,
334
- >(config: {
335
- method: Method
336
- url: Url
337
- requestSchema: RequestSchema
338
- querySchema: QuerySchema
339
- responseSchema: Response
340
- processResponse: ProcessResponseFunction<Result, ReqResult>
341
- useContext?: () => Context
342
- onMutate?: (
343
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
344
- context: Context & MutationFunctionContext,
345
- ) => OnMutateResult | Promise<OnMutateResult>
346
- onSuccess?: (
347
- data: NoInfer<Result>,
348
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
349
- context: Context &
350
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
351
- ) => void | Promise<void>
352
- onError?: (
353
- error: Error,
354
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
355
- context: Context &
356
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
357
- ) => void | Promise<void>
358
- onSettled?: (
359
- data: NoInfer<Result> | undefined,
360
- error: Error | null,
361
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
362
- context: Context &
363
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
364
- ) => void | Promise<void>
365
- }): (() => UseMutationResult<
366
- Result,
367
- Error,
368
- MutationArgs<Url, RequestSchema, QuerySchema>,
369
- OnMutateResult
370
- >) &
371
- MutationHelpers<Url, Result> &
372
- EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
373
-
374
- // Without useKey, with requestSchema only
375
- mutation<
376
- Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
377
- Url extends string = string,
378
- RequestSchema extends ZodType = ZodType,
379
- Response extends ZodType = ZodType,
380
- ReqResult = z.output<Response>,
381
- Result = unknown,
382
- OnMutateResult = unknown,
383
- Context = unknown,
384
- >(config: {
385
- method: Method
386
- url: Url
387
- requestSchema: RequestSchema
388
- responseSchema: Response
389
- processResponse: ProcessResponseFunction<Result, ReqResult>
390
- useContext?: () => Context
391
- onMutate?: (
392
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
393
- context: Context & MutationFunctionContext,
394
- ) => OnMutateResult | Promise<OnMutateResult>
395
- onSuccess?: (
396
- data: NoInfer<Result>,
397
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
398
- context: Context &
399
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
400
- ) => void | Promise<void>
401
- onError?: (
402
- error: Error,
403
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
404
- context: Context &
405
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
406
- ) => void | Promise<void>
407
- onSettled?: (
408
- data: NoInfer<Result> | undefined,
409
- error: Error | null,
410
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
411
- context: Context &
412
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
413
- ) => void | Promise<void>
414
- }): (() => UseMutationResult<
415
- Result,
416
- Error,
417
- MutationArgs<Url, RequestSchema, undefined>,
418
- OnMutateResult
419
- >) &
420
- MutationHelpers<Url, Result> &
421
- EndpointHelper<Method, Url, RequestSchema, Response>
422
-
423
- // With useKey and requestSchema only
424
- mutation<
425
- Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
426
- Url extends string = string,
427
- RequestSchema extends ZodType = ZodType,
428
- Response extends ZodType = ZodType,
429
- ReqResult = z.output<Response>,
430
- Result = unknown,
431
- OnMutateResult = unknown,
432
- Context = unknown,
433
- UseKey extends true = true,
434
- >(config: {
435
- method: Method
436
- url: Url
437
- useKey: UseKey
438
- requestSchema: RequestSchema
439
- responseSchema: Response
440
- processResponse: ProcessResponseFunction<Result, ReqResult>
441
- useContext?: () => Context
442
- onMutate?: (
443
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
444
- context: Context & MutationFunctionContext,
445
- ) => OnMutateResult | Promise<OnMutateResult>
446
- onSuccess?: (
447
- data: NoInfer<Result>,
448
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
449
- context: Context &
450
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
451
- ) => void | Promise<void>
452
- onError?: (
453
- error: Error,
454
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
455
- context: Context &
456
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
457
- ) => void | Promise<void>
458
- onSettled?: (
459
- data: NoInfer<Result> | undefined,
460
- error: Error | null,
461
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
462
- context: Context &
463
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
464
- ) => void | Promise<void>
465
- }): ((
466
- params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
467
- ) => UseMutationResult<
468
- Result,
469
- Error,
470
- MutationArgs<Url, RequestSchema, undefined>,
471
- OnMutateResult
472
- >) &
473
- MutationHelpers<Url, Result> &
474
- EndpointHelper<Method, Url, RequestSchema, Response>
475
-
476
- // ============================================================================
477
- // DELETE MUTATION METHODS
478
- // ============================================================================
479
-
480
- // DELETE with useKey and querySchema
481
- mutation<
482
- Method extends 'DELETE' = 'DELETE',
483
- Url extends string = string,
484
- QuerySchema extends ZodObject = ZodObject,
485
- Response extends ZodType = ZodType,
486
- ReqResult = z.output<Response>,
487
- Result = unknown,
488
- OnMutateResult = unknown,
489
- Context = unknown,
490
- UseKey extends true = true,
491
- >(config: {
492
- method: Method
493
- url: Url
494
- useKey: UseKey
495
- querySchema: QuerySchema
496
- responseSchema: Response
497
- processResponse: ProcessResponseFunction<Result, ReqResult>
498
- useContext?: () => Context
499
- onMutate?: (
500
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
501
- context: Context & MutationFunctionContext,
502
- ) => OnMutateResult | Promise<OnMutateResult>
503
- onSuccess?: (
504
- data: NoInfer<Result>,
505
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
506
- context: Context &
507
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
508
- ) => void | Promise<void>
509
- onError?: (
510
- error: Error,
511
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
512
- context: Context &
513
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
514
- ) => void | Promise<void>
515
- onSettled?: (
516
- data: NoInfer<Result> | undefined,
517
- error: Error | null,
518
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
519
- context: Context &
520
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
521
- ) => void | Promise<void>
522
- }): ((
523
- params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
524
- ) => UseMutationResult<
525
- Result,
526
- Error,
527
- MutationArgs<Url, undefined, QuerySchema>,
528
- OnMutateResult
529
- >) &
530
- MutationHelpers<Url, Result> &
531
- EndpointHelper<Method, Url, undefined, Response, QuerySchema>
532
-
533
- // DELETE without useKey, with querySchema
534
- mutation<
535
- Method extends 'DELETE' = 'DELETE',
536
- Url extends string = string,
537
- QuerySchema extends ZodObject = ZodObject,
538
- Response extends ZodType = ZodType,
539
- ReqResult = z.output<Response>,
540
- Result = unknown,
541
- OnMutateResult = unknown,
542
- Context = unknown,
543
- >(config: {
544
- method: Method
545
- url: Url
546
- querySchema: QuerySchema
547
- responseSchema: Response
548
- processResponse: ProcessResponseFunction<Result, ReqResult>
549
- useContext?: () => Context
550
- onMutate?: (
551
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
552
- context: Context & MutationFunctionContext,
553
- ) => OnMutateResult | Promise<OnMutateResult>
554
- onSuccess?: (
555
- data: NoInfer<Result>,
556
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
557
- context: Context &
558
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
559
- ) => void | Promise<void>
560
- onError?: (
561
- error: Error,
562
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
563
- context: Context &
564
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
565
- ) => void | Promise<void>
566
- onSettled?: (
567
- data: NoInfer<Result> | undefined,
568
- error: Error | null,
569
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
570
- context: Context &
571
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
572
- ) => void | Promise<void>
573
- }): (() => UseMutationResult<
574
- Result,
575
- Error,
576
- MutationArgs<Url, undefined, QuerySchema>,
577
- OnMutateResult
578
- >) &
579
- MutationHelpers<Url, Result> &
580
- EndpointHelper<Method, Url, undefined, Response, QuerySchema>
581
-
582
- // DELETE with useKey only (no schemas)
583
- mutation<
584
- Method extends 'DELETE' = 'DELETE',
585
- Url extends string = string,
586
- Response extends ZodType = ZodType,
587
- ReqResult = z.output<Response>,
588
- Result = unknown,
589
- OnMutateResult = unknown,
590
- Context = unknown,
591
- UseKey extends true = true,
592
- >(config: {
593
- method: Method
594
- url: Url
595
- useKey: UseKey
596
- responseSchema: Response
597
- processResponse: ProcessResponseFunction<Result, ReqResult>
598
- useContext?: () => Context
599
- onMutate?: (
600
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
601
- context: Context & MutationFunctionContext,
602
- ) => OnMutateResult | Promise<OnMutateResult>
603
- onSuccess?: (
604
- data: NoInfer<Result>,
605
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
606
- context: Context &
607
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
608
- ) => void | Promise<void>
609
- onError?: (
610
- error: Error,
611
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
612
- context: Context &
613
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
614
- ) => void | Promise<void>
615
- onSettled?: (
616
- data: NoInfer<Result> | undefined,
617
- error: Error | null,
618
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
619
- context: Context &
620
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
621
- ) => void | Promise<void>
622
- }): ((
623
- params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
624
- ) => UseMutationResult<
625
- Result,
626
- Error,
627
- MutationArgs<Url, undefined, undefined>,
628
- OnMutateResult
629
- >) &
630
- MutationHelpers<Url, Result> &
631
- EndpointHelper<Method, Url, undefined, Response>
632
-
633
- // DELETE without useKey (no schemas)
634
- mutation<
635
- Method extends 'DELETE' = 'DELETE',
636
- Url extends string = string,
637
- Response extends ZodType = ZodType,
638
- ReqResult = z.output<Response>,
639
- Result = unknown,
640
- OnMutateResult = unknown,
641
- Context = unknown,
642
- >(config: {
643
- method: Method
644
- url: Url
645
- responseSchema: Response
646
- processResponse: ProcessResponseFunction<Result, ReqResult>
647
- useContext?: () => Context
648
- onMutate?: (
649
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
650
- context: Context & MutationFunctionContext,
651
- ) => OnMutateResult | Promise<OnMutateResult>
652
- onSuccess?: (
653
- data: NoInfer<Result>,
654
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
655
- context: Context &
656
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
657
- ) => void | Promise<void>
658
- onError?: (
659
- error: Error,
660
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
661
- context: Context &
662
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
663
- ) => void | Promise<void>
664
- onSettled?: (
665
- data: NoInfer<Result> | undefined,
666
- error: Error | null,
667
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
668
- context: Context &
669
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
670
- ) => void | Promise<void>
671
- }): (() => UseMutationResult<
672
- Result,
673
- Error,
674
- MutationArgs<Url, undefined, undefined>,
675
- OnMutateResult
676
- >) &
677
- MutationHelpers<Url, Result> &
678
- EndpointHelper<Method, Url, undefined, Response>
679
-
680
- // ============================================================================
681
- // FROM ENDPOINT METHODS
682
- // ============================================================================
683
-
684
- queryFromEndpoint<
685
- Method extends 'GET' | 'HEAD' | 'OPTIONS' = 'GET',
686
- Url extends string = string,
687
- QuerySchema extends ZodObject = ZodObject,
688
- Response extends ZodType = ZodType,
689
- Result = z.output<Response>,
690
- >(
691
- endpoint: {
692
- config: BaseEndpointConfig<Method, Url, QuerySchema, Response>
693
- },
694
- options?: {
695
- processResponse?: (data: z.output<Response>) => Result
696
- },
697
- ): (
698
- params: Util_FlatObject<QueryArgs<Url, QuerySchema>>,
699
- ) => UseSuspenseQueryOptions<
700
- Result,
701
- Error,
702
- Result,
703
- DataTag<Split<Url, '/'>, Result, Error>
704
- > &
705
- QueryHelpers<Url, QuerySchema, Result>
706
-
707
- queryFromEndpoint<
708
- Method extends 'GET' | 'HEAD' | 'OPTIONS' = 'GET',
709
- Url extends string = string,
710
- Response extends ZodType = ZodType,
711
- Result = z.output<Response>,
712
- >(
713
- endpoint: {
714
- config: BaseEndpointConfig<Method, Url, undefined, Response>
715
- },
716
- options?: {
717
- processResponse?: (data: z.output<Response>) => Result
718
- },
719
- ): ((
720
- params: Util_FlatObject<QueryArgs<Url, undefined>>,
721
- ) => UseSuspenseQueryOptions<
722
- Result,
723
- Error,
724
- Result,
725
- DataTag<Split<Url, '/'>, Result, Error>
726
- >) &
727
- QueryHelpers<Url, undefined, Result>
728
-
729
- infiniteQueryFromEndpoint<
730
- Method extends 'GET' | 'HEAD' | 'OPTIONS' = 'GET',
731
- Url extends string = string,
732
- QuerySchema extends ZodObject = ZodObject,
733
- Response extends ZodType = ZodType,
734
- PageResult = z.output<Response>,
735
- Result = InfiniteData<PageResult>,
736
- >(
737
- endpoint: {
738
- config: BaseEndpointConfig<Method, Url, QuerySchema, Response>
739
- },
740
- options: {
741
- processResponse?: (data: z.output<Response>) => PageResult
742
- getNextPageParam: (
743
- lastPage: PageResult,
744
- allPages: PageResult[],
745
- lastPageParam: z.infer<QuerySchema> | undefined,
746
- allPageParams: z.infer<QuerySchema>[] | undefined,
747
- ) => z.input<QuerySchema> | undefined
748
- getPreviousPageParam?: (
749
- firstPage: PageResult,
750
- allPages: PageResult[],
751
- lastPageParam: z.infer<QuerySchema> | undefined,
752
- allPageParams: z.infer<QuerySchema>[] | undefined,
753
- ) => z.input<QuerySchema>
754
- },
755
- ): ((
756
- params: Util_FlatObject<QueryArgs<Url, QuerySchema>>,
757
- ) => UseSuspenseInfiniteQueryOptions<
758
- PageResult,
759
- Error,
760
- Result,
761
- DataTag<Split<Url, '/'>, PageResult, Error>,
762
- z.output<QuerySchema>
763
- >) &
764
- QueryHelpers<Url, QuerySchema, PageResult, true>
765
-
766
- // ============================================================================
767
- // MUTATION FROM ENDPOINT METHODS (POST, PUT, PATCH)
768
- // ============================================================================
769
-
770
- mutationFromEndpoint<
771
- Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
772
- Url extends string = string,
773
- RequestSchema extends ZodType = ZodType,
774
- QuerySchema extends ZodObject = ZodObject,
775
- Response extends ZodType = ZodType,
776
- ReqResult = z.output<Response>,
777
- Result = unknown,
778
- OnMutateResult = unknown,
779
- Context = unknown,
780
- UseKey extends true = true,
781
- >(
782
- endpoint: {
783
- config: BaseEndpointConfig<
784
- Method,
785
- Url,
786
- QuerySchema,
787
- Response,
788
- RequestSchema
789
- >
790
- },
791
- mutationOptions: {
792
- processResponse: ProcessResponseFunction<Result, ReqResult>
793
- useKey: UseKey
794
- useContext?: () => Context
795
- onMutate?: (
796
- variables: Util_FlatObject<
797
- MutationArgs<Url, RequestSchema, QuerySchema>
798
- >,
799
- context: Context & MutationFunctionContext,
800
- ) => OnMutateResult | Promise<OnMutateResult>
801
- onSuccess?: (
802
- data: NoInfer<Result>,
803
- variables: Util_FlatObject<
804
- MutationArgs<Url, RequestSchema, QuerySchema>
805
- >,
806
- context: Context &
807
- MutationFunctionContext & {
808
- onMutateResult: OnMutateResult | undefined
809
- },
810
- ) => void | Promise<void>
811
- onError?: (
812
- error: Error,
813
- variables: Util_FlatObject<
814
- MutationArgs<Url, RequestSchema, QuerySchema>
815
- >,
816
- context: Context &
817
- MutationFunctionContext & {
818
- onMutateResult: OnMutateResult | undefined
819
- },
820
- ) => void | Promise<void>
821
- onSettled?: (
822
- data: NoInfer<Result> | undefined,
823
- error: Error | null,
824
- variables: Util_FlatObject<
825
- MutationArgs<Url, RequestSchema, QuerySchema>
826
- >,
827
- context: Context &
828
- MutationFunctionContext & {
829
- onMutateResult: OnMutateResult | undefined
830
- },
831
- ) => void | Promise<void>
832
- },
833
- ): ((
834
- params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
835
- ) => UseMutationResult<
836
- Result,
837
- Error,
838
- MutationArgs<Url, RequestSchema, QuerySchema>,
839
- OnMutateResult
840
- >) &
841
- MutationHelpers<Url, Result> &
842
- EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
843
-
844
- mutationFromEndpoint<
845
- Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
846
- Url extends string = string,
847
- RequestSchema extends ZodType = ZodType,
848
- Response extends ZodType = ZodType,
849
- ReqResult = z.output<Response>,
850
- Result = unknown,
851
- OnMutateResult = unknown,
852
- Context = unknown,
853
- UseKey extends true = true,
854
- >(
855
- endpoint: {
856
- config: BaseEndpointConfig<
857
- Method,
858
- Url,
859
- undefined,
860
- Response,
861
- RequestSchema
862
- >
863
- },
864
- mutationOptions: {
865
- processResponse: ProcessResponseFunction<Result, ReqResult>
866
- useKey: UseKey
867
- useContext?: () => Context
868
- onMutate?: (
869
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
870
- context: Context & MutationFunctionContext,
871
- ) => OnMutateResult | Promise<OnMutateResult>
872
- onSuccess?: (
873
- data: NoInfer<Result>,
874
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
875
- context: Context &
876
- MutationFunctionContext & {
877
- onMutateResult: OnMutateResult | undefined
878
- },
879
- ) => void | Promise<void>
880
- onError?: (
881
- error: Error,
882
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
883
- context: Context &
884
- MutationFunctionContext & {
885
- onMutateResult: OnMutateResult | undefined
886
- },
887
- ) => void | Promise<void>
888
- onSettled?: (
889
- data: NoInfer<Result> | undefined,
890
- error: Error | null,
891
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
892
- context: Context &
893
- MutationFunctionContext & {
894
- onMutateResult: OnMutateResult | undefined
895
- },
896
- ) => void | Promise<void>
897
- },
898
- ): ((
899
- params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
900
- ) => UseMutationResult<
901
- Result,
902
- Error,
903
- MutationArgs<Url, RequestSchema, undefined>,
904
- OnMutateResult
905
- >) &
906
- MutationHelpers<Url, Result> &
907
- EndpointHelper<Method, Url, RequestSchema, Response, undefined>
908
-
909
- mutationFromEndpoint<
910
- Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
911
- Url extends string = string,
912
- RequestSchema extends ZodType = ZodType,
913
- QuerySchema extends ZodObject = ZodObject,
914
- Response extends ZodType = ZodType,
915
- ReqResult = z.output<Response>,
916
- Result = unknown,
917
- OnMutateResult = unknown,
918
- Context = unknown,
919
- >(
920
- endpoint: {
921
- config: BaseEndpointConfig<
922
- Method,
923
- Url,
924
- QuerySchema,
925
- Response,
926
- RequestSchema
927
- >
928
- },
929
- mutationOptions: {
930
- processResponse: ProcessResponseFunction<Result, ReqResult>
931
- useContext?: () => Context
932
- onMutate?: (
933
- variables: Util_FlatObject<
934
- MutationArgs<Url, RequestSchema, QuerySchema>
935
- >,
936
- context: Context & MutationFunctionContext,
937
- ) => OnMutateResult | Promise<OnMutateResult>
938
- onSuccess?: (
939
- data: NoInfer<Result>,
940
- variables: Util_FlatObject<
941
- MutationArgs<Url, RequestSchema, QuerySchema>
942
- >,
943
- context: Context &
944
- MutationFunctionContext & {
945
- onMutateResult: OnMutateResult | undefined
946
- },
947
- ) => void | Promise<void>
948
- onError?: (
949
- error: Error,
950
- variables: Util_FlatObject<
951
- MutationArgs<Url, RequestSchema, QuerySchema>
952
- >,
953
- context: Context &
954
- MutationFunctionContext & {
955
- onMutateResult: OnMutateResult | undefined
956
- },
957
- ) => void | Promise<void>
958
- onSettled?: (
959
- data: NoInfer<Result> | undefined,
960
- error: Error | null,
961
- variables: Util_FlatObject<
962
- MutationArgs<Url, RequestSchema, QuerySchema>
963
- >,
964
- context: Context &
965
- MutationFunctionContext & {
966
- onMutateResult: OnMutateResult | undefined
967
- },
968
- ) => void | Promise<void>
969
- },
970
- ): (() => UseMutationResult<
971
- Result,
972
- Error,
973
- MutationArgs<Url, RequestSchema, QuerySchema>,
974
- OnMutateResult
975
- >) &
976
- EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
977
-
978
- mutationFromEndpoint<
979
- Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
980
- Url extends string = string,
981
- RequestSchema extends ZodType = ZodType,
982
- Response extends ZodType = ZodType,
983
- ReqResult = z.output<Response>,
984
- Result = unknown,
985
- OnMutateResult = unknown,
986
- Context = unknown,
987
- >(
988
- endpoint: {
989
- config: BaseEndpointConfig<
990
- Method,
991
- Url,
992
- undefined,
993
- Response,
994
- RequestSchema
995
- >
996
- },
997
- mutationOptions: {
998
- processResponse: ProcessResponseFunction<Result, ReqResult>
999
- useContext?: () => Context
1000
- onMutate?: (
1001
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
1002
- context: Context & MutationFunctionContext,
1003
- ) => OnMutateResult | Promise<OnMutateResult>
1004
- onSuccess?: (
1005
- data: NoInfer<Result>,
1006
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
1007
- context: Context &
1008
- MutationFunctionContext & {
1009
- onMutateResult: OnMutateResult | undefined
1010
- },
1011
- ) => void | Promise<void>
1012
- onError?: (
1013
- error: Error,
1014
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
1015
- context: Context &
1016
- MutationFunctionContext & {
1017
- onMutateResult: OnMutateResult | undefined
1018
- },
1019
- ) => void | Promise<void>
1020
- onSettled?: (
1021
- data: NoInfer<Result> | undefined,
1022
- error: Error | null,
1023
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
1024
- context: Context &
1025
- MutationFunctionContext & {
1026
- onMutateResult: OnMutateResult | undefined
1027
- },
1028
- ) => void | Promise<void>
1029
- },
1030
- ): (() => UseMutationResult<
1031
- Result,
1032
- Error,
1033
- MutationArgs<Url, RequestSchema, undefined>,
1034
- OnMutateResult
1035
- >) &
1036
- EndpointHelper<Method, Url, RequestSchema, Response, undefined>
1037
-
1038
- // ============================================================================
1039
- // DELETE MUTATION FROM ENDPOINT METHODS
1040
- // ============================================================================
1041
-
1042
- mutationFromEndpoint<
1043
- Method extends 'DELETE' = 'DELETE',
1044
- Url extends string = string,
1045
- QuerySchema extends ZodObject = ZodObject,
1046
- Response extends ZodType = ZodType,
1047
- ReqResult = z.output<Response>,
1048
- Result = unknown,
1049
- OnMutateResult = unknown,
1050
- Context = unknown,
1051
- UseKey extends true = true,
1052
- >(
1053
- endpoint: {
1054
- config: BaseEndpointConfig<Method, Url, QuerySchema, Response>
1055
- },
1056
- mutationOptions: {
1057
- processResponse: ProcessResponseFunction<Result, ReqResult>
1058
- useKey: UseKey
1059
- useContext?: () => Context
1060
- onMutate?: (
1061
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
1062
- context: Context & MutationFunctionContext,
1063
- ) => OnMutateResult | Promise<OnMutateResult>
1064
- onSuccess?: (
1065
- data: NoInfer<Result>,
1066
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
1067
- context: Context &
1068
- MutationFunctionContext & {
1069
- onMutateResult: OnMutateResult | undefined
1070
- },
1071
- ) => void | Promise<void>
1072
- onError?: (
1073
- error: Error,
1074
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
1075
- context: Context &
1076
- MutationFunctionContext & {
1077
- onMutateResult: OnMutateResult | undefined
1078
- },
1079
- ) => void | Promise<void>
1080
- onSettled?: (
1081
- data: NoInfer<Result> | undefined,
1082
- error: Error | null,
1083
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
1084
- context: Context &
1085
- MutationFunctionContext & {
1086
- onMutateResult: OnMutateResult | undefined
1087
- },
1088
- ) => void | Promise<void>
1089
- },
1090
- ): (() => UseMutationResult<
1091
- Result,
1092
- Error,
1093
- MutationArgs<Url, undefined, QuerySchema>,
1094
- OnMutateResult
1095
- >) &
1096
- MutationHelpers<Url, Result> &
1097
- EndpointHelper<Method, Url, undefined, Response, QuerySchema>
1098
-
1099
- mutationFromEndpoint<
1100
- Method extends 'DELETE' = 'DELETE',
1101
- Url extends string = string,
1102
- Response extends ZodType = ZodType,
1103
- ReqResult = z.output<Response>,
1104
- Result = unknown,
1105
- OnMutateResult = unknown,
1106
- Context = unknown,
1107
- UseKey extends true = true,
1108
- >(
1109
- endpoint: {
1110
- config: BaseEndpointConfig<Method, Url, undefined, Response>
1111
- },
1112
- mutationOptions: {
1113
- processResponse: ProcessResponseFunction<Result, ReqResult>
1114
- useKey: UseKey
1115
- useContext?: () => Context
1116
- onMutate?: (
1117
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
1118
- context: Context & MutationFunctionContext,
1119
- ) => OnMutateResult | Promise<OnMutateResult>
1120
- onSuccess?: (
1121
- data: NoInfer<Result>,
1122
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
1123
- context: Context &
1124
- MutationFunctionContext & {
1125
- onMutateResult: OnMutateResult | undefined
1126
- },
1127
- ) => void | Promise<void>
1128
- onError?: (
1129
- error: Error,
1130
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
1131
- context: Context &
1132
- MutationFunctionContext & {
1133
- onMutateResult: OnMutateResult | undefined
1134
- },
1135
- ) => void | Promise<void>
1136
- onSettled?: (
1137
- data: NoInfer<Result> | undefined,
1138
- error: Error | null,
1139
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
1140
- context: Context &
1141
- MutationFunctionContext & {
1142
- onMutateResult: OnMutateResult | undefined
1143
- },
1144
- ) => void | Promise<void>
1145
- },
1146
- ): ((
1147
- params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
1148
- ) => UseMutationResult<
1149
- Result,
1150
- Error,
1151
- MutationArgs<Url, undefined, undefined>,
1152
- OnMutateResult
1153
- >) &
1154
- MutationHelpers<Url, Result> &
1155
- EndpointHelper<Method, Url, undefined, Response, undefined>
1156
-
1157
- mutationFromEndpoint<
1158
- Method extends 'DELETE' = 'DELETE',
1159
- Url extends string = string,
1160
- QuerySchema extends ZodObject = ZodObject,
1161
- Response extends ZodType = ZodType,
1162
- ReqResult = z.output<Response>,
1163
- Result = unknown,
1164
- OnMutateResult = unknown,
1165
- Context = unknown,
1166
- >(
1167
- endpoint: {
1168
- config: BaseEndpointConfig<Method, Url, QuerySchema, Response>
1169
- },
1170
- mutationOptions: {
1171
- processResponse: ProcessResponseFunction<Result, ReqResult>
1172
- useContext?: () => Context
1173
- onMutate?: (
1174
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
1175
- context: Context & MutationFunctionContext,
1176
- ) => OnMutateResult | Promise<OnMutateResult>
1177
- onSuccess?: (
1178
- data: NoInfer<Result>,
1179
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
1180
- context: Context &
1181
- MutationFunctionContext & {
1182
- onMutateResult: OnMutateResult | undefined
1183
- },
1184
- ) => void | Promise<void>
1185
- onError?: (
1186
- error: Error,
1187
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
1188
- context: Context &
1189
- MutationFunctionContext & {
1190
- onMutateResult: OnMutateResult | undefined
1191
- },
1192
- ) => void | Promise<void>
1193
- onSettled?: (
1194
- data: NoInfer<Result> | undefined,
1195
- error: Error | null,
1196
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
1197
- context: Context &
1198
- MutationFunctionContext & {
1199
- onMutateResult: OnMutateResult | undefined
1200
- },
1201
- ) => void | Promise<void>
1202
- },
1203
- ): (() => UseMutationResult<
1204
- Result,
1205
- Error,
1206
- MutationArgs<Url, undefined, QuerySchema>,
1207
- OnMutateResult
1208
- >) &
1209
- EndpointHelper<Method, Url, undefined, Response, QuerySchema>
1210
-
1211
- mutationFromEndpoint<
1212
- Method extends 'DELETE' = 'DELETE',
1213
- Url extends string = string,
1214
- Response extends ZodType = ZodType,
1215
- ReqResult = z.output<Response>,
1216
- Result = unknown,
1217
- OnMutateResult = unknown,
1218
- Context = unknown,
1219
- >(
1220
- endpoint: {
1221
- config: BaseEndpointConfig<Method, Url, undefined, Response>
1222
- },
1223
- mutationOptions: {
1224
- processResponse: ProcessResponseFunction<Result, ReqResult>
1225
- useContext?: () => Context
1226
- onMutate?: (
1227
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
1228
- context: Context & MutationFunctionContext,
1229
- ) => OnMutateResult | Promise<OnMutateResult>
1230
- onSuccess?: (
1231
- data: NoInfer<Result>,
1232
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
1233
- context: Context &
1234
- MutationFunctionContext & {
1235
- onMutateResult: OnMutateResult | undefined
1236
- },
1237
- ) => void | Promise<void>
1238
- onError?: (
1239
- error: Error,
1240
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
1241
- context: Context &
1242
- MutationFunctionContext & {
1243
- onMutateResult: OnMutateResult | undefined
1244
- },
1245
- ) => void | Promise<void>
1246
- onSettled?: (
1247
- data: NoInfer<Result> | undefined,
1248
- error: Error | null,
1249
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
1250
- context: Context &
1251
- MutationFunctionContext & {
1252
- onMutateResult: OnMutateResult | undefined
1253
- },
1254
- ) => void | Promise<void>
1255
- },
1256
- ): (() => UseMutationResult<
1257
- Result,
1258
- Error,
1259
- MutationArgs<Url, undefined, undefined>,
1260
- OnMutateResult
1261
- >) &
1262
- EndpointHelper<Method, Url, undefined, Response, undefined>
1263
-
1264
- // ============================================================================
1265
- // MULTIPART MUTATION METHODS
1266
- // ============================================================================
1267
-
1268
- multipartMutation<
1269
- Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
1270
- Url extends string = string,
1271
- RequestSchema extends ZodType = ZodType,
1272
- QuerySchema extends ZodObject = ZodObject,
1273
- Response extends ZodType = ZodType,
1274
- ReqResult = z.output<Response>,
1275
- Result = unknown,
1276
- OnMutateResult = unknown,
1277
- Context = unknown,
1278
- UseKey extends true = true,
1279
- >(config: {
1280
- method: Method
1281
- url: Url
1282
- useKey: UseKey
1283
- requestSchema: RequestSchema
1284
- querySchema: QuerySchema
1285
- responseSchema: Response
1286
- processResponse: ProcessResponseFunction<Result, ReqResult>
1287
- useContext?: () => Context
1288
- onMutate?: (
1289
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
1290
- context: Context & MutationFunctionContext,
1291
- ) => OnMutateResult | Promise<OnMutateResult>
1292
- onSuccess?: (
1293
- data: NoInfer<Result>,
1294
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
1295
- context: Context &
1296
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
1297
- ) => void | Promise<void>
1298
- onError?: (
1299
- error: Error,
1300
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
1301
- context: Context &
1302
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
1303
- ) => void | Promise<void>
1304
- onSettled?: (
1305
- data: NoInfer<Result> | undefined,
1306
- error: Error | null,
1307
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
1308
- context: Context &
1309
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
1310
- ) => void | Promise<void>
1311
- }): ((
1312
- params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
1313
- ) => UseMutationResult<
1314
- Result,
1315
- Error,
1316
- MutationArgs<Url, RequestSchema, QuerySchema>,
1317
- OnMutateResult
1318
- >) &
1319
- MutationHelpers<Url, Result> &
1320
- EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
1321
-
1322
- multipartMutation<
1323
- Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
1324
- Url extends string = string,
1325
- RequestSchema extends ZodType = ZodType,
1326
- QuerySchema extends ZodObject = ZodObject,
1327
- Response extends ZodType = ZodType,
1328
- ReqResult = z.output<Response>,
1329
- Result = unknown,
1330
- OnMutateResult = unknown,
1331
- Context = unknown,
1332
- >(config: {
1333
- method: Method
1334
- url: Url
1335
- requestSchema: RequestSchema
1336
- querySchema: QuerySchema
1337
- responseSchema: Response
1338
- processResponse: ProcessResponseFunction<Result, ReqResult>
1339
- useContext?: () => Context
1340
- onMutate?: (
1341
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
1342
- context: Context & MutationFunctionContext,
1343
- ) => OnMutateResult | Promise<OnMutateResult>
1344
- onSuccess?: (
1345
- data: NoInfer<Result>,
1346
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
1347
- context: Context &
1348
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
1349
- ) => void | Promise<void>
1350
- onError?: (
1351
- error: Error,
1352
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
1353
- context: Context &
1354
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
1355
- ) => void | Promise<void>
1356
- onSettled?: (
1357
- data: NoInfer<Result> | undefined,
1358
- error: Error | null,
1359
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, QuerySchema>>,
1360
- context: Context &
1361
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
1362
- ) => void | Promise<void>
1363
- }): (() => UseMutationResult<
1364
- Result,
1365
- Error,
1366
- MutationArgs<Url, RequestSchema, QuerySchema>,
1367
- OnMutateResult
1368
- >) &
1369
- MutationHelpers<Url, Result> &
1370
- EndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
1371
-
1372
- multipartMutation<
1373
- Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
1374
- Url extends string = string,
1375
- RequestSchema extends ZodType = ZodType,
1376
- Response extends ZodType = ZodType,
1377
- ReqResult = z.output<Response>,
1378
- Result = unknown,
1379
- OnMutateResult = unknown,
1380
- Context = unknown,
1381
- >(config: {
1382
- method: Method
1383
- url: Url
1384
- requestSchema: RequestSchema
1385
- responseSchema: Response
1386
- processResponse: ProcessResponseFunction<Result, ReqResult>
1387
- useContext?: () => Context
1388
- onMutate?: (
1389
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
1390
- context: Context & MutationFunctionContext,
1391
- ) => OnMutateResult | Promise<OnMutateResult>
1392
- onSuccess?: (
1393
- data: NoInfer<Result>,
1394
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
1395
- context: Context &
1396
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
1397
- ) => void | Promise<void>
1398
- onError?: (
1399
- error: Error,
1400
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
1401
- context: Context &
1402
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
1403
- ) => void | Promise<void>
1404
- onSettled?: (
1405
- data: NoInfer<Result> | undefined,
1406
- error: Error | null,
1407
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
1408
- context: Context &
1409
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
1410
- ) => void | Promise<void>
1411
- }): (() => UseMutationResult<
1412
- Result,
1413
- Error,
1414
- MutationArgs<Url, RequestSchema, undefined>,
1415
- OnMutateResult
1416
- >) &
1417
- MutationHelpers<Url, Result> &
1418
- EndpointHelper<Method, Url, RequestSchema, Response>
1419
-
1420
- multipartMutation<
1421
- Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
1422
- Url extends string = string,
1423
- RequestSchema extends ZodType = ZodType,
1424
- Response extends ZodType = ZodType,
1425
- ReqResult = z.output<Response>,
1426
- Result = unknown,
1427
- OnMutateResult = unknown,
1428
- Context = unknown,
1429
- UseKey extends true = true,
1430
- >(config: {
1431
- method: Method
1432
- url: Url
1433
- useKey: UseKey
1434
- requestSchema: RequestSchema
1435
- responseSchema: Response
1436
- processResponse: ProcessResponseFunction<Result, ReqResult>
1437
- useContext?: () => Context
1438
- onMutate?: (
1439
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
1440
- context: Context & MutationFunctionContext,
1441
- ) => OnMutateResult | Promise<OnMutateResult>
1442
- onSuccess?: (
1443
- data: NoInfer<Result>,
1444
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
1445
- context: Context &
1446
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
1447
- ) => void | Promise<void>
1448
- onError?: (
1449
- error: Error,
1450
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
1451
- context: Context &
1452
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
1453
- ) => void | Promise<void>
1454
- onSettled?: (
1455
- data: NoInfer<Result> | undefined,
1456
- error: Error | null,
1457
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
1458
- context: Context &
1459
- MutationFunctionContext & { onMutateResult: OnMutateResult | undefined },
1460
- ) => void | Promise<void>
1461
- }): ((
1462
- params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
1463
- ) => UseMutationResult<
1464
- Result,
1465
- Error,
1466
- MutationArgs<Url, RequestSchema, undefined>,
1467
- OnMutateResult
1468
- >) &
1469
- MutationHelpers<Url, Result> &
1470
- EndpointHelper<Method, Url, RequestSchema, Response>
1471
-
1472
- // ============================================================================
1473
- // STREAM MUTATION FROM ENDPOINT METHODS
1474
- // ============================================================================
1475
-
1476
- // Stream mutation with useKey, requestSchema, and querySchema
1477
- mutationFromEndpoint<
1478
- Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
1479
- Url extends string = string,
1480
- RequestSchema extends ZodType = ZodType,
1481
- QuerySchema extends ZodObject = ZodObject,
1482
- Result = Blob,
1483
- OnMutateResult = unknown,
1484
- Context = unknown,
1485
- UseKey extends true = true,
1486
- >(
1487
- endpoint: {
1488
- config: BaseStreamConfig<Method, Url, QuerySchema, RequestSchema>
1489
- },
1490
- mutationOptions: {
1491
- processResponse?: ProcessResponseFunction<Result, Blob>
1492
- useKey: UseKey
1493
- useContext?: () => Context
1494
- onMutate?: (
1495
- variables: Util_FlatObject<
1496
- MutationArgs<Url, RequestSchema, QuerySchema>
1497
- >,
1498
- context: Context & MutationFunctionContext,
1499
- ) => OnMutateResult | Promise<OnMutateResult>
1500
- onSuccess?: (
1501
- data: NoInfer<Result>,
1502
- variables: Util_FlatObject<
1503
- MutationArgs<Url, RequestSchema, QuerySchema>
1504
- >,
1505
- context: Context &
1506
- MutationFunctionContext & {
1507
- onMutateResult: OnMutateResult | undefined
1508
- },
1509
- ) => void | Promise<void>
1510
- onError?: (
1511
- error: Error,
1512
- variables: Util_FlatObject<
1513
- MutationArgs<Url, RequestSchema, QuerySchema>
1514
- >,
1515
- context: Context &
1516
- MutationFunctionContext & {
1517
- onMutateResult: OnMutateResult | undefined
1518
- },
1519
- ) => void | Promise<void>
1520
- onSettled?: (
1521
- data: NoInfer<Result> | undefined,
1522
- error: Error | null,
1523
- variables: Util_FlatObject<
1524
- MutationArgs<Url, RequestSchema, QuerySchema>
1525
- >,
1526
- context: Context &
1527
- MutationFunctionContext & {
1528
- onMutateResult: OnMutateResult | undefined
1529
- },
1530
- ) => void | Promise<void>
1531
- },
1532
- ): ((
1533
- params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
1534
- ) => UseMutationResult<
1535
- Result,
1536
- Error,
1537
- MutationArgs<Url, RequestSchema, QuerySchema>,
1538
- OnMutateResult
1539
- >) &
1540
- MutationHelpers<Url, Result> &
1541
- StreamHelper<Method, Url, RequestSchema, QuerySchema>
1542
-
1543
- // Stream mutation without useKey, with requestSchema and querySchema
1544
- mutationFromEndpoint<
1545
- Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
1546
- Url extends string = string,
1547
- RequestSchema extends ZodType = ZodType,
1548
- QuerySchema extends ZodObject = ZodObject,
1549
- Result = Blob,
1550
- OnMutateResult = unknown,
1551
- Context = unknown,
1552
- >(
1553
- endpoint: {
1554
- config: BaseStreamConfig<Method, Url, QuerySchema, RequestSchema>
1555
- },
1556
- mutationOptions?: {
1557
- processResponse?: ProcessResponseFunction<Result, Blob>
1558
- useContext?: () => Context
1559
- onMutate?: (
1560
- variables: Util_FlatObject<
1561
- MutationArgs<Url, RequestSchema, QuerySchema>
1562
- >,
1563
- context: Context & MutationFunctionContext,
1564
- ) => OnMutateResult | Promise<OnMutateResult>
1565
- onSuccess?: (
1566
- data: NoInfer<Result>,
1567
- variables: Util_FlatObject<
1568
- MutationArgs<Url, RequestSchema, QuerySchema>
1569
- >,
1570
- context: Context &
1571
- MutationFunctionContext & {
1572
- onMutateResult: OnMutateResult | undefined
1573
- },
1574
- ) => void | Promise<void>
1575
- onError?: (
1576
- error: Error,
1577
- variables: Util_FlatObject<
1578
- MutationArgs<Url, RequestSchema, QuerySchema>
1579
- >,
1580
- context: Context &
1581
- MutationFunctionContext & {
1582
- onMutateResult: OnMutateResult | undefined
1583
- },
1584
- ) => void | Promise<void>
1585
- onSettled?: (
1586
- data: NoInfer<Result> | undefined,
1587
- error: Error | null,
1588
- variables: Util_FlatObject<
1589
- MutationArgs<Url, RequestSchema, QuerySchema>
1590
- >,
1591
- context: Context &
1592
- MutationFunctionContext & {
1593
- onMutateResult: OnMutateResult | undefined
1594
- },
1595
- ) => void | Promise<void>
1596
- },
1597
- ): (() => UseMutationResult<
1598
- Result,
1599
- Error,
1600
- MutationArgs<Url, RequestSchema, QuerySchema>,
1601
- OnMutateResult
1602
- >) &
1603
- StreamHelper<Method, Url, RequestSchema, QuerySchema>
1604
-
1605
- // Stream mutation with useKey, requestSchema only
1606
- mutationFromEndpoint<
1607
- Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
1608
- Url extends string = string,
1609
- RequestSchema extends ZodType = ZodType,
1610
- Result = Blob,
1611
- OnMutateResult = unknown,
1612
- Context = unknown,
1613
- UseKey extends true = true,
1614
- >(
1615
- endpoint: {
1616
- config: BaseStreamConfig<Method, Url, undefined, RequestSchema>
1617
- },
1618
- mutationOptions: {
1619
- processResponse?: ProcessResponseFunction<Result, Blob>
1620
- useKey: UseKey
1621
- useContext?: () => Context
1622
- onMutate?: (
1623
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
1624
- context: Context & MutationFunctionContext,
1625
- ) => OnMutateResult | Promise<OnMutateResult>
1626
- onSuccess?: (
1627
- data: NoInfer<Result>,
1628
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
1629
- context: Context &
1630
- MutationFunctionContext & {
1631
- onMutateResult: OnMutateResult | undefined
1632
- },
1633
- ) => void | Promise<void>
1634
- onError?: (
1635
- error: Error,
1636
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
1637
- context: Context &
1638
- MutationFunctionContext & {
1639
- onMutateResult: OnMutateResult | undefined
1640
- },
1641
- ) => void | Promise<void>
1642
- onSettled?: (
1643
- data: NoInfer<Result> | undefined,
1644
- error: Error | null,
1645
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
1646
- context: Context &
1647
- MutationFunctionContext & {
1648
- onMutateResult: OnMutateResult | undefined
1649
- },
1650
- ) => void | Promise<void>
1651
- },
1652
- ): ((
1653
- params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
1654
- ) => UseMutationResult<
1655
- Result,
1656
- Error,
1657
- MutationArgs<Url, RequestSchema, undefined>,
1658
- OnMutateResult
1659
- >) &
1660
- MutationHelpers<Url, Result> &
1661
- StreamHelper<Method, Url, RequestSchema, undefined>
1662
-
1663
- // Stream mutation without useKey, with requestSchema only
1664
- mutationFromEndpoint<
1665
- Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
1666
- Url extends string = string,
1667
- RequestSchema extends ZodType = ZodType,
1668
- Result = Blob,
1669
- OnMutateResult = unknown,
1670
- Context = unknown,
1671
- >(
1672
- endpoint: {
1673
- config: BaseStreamConfig<Method, Url, undefined, RequestSchema>
1674
- },
1675
- mutationOptions?: {
1676
- processResponse?: ProcessResponseFunction<Result, Blob>
1677
- useContext?: () => Context
1678
- onMutate?: (
1679
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
1680
- context: Context & MutationFunctionContext,
1681
- ) => OnMutateResult | Promise<OnMutateResult>
1682
- onSuccess?: (
1683
- data: NoInfer<Result>,
1684
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
1685
- context: Context &
1686
- MutationFunctionContext & {
1687
- onMutateResult: OnMutateResult | undefined
1688
- },
1689
- ) => void | Promise<void>
1690
- onError?: (
1691
- error: Error,
1692
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
1693
- context: Context &
1694
- MutationFunctionContext & {
1695
- onMutateResult: OnMutateResult | undefined
1696
- },
1697
- ) => void | Promise<void>
1698
- onSettled?: (
1699
- data: NoInfer<Result> | undefined,
1700
- error: Error | null,
1701
- variables: Util_FlatObject<MutationArgs<Url, RequestSchema, undefined>>,
1702
- context: Context &
1703
- MutationFunctionContext & {
1704
- onMutateResult: OnMutateResult | undefined
1705
- },
1706
- ) => void | Promise<void>
1707
- },
1708
- ): (() => UseMutationResult<
1709
- Result,
1710
- Error,
1711
- MutationArgs<Url, RequestSchema, undefined>,
1712
- OnMutateResult
1713
- >) &
1714
- StreamHelper<Method, Url, RequestSchema, undefined>
1715
-
1716
- // Stream mutation GET methods with useKey and querySchema
1717
- mutationFromEndpoint<
1718
- Method extends 'GET' | 'DELETE' | 'OPTIONS' | 'HEAD' = 'GET',
1719
- Url extends string = string,
1720
- QuerySchema extends ZodObject = ZodObject,
1721
- Result = Blob,
1722
- OnMutateResult = unknown,
1723
- Context = unknown,
1724
- UseKey extends true = true,
1725
- >(
1726
- endpoint: {
1727
- config: BaseStreamConfig<Method, Url, QuerySchema, undefined>
1728
- },
1729
- mutationOptions: {
1730
- processResponse?: ProcessResponseFunction<Result, Blob>
1731
- useKey: UseKey
1732
- useContext?: () => Context
1733
- onMutate?: (
1734
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
1735
- context: Context & MutationFunctionContext,
1736
- ) => OnMutateResult | Promise<OnMutateResult>
1737
- onSuccess?: (
1738
- data: NoInfer<Result>,
1739
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
1740
- context: Context &
1741
- MutationFunctionContext & {
1742
- onMutateResult: OnMutateResult | undefined
1743
- },
1744
- ) => void | Promise<void>
1745
- onError?: (
1746
- error: Error,
1747
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
1748
- context: Context &
1749
- MutationFunctionContext & {
1750
- onMutateResult: OnMutateResult | undefined
1751
- },
1752
- ) => void | Promise<void>
1753
- onSettled?: (
1754
- data: NoInfer<Result> | undefined,
1755
- error: Error | null,
1756
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
1757
- context: Context &
1758
- MutationFunctionContext & {
1759
- onMutateResult: OnMutateResult | undefined
1760
- },
1761
- ) => void | Promise<void>
1762
- },
1763
- ): ((
1764
- params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
1765
- ) => UseMutationResult<
1766
- Result,
1767
- Error,
1768
- MutationArgs<Url, undefined, QuerySchema>,
1769
- OnMutateResult
1770
- >) &
1771
- MutationHelpers<Url, Result> &
1772
- StreamHelper<Method, Url, undefined, QuerySchema>
1773
-
1774
- // Stream mutation GET methods without useKey, with querySchema
1775
- mutationFromEndpoint<
1776
- Method extends 'GET' | 'DELETE' | 'OPTIONS' | 'HEAD' = 'GET',
1777
- Url extends string = string,
1778
- QuerySchema extends ZodObject = ZodObject,
1779
- Result = Blob,
1780
- OnMutateResult = unknown,
1781
- Context = unknown,
1782
- >(
1783
- endpoint: {
1784
- config: BaseStreamConfig<Method, Url, QuerySchema, undefined>
1785
- },
1786
- mutationOptions?: {
1787
- processResponse?: ProcessResponseFunction<Result, Blob>
1788
- useContext?: () => Context
1789
- onMutate?: (
1790
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
1791
- context: Context & MutationFunctionContext,
1792
- ) => OnMutateResult | Promise<OnMutateResult>
1793
- onSuccess?: (
1794
- data: NoInfer<Result>,
1795
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
1796
- context: Context &
1797
- MutationFunctionContext & {
1798
- onMutateResult: OnMutateResult | undefined
1799
- },
1800
- ) => void | Promise<void>
1801
- onError?: (
1802
- error: Error,
1803
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
1804
- context: Context &
1805
- MutationFunctionContext & {
1806
- onMutateResult: OnMutateResult | undefined
1807
- },
1808
- ) => void | Promise<void>
1809
- onSettled?: (
1810
- data: NoInfer<Result> | undefined,
1811
- error: Error | null,
1812
- variables: Util_FlatObject<MutationArgs<Url, undefined, QuerySchema>>,
1813
- context: Context &
1814
- MutationFunctionContext & {
1815
- onMutateResult: OnMutateResult | undefined
1816
- },
1817
- ) => void | Promise<void>
1818
- },
1819
- ): (() => UseMutationResult<
1820
- Result,
1821
- Error,
1822
- MutationArgs<Url, undefined, QuerySchema>,
1823
- OnMutateResult
1824
- >) &
1825
- StreamHelper<Method, Url, undefined, QuerySchema>
1826
-
1827
- // Stream mutation GET methods with useKey only (no schemas)
1828
- mutationFromEndpoint<
1829
- Method extends 'GET' | 'DELETE' | 'OPTIONS' | 'HEAD' = 'GET',
1830
- Url extends string = string,
1831
- Result = Blob,
1832
- OnMutateResult = unknown,
1833
- Context = unknown,
1834
- UseKey extends true = true,
1835
- >(
1836
- endpoint: {
1837
- config: BaseStreamConfig<Method, Url, undefined, undefined>
1838
- },
1839
- mutationOptions: {
1840
- processResponse?: ProcessResponseFunction<Result, Blob>
1841
- useKey: UseKey
1842
- useContext?: () => Context
1843
- onMutate?: (
1844
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
1845
- context: Context & MutationFunctionContext,
1846
- ) => OnMutateResult | Promise<OnMutateResult>
1847
- onSuccess?: (
1848
- data: NoInfer<Result>,
1849
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
1850
- context: Context &
1851
- MutationFunctionContext & {
1852
- onMutateResult: OnMutateResult | undefined
1853
- },
1854
- ) => void | Promise<void>
1855
- onError?: (
1856
- error: Error,
1857
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
1858
- context: Context &
1859
- MutationFunctionContext & {
1860
- onMutateResult: OnMutateResult | undefined
1861
- },
1862
- ) => void | Promise<void>
1863
- onSettled?: (
1864
- data: NoInfer<Result> | undefined,
1865
- error: Error | null,
1866
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
1867
- context: Context &
1868
- MutationFunctionContext & {
1869
- onMutateResult: OnMutateResult | undefined
1870
- },
1871
- ) => void | Promise<void>
1872
- },
1873
- ): ((
1874
- params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
1875
- ) => UseMutationResult<
1876
- Result,
1877
- Error,
1878
- MutationArgs<Url, undefined, undefined>,
1879
- OnMutateResult
1880
- >) &
1881
- MutationHelpers<Url, Result> &
1882
- StreamHelper<Method, Url, undefined, undefined>
1883
-
1884
- // Stream mutation GET methods without useKey (no schemas)
1885
- mutationFromEndpoint<
1886
- Method extends 'GET' | 'DELETE' | 'OPTIONS' | 'HEAD' = 'GET',
1887
- Url extends string = string,
1888
- Result = Blob,
1889
- OnMutateResult = unknown,
1890
- Context = unknown,
1891
- >(
1892
- endpoint: {
1893
- config: BaseStreamConfig<Method, Url, undefined, undefined>
1894
- },
1895
- mutationOptions?: {
1896
- processResponse?: ProcessResponseFunction<Result, Blob>
1897
- useContext?: () => Context
1898
- onMutate?: (
1899
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
1900
- context: Context & MutationFunctionContext,
1901
- ) => OnMutateResult | Promise<OnMutateResult>
1902
- onSuccess?: (
1903
- data: NoInfer<Result>,
1904
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
1905
- context: Context &
1906
- MutationFunctionContext & {
1907
- onMutateResult: OnMutateResult | undefined
1908
- },
1909
- ) => void | Promise<void>
1910
- onError?: (
1911
- error: Error,
1912
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
1913
- context: Context &
1914
- MutationFunctionContext & {
1915
- onMutateResult: OnMutateResult | undefined
1916
- },
1917
- ) => void | Promise<void>
1918
- onSettled?: (
1919
- data: NoInfer<Result> | undefined,
1920
- error: Error | null,
1921
- variables: Util_FlatObject<MutationArgs<Url, undefined, undefined>>,
1922
- context: Context &
1923
- MutationFunctionContext & {
1924
- onMutateResult: OnMutateResult | undefined
1925
- },
1926
- ) => void | Promise<void>
1927
- },
1928
- ): (() => UseMutationResult<
1929
- Result,
1930
- Error,
1931
- MutationArgs<Url, undefined, undefined>,
1932
- OnMutateResult
1933
- >) &
1934
- StreamHelper<Method, Url, undefined, undefined>
1935
- }
1
+ export * from './types/index.mjs'