import { ICacheMap, parseTypesMap, requestProtocolsMap, TRACING_ERRORS } from '../constants'; import { CacheRequestParamsType, GetRequestCacheParamsType } from '../utils/browser-api-cache/_types'; export interface IResponse, AdditionalErrorsType = Record> { error: boolean; errorText: string; data: DataType; additionalErrors: AdditionalErrorsType | null; code: number; headers: HeadersType; } export declare type ErrorTracingType = null | typeof TRACING_ERRORS[keyof typeof TRACING_ERRORS]; export declare type ModeCorsType = 'cors' | 'no-cors'; export declare type QueryParamsType = { [key: string]: string | number | Array | boolean; }; export declare type BrowserCacheParamsType = Omit, 'request'> & GetRequestCacheParamsType; export declare type CacheParamsType = { endpoint: string; method: Pick; requestBody: Pick; requestHeaders: Record; requestCookies: string; fullEndpoint: string; }; export interface ICache { getFromCache: (params: CacheParamsType) => Promise; setToCache: (params: CacheParamsType & { response: IResponse; }) => void; } export declare type ResponseValidateType = { response: any; schema: any; prevId?: string; }; export declare type FormatValidateParams = { response: any; schema: any; prevId?: string; isResponseStatusSuccess?: boolean; isStatusEmpty?: boolean; isBatchRequest?: boolean; isPureFileRequest?: boolean; ignoreResponseIdCompare?: boolean; requestBody: Pick; statusCode: number; }; export declare type ExtraValidationCallbackType = (options: FormatValidateParams) => boolean; export declare type TranslateFunctionType = (key: string, options?: Record | null) => string; export declare type ArrayFormatType = 'bracket' | 'index' | 'comma' | 'none'; export declare type ProgressCallbackParams = ({ total, current, }: { total: number; current: number; }) => void; export declare type ProgressOptionsType = { onLoaded?: (total: number) => void; onProgress?: ProgressCallbackParams; }; export declare type CustomSelectorDataType = (responseData: any, selectData?: string) => any; export declare type SetResponseTrackCallbackOptions = { endpoint: string; method: Pick; requestBody: Pick; requestHeaders: Record; requestCookies: string; response: Response; responseBody: any; formattedResponse: IResponse; responseHeaders: Record; responseCookies: string; error: boolean; errorType: ErrorTracingType; code: number; }; export declare type SetResponseTrackCallback = (options: SetResponseTrackCallbackOptions) => void; export declare type SetResponseTrackOptions = { callback: SetResponseTrackCallback; name: string; }; export declare type ExtraVerifyRetryCallbackType = (params: { formattedResponseData: IResponse; }) => boolean; export interface IRequestParams extends RequestInit { headers?: Record; body?: any; endpoint: string; parseType?: keyof typeof parseTypesMap; queryParams?: QueryParamsType; translateFunction?: TranslateFunctionType; responseSchema?: any; isErrorTextStraightToOutput?: boolean; extraValidationCallback?: ExtraValidationCallbackType; customTimeout?: number; isBatchRequest?: boolean; abortRequestId?: string; arrayFormat?: ArrayFormatType; progressOptions?: ProgressOptionsType; customSelectorData?: CustomSelectorDataType; selectData?: string; retry?: number; traceRequestCallback?: SetResponseTrackCallback; tracingDisabled?: boolean; cacheIsDisabled?: boolean; middlewaresAreDisabled?: boolean; proxyPersistentOptionsAreDisabled?: boolean; pureJsonFileResponse?: boolean; extraVerifyRetry?: ExtraVerifyRetryCallbackType; retryTimeInterval?: number; retryIntervalNonIncrement?: boolean; requestCache?: ICache; ignoreResponseIdCompare?: boolean; notRetryWhenOffline?: boolean; browserCacheParams?: BrowserCacheParamsType | null; } export declare type IJSONPRCRequestBodyParams = { method?: string; params?: string | number | Array | Record; }; export interface IJSONPRCRequestParams extends IRequestParams { id: string; version: { jsonrpc: string; }; body?: IJSONPRCRequestBodyParams | Array; responseSchema?: any | Array; } export declare type PersistentFetchParamsType = Pick, 'headers' | 'body' | 'mode' | 'method'>; export declare type PersistentFetchOptionsCallback = (params: RequestInit & Pick) => PersistentFetchParamsType; export declare type SetResponsePersistentParamsOptions = { callback: PersistentFetchOptionsCallback; name: string; }; export declare type TraceBaseRequestParamsType = { traceRequestCallback?: SetResponseTrackCallback; response: Response | null; requestError?: boolean; validationError?: boolean; responseError?: boolean; requestBody: Pick; requestHeaders: Record; requestCookies: string; responseBody: any; formattedResponse: IResponse; endpoint: string; method: Pick; code: number; tracingDisabled?: boolean; }; export declare type AdditionalErrors = Record; export declare type IJSONPRCRequestFormattedBodyParams = IJSONPRCRequestBodyParams & { id: string; jsonrpc: string; }; export interface IRESTPureResponse { error: boolean; errorText: string; data: Record | null; additionalErrors: AdditionalErrors | null; } export declare type FormatResponseRESTDataOptionsType = { isErrorTextStraightToOutput?: boolean; translateFunction?: TranslateFunctionType; statusCode: number; responseHeaders: Record; } & IRESTPureResponse; export declare type FormatResponsePureRESTDataOptionsType = { isErrorTextStraightToOutput?: boolean; translateFunction?: TranslateFunctionType; statusCode: number; data: any; responseHeaders: Record; }; export declare type GetFetchParamsType = { params: RequestInit & Pick; proxyPersistentOptionsAreDisabled?: boolean; }; export declare type JSONRPCErrorType = { code: string; message: string; data: { err: string; trKey: string; errors?: Record; }; }; export interface IJSONRPCPureResponse { jsonrpc: string; result?: any; error?: JSONRPCErrorType; id: string | number; } export declare type FormatResponseJSONRPCDataOptionsType = { isErrorTextStraightToOutput?: boolean; translateFunction?: TranslateFunctionType; statusCode: number; responseHeaders: Record; } & IJSONRPCPureResponse; export declare type CacheType = 'default' | 'force-cache' | 'no-cache' | 'no-store' | 'only-if-cached' | 'reload'; export declare const cacheMap: ICacheMap; export declare type FetchMethodType = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'UPDATE' | 'DELETE'; export declare type IUtilResponse = Omit & { data: DataType; }; export declare type BatchResponseType = Array; export declare type RequestRacerParams = { request: Promise; fetchController?: any; requestId?: string | number; isErrorTextStraightToOutput?: boolean; translateFunction?: TranslateFunctionType; customTimeout?: number; }; export declare type ParseResponseParams = { response: Response; parseType?: keyof typeof parseTypesMap; isResponseStatusSuccess: boolean; isStatusEmpty: boolean; isNotFound: boolean; progressOptions?: ProgressOptionsType; requestProtocol: keyof typeof requestProtocolsMap; }; export declare abstract class ResponseParser { abstract parse: (data: Response) => any; } export declare type FormattedEndpointParams = { endpoint: string; queryParams?: QueryParamsType; arrayFormat?: ArrayFormatType; }; export declare type ErrorResponseFormatterConstructorParams = { errorTextKey: string; isErrorTextStraightToOutput?: boolean; errorTextData?: Record | null; translateFunction?: TranslateFunctionType; statusCode: number; userAbortedRequest?: boolean; }; export declare type FormatDataTypeValidatorParamsType = { responseData: any; responseSchema: any; }; export declare type GetIsomorphicFetchReturnsType = { requestFetch: () => Promise; fetchController?: AbortController; }; export declare type GetIsomorphicFetchParamsType = { endpoint: string; fetchParams: RequestInit & Pick; abortRequestId?: string; proxyPersistentOptionsAreDisabled?: boolean; }; export declare type GetFetchBodyParamsType = { requestProtocol: keyof typeof requestProtocolsMap; body: any; method: Pick; version?: { jsonrpc: string; }; id?: string; isBatchRequest?: boolean; }; export declare type GetPreparedResponseDataParams = { response: any; translateFunction?: TranslateFunctionType; protocol: keyof typeof requestProtocolsMap; isErrorTextStraightToOutput?: boolean; parseType: keyof typeof parseTypesMap; statusCode: number; isBatchRequest?: boolean; responseSchema?: any; body?: Array; isNotFound: boolean; isPureFileRequest?: boolean; responseHeaders: Record; ignoreResponseIdCompare?: boolean; }; export declare type GetMiddlewareCombinedResponseParamsType = { response: IResponse; endpoint: string; method: Pick; middlewaresAreDisabled?: boolean; retryRequest: (additionalParams: Partial) => Promise; pureRequestParams: { response: Response | null; validationError?: boolean; responseError?: boolean; requestBody: Pick; requestHeaders: Record; requestCookies: string; responseBody: any; formattedResponse: IResponse; endpoint: string; method: Pick; code: number; }; }; export declare type IMiddleware = (params: Omit) => Promise; export declare type GetResponseFromCacheParamsType = CacheParamsType & { cacheIsDisabled?: boolean; cacheNoStore?: boolean; requestCache?: ICache; }; export declare type SetResponseFromCacheParamsType = GetResponseFromCacheParamsType & { response: IResponse; }; export declare type GetCompareIdsParams = { requestId: string; responceId: string; }; export declare type GetIsSchemaResponseValidParams = { data: any; error: boolean; schema: { validate: (data: any, params: { allowUnknown: boolean; abortEarly: boolean; [key: string]: any; }) => { error: string; [key: string]: any; }; [key: string]: any; }; }; export declare type MiddlewareParams = { middleware: IMiddleware; name: string; }; export declare type CacheParams = { cache: ICache; name: string; }; export declare type GetTimeoutExceptionParamsType = { fetchController?: any; requestId?: string | number; isErrorTextStraightToOutput?: boolean; translateFunction?: TranslateFunctionType; customTimeout?: number; }; export declare abstract class ResponseFormatter { abstract getFormattedResponse: () => IResponse; } export declare type FormatResponseParamsType = { parseType: keyof typeof parseTypesMap; protocol: keyof typeof requestProtocolsMap; translateFunction?: TranslateFunctionType; isErrorTextStraightToOutput?: boolean; statusCode: number; responseHeaders: Record; data: any | Blob | string | Array; error?: boolean | JSONRPCErrorType; isBatchRequest?: boolean; responseSchema?: Array; body?: Array; ignoreResponseIdCompare?: boolean; } & (Partial> & Partial>); export declare type GetFormatValidateMethodParams = { protocol: keyof typeof requestProtocolsMap; extraValidationCallback?: ExtraValidationCallbackType; responseSchema?: any | Array; }; export declare type IDType = string; export declare type GetFormattedErrorTextResponseParams = { errorDictionaryParams: ErrorResponseFormatterConstructorParams; statusCode: number; responseHeaders: Record; userAbortedRequest?: boolean; }; export declare type FormatValidateParamsMethod = (options: FormatValidateParams) => boolean; export declare type RestResponseValidParams = { response: IRESTPureResponse; parseType?: keyof typeof parseTypesMap; }; export declare type FormatValidateParamsMehod = (options: FormatValidateParams) => boolean; export declare type GetFormattedHeadersParamsType = { isPureFileRequest?: boolean; body: JSON | FormData; headers?: { [key: string]: any; }; }; export declare type AbortListenersParamsType = { fetchController: AbortController; abortRequestId: string; }; export declare type GetFilteredDefaultErrorMessageParamsType = { response: Response; isErrorTextStraightToOutput?: boolean; }; export declare type ExtendedResponse = Omit & { body: any; }; export declare type SetResponseParams = { pureResponse: ExtendedResponse; responseBody: any; }; export declare type DependencyType = { name: string; value: any; }; export declare type StatusValidatorParamsType = { requestProtocol: keyof typeof requestProtocolsMap; isBatchRequest?: boolean; isPureFileRequest: boolean; status: number; }; export declare type StatusValidatorMethodParamsType = Omit; export declare type StatusValidatorMethodOutputType = () => boolean; export declare abstract class Formatter { abstract getFormattedValue: (data: DataType) => FormatType; }