import React, { ReactElement, ReactNode } from 'react';
import { ApolloClient, NormalizedCacheObject, QueryHookOptions, QueryOptions, TypedDocumentNode } from '@apollo/client';
import { FormItemProps, FormProps, FormInstance } from 'antd';
import { FormListProps, Rule } from 'antd/lib/form';
import { InternalNamePath, NamePath } from 'antd/lib/form/interface';
import { TableProps } from 'antd/lib/table';
import { ColumnFilterItem, ColumnTitle, ColumnType } from 'antd/lib/table/interface';
import { DocumentNode } from 'graphql';
export type GraphQLType = string;
export type GraphQLFragmentType = string | string[] | {
    [fragmentName: string]: string;
};
export type GraphQLObject = {
    __typename: string;
    [key: string]: any;
};
export type TypeConfigurationAdminColumnArgs = {
    type: GraphQLType;
    registry: TypesRegistryInterface;
    context: any;
};
export type TypeConfigurationAdminColumn = ColumnType<GraphQLObject> & {
    filters: ColumnFilterItem[] | ((args: TypeConfigurationAdminColumnArgs) => Promise<ColumnFilterItem[]>);
};
export type TypeConfigurationAdmin = {
    columns: TypeConfigurationAdminColumn[] | ((args: TypeConfigurationAdminColumnArgs) => Promise<TypeConfigurationAdminColumn[]>);
    creatable?: boolean;
    deletable?: boolean;
    searchable?: boolean;
    selectable?: boolean;
    route?: string;
    filter?: (item: GraphQLObject, context: any) => boolean;
    props?: TableProps<GraphQLObject>;
    headerComponent?: React.ComponentType<AdminHeaderType>;
    footerComponent?: React.ComponentType<AdminFooterType>;
    context?: {
        wrapper?: ContextWrapperType;
        queries?: ContextQueriesType;
    };
    queryOptions?: QueryHookOptions;
};
export type GraphQLObjects = GraphQLObject[] | readonly GraphQLObject[];
export type AdminHeaderType = {
    type: GraphQLType;
    context: any;
    search: string;
    refetch: () => void;
    items: GraphQLObjects;
    itemsFiltered: GraphQLObjects;
    itemsSelected: GraphQLObjects;
    selectable: boolean;
    setSearch: React.Dispatch<React.SetStateAction<string>>;
    extraLeft: undefined | ((arg: {
        items: GraphQLObjects;
        itemsFiltered: GraphQLObjects;
        itemsSelected: GraphQLObjects;
    }) => JSX.Element);
    extraRight: undefined | ((arg: {
        items: GraphQLObjects;
        itemsFiltered: GraphQLObjects;
        itemsSelected: GraphQLObjects;
    }) => JSX.Element);
    onNew?: ({ type, context }: {
        type: GraphQLType;
        context: any;
    }) => void;
};
export type AdminFooterType = {
    type: GraphQLType;
    context: any;
    search: string;
    refetch: () => void;
    items: GraphQLObjects;
    itemsFiltered: GraphQLObjects;
    itemsSelected: GraphQLObjects;
    selectable: boolean;
    currentPageData: GraphQLObjects;
    className?: string;
    children?: ReactNode;
};
export type FormObjectType = {
    __typename?: string;
    [key: string]: any;
};
export type FormFieldWidgetType = {
    widget?: string | React.ComponentType<any>;
} & {
    [key: string]: any;
};
export type FormFieldCallbackArgs = {
    context: FormContextType;
    field: FormEntryResolvedType;
    path: NamePath;
};
export type FormFieldExtraType = {
    initialValue?: ((context: FormContextType) => any) | any;
    hasObjectValue?: boolean;
    mapped?: boolean | ((context: FormContextType) => boolean | Promise<boolean>);
    auto?: boolean;
    group?: string;
    show?: ((args: FormFieldCallbackArgs) => boolean) | boolean;
    rules?: ((args: FormFieldCallbackArgs) => Rule[]) | Rule[];
    disabled?: ((args: FormFieldCallbackArgs) => boolean) | boolean;
    shouldUpdate?: ((normalizedName: InternalNamePath | undefined, prevValues: any, curValues: any) => boolean) | boolean;
    meta?: {
        [key: string]: any;
    };
};
export type FormFieldType = {
    list?: undefined | false;
    widget?: string | FormFieldWidgetType | false | ((args: FormFieldCallbackArgs) => Required<FormFieldWidgetType>);
} & FormFieldExtraType & Omit<FormItemProps, 'initialValue' | 'rules'>;
export type FormListType = {
    list: true;
    fields?: FormEntryType[];
} & FormFieldExtraType & Omit<FormListProps, 'children'> & {
    children?: FormListProps['children'];
};
export type FormContentType = {
    content: ((context: FormContextType) => JSX.Element) | JSX.Element;
};
export declare function isFormContentType(field: FormEntryType | FormEntryResolvedType | FormContentType): field is FormContentType;
export type FormEntryType = FormFieldType | FormListType | ((context: FormContextType) => FormFieldType | FormListType);
export type FormFieldResolvedType = {
    widget?: Required<FormFieldWidgetType> | ((args: FormFieldCallbackArgs) => Required<FormFieldWidgetType>);
    list: false;
    item: Omit<FormItemProps, 'name'> & {
        name?: InternalNamePath;
    };
    path: string;
} & FormFieldExtraType;
export type FormListResolvedType = {
    list: true;
    item: Omit<FormListProps, 'children' | 'name'> & {
        children?: FormListProps['children'];
        name: InternalNamePath;
    };
    fields: FormEntryResolvedType[];
    path: string;
} & FormFieldExtraType;
export type FormEntryResolvedType = FormFieldResolvedType | FormListResolvedType;
export type FormFieldMapperType = (field: FormEntryResolvedType) => FormEntryResolvedType;
export type ContextWrapperType = React.FunctionComponent<{
    children: (extra: object) => ReactElement | null;
}>;
export type ContextQueriesType = {
    [key: string]: DocumentNode | TypedDocumentNode | (QueryHookOptions & {
        query: DocumentNode | TypedDocumentNode;
        dataKey?: string;
    });
};
export type FormConfigurationType = {
    props?: Omit<FormProps, 'onFinish'> | ((context: FormContextType) => Omit<FormProps, 'onFinish'>);
    fields?: (FormEntryType | FormContentType)[] | ((context: FormContextType) => (FormEntryType | FormContentType)[]);
    mappers?: FormFieldMapperType[] | ((context: FormContextType) => FormFieldMapperType[]);
    context?: {
        wrapper?: ContextWrapperType;
        queries?: ContextQueriesType;
    };
};
export type FormHelpers = {
    isset: (...names: NamePath[]) => boolean;
    unset: (...names: NamePath[]) => boolean;
};
export type FormContextType = {
    form: FormInstance;
    object?: FormObjectType;
} & FormHelpers & {
    [key: string]: any;
};
export type TypesConfiguration = {
    [name: string]: TypeConfigurationResolved;
};
export type TypeConfiguration = {
    id?: string;
    label?: string | ((object: FormObjectType) => string | React.ReactNode);
    order?: string | {
        [field: string]: 'asc' | 'desc';
    } | ((a: GraphQLObject, b: GraphQLObject) => number);
    admin?: TypeConfigurationAdmin;
    search?: string | string[] | ((object: GraphQLObject, context?: any) => string) | {
        custom: (object: GraphQLObject, search: string, context?: any) => boolean;
    };
    forms?: {
        [formName: string]: FormConfigurationType;
    };
    select?: {
        label: any;
        fragment: any;
    };
    operations?: Partial<TypeOperationConfiguration>;
    metadata?: {
        [key: string]: any;
    };
};
export type TypeConfigurationResolved = TypeConfiguration & {
    id: string;
    operations: TypeOperationConfiguration;
};
export interface OperationsConfiguration {
    [key: string]: DocumentNode;
}
export type TypeOperation = 'get' | 'list' | 'create' | 'update' | 'delete';
export type TypeOperationQuery = 'get' | 'list';
export type TypeOperationMutation = 'create' | 'update' | 'delete';
export declare const OPERATION_GET = "get";
export declare const OPERATION_LIST = "list";
export declare const OPERATION_CREATE = "create";
export declare const OPERATION_UPDATE = "update";
export declare const OPERATION_DELETE = "delete";
export type Configuration = {
    form?: {
        labelCallback?: (label: string | React.ReactNode) => string | React.ReactNode;
        widget?: {
            dateFormat: string;
            dateTimeFormat: string;
            timeFormat: string;
        };
    };
    admin?: {
        columnTitleCallback?: (type: GraphQLType, title: ColumnTitle<any>) => string | React.ReactNode;
    };
    datePicker?: {
        date: {
            format: string;
            scalar: string;
        };
        time: {
            format: string;
            scalar: string;
        };
        datetime: {
            format: string;
            scalar: string;
        };
    };
    translator?: Translator;
    iconRenderer?: (icon: string, props: any) => React.ReactNode;
};
export type TypeTranslator = {
    name: (type: GraphQLType, count?: number) => string;
    article: (type: GraphQLType, plural?: boolean) => string;
    pastParticiple: (type: GraphQLType, plural?: boolean) => string;
};
export type Translator = {
    admin: {
        createLabel: (type: GraphQLType) => string | React.ReactNode;
        searchPlaceholder: (type: GraphQLType) => string;
        footer: {
            total: (type: GraphQLType, count: number) => string | React.ReactNode;
            selected: (type: GraphQLType, count: number) => string | React.ReactNode;
            displayed: (type: GraphQLType, count: number) => string | React.ReactNode;
        };
    };
    widgets: {
        select: {
            placeholder: (type: GraphQLType, multiple: boolean) => string;
        };
    };
};
/**
 * Given an operation type and a type, return the name of the query or mutation
 */
