export type Identifier = string | number; export interface BasicRecord { 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 DataProvider = { getList: ( resource: ResourceType, params: GetListParams ) => Promise>; getOne: ( resource: ResourceType, params: GetOneParams ) => Promise>; getMany: ( resource: ResourceType, params: GetManyParams ) => Promise>; getManyReference: ( resource: ResourceType, params: GetManyReferenceParams ) => Promise>; update: ( resource: ResourceType, params: UpdateParams ) => Promise>; updateMany: ( resource: ResourceType, params: UpdateManyParams ) => Promise>; create: ( resource: ResourceType, params: CreateParams ) => Promise>; delete: ( resource: ResourceType, params: DeleteParams ) => Promise>; deleteMany: ( resource: ResourceType, params: DeleteManyParams ) => Promise>; [key: string]: any; }; export interface GetListParams { pagination: PaginationPayload; sort: SortPayload; filter: Record; meta?: any; } export interface GetListResult { data: RecordType[]; total?: number; pageInfo?: { hasNextPage?: boolean; hasPreviousPage?: boolean; }; } export interface SortPayload { field: string; order: string; } export interface GetOneParams { id: RecordType['id']; meta?: any; } export interface GetOneResult { data: RecordType; } export interface GetManyParams { ids: Identifier[]; meta?: any; } export interface GetManyResult { data: RecordType[]; } export interface GetManyReferenceParams { target: string; id: Identifier; pagination: PaginationPayload; sort: SortPayload; filter: any; meta?: any; } export interface GetManyReferenceResult { data: RecordType[]; total?: number; pageInfo?: { hasNextPage?: boolean; hasPreviousPage?: boolean; }; } export interface UpdateParams { id: Identifier; data: Partial; previousData: T; meta?: any; } export interface UpdateResult { data: RecordType; } export interface UpdateManyParams { ids: Identifier[]; data: T; meta?: any; } export interface UpdateManyResult { data?: RecordType['id'][]; } export interface CreateParams { data: T; meta?: any; } export interface CreateResult { data: RecordType; } export interface DeleteParams { id: RecordType['id']; previousData?: RecordType; meta?: any; } export interface DeleteResult { data: RecordType; } export interface DeleteManyParams { ids: RecordType['id'][]; meta?: any; } export interface DeleteManyResult { data?: RecordType['id'][]; } /** * authProvider types */ export interface AuthProvider { login: ( params: any ) => Promise<{ redirectTo?: string | boolean } | void | any>; logout: (params: any) => Promise; checkAuth: (params: any) => Promise; checkError: (error: any) => Promise; getIdentity?: () => Promise; getPermissions: (params: any) => Promise; handleCallback?: () => Promise; } export interface UserIdentity { id: Identifier; fullName?: string; avatar?: string; [key: string]: any; } export type AuthRedirectResult = { redirectTo?: string | false; logoutOnFailure?: boolean; }; export type Exporter = ( data: any, fetchRelatedRecords: ( data: any, field: string, resource: string ) => Promise, dataProvider: DataProvider, resource: string ) => void | Promise; export interface GetInfiniteListResult extends GetListResult { pageParam?: number; }