import { Mutation } from './mutation'; import { Action, MutationInfo, MutationInfoOptions, MutationStatus } from './mutationInfo'; import { QueryClient } from './queryClient'; import { DeepPartial, NotifyEvent } from './typeUtils'; export interface MutationCache extends ReturnType { } export interface MutationCacheConfig { onSuccess?: (data: unknown, variables: unknown, mutationInfo: MutationInfo) => Promise | unknown; onError?: (error: unknown, variables: unknown, mutationInfo: MutationInfo) => Promise | unknown; onSettled?: (data: unknown, error: unknown | null, variables: unknown, mutationInfo: MutationInfo) => Promise | unknown; } interface NotifyEventMutationAdded extends NotifyEvent { type: 'added'; mutationInfo: MutationInfo; } interface NotifyEventMutationRemoved extends NotifyEvent { type: 'removed'; mutationInfo: MutationInfo; } interface NotifyEventMutationUpdated extends NotifyEvent { type: 'updated'; mutationInfo: MutationInfo; action: Action; } export type MutationCacheNotifyEvent = NotifyEventMutationAdded | NotifyEventMutationRemoved | NotifyEventMutationUpdated; export type MutationCacheListener = (event: MutationCacheNotifyEvent) => void; export declare const createMutationCache: (config?: MutationCacheConfig) => { build: (client: QueryClient, options: MutationInfoOptions) => MutationInfo; remove: (mutationInfo: MutationInfo) => void; clear: () => void; getAll: () => MutationInfo[]; find: (filters: MutationInfoFilters) => MutationInfo | undefined; findAll: (filters?: MutationInfoFilters) => MutationInfo[]; subscribe: { (filters: MutationInfoFilters, listener: MutationCacheListener): () => void; (listener: MutationCacheListener): () => void; }; notify: (event: MutationCacheNotifyEvent) => void; config: MutationCacheConfig; readonly lastUpdated: number; }; export interface MutationInfoFilters { /** * Include mutations matching this predicate function */ predicate?: (mutationInfo: MutationInfo) => boolean; /** * Include mutations matching this mutation key */ mutation?: Mutation; /** * Filter by mutation status */ status?: MutationStatus; /** * Filter by mutation variables */ variables?: DeepPartial; /** * Match mutation key exactly */ exact?: boolean; } export {};