import type { AnyAction , AsyncThunk , AsyncThunkAction , Middleware , MiddlewareAPI , ThunkDispatch , } from '@reduxjs/toolkit' ; import type { Api , ApiContext } from '../../apiTypes' ; import type { AssertTagTypes , EndpointDefinitions , } from '../../endpointDefinitions' ; import type { QueryStatus , QuerySubState , RootState } from '../apiState' ; import type { MutationThunk , QueryThunk , QueryThunkArg , ThunkResult , } from '../buildThunks' ; export type QueryStateMeta < T > = Record < string , undefined | T > ; export type TimeoutId = ReturnType < typeof setTimeout > ; export interface BuildMiddlewareInput < Definitions extends EndpointDefinitions , ReducerPath extends string , TagTypes extends string > { reducerPath : ReducerPath ; context : ApiContext < Definitions > ; queryThunk : QueryThunk ; mutationThunk : MutationThunk ; api : Api < any , Definitions , ReducerPath , TagTypes > ; assertTagType : AssertTagTypes ; } export type SubMiddlewareApi = MiddlewareAPI < ThunkDispatch < any , any , AnyAction > , RootState < EndpointDefinitions , string , string > > ; export interface BuildSubMiddlewareInput extends BuildMiddlewareInput < EndpointDefinitions , string , string > { refetchQuery ( querySubState , queryCacheKey , override ? ) : AsyncThunkAction < ThunkResult , QueryThunkArg , { } > ; } export type SubMiddlewareBuilder = ( input : BuildSubMiddlewareInput ) => Middleware < { } , RootState < EndpointDefinitions , string , string > , ThunkDispatch < any , any , AnyAction > > ; export interface PromiseConstructorWithKnownReason { param executor new < T , R > ( executor ) : PromiseWithKnownReason < T , R > ; } export interface PromiseWithKnownReason < T , R > extends Omit < Promise < T > , 'then' | 'catch' > { param onfulfilled param onrejected returns then < TResult1 = T , TResult2 = never > ( onfulfilled ? , onrejected ? ) : Promise < TResult1 | TResult2 > ; param onrejected returns catch < TResult = never > ( onrejected ? ) : Promise < T | TResult > ; }