import { ReactNode, ReactElement, ComponentType } from 'react';
import { RenderOptions } from "bwip-js";
import { AuthActionType } from './authentication/types';
export interface BarCodeProps extends RenderOptions {
    type?: any;
    data?: any;
    scale?: any;
    height?: any;
    textSize?: any;
    includeText?: any;
    textXAlign?: any;
}
export interface BarCodeRenderProps extends BarCodeProps {
}
/**
 * data types
 */
export type Identifier = string | number;
export interface RaRecord {
    id: Identifier;
    [key: string]: any;
}
export interface SortPayload {
    field: string;
    order: string;
}
export interface FilterPayload {
    [k: string]: any;
}
export interface PaginationPayload {
    page: number;
    perPage: number;
}
export type ValidUntil = Date;
/**
 * i18nProvider types
 */
export declare const I18N_TRANSLATE = "I18N_TRANSLATE";
export declare const I18N_CHANGE_LOCALE = "I18N_CHANGE_LOCALE";
export type Translate = (key: string, options?: any) => string;
export type Locale = {
    locale: string;
    name: string;
};
export interface I18nProvider {
    translate: Translate;
    changeLocale: (locale: string, options?: any) => Promise<void>;
    getLocale: () => string;
    getLocales?: () => Locale[];
    [key: string]: any;
}
export interface UserIdentity {
    id: Identifier;
    fullName?: string;
    avatar?: string;
    [key: string]: any;
}
/**
 * authProvider types
 */
export interface AuthProvider {
    login: (params: any) => Promise<{
        redirectTo?: string | boolean;
    } | void | any>;
    logout: (params: any) => Promise<void | false | string>;
    checkAuth: (params: any) => Promise<void>;
    checkError: (error: any) => Promise<void>;
    getIdentity?: () => Promise<UserIdentity>;
    getPermissions: (params: any) => Promise<any>;
    handleCallback?: () => Promise<AuthRedirectResult | void | any>;
    [key: string]: any;
}
export type AuthRedirectResult = {
    redirectTo?: string | false;
    logoutOnFailure?: boolean;
};
export type LegacyAuthProvider = (type: AuthActionType, params?: any) => Promise<any>;
/**
 * dataProvider types
 */
export type DataProvider<ResourceType extends string = string> = {
    getList: <RecordType extends RaRecord = any>(resource: ResourceType, params: GetListParams) => Promise<GetListResult<RecordType>>;
    getOne: <RecordType extends RaRecord = any>(resource: ResourceType, params: GetOneParams) => Promise<GetOneResult<RecordType>>;
    getMany: <RecordType extends RaRecord = any>(resource: ResourceType, params: GetManyParams) => Promise<GetManyResult<RecordType>>;
    getManyReference: <RecordType extends RaRecord = any>(resource: ResourceType, params: GetManyReferenceParams) => Promise<GetManyReferenceResult<RecordType>>;
    update: <RecordType extends RaRecord = any>(resource: ResourceType, params: UpdateParams) => Promise<UpdateResult<RecordType>>;
    updateMany: <RecordType extends RaRecord = any>(resource: ResourceType, params: UpdateManyParams) => Promise<UpdateManyResult<RecordType>>;
    create: <RecordType extends RaRecord = any>(resource: ResourceType, params: CreateParams) => Promise<CreateResult<RecordType>>;
    delete: <RecordType extends RaRecord = any>(resource: ResourceType, params: DeleteParams<RecordType>) => Promise<DeleteResult<RecordType>>;
    deleteMany: <RecordType extends RaRecord = any>(resource: ResourceType, params: DeleteManyParams<RecordType>) => Promise<DeleteManyResult<RecordType>>;
    [key: string]: any;
};
export interface GetListParams {
    pagination: PaginationPayload;
    sort: SortPayload;
    filter: any;
    meta?: any;
}
export interface GetListResult<RecordType extends RaRecord = any> {
    data: RecordType[];
    total?: number;
    pageInfo?: {
        hasNextPage?: boolean;
        hasPreviousPage?: boolean;
    };
}
export interface GetInfiniteListResult<RecordType extends RaRecord = any> extends GetListResult<RecordType> {
    pageParam?: number;
}
export interface GetOneParams<RecordType extends RaRecord = any> {
    id: RecordType['id'];
    meta?: any;
}
export interface GetOneResult<RecordType extends RaRecord = any> {
    data: RecordType;
}
export interface GetManyParams {
    ids: Identifier[];
    meta?: any;
}
export interface GetManyResult<RecordType extends RaRecord = any> {
    data: RecordType[];
}
export interface GetManyReferenceParams {
    target: string;
    id: Identifier;
    pagination: PaginationPayload;
    sort: SortPayload;
    filter: any;
    meta?: any;
}
export interface GetManyReferenceResult<RecordType extends RaRecord = any> {
    data: RecordType[];
    total?: number;
    pageInfo?: {
        hasNextPage?: boolean;
        hasPreviousPage?: boolean;
    };
}
export interface UpdateParams<T = any> {
    id: Identifier;
    data: Partial<T>;
    previousData: T;
    meta?: any;
}
export interface UpdateResult<RecordType extends RaRecord = any> {
    data: RecordType;
}
export interface UpdateManyParams<T = any> {
    ids: Identifier[];
    data: T;
    meta?: any;
}
export interface UpdateManyResult<RecordType extends RaRecord = any> {
    data?: RecordType['id'][];
}
export interface CreateParams<T = any> {
    data: T;
    meta?: any;
}
export interface CreateResult<RecordType extends RaRecord = any> {
    data: RecordType;
}
export interface DeleteParams<RecordType extends RaRecord = any> {
    id: RecordType['id'];
    previousData?: RecordType;
    meta?: any;
}
export interface DeleteResult<RecordType extends RaRecord = any> {
    data: RecordType;
}
export interface DeleteManyParams<RecordType extends RaRecord = any> {
    ids: RecordType['id'][];
    meta?: any;
}
export interface DeleteManyResult<RecordType extends RaRecord = any> {
    data?: RecordType['id'][];
}
export type DataProviderResult<RecordType extends RaRecord = any> = CreateResult<RecordType> | DeleteResult<RecordType> | DeleteManyResult | GetListResult<RecordType> | GetManyResult<RecordType> | GetManyReferenceResult<RecordType> | GetOneResult<RecordType> | UpdateResult<RecordType> | UpdateManyResult;
export type MutationMode = 'pessimistic' | 'optimistic' | 'undoable';
export type OnSuccess = (response?: any, variables?: any, context?: any) => void;
export type onError = (error?: any, variables?: any, context?: any) => void;
export type TransformData = (data: any, options?: {
    previousData: any;
}) => any | Promise<any>;
export interface UseDataProviderOptions {
    action?: string;
    fetch?: string;
    meta?: object;
    mutationMode?: MutationMode;
    onSuccess?: OnSuccess;
    onError?: onError;
    enabled?: boolean;
}
export type LegacyDataProvider = (type: string, resource: string, params: any) => Promise<any>;
export type RecordToStringFunction = (record: any) => string;
export interface ResourceDefinition {
    readonly name: string;
    readonly options?: any;
    readonly hasList?: boolean;
    readonly hasEdit?: boolean;
    readonly hasShow?: boolean;
    readonly hasCreate?: boolean;
    readonly icon?: any;
    readonly recordRepresentation?: ReactElement | RecordToStringFunction | string;
}
/**
 * Misc types
 */
