/// <reference types="react" />
import * as Apollo from '@apollo/client';
import { ModelFieldsTypes } from '@bcrumbs.net/bc-api';
export interface BackendField<T> {
    field: keyof T;
    i18Key?: string;
    type: ModelFieldsTypes;
    options?: {
        value: string;
        label: string;
    }[];
    subFields?: BackendField<T>[];
    cssClass?: string;
    CustomHeaderComponent?: React.FC<any>;
    CustomRowComponent?: React.FC<any>;
    sortable?: boolean;
}
export interface BackendCallDefinition<T> {
    fields?: BackendField<T>[];
    type: 'query' | 'lazyQuery' | 'mutation';
}
export interface BackendQueryDefinition<T> extends BackendCallDefinition<T> {
    reactHook: (options: Apollo.QueryHookOptions<any, any> & ({
        variables: any;
        skip?: boolean;
    } | {
        skip: boolean;
    })) => Apollo.QueryResult<any, any>;
    queryName: string;
    type: 'query';
}
export interface BackendLazyQueryDefinition<T> extends BackendCallDefinition<T> {
    reactHook: (options: Apollo.LazyQueryHookOptions<any, any> & ({
        variables: any;
        skip?: boolean;
    } | {
        skip: boolean;
    })) => Apollo.LazyQueryResultTuple<any, any>;
    queryName: string;
    type: 'lazyQuery';
}
export interface CustomComponentProps<T> {
    sourceDef: SourceDefinition<T>;
    itemId?: string;
}
export interface BackendMutationDefinition<T> extends BackendCallDefinition<T> {
    component?: React.FC<CustomComponentProps<T>>;
    reactHook: (options: Apollo.MutationHookOptions<any, any>) => Apollo.MutationTuple<any, any, Apollo.DefaultContext, Apollo.ApolloCache<any>>;
    type: 'mutation';
}
export interface SourceDefinition<T> {
    name: string;
    i18Key: string;
    orderField?: keyof T;
    listQuery: BackendLazyQueryDefinition<T> | BackendQueryDefinition<T>;
    getQuery?: BackendQueryDefinition<T>;
    createMutation?: BackendMutationDefinition<T>;
    patchMutation?: BackendMutationDefinition<T>;
    deleteMutation?: Omit<BackendMutationDefinition<T>, 'fields'>;
    client?: Apollo.ApolloClient<Apollo.NormalizedCacheObject>;
}
