import { ResultOf, TypedDocumentNode, VariablesOf } from '@graphql-typed-document-node/core';
import { ModelWithId } from '@parlor/components/select';
import { ApolloClientService } from '../facades/apollo-client-service';
import { Documents } from '../types';
import { CacheUpdateOptions, HasOneRelationsOf, ICrudService, IDocuments, InputAndRelations, MutationOptionsWithoutMutation, ServiceLazyQueryHookOptions, ServiceMutationHookOptions, ServiceQueryHookOptions } from './crud-service.types';
export declare abstract class CRUDService<Model extends ModelWithId> {
    protected client: ApolloClientService;
    constructor(client: ApolloClientService);
    protected hasOneModels?: ICrudService<Model>['hasOneModels'];
    protected hasManyModels?: ICrudService<Model>['hasManyModels'];
    documents: Partial<IDocuments>;
    additionalDocuments: Record<string, TypedDocumentNode>;
    get __typename(): string;
    getModelFromCache<T = Model>(id: string, typename?: string): T;
    protected setDocument: <K extends keyof IDocuments, T extends IDocuments[K]>(key: K, document: T) => void;
    protected _hasOneModelTransformer: (key: HasOneRelationsOf<Model>, value: ModelWithId) => {
        parentMilestoneId: string;
    } | {
        [x: string]: string;
        parentMilestoneId?: undefined;
    };
    protected _useCreate: <T extends Documents.Create>(document: T) => (options?: CacheUpdateOptions<ServiceMutationHookOptions<T>>) => [(payload: InputAndRelations<T, Model>) => Promise<ResultOf<T>["createOne"]>, import("@apollo/client").MutationResult<{
        createOne: ModelWithId;
    }>];
    protected _create: ICrudService<Model>['create'];
    protected updateOptionsWithOptimisticResponse<T extends Documents.Update>(options: MutationOptionsWithoutMutation<T>, id: string, input: unknown): MutationOptionsWithoutMutation<T>;
    protected _update: ICrudService<Model>['update'];
    protected _updateMany: ICrudService<Model>['updateMany'];
    protected _useUpdate: <T extends Documents.Update>(document: T) => (mainOptions?: CacheUpdateOptions<ServiceMutationHookOptions<T>>) => [({ id, ...input }: Partial<Record<Exclude<{ [Key in keyof Model]-?: Model[Key] extends ModelWithId[] ? Key : never; }[keyof Model], { [Key_1 in keyof Model]-?: Model[Key_1] extends string | number | boolean ? Key_1 : never; }[keyof Model]>, ModelWithId[]> & Record<HasOneRelationsOf<Model>, ModelWithId>> & VariablesOf<T>["input"]["update"] & {
        id: string;
    }, options?: CacheUpdateOptions<ServiceMutationHookOptions<T>>) => Promise<Record<string, unknown>>, import("@apollo/client").MutationResult<{
        updateOne: Record<string, unknown>;
    }>];
    protected _delete: ICrudService<Model>['delete'];
    protected _useDelete: <T extends Documents.Delete>(document: T) => (options?: ServiceMutationHookOptions<T>) => [(id?: string) => Promise<ResultOf<T>["deleteOne"]>, import("@apollo/client").MutationResult<ResultOf<T>>];
    protected _get: ICrudService<Model>['get'];
    protected _getBySegmentID: ICrudService<Model>['getBySegmentID'];
    get useGetAll(): <T extends ModelWithId>(pageSize: number, getChunk: (offset: number) => Promise<{
        edges: Record<"node", T>[];
        totalCount: number;
    }>) => import("react-use/lib/useAsyncFn").AsyncState<T[]>;
    chunkedList<T extends ModelWithId>(ids: string[], getChunk: (chunk: string[]) => Promise<{
        edges: Record<'node', T>[];
    }>, count?: number): Promise<T[]>;
    protected _list: ICrudService<Model>['list'];
    /**
     * 1. We are going to loop over the input object and check if the key is a hasOne or hasMany relation.
     * 2. If it is a **hasOne**, we are going to use the _hasOneModelTransformer function to transform the relation.
     * 3. If it is a **hasMany**, we are going to push setRelation function to an array which will be executed later.
     * 4. If it is neither, we are going to add the key and the value to the newInput object.
     * 5. At the end of the loop, we are going to return the _newInput_ and the _setHasManyRelations_ function which
     *    will set all hasMany relations
     * TODO: THIS SHOULD ONLY HAPPEN IF THE INPUT HAS A MATCHING KEY/VALUE PAIR
     */
    protected serializePayload<Response extends Record<string, any>>(input: any): {
        input: Response;
        setHasManyRelations: (modelId: string) => Promise<unknown[]>;
    };
    protected _useList: <T extends Documents.List>(document: T, cacheKey?: keyof IDocuments | false) => (options: CacheUpdateOptions<ServiceQueryHookOptions<T>>) => {
        isLoading: boolean;
        isRefetching: boolean;
        hasMore: any;
        refetching: boolean;
        client: import("@apollo/client").ApolloClient<any>;
        observable: import("@apollo/client").ObservableQuery<ResultOf<T>, VariablesOf<T>>;
        data: ResultOf<T>;
        previousData?: ResultOf<T>;
        error?: import("@apollo/client").ApolloError;
        errors?: readonly import("graphql").GraphQLFormattedError[];
        loading: boolean;
        networkStatus: import("@apollo/client").NetworkStatus;
        called: boolean;
        startPolling: (pollInterval: number) => void;
        stopPolling: () => void;
        subscribeToMore: <TSubscriptionData = ResultOf<T>, TSubscriptionVariables extends import("@apollo/client").OperationVariables = VariablesOf<T>>(options: import("@apollo/client").SubscribeToMoreOptions<ResultOf<T>, TSubscriptionVariables, TSubscriptionData>) => () => void;
        updateQuery: <TVars extends import("@apollo/client").OperationVariables = VariablesOf<T>>(mapFn: (previousQueryResult: ResultOf<T>, options: Pick<import("@apollo/client").WatchQueryOptions<TVars, ResultOf<T>>, "variables">) => ResultOf<T>) => void;
        refetch: (variables?: Partial<VariablesOf<T>>) => Promise<import("@apollo/client").ApolloQueryResult<ResultOf<T>>>;
        reobserve: (newOptions?: Partial<import("@apollo/client").WatchQueryOptions<VariablesOf<T>, ResultOf<T>>>, newNetworkStatus?: import("@apollo/client").NetworkStatus) => Promise<import("@apollo/client").ApolloQueryResult<ResultOf<T>>>;
        variables: VariablesOf<T>;
        fetchMore: <TFetchData = ResultOf<T>, TFetchVars extends import("@apollo/client").OperationVariables = VariablesOf<T>>(fetchMoreOptions: import("@apollo/client").FetchMoreQueryOptions<TFetchVars, TFetchData> & {
            updateQuery?: (previousQueryResult: ResultOf<T>, options: {
                fetchMoreResult: TFetchData;
                variables: TFetchVars;
            }) => ResultOf<T>;
        }) => Promise<import("@apollo/client").ApolloQueryResult<TFetchData>>;
    };
    get readById(): (id: string) => {
        [key: string]: any;
    };
    protected _readById: <T extends TypedDocumentNode<{
        [key: string]: any;
    }, {
        [key: string]: any;
    }>>(fragment: T) => (id: string) => ResultOf<T>;
    protected _useLazyList: <T extends Documents.List>(document: T, cacheKey?: keyof IDocuments | false) => (options?: CacheUpdateOptions<ServiceLazyQueryHookOptions<T>>) => import("@apollo/client").LazyQueryResultTuple<ResultOf<T>, VariablesOf<T>>;
    protected _useQuery: <T extends TypedDocumentNode<{
        [key: string]: any;
    }, {
        [key: string]: any;
    }>>(document: T) => (options?: CacheUpdateOptions<ServiceQueryHookOptions<T>>) => {
        isLoading: boolean;
        isRefetching: boolean;
        hasMore: any;
        refetching: boolean;
        client: import("@apollo/client").ApolloClient<any>;
        observable: import("@apollo/client").ObservableQuery<ResultOf<T>, VariablesOf<T>>;
        data: ResultOf<T>;
        previousData?: ResultOf<T>;
        error?: import("@apollo/client").ApolloError;
        errors?: readonly import("graphql").GraphQLFormattedError[];
        loading: boolean;
        networkStatus: import("@apollo/client").NetworkStatus;
        called: boolean;
        startPolling: (pollInterval: number) => void;
        stopPolling: () => void;
        subscribeToMore: <TSubscriptionData = ResultOf<T>, TSubscriptionVariables extends import("@apollo/client").OperationVariables = VariablesOf<T>>(options: import("@apollo/client").SubscribeToMoreOptions<ResultOf<T>, TSubscriptionVariables, TSubscriptionData>) => () => void;
        updateQuery: <TVars extends import("@apollo/client").OperationVariables = VariablesOf<T>>(mapFn: (previousQueryResult: ResultOf<T>, options: Pick<import("@apollo/client").WatchQueryOptions<TVars, ResultOf<T>>, "variables">) => ResultOf<T>) => void;
        refetch: (variables?: Partial<VariablesOf<T>>) => Promise<import("@apollo/client").ApolloQueryResult<ResultOf<T>>>;
        reobserve: (newOptions?: Partial<import("@apollo/client").WatchQueryOptions<VariablesOf<T>, ResultOf<T>>>, newNetworkStatus?: import("@apollo/client").NetworkStatus) => Promise<import("@apollo/client").ApolloQueryResult<ResultOf<T>>>;
        variables: VariablesOf<T>;
        fetchMore: <TFetchData = ResultOf<T>, TFetchVars extends import("@apollo/client").OperationVariables = VariablesOf<T>>(fetchMoreOptions: import("@apollo/client").FetchMoreQueryOptions<TFetchVars, TFetchData> & {
            updateQuery?: (previousQueryResult: ResultOf<T>, options: {
                fetchMoreResult: TFetchData;
                variables: TFetchVars;
            }) => ResultOf<T>;
        }) => Promise<import("@apollo/client").ApolloQueryResult<TFetchData>>;
    };
    protected _useLazyQuery: <T extends TypedDocumentNode<{
        [key: string]: any;
    }, {
        [key: string]: any;
    }>>(document: T) => (options?: CacheUpdateOptions<ServiceLazyQueryHookOptions<T>>) => import("@apollo/client").LazyQueryResultTuple<ResultOf<T>, VariablesOf<T>>;
    protected _useMutation: <T extends TypedDocumentNode<{
        [key: string]: any;
    }, {
        [key: string]: any;
    }>>(document: T) => (options?: CacheUpdateOptions<ServiceMutationHookOptions<T>>) => import("@apollo/client").MutationTuple<{
        [key: string]: any;
    }, {
        [key: string]: any;
    }, import("@apollo/client").DefaultContext, import("@apollo/client").ApolloCache<any>>;
    protected _useGet: <T extends Documents.Get>(document: T) => (options: ServiceQueryHookOptions<T>) => {
        isLoading: boolean;
        isRefetching: boolean;
        hasMore: any;
        refetching: boolean;
        client: import("@apollo/client").ApolloClient<any>;
        observable: import("@apollo/client").ObservableQuery<ResultOf<T>, VariablesOf<T>>;
        data: ResultOf<T>;
        previousData?: ResultOf<T>;
        error?: import("@apollo/client").ApolloError;
        errors?: readonly import("graphql").GraphQLFormattedError[];
        loading: boolean;
        networkStatus: import("@apollo/client").NetworkStatus;
        called: boolean;
        startPolling: (pollInterval: number) => void;
        stopPolling: () => void;
        subscribeToMore: <TSubscriptionData = ResultOf<T>, TSubscriptionVariables extends import("@apollo/client").OperationVariables = VariablesOf<T>>(options: import("@apollo/client").SubscribeToMoreOptions<ResultOf<T>, TSubscriptionVariables, TSubscriptionData>) => () => void;
        updateQuery: <TVars extends import("@apollo/client").OperationVariables = VariablesOf<T>>(mapFn: (previousQueryResult: ResultOf<T>, options: Pick<import("@apollo/client").WatchQueryOptions<TVars, ResultOf<T>>, "variables">) => ResultOf<T>) => void;
        refetch: (variables?: Partial<VariablesOf<T>>) => Promise<import("@apollo/client").ApolloQueryResult<ResultOf<T>>>;
        reobserve: (newOptions?: Partial<import("@apollo/client").WatchQueryOptions<VariablesOf<T>, ResultOf<T>>>, newNetworkStatus?: import("@apollo/client").NetworkStatus) => Promise<import("@apollo/client").ApolloQueryResult<ResultOf<T>>>;
        variables: VariablesOf<T>;
        fetchMore: <TFetchData = ResultOf<T>, TFetchVars extends import("@apollo/client").OperationVariables = VariablesOf<T>>(fetchMoreOptions: import("@apollo/client").FetchMoreQueryOptions<TFetchVars, TFetchData> & {
            updateQuery?: (previousQueryResult: ResultOf<T>, options: {
                fetchMoreResult: TFetchData;
                variables: TFetchVars;
            }) => ResultOf<T>;
        }) => Promise<import("@apollo/client").ApolloQueryResult<TFetchData>>;
    };
    protected _useLazyGet: <T extends Documents.Get>(document: T) => (options?: CacheUpdateOptions<ServiceLazyQueryHookOptions<T>>) => import("@apollo/client").LazyQueryResultTuple<ResultOf<T>, VariablesOf<T>>;
    protected _setHasManyRelation({ id, relationIds, key }: {
        id: string;
        key: string;
        relationIds: string[];
    }): Promise<void> | Promise<import("@apollo/client").FetchResult<any>>;
    private _isHasOneRelation;
    private _isHasManyRelation;
}
