import { Synnax as Client } from '@synnaxlabs/client';
import { destructor } from '@synnaxlabs/x';
import { base } from './base';
import { Result } from './result';
import { state } from '../state';
export interface RetrieveParams<Query extends base.Shape, Store extends base.Store, AllowDisconnected extends boolean = false> {
    client: AllowDisconnected extends true ? Client | null : Client;
    query: Query;
    store: Store;
}
export interface RetrieveMountListenersParams<Query extends base.Shape, Data extends base.Shape, Store extends base.Store, AllowDisconnected extends boolean = false> extends RetrieveParams<Query, Store, AllowDisconnected> {
    onChange: state.Setter<Data | undefined>;
}
export interface CreateRetrieveParams<Query extends base.Shape, Data extends base.Shape, Store extends base.Store, AllowDisconnected extends boolean = false> {
    name: string;
    retrieve: (Params: RetrieveParams<Query, Store, AllowDisconnected>) => Promise<Data>;
    mountListeners?: (Params: RetrieveMountListenersParams<Query, Data, Store, AllowDisconnected>) => destructor.Destructor | destructor.Destructor[];
    allowDisconnected?: AllowDisconnected;
}
export interface BeforeRetrieveParams<Query extends base.Shape> {
    query: Query;
}
export interface UseObservableBaseRetrieveParams<Query extends base.Shape, Data extends state.State> {
    addStatusOnFailure?: boolean;
    beforeRetrieve?: (Params: BeforeRetrieveParams<Query>) => Data | boolean;
    onChange: (result: state.SetArg<Result<Data>>, query: Query) => void;
    scope?: string;
}
export interface UseRetrieveObservableParams<Query extends base.Shape, Data extends state.State> extends Omit<UseObservableBaseRetrieveParams<Query, Data>, "onChange"> {
    onChange: (result: Result<Data>, query: Query) => void;
}
export interface UseRetrieveObservableReturn<Query extends base.Shape> {
    retrieve: (query: state.SetArg<Query, Partial<Query>>, options?: base.FetchOptions) => void;
    retrieveAsync: (query: state.SetArg<Query, Partial<Query>>, options?: base.FetchOptions) => Promise<void>;
}
export type UseRetrieveStatefulReturn<Query extends base.Shape, Data extends state.State> = Result<Data> & UseRetrieveObservableReturn<Query>;
export interface UseDirectRetrieveParams<Query extends base.Shape, Data extends state.State> extends Pick<UseObservableBaseRetrieveParams<Query, Data>, "scope" | "beforeRetrieve" | "addStatusOnFailure"> {
    query: Query;
}
export type UseDirectRetrieveReturn<Data extends state.State> = Result<Data>;
export interface UseRetrieveEffectParams<Query extends base.Shape, Data extends state.State> {
    scope?: string;
    onChange?: (result: Result<Data>, query: Query) => void;
    query?: Query;
}
export interface UseRetrieve<Query extends base.Shape, Data extends state.State> {
    (params: Query, opts?: Pick<UseDirectRetrieveParams<Query, Data>, "beforeRetrieve" | "addStatusOnFailure">): UseDirectRetrieveReturn<Data>;
}
export interface UseRetrieveEffect<Query extends base.Shape, Data extends state.State> {
    (params: UseRetrieveEffectParams<Query, Data>): void;
}
export interface UseRetrieveStateful<Query extends base.Shape, Data extends state.State> {
    (): UseRetrieveStatefulReturn<Query, Data>;
}
export interface UseRetrieveObservable<Query extends base.Shape, Data extends state.State> {
    (params: UseRetrieveObservableParams<Query, Data>): UseRetrieveObservableReturn<Query>;
}
export interface CreateRetrieveReturn<Query extends base.Shape, Data extends state.State> {
    useRetrieve: UseRetrieve<Query, Data>;
    useRetrieveEffect: UseRetrieveEffect<Query, Data>;
    useRetrieveStateful: UseRetrieveStateful<Query, Data>;
    useRetrieveObservable: UseRetrieveObservable<Query, Data>;
}
export declare const useObservableRetrieve: <Query extends base.Shape, Data extends state.State, ScopedStore extends base.Store, AllowDisconnected extends boolean = false>({ onChange, ...restParams }: UseRetrieveObservableParams<Query, Data> & CreateRetrieveParams<Query, Data, ScopedStore, AllowDisconnected>) => UseRetrieveObservableReturn<Query>;
export declare const createRetrieve: <Query extends base.Shape, Data extends state.State, ScopedStore extends base.Store = {}, AllowDisconnected extends boolean = false>(createParams: CreateRetrieveParams<Query, Data, ScopedStore, AllowDisconnected>) => CreateRetrieveReturn<Query, Data>;
//# sourceMappingURL=retrieve.d.ts.map