export type Dispatch<T> = T extends (...args: infer A) => any ? (...args: A) => void : never;
export type ResourceElement = ReactElement<ResourceProps>;
export type RenderResourcesFunction = (permissions: any) => ReactNode | Promise<ReactNode> | ResourceElement[] | Promise<ResourceElement[]>;
export interface ResourceComponentInjectedProps {
    permissions?: any;
    resource?: string;
    options?: any;
    hasList?: boolean;
    hasEdit?: boolean;
    hasShow?: boolean;
    hasCreate?: boolean;
}
export interface ResourceOptions {
    label?: string;
    [key: string]: any;
}
export interface ResourceProps {
    intent?: 'route' | 'registration';
    name: string;
    list?: ComponentType<any> | ReactElement;
    create?: ComponentType<any> | ReactElement;
    edit?: ComponentType<any> | ReactElement;
    show?: ComponentType<any> | ReactElement;
    icon?: ComponentType<any>;
    recordRepresentation?: ReactElement | RecordToStringFunction | string;
    options?: ResourceOptions;
    children?: ReactNode;
    layout?: ComponentType<any> | ReactElement | ReactNode;
    path: string;
    component: ComponentType<any> | ReactElement | ReactNode;
    resources?: any[];
}
export type Exporter = (data: any, fetchRelatedRecords: (data: any, field: string, resource: string) => Promise<any>, dataProvider: DataProvider, resource?: string) => void | Promise<void>;
export type SetOnSave = (onSave?: (values: object, redirect: any) => void) => void;
export type FormFunctions = {
    setOnSave?: SetOnSave;
};
export interface AppConfigProps {
    appId: string;
    appName?: string;
    title: string | any;
    path: string;
    homePage?: string | undefined | null;
    dataStore: string;
    setupStore?: string;
    useDefaultUiSchema?: boolean;
    enableFhir?: boolean;
    useDhis2Import?: boolean;
    isDashboard?: boolean;
    isUser?: boolean;
    isAdmin?: boolean;
    href?: any;
}
export interface FeedbackConfigProps {
    email?: string;
    telephone?: string;
    description?: string;
    title?: string;
    [key: string]: any;
}
export interface AuthProps {
    url?: string;
    realm?: string;
    clientId?: string;
    [key: string]: any;
}
export interface ApiConfigProps {
    baseUrl: string | undefined | null;
    headers?: any;
    integration: string | undefined | null;
    dataStore: string | undefined | null;
    apps: AppConfigProps[];
    standalone: boolean;
    defaultPage?: string;
    url?: string | undefined | null;
    api?: string | undefined | null;
    loginFooter?: string;
    loginTitle?: string;
    landingPage?: string;
    appName?: string;
    appId?: string;
    bannerImage?: any;
    logo?: any;
    title?: any;
    signup?: boolean;
    footer?: boolean;
    credit?: boolean;
    creditName?: string | undefined;
    creditUrl?: string | undefined;
    notifications?: any;
    signout?: boolean | any;
    type?: string;
    strategy?: string;
    usernameField?: string;
    usernameFieldLabel?: string;
    homePage?: string;
    feedback?: FeedbackConfigProps;
    auth?: AuthProps;
}
