import { EmptyTypes, ExtendRequest } from '../types'; import { EndpointMapper, AdapterFetcherType, AdapterPayloadMappingType, HeaderMappingType, QueryParamsMapper, QueryParamsType, RequestResponseType } from './adapter.types'; import { RequestInstance, RequestOptionsType } from '../request'; import { Client, ClientInstance } from '../client'; import { LoggerMethods } from '../managers'; import { getErrorMessage } from './adapter.utils'; export type DefaultMapperType = (value: V, config: C) => V; export declare const defaultMapper: DefaultMapperType; export declare class Adapter, QueryParams = QueryParamsType | string | EmptyTypes, DefaultQueryParams = undefined, EndpointType = string, EndpointMapperType extends EndpointMapper | DefaultMapperType = DefaultMapperType, QueryParamsMapperType extends QueryParamsMapper | DefaultMapperType = DefaultMapperType, HeaderMapperType extends HeaderMappingType | DefaultMapperType = DefaultMapperType, PayloadMapperType extends AdapterPayloadMappingType | DefaultMapperType = DefaultMapperType> { options: { name: string; defaultMethod: MethodType; defaultExtra: Extra; systemErrorStatus: StatusType; systemErrorExtra: Extra; defaultRequestOptions?: RequestOptionsType; }; /** Fetching function */ unstable_fetcher: AdapterFetcherType>; /** * ******************** * Defaults * ******************** */ name: string; defaultMethod: MethodType; defaultExtra: Extra; systemErrorStatus: StatusType; systemErrorExtra: Extra; defaultRequestOptions?: RequestOptionsType; logger: LoggerMethods; initialized: boolean; client: ClientInstance; unstable_onInitializeCallback?: (options: { client: ClientInstance; }) => void; unstable_queryParamsMapperConfig: Parameters[1]; unstable_headerMapperConfig: Parameters[1]; unstable_payloadMapperConfig: Parameters[1]; unstable_endpointMapperConfig: Parameters[1]; constructor(options: { name: string; defaultMethod: MethodType; defaultExtra: Extra; systemErrorStatus: StatusType; systemErrorExtra: Extra; defaultRequestOptions?: RequestOptionsType; }); initialize: (client: ClientInstance) => this; onInitialize: (callback: (options: { client: ClientInstance; }) => void) => this; /** * ******************** * Options Setters * ******************** */ unstable_internalErrorMapping: (error: ReturnType) => any; /** Method to get default headers and to map them based on the data format exchange, by default it handles FormData / JSON formats. */ unstable_headerMapper: HeaderMapperType; /** Method to get request data and transform them to the required format. It handles FormData and JSON by default. */ unstable_payloadMapper: PayloadMapperType; /** Method to get the endpoint for the adapter request. */ unstable_endpointMapper: EndpointMapperType; /** Method to get request data and transform them to the required format. */ unstable_queryParamsMapper: QueryParamsMapperType; /** Get default adapter options for the request. */ unstable_getAdapterDefaults?: (request: ExtendRequest>; }>) => AdapterOptions; /** Get default request options for the request. */ unstable_getRequestDefaults?: (options: RequestOptionsType) => Partial>; /** * Get formatted endpoint name of the request. * Helpful in displaying long endpoints like in case of graphql schemas etc. */ unstable_devtoolsEndpointGetter: (endpoint: string) => string; /** * ******************** * Methods * ******************** */ setDefaultMethod: (method: MethodType) => this; setDefaultExtra: (extra: Extra) => this; setDevtoolsEndpointGetter: (callback: (endpoint: string) => string) => this; /** * This method allows to configure global defaults for the request configuration like method, auth, deduplication etc. */ setRequestDefaults: (callback: typeof this.unstable_getRequestDefaults) => this; /** * Set the adapter default options added to every sent request */ setAdapterDefaults: (callback: (request: ExtendRequest>; }>) => AdapterOptions) => this; setInternalErrorMapping: (callback: (error: ReturnType) => any) => this; /** * Set the custom header mapping function */ setHeaderMapper: (headerMapper: NewMapper) => Adapter; /** * Set the request payload mapping function which gets triggered before request is send */ setPayloadMapper: (payloadMapper: NewMapper) => Adapter; /** * Set the request payload mapping function which get triggered before request get sent */ setEndpointMapper: >(endpointMapper: NewEndpointMapper) => Adapter; /** * Set the query params mapping function which get triggered before request get sent */ setQueryParamsMapper: >(queryParamsMapper: NewQueryParamsMapper) => Adapter; setQueryParamsMapperConfig: [1]>(config: NewQueryParamsMapperConfig) => this; setHeaderMapperConfig: [1]>(config: NewHeaderMapperConfig) => this; setEndpointMapperConfig: [1]>(config: NewEndpointMapperConfig) => this; setPayloadMapperConfig: [1]>(config: NewPayloadMapperConfig) => this; /** * ******************** * Fetching * ******************** */ setFetcher(fetcher: AdapterFetcherType>): this; fetch(request: ExtendRequest>; }>, requestId: string): Promise>; } //# sourceMappingURL=adapter.d.ts.map