@navios/react-query 0.1.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/__tests__/client-type-check.spec.d.mts +2 -0
- package/dist/src/__tests__/client-type-check.spec.d.mts.map +1 -0
- package/dist/src/__tests__/declare-client.spec.d.mts +2 -0
- package/dist/src/__tests__/declare-client.spec.d.mts.map +1 -0
- package/dist/src/__tests__/make-mutation.spec.d.mts +2 -0
- package/dist/src/__tests__/make-mutation.spec.d.mts.map +1 -0
- package/dist/src/__tests__/makeDataTag.spec.d.mts +2 -0
- package/dist/src/__tests__/makeDataTag.spec.d.mts.map +1 -0
- package/dist/src/__tests__/makeInfiniteQueryOptions.spec.d.mts +2 -0
- package/dist/src/__tests__/makeInfiniteQueryOptions.spec.d.mts.map +1 -0
- package/dist/src/__tests__/makeQueryOptions.spec.d.mts +2 -0
- package/dist/src/__tests__/makeQueryOptions.spec.d.mts.map +1 -0
- package/dist/src/declare-client.d.mts +31 -0
- package/dist/src/declare-client.d.mts.map +1 -0
- package/dist/src/index.d.mts +9 -0
- package/dist/src/index.d.mts.map +1 -0
- package/dist/src/make-infinite-query-options.d.mts +13 -0
- package/dist/src/make-infinite-query-options.d.mts.map +1 -0
- package/dist/src/make-mutation.d.mts +15 -0
- package/dist/src/make-mutation.d.mts.map +1 -0
- package/dist/src/make-query-options.d.mts +15 -0
- package/dist/src/make-query-options.d.mts.map +1 -0
- package/dist/src/types/client-endpoint-helper.d.mts +8 -0
- package/dist/src/types/client-endpoint-helper.d.mts.map +1 -0
- package/dist/src/types/client-instance.d.mts +211 -0
- package/dist/src/types/client-instance.d.mts.map +1 -0
- package/dist/src/types/index.d.mts +8 -0
- package/dist/src/types/index.d.mts.map +1 -0
- package/dist/src/types/mutation-args.d.mts +10 -0
- package/dist/src/types/mutation-args.d.mts.map +1 -0
- package/dist/src/types/mutation-helpers.d.mts +10 -0
- package/dist/src/types/mutation-helpers.d.mts.map +1 -0
- package/dist/src/types/query-args.d.mts +8 -0
- package/dist/src/types/query-args.d.mts.map +1 -0
- package/dist/src/types/query-helpers.d.mts +14 -0
- package/dist/src/types/query-helpers.d.mts.map +1 -0
- package/dist/src/types/query-url-params-args.d.mts +5 -0
- package/dist/src/types/query-url-params-args.d.mts.map +1 -0
- package/dist/src/types.d.mts +49 -0
- package/dist/src/types.d.mts.map +1 -0
- package/dist/src/utils/mutation-key.creator.d.mts +39 -0
- package/dist/src/utils/mutation-key.creator.d.mts.map +1 -0
- package/dist/src/utils/query-key-creator.d.mts +24 -0
- package/dist/src/utils/query-key-creator.d.mts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/tsdown.config.d.mts +3 -0
- package/dist/tsdown.config.d.mts.map +1 -0
- package/dist/tsup.config.d.mts +3 -0
- package/dist/tsup.config.d.mts.map +1 -0
- package/dist/vitest.config.d.mts +3 -0
- package/dist/vitest.config.d.mts.map +1 -0
- package/{dist → lib}/_tsup-dts-rollup.d.mts +89 -35
- package/{dist → lib}/_tsup-dts-rollup.d.ts +89 -35
- package/{dist → lib}/index.js +49 -74
- package/lib/index.js.map +1 -0
- package/{dist → lib}/index.mjs +34 -42
- package/lib/index.mjs.map +1 -0
- package/package.json +12 -13
- package/project.json +53 -0
- package/src/__tests__/client-type-check.spec.mts +1 -1
- package/src/__tests__/declare-client.spec.mts +1 -2
- package/src/__tests__/make-mutation.spec.mts +1 -1
- package/src/__tests__/makeDataTag.spec.mts +1 -1
- package/src/__tests__/makeInfiniteQueryOptions.spec.mts +1 -1
- package/src/__tests__/makeQueryOptions.spec.mts +1 -1
- package/src/declare-client.mts +32 -1
- package/src/make-infinite-query-options.mts +1 -1
- package/src/make-mutation.mts +1 -1
- package/src/make-query-options.mts +1 -1
- package/src/types/client-endpoint-helper.mts +1 -1
- package/src/types/client-instance.mts +373 -23
- package/src/types/mutation-args.mts +1 -1
- package/src/types/mutation-helpers.mts +1 -1
- package/src/types/query-args.mts +1 -1
- package/src/types/query-helpers.mts +1 -1
- package/src/types/query-url-params-args.mts +1 -1
- package/src/types.mts +1 -1
- package/src/utils/mutation-key.creator.mts +5 -1
- package/src/utils/query-key-creator.mts +6 -2
- package/tsconfig.json +16 -0
- package/tsup.config.mts +12 -0
- package/vitest.config.mts +9 -0
- /package/{dist → lib}/index.d.mts +0 -0
- /package/{dist → lib}/index.d.ts +0 -0
package/project.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@navios/react-query",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "packages/react-query/src",
|
|
5
|
+
"prefix": "react-query",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"projectType": "library",
|
|
8
|
+
"targets": {
|
|
9
|
+
"check": {
|
|
10
|
+
"executor": "nx:run-commands",
|
|
11
|
+
"outputs": ["{projectRoot}/dist"],
|
|
12
|
+
"inputs": ["^projectSources", "projectSources"],
|
|
13
|
+
"options": {
|
|
14
|
+
"command": ["tsc -b"],
|
|
15
|
+
"cwd": "packages/react-query"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"test:ci": {
|
|
19
|
+
"executor": "nx:run-commands",
|
|
20
|
+
"inputs": ["^projectSources", "project"],
|
|
21
|
+
"options": {
|
|
22
|
+
"command": "vitest run",
|
|
23
|
+
"cwd": "packages/react-query"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"build": {
|
|
27
|
+
"executor": "nx:run-commands",
|
|
28
|
+
"inputs": ["projectSources"],
|
|
29
|
+
"outputs": ["{projectRoot}/lib"],
|
|
30
|
+
"dependsOn": ["check", "test:ci"],
|
|
31
|
+
"options": {
|
|
32
|
+
"command": "tsup",
|
|
33
|
+
"cwd": "packages/react-query"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"publish": {
|
|
37
|
+
"executor": "nx:run-commands",
|
|
38
|
+
"dependsOn": ["build"],
|
|
39
|
+
"options": {
|
|
40
|
+
"command": "yarn npm publish --access public",
|
|
41
|
+
"cwd": "packages/react-query"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"publish:next": {
|
|
45
|
+
"executor": "nx:run-commands",
|
|
46
|
+
"dependsOn": ["build"],
|
|
47
|
+
"options": {
|
|
48
|
+
"command": "yarn npm publish --access public --tag next",
|
|
49
|
+
"cwd": "packages/react-query"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { create } from 'navios'
|
|
2
2
|
import { makeNaviosFakeAdapter } from 'navios/testing'
|
|
3
3
|
|
|
4
|
-
import { builder } from '@navios/
|
|
4
|
+
import { builder } from '@navios/builder'
|
|
5
5
|
|
|
6
6
|
import { describe, expect, it, vi } from 'vitest'
|
|
7
7
|
import { z } from 'zod'
|
|
@@ -167,7 +167,6 @@ describe('declareClient', () => {
|
|
|
167
167
|
},
|
|
168
168
|
})
|
|
169
169
|
|
|
170
|
-
// @ts-expect-error it's internal type
|
|
171
170
|
const mutationResult = mutation()
|
|
172
171
|
const res = await mutationResult.mutateAsync({
|
|
173
172
|
urlParams: {
|
package/src/declare-client.mts
CHANGED
|
@@ -3,7 +3,7 @@ import type {
|
|
|
3
3
|
AnyEndpointConfig,
|
|
4
4
|
HttpMethod,
|
|
5
5
|
Util_FlatObject,
|
|
6
|
-
} from '@navios/
|
|
6
|
+
} from '@navios/builder'
|
|
7
7
|
import type { InfiniteData, QueryClient } from '@tanstack/react-query'
|
|
8
8
|
import type { AnyZodObject, z, ZodType } from 'zod'
|
|
9
9
|
|
|
@@ -211,6 +211,35 @@ export function declareClient<Options extends ClientOptions>({
|
|
|
211
211
|
return useMutation
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
function mutationFromEndpoint(
|
|
215
|
+
endpoint: AbstractEndpoint<AnyEndpointConfig>,
|
|
216
|
+
options: {
|
|
217
|
+
processResponse: ProcessResponseFunction
|
|
218
|
+
useContext?: () => unknown
|
|
219
|
+
onSuccess?: (
|
|
220
|
+
queryClient: QueryClient,
|
|
221
|
+
data: unknown,
|
|
222
|
+
variables: Util_FlatObject<ClientMutationArgs>,
|
|
223
|
+
context: unknown,
|
|
224
|
+
) => void | Promise<void>
|
|
225
|
+
onError?: (
|
|
226
|
+
queryClient: QueryClient,
|
|
227
|
+
error: Error,
|
|
228
|
+
variables: Util_FlatObject<ClientMutationArgs>,
|
|
229
|
+
context: unknown,
|
|
230
|
+
) => void | Promise<void>
|
|
231
|
+
},
|
|
232
|
+
) {
|
|
233
|
+
return makeMutation(endpoint, {
|
|
234
|
+
processResponse: options.processResponse,
|
|
235
|
+
useContext: options.useContext,
|
|
236
|
+
onSuccess: options.onSuccess,
|
|
237
|
+
// @ts-expect-error simplify types here
|
|
238
|
+
onError: options.onError,
|
|
239
|
+
...defaults,
|
|
240
|
+
})
|
|
241
|
+
}
|
|
242
|
+
|
|
214
243
|
return {
|
|
215
244
|
// @ts-expect-error We simplified types here
|
|
216
245
|
query,
|
|
@@ -222,5 +251,7 @@ export function declareClient<Options extends ClientOptions>({
|
|
|
222
251
|
infiniteQueryFromEndpoint,
|
|
223
252
|
// @ts-expect-error We simplified types here
|
|
224
253
|
mutation,
|
|
254
|
+
// @ts-expect-error We simplified types here
|
|
255
|
+
mutationFromEndpoint,
|
|
225
256
|
}
|
|
226
257
|
}
|
package/src/make-mutation.mts
CHANGED
|
@@ -3,7 +3,7 @@ import type {
|
|
|
3
3
|
UrlHasParams,
|
|
4
4
|
UrlParams,
|
|
5
5
|
Util_FlatObject,
|
|
6
|
-
} from '@navios/
|
|
6
|
+
} from '@navios/builder'
|
|
7
7
|
import type {
|
|
8
8
|
DataTag,
|
|
9
9
|
InfiniteData,
|
|
@@ -182,13 +182,11 @@ export interface ClientInstance {
|
|
|
182
182
|
>,
|
|
183
183
|
context: Context,
|
|
184
184
|
) => void | Promise<void>
|
|
185
|
-
}): (
|
|
186
|
-
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
187
|
-
) => UseMutationResult<
|
|
185
|
+
}): (() => UseMutationResult<
|
|
188
186
|
Result,
|
|
189
187
|
Error,
|
|
190
188
|
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
191
|
-
> &
|
|
189
|
+
>) &
|
|
192
190
|
ClientEndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
|
|
193
191
|
|
|
194
192
|
mutation<
|
|
@@ -222,9 +220,7 @@ export interface ClientInstance {
|
|
|
222
220
|
>,
|
|
223
221
|
context: Context,
|
|
224
222
|
) => void | Promise<void>
|
|
225
|
-
}): ((
|
|
226
|
-
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
227
|
-
) => UseMutationResult<
|
|
223
|
+
}): (() => UseMutationResult<
|
|
228
224
|
Result,
|
|
229
225
|
Error,
|
|
230
226
|
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
@@ -266,7 +262,7 @@ export interface ClientInstance {
|
|
|
266
262
|
context: Context,
|
|
267
263
|
) => void | Promise<void>
|
|
268
264
|
}): ((
|
|
269
|
-
params: UrlHasParams<Url> extends true ?
|
|
265
|
+
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
270
266
|
) => UseMutationResult<
|
|
271
267
|
Result,
|
|
272
268
|
Error,
|
|
@@ -309,7 +305,7 @@ export interface ClientInstance {
|
|
|
309
305
|
context: Context,
|
|
310
306
|
) => void | Promise<void>
|
|
311
307
|
}): ((
|
|
312
|
-
params: UrlHasParams<Url> extends true ?
|
|
308
|
+
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
313
309
|
) => UseMutationResult<
|
|
314
310
|
Result,
|
|
315
311
|
Error,
|
|
@@ -349,13 +345,11 @@ export interface ClientInstance {
|
|
|
349
345
|
>,
|
|
350
346
|
context: Context,
|
|
351
347
|
) => void | Promise<void>
|
|
352
|
-
}): (
|
|
353
|
-
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
354
|
-
) => UseMutationResult<
|
|
348
|
+
}): (() => UseMutationResult<
|
|
355
349
|
Result,
|
|
356
350
|
Error,
|
|
357
351
|
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
358
|
-
> &
|
|
352
|
+
>) &
|
|
359
353
|
ClientEndpointHelper<Method, Url, undefined, Response, QuerySchema>
|
|
360
354
|
|
|
361
355
|
mutation<
|
|
@@ -386,7 +380,7 @@ export interface ClientInstance {
|
|
|
386
380
|
context: Context,
|
|
387
381
|
) => void | Promise<void>
|
|
388
382
|
}): ((
|
|
389
|
-
params: UrlHasParams<Url> extends true ?
|
|
383
|
+
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
390
384
|
) => UseMutationResult<
|
|
391
385
|
Result,
|
|
392
386
|
Error,
|
|
@@ -420,13 +414,11 @@ export interface ClientInstance {
|
|
|
420
414
|
variables: Util_FlatObject<ClientMutationArgs<Url, undefined, undefined>>,
|
|
421
415
|
context: Context,
|
|
422
416
|
) => void | Promise<void>
|
|
423
|
-
}): (
|
|
424
|
-
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
425
|
-
) => UseMutationResult<
|
|
417
|
+
}): (() => UseMutationResult<
|
|
426
418
|
Result,
|
|
427
419
|
Error,
|
|
428
420
|
ClientMutationArgs<Url, undefined, undefined>
|
|
429
|
-
> &
|
|
421
|
+
>) &
|
|
430
422
|
ClientEndpointHelper<Method, Url, undefined, Response>
|
|
431
423
|
|
|
432
424
|
queryFromEndpoint<
|
|
@@ -464,14 +456,14 @@ export interface ClientInstance {
|
|
|
464
456
|
options?: {
|
|
465
457
|
processResponse?: (data: z.output<Response>) => Result
|
|
466
458
|
},
|
|
467
|
-
): (
|
|
459
|
+
): ((
|
|
468
460
|
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
469
461
|
) => UseSuspenseQueryOptions<
|
|
470
462
|
Result,
|
|
471
463
|
Error,
|
|
472
464
|
Result,
|
|
473
465
|
DataTag<Split<Url, '/'>, Result, Error>
|
|
474
|
-
> &
|
|
466
|
+
>) &
|
|
475
467
|
QueryHelpers<Url, undefined, Result>
|
|
476
468
|
|
|
477
469
|
infiniteQueryFromEndpoint<
|
|
@@ -500,7 +492,7 @@ export interface ClientInstance {
|
|
|
500
492
|
allPageParams: z.infer<QuerySchema>[] | undefined,
|
|
501
493
|
) => z.input<QuerySchema>
|
|
502
494
|
},
|
|
503
|
-
): (
|
|
495
|
+
): ((
|
|
504
496
|
params: UrlHasParams<Url> extends true ? { urlParams: UrlParams<Url> } : {},
|
|
505
497
|
) => UseSuspenseInfiniteQueryOptions<
|
|
506
498
|
PageResult,
|
|
@@ -509,6 +501,364 @@ export interface ClientInstance {
|
|
|
509
501
|
PageResult,
|
|
510
502
|
DataTag<Split<Url, '/'>, PageResult, Error>,
|
|
511
503
|
z.output<QuerySchema>
|
|
512
|
-
> &
|
|
504
|
+
>) &
|
|
513
505
|
QueryHelpers<Url, QuerySchema, PageResult, true>
|
|
506
|
+
|
|
507
|
+
mutationFromEndpoint<
|
|
508
|
+
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
509
|
+
Url extends string = string,
|
|
510
|
+
RequestSchema extends ZodType = ZodType,
|
|
511
|
+
QuerySchema extends AnyZodObject = AnyZodObject,
|
|
512
|
+
Response extends ZodType = ZodType,
|
|
513
|
+
ReqResult = z.output<Response>,
|
|
514
|
+
Result = unknown,
|
|
515
|
+
Context = unknown,
|
|
516
|
+
UseKey extends true = true,
|
|
517
|
+
>(
|
|
518
|
+
endpoint: any & {
|
|
519
|
+
config: BaseEndpointConfig<
|
|
520
|
+
Method,
|
|
521
|
+
Url,
|
|
522
|
+
QuerySchema,
|
|
523
|
+
Response,
|
|
524
|
+
RequestSchema
|
|
525
|
+
>
|
|
526
|
+
},
|
|
527
|
+
mutationOptions: {
|
|
528
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
529
|
+
useKey: UseKey
|
|
530
|
+
useContext?: () => Context
|
|
531
|
+
onSuccess?: (
|
|
532
|
+
queryClient: QueryClient,
|
|
533
|
+
data: NoInfer<Result>,
|
|
534
|
+
variables: Util_FlatObject<
|
|
535
|
+
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
536
|
+
>,
|
|
537
|
+
context: Context,
|
|
538
|
+
) => void | Promise<void>
|
|
539
|
+
onError?: (
|
|
540
|
+
queryClient: QueryClient,
|
|
541
|
+
error: Error,
|
|
542
|
+
variables: Util_FlatObject<
|
|
543
|
+
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
544
|
+
>,
|
|
545
|
+
context: Context,
|
|
546
|
+
) => void | Promise<void>
|
|
547
|
+
},
|
|
548
|
+
): ((
|
|
549
|
+
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
550
|
+
) => UseMutationResult<
|
|
551
|
+
Result,
|
|
552
|
+
Error,
|
|
553
|
+
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
554
|
+
>) &
|
|
555
|
+
MutationHelpers<Url, Result> &
|
|
556
|
+
ClientEndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
|
|
557
|
+
|
|
558
|
+
mutationFromEndpoint<
|
|
559
|
+
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
560
|
+
Url extends string = string,
|
|
561
|
+
RequestSchema extends ZodType = ZodType,
|
|
562
|
+
Response extends ZodType = ZodType,
|
|
563
|
+
ReqResult = z.output<Response>,
|
|
564
|
+
Result = unknown,
|
|
565
|
+
Context = unknown,
|
|
566
|
+
UseKey extends true = true,
|
|
567
|
+
>(
|
|
568
|
+
endpoint: any & {
|
|
569
|
+
config: BaseEndpointConfig<
|
|
570
|
+
Method,
|
|
571
|
+
Url,
|
|
572
|
+
undefined,
|
|
573
|
+
Response,
|
|
574
|
+
RequestSchema
|
|
575
|
+
>
|
|
576
|
+
},
|
|
577
|
+
mutationOptions: {
|
|
578
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
579
|
+
useKey: UseKey
|
|
580
|
+
useContext?: () => Context
|
|
581
|
+
onSuccess?: (
|
|
582
|
+
queryClient: QueryClient,
|
|
583
|
+
data: NoInfer<Result>,
|
|
584
|
+
variables: Util_FlatObject<
|
|
585
|
+
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
586
|
+
>,
|
|
587
|
+
context: Context,
|
|
588
|
+
) => void | Promise<void>
|
|
589
|
+
onError?: (
|
|
590
|
+
queryClient: QueryClient,
|
|
591
|
+
error: Error,
|
|
592
|
+
variables: Util_FlatObject<
|
|
593
|
+
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
594
|
+
>,
|
|
595
|
+
context: Context,
|
|
596
|
+
) => void | Promise<void>
|
|
597
|
+
},
|
|
598
|
+
): ((
|
|
599
|
+
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
600
|
+
) => UseMutationResult<
|
|
601
|
+
Result,
|
|
602
|
+
Error,
|
|
603
|
+
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
604
|
+
>) &
|
|
605
|
+
MutationHelpers<Url, Result> &
|
|
606
|
+
ClientEndpointHelper<Method, Url, RequestSchema, Response, undefined>
|
|
607
|
+
|
|
608
|
+
mutationFromEndpoint<
|
|
609
|
+
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
610
|
+
Url extends string = string,
|
|
611
|
+
RequestSchema extends ZodType = ZodType,
|
|
612
|
+
QuerySchema extends AnyZodObject = AnyZodObject,
|
|
613
|
+
Response extends ZodType = ZodType,
|
|
614
|
+
ReqResult = z.output<Response>,
|
|
615
|
+
Result = unknown,
|
|
616
|
+
Context = unknown,
|
|
617
|
+
>(
|
|
618
|
+
endpoint: any & {
|
|
619
|
+
config: BaseEndpointConfig<
|
|
620
|
+
Method,
|
|
621
|
+
Url,
|
|
622
|
+
QuerySchema,
|
|
623
|
+
Response,
|
|
624
|
+
RequestSchema
|
|
625
|
+
>
|
|
626
|
+
},
|
|
627
|
+
mutationOptions: {
|
|
628
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
629
|
+
useContext?: () => Context
|
|
630
|
+
onSuccess?: (
|
|
631
|
+
queryClient: QueryClient,
|
|
632
|
+
data: NoInfer<Result>,
|
|
633
|
+
variables: Util_FlatObject<
|
|
634
|
+
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
635
|
+
>,
|
|
636
|
+
context: Context,
|
|
637
|
+
) => void | Promise<void>
|
|
638
|
+
onError?: (
|
|
639
|
+
queryClient: QueryClient,
|
|
640
|
+
error: Error,
|
|
641
|
+
variables: Util_FlatObject<
|
|
642
|
+
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
643
|
+
>,
|
|
644
|
+
context: Context,
|
|
645
|
+
) => void | Promise<void>
|
|
646
|
+
},
|
|
647
|
+
): (() => UseMutationResult<
|
|
648
|
+
Result,
|
|
649
|
+
Error,
|
|
650
|
+
ClientMutationArgs<Url, RequestSchema, QuerySchema>
|
|
651
|
+
>) &
|
|
652
|
+
ClientEndpointHelper<Method, Url, RequestSchema, Response, QuerySchema>
|
|
653
|
+
|
|
654
|
+
mutationFromEndpoint<
|
|
655
|
+
Method extends 'POST' | 'PUT' | 'PATCH' = 'POST' | 'PUT' | 'PATCH',
|
|
656
|
+
Url extends string = string,
|
|
657
|
+
RequestSchema extends ZodType = ZodType,
|
|
658
|
+
Response extends ZodType = ZodType,
|
|
659
|
+
ReqResult = z.output<Response>,
|
|
660
|
+
Result = unknown,
|
|
661
|
+
Context = unknown,
|
|
662
|
+
>(
|
|
663
|
+
endpoint: any & {
|
|
664
|
+
config: BaseEndpointConfig<
|
|
665
|
+
Method,
|
|
666
|
+
Url,
|
|
667
|
+
undefined,
|
|
668
|
+
Response,
|
|
669
|
+
RequestSchema
|
|
670
|
+
>
|
|
671
|
+
},
|
|
672
|
+
mutationOptions: {
|
|
673
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
674
|
+
useContext?: () => Context
|
|
675
|
+
onSuccess?: (
|
|
676
|
+
queryClient: QueryClient,
|
|
677
|
+
data: NoInfer<Result>,
|
|
678
|
+
variables: Util_FlatObject<
|
|
679
|
+
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
680
|
+
>,
|
|
681
|
+
context: Context,
|
|
682
|
+
) => void | Promise<void>
|
|
683
|
+
onError?: (
|
|
684
|
+
queryClient: QueryClient,
|
|
685
|
+
error: Error,
|
|
686
|
+
variables: Util_FlatObject<
|
|
687
|
+
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
688
|
+
>,
|
|
689
|
+
context: Context,
|
|
690
|
+
) => void | Promise<void>
|
|
691
|
+
},
|
|
692
|
+
): (() => UseMutationResult<
|
|
693
|
+
Result,
|
|
694
|
+
Error,
|
|
695
|
+
ClientMutationArgs<Url, RequestSchema, undefined>
|
|
696
|
+
>) &
|
|
697
|
+
ClientEndpointHelper<Method, Url, RequestSchema, Response, undefined>
|
|
698
|
+
|
|
699
|
+
mutationFromEndpoint<
|
|
700
|
+
Method extends 'DELETE' = 'DELETE',
|
|
701
|
+
Url extends string = string,
|
|
702
|
+
QuerySchema extends AnyZodObject = AnyZodObject,
|
|
703
|
+
Response extends ZodType = ZodType,
|
|
704
|
+
ReqResult = z.output<Response>,
|
|
705
|
+
Result = unknown,
|
|
706
|
+
Context = unknown,
|
|
707
|
+
UseKey extends true = true,
|
|
708
|
+
>(
|
|
709
|
+
endpoint: any & {
|
|
710
|
+
config: BaseEndpointConfig<Method, Url, QuerySchema, Response>
|
|
711
|
+
},
|
|
712
|
+
mutationOptions: {
|
|
713
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
714
|
+
useKey: UseKey
|
|
715
|
+
useContext?: () => Context
|
|
716
|
+
onSuccess?: (
|
|
717
|
+
queryClient: QueryClient,
|
|
718
|
+
data: NoInfer<Result>,
|
|
719
|
+
variables: Util_FlatObject<
|
|
720
|
+
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
721
|
+
>,
|
|
722
|
+
context: Context,
|
|
723
|
+
) => void | Promise<void>
|
|
724
|
+
onError?: (
|
|
725
|
+
queryClient: QueryClient,
|
|
726
|
+
error: Error,
|
|
727
|
+
variables: Util_FlatObject<
|
|
728
|
+
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
729
|
+
>,
|
|
730
|
+
context: Context,
|
|
731
|
+
) => void | Promise<void>
|
|
732
|
+
},
|
|
733
|
+
): ((
|
|
734
|
+
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
735
|
+
) => UseMutationResult<
|
|
736
|
+
Result,
|
|
737
|
+
Error,
|
|
738
|
+
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
739
|
+
>) &
|
|
740
|
+
MutationHelpers<Url, Result> &
|
|
741
|
+
ClientEndpointHelper<Method, Url, undefined, Response, QuerySchema>
|
|
742
|
+
|
|
743
|
+
mutationFromEndpoint<
|
|
744
|
+
Method extends 'DELETE' = 'DELETE',
|
|
745
|
+
Url extends string = string,
|
|
746
|
+
Response extends ZodType = ZodType,
|
|
747
|
+
ReqResult = z.output<Response>,
|
|
748
|
+
Result = unknown,
|
|
749
|
+
Context = unknown,
|
|
750
|
+
UseKey extends true = true,
|
|
751
|
+
>(
|
|
752
|
+
endpoint: any & {
|
|
753
|
+
config: BaseEndpointConfig<Method, Url, undefined, Response>
|
|
754
|
+
},
|
|
755
|
+
mutationOptions: {
|
|
756
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
757
|
+
useKey: UseKey
|
|
758
|
+
useContext?: () => Context
|
|
759
|
+
onSuccess?: (
|
|
760
|
+
queryClient: QueryClient,
|
|
761
|
+
data: NoInfer<Result>,
|
|
762
|
+
variables: Util_FlatObject<
|
|
763
|
+
ClientMutationArgs<Url, undefined, undefined>
|
|
764
|
+
>,
|
|
765
|
+
context: Context,
|
|
766
|
+
) => void | Promise<void>
|
|
767
|
+
onError?: (
|
|
768
|
+
queryClient: QueryClient,
|
|
769
|
+
error: Error,
|
|
770
|
+
variables: Util_FlatObject<
|
|
771
|
+
ClientMutationArgs<Url, undefined, undefined>
|
|
772
|
+
>,
|
|
773
|
+
context: Context,
|
|
774
|
+
) => void | Promise<void>
|
|
775
|
+
},
|
|
776
|
+
): ((
|
|
777
|
+
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
778
|
+
) => UseMutationResult<
|
|
779
|
+
Result,
|
|
780
|
+
Error,
|
|
781
|
+
ClientMutationArgs<Url, undefined, undefined>
|
|
782
|
+
>) &
|
|
783
|
+
MutationHelpers<Url, Result> &
|
|
784
|
+
ClientEndpointHelper<Method, Url, undefined, Response, undefined>
|
|
785
|
+
|
|
786
|
+
mutationFromEndpoint<
|
|
787
|
+
Method extends 'DELETE' = 'DELETE',
|
|
788
|
+
Url extends string = string,
|
|
789
|
+
QuerySchema extends AnyZodObject = AnyZodObject,
|
|
790
|
+
Response extends ZodType = ZodType,
|
|
791
|
+
ReqResult = z.output<Response>,
|
|
792
|
+
Result = unknown,
|
|
793
|
+
Context = unknown,
|
|
794
|
+
>(
|
|
795
|
+
endpoint: any & {
|
|
796
|
+
config: BaseEndpointConfig<Method, Url, QuerySchema, Response>
|
|
797
|
+
},
|
|
798
|
+
mutationOptions: {
|
|
799
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
800
|
+
useContext?: () => Context
|
|
801
|
+
onSuccess?: (
|
|
802
|
+
queryClient: QueryClient,
|
|
803
|
+
data: NoInfer<Result>,
|
|
804
|
+
variables: Util_FlatObject<
|
|
805
|
+
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
806
|
+
>,
|
|
807
|
+
context: Context,
|
|
808
|
+
) => void | Promise<void>
|
|
809
|
+
onError?: (
|
|
810
|
+
queryClient: QueryClient,
|
|
811
|
+
error: Error,
|
|
812
|
+
variables: Util_FlatObject<
|
|
813
|
+
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
814
|
+
>,
|
|
815
|
+
context: Context,
|
|
816
|
+
) => void | Promise<void>
|
|
817
|
+
},
|
|
818
|
+
): (() => UseMutationResult<
|
|
819
|
+
Result,
|
|
820
|
+
Error,
|
|
821
|
+
ClientMutationArgs<Url, undefined, QuerySchema>
|
|
822
|
+
>) &
|
|
823
|
+
ClientEndpointHelper<Method, Url, undefined, Response, QuerySchema>
|
|
824
|
+
|
|
825
|
+
mutationFromEndpoint<
|
|
826
|
+
Method extends 'DELETE' = 'DELETE',
|
|
827
|
+
Url extends string = string,
|
|
828
|
+
Response extends ZodType = ZodType,
|
|
829
|
+
ReqResult = z.output<Response>,
|
|
830
|
+
Result = unknown,
|
|
831
|
+
Context = unknown,
|
|
832
|
+
>(
|
|
833
|
+
endpoint: any & {
|
|
834
|
+
config: BaseEndpointConfig<Method, Url, undefined, Response>
|
|
835
|
+
},
|
|
836
|
+
mutationOptions: {
|
|
837
|
+
processResponse: ProcessResponseFunction<Result, ReqResult>
|
|
838
|
+
useContext?: () => Context
|
|
839
|
+
onSuccess?: (
|
|
840
|
+
queryClient: QueryClient,
|
|
841
|
+
data: NoInfer<Result>,
|
|
842
|
+
variables: Util_FlatObject<
|
|
843
|
+
ClientMutationArgs<Url, undefined, undefined>
|
|
844
|
+
>,
|
|
845
|
+
context: Context,
|
|
846
|
+
) => void | Promise<void>
|
|
847
|
+
onError?: (
|
|
848
|
+
queryClient: QueryClient,
|
|
849
|
+
error: Error,
|
|
850
|
+
variables: Util_FlatObject<
|
|
851
|
+
ClientMutationArgs<Url, undefined, undefined>
|
|
852
|
+
>,
|
|
853
|
+
context: Context,
|
|
854
|
+
) => void | Promise<void>
|
|
855
|
+
},
|
|
856
|
+
): ((
|
|
857
|
+
params: UrlHasParams<Url> extends true ? UrlParams<Url> : {},
|
|
858
|
+
) => UseMutationResult<
|
|
859
|
+
Result,
|
|
860
|
+
Error,
|
|
861
|
+
ClientMutationArgs<Url, undefined, undefined>
|
|
862
|
+
>) &
|
|
863
|
+
ClientEndpointHelper<Method, Url, undefined, Response, undefined>
|
|
514
864
|
}
|