export type OperationResolversType = {
    [key in TypeOperation]: (type: string) => string;
};
/**
 * Given an GraphQL Operation name, how to resolve it to a GraphQL Document index in the operations index
 */
export type OperationKeyResolverType = (operationName: string, operation: TypeOperation) => string;
/**
 * Type registry configuration
 */
export type TypesRegistryConfiguration = {
    types: {
        [type: string]: TypeConfiguration;
    };
    apollo: ApolloClient<NormalizedCacheObject>;
    operations: {
        [name: string]: any;
    };
    configuration?: Partial<TypeOperationConfiguration>;
};
export interface TypesRegistryInterface {
    getTypes(): string[];
    hasType(type: GraphQLType): boolean;
    getType(type: GraphQLType): TypeConfigurationResolved;
    getOperation(type: GraphQLType, operation: TypeOperation): DocumentNode | null;
    getTypeFragmentName(type: GraphQLType): string;
    queryList(type: GraphQLType, options: Omit<QueryOptions, 'query'>): any;
    queryItem(type: GraphQLType, id: any, options: Omit<QueryOptions, 'query'>): any;
}
/**
 * Describe how to resolver operation for a type
 */
export type TypeOperationConfiguration = {
    operationResolvers: OperationResolversType;
    operationKeyResolver: OperationKeyResolverType;
} & {
    [operation in TypeOperation]: {
        getVariables: (...a: any) => any;
        getResult: (object: any) => any;
    };
};
//# sourceMappingURL=definitions.d.ts.map