import constants from './constants'; export type AjaxServiceRequestRetryOptions = { attempts: number; }; export type AjaxServiceRequestOptionsBase = { method: string; url: string; id?: string; headers?: Record; data?: any; accept?: string; contentType?: string; credentials?: RequestCredentials; origin?: string; retry?: AjaxServiceRequestRetryOptions; }; export type AjaxServiceResponse = { status: number; headers: Record; data: T; }; export declare class AjaxServiceError extends Error { readonly response: AjaxServiceResponse; constructor(response: AjaxServiceResponse); } export declare function isAjaxServiceError(err: Error): err is AjaxServiceError; export type RetryState = { err: Error & { status: number; response: AjaxServiceResponse; }; attemptNumber: number; numOfAttempts: number; }; export type RequestState = { cancel: () => Promise; retryState: RetryState; next: (req: AjaxServiceRequestOptionsBase) => Promise; }; export type Interceptor = (req: AjaxServiceRequestOptionsBase, requestState: RequestState) => Promise; export type ResponseState = { req: AjaxServiceRequestOptionsBase; res: AjaxServiceResponse; }; export type ResponseListener = (responseState: ResponseState) => void | Promise; export type CancelState = { req: AjaxServiceRequestOptionsBase; }; export type CancelListener = (cancelState: CancelState) => void; export type AjaxServiceConfig = { onRequest: Interceptor; onResponse: ResponseListener; onCancel: CancelListener; }; export type AjaxServiceRequestOptions = AjaxServiceRequestOptionsBase & { configs?: Partial[]; }; export type RequestInitWithUrl = RequestInit & { url: string; origin?: string; }; export type AjaxService = { constants: typeof constants; get(opts: Partial): Promise>; post(opts: Partial): Promise>; delete(opts: Partial): Promise; send(opts: AjaxServiceRequestOptions): Promise>; }; export type AjaxServiceInitializer = ((configs?: Partial[]) => AjaxService) & { constants: typeof constants; };