import { QueryKey, UseMutationResult } from '@tanstack/react-query'; export type MessageResolver = string | ((ctx: { data?: TData; error?: TError; variables: TVariables; }) => string | undefined); export interface RealisticMutationOptions { /** Primary query key whose cache is optimistically mutated + later invalidated. */ queryKey: QueryKey; /** The network call. */ mutationFn: (variables: TVariables) => Promise; /** Transform the cached data into its optimistic shape. Called inside onMutate. */ applyOptimistic?: (cache: TCache | undefined, variables: TVariables) => TCache | undefined; /** Additional query keys to invalidate in onSettled (e.g. related lists). */ invalidateKeys?: ReadonlyArray; /** Toast fired in onSettled on success. */ onSuccessMessage?: MessageResolver; /** Toast fired in onError. Receives the raw error for contextual description. */ onErrorMessage?: MessageResolver; /** Escape hatch: extra onSuccess behavior (e.g. navigate, focus, open a dialog). */ onSuccess?: (data: TData, variables: TVariables) => void; /** Escape hatch: extra onError behavior (e.g. re-open a closed dialog). */ onError?: (error: TError, variables: TVariables, snapshot: TCache | undefined) => void; } interface Context { snapshot: TCache | undefined; } export declare function useRealisticMutation(options: RealisticMutationOptions): UseMutationResult>; export {}; //# sourceMappingURL=useRealisticMutation.d.ts.map