@tanstack/query-core 5.35.4 → 5.35.5
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/build/legacy/hydration.d.cts +1 -1
- package/build/legacy/hydration.d.ts +1 -1
- package/build/legacy/index.d.cts +1 -1
- package/build/legacy/index.d.ts +1 -1
- package/build/legacy/infiniteQueryBehavior.d.cts +1 -1
- package/build/legacy/infiniteQueryBehavior.d.ts +1 -1
- package/build/legacy/infiniteQueryObserver.d.cts +1 -1
- package/build/legacy/infiniteQueryObserver.d.ts +1 -1
- package/build/legacy/mutation.d.cts +1 -1
- package/build/legacy/mutation.d.ts +1 -1
- package/build/legacy/mutationCache.d.cts +1 -1
- package/build/legacy/mutationCache.d.ts +1 -1
- package/build/legacy/mutationObserver.d.cts +1 -1
- package/build/legacy/mutationObserver.d.ts +1 -1
- package/build/legacy/queriesObserver.d.cts +1 -1
- package/build/legacy/queriesObserver.d.ts +1 -1
- package/build/legacy/query.d.cts +1 -1
- package/build/legacy/query.d.ts +1 -1
- package/build/legacy/queryCache.d.cts +1 -1
- package/build/legacy/queryCache.d.ts +1 -1
- package/build/legacy/queryClient.d.cts +1 -1
- package/build/legacy/queryClient.d.ts +1 -1
- package/build/legacy/queryObserver.d.cts +1 -1
- package/build/legacy/queryObserver.d.ts +1 -1
- package/build/legacy/retryer.d.cts +1 -1
- package/build/legacy/retryer.d.ts +1 -1
- package/build/legacy/{types-4So4yn86.d.ts → types-Br-AgPmc.d.ts} +143 -1
- package/build/legacy/{types-t-GGY-tI.d.cts → types-Ya7vXgfL.d.cts} +143 -1
- package/build/legacy/types.cjs.map +1 -1
- package/build/legacy/types.d.cts +1 -1
- package/build/legacy/types.d.ts +1 -1
- package/build/legacy/utils.d.cts +1 -1
- package/build/legacy/utils.d.ts +1 -1
- package/build/modern/hydration.d.cts +1 -1
- package/build/modern/hydration.d.ts +1 -1
- package/build/modern/index.d.cts +1 -1
- package/build/modern/index.d.ts +1 -1
- package/build/modern/infiniteQueryBehavior.d.cts +1 -1
- package/build/modern/infiniteQueryBehavior.d.ts +1 -1
- package/build/modern/infiniteQueryObserver.d.cts +1 -1
- package/build/modern/infiniteQueryObserver.d.ts +1 -1
- package/build/modern/mutation.d.cts +1 -1
- package/build/modern/mutation.d.ts +1 -1
- package/build/modern/mutationCache.d.cts +1 -1
- package/build/modern/mutationCache.d.ts +1 -1
- package/build/modern/mutationObserver.d.cts +1 -1
- package/build/modern/mutationObserver.d.ts +1 -1
- package/build/modern/queriesObserver.d.cts +1 -1
- package/build/modern/queriesObserver.d.ts +1 -1
- package/build/modern/query.d.cts +1 -1
- package/build/modern/query.d.ts +1 -1
- package/build/modern/queryCache.d.cts +1 -1
- package/build/modern/queryCache.d.ts +1 -1
- package/build/modern/queryClient.d.cts +1 -1
- package/build/modern/queryClient.d.ts +1 -1
- package/build/modern/queryObserver.d.cts +1 -1
- package/build/modern/queryObserver.d.ts +1 -1
- package/build/modern/retryer.d.cts +1 -1
- package/build/modern/retryer.d.ts +1 -1
- package/build/modern/{types-4So4yn86.d.ts → types-Br-AgPmc.d.ts} +143 -1
- package/build/modern/{types-t-GGY-tI.d.cts → types-Ya7vXgfL.d.cts} +143 -1
- package/build/modern/types.cjs.map +1 -1
- package/build/modern/types.d.cts +1 -1
- package/build/modern/types.d.ts +1 -1
- package/build/modern/utils.d.cts +1 -1
- package/build/modern/utils.d.ts +1 -1
- package/package.json +1 -1
- package/src/types.ts +143 -1
|
@@ -736,33 +736,122 @@ interface FetchPreviousPageOptions extends ResultOptions {
|
|
|
736
736
|
type QueryStatus = 'pending' | 'error' | 'success';
|
|
737
737
|
type FetchStatus = 'fetching' | 'paused' | 'idle';
|
|
738
738
|
interface QueryObserverBaseResult<TData = unknown, TError = DefaultError> {
|
|
739
|
+
/**
|
|
740
|
+
* The last successfully resolved data for the query.
|
|
741
|
+
* - Defaults to `undefined`.
|
|
742
|
+
*/
|
|
739
743
|
data: TData | undefined;
|
|
744
|
+
/**
|
|
745
|
+
* The timestamp for when the query most recently returned the `status` as `"success"`.
|
|
746
|
+
*/
|
|
740
747
|
dataUpdatedAt: number;
|
|
748
|
+
/**
|
|
749
|
+
* The error object for the query, if an error was thrown.
|
|
750
|
+
* - Defaults to `null`.
|
|
751
|
+
*/
|
|
741
752
|
error: TError | null;
|
|
753
|
+
/**
|
|
754
|
+
* The timestamp for when the query most recently returned the `status` as `"error"`.
|
|
755
|
+
*/
|
|
742
756
|
errorUpdatedAt: number;
|
|
757
|
+
/**
|
|
758
|
+
* The failure count for the query.
|
|
759
|
+
* - Incremented every time the query fails.
|
|
760
|
+
* - Reset to `0` when the query succeeds.
|
|
761
|
+
*/
|
|
743
762
|
failureCount: number;
|
|
763
|
+
/**
|
|
764
|
+
* The failure reason for the query retry.
|
|
765
|
+
* - Reset to `null` when the query succeeds.
|
|
766
|
+
*/
|
|
744
767
|
failureReason: TError | null;
|
|
768
|
+
/**
|
|
769
|
+
* The sum of all errors.
|
|
770
|
+
*/
|
|
745
771
|
errorUpdateCount: number;
|
|
772
|
+
/**
|
|
773
|
+
* A derived boolean from the `status` variable, provided for convenience.
|
|
774
|
+
* - `true` if the query attempt resulted in an error.
|
|
775
|
+
*/
|
|
746
776
|
isError: boolean;
|
|
777
|
+
/**
|
|
778
|
+
* Will be `true` if the query has been fetched.
|
|
779
|
+
*/
|
|
747
780
|
isFetched: boolean;
|
|
781
|
+
/**
|
|
782
|
+
* Will be `true` if the query has been fetched after the component mounted.
|
|
783
|
+
* - This property can be used to not show any previously cached data.
|
|
784
|
+
*/
|
|
748
785
|
isFetchedAfterMount: boolean;
|
|
786
|
+
/**
|
|
787
|
+
* A derived boolean from the `fetchStatus` variable, provided for convenience.
|
|
788
|
+
* - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch.
|
|
789
|
+
*/
|
|
749
790
|
isFetching: boolean;
|
|
791
|
+
/**
|
|
792
|
+
* Is `true` whenever the first fetch for a query is in-flight.
|
|
793
|
+
* - Is the same as `isFetching && isPending`.
|
|
794
|
+
*/
|
|
750
795
|
isLoading: boolean;
|
|
796
|
+
/**
|
|
797
|
+
* Will be `pending` if there's no cached data and no query attempt was finished yet.
|
|
798
|
+
*/
|
|
751
799
|
isPending: boolean;
|
|
800
|
+
/**
|
|
801
|
+
* Will be `true` if the query failed while fetching for the first time.
|
|
802
|
+
*/
|
|
752
803
|
isLoadingError: boolean;
|
|
753
804
|
/**
|
|
754
|
-
* @deprecated isInitialLoading is being deprecated in favor of isLoading
|
|
805
|
+
* @deprecated `isInitialLoading` is being deprecated in favor of `isLoading`
|
|
755
806
|
* and will be removed in the next major version.
|
|
756
807
|
*/
|
|
757
808
|
isInitialLoading: boolean;
|
|
809
|
+
/**
|
|
810
|
+
* A derived boolean from the `fetchStatus` variable, provided for convenience.
|
|
811
|
+
* - The query wanted to fetch, but has been `paused`.
|
|
812
|
+
*/
|
|
758
813
|
isPaused: boolean;
|
|
814
|
+
/**
|
|
815
|
+
* Will be `true` if the data shown is the placeholder data.
|
|
816
|
+
*/
|
|
759
817
|
isPlaceholderData: boolean;
|
|
818
|
+
/**
|
|
819
|
+
* Will be `true` if the query failed while refetching.
|
|
820
|
+
*/
|
|
760
821
|
isRefetchError: boolean;
|
|
822
|
+
/**
|
|
823
|
+
* Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`.
|
|
824
|
+
* - Is the same as `isFetching && !isPending`.
|
|
825
|
+
*/
|
|
761
826
|
isRefetching: boolean;
|
|
827
|
+
/**
|
|
828
|
+
* Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`.
|
|
829
|
+
*/
|
|
762
830
|
isStale: boolean;
|
|
831
|
+
/**
|
|
832
|
+
* A derived boolean from the `status` variable, provided for convenience.
|
|
833
|
+
* - `true` if the query has received a response with no errors and is ready to display its data.
|
|
834
|
+
*/
|
|
763
835
|
isSuccess: boolean;
|
|
836
|
+
/**
|
|
837
|
+
* A function to manually refetch the query.
|
|
838
|
+
*/
|
|
764
839
|
refetch: (options?: RefetchOptions) => Promise<QueryObserverResult<TData, TError>>;
|
|
840
|
+
/**
|
|
841
|
+
* The status of the query.
|
|
842
|
+
* - Will be:
|
|
843
|
+
* - `pending` if there's no cached data and no query attempt was finished yet.
|
|
844
|
+
* - `error` if the query attempt resulted in an error.
|
|
845
|
+
* - `success` if the query has received a response with no errors and is ready to display its data.
|
|
846
|
+
*/
|
|
765
847
|
status: QueryStatus;
|
|
848
|
+
/**
|
|
849
|
+
* The fetch status of the query.
|
|
850
|
+
* - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch.
|
|
851
|
+
* - `paused`: The query wanted to fetch, but has been `paused`.
|
|
852
|
+
* - `idle`: The query is not fetching.
|
|
853
|
+
* - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information.
|
|
854
|
+
*/
|
|
766
855
|
fetchStatus: FetchStatus;
|
|
767
856
|
}
|
|
768
857
|
interface QueryObserverPendingResult<TData = unknown, TError = DefaultError> extends QueryObserverBaseResult<TData, TError> {
|
|
@@ -919,11 +1008,64 @@ interface MutateOptions<TData = unknown, TError = DefaultError, TVariables = voi
|
|
|
919
1008
|
}
|
|
920
1009
|
type MutateFunction<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> = (variables: TVariables, options?: MutateOptions<TData, TError, TVariables, TContext>) => Promise<TData>;
|
|
921
1010
|
interface MutationObserverBaseResult<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> extends MutationState<TData, TError, TVariables, TContext> {
|
|
1011
|
+
/**
|
|
1012
|
+
* The last successfully resolved data for the mutation.
|
|
1013
|
+
* - Defaults to `undefined`.
|
|
1014
|
+
*/
|
|
1015
|
+
data: TData | undefined;
|
|
1016
|
+
/**
|
|
1017
|
+
* The variables object passed to the `mutationFn`.
|
|
1018
|
+
* - Defaults to `undefined`.
|
|
1019
|
+
*/
|
|
1020
|
+
variables: TVariables | undefined;
|
|
1021
|
+
/**
|
|
1022
|
+
* The error object for the mutation, if an error was encountered.
|
|
1023
|
+
* - Defaults to `null`.
|
|
1024
|
+
*/
|
|
1025
|
+
error: TError | null;
|
|
1026
|
+
/**
|
|
1027
|
+
* A boolean variable derived from `status`.
|
|
1028
|
+
* - `true` if the last mutation attempt resulted in an error.
|
|
1029
|
+
*/
|
|
922
1030
|
isError: boolean;
|
|
1031
|
+
/**
|
|
1032
|
+
* A boolean variable derived from `status`.
|
|
1033
|
+
* - `true` if the mutation is in its initial state prior to executing.
|
|
1034
|
+
*/
|
|
923
1035
|
isIdle: boolean;
|
|
1036
|
+
/**
|
|
1037
|
+
* A boolean variable derived from `status`.
|
|
1038
|
+
* - `true` if the mutation is currently executing.
|
|
1039
|
+
*/
|
|
924
1040
|
isPending: boolean;
|
|
1041
|
+
/**
|
|
1042
|
+
* A boolean variable derived from `status`.
|
|
1043
|
+
* - `true` if the last mutation attempt was successful.
|
|
1044
|
+
*/
|
|
925
1045
|
isSuccess: boolean;
|
|
1046
|
+
/**
|
|
1047
|
+
* The status of the mutation.
|
|
1048
|
+
* - Will be:
|
|
1049
|
+
* - `idle` initial status prior to the mutation function executing.
|
|
1050
|
+
* - `pending` if the mutation is currently executing.
|
|
1051
|
+
* - `error` if the last mutation attempt resulted in an error.
|
|
1052
|
+
* - `success` if the last mutation attempt was successful.
|
|
1053
|
+
*/
|
|
1054
|
+
status: MutationStatus;
|
|
1055
|
+
/**
|
|
1056
|
+
* The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options.
|
|
1057
|
+
* @param variables - The variables object to pass to the `mutationFn`.
|
|
1058
|
+
* @param options.onSuccess - This function will fire when the mutation is successful and will be passed the mutation's result.
|
|
1059
|
+
* @param options.onError - This function will fire if the mutation encounters an error and will be passed the error.
|
|
1060
|
+
* @param options.onSettled - This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error.
|
|
1061
|
+
* @remarks
|
|
1062
|
+
* - If you make multiple requests, `onSuccess` will fire only after the latest call you've made.
|
|
1063
|
+
* - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored.
|
|
1064
|
+
*/
|
|
926
1065
|
mutate: MutateFunction<TData, TError, TVariables, TContext>;
|
|
1066
|
+
/**
|
|
1067
|
+
* A function to clean the mutation internal state (i.e., it resets the mutation to its initial state).
|
|
1068
|
+
*/
|
|
927
1069
|
reset: () => void;
|
|
928
1070
|
}
|
|
929
1071
|
interface MutationObserverIdleResult<TData = unknown, TError = DefaultError, TVariables = void, TContext = unknown> extends MutationObserverBaseResult<TData, TError, TVariables, TContext> {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/types.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport type { MutationState } from './mutation'\nimport type { FetchDirection, Query, QueryBehavior } from './query'\nimport type { RetryDelayValue, RetryValue } from './retryer'\nimport type { QueryFilters, QueryTypeFilter, SkipToken } from './utils'\nimport type { QueryCache } from './queryCache'\nimport type { MutationCache } from './mutationCache'\n\nexport type OmitKeyof<\n TObject,\n TKey extends TStrictly extends 'safely'\n ?\n | keyof TObject\n | (string & Record<never, never>)\n | (number & Record<never, never>)\n | (symbol & Record<never, never>)\n : keyof TObject,\n TStrictly extends 'strictly' | 'safely' = 'strictly',\n> = Omit<TObject, TKey>\n\nexport type NoInfer<T> = [T][T extends any ? 0 : never]\n\nexport interface Register {\n // defaultError: Error\n // queryMeta: Record<string, unknown>\n // mutationMeta: Record<string, unknown>\n}\n\nexport type DefaultError = Register extends {\n defaultError: infer TError\n}\n ? TError\n : Error\n\nexport type QueryKey = ReadonlyArray<unknown>\n\nexport declare const dataTagSymbol: unique symbol\nexport type DataTag<TType, TValue> = TType & {\n [dataTagSymbol]: TValue\n}\n\nexport type QueryFunction<\n T = unknown,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> = (context: QueryFunctionContext<TQueryKey, TPageParam>) => T | Promise<T>\n\nexport type QueryPersister<\n T = unknown,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> = [TPageParam] extends [never]\n ? (\n queryFn: QueryFunction<T, TQueryKey, never>,\n context: QueryFunctionContext<TQueryKey>,\n query: Query,\n ) => T | Promise<T>\n : (\n queryFn: QueryFunction<T, TQueryKey, TPageParam>,\n context: QueryFunctionContext<TQueryKey>,\n query: Query,\n ) => T | Promise<T>\n\nexport type QueryFunctionContext<\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> = [TPageParam] extends [never]\n ? {\n queryKey: TQueryKey\n signal: AbortSignal\n meta: QueryMeta | undefined\n pageParam?: unknown\n /**\n * @deprecated\n * if you want access to the direction, you can add it to the pageParam\n */\n direction?: unknown\n }\n : {\n queryKey: TQueryKey\n signal: AbortSignal\n pageParam: TPageParam\n /**\n * @deprecated\n * if you want access to the direction, you can add it to the pageParam\n */\n direction: FetchDirection\n meta: QueryMeta | undefined\n }\n\nexport type InitialDataFunction<T> = () => T | undefined\n\ntype NonFunctionGuard<T> = T extends Function ? never : T\n\nexport type PlaceholderDataFunction<\n TQueryFnData = unknown,\n TError = DefaultError,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = (\n previousData: TQueryData | undefined,\n previousQuery: Query<TQueryFnData, TError, TQueryData, TQueryKey> | undefined,\n) => TQueryData | undefined\n\nexport type QueriesPlaceholderDataFunction<TQueryData> = (\n previousData: undefined,\n previousQuery: undefined,\n) => TQueryData | undefined\n\nexport type QueryKeyHashFunction<TQueryKey extends QueryKey> = (\n queryKey: TQueryKey,\n) => string\n\nexport type GetPreviousPageParamFunction<TPageParam, TQueryFnData = unknown> = (\n firstPage: TQueryFnData,\n allPages: Array<TQueryFnData>,\n firstPageParam: TPageParam,\n allPageParams: Array<TPageParam>,\n) => TPageParam | undefined | null\n\nexport type GetNextPageParamFunction<TPageParam, TQueryFnData = unknown> = (\n lastPage: TQueryFnData,\n allPages: Array<TQueryFnData>,\n lastPageParam: TPageParam,\n allPageParams: Array<TPageParam>,\n) => TPageParam | undefined | null\n\nexport interface InfiniteData<TData, TPageParam = unknown> {\n pages: Array<TData>\n pageParams: Array<TPageParam>\n}\n\nexport type QueryMeta = Register extends {\n queryMeta: infer TQueryMeta\n}\n ? TQueryMeta extends Record<string, unknown>\n ? TQueryMeta\n : Record<string, unknown>\n : Record<string, unknown>\n\nexport type NetworkMode = 'online' | 'always' | 'offlineFirst'\n\nexport type NotifyOnChangeProps =\n | Array<keyof InfiniteQueryObserverResult>\n | 'all'\n | (() => Array<keyof InfiniteQueryObserverResult> | 'all')\n\nexport interface QueryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> {\n /**\n * If `false`, failed queries will not retry by default.\n * If `true`, failed queries will retry infinitely., failureCount: num\n * If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number.\n * If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false.\n */\n retry?: RetryValue<TError>\n retryDelay?: RetryDelayValue<TError>\n networkMode?: NetworkMode\n /**\n * The time in milliseconds that unused/inactive cache data remains in memory.\n * When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration.\n * When different garbage collection times are specified, the longest one will be used.\n * Setting it to `Infinity` will disable garbage collection.\n */\n gcTime?: number\n queryFn?: QueryFunction<TQueryFnData, TQueryKey, TPageParam> | SkipToken\n persister?: QueryPersister<\n NoInfer<TQueryFnData>,\n NoInfer<TQueryKey>,\n NoInfer<TPageParam>\n >\n queryHash?: string\n queryKey?: TQueryKey\n queryKeyHashFn?: QueryKeyHashFunction<TQueryKey>\n initialData?: TData | InitialDataFunction<TData>\n initialDataUpdatedAt?: number | (() => number | undefined)\n behavior?: QueryBehavior<TQueryFnData, TError, TData, TQueryKey>\n /**\n * Set this to `false` to disable structural sharing between query results.\n * Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic.\n * Defaults to `true`.\n */\n structuralSharing?:\n | boolean\n | ((oldData: unknown | undefined, newData: unknown) => unknown)\n _defaulted?: boolean\n /**\n * Additional payload to be stored on each query.\n * Use this property to pass information that can be used in other places.\n */\n meta?: QueryMeta\n /**\n * Maximum number of pages to store in the data of an infinite query.\n */\n maxPages?: number\n}\n\nexport interface InitialPageParam<TPageParam = unknown> {\n initialPageParam: TPageParam\n}\n\nexport interface InfiniteQueryPageParamsOptions<\n TQueryFnData = unknown,\n TPageParam = unknown,\n> extends InitialPageParam<TPageParam> {\n /**\n * This function can be set to automatically get the previous cursor for infinite queries.\n * The result will also be used to determine the value of `hasPreviousPage`.\n */\n getPreviousPageParam?: GetPreviousPageParamFunction<TPageParam, TQueryFnData>\n /**\n * This function can be set to automatically get the next cursor for infinite queries.\n * The result will also be used to determine the value of `hasNextPage`.\n */\n getNextPageParam: GetNextPageParamFunction<TPageParam, TQueryFnData>\n}\n\nexport type ThrowOnError<\n TQueryFnData,\n TError,\n TQueryData,\n TQueryKey extends QueryKey,\n> =\n | boolean\n | ((\n error: TError,\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n ) => boolean)\n\nexport interface QueryObserverOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> extends WithRequired<\n QueryOptions<TQueryFnData, TError, TQueryData, TQueryKey, TPageParam>,\n 'queryKey'\n > {\n /**\n * Set this to `false` to disable automatic refetching when the query mounts or changes query keys.\n * To refetch the query, use the `refetch` method returned from the `useQuery` instance.\n * Defaults to `true`.\n */\n enabled?: boolean\n /**\n * The time in milliseconds after data is considered stale.\n * If set to `Infinity`, the data will never be considered stale.\n */\n staleTime?: number\n /**\n * If set to a number, the query will continuously refetch at this frequency in milliseconds.\n * If set to a function, the function will be executed with the latest data and query to compute a frequency\n * Defaults to `false`.\n */\n refetchInterval?:\n | number\n | false\n | ((\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n ) => number | false | undefined)\n /**\n * If set to `true`, the query will continue to refetch while their tab/window is in the background.\n * Defaults to `false`.\n */\n refetchIntervalInBackground?: boolean\n /**\n * If set to `true`, the query will refetch on window focus if the data is stale.\n * If set to `false`, the query will not refetch on window focus.\n * If set to `'always'`, the query will always refetch on window focus.\n * If set to a function, the function will be executed with the latest data and query to compute the value.\n * Defaults to `true`.\n */\n refetchOnWindowFocus?:\n | boolean\n | 'always'\n | ((\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n ) => boolean | 'always')\n /**\n * If set to `true`, the query will refetch on reconnect if the data is stale.\n * If set to `false`, the query will not refetch on reconnect.\n * If set to `'always'`, the query will always refetch on reconnect.\n * If set to a function, the function will be executed with the latest data and query to compute the value.\n * Defaults to the value of `networkOnline` (`true`)\n */\n refetchOnReconnect?:\n | boolean\n | 'always'\n | ((\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n ) => boolean | 'always')\n /**\n * If set to `true`, the query will refetch on mount if the data is stale.\n * If set to `false`, will disable additional instances of a query to trigger background refetch.\n * If set to `'always'`, the query will always refetch on mount.\n * If set to a function, the function will be executed with the latest data and query to compute the value\n * Defaults to `true`.\n */\n refetchOnMount?:\n | boolean\n | 'always'\n | ((\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n ) => boolean | 'always')\n /**\n * If set to `false`, the query will not be retried on mount if it contains an error.\n * Defaults to `true`.\n */\n retryOnMount?: boolean\n /**\n * If set, the component will only re-render if any of the listed properties change.\n * When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change.\n * When set to `'all'`, the component will re-render whenever a query is updated.\n * When set to a function, the function will be executed to compute the list of properties.\n * By default, access to properties will be tracked, and the component will only re-render when one of the tracked properties change.\n */\n notifyOnChangeProps?: NotifyOnChangeProps\n /**\n * Whether errors should be thrown instead of setting the `error` property.\n * If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary.\n * If set to `false` and `suspense` is `false`, errors are returned as state.\n * If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`).\n * Defaults to `false`.\n */\n throwOnError?: ThrowOnError<TQueryFnData, TError, TQueryData, TQueryKey>\n /**\n * This option can be used to transform or select a part of the data returned by the query function.\n */\n select?: (data: TQueryData) => TData\n /**\n * If set to `true`, the query will suspend when `status === 'pending'`\n * and throw errors when `status === 'error'`.\n * Defaults to `false`.\n */\n suspense?: boolean\n /**\n * If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided.\n */\n placeholderData?:\n | NonFunctionGuard<TQueryData>\n | PlaceholderDataFunction<\n NonFunctionGuard<TQueryData>,\n TError,\n NonFunctionGuard<TQueryData>,\n TQueryKey\n >\n\n _optimisticResults?: 'optimistic' | 'isRestoring'\n}\n\nexport type WithRequired<TTarget, TKey extends keyof TTarget> = TTarget & {\n [_ in TKey]: {}\n}\nexport type Optional<TTarget, TKey extends keyof TTarget> = Pick<\n Partial<TTarget>,\n TKey\n> &\n OmitKeyof<TTarget, TKey>\n\nexport type DefaultedQueryObserverOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = WithRequired<\n QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>,\n 'throwOnError' | 'refetchOnReconnect' | 'queryHash'\n>\n\nexport interface InfiniteQueryObserverOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> extends QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n InfiniteData<TQueryData, TPageParam>,\n TQueryKey,\n TPageParam\n >,\n InfiniteQueryPageParamsOptions<TQueryFnData, TPageParam> {}\n\nexport type DefaultedInfiniteQueryObserverOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = WithRequired<\n InfiniteQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n TPageParam\n >,\n 'throwOnError' | 'refetchOnReconnect' | 'queryHash'\n>\n\nexport interface FetchQueryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> extends WithRequired<\n QueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>,\n 'queryKey'\n > {\n /**\n * The time in milliseconds after data is considered stale.\n * If the data is fresh it will be returned from the cache.\n */\n staleTime?: number\n}\n\nexport interface EnsureQueryDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> extends FetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n > {\n revalidateIfStale?: boolean\n}\n\ntype FetchInfiniteQueryPages<TQueryFnData = unknown, TPageParam = unknown> =\n | { pages?: never }\n | {\n pages: number\n getNextPageParam: GetNextPageParamFunction<TPageParam, TQueryFnData>\n }\n\nexport type FetchInfiniteQueryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = FetchQueryOptions<\n TQueryFnData,\n TError,\n InfiniteData<TData, TPageParam>,\n TQueryKey,\n TPageParam\n> &\n InitialPageParam<TPageParam> &\n FetchInfiniteQueryPages<TQueryFnData, TPageParam>\n\nexport interface ResultOptions {\n throwOnError?: boolean\n}\n\nexport interface RefetchOptions extends ResultOptions {\n cancelRefetch?: boolean\n}\n\nexport interface InvalidateQueryFilters extends QueryFilters {\n refetchType?: QueryTypeFilter | 'none'\n}\n\nexport interface RefetchQueryFilters extends QueryFilters {}\n\nexport interface InvalidateOptions extends RefetchOptions {}\nexport interface ResetOptions extends RefetchOptions {}\n\nexport interface FetchNextPageOptions extends ResultOptions {\n cancelRefetch?: boolean\n}\n\nexport interface FetchPreviousPageOptions extends ResultOptions {\n cancelRefetch?: boolean\n}\n\nexport type QueryStatus = 'pending' | 'error' | 'success'\nexport type FetchStatus = 'fetching' | 'paused' | 'idle'\n\nexport interface QueryObserverBaseResult<\n TData = unknown,\n TError = DefaultError,\n> {\n data: TData | undefined\n dataUpdatedAt: number\n error: TError | null\n errorUpdatedAt: number\n failureCount: number\n failureReason: TError | null\n errorUpdateCount: number\n isError: boolean\n isFetched: boolean\n isFetchedAfterMount: boolean\n isFetching: boolean\n isLoading: boolean\n isPending: boolean\n isLoadingError: boolean\n /**\n * @deprecated isInitialLoading is being deprecated in favor of isLoading\n * and will be removed in the next major version.\n */\n isInitialLoading: boolean\n isPaused: boolean\n isPlaceholderData: boolean\n isRefetchError: boolean\n isRefetching: boolean\n isStale: boolean\n isSuccess: boolean\n refetch: (\n options?: RefetchOptions,\n ) => Promise<QueryObserverResult<TData, TError>>\n status: QueryStatus\n fetchStatus: FetchStatus\n}\n\nexport interface QueryObserverPendingResult<\n TData = unknown,\n TError = DefaultError,\n> extends QueryObserverBaseResult<TData, TError> {\n data: undefined\n error: null\n isError: false\n isPending: true\n isLoadingError: false\n isRefetchError: false\n isSuccess: false\n status: 'pending'\n}\n\nexport interface QueryObserverLoadingResult<\n TData = unknown,\n TError = DefaultError,\n> extends QueryObserverBaseResult<TData, TError> {\n data: undefined\n error: null\n isError: false\n isPending: true\n isLoading: true\n isLoadingError: false\n isRefetchError: false\n isSuccess: false\n status: 'pending'\n}\n\nexport interface QueryObserverLoadingErrorResult<\n TData = unknown,\n TError = DefaultError,\n> extends QueryObserverBaseResult<TData, TError> {\n data: undefined\n error: TError\n isError: true\n isPending: false\n isLoading: false\n isLoadingError: true\n isRefetchError: false\n isSuccess: false\n status: 'error'\n}\n\nexport interface QueryObserverRefetchErrorResult<\n TData = unknown,\n TError = DefaultError,\n> extends QueryObserverBaseResult<TData, TError> {\n data: TData\n error: TError\n isError: true\n isPending: false\n isLoading: false\n isLoadingError: false\n isRefetchError: true\n isSuccess: false\n status: 'error'\n}\n\nexport interface QueryObserverSuccessResult<\n TData = unknown,\n TError = DefaultError,\n> extends QueryObserverBaseResult<TData, TError> {\n data: TData\n error: null\n isError: false\n isPending: false\n isLoading: false\n isLoadingError: false\n isRefetchError: false\n isSuccess: true\n status: 'success'\n}\n\nexport type DefinedQueryObserverResult<\n TData = unknown,\n TError = DefaultError,\n> =\n | QueryObserverRefetchErrorResult<TData, TError>\n | QueryObserverSuccessResult<TData, TError>\n\nexport type QueryObserverResult<TData = unknown, TError = DefaultError> =\n | DefinedQueryObserverResult<TData, TError>\n | QueryObserverLoadingErrorResult<TData, TError>\n | QueryObserverLoadingResult<TData, TError>\n | QueryObserverPendingResult<TData, TError>\n\nexport interface InfiniteQueryObserverBaseResult<\n TData = unknown,\n TError = DefaultError,\n> extends QueryObserverBaseResult<TData, TError> {\n fetchNextPage: (\n options?: FetchNextPageOptions,\n ) => Promise<InfiniteQueryObserverResult<TData, TError>>\n fetchPreviousPage: (\n options?: FetchPreviousPageOptions,\n ) => Promise<InfiniteQueryObserverResult<TData, TError>>\n hasNextPage: boolean\n hasPreviousPage: boolean\n isFetchingNextPage: boolean\n isFetchingPreviousPage: boolean\n}\n\nexport interface InfiniteQueryObserverPendingResult<\n TData = unknown,\n TError = DefaultError,\n> extends InfiniteQueryObserverBaseResult<TData, TError> {\n data: undefined\n error: null\n isError: false\n isPending: true\n isLoadingError: false\n isRefetchError: false\n isSuccess: false\n status: 'pending'\n}\n\nexport interface InfiniteQueryObserverLoadingResult<\n TData = unknown,\n TError = DefaultError,\n> extends InfiniteQueryObserverBaseResult<TData, TError> {\n data: undefined\n error: null\n isError: false\n isPending: true\n isLoading: true\n isLoadingError: false\n isRefetchError: false\n isSuccess: false\n status: 'pending'\n}\n\nexport interface InfiniteQueryObserverLoadingErrorResult<\n TData = unknown,\n TError = DefaultError,\n> extends InfiniteQueryObserverBaseResult<TData, TError> {\n data: undefined\n error: TError\n isError: true\n isPending: false\n isLoading: false\n isLoadingError: true\n isRefetchError: false\n isSuccess: false\n status: 'error'\n}\n\nexport interface InfiniteQueryObserverRefetchErrorResult<\n TData = unknown,\n TError = DefaultError,\n> extends InfiniteQueryObserverBaseResult<TData, TError> {\n data: TData\n error: TError\n isError: true\n isPending: false\n isLoading: false\n isLoadingError: false\n isRefetchError: true\n isSuccess: false\n status: 'error'\n}\n\nexport interface InfiniteQueryObserverSuccessResult<\n TData = unknown,\n TError = DefaultError,\n> extends InfiniteQueryObserverBaseResult<TData, TError> {\n data: TData\n error: null\n isError: false\n isPending: false\n isLoading: false\n isLoadingError: false\n isRefetchError: false\n isSuccess: true\n status: 'success'\n}\n\nexport type DefinedInfiniteQueryObserverResult<\n TData = unknown,\n TError = DefaultError,\n> =\n | InfiniteQueryObserverRefetchErrorResult<TData, TError>\n | InfiniteQueryObserverSuccessResult<TData, TError>\n\nexport type InfiniteQueryObserverResult<\n TData = unknown,\n TError = DefaultError,\n> =\n | DefinedInfiniteQueryObserverResult<TData, TError>\n | InfiniteQueryObserverLoadingErrorResult<TData, TError>\n | InfiniteQueryObserverLoadingResult<TData, TError>\n | InfiniteQueryObserverPendingResult<TData, TError>\n\nexport type MutationKey = ReadonlyArray<unknown>\n\nexport type MutationStatus = 'idle' | 'pending' | 'success' | 'error'\n\nexport type MutationScope = {\n id: string\n}\n\nexport type MutationMeta = Register extends {\n mutationMeta: infer TMutationMeta\n}\n ? TMutationMeta extends Record<string, unknown>\n ? TMutationMeta\n : Record<string, unknown>\n : Record<string, unknown>\n\nexport type MutationFunction<TData = unknown, TVariables = unknown> = (\n variables: TVariables,\n) => Promise<TData>\n\nexport interface MutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> {\n mutationFn?: MutationFunction<TData, TVariables>\n mutationKey?: MutationKey\n onMutate?: (\n variables: TVariables,\n ) => Promise<TContext | undefined> | TContext | undefined\n onSuccess?: (\n data: TData,\n variables: TVariables,\n context: TContext,\n ) => Promise<unknown> | unknown\n onError?: (\n error: TError,\n variables: TVariables,\n context: TContext | undefined,\n ) => Promise<unknown> | unknown\n onSettled?: (\n data: TData | undefined,\n error: TError | null,\n variables: TVariables,\n context: TContext | undefined,\n ) => Promise<unknown> | unknown\n retry?: RetryValue<TError>\n retryDelay?: RetryDelayValue<TError>\n networkMode?: NetworkMode\n gcTime?: number\n _defaulted?: boolean\n meta?: MutationMeta\n scope?: MutationScope\n}\n\nexport interface MutationObserverOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends MutationOptions<TData, TError, TVariables, TContext> {\n throwOnError?: boolean | ((error: TError) => boolean)\n}\n\nexport interface MutateOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> {\n onSuccess?: (data: TData, variables: TVariables, context: TContext) => void\n onError?: (\n error: TError,\n variables: TVariables,\n context: TContext | undefined,\n ) => void\n onSettled?: (\n data: TData | undefined,\n error: TError | null,\n variables: TVariables,\n context: TContext | undefined,\n ) => void\n}\n\nexport type MutateFunction<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> = (\n variables: TVariables,\n options?: MutateOptions<TData, TError, TVariables, TContext>,\n) => Promise<TData>\n\nexport interface MutationObserverBaseResult<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends MutationState<TData, TError, TVariables, TContext> {\n isError: boolean\n isIdle: boolean\n isPending: boolean\n isSuccess: boolean\n mutate: MutateFunction<TData, TError, TVariables, TContext>\n reset: () => void\n}\n\nexport interface MutationObserverIdleResult<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends MutationObserverBaseResult<TData, TError, TVariables, TContext> {\n data: undefined\n variables: undefined\n error: null\n isError: false\n isIdle: true\n isPending: false\n isSuccess: false\n status: 'idle'\n}\n\nexport interface MutationObserverLoadingResult<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends MutationObserverBaseResult<TData, TError, TVariables, TContext> {\n data: undefined\n variables: TVariables\n error: null\n isError: false\n isIdle: false\n isPending: true\n isSuccess: false\n status: 'pending'\n}\n\nexport interface MutationObserverErrorResult<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends MutationObserverBaseResult<TData, TError, TVariables, TContext> {\n data: undefined\n error: TError\n variables: TVariables\n isError: true\n isIdle: false\n isPending: false\n isSuccess: false\n status: 'error'\n}\n\nexport interface MutationObserverSuccessResult<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends MutationObserverBaseResult<TData, TError, TVariables, TContext> {\n data: TData\n error: null\n variables: TVariables\n isError: false\n isIdle: false\n isPending: false\n isSuccess: true\n status: 'success'\n}\n\nexport type MutationObserverResult<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> =\n | MutationObserverIdleResult<TData, TError, TVariables, TContext>\n | MutationObserverLoadingResult<TData, TError, TVariables, TContext>\n | MutationObserverErrorResult<TData, TError, TVariables, TContext>\n | MutationObserverSuccessResult<TData, TError, TVariables, TContext>\n\nexport interface QueryClientConfig {\n queryCache?: QueryCache\n mutationCache?: MutationCache\n defaultOptions?: DefaultOptions\n}\n\nexport interface DefaultOptions<TError = DefaultError> {\n queries?: OmitKeyof<\n QueryObserverOptions<unknown, TError>,\n 'suspense' | 'queryKey'\n >\n mutations?: MutationObserverOptions<unknown, TError, unknown, unknown>\n}\n\nexport interface CancelOptions {\n revert?: boolean\n silent?: boolean\n}\n\nexport interface SetDataOptions {\n updatedAt?: number\n}\n\nexport type NotifyEventType =\n | 'added'\n | 'removed'\n | 'updated'\n | 'observerAdded'\n | 'observerRemoved'\n | 'observerResultsUpdated'\n | 'observerOptionsUpdated'\n\nexport interface NotifyEvent {\n type: NotifyEventType\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/types.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport type { MutationState } from './mutation'\nimport type { FetchDirection, Query, QueryBehavior } from './query'\nimport type { RetryDelayValue, RetryValue } from './retryer'\nimport type { QueryFilters, QueryTypeFilter, SkipToken } from './utils'\nimport type { QueryCache } from './queryCache'\nimport type { MutationCache } from './mutationCache'\n\nexport type OmitKeyof<\n TObject,\n TKey extends TStrictly extends 'safely'\n ?\n | keyof TObject\n | (string & Record<never, never>)\n | (number & Record<never, never>)\n | (symbol & Record<never, never>)\n : keyof TObject,\n TStrictly extends 'strictly' | 'safely' = 'strictly',\n> = Omit<TObject, TKey>\n\nexport type NoInfer<T> = [T][T extends any ? 0 : never]\n\nexport interface Register {\n // defaultError: Error\n // queryMeta: Record<string, unknown>\n // mutationMeta: Record<string, unknown>\n}\n\nexport type DefaultError = Register extends {\n defaultError: infer TError\n}\n ? TError\n : Error\n\nexport type QueryKey = ReadonlyArray<unknown>\n\nexport declare const dataTagSymbol: unique symbol\nexport type DataTag<TType, TValue> = TType & {\n [dataTagSymbol]: TValue\n}\n\nexport type QueryFunction<\n T = unknown,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> = (context: QueryFunctionContext<TQueryKey, TPageParam>) => T | Promise<T>\n\nexport type QueryPersister<\n T = unknown,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> = [TPageParam] extends [never]\n ? (\n queryFn: QueryFunction<T, TQueryKey, never>,\n context: QueryFunctionContext<TQueryKey>,\n query: Query,\n ) => T | Promise<T>\n : (\n queryFn: QueryFunction<T, TQueryKey, TPageParam>,\n context: QueryFunctionContext<TQueryKey>,\n query: Query,\n ) => T | Promise<T>\n\nexport type QueryFunctionContext<\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> = [TPageParam] extends [never]\n ? {\n queryKey: TQueryKey\n signal: AbortSignal\n meta: QueryMeta | undefined\n pageParam?: unknown\n /**\n * @deprecated\n * if you want access to the direction, you can add it to the pageParam\n */\n direction?: unknown\n }\n : {\n queryKey: TQueryKey\n signal: AbortSignal\n pageParam: TPageParam\n /**\n * @deprecated\n * if you want access to the direction, you can add it to the pageParam\n */\n direction: FetchDirection\n meta: QueryMeta | undefined\n }\n\nexport type InitialDataFunction<T> = () => T | undefined\n\ntype NonFunctionGuard<T> = T extends Function ? never : T\n\nexport type PlaceholderDataFunction<\n TQueryFnData = unknown,\n TError = DefaultError,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = (\n previousData: TQueryData | undefined,\n previousQuery: Query<TQueryFnData, TError, TQueryData, TQueryKey> | undefined,\n) => TQueryData | undefined\n\nexport type QueriesPlaceholderDataFunction<TQueryData> = (\n previousData: undefined,\n previousQuery: undefined,\n) => TQueryData | undefined\n\nexport type QueryKeyHashFunction<TQueryKey extends QueryKey> = (\n queryKey: TQueryKey,\n) => string\n\nexport type GetPreviousPageParamFunction<TPageParam, TQueryFnData = unknown> = (\n firstPage: TQueryFnData,\n allPages: Array<TQueryFnData>,\n firstPageParam: TPageParam,\n allPageParams: Array<TPageParam>,\n) => TPageParam | undefined | null\n\nexport type GetNextPageParamFunction<TPageParam, TQueryFnData = unknown> = (\n lastPage: TQueryFnData,\n allPages: Array<TQueryFnData>,\n lastPageParam: TPageParam,\n allPageParams: Array<TPageParam>,\n) => TPageParam | undefined | null\n\nexport interface InfiniteData<TData, TPageParam = unknown> {\n pages: Array<TData>\n pageParams: Array<TPageParam>\n}\n\nexport type QueryMeta = Register extends {\n queryMeta: infer TQueryMeta\n}\n ? TQueryMeta extends Record<string, unknown>\n ? TQueryMeta\n : Record<string, unknown>\n : Record<string, unknown>\n\nexport type NetworkMode = 'online' | 'always' | 'offlineFirst'\n\nexport type NotifyOnChangeProps =\n | Array<keyof InfiniteQueryObserverResult>\n | 'all'\n | (() => Array<keyof InfiniteQueryObserverResult> | 'all')\n\nexport interface QueryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> {\n /**\n * If `false`, failed queries will not retry by default.\n * If `true`, failed queries will retry infinitely., failureCount: num\n * If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number.\n * If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false.\n */\n retry?: RetryValue<TError>\n retryDelay?: RetryDelayValue<TError>\n networkMode?: NetworkMode\n /**\n * The time in milliseconds that unused/inactive cache data remains in memory.\n * When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration.\n * When different garbage collection times are specified, the longest one will be used.\n * Setting it to `Infinity` will disable garbage collection.\n */\n gcTime?: number\n queryFn?: QueryFunction<TQueryFnData, TQueryKey, TPageParam> | SkipToken\n persister?: QueryPersister<\n NoInfer<TQueryFnData>,\n NoInfer<TQueryKey>,\n NoInfer<TPageParam>\n >\n queryHash?: string\n queryKey?: TQueryKey\n queryKeyHashFn?: QueryKeyHashFunction<TQueryKey>\n initialData?: TData | InitialDataFunction<TData>\n initialDataUpdatedAt?: number | (() => number | undefined)\n behavior?: QueryBehavior<TQueryFnData, TError, TData, TQueryKey>\n /**\n * Set this to `false` to disable structural sharing between query results.\n * Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic.\n * Defaults to `true`.\n */\n structuralSharing?:\n | boolean\n | ((oldData: unknown | undefined, newData: unknown) => unknown)\n _defaulted?: boolean\n /**\n * Additional payload to be stored on each query.\n * Use this property to pass information that can be used in other places.\n */\n meta?: QueryMeta\n /**\n * Maximum number of pages to store in the data of an infinite query.\n */\n maxPages?: number\n}\n\nexport interface InitialPageParam<TPageParam = unknown> {\n initialPageParam: TPageParam\n}\n\nexport interface InfiniteQueryPageParamsOptions<\n TQueryFnData = unknown,\n TPageParam = unknown,\n> extends InitialPageParam<TPageParam> {\n /**\n * This function can be set to automatically get the previous cursor for infinite queries.\n * The result will also be used to determine the value of `hasPreviousPage`.\n */\n getPreviousPageParam?: GetPreviousPageParamFunction<TPageParam, TQueryFnData>\n /**\n * This function can be set to automatically get the next cursor for infinite queries.\n * The result will also be used to determine the value of `hasNextPage`.\n */\n getNextPageParam: GetNextPageParamFunction<TPageParam, TQueryFnData>\n}\n\nexport type ThrowOnError<\n TQueryFnData,\n TError,\n TQueryData,\n TQueryKey extends QueryKey,\n> =\n | boolean\n | ((\n error: TError,\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n ) => boolean)\n\nexport interface QueryObserverOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> extends WithRequired<\n QueryOptions<TQueryFnData, TError, TQueryData, TQueryKey, TPageParam>,\n 'queryKey'\n > {\n /**\n * Set this to `false` to disable automatic refetching when the query mounts or changes query keys.\n * To refetch the query, use the `refetch` method returned from the `useQuery` instance.\n * Defaults to `true`.\n */\n enabled?: boolean\n /**\n * The time in milliseconds after data is considered stale.\n * If set to `Infinity`, the data will never be considered stale.\n */\n staleTime?: number\n /**\n * If set to a number, the query will continuously refetch at this frequency in milliseconds.\n * If set to a function, the function will be executed with the latest data and query to compute a frequency\n * Defaults to `false`.\n */\n refetchInterval?:\n | number\n | false\n | ((\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n ) => number | false | undefined)\n /**\n * If set to `true`, the query will continue to refetch while their tab/window is in the background.\n * Defaults to `false`.\n */\n refetchIntervalInBackground?: boolean\n /**\n * If set to `true`, the query will refetch on window focus if the data is stale.\n * If set to `false`, the query will not refetch on window focus.\n * If set to `'always'`, the query will always refetch on window focus.\n * If set to a function, the function will be executed with the latest data and query to compute the value.\n * Defaults to `true`.\n */\n refetchOnWindowFocus?:\n | boolean\n | 'always'\n | ((\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n ) => boolean | 'always')\n /**\n * If set to `true`, the query will refetch on reconnect if the data is stale.\n * If set to `false`, the query will not refetch on reconnect.\n * If set to `'always'`, the query will always refetch on reconnect.\n * If set to a function, the function will be executed with the latest data and query to compute the value.\n * Defaults to the value of `networkOnline` (`true`)\n */\n refetchOnReconnect?:\n | boolean\n | 'always'\n | ((\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n ) => boolean | 'always')\n /**\n * If set to `true`, the query will refetch on mount if the data is stale.\n * If set to `false`, will disable additional instances of a query to trigger background refetch.\n * If set to `'always'`, the query will always refetch on mount.\n * If set to a function, the function will be executed with the latest data and query to compute the value\n * Defaults to `true`.\n */\n refetchOnMount?:\n | boolean\n | 'always'\n | ((\n query: Query<TQueryFnData, TError, TQueryData, TQueryKey>,\n ) => boolean | 'always')\n /**\n * If set to `false`, the query will not be retried on mount if it contains an error.\n * Defaults to `true`.\n */\n retryOnMount?: boolean\n /**\n * If set, the component will only re-render if any of the listed properties change.\n * When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change.\n * When set to `'all'`, the component will re-render whenever a query is updated.\n * When set to a function, the function will be executed to compute the list of properties.\n * By default, access to properties will be tracked, and the component will only re-render when one of the tracked properties change.\n */\n notifyOnChangeProps?: NotifyOnChangeProps\n /**\n * Whether errors should be thrown instead of setting the `error` property.\n * If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary.\n * If set to `false` and `suspense` is `false`, errors are returned as state.\n * If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`).\n * Defaults to `false`.\n */\n throwOnError?: ThrowOnError<TQueryFnData, TError, TQueryData, TQueryKey>\n /**\n * This option can be used to transform or select a part of the data returned by the query function.\n */\n select?: (data: TQueryData) => TData\n /**\n * If set to `true`, the query will suspend when `status === 'pending'`\n * and throw errors when `status === 'error'`.\n * Defaults to `false`.\n */\n suspense?: boolean\n /**\n * If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided.\n */\n placeholderData?:\n | NonFunctionGuard<TQueryData>\n | PlaceholderDataFunction<\n NonFunctionGuard<TQueryData>,\n TError,\n NonFunctionGuard<TQueryData>,\n TQueryKey\n >\n\n _optimisticResults?: 'optimistic' | 'isRestoring'\n}\n\nexport type WithRequired<TTarget, TKey extends keyof TTarget> = TTarget & {\n [_ in TKey]: {}\n}\nexport type Optional<TTarget, TKey extends keyof TTarget> = Pick<\n Partial<TTarget>,\n TKey\n> &\n OmitKeyof<TTarget, TKey>\n\nexport type DefaultedQueryObserverOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = WithRequired<\n QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>,\n 'throwOnError' | 'refetchOnReconnect' | 'queryHash'\n>\n\nexport interface InfiniteQueryObserverOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> extends QueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n InfiniteData<TQueryData, TPageParam>,\n TQueryKey,\n TPageParam\n >,\n InfiniteQueryPageParamsOptions<TQueryFnData, TPageParam> {}\n\nexport type DefaultedInfiniteQueryObserverOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = WithRequired<\n InfiniteQueryObserverOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey,\n TPageParam\n >,\n 'throwOnError' | 'refetchOnReconnect' | 'queryHash'\n>\n\nexport interface FetchQueryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> extends WithRequired<\n QueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam>,\n 'queryKey'\n > {\n /**\n * The time in milliseconds after data is considered stale.\n * If the data is fresh it will be returned from the cache.\n */\n staleTime?: number\n}\n\nexport interface EnsureQueryDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = never,\n> extends FetchQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n > {\n revalidateIfStale?: boolean\n}\n\ntype FetchInfiniteQueryPages<TQueryFnData = unknown, TPageParam = unknown> =\n | { pages?: never }\n | {\n pages: number\n getNextPageParam: GetNextPageParamFunction<TPageParam, TQueryFnData>\n }\n\nexport type FetchInfiniteQueryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = FetchQueryOptions<\n TQueryFnData,\n TError,\n InfiniteData<TData, TPageParam>,\n TQueryKey,\n TPageParam\n> &\n InitialPageParam<TPageParam> &\n FetchInfiniteQueryPages<TQueryFnData, TPageParam>\n\nexport interface ResultOptions {\n throwOnError?: boolean\n}\n\nexport interface RefetchOptions extends ResultOptions {\n cancelRefetch?: boolean\n}\n\nexport interface InvalidateQueryFilters extends QueryFilters {\n refetchType?: QueryTypeFilter | 'none'\n}\n\nexport interface RefetchQueryFilters extends QueryFilters {}\n\nexport interface InvalidateOptions extends RefetchOptions {}\nexport interface ResetOptions extends RefetchOptions {}\n\nexport interface FetchNextPageOptions extends ResultOptions {\n cancelRefetch?: boolean\n}\n\nexport interface FetchPreviousPageOptions extends ResultOptions {\n cancelRefetch?: boolean\n}\n\nexport type QueryStatus = 'pending' | 'error' | 'success'\nexport type FetchStatus = 'fetching' | 'paused' | 'idle'\n\nexport interface QueryObserverBaseResult<\n TData = unknown,\n TError = DefaultError,\n> {\n /**\n * The last successfully resolved data for the query.\n * - Defaults to `undefined`.\n */\n data: TData | undefined\n /**\n * The timestamp for when the query most recently returned the `status` as `\"success\"`.\n */\n dataUpdatedAt: number\n /**\n * The error object for the query, if an error was thrown.\n * - Defaults to `null`.\n */\n error: TError | null\n /**\n * The timestamp for when the query most recently returned the `status` as `\"error\"`.\n */\n errorUpdatedAt: number\n /**\n * The failure count for the query.\n * - Incremented every time the query fails.\n * - Reset to `0` when the query succeeds.\n */\n failureCount: number\n /**\n * The failure reason for the query retry.\n * - Reset to `null` when the query succeeds.\n */\n failureReason: TError | null\n /**\n * The sum of all errors.\n */\n errorUpdateCount: number\n /**\n * A derived boolean from the `status` variable, provided for convenience.\n * - `true` if the query attempt resulted in an error.\n */\n isError: boolean\n /**\n * Will be `true` if the query has been fetched.\n */\n isFetched: boolean\n /**\n * Will be `true` if the query has been fetched after the component mounted.\n * - This property can be used to not show any previously cached data.\n */\n isFetchedAfterMount: boolean\n /**\n * A derived boolean from the `fetchStatus` variable, provided for convenience.\n * - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch.\n */\n isFetching: boolean\n /**\n * Is `true` whenever the first fetch for a query is in-flight.\n * - Is the same as `isFetching && isPending`.\n */\n isLoading: boolean\n /**\n * Will be `pending` if there's no cached data and no query attempt was finished yet.\n */\n isPending: boolean\n /**\n * Will be `true` if the query failed while fetching for the first time.\n */\n isLoadingError: boolean\n /**\n * @deprecated `isInitialLoading` is being deprecated in favor of `isLoading`\n * and will be removed in the next major version.\n */\n isInitialLoading: boolean\n /**\n * A derived boolean from the `fetchStatus` variable, provided for convenience.\n * - The query wanted to fetch, but has been `paused`.\n */\n isPaused: boolean\n /**\n * Will be `true` if the data shown is the placeholder data.\n */\n isPlaceholderData: boolean\n /**\n * Will be `true` if the query failed while refetching.\n */\n isRefetchError: boolean\n /**\n * Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`.\n * - Is the same as `isFetching && !isPending`.\n */\n isRefetching: boolean\n /**\n * Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`.\n */\n isStale: boolean\n /**\n * A derived boolean from the `status` variable, provided for convenience.\n * - `true` if the query has received a response with no errors and is ready to display its data.\n */\n isSuccess: boolean\n /**\n * A function to manually refetch the query.\n */\n refetch: (\n options?: RefetchOptions,\n ) => Promise<QueryObserverResult<TData, TError>>\n /**\n * The status of the query.\n * - Will be:\n * - `pending` if there's no cached data and no query attempt was finished yet.\n * - `error` if the query attempt resulted in an error.\n * - `success` if the query has received a response with no errors and is ready to display its data.\n */\n status: QueryStatus\n /**\n * The fetch status of the query.\n * - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch.\n * - `paused`: The query wanted to fetch, but has been `paused`.\n * - `idle`: The query is not fetching.\n * - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information.\n */\n fetchStatus: FetchStatus\n}\n\nexport interface QueryObserverPendingResult<\n TData = unknown,\n TError = DefaultError,\n> extends QueryObserverBaseResult<TData, TError> {\n data: undefined\n error: null\n isError: false\n isPending: true\n isLoadingError: false\n isRefetchError: false\n isSuccess: false\n status: 'pending'\n}\n\nexport interface QueryObserverLoadingResult<\n TData = unknown,\n TError = DefaultError,\n> extends QueryObserverBaseResult<TData, TError> {\n data: undefined\n error: null\n isError: false\n isPending: true\n isLoading: true\n isLoadingError: false\n isRefetchError: false\n isSuccess: false\n status: 'pending'\n}\n\nexport interface QueryObserverLoadingErrorResult<\n TData = unknown,\n TError = DefaultError,\n> extends QueryObserverBaseResult<TData, TError> {\n data: undefined\n error: TError\n isError: true\n isPending: false\n isLoading: false\n isLoadingError: true\n isRefetchError: false\n isSuccess: false\n status: 'error'\n}\n\nexport interface QueryObserverRefetchErrorResult<\n TData = unknown,\n TError = DefaultError,\n> extends QueryObserverBaseResult<TData, TError> {\n data: TData\n error: TError\n isError: true\n isPending: false\n isLoading: false\n isLoadingError: false\n isRefetchError: true\n isSuccess: false\n status: 'error'\n}\n\nexport interface QueryObserverSuccessResult<\n TData = unknown,\n TError = DefaultError,\n> extends QueryObserverBaseResult<TData, TError> {\n data: TData\n error: null\n isError: false\n isPending: false\n isLoading: false\n isLoadingError: false\n isRefetchError: false\n isSuccess: true\n status: 'success'\n}\n\nexport type DefinedQueryObserverResult<\n TData = unknown,\n TError = DefaultError,\n> =\n | QueryObserverRefetchErrorResult<TData, TError>\n | QueryObserverSuccessResult<TData, TError>\n\nexport type QueryObserverResult<TData = unknown, TError = DefaultError> =\n | DefinedQueryObserverResult<TData, TError>\n | QueryObserverLoadingErrorResult<TData, TError>\n | QueryObserverLoadingResult<TData, TError>\n | QueryObserverPendingResult<TData, TError>\n\nexport interface InfiniteQueryObserverBaseResult<\n TData = unknown,\n TError = DefaultError,\n> extends QueryObserverBaseResult<TData, TError> {\n fetchNextPage: (\n options?: FetchNextPageOptions,\n ) => Promise<InfiniteQueryObserverResult<TData, TError>>\n fetchPreviousPage: (\n options?: FetchPreviousPageOptions,\n ) => Promise<InfiniteQueryObserverResult<TData, TError>>\n hasNextPage: boolean\n hasPreviousPage: boolean\n isFetchingNextPage: boolean\n isFetchingPreviousPage: boolean\n}\n\nexport interface InfiniteQueryObserverPendingResult<\n TData = unknown,\n TError = DefaultError,\n> extends InfiniteQueryObserverBaseResult<TData, TError> {\n data: undefined\n error: null\n isError: false\n isPending: true\n isLoadingError: false\n isRefetchError: false\n isSuccess: false\n status: 'pending'\n}\n\nexport interface InfiniteQueryObserverLoadingResult<\n TData = unknown,\n TError = DefaultError,\n> extends InfiniteQueryObserverBaseResult<TData, TError> {\n data: undefined\n error: null\n isError: false\n isPending: true\n isLoading: true\n isLoadingError: false\n isRefetchError: false\n isSuccess: false\n status: 'pending'\n}\n\nexport interface InfiniteQueryObserverLoadingErrorResult<\n TData = unknown,\n TError = DefaultError,\n> extends InfiniteQueryObserverBaseResult<TData, TError> {\n data: undefined\n error: TError\n isError: true\n isPending: false\n isLoading: false\n isLoadingError: true\n isRefetchError: false\n isSuccess: false\n status: 'error'\n}\n\nexport interface InfiniteQueryObserverRefetchErrorResult<\n TData = unknown,\n TError = DefaultError,\n> extends InfiniteQueryObserverBaseResult<TData, TError> {\n data: TData\n error: TError\n isError: true\n isPending: false\n isLoading: false\n isLoadingError: false\n isRefetchError: true\n isSuccess: false\n status: 'error'\n}\n\nexport interface InfiniteQueryObserverSuccessResult<\n TData = unknown,\n TError = DefaultError,\n> extends InfiniteQueryObserverBaseResult<TData, TError> {\n data: TData\n error: null\n isError: false\n isPending: false\n isLoading: false\n isLoadingError: false\n isRefetchError: false\n isSuccess: true\n status: 'success'\n}\n\nexport type DefinedInfiniteQueryObserverResult<\n TData = unknown,\n TError = DefaultError,\n> =\n | InfiniteQueryObserverRefetchErrorResult<TData, TError>\n | InfiniteQueryObserverSuccessResult<TData, TError>\n\nexport type InfiniteQueryObserverResult<\n TData = unknown,\n TError = DefaultError,\n> =\n | DefinedInfiniteQueryObserverResult<TData, TError>\n | InfiniteQueryObserverLoadingErrorResult<TData, TError>\n | InfiniteQueryObserverLoadingResult<TData, TError>\n | InfiniteQueryObserverPendingResult<TData, TError>\n\nexport type MutationKey = ReadonlyArray<unknown>\n\nexport type MutationStatus = 'idle' | 'pending' | 'success' | 'error'\n\nexport type MutationScope = {\n id: string\n}\n\nexport type MutationMeta = Register extends {\n mutationMeta: infer TMutationMeta\n}\n ? TMutationMeta extends Record<string, unknown>\n ? TMutationMeta\n : Record<string, unknown>\n : Record<string, unknown>\n\nexport type MutationFunction<TData = unknown, TVariables = unknown> = (\n variables: TVariables,\n) => Promise<TData>\n\nexport interface MutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> {\n mutationFn?: MutationFunction<TData, TVariables>\n mutationKey?: MutationKey\n onMutate?: (\n variables: TVariables,\n ) => Promise<TContext | undefined> | TContext | undefined\n onSuccess?: (\n data: TData,\n variables: TVariables,\n context: TContext,\n ) => Promise<unknown> | unknown\n onError?: (\n error: TError,\n variables: TVariables,\n context: TContext | undefined,\n ) => Promise<unknown> | unknown\n onSettled?: (\n data: TData | undefined,\n error: TError | null,\n variables: TVariables,\n context: TContext | undefined,\n ) => Promise<unknown> | unknown\n retry?: RetryValue<TError>\n retryDelay?: RetryDelayValue<TError>\n networkMode?: NetworkMode\n gcTime?: number\n _defaulted?: boolean\n meta?: MutationMeta\n scope?: MutationScope\n}\n\nexport interface MutationObserverOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends MutationOptions<TData, TError, TVariables, TContext> {\n throwOnError?: boolean | ((error: TError) => boolean)\n}\n\nexport interface MutateOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> {\n onSuccess?: (data: TData, variables: TVariables, context: TContext) => void\n onError?: (\n error: TError,\n variables: TVariables,\n context: TContext | undefined,\n ) => void\n onSettled?: (\n data: TData | undefined,\n error: TError | null,\n variables: TVariables,\n context: TContext | undefined,\n ) => void\n}\n\nexport type MutateFunction<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> = (\n variables: TVariables,\n options?: MutateOptions<TData, TError, TVariables, TContext>,\n) => Promise<TData>\n\nexport interface MutationObserverBaseResult<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends MutationState<TData, TError, TVariables, TContext> {\n /**\n * The last successfully resolved data for the mutation.\n * - Defaults to `undefined`.\n */\n data: TData | undefined\n /**\n * The variables object passed to the `mutationFn`.\n * - Defaults to `undefined`.\n */\n variables: TVariables | undefined\n /**\n * The error object for the mutation, if an error was encountered.\n * - Defaults to `null`.\n */\n error: TError | null\n /**\n * A boolean variable derived from `status`.\n * - `true` if the last mutation attempt resulted in an error.\n */\n isError: boolean\n /**\n * A boolean variable derived from `status`.\n * - `true` if the mutation is in its initial state prior to executing.\n */\n isIdle: boolean\n /**\n * A boolean variable derived from `status`.\n * - `true` if the mutation is currently executing.\n */\n isPending: boolean\n /**\n * A boolean variable derived from `status`.\n * - `true` if the last mutation attempt was successful.\n */\n isSuccess: boolean\n /**\n * The status of the mutation.\n * - Will be:\n * - `idle` initial status prior to the mutation function executing.\n * - `pending` if the mutation is currently executing.\n * - `error` if the last mutation attempt resulted in an error.\n * - `success` if the last mutation attempt was successful.\n */\n status: MutationStatus\n /**\n * The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options.\n * @param variables - The variables object to pass to the `mutationFn`.\n * @param options.onSuccess - This function will fire when the mutation is successful and will be passed the mutation's result.\n * @param options.onError - This function will fire if the mutation encounters an error and will be passed the error.\n * @param options.onSettled - This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error.\n * @remarks\n * - If you make multiple requests, `onSuccess` will fire only after the latest call you've made.\n * - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored.\n */\n mutate: MutateFunction<TData, TError, TVariables, TContext>\n /**\n * A function to clean the mutation internal state (i.e., it resets the mutation to its initial state).\n */\n reset: () => void\n}\n\nexport interface MutationObserverIdleResult<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends MutationObserverBaseResult<TData, TError, TVariables, TContext> {\n data: undefined\n variables: undefined\n error: null\n isError: false\n isIdle: true\n isPending: false\n isSuccess: false\n status: 'idle'\n}\n\nexport interface MutationObserverLoadingResult<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends MutationObserverBaseResult<TData, TError, TVariables, TContext> {\n data: undefined\n variables: TVariables\n error: null\n isError: false\n isIdle: false\n isPending: true\n isSuccess: false\n status: 'pending'\n}\n\nexport interface MutationObserverErrorResult<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends MutationObserverBaseResult<TData, TError, TVariables, TContext> {\n data: undefined\n error: TError\n variables: TVariables\n isError: true\n isIdle: false\n isPending: false\n isSuccess: false\n status: 'error'\n}\n\nexport interface MutationObserverSuccessResult<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends MutationObserverBaseResult<TData, TError, TVariables, TContext> {\n data: TData\n error: null\n variables: TVariables\n isError: false\n isIdle: false\n isPending: false\n isSuccess: true\n status: 'success'\n}\n\nexport type MutationObserverResult<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> =\n | MutationObserverIdleResult<TData, TError, TVariables, TContext>\n | MutationObserverLoadingResult<TData, TError, TVariables, TContext>\n | MutationObserverErrorResult<TData, TError, TVariables, TContext>\n | MutationObserverSuccessResult<TData, TError, TVariables, TContext>\n\nexport interface QueryClientConfig {\n queryCache?: QueryCache\n mutationCache?: MutationCache\n defaultOptions?: DefaultOptions\n}\n\nexport interface DefaultOptions<TError = DefaultError> {\n queries?: OmitKeyof<\n QueryObserverOptions<unknown, TError>,\n 'suspense' | 'queryKey'\n >\n mutations?: MutationObserverOptions<unknown, TError, unknown, unknown>\n}\n\nexport interface CancelOptions {\n revert?: boolean\n silent?: boolean\n}\n\nexport interface SetDataOptions {\n updatedAt?: number\n}\n\nexport type NotifyEventType =\n | 'added'\n | 'removed'\n | 'updated'\n | 'observerAdded'\n | 'observerRemoved'\n | 'observerResultsUpdated'\n | 'observerOptionsUpdated'\n\nexport interface NotifyEvent {\n type: NotifyEventType\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/build/modern/types.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { aK as CancelOptions, v as DataTag, D as DefaultError, aJ as DefaultOptions, $ as DefaultedInfiniteQueryObserverOptions, Z as DefaultedQueryObserverOptions, ar as DefinedInfiniteQueryObserverResult, aj as DefinedQueryObserverResult, a1 as EnsureQueryDataOptions, a2 as FetchInfiniteQueryOptions, a9 as FetchNextPageOptions, aa as FetchPreviousPageOptions, a0 as FetchQueryOptions, ac as FetchStatus, B as GetNextPageParamFunction, G as GetPreviousPageParamFunction, E as InfiniteData, al as InfiniteQueryObserverBaseResult, ao as InfiniteQueryObserverLoadingErrorResult, an as InfiniteQueryObserverLoadingResult, _ as InfiniteQueryObserverOptions, am as InfiniteQueryObserverPendingResult, ap as InfiniteQueryObserverRefetchErrorResult, as as InfiniteQueryObserverResult, aq as InfiniteQueryObserverSuccessResult, T as InfiniteQueryPageParamsOptions, I as InitialDataFunction, L as InitialPageParam, a7 as InvalidateOptions, a5 as InvalidateQueryFilters, aB as MutateFunction, aA as MutateOptions, ax as MutationFunction, at as MutationKey, aw as MutationMeta, aC as MutationObserverBaseResult, aF as MutationObserverErrorResult, aD as MutationObserverIdleResult, aE as MutationObserverLoadingResult, az as MutationObserverOptions, aH as MutationObserverResult, aG as MutationObserverSuccessResult, ay as MutationOptions, av as MutationScope, au as MutationStatus, H as NetworkMode, N as NoInfer, aN as NotifyEvent, aM as NotifyEventType, J as NotifyOnChangeProps, O as OmitKeyof, Y as Optional, P as PlaceholderDataFunction, z as QueriesPlaceholderDataFunction, aI as QueryClientConfig, w as QueryFunction, y as QueryFunctionContext, t as QueryKey, A as QueryKeyHashFunction, F as QueryMeta, ad as QueryObserverBaseResult, ag as QueryObserverLoadingErrorResult, af as QueryObserverLoadingResult, W as QueryObserverOptions, ae as QueryObserverPendingResult, ah as QueryObserverRefetchErrorResult, ak as QueryObserverResult, ai as QueryObserverSuccessResult, K as QueryOptions, x as QueryPersister, ab as QueryStatus, a4 as RefetchOptions, a6 as RefetchQueryFilters, R as Register, a8 as ResetOptions, a3 as ResultOptions, aL as SetDataOptions, V as ThrowOnError, X as WithRequired, u as dataTagSymbol } from './types-
|
|
1
|
+
export { aK as CancelOptions, v as DataTag, D as DefaultError, aJ as DefaultOptions, $ as DefaultedInfiniteQueryObserverOptions, Z as DefaultedQueryObserverOptions, ar as DefinedInfiniteQueryObserverResult, aj as DefinedQueryObserverResult, a1 as EnsureQueryDataOptions, a2 as FetchInfiniteQueryOptions, a9 as FetchNextPageOptions, aa as FetchPreviousPageOptions, a0 as FetchQueryOptions, ac as FetchStatus, B as GetNextPageParamFunction, G as GetPreviousPageParamFunction, E as InfiniteData, al as InfiniteQueryObserverBaseResult, ao as InfiniteQueryObserverLoadingErrorResult, an as InfiniteQueryObserverLoadingResult, _ as InfiniteQueryObserverOptions, am as InfiniteQueryObserverPendingResult, ap as InfiniteQueryObserverRefetchErrorResult, as as InfiniteQueryObserverResult, aq as InfiniteQueryObserverSuccessResult, T as InfiniteQueryPageParamsOptions, I as InitialDataFunction, L as InitialPageParam, a7 as InvalidateOptions, a5 as InvalidateQueryFilters, aB as MutateFunction, aA as MutateOptions, ax as MutationFunction, at as MutationKey, aw as MutationMeta, aC as MutationObserverBaseResult, aF as MutationObserverErrorResult, aD as MutationObserverIdleResult, aE as MutationObserverLoadingResult, az as MutationObserverOptions, aH as MutationObserverResult, aG as MutationObserverSuccessResult, ay as MutationOptions, av as MutationScope, au as MutationStatus, H as NetworkMode, N as NoInfer, aN as NotifyEvent, aM as NotifyEventType, J as NotifyOnChangeProps, O as OmitKeyof, Y as Optional, P as PlaceholderDataFunction, z as QueriesPlaceholderDataFunction, aI as QueryClientConfig, w as QueryFunction, y as QueryFunctionContext, t as QueryKey, A as QueryKeyHashFunction, F as QueryMeta, ad as QueryObserverBaseResult, ag as QueryObserverLoadingErrorResult, af as QueryObserverLoadingResult, W as QueryObserverOptions, ae as QueryObserverPendingResult, ah as QueryObserverRefetchErrorResult, ak as QueryObserverResult, ai as QueryObserverSuccessResult, K as QueryOptions, x as QueryPersister, ab as QueryStatus, a4 as RefetchOptions, a6 as RefetchQueryFilters, R as Register, a8 as ResetOptions, a3 as ResultOptions, aL as SetDataOptions, V as ThrowOnError, X as WithRequired, u as dataTagSymbol } from './types-Ya7vXgfL.cjs';
|
|
2
2
|
import './removable.cjs';
|
|
3
3
|
import './subscribable.cjs';
|
package/build/modern/types.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { aK as CancelOptions, v as DataTag, D as DefaultError, aJ as DefaultOptions, $ as DefaultedInfiniteQueryObserverOptions, Z as DefaultedQueryObserverOptions, ar as DefinedInfiniteQueryObserverResult, aj as DefinedQueryObserverResult, a1 as EnsureQueryDataOptions, a2 as FetchInfiniteQueryOptions, a9 as FetchNextPageOptions, aa as FetchPreviousPageOptions, a0 as FetchQueryOptions, ac as FetchStatus, B as GetNextPageParamFunction, G as GetPreviousPageParamFunction, E as InfiniteData, al as InfiniteQueryObserverBaseResult, ao as InfiniteQueryObserverLoadingErrorResult, an as InfiniteQueryObserverLoadingResult, _ as InfiniteQueryObserverOptions, am as InfiniteQueryObserverPendingResult, ap as InfiniteQueryObserverRefetchErrorResult, as as InfiniteQueryObserverResult, aq as InfiniteQueryObserverSuccessResult, T as InfiniteQueryPageParamsOptions, I as InitialDataFunction, L as InitialPageParam, a7 as InvalidateOptions, a5 as InvalidateQueryFilters, aB as MutateFunction, aA as MutateOptions, ax as MutationFunction, at as MutationKey, aw as MutationMeta, aC as MutationObserverBaseResult, aF as MutationObserverErrorResult, aD as MutationObserverIdleResult, aE as MutationObserverLoadingResult, az as MutationObserverOptions, aH as MutationObserverResult, aG as MutationObserverSuccessResult, ay as MutationOptions, av as MutationScope, au as MutationStatus, H as NetworkMode, N as NoInfer, aN as NotifyEvent, aM as NotifyEventType, J as NotifyOnChangeProps, O as OmitKeyof, Y as Optional, P as PlaceholderDataFunction, z as QueriesPlaceholderDataFunction, aI as QueryClientConfig, w as QueryFunction, y as QueryFunctionContext, t as QueryKey, A as QueryKeyHashFunction, F as QueryMeta, ad as QueryObserverBaseResult, ag as QueryObserverLoadingErrorResult, af as QueryObserverLoadingResult, W as QueryObserverOptions, ae as QueryObserverPendingResult, ah as QueryObserverRefetchErrorResult, ak as QueryObserverResult, ai as QueryObserverSuccessResult, K as QueryOptions, x as QueryPersister, ab as QueryStatus, a4 as RefetchOptions, a6 as RefetchQueryFilters, R as Register, a8 as ResetOptions, a3 as ResultOptions, aL as SetDataOptions, V as ThrowOnError, X as WithRequired, u as dataTagSymbol } from './types-
|
|
1
|
+
export { aK as CancelOptions, v as DataTag, D as DefaultError, aJ as DefaultOptions, $ as DefaultedInfiniteQueryObserverOptions, Z as DefaultedQueryObserverOptions, ar as DefinedInfiniteQueryObserverResult, aj as DefinedQueryObserverResult, a1 as EnsureQueryDataOptions, a2 as FetchInfiniteQueryOptions, a9 as FetchNextPageOptions, aa as FetchPreviousPageOptions, a0 as FetchQueryOptions, ac as FetchStatus, B as GetNextPageParamFunction, G as GetPreviousPageParamFunction, E as InfiniteData, al as InfiniteQueryObserverBaseResult, ao as InfiniteQueryObserverLoadingErrorResult, an as InfiniteQueryObserverLoadingResult, _ as InfiniteQueryObserverOptions, am as InfiniteQueryObserverPendingResult, ap as InfiniteQueryObserverRefetchErrorResult, as as InfiniteQueryObserverResult, aq as InfiniteQueryObserverSuccessResult, T as InfiniteQueryPageParamsOptions, I as InitialDataFunction, L as InitialPageParam, a7 as InvalidateOptions, a5 as InvalidateQueryFilters, aB as MutateFunction, aA as MutateOptions, ax as MutationFunction, at as MutationKey, aw as MutationMeta, aC as MutationObserverBaseResult, aF as MutationObserverErrorResult, aD as MutationObserverIdleResult, aE as MutationObserverLoadingResult, az as MutationObserverOptions, aH as MutationObserverResult, aG as MutationObserverSuccessResult, ay as MutationOptions, av as MutationScope, au as MutationStatus, H as NetworkMode, N as NoInfer, aN as NotifyEvent, aM as NotifyEventType, J as NotifyOnChangeProps, O as OmitKeyof, Y as Optional, P as PlaceholderDataFunction, z as QueriesPlaceholderDataFunction, aI as QueryClientConfig, w as QueryFunction, y as QueryFunctionContext, t as QueryKey, A as QueryKeyHashFunction, F as QueryMeta, ad as QueryObserverBaseResult, ag as QueryObserverLoadingErrorResult, af as QueryObserverLoadingResult, W as QueryObserverOptions, ae as QueryObserverPendingResult, ah as QueryObserverRefetchErrorResult, ak as QueryObserverResult, ai as QueryObserverSuccessResult, K as QueryOptions, x as QueryPersister, ab as QueryStatus, a4 as RefetchOptions, a6 as RefetchQueryFilters, R as Register, a8 as ResetOptions, a3 as ResultOptions, aL as SetDataOptions, V as ThrowOnError, X as WithRequired, u as dataTagSymbol } from './types-Br-AgPmc.js';
|
|
2
2
|
import './removable.js';
|
|
3
3
|
import './subscribable.js';
|
package/build/modern/utils.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { g as MutationFilters, j as QueryFilters, aY as QueryTypeFilter, S as SkipToken, U as Updater, b8 as addToEnd, b9 as addToStart, a_ as functionalUpdate, h as hashKey, b1 as hashQueryKeyByOptions, b4 as isPlainArray, b5 as isPlainObject, i as isServer, a$ as isValidTimeout, k as keepPreviousData, f as matchMutation, m as matchQuery, aZ as noop, b2 as partialMatchKey, b7 as replaceData, r as replaceEqualDeep, b3 as shallowEqualObjects, s as skipToken, b6 as sleep, b0 as timeUntilStale } from './types-
|
|
1
|
+
export { g as MutationFilters, j as QueryFilters, aY as QueryTypeFilter, S as SkipToken, U as Updater, b8 as addToEnd, b9 as addToStart, a_ as functionalUpdate, h as hashKey, b1 as hashQueryKeyByOptions, b4 as isPlainArray, b5 as isPlainObject, i as isServer, a$ as isValidTimeout, k as keepPreviousData, f as matchMutation, m as matchQuery, aZ as noop, b2 as partialMatchKey, b7 as replaceData, r as replaceEqualDeep, b3 as shallowEqualObjects, s as skipToken, b6 as sleep, b0 as timeUntilStale } from './types-Ya7vXgfL.cjs';
|
|
2
2
|
import './removable.cjs';
|
|
3
3
|
import './subscribable.cjs';
|
package/build/modern/utils.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { g as MutationFilters, j as QueryFilters, aY as QueryTypeFilter, S as SkipToken, U as Updater, b8 as addToEnd, b9 as addToStart, a_ as functionalUpdate, h as hashKey, b1 as hashQueryKeyByOptions, b4 as isPlainArray, b5 as isPlainObject, i as isServer, a$ as isValidTimeout, k as keepPreviousData, f as matchMutation, m as matchQuery, aZ as noop, b2 as partialMatchKey, b7 as replaceData, r as replaceEqualDeep, b3 as shallowEqualObjects, s as skipToken, b6 as sleep, b0 as timeUntilStale } from './types-
|
|
1
|
+
export { g as MutationFilters, j as QueryFilters, aY as QueryTypeFilter, S as SkipToken, U as Updater, b8 as addToEnd, b9 as addToStart, a_ as functionalUpdate, h as hashKey, b1 as hashQueryKeyByOptions, b4 as isPlainArray, b5 as isPlainObject, i as isServer, a$ as isValidTimeout, k as keepPreviousData, f as matchMutation, m as matchQuery, aZ as noop, b2 as partialMatchKey, b7 as replaceData, r as replaceEqualDeep, b3 as shallowEqualObjects, s as skipToken, b6 as sleep, b0 as timeUntilStale } from './types-Br-AgPmc.js';
|
|
2
2
|
import './removable.js';
|
|
3
3
|
import './subscribable.js';
|
package/package.json
CHANGED
package/src/types.ts
CHANGED
|
@@ -500,35 +500,124 @@ export interface QueryObserverBaseResult<
|
|
|
500
500
|
TData = unknown,
|
|
501
501
|
TError = DefaultError,
|
|
502
502
|
> {
|
|
503
|
+
/**
|
|
504
|
+
* The last successfully resolved data for the query.
|
|
505
|
+
* - Defaults to `undefined`.
|
|
506
|
+
*/
|
|
503
507
|
data: TData | undefined
|
|
508
|
+
/**
|
|
509
|
+
* The timestamp for when the query most recently returned the `status` as `"success"`.
|
|
510
|
+
*/
|
|
504
511
|
dataUpdatedAt: number
|
|
512
|
+
/**
|
|
513
|
+
* The error object for the query, if an error was thrown.
|
|
514
|
+
* - Defaults to `null`.
|
|
515
|
+
*/
|
|
505
516
|
error: TError | null
|
|
517
|
+
/**
|
|
518
|
+
* The timestamp for when the query most recently returned the `status` as `"error"`.
|
|
519
|
+
*/
|
|
506
520
|
errorUpdatedAt: number
|
|
521
|
+
/**
|
|
522
|
+
* The failure count for the query.
|
|
523
|
+
* - Incremented every time the query fails.
|
|
524
|
+
* - Reset to `0` when the query succeeds.
|
|
525
|
+
*/
|
|
507
526
|
failureCount: number
|
|
527
|
+
/**
|
|
528
|
+
* The failure reason for the query retry.
|
|
529
|
+
* - Reset to `null` when the query succeeds.
|
|
530
|
+
*/
|
|
508
531
|
failureReason: TError | null
|
|
532
|
+
/**
|
|
533
|
+
* The sum of all errors.
|
|
534
|
+
*/
|
|
509
535
|
errorUpdateCount: number
|
|
536
|
+
/**
|
|
537
|
+
* A derived boolean from the `status` variable, provided for convenience.
|
|
538
|
+
* - `true` if the query attempt resulted in an error.
|
|
539
|
+
*/
|
|
510
540
|
isError: boolean
|
|
541
|
+
/**
|
|
542
|
+
* Will be `true` if the query has been fetched.
|
|
543
|
+
*/
|
|
511
544
|
isFetched: boolean
|
|
545
|
+
/**
|
|
546
|
+
* Will be `true` if the query has been fetched after the component mounted.
|
|
547
|
+
* - This property can be used to not show any previously cached data.
|
|
548
|
+
*/
|
|
512
549
|
isFetchedAfterMount: boolean
|
|
550
|
+
/**
|
|
551
|
+
* A derived boolean from the `fetchStatus` variable, provided for convenience.
|
|
552
|
+
* - `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch.
|
|
553
|
+
*/
|
|
513
554
|
isFetching: boolean
|
|
555
|
+
/**
|
|
556
|
+
* Is `true` whenever the first fetch for a query is in-flight.
|
|
557
|
+
* - Is the same as `isFetching && isPending`.
|
|
558
|
+
*/
|
|
514
559
|
isLoading: boolean
|
|
560
|
+
/**
|
|
561
|
+
* Will be `pending` if there's no cached data and no query attempt was finished yet.
|
|
562
|
+
*/
|
|
515
563
|
isPending: boolean
|
|
564
|
+
/**
|
|
565
|
+
* Will be `true` if the query failed while fetching for the first time.
|
|
566
|
+
*/
|
|
516
567
|
isLoadingError: boolean
|
|
517
568
|
/**
|
|
518
|
-
* @deprecated isInitialLoading is being deprecated in favor of isLoading
|
|
569
|
+
* @deprecated `isInitialLoading` is being deprecated in favor of `isLoading`
|
|
519
570
|
* and will be removed in the next major version.
|
|
520
571
|
*/
|
|
521
572
|
isInitialLoading: boolean
|
|
573
|
+
/**
|
|
574
|
+
* A derived boolean from the `fetchStatus` variable, provided for convenience.
|
|
575
|
+
* - The query wanted to fetch, but has been `paused`.
|
|
576
|
+
*/
|
|
522
577
|
isPaused: boolean
|
|
578
|
+
/**
|
|
579
|
+
* Will be `true` if the data shown is the placeholder data.
|
|
580
|
+
*/
|
|
523
581
|
isPlaceholderData: boolean
|
|
582
|
+
/**
|
|
583
|
+
* Will be `true` if the query failed while refetching.
|
|
584
|
+
*/
|
|
524
585
|
isRefetchError: boolean
|
|
586
|
+
/**
|
|
587
|
+
* Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`.
|
|
588
|
+
* - Is the same as `isFetching && !isPending`.
|
|
589
|
+
*/
|
|
525
590
|
isRefetching: boolean
|
|
591
|
+
/**
|
|
592
|
+
* Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`.
|
|
593
|
+
*/
|
|
526
594
|
isStale: boolean
|
|
595
|
+
/**
|
|
596
|
+
* A derived boolean from the `status` variable, provided for convenience.
|
|
597
|
+
* - `true` if the query has received a response with no errors and is ready to display its data.
|
|
598
|
+
*/
|
|
527
599
|
isSuccess: boolean
|
|
600
|
+
/**
|
|
601
|
+
* A function to manually refetch the query.
|
|
602
|
+
*/
|
|
528
603
|
refetch: (
|
|
529
604
|
options?: RefetchOptions,
|
|
530
605
|
) => Promise<QueryObserverResult<TData, TError>>
|
|
606
|
+
/**
|
|
607
|
+
* The status of the query.
|
|
608
|
+
* - Will be:
|
|
609
|
+
* - `pending` if there's no cached data and no query attempt was finished yet.
|
|
610
|
+
* - `error` if the query attempt resulted in an error.
|
|
611
|
+
* - `success` if the query has received a response with no errors and is ready to display its data.
|
|
612
|
+
*/
|
|
531
613
|
status: QueryStatus
|
|
614
|
+
/**
|
|
615
|
+
* The fetch status of the query.
|
|
616
|
+
* - `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch.
|
|
617
|
+
* - `paused`: The query wanted to fetch, but has been `paused`.
|
|
618
|
+
* - `idle`: The query is not fetching.
|
|
619
|
+
* - See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information.
|
|
620
|
+
*/
|
|
532
621
|
fetchStatus: FetchStatus
|
|
533
622
|
}
|
|
534
623
|
|
|
@@ -826,11 +915,64 @@ export interface MutationObserverBaseResult<
|
|
|
826
915
|
TVariables = void,
|
|
827
916
|
TContext = unknown,
|
|
828
917
|
> extends MutationState<TData, TError, TVariables, TContext> {
|
|
918
|
+
/**
|
|
919
|
+
* The last successfully resolved data for the mutation.
|
|
920
|
+
* - Defaults to `undefined`.
|
|
921
|
+
*/
|
|
922
|
+
data: TData | undefined
|
|
923
|
+
/**
|
|
924
|
+
* The variables object passed to the `mutationFn`.
|
|
925
|
+
* - Defaults to `undefined`.
|
|
926
|
+
*/
|
|
927
|
+
variables: TVariables | undefined
|
|
928
|
+
/**
|
|
929
|
+
* The error object for the mutation, if an error was encountered.
|
|
930
|
+
* - Defaults to `null`.
|
|
931
|
+
*/
|
|
932
|
+
error: TError | null
|
|
933
|
+
/**
|
|
934
|
+
* A boolean variable derived from `status`.
|
|
935
|
+
* - `true` if the last mutation attempt resulted in an error.
|
|
936
|
+
*/
|
|
829
937
|
isError: boolean
|
|
938
|
+
/**
|
|
939
|
+
* A boolean variable derived from `status`.
|
|
940
|
+
* - `true` if the mutation is in its initial state prior to executing.
|
|
941
|
+
*/
|
|
830
942
|
isIdle: boolean
|
|
943
|
+
/**
|
|
944
|
+
* A boolean variable derived from `status`.
|
|
945
|
+
* - `true` if the mutation is currently executing.
|
|
946
|
+
*/
|
|
831
947
|
isPending: boolean
|
|
948
|
+
/**
|
|
949
|
+
* A boolean variable derived from `status`.
|
|
950
|
+
* - `true` if the last mutation attempt was successful.
|
|
951
|
+
*/
|
|
832
952
|
isSuccess: boolean
|
|
953
|
+
/**
|
|
954
|
+
* The status of the mutation.
|
|
955
|
+
* - Will be:
|
|
956
|
+
* - `idle` initial status prior to the mutation function executing.
|
|
957
|
+
* - `pending` if the mutation is currently executing.
|
|
958
|
+
* - `error` if the last mutation attempt resulted in an error.
|
|
959
|
+
* - `success` if the last mutation attempt was successful.
|
|
960
|
+
*/
|
|
961
|
+
status: MutationStatus
|
|
962
|
+
/**
|
|
963
|
+
* The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options.
|
|
964
|
+
* @param variables - The variables object to pass to the `mutationFn`.
|
|
965
|
+
* @param options.onSuccess - This function will fire when the mutation is successful and will be passed the mutation's result.
|
|
966
|
+
* @param options.onError - This function will fire if the mutation encounters an error and will be passed the error.
|
|
967
|
+
* @param options.onSettled - This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error.
|
|
968
|
+
* @remarks
|
|
969
|
+
* - If you make multiple requests, `onSuccess` will fire only after the latest call you've made.
|
|
970
|
+
* - All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored.
|
|
971
|
+
*/
|
|
833
972
|
mutate: MutateFunction<TData, TError, TVariables, TContext>
|
|
973
|
+
/**
|
|
974
|
+
* A function to clean the mutation internal state (i.e., it resets the mutation to its initial state).
|
|
975
|
+
*/
|
|
834
976
|
reset: () => void
|
|
835
977
|
}
|
|
836
978
|
|