import { Trie } from "@wry/trie";
import type { DocumentNode } from "graphql";
import { OperationTypeNode } from "graphql";
import { Observable } from "rxjs";
import type { ApolloCache, Cache } from "@apollo/client/cache";
import type { Incremental } from "@apollo/client/incremental";
import type { FetchResult } from "@apollo/client/link";
import type { LocalState } from "@apollo/client/local-state";
import type { MaybeMasked } from "@apollo/client/masking";
import { DocumentTransform } from "@apollo/client/utilities";
import type { ApolloClient, ApolloClientOptions, DefaultOptions } from "./ApolloClient.js";
import { NetworkStatus } from "./networkStatus.js";
import { ObservableQuery } from "./ObservableQuery.js";
import type { DefaultContext, InternalRefetchQueriesInclude, InternalRefetchQueriesMap, InternalRefetchQueriesOptions, MutateResult, OperationVariables, QueryNotification, QueryResult, SubscribeResult, SubscriptionObservable } from "./types.js";
import type { ErrorPolicy, MutationFetchPolicy, MutationOptions, QueryOptions, SubscriptionOptions, WatchQueryFetchPolicy, WatchQueryOptions } from "./watchQueryOptions.js";
interface MutationStoreValue {
    mutation: DocumentNode;
    variables: Record<string, any>;
    loading: boolean;
    error: Error | null;
}
interface TransformCacheEntry {
    hasClientExports: boolean;
    hasForcedResolvers: boolean;
    hasNonreactiveDirective: boolean;
    hasIncrementalDirective: boolean;
    nonReactiveQuery: DocumentNode;
    clientQuery: DocumentNode | null;
    serverQuery: DocumentNode | null;
    defaultVars: OperationVariables;
    asQuery: DocumentNode;
    operationType: OperationTypeNode | undefined;
    violation?: Error | undefined;
}
interface MaskFragmentOptions<TData> {
    fragment: DocumentNode;
    data: TData;
    fragmentName?: string;
}
interface MaskOperationOptions<TData> {
    document: DocumentNode;
    data: TData;
    /**
     * Can be used to identify the cause to prevent warning for the same cause twice.
     * This would be an object like e.g. an `ObervableQuery`.
     * If the `cause` is not provided, we will warn every time.
     */
    cause?: object;
    fetchPolicy?: WatchQueryFetchPolicy;
}
interface QueryManagerOptions {
    client: ApolloClient;
    clientOptions: ApolloClientOptions;
    defaultOptions: DefaultOptions;
    documentTransform: DocumentTransform | null | undefined;
    queryDeduplication: boolean;
    onBroadcast: undefined | (() => void);
    ssrMode: boolean;
    assumeImmutableResults: boolean;
    defaultContext: Partial<DefaultContext> | undefined;
    dataMasking: boolean;
    localState: LocalState | undefined;
    incrementalHandler: Incremental.Handler;
}
export declare class QueryManager {
    defaultOptions: DefaultOptions;
    readonly client: ApolloClient;
    /**
     * The options that were passed to the ApolloClient constructor.
     */
    readonly clientOptions: ApolloClientOptions;
    readonly assumeImmutableResults: boolean;
    readonly documentTransform: DocumentTransform;
    readonly ssrMode: boolean;
    readonly defaultContext: Partial<DefaultContext>;
    readonly dataMasking: boolean;
    readonly incrementalHandler: Incremental.Handler;
    localState: LocalState | undefined;
    private queryDeduplication;
    /**
     * Whether to prioritize cache values over network results when
     * `fetchObservableWithInfo` is called.
     * This will essentially turn a `"network-only"` or `"cache-and-network"`
     * fetchPolicy into a `"cache-first"` fetchPolicy, but without influencing
     * the `fetchPolicy` of the `ObservableQuery`.
     *
     * This can e.g. be used to prioritize the cache during the first render after
     * SSR.
     */
    prioritizeCacheValues: boolean;
    private onBroadcast?;
    mutationStore?: {
        [mutationId: string]: MutationStoreValue;
    };
    /**
     * All ObservableQueries that currently have at least one subscriber.
     */
    obsQueries: Set<ObservableQuery<any, any>>;
    protected fetchCancelFns: Map<string, (error: any) => any>;
    constructor(options: QueryManagerOptions);
    get link(): import("@apollo/client/link").ApolloLink;
    get cache(): ApolloCache;
    /**
     * Call this method to terminate any active query processes, making it safe
     * to dispose of this QueryManager instance.
     */
    stop(): void;
    private cancelPendingFetches;
    mutate<TData, TVariables extends OperationVariables, TCache extends ApolloCache>({ mutation, variables, optimisticResponse, updateQueries, refetchQueries, awaitRefetchQueries, update: updateWithProxyFn, onQueryUpdated, fetchPolicy, errorPolicy, keepRootFields, context, }: MutationOptions<TData, TVariables, TCache> & {
        errorPolicy: ErrorPolicy;
        fetchPolicy: MutationFetchPolicy;
    }): Promise<MutateResult<MaybeMasked<TData>>>;
    fetchQuery<TData, TVars extends OperationVariables>(options: WatchQueryOptions<TVars, TData>, networkStatus?: NetworkStatus): Promise<QueryResult<TData>>;
    transform(document: DocumentNode): DocumentNode;
    private transformCache;
    getDocumentInfo(document: DocumentNode): TransformCacheEntry;
    getVariables<TVariables>(document: DocumentNode, variables?: TVariables): TVariables;
    watchQuery<T, TVariables extends OperationVariables = OperationVariables>(options: WatchQueryOptions<TVariables, T>): ObservableQuery<T, TVariables>;
    query<TData, TVars extends OperationVariables = OperationVariables>(options: QueryOptions<TVars, TData>): Promise<QueryResult<MaybeMasked<TData>>>;
    private requestIdCounter;
    generateRequestId(): number;
    clearStore(options?: Cache.ResetOptions): Promise<void>;
    getObservableQueries(include?: InternalRefetchQueriesInclude): Set<ObservableQuery<any, OperationVariables>>;
    refetchObservableQueries(includeStandby?: boolean): Promise<QueryResult<any>[]>;
    startGraphQLSubscription<TData = unknown>(options: SubscriptionOptions): SubscriptionObservable<SubscribeResult<TData>>;
    broadcastQueries(): void;
    protected inFlightLinkObservables: Trie<{
        observable?: Observable<FetchResult<any>>;
        restart?: () => void;
    }>;
    private getObservableFromLink;
    private getResultsFromLink;
    fetchObservableWithInfo<TData, TVars extends OperationVariables>(options: WatchQueryOptions<TVars, TData>, { networkStatus, query, fetchQueryOperator, onCacheHit, observableQuery, }: {
        networkStatus?: NetworkStatus;
        query?: DocumentNode;
        fetchQueryOperator?: <T>(source: Observable<T>) => Observable<T>;
        onCacheHit?: () => void;
        observableQuery?: ObservableQuery<TData, TVars> | undefined;
    }): ObservableAndInfo<TData>;
    refetchQueries<TResult>({ updateCache, include, optimistic, removeOptimistic, onQueryUpdated, }: InternalRefetchQueriesOptions<ApolloCache, TResult>): InternalRefetchQueriesMap<TResult>;
    private noCacheWarningsByCause;
    maskOperation<TData = unknown>(options: MaskOperationOptions<TData>): MaybeMasked<TData>;
    maskFragment<TData = unknown>(options: MaskFragmentOptions<TData>): TData;
    private fetchQueryByPolicy;
}
interface ObservableAndInfo<TData> {
    fromLink: boolean;
    observable: Observable<QueryNotification.Value<TData>>;
}
export {};
//# sourceMappingURL=QueryManager.d.ts.map
