import type { HTTPMethodInputArgs } from './types'; import type { OAPIRequestResult, HTTPMethodType } from '../../types'; import TransportBase from './transport-base'; import type { ITransport } from './transport-base'; interface TransportCall { method: HTTPMethodType; args: HTTPMethodInputArgs; resolve: (value?: any) => void; reject: (value?: any) => void; retryCount: number; retryTimer: number | null; } interface RetryOptions { retryTimeouts?: number[]; statuses?: number[]; retryNetworkError?: boolean; retryLimit?: number; } declare type HTTPRequestRetryOptions = Partial>; interface Options { /** * The number of ms after that the retry calls should be done. */ retryTimeout: number; /** * Http methods that should retry. For each method provide an object with `retryLimit` parameter. * Note that the default is to not retry. a call will be retried if it is a network error and retryNetworkError is true or the rejection * includes a status and it is in the statuses list. */ methods?: HTTPRequestRetryOptions; } /** * TransportRetry wraps a transport class to allow the retrying of failed transport calls, so the calls are resent after a timeout. * * @example * ```ts * // Constructor with parameters * * const transportRetry = new TransportRetry(transport, { * retryTimeout:10000, * methods:{ * 'delete':{ retryLimit:3, retryNetworkError: true }, * 'post':{ retryTimeouts: [1000, 1000, 2000, 3000, 5000], statuses: [504], retryNetworkError: false }, * } * }); * ``` */ declare class TransportRetry extends TransportBase { retryTimeout: number; methods: HTTPRequestRetryOptions; transport: ITransport; failedCalls: TransportCall[]; individualFailedCalls: TransportCall[]; retryTimer: number | null; isDisposed: boolean; /** * @param transport - The transport to wrap. * @param options - (optional) Settings options. Define retry timeout, http methods to retry and max retry limit * per http method type. If not given then calls will run with underlying transport without retry logic. */ constructor(transport: ITransport, options?: Options); prepareTransportMethod(method: HTTPMethodType): (args_0: string, args_1: string, args_2: import("../../types").StringTemplateArgs | undefined, args_3: import("../../types").RequestOptions | undefined) => Promise>; protected sendTransportCall: (transportCall: TransportCall) => void; protected addFailedCall(transportCall: TransportCall): void; protected retryFailedCalls(): void; protected retryIndividualFailedCall(transportCall: TransportCall): void; dispose(): void; } export default TransportRetry;