@openapi-qraft/react 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/ServiceOperation.d.ts +114 -46
- package/dist/ServiceOperation.d.ts.map +1 -1
- package/dist/callbacks/getInfiniteQueryState.d.ts +5 -0
- package/dist/callbacks/getInfiniteQueryState.d.ts.map +1 -0
- package/dist/callbacks/getInfiniteQueryState.js +5 -0
- package/dist/callbacks/getInfiniteQueryState.js.map +1 -0
- package/dist/callbacks/getQueriesData.d.ts +5 -0
- package/dist/callbacks/getQueriesData.d.ts.map +1 -0
- package/dist/callbacks/getQueriesData.js +5 -0
- package/dist/callbacks/getQueriesData.js.map +1 -0
- package/dist/callbacks/getQueryState.d.ts +5 -0
- package/dist/callbacks/getQueryState.d.ts.map +1 -0
- package/dist/callbacks/getQueryState.js +5 -0
- package/dist/callbacks/getQueryState.js.map +1 -0
- package/dist/callbacks/setQueriesData.d.ts +5 -0
- package/dist/callbacks/setQueriesData.d.ts.map +1 -0
- package/dist/callbacks/setQueriesData.js +5 -0
- package/dist/callbacks/setQueriesData.js.map +1 -0
- package/dist/callbacks/useIsFetching.js.map +1 -1
- package/dist/lib/callQueryClientMethodWithMutationFilters.js +1 -1
- package/dist/lib/callQueryClientMethodWithMutationFilters.js.map +1 -1
- package/dist/lib/callQueryClientMethodWithQueryFilters.js +1 -1
- package/dist/lib/callQueryClientMethodWithQueryFilters.js.map +1 -1
- package/dist/lib/callQueryClientMethodWithQueryKey.js +1 -1
- package/dist/lib/callQueryClientMethodWithQueryKey.js.map +1 -1
- package/dist/lib/composeBaseQueryKey.d.ts +6 -0
- package/dist/lib/composeBaseQueryKey.d.ts.map +1 -0
- package/dist/lib/composeBaseQueryKey.js +7 -0
- package/dist/lib/composeBaseQueryKey.js.map +1 -0
- package/dist/lib/composeInfiniteQueryKey.d.ts.map +1 -1
- package/dist/lib/composeInfiniteQueryKey.js +2 -1
- package/dist/lib/composeInfiniteQueryKey.js.map +1 -1
- package/dist/lib/composeQueryFilters.d.ts +5 -2
- package/dist/lib/composeQueryFilters.d.ts.map +1 -1
- package/dist/lib/composeQueryFilters.js +17 -11
- package/dist/lib/composeQueryFilters.js.map +1 -1
- package/dist/lib/composeQueryKey.d.ts.map +1 -1
- package/dist/lib/composeQueryKey.js +2 -1
- package/dist/lib/composeQueryKey.js.map +1 -1
- package/package.json +3 -3
- package/src/ServiceOperation.ts +267 -104
- package/src/callbacks/getInfiniteQueryState.ts +23 -0
- package/src/callbacks/getQueriesData.ts +18 -0
- package/src/callbacks/getQueryState.ts +19 -0
- package/src/callbacks/setQueriesData.ts +22 -0
- package/src/callbacks/useIsFetching.ts +1 -1
- package/src/lib/callQueryClientMethodWithMutationFilters.ts +1 -1
- package/src/lib/callQueryClientMethodWithQueryFilters.ts +1 -1
- package/src/lib/callQueryClientMethodWithQueryKey.ts +1 -1
- package/src/lib/composeBaseQueryKey.ts +34 -0
- package/src/lib/composeInfiniteQueryKey.ts +2 -1
- package/src/lib/composeQueryFilters.ts +24 -16
- package/src/lib/composeQueryKey.ts +2 -1
package/src/ServiceOperation.ts
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
QueryFunction,
|
|
21
21
|
InitialPageParam,
|
|
22
22
|
GetNextPageParamFunction,
|
|
23
|
+
QueryState,
|
|
23
24
|
} from '@tanstack/query-core';
|
|
24
25
|
import type {
|
|
25
26
|
DefinedInitialDataInfiniteOptions,
|
|
@@ -41,15 +42,21 @@ import type {
|
|
|
41
42
|
|
|
42
43
|
import type { RequestFn } from './lib/requestFn.js';
|
|
43
44
|
|
|
45
|
+
type ServiceOperationBaseQueryKey<
|
|
46
|
+
S extends { url: string; method: string },
|
|
47
|
+
Infinite extends boolean,
|
|
48
|
+
T,
|
|
49
|
+
> = [S & { infinite: Infinite }, T];
|
|
50
|
+
|
|
44
51
|
export type ServiceOperationQueryKey<
|
|
45
52
|
S extends { url: string; method: string },
|
|
46
53
|
T,
|
|
47
|
-
> =
|
|
54
|
+
> = ServiceOperationBaseQueryKey<S, false, T>;
|
|
48
55
|
|
|
49
56
|
export type ServiceOperationInfiniteQueryKey<
|
|
50
57
|
S extends { url: string; method: string },
|
|
51
58
|
T,
|
|
52
|
-
> =
|
|
59
|
+
> = ServiceOperationBaseQueryKey<S, true, T>;
|
|
53
60
|
|
|
54
61
|
export type ServiceOperationMutationKey<
|
|
55
62
|
S extends Record<'url' | 'method', string>,
|
|
@@ -72,8 +79,11 @@ export interface ServiceOperationQuery<
|
|
|
72
79
|
ServiceOperationFetchQuery<TSchema, TData, TParams, TError>,
|
|
73
80
|
ServiceOperationFetchInfiniteQuery<TSchema, TData, TParams, TError>,
|
|
74
81
|
ServiceOperationGetQueryData<TSchema, TData, TParams>,
|
|
82
|
+
ServiceOperationGetQueryState<TSchema, TData, TParams, TError>,
|
|
83
|
+
ServiceOperationGetQueriesData<TSchema, TData, TParams, TError>,
|
|
75
84
|
ServiceOperationGetInfiniteQueryData<TSchema, TData, TParams>,
|
|
76
85
|
ServiceOperationSetQueryData<TSchema, TData, TParams>,
|
|
86
|
+
ServiceOperationSetQueriesData<TSchema, TData, TParams, TError>,
|
|
77
87
|
ServiceOperationSetInfiniteQueryData<TSchema, TData, TParams>,
|
|
78
88
|
ServiceOperationInvalidateQueries<TSchema, TData, TParams, TError>,
|
|
79
89
|
ServiceOperationCancelQueries<TSchema, TData, TParams, TError>,
|
|
@@ -390,9 +400,18 @@ type QueryTypeFilter = 'all' | 'active' | 'inactive';
|
|
|
390
400
|
interface QueryFiltersBase<
|
|
391
401
|
TSchema extends { url: string; method: string },
|
|
392
402
|
TData,
|
|
403
|
+
TInfinite extends boolean,
|
|
393
404
|
TParams = {},
|
|
394
405
|
TError = DefaultError,
|
|
395
406
|
> {
|
|
407
|
+
/**
|
|
408
|
+
* Include queries matching this predicate function
|
|
409
|
+
*/
|
|
410
|
+
predicate?: TInfinite extends true
|
|
411
|
+
? QueryFilterInfinitePredicate<TSchema, TData, TParams, TError>
|
|
412
|
+
: TInfinite extends false
|
|
413
|
+
? QueryFilterRegularPredicate<TSchema, TData, TParams, TError>
|
|
414
|
+
: (query: string) => boolean;
|
|
396
415
|
/**
|
|
397
416
|
* Filter to active queries, inactive queries or all queries
|
|
398
417
|
*/
|
|
@@ -401,18 +420,6 @@ interface QueryFiltersBase<
|
|
|
401
420
|
* Match query key exactly
|
|
402
421
|
*/
|
|
403
422
|
exact?: boolean;
|
|
404
|
-
/**
|
|
405
|
-
* Include queries matching this predicate function
|
|
406
|
-
*/
|
|
407
|
-
predicate?: (
|
|
408
|
-
query: Query<
|
|
409
|
-
TData,
|
|
410
|
-
TError,
|
|
411
|
-
TData,
|
|
412
|
-
| ServiceOperationQueryKey<TSchema, TParams>
|
|
413
|
-
| ServiceOperationInfiniteQueryKey<TSchema, TParams>
|
|
414
|
-
>
|
|
415
|
-
) => boolean;
|
|
416
423
|
/**
|
|
417
424
|
* Include or exclude stale queries
|
|
418
425
|
*/
|
|
@@ -426,35 +433,86 @@ interface QueryFiltersBase<
|
|
|
426
433
|
interface QueryFiltersByQueryKey<
|
|
427
434
|
TSchema extends { url: string; method: string },
|
|
428
435
|
TData,
|
|
436
|
+
TInfinite extends boolean,
|
|
429
437
|
TParams = {},
|
|
430
438
|
TError = DefaultError,
|
|
431
|
-
> extends QueryFiltersBase<TSchema, TData, TParams, TError> {
|
|
439
|
+
> extends QueryFiltersBase<TSchema, TData, TInfinite, TParams, TError> {
|
|
432
440
|
/**
|
|
433
441
|
* Include queries matching this query key
|
|
434
442
|
*/
|
|
435
|
-
queryKey?:
|
|
443
|
+
queryKey?: ServiceOperationBaseQueryKey<TSchema, TInfinite, TParams>;
|
|
444
|
+
|
|
445
|
+
infinite?: never;
|
|
446
|
+
parameters?: never;
|
|
436
447
|
}
|
|
437
448
|
|
|
438
449
|
interface QueryFiltersByParameters<
|
|
439
450
|
TSchema extends { url: string; method: string },
|
|
440
451
|
TData,
|
|
452
|
+
TInfinite extends boolean,
|
|
441
453
|
TParams = {},
|
|
442
454
|
TError = DefaultError,
|
|
443
|
-
> extends QueryFiltersBase<TSchema, TData, TParams, TError> {
|
|
455
|
+
> extends QueryFiltersBase<TSchema, TData, TInfinite, TParams, TError> {
|
|
456
|
+
/**
|
|
457
|
+
* Is the query infinite
|
|
458
|
+
*/
|
|
459
|
+
infinite?: TInfinite;
|
|
460
|
+
|
|
444
461
|
/**
|
|
445
462
|
* Include queries matching parameters
|
|
446
463
|
*/
|
|
447
464
|
parameters?: TParams;
|
|
465
|
+
|
|
466
|
+
queryKey?: never;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
interface QueryFilterInfinitePredicate<
|
|
470
|
+
TSchema extends { url: string; method: string },
|
|
471
|
+
TData,
|
|
472
|
+
TParams = {},
|
|
473
|
+
TError = DefaultError,
|
|
474
|
+
> {
|
|
475
|
+
/**
|
|
476
|
+
* Include queries matching this predicate function
|
|
477
|
+
*/
|
|
478
|
+
(
|
|
479
|
+
query: Query<
|
|
480
|
+
InfiniteData<TData, TParams>,
|
|
481
|
+
TError,
|
|
482
|
+
InfiniteData<TData, TParams>,
|
|
483
|
+
ServiceOperationInfiniteQueryKey<TSchema, TParams>
|
|
484
|
+
>
|
|
485
|
+
): boolean;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
interface QueryFilterRegularPredicate<
|
|
489
|
+
TSchema extends { url: string; method: string },
|
|
490
|
+
TData,
|
|
491
|
+
TParams = {},
|
|
492
|
+
TError = DefaultError,
|
|
493
|
+
> {
|
|
494
|
+
/**
|
|
495
|
+
* Include queries matching this predicate function
|
|
496
|
+
*/
|
|
497
|
+
(
|
|
498
|
+
query: Query<
|
|
499
|
+
TData,
|
|
500
|
+
TError,
|
|
501
|
+
TData,
|
|
502
|
+
ServiceOperationQueryKey<TSchema, TParams>
|
|
503
|
+
>
|
|
504
|
+
): boolean;
|
|
448
505
|
}
|
|
449
506
|
|
|
450
507
|
type InvalidateQueryFilters<
|
|
451
508
|
TSchema extends { url: string; method: string },
|
|
452
509
|
TData,
|
|
510
|
+
TInfinite extends boolean,
|
|
453
511
|
TParams = {},
|
|
454
512
|
TError = DefaultError,
|
|
455
513
|
> = (
|
|
456
|
-
| QueryFiltersByParameters<TSchema, TData, TParams, TError>
|
|
457
|
-
| QueryFiltersByQueryKey<TSchema, TData, TParams, TError>
|
|
514
|
+
| QueryFiltersByParameters<TSchema, TData, TInfinite, TParams, TError>
|
|
515
|
+
| QueryFiltersByQueryKey<TSchema, TData, TInfinite, TParams, TError>
|
|
458
516
|
) & {
|
|
459
517
|
refetchType?: QueryTypeFilter | 'none';
|
|
460
518
|
};
|
|
@@ -465,13 +523,13 @@ interface ServiceOperationInvalidateQueries<
|
|
|
465
523
|
TParams = {},
|
|
466
524
|
TError = DefaultError,
|
|
467
525
|
> {
|
|
468
|
-
invalidateQueries(
|
|
469
|
-
filters: InvalidateQueryFilters<TSchema, TData, TParams, TError>,
|
|
526
|
+
invalidateQueries<TInfinite extends boolean>(
|
|
527
|
+
filters: InvalidateQueryFilters<TSchema, TData, TInfinite, TParams, TError>,
|
|
470
528
|
options: InvalidateOptions,
|
|
471
529
|
queryClient: QueryClient
|
|
472
530
|
): Promise<void>;
|
|
473
|
-
invalidateQueries(
|
|
474
|
-
filters: InvalidateQueryFilters<TSchema, TData, TParams, TError>,
|
|
531
|
+
invalidateQueries<TInfinite extends boolean>(
|
|
532
|
+
filters: InvalidateQueryFilters<TSchema, TData, TInfinite, TParams, TError>,
|
|
475
533
|
queryClient: QueryClient
|
|
476
534
|
): Promise<void>;
|
|
477
535
|
invalidateQueries(queryClient: QueryClient): Promise<void>;
|
|
@@ -486,10 +544,9 @@ export interface ServiceOperationInvalidateQueriesCallback<
|
|
|
486
544
|
TParams = {},
|
|
487
545
|
TError = DefaultError,
|
|
488
546
|
> extends ServiceOperationInvalidateQueries<TSchema, TData, TParams, TError> {
|
|
489
|
-
invalidateQueries(
|
|
547
|
+
invalidateQueries<TInfinite extends boolean>(
|
|
490
548
|
filters:
|
|
491
|
-
|
|
|
492
|
-
| QueryFiltersByQueryKey<TSchema, TData, TParams, TError>
|
|
549
|
+
| InvalidateQueryFilters<TSchema, TData, TInfinite, TParams, TError>
|
|
493
550
|
| QueryClient,
|
|
494
551
|
options?: InvalidateOptions | QueryClient,
|
|
495
552
|
queryClient?: QueryClient
|
|
@@ -502,17 +559,17 @@ interface ServiceOperationCancelQueries<
|
|
|
502
559
|
TParams = {},
|
|
503
560
|
TError = DefaultError,
|
|
504
561
|
> {
|
|
505
|
-
cancelQueries(
|
|
562
|
+
cancelQueries<TInfinite extends boolean>(
|
|
506
563
|
filters:
|
|
507
|
-
| QueryFiltersByParameters<TSchema, TData, TParams, TError>
|
|
508
|
-
| QueryFiltersByQueryKey<TSchema, TData, TParams, TError>,
|
|
564
|
+
| QueryFiltersByParameters<TSchema, TData, TInfinite, TParams, TError>
|
|
565
|
+
| QueryFiltersByQueryKey<TSchema, TData, TInfinite, TParams, TError>,
|
|
509
566
|
options: CancelOptions,
|
|
510
567
|
queryClient: QueryClient
|
|
511
568
|
): Promise<void>;
|
|
512
|
-
cancelQueries(
|
|
569
|
+
cancelQueries<TInfinite extends boolean>(
|
|
513
570
|
filters:
|
|
514
|
-
| QueryFiltersByParameters<TSchema, TData, TParams, TError>
|
|
515
|
-
| QueryFiltersByQueryKey<TSchema, TData, TParams, TError>,
|
|
571
|
+
| QueryFiltersByParameters<TSchema, TData, TInfinite, TParams, TError>
|
|
572
|
+
| QueryFiltersByQueryKey<TSchema, TData, TInfinite, TParams, TError>,
|
|
516
573
|
queryClient: QueryClient
|
|
517
574
|
): Promise<void>;
|
|
518
575
|
cancelQueries(queryClient: QueryClient): Promise<void>;
|
|
@@ -527,10 +584,10 @@ export interface ServiceOperationCancelQueriesCallback<
|
|
|
527
584
|
TParams = {},
|
|
528
585
|
TError = DefaultError,
|
|
529
586
|
> extends ServiceOperationCancelQueries<TSchema, TData, TParams, TError> {
|
|
530
|
-
cancelQueries(
|
|
587
|
+
cancelQueries<TInfinite extends boolean>(
|
|
531
588
|
filters:
|
|
532
|
-
| QueryFiltersByParameters<TSchema, TData, TParams, TError>
|
|
533
|
-
| QueryFiltersByQueryKey<TSchema, TData, TParams, TError>
|
|
589
|
+
| QueryFiltersByParameters<TSchema, TData, TInfinite, TParams, TError>
|
|
590
|
+
| QueryFiltersByQueryKey<TSchema, TData, TInfinite, TParams, TError>
|
|
534
591
|
| QueryClient,
|
|
535
592
|
options?: CancelOptions | QueryClient,
|
|
536
593
|
queryClient?: QueryClient
|
|
@@ -543,10 +600,10 @@ interface ServiceOperationRemoveQueries<
|
|
|
543
600
|
TParams = {},
|
|
544
601
|
TError = DefaultError,
|
|
545
602
|
> {
|
|
546
|
-
removeQueries(
|
|
603
|
+
removeQueries<TInfinite extends boolean>(
|
|
547
604
|
filters:
|
|
548
|
-
| QueryFiltersByParameters<TSchema, TData, TParams, TError>
|
|
549
|
-
| QueryFiltersByQueryKey<TSchema, TData, TParams, TError>,
|
|
605
|
+
| QueryFiltersByParameters<TSchema, TData, TInfinite, TParams, TError>
|
|
606
|
+
| QueryFiltersByQueryKey<TSchema, TData, TInfinite, TParams, TError>,
|
|
550
607
|
queryClient: QueryClient
|
|
551
608
|
): void;
|
|
552
609
|
removeQueries(queryClient: QueryClient): void;
|
|
@@ -561,10 +618,10 @@ export interface ServiceOperationRemoveQueriesCallback<
|
|
|
561
618
|
TParams = {},
|
|
562
619
|
TError = DefaultError,
|
|
563
620
|
> extends ServiceOperationRemoveQueries<TSchema, TData, TParams, TError> {
|
|
564
|
-
removeQueries(
|
|
621
|
+
removeQueries<TInfinite extends boolean>(
|
|
565
622
|
filters:
|
|
566
|
-
| QueryFiltersByParameters<TSchema, TData, TParams, TError>
|
|
567
|
-
| QueryFiltersByQueryKey<TSchema, TData, TParams, TError>
|
|
623
|
+
| QueryFiltersByParameters<TSchema, TData, TInfinite, TParams, TError>
|
|
624
|
+
| QueryFiltersByQueryKey<TSchema, TData, TInfinite, TParams, TError>
|
|
568
625
|
| QueryClient,
|
|
569
626
|
queryClient?: QueryClient
|
|
570
627
|
): void;
|
|
@@ -576,17 +633,17 @@ interface ServiceOperationResetQueries<
|
|
|
576
633
|
TParams = {},
|
|
577
634
|
TError = DefaultError,
|
|
578
635
|
> {
|
|
579
|
-
resetQueries(
|
|
636
|
+
resetQueries<TInfinite extends boolean>(
|
|
580
637
|
filters:
|
|
581
|
-
| QueryFiltersByParameters<TSchema, TData, TParams, TError>
|
|
582
|
-
| QueryFiltersByQueryKey<TSchema, TData, TParams, TError>,
|
|
638
|
+
| QueryFiltersByParameters<TSchema, TData, TInfinite, TParams, TError>
|
|
639
|
+
| QueryFiltersByQueryKey<TSchema, TData, TInfinite, TParams, TError>,
|
|
583
640
|
options: ResetOptions,
|
|
584
641
|
queryClient: QueryClient
|
|
585
642
|
): Promise<void>;
|
|
586
|
-
resetQueries(
|
|
643
|
+
resetQueries<TInfinite extends boolean>(
|
|
587
644
|
filters:
|
|
588
|
-
| QueryFiltersByParameters<TSchema, TData, TParams, TError>
|
|
589
|
-
| QueryFiltersByQueryKey<TSchema, TData, TParams, TError>,
|
|
645
|
+
| QueryFiltersByParameters<TSchema, TData, TInfinite, TParams, TError>
|
|
646
|
+
| QueryFiltersByQueryKey<TSchema, TData, TInfinite, TParams, TError>,
|
|
590
647
|
queryClient: QueryClient
|
|
591
648
|
): Promise<void>;
|
|
592
649
|
resetQueries(queryClient: QueryClient): Promise<void>;
|
|
@@ -601,10 +658,10 @@ export interface ServiceOperationResetQueriesCallback<
|
|
|
601
658
|
TParams = {},
|
|
602
659
|
TError = DefaultError,
|
|
603
660
|
> extends ServiceOperationResetQueries<TSchema, TData, TParams, TError> {
|
|
604
|
-
resetQueries(
|
|
661
|
+
resetQueries<TInfinite extends boolean>(
|
|
605
662
|
filters:
|
|
606
|
-
| QueryFiltersByParameters<TSchema, TData, TParams, TError>
|
|
607
|
-
| QueryFiltersByQueryKey<TSchema, TData, TParams, TError>
|
|
663
|
+
| QueryFiltersByParameters<TSchema, TData, TInfinite, TParams, TError>
|
|
664
|
+
| QueryFiltersByQueryKey<TSchema, TData, TInfinite, TParams, TError>
|
|
608
665
|
| QueryClient,
|
|
609
666
|
options?: ResetOptions | QueryClient,
|
|
610
667
|
queryClient?: QueryClient
|
|
@@ -617,17 +674,17 @@ interface ServiceOperationRefetchQueries<
|
|
|
617
674
|
TParams = {},
|
|
618
675
|
TError = DefaultError,
|
|
619
676
|
> {
|
|
620
|
-
refetchQueries(
|
|
677
|
+
refetchQueries<TInfinite extends boolean>(
|
|
621
678
|
filters:
|
|
622
|
-
| QueryFiltersByParameters<TSchema, TData, TParams, TError>
|
|
623
|
-
| QueryFiltersByQueryKey<TSchema, TData, TParams, TError>,
|
|
679
|
+
| QueryFiltersByParameters<TSchema, TData, TInfinite, TParams, TError>
|
|
680
|
+
| QueryFiltersByQueryKey<TSchema, TData, TInfinite, TParams, TError>,
|
|
624
681
|
options: RefetchOptions,
|
|
625
682
|
queryClient: QueryClient
|
|
626
683
|
): Promise<void>;
|
|
627
|
-
refetchQueries(
|
|
684
|
+
refetchQueries<TInfinite extends boolean>(
|
|
628
685
|
filters:
|
|
629
|
-
| QueryFiltersByParameters<TSchema, TData, TParams, TError>
|
|
630
|
-
| QueryFiltersByQueryKey<TSchema, TData, TParams, TError>,
|
|
686
|
+
| QueryFiltersByParameters<TSchema, TData, TInfinite, TParams, TError>
|
|
687
|
+
| QueryFiltersByQueryKey<TSchema, TData, TInfinite, TParams, TError>,
|
|
631
688
|
queryClient: QueryClient
|
|
632
689
|
): Promise<void>;
|
|
633
690
|
refetchQueries(queryClient: QueryClient): Promise<void>;
|
|
@@ -642,10 +699,10 @@ export interface ServiceOperationResetQueriesCallback<
|
|
|
642
699
|
TParams = {},
|
|
643
700
|
TError = DefaultError,
|
|
644
701
|
> extends ServiceOperationRefetchQueries<TSchema, TData, TParams, TError> {
|
|
645
|
-
refetchQueries(
|
|
702
|
+
refetchQueries<TInfinite extends boolean>(
|
|
646
703
|
filters:
|
|
647
|
-
| QueryFiltersByParameters<TSchema, TData, TParams, TError>
|
|
648
|
-
| QueryFiltersByQueryKey<TSchema, TData, TParams, TError>
|
|
704
|
+
| QueryFiltersByParameters<TSchema, TData, TInfinite, TParams, TError>
|
|
705
|
+
| QueryFiltersByQueryKey<TSchema, TData, TInfinite, TParams, TError>
|
|
649
706
|
| QueryClient,
|
|
650
707
|
options?: RefetchOptions | QueryClient,
|
|
651
708
|
queryClient?: QueryClient
|
|
@@ -658,10 +715,10 @@ interface ServiceOperationIsFetchingQueries<
|
|
|
658
715
|
TParams = {},
|
|
659
716
|
TError = DefaultError,
|
|
660
717
|
> {
|
|
661
|
-
isFetching(
|
|
718
|
+
isFetching<TInfinite extends boolean>(
|
|
662
719
|
filters:
|
|
663
|
-
| QueryFiltersByParameters<TSchema, TData, TParams, TError>
|
|
664
|
-
| QueryFiltersByQueryKey<TSchema, TData, TParams, TError>,
|
|
720
|
+
| QueryFiltersByParameters<TSchema, TData, TInfinite, TParams, TError>
|
|
721
|
+
| QueryFiltersByQueryKey<TSchema, TData, TInfinite, TParams, TError>,
|
|
665
722
|
queryClient: QueryClient
|
|
666
723
|
): number;
|
|
667
724
|
isFetching(queryClient: QueryClient): number;
|
|
@@ -676,10 +733,10 @@ export interface ServiceOperationIsFetchingQueriesCallback<
|
|
|
676
733
|
TParams = {},
|
|
677
734
|
TError = DefaultError,
|
|
678
735
|
> extends ServiceOperationIsFetchingQueries<TSchema, TData, TParams, TError> {
|
|
679
|
-
refetchQueries(
|
|
736
|
+
refetchQueries<TInfinite extends boolean>(
|
|
680
737
|
filters:
|
|
681
|
-
| QueryFiltersByParameters<TSchema, TData, TParams, TError>
|
|
682
|
-
| QueryFiltersByQueryKey<TSchema, TData, TParams, TError>
|
|
738
|
+
| QueryFiltersByParameters<TSchema, TData, TInfinite, TParams, TError>
|
|
739
|
+
| QueryFiltersByQueryKey<TSchema, TData, TInfinite, TParams, TError>
|
|
683
740
|
| QueryClient,
|
|
684
741
|
queryClient?: QueryClient
|
|
685
742
|
): number;
|
|
@@ -691,10 +748,10 @@ interface ServiceOperationUseIsFetchingQueries<
|
|
|
691
748
|
TParams = {},
|
|
692
749
|
TError = DefaultError,
|
|
693
750
|
> {
|
|
694
|
-
useIsFetching(
|
|
751
|
+
useIsFetching<TInfinite extends boolean>(
|
|
695
752
|
filters?:
|
|
696
|
-
| QueryFiltersByParameters<TSchema, TData, TParams, TError>
|
|
697
|
-
| QueryFiltersByQueryKey<TSchema, TData, TParams, TError>,
|
|
753
|
+
| QueryFiltersByParameters<TSchema, TData, TInfinite, TParams, TError>
|
|
754
|
+
| QueryFiltersByQueryKey<TSchema, TData, TInfinite, TParams, TError>,
|
|
698
755
|
queryClient?: QueryClient
|
|
699
756
|
): number;
|
|
700
757
|
}
|
|
@@ -748,7 +805,7 @@ interface ServiceOperationUseInfiniteQuery<
|
|
|
748
805
|
UndefinedInitialDataInfiniteOptions<
|
|
749
806
|
TData,
|
|
750
807
|
TError,
|
|
751
|
-
InfiniteData<TData>,
|
|
808
|
+
InfiniteData<TData, TParams>,
|
|
752
809
|
ServiceOperationInfiniteQueryKey<TSchema, TParams>,
|
|
753
810
|
PartialParameters<TPageParam>
|
|
754
811
|
>,
|
|
@@ -759,14 +816,14 @@ interface ServiceOperationUseInfiniteQuery<
|
|
|
759
816
|
> &
|
|
760
817
|
InfiniteQueryPageParamsOptions<TData, PartialParameters<TPageParam>>,
|
|
761
818
|
queryClient?: QueryClient
|
|
762
|
-
): UseInfiniteQueryResult<InfiniteData<TData>, TError | Error>;
|
|
819
|
+
): UseInfiniteQueryResult<InfiniteData<TData, TParams>, TError | Error>;
|
|
763
820
|
useInfiniteQuery<TPageParam extends TParams>(
|
|
764
821
|
parameters: TParams | ServiceOperationInfiniteQueryKey<TSchema, TParams>,
|
|
765
822
|
options: Omit<
|
|
766
823
|
DefinedInitialDataInfiniteOptions<
|
|
767
824
|
TData,
|
|
768
825
|
TError,
|
|
769
|
-
InfiniteData<TData>,
|
|
826
|
+
InfiniteData<TData, TParams>,
|
|
770
827
|
ServiceOperationInfiniteQueryKey<TSchema, TParams>,
|
|
771
828
|
PartialParameters<TPageParam>
|
|
772
829
|
>,
|
|
@@ -777,7 +834,10 @@ interface ServiceOperationUseInfiniteQuery<
|
|
|
777
834
|
> &
|
|
778
835
|
InfiniteQueryPageParamsOptions<TData, PartialParameters<TPageParam>>,
|
|
779
836
|
queryClient?: QueryClient
|
|
780
|
-
): DefinedUseInfiniteQueryResult<
|
|
837
|
+
): DefinedUseInfiniteQueryResult<
|
|
838
|
+
InfiniteData<TData, TParams>,
|
|
839
|
+
TError | Error
|
|
840
|
+
>;
|
|
781
841
|
}
|
|
782
842
|
|
|
783
843
|
interface ServiceOperationUseSuspenseInfiniteQuery<
|
|
@@ -792,7 +852,7 @@ interface ServiceOperationUseSuspenseInfiniteQuery<
|
|
|
792
852
|
UseSuspenseInfiniteQueryOptions<
|
|
793
853
|
TData,
|
|
794
854
|
TError,
|
|
795
|
-
InfiniteData<TData>,
|
|
855
|
+
InfiniteData<TData, TParams>,
|
|
796
856
|
TData,
|
|
797
857
|
ServiceOperationInfiniteQueryKey<TSchema, TParams>,
|
|
798
858
|
PartialParameters<TPageParam>
|
|
@@ -804,7 +864,10 @@ interface ServiceOperationUseSuspenseInfiniteQuery<
|
|
|
804
864
|
> &
|
|
805
865
|
InfiniteQueryPageParamsOptions<TData, PartialParameters<TPageParam>>,
|
|
806
866
|
queryClient?: QueryClient
|
|
807
|
-
): UseSuspenseInfiniteQueryResult<
|
|
867
|
+
): UseSuspenseInfiniteQueryResult<
|
|
868
|
+
InfiniteData<TData, TParams>,
|
|
869
|
+
TError | Error
|
|
870
|
+
>;
|
|
808
871
|
}
|
|
809
872
|
|
|
810
873
|
interface ServiceOperationUseSuspenseQueryQuery<
|
|
@@ -837,7 +900,7 @@ export interface ServiceOperationMutation<
|
|
|
837
900
|
> extends ServiceOperationUseMutation<TSchema, TBody, TData, TParams, TError>,
|
|
838
901
|
ServiceOperationUseIsMutating<TSchema, TBody, TData, TParams, TError>,
|
|
839
902
|
ServiceOperationUseMutationState<TSchema, TBody, TData, TParams, TError>,
|
|
840
|
-
ServiceOperationIsMutatingQueries<TSchema, TData, TParams, TError>,
|
|
903
|
+
ServiceOperationIsMutatingQueries<TSchema, TBody, TData, TParams, TError>,
|
|
841
904
|
ServiceOperationMutationFn<TSchema, TBody, TData, TParams> {
|
|
842
905
|
schema: TSchema;
|
|
843
906
|
types: {
|
|
@@ -912,7 +975,7 @@ interface UseMutationStateFiltersBase<
|
|
|
912
975
|
status?: MutationStatus;
|
|
913
976
|
}
|
|
914
977
|
|
|
915
|
-
interface
|
|
978
|
+
interface MutationFiltersByParameters<
|
|
916
979
|
TBody,
|
|
917
980
|
TData,
|
|
918
981
|
TParams,
|
|
@@ -923,9 +986,10 @@ interface UseMutationStateFiltersByParameters<
|
|
|
923
986
|
* Include mutations matching these parameters
|
|
924
987
|
*/
|
|
925
988
|
parameters?: PartialParameters<TParams>;
|
|
989
|
+
mutationKey?: never;
|
|
926
990
|
}
|
|
927
991
|
|
|
928
|
-
interface
|
|
992
|
+
interface MutationFiltersByMutationKey<
|
|
929
993
|
TSchema extends { url: string; method: string },
|
|
930
994
|
TBody,
|
|
931
995
|
TData,
|
|
@@ -940,6 +1004,7 @@ interface UseMutationStateFiltersByMutationKey<
|
|
|
940
1004
|
TSchema,
|
|
941
1005
|
PartialParameters<TParams>
|
|
942
1006
|
>;
|
|
1007
|
+
parameters?: never;
|
|
943
1008
|
}
|
|
944
1009
|
|
|
945
1010
|
type MutationVariables<TBody, TParams> = {
|
|
@@ -964,14 +1029,8 @@ interface ServiceOperationUseMutationState<
|
|
|
964
1029
|
>(
|
|
965
1030
|
options?: {
|
|
966
1031
|
filters?:
|
|
967
|
-
|
|
|
968
|
-
|
|
969
|
-
TData,
|
|
970
|
-
TParams,
|
|
971
|
-
TError,
|
|
972
|
-
TContext
|
|
973
|
-
>
|
|
974
|
-
| UseMutationStateFiltersByMutationKey<
|
|
1032
|
+
| MutationFiltersByParameters<TBody, TData, TParams, TError, TContext>
|
|
1033
|
+
| MutationFiltersByMutationKey<
|
|
975
1034
|
TSchema,
|
|
976
1035
|
TBody,
|
|
977
1036
|
TData,
|
|
@@ -1001,14 +1060,8 @@ interface ServiceOperationUseIsMutating<
|
|
|
1001
1060
|
> {
|
|
1002
1061
|
useIsMutating<TContext = unknown>(
|
|
1003
1062
|
filters?:
|
|
1004
|
-
|
|
|
1005
|
-
|
|
1006
|
-
TData,
|
|
1007
|
-
TParams,
|
|
1008
|
-
TError,
|
|
1009
|
-
TContext
|
|
1010
|
-
>
|
|
1011
|
-
| UseMutationStateFiltersByMutationKey<
|
|
1063
|
+
| MutationFiltersByParameters<TBody, TData, TParams, TError, TContext>
|
|
1064
|
+
| MutationFiltersByMutationKey<
|
|
1012
1065
|
TSchema,
|
|
1013
1066
|
TBody,
|
|
1014
1067
|
TData,
|
|
@@ -1121,6 +1174,75 @@ export interface ServiceOperationSetQueryDataCallback<
|
|
|
1121
1174
|
): TData | undefined;
|
|
1122
1175
|
}
|
|
1123
1176
|
|
|
1177
|
+
interface ServiceOperationSetQueriesData<
|
|
1178
|
+
TSchema extends { url: string; method: string },
|
|
1179
|
+
TData,
|
|
1180
|
+
TParams = {}, // todo::try to replace `TParams = {}` with `TParams = undefined`
|
|
1181
|
+
TError = DefaultError,
|
|
1182
|
+
> {
|
|
1183
|
+
setQueriesData<TInfinite extends boolean>(
|
|
1184
|
+
filters:
|
|
1185
|
+
| QueryFiltersByParameters<TSchema, TData, TInfinite, TParams, TError>
|
|
1186
|
+
| QueryFiltersByQueryKey<TSchema, TData, TInfinite, TParams, TError>,
|
|
1187
|
+
updater: Updater<NoInfer<TData> | undefined, NoInfer<TData> | undefined>,
|
|
1188
|
+
options: SetDataOptions,
|
|
1189
|
+
queryClient: QueryClient
|
|
1190
|
+
): Array<TData | undefined>;
|
|
1191
|
+
|
|
1192
|
+
setQueriesData<TInfinite extends boolean>(
|
|
1193
|
+
filters:
|
|
1194
|
+
| QueryFiltersByParameters<TSchema, TData, TInfinite, TParams, TError>
|
|
1195
|
+
| QueryFiltersByQueryKey<TSchema, TData, TInfinite, TParams, TError>,
|
|
1196
|
+
updater: Updater<NoInfer<TData> | undefined, NoInfer<TData> | undefined>,
|
|
1197
|
+
queryClient: QueryClient
|
|
1198
|
+
): Array<TData | undefined>;
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
/**
|
|
1202
|
+
* @internal
|
|
1203
|
+
*/
|
|
1204
|
+
export interface ServiceOperationSetQueriesDataCallback<
|
|
1205
|
+
TSchema extends { url: string; method: string },
|
|
1206
|
+
TData,
|
|
1207
|
+
TParams = {},
|
|
1208
|
+
TError = DefaultError,
|
|
1209
|
+
> extends ServiceOperationSetQueriesData<TSchema, TData, TParams, TError> {
|
|
1210
|
+
setQueriesData<TInfinite extends boolean>(
|
|
1211
|
+
filters:
|
|
1212
|
+
| QueryFiltersByParameters<TSchema, TData, TInfinite, TParams, TError>
|
|
1213
|
+
| QueryFiltersByQueryKey<TSchema, TData, TInfinite, TParams, TError>,
|
|
1214
|
+
updater: Updater<NoInfer<TData> | undefined, NoInfer<TData> | undefined>,
|
|
1215
|
+
options: SetDataOptions | QueryClient,
|
|
1216
|
+
queryClient?: QueryClient
|
|
1217
|
+
): Array<TData | undefined>;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
interface ServiceOperationGetQueriesData<
|
|
1221
|
+
TSchema extends { url: string; method: string },
|
|
1222
|
+
TData,
|
|
1223
|
+
TParams = {}, // todo::try to replace `TParams = {}` with `TParams = undefined`
|
|
1224
|
+
TError = DefaultError,
|
|
1225
|
+
> {
|
|
1226
|
+
getQueriesData<TInfinite extends boolean>(
|
|
1227
|
+
filters:
|
|
1228
|
+
| QueryFiltersByParameters<TSchema, TData, TInfinite, TParams, TError>
|
|
1229
|
+
| QueryFiltersByQueryKey<TSchema, TData, TInfinite, TParams, TError>,
|
|
1230
|
+
queryClient: QueryClient
|
|
1231
|
+
): TInfinite extends true
|
|
1232
|
+
? Array<
|
|
1233
|
+
[
|
|
1234
|
+
queryKey: ServiceOperationInfiniteQueryKey<TSchema, TParams>,
|
|
1235
|
+
data: NoInfer<InfiniteData<TData, TParams>> | undefined,
|
|
1236
|
+
]
|
|
1237
|
+
>
|
|
1238
|
+
: Array<
|
|
1239
|
+
[
|
|
1240
|
+
queryKey: ServiceOperationQueryKey<TSchema, TParams>,
|
|
1241
|
+
data: TData | undefined,
|
|
1242
|
+
]
|
|
1243
|
+
>;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1124
1246
|
interface ServiceOperationSetInfiniteQueryData<
|
|
1125
1247
|
TSchema extends { url: string; method: string },
|
|
1126
1248
|
TData,
|
|
@@ -1129,12 +1251,12 @@ interface ServiceOperationSetInfiniteQueryData<
|
|
|
1129
1251
|
setInfiniteQueryData(
|
|
1130
1252
|
parameters: TParams | ServiceOperationInfiniteQueryKey<TSchema, TParams>,
|
|
1131
1253
|
updater: Updater<
|
|
1132
|
-
NoInfer<InfiniteData<TData>> | undefined,
|
|
1133
|
-
NoInfer<InfiniteData<TData>> | undefined
|
|
1254
|
+
NoInfer<InfiniteData<TData, TParams>> | undefined,
|
|
1255
|
+
NoInfer<InfiniteData<TData, TParams>> | undefined
|
|
1134
1256
|
>,
|
|
1135
1257
|
queryClient: QueryClient,
|
|
1136
1258
|
options?: SetDataOptions
|
|
1137
|
-
): InfiniteData<TData> | undefined;
|
|
1259
|
+
): InfiniteData<TData, TParams> | undefined;
|
|
1138
1260
|
}
|
|
1139
1261
|
|
|
1140
1262
|
interface ServiceOperationGetQueryData<
|
|
@@ -1156,7 +1278,26 @@ interface ServiceOperationGetInfiniteQueryData<
|
|
|
1156
1278
|
getInfiniteQueryData(
|
|
1157
1279
|
parameters: TParams | ServiceOperationInfiniteQueryKey<TSchema, TParams>,
|
|
1158
1280
|
queryClient: QueryClient
|
|
1159
|
-
): InfiniteData<TData> | undefined;
|
|
1281
|
+
): InfiniteData<TData, TParams> | undefined;
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
interface ServiceOperationGetQueryState<
|
|
1285
|
+
TSchema extends { url: string; method: string },
|
|
1286
|
+
TData,
|
|
1287
|
+
TParams = {},
|
|
1288
|
+
TError = DefaultError,
|
|
1289
|
+
> {
|
|
1290
|
+
getQueryState(
|
|
1291
|
+
parameters: TParams | ServiceOperationQueryKey<TSchema, TParams>,
|
|
1292
|
+
queryClient: QueryClient
|
|
1293
|
+
): QueryState<TData, TError> | undefined;
|
|
1294
|
+
|
|
1295
|
+
getInfiniteQueryState(
|
|
1296
|
+
parameters: TParams | ServiceOperationInfiniteQueryKey<TSchema, TParams>,
|
|
1297
|
+
queryClient: QueryClient
|
|
1298
|
+
):
|
|
1299
|
+
| QueryState<InfiniteData<TData, PartialParameters<TParams>>, TError>
|
|
1300
|
+
| undefined;
|
|
1160
1301
|
}
|
|
1161
1302
|
|
|
1162
1303
|
export interface ServiceOperationMutationFn<
|
|
@@ -1196,14 +1337,22 @@ export interface ServiceOperationMutationFn<
|
|
|
1196
1337
|
|
|
1197
1338
|
interface ServiceOperationIsMutatingQueries<
|
|
1198
1339
|
TSchema extends { url: string; method: string },
|
|
1340
|
+
TBody,
|
|
1199
1341
|
TData,
|
|
1200
1342
|
TParams = {},
|
|
1201
1343
|
TError = DefaultError,
|
|
1202
1344
|
> {
|
|
1203
|
-
isMutating(
|
|
1345
|
+
isMutating<TContext>(
|
|
1204
1346
|
filters:
|
|
1205
|
-
|
|
|
1206
|
-
|
|
|
1347
|
+
| MutationFiltersByParameters<TBody, TData, TParams, TError, TContext>
|
|
1348
|
+
| MutationFiltersByMutationKey<
|
|
1349
|
+
TSchema,
|
|
1350
|
+
TBody,
|
|
1351
|
+
TData,
|
|
1352
|
+
TParams,
|
|
1353
|
+
TError,
|
|
1354
|
+
TContext
|
|
1355
|
+
>,
|
|
1207
1356
|
queryClient: QueryClient
|
|
1208
1357
|
): number;
|
|
1209
1358
|
isMutating(queryClient: QueryClient): number;
|
|
@@ -1214,14 +1363,28 @@ interface ServiceOperationIsMutatingQueries<
|
|
|
1214
1363
|
*/
|
|
1215
1364
|
export interface ServiceOperationIsMutatingQueriesCallback<
|
|
1216
1365
|
TSchema extends { url: string; method: string },
|
|
1366
|
+
TBody,
|
|
1217
1367
|
TData,
|
|
1218
1368
|
TParams = {},
|
|
1219
1369
|
TError = DefaultError,
|
|
1220
|
-
> extends ServiceOperationIsMutatingQueries<
|
|
1221
|
-
|
|
1370
|
+
> extends ServiceOperationIsMutatingQueries<
|
|
1371
|
+
TSchema,
|
|
1372
|
+
TBody,
|
|
1373
|
+
TData,
|
|
1374
|
+
TParams,
|
|
1375
|
+
TError
|
|
1376
|
+
> {
|
|
1377
|
+
isMutating<TContext>(
|
|
1222
1378
|
filters:
|
|
1223
|
-
|
|
|
1224
|
-
|
|
|
1379
|
+
| MutationFiltersByParameters<TBody, TData, TParams, TError, TContext>
|
|
1380
|
+
| MutationFiltersByMutationKey<
|
|
1381
|
+
TSchema,
|
|
1382
|
+
TBody,
|
|
1383
|
+
TData,
|
|
1384
|
+
TParams,
|
|
1385
|
+
TError,
|
|
1386
|
+
TContext
|
|
1387
|
+
>
|
|
1225
1388
|
| QueryClient,
|
|
1226
1389
|
queryClient?: QueryClient
|
|
1227
1390
|
): number;
|