import { NormalizeEntities } from '../utils/normalizeEntities' import { ReduxModulesState, RequestConfig, Entities, IsEmpty, ApiStatus, } from './exportedTypes' export declare type RecursivePartial = { [K in keyof T]?: T[K] extends {} ? RecursivePartial : T[K] } export declare type Selector = (state: ReduxModulesState) => R export declare type Obj = { [k: string]: T [k: number]: T } export declare type AnyFunc = (...args: any[]) => R export declare type MapReturns> = { [K in keyof M]: M[K] extends AnyFunc ? ReturnType : never } export declare type PagingParams = { page?: number perPage?: number } export declare type ApiActionCreator = ( params: Params, ) => RequestConfig export declare type ApiResponse = Promise<{ data: R error: boolean }> export declare type HandleRequest = ( request: RequestConfig, extraArg: any, ) => ApiResponse export declare type ApiModule = { [k: string]: (params: MakeApiParams) => {} } export declare type EntitySelector = ( id: Id, ) => Selector export declare type RawEntitiesSelector = Selector< Entities > export declare type EntitiesArraySelector = Selector< Entity[] > export declare type MakeApiParams = { schemaKey: string normalizeEntities: NormalizeEntities rawEntitiesSelector: RawEntitiesSelector entitiesSelector: EntitiesArraySelector entitySelector: EntitySelector handleRequest: HandleRequest } export declare type ModuleThunkArgs = { actionCreator: ApiActionCreator normalizeEntities: NormalizeEntities method: RequestConfig['method'] uniqueModuleKey: string handleRequest: HandleRequest } export declare type Id = string | number export declare type Ids = Id[] export declare type Updater = (...args: any[]) => any export interface ApiPaging { nextPage?: number page: number total: number totalPages: number } export declare type Meta = { moduleKey: string } export declare type Item = { item: Id } export declare type Items = { items: Ids } export declare type Update = { path: Ids updater: Updater } export interface ModuleState { status: ApiStatus items: Ids paging: ApiPaging } export interface ModulesState { [moduleName: string]: ModuleState } export declare type Thunk = ( dispatch: AnyFunc, getState: () => {}, handleRequest: any, ) => R export declare type AsyncThunk = Thunk> export declare type OptionalParams< Params extends Obj, ReturnValue extends any > = IsEmpty< Params, () => ReturnValue, (params?: Params) => ReturnValue, (params: Params) => ReturnValue > export declare type OptionalParam = IsEmpty< Params, [undefined?], [Params?], [Params] >