import { PrimitiveQuery } from './primitiveQuery'; import { QueryClient } from './queryClient'; import { Action, FetchStatus, QueryInfo, QueryInfoOptions, QueryInfoState } from './queryInfo'; import type { DeepPartial, NotifyEvent, WithRequired } from './typeUtils'; export interface QueryCache extends ReturnType { } interface NotifyEventQueryAdded extends NotifyEvent { type: 'added'; queryInfo: QueryInfo; } interface NotifyEventQueryRemoved extends NotifyEvent { type: 'removed'; queryInfo: QueryInfo; } export interface NotifyEventQueryUpdated extends NotifyEvent { type: 'updated'; queryInfo: QueryInfo; action: Action; } export type QueryCacheNotifyEvent = NotifyEventQueryAdded | NotifyEventQueryRemoved | NotifyEventQueryUpdated; export interface QueryStore { has: (queryKey: string) => boolean; set: (queryKey: string, queryInfo: QueryInfo) => void; get: (queryKey: string) => QueryInfo | undefined; delete: (queryKey: string) => void; values: () => IterableIterator>; } type QueryCacheListeners = (event: QueryCacheNotifyEvent) => void; export declare const createQueryCache: (config?: { onError?: ((error: Error, queryInfo: QueryInfo) => void) | undefined; onSuccess?: ((data: unknown, query: QueryInfo) => void) | undefined; onSettled?: ((data: unknown, error: Error, query: QueryInfo) => void) | undefined; createStore?: (() => QueryStore) | undefined; }) => { build: (client: QueryClient, options: QueryInfoOptions, state?: QueryInfoState | undefined) => QueryInfo; getAll: () => QueryInfo[]; find: (filters: WithRequired, "query">) => QueryInfo | undefined; findAll: (filters?: QueryInfoFilters) => QueryInfo[]; remove: (queryInfo: QueryInfo) => void; get: (queryHash: string) => QueryInfo | undefined; onFocus: () => void; onOnline: () => void; subscribe: { (filters: QueryInfoFilters, listener: QueryCacheListeners): () => void; (listener: QueryCacheListeners): () => void; }; notify: (event: QueryCacheNotifyEvent) => void; clear: () => void; config: { onError?: ((error: Error, queryInfo: QueryInfo) => void) | undefined; onSuccess?: ((data: unknown, query: QueryInfo) => void) | undefined; onSettled?: ((data: unknown, error: Error, query: QueryInfo) => void) | undefined; createStore?: (() => QueryStore) | undefined; }; readonly lastUpdated: number; }; export type QueryInfoTypeFilter = 'all' | 'active' | 'inactive'; export interface QueryInfoFilters { /** * Filter to active queries, inactive queries or all queries */ type?: QueryInfoTypeFilter; /** * Match query key exactly */ exact?: boolean; /** * Include queries matching this predicate function */ predicate?: (queryInfo: QueryInfo) => boolean; query?: PrimitiveQuery; variables?: DeepPartial; fetchStatus?: FetchStatus; stale?: boolean; } export {};