import type AuthProvider from '../authProvider'; import type { HTTPMethodInputArgs } from './types'; import type { OAPIRequestResult, HTTPMethodType, StringTemplateArgs, RequestOptions } from '../../types'; import type { ITransport } from './transport-base'; import TransportBase from './transport-base'; export declare type QueueItem = { method: HTTPMethodType; args: HTTPMethodInputArgs; servicePath: string; urlTemplate: string; urlArgs?: StringTemplateArgs; options?: RequestOptions; resolve: (...value: any[]) => void; reject: (reason?: any, ...rest: any[]) => void; }; /** * TransportQueue wraps a transport class to allow the queueing of transport calls, so that all calls can be paused until after a particular event. * 1. This coordinates with authentication so that calls are queued whilst not authenticated * 2. The ability to wait for a promise to complete see {@link TransportQueue#waitFor}. * The old library had an option initLoadBalancerCookies which did * two calls to isalive before allowing any other calls through. This can be implemented with this class. * 3. It serves as a base class for auto batching, which by its nature queues calls. * @param transport - * The transport to wrap. * @param authProvider - (optional) If provided then calls will be queued whilst the token is expired. * If not given then calls will continue even when the authentication is not expired and no 401 calls will be handled. */ declare class TransportQueue extends TransportBase { isQueueing: boolean; authProvider: AuthProvider | null; queue: QueueItem[]; transport: ITransport; waitForPromises: Promise[]; constructor(transport: ITransport, authProvider?: AuthProvider); private tryEmptyQueue; prepareTransportMethod(method: HTTPMethodType): (args_0: string, args_1: string, args_2: StringTemplateArgs | undefined, args_3: RequestOptions | undefined) => Promise>; private onWaitForPromiseResolved; private authTokenReceived; waitFor(promise: Promise): void; protected emptyQueue(): void; protected runQueueItem(item: QueueItem): void; protected addToQueue(item: QueueItem): void; protected shouldQueue(_item: QueueItem): boolean; dispose(): void; } export default TransportQueue;