import { BindingTag, Constructor, DynamicValueProviderClass } from '@loopback/context'; import { Filter, Where } from '@loopback/filter'; import { CreateParams, CreateResult, DeleteManyParams, DeleteManyResult, DeleteParams, DeleteResult, GetListParams, GetListResult, GetManyParams, GetManyReferenceParams, GetManyReferenceResult, GetManyResult, GetOneParams, GetOneResult, Identifier, Locale, QueryFunctionContext, RaRecord, UpdateManyParams, UpdateManyResult, UpdateParams, UpdateResult, UserIdentity } from 'react-admin'; import { Environments, RequestBodyTypes, RequestMethods, RequestTypes } from './constants'; export type NumberIdType = number; export type StringIdType = string; export type IdType = string | number; export type NullableType = undefined | null | void; export type AnyType = any; export type AnyObject = Record; export type ValueOrPromise = T | Promise; export type ValueOf = T[keyof T]; export type ValueOptional = Omit & Partial>; export type ValueOptionalExcept = Pick & Partial>; export type ClassProps = ValueOf; export type ClassType = Function & { prototype: T; }; export type TStatusFromClass> = ValueOf>; export type TStringConstValue> = Extract, string>; export type TNumberConstValue> = Extract, number>; export type TConstValue> = Extract, string | number>; export type TPrettify = { [K in keyof T]: T[K]; } & {}; export type EntityRelationType = {}; export type TRequestMethod = TStatusFromClass; export type TEnvironment = TStatusFromClass; export interface IRequestProps { headers?: { [key: string]: string | number; }; body?: any; query?: any; } export interface ISendParams { id?: string | number; method?: TRequestMethod; bodyType?: TRequestBodyType; body?: any; file?: any; query?: { [key: string]: any; }; headers?: { [key: string]: string | number; }; [key: string]: any; } export interface ISendResponse { data: T; [key: string]: any; } export type TRequestBodyType = Extract, string>; export type TRequestType = Extract, string>; export interface IGetRequestPropsParams { resource: string; body?: any; file?: File; bodyType?: TRequestBodyType; } export interface IGetRequestPropsResult { headers?: HeadersInit; body?: any; } export interface ICustomParams { params?: Record; [key: string]: AnyType; } export interface IReactAdminDataProvider { getList: (resource: TResource, params: GetListParams & QueryFunctionContext & ICustomParams) => Promise>; getOne: (resource: TResource, params: GetOneParams & QueryFunctionContext & ICustomParams) => Promise>; getMany: (resource: TResource, params: GetManyParams & QueryFunctionContext & ICustomParams) => Promise>; getManyReference: (resource: TResource, params: GetManyReferenceParams & QueryFunctionContext & ICustomParams) => Promise>; update: (resource: TResource, params: UpdateParams) => Promise>; updateMany: (resource: TResource, params: UpdateManyParams) => Promise>; create: = AnyType, ResultRecordType extends RaRecord = RecordType & { id: Identifier; }>(resource: TResource, params: CreateParams) => Promise>; delete: (resource: TResource, params: DeleteParams) => Promise>; deleteMany: (resource: TResource, params: DeleteManyParams) => Promise>; } export interface IDataProvider extends IReactAdminDataProvider { send: (opts: { resource: TResource; params: ISendParams; }) => Promise>; } export interface IReactAdminAuthProvider { login: (params: AnyType) => Promise<{ redirectTo?: string | boolean; } | void | any>; logout: (params: AnyType) => Promise; checkAuth: (params: AnyType & QueryFunctionContext) => Promise; checkError: (error: AnyType) => Promise; getIdentity?: (params?: QueryFunctionContext) => Promise; getPermissions: (params: AnyType & QueryFunctionContext) => Promise; } export interface IAuthProvider extends IReactAdminAuthProvider { getRoles: (params?: AnyType) => Promise>; } export interface IAuthProviderOptions { paths?: { signIn?: string; signUp?: string; checkAuth?: string; }; } export interface IRestDataProviderOptions { url: string; noAuthPaths?: Array; headers?: HeadersInit; } export interface II18nProviderOptions { i18nSources?: Record; listLanguages?: Locale[]; } export interface IService { } export interface ICrudService extends IService { find(filter: Filter): Promise>; findById(id: IdType, filter: Filter): Promise; findOne(filter: Filter): Promise<(E & EntityRelationType) | null>; count(where: Where): Promise<{ count: number; }>; create(data: Omit): Promise; updateAll(data: Partial, where: Where): Promise<{ count: number; }>; updateById(id: IdType, data: Partial): Promise; replaceById(id: IdType, data: E): Promise; deleteById(id: IdType): Promise<{ id: IdType; }>; } export interface IRaApplication { preConfigure(): ValueOrPromise; postConfigure(): ValueOrPromise; bindContext(): ValueOrPromise; injectable(scope: string, value: DynamicValueProviderClass | Constructor, tags?: Array): void; service(value: DynamicValueProviderClass | Constructor): void; start(): ValueOrPromise; }