import { AxiosRequestConfig, AxiosInstance, AxiosResponse } from "axios"; import { GuidValue, HttpHeaders, IContextProviderCollection, IContextProvider, Future } from "../../models"; export interface HttpClientConstructor { configPromise?: Promise; } export interface HttpClientInterceptOptions { beforeRequest?: (requestUrl: string, baseConfig: AxiosRequestConfig, requestConfig: AxiosRequestConfig) => { requestUrl: string; baseConfig: AxiosRequestConfig; requestConfig: AxiosRequestConfig; }; } export declare class HttpContextProviderCollection implements IContextProviderCollection { private registeredProviders; constructor(); registerProvider: (contextProvider: IContextProvider) => void; getContextHttpHeaders: () => Promise; getHttpHeaders: () => Promise; getSerializedContextRepresentation: () => Promise; createFromContextRepresentation: (serializedContextRepresentation: string) => void; shouldRetryHttpRequest: (httpResponse: AxiosResponse) => Promise; private getProviderById; private mergeHeaders; } /** * Promise based HttpClient * @class HttpClient */ export declare class HttpClient { protected configPromise?: Promise; private httpContextProviderCollection; private tokenService; private static circuitBreakerBaseUrlDict; private static md5Util; private static ctxAwareRequestConfig; static msServiceCtxAwareRequestConfig: string; static interceptors: HttpClientInterceptOptions; protected ax: AxiosInstance; protected conf: AxiosRequestConfig; private maxCount; private safeHeaderNames; private axiosHeaderObjects; constructor(configPromise?: Promise); useConfig(conf: AxiosRequestConfig): void; /** * Handle abort functionality of abort setup * @param config axios config * @param httpClientOnAbort abort setup function of Future object type * @returns */ private tryConfigAxiosAbortSignal; /** * Perform request using the provided request config * @param config axios config * @param onAbortCallback abort call back of Future type from outside * @returns */ request(config: AxiosRequestConfig): Future>; /** * Perform GET request for provided url * @param url url * @param config axios config * @param onAbortCallback abort call back of Future type from outside * @returns */ get(url: string, config?: AxiosRequestConfig): Future>; /** * Perform DELETE request for provided url * @param url url * @param config axios config * @param onAbortCallback abort call back of Future type from outside * @returns */ delete(url: string, config?: AxiosRequestConfig): Future>; /** * Perform HEAD request for provided url * @param url url * @param config axios request config * @param onAbortCallback abort call back of Future type from outside * @returns */ head(url: string, config?: AxiosRequestConfig): Promise>; /** * Perform POST request for provided url * @param url url * @param data data * @param config axios config * @param onAbortCallback abort call back of Future type from outside * @returns */ post(url: string, data?: any, config?: AxiosRequestConfig): Future>; /** * Perform PUT request for provided url * @param url url * @param data data * @param config axios config * @param onAbortCallback abort call back of Future type from outside * @returns */ put(url: string, data?: any, config?: AxiosRequestConfig): Future>; /** * Perform PATCH request for provided url * @param url url * @param data data * @param config axios config * @param onAbortCallback abort call back of Future type from outside * @returns */ patch(url: string, data?: any, config?: AxiosRequestConfig): Future>; private handleAxiosError; private handleSuccessResponse; private enableCircuitBreaker; private checkCircuitBreaker; private static requestKeyHash; private writeHeadersToCookie; private removeHeadersCookie; private requestCtxKey; private expiresAt; private setupCtxAwareClient; private ensureRemoveHeadersCookie; private setupCtxAwareClientMSService; private configurePreflightKiller; /** * Creates an AxiosRequestConfig with provided headers for calling Omnia Token Enabled API and auto inject your dns to base url * Passing the CTX in the accept header to avoid CORS preflight i.e. OPTIONS request. * * You can call this inside your own method returning a Promise e.g. overriding with own cfg: * Or create your own cfg from scratch. * * public static myServicesRequestConfig = (): Promise => { * * return new Promise((resolveConfig, rejectConfig) => { * HttpClient.createOmniaTokenRequestConfig().then((cfg) => { * * cfg.baseURL = "https://mydomain/service/api"; * * //+Other cfg modifications * * resolveConfig(cfg); * * }).catch(rejectConfig); * }); * * } */ static createOmniaServiceRequestConfig: (serviceId?: GuidValue, skipDomainReplacement?: boolean) => Promise; static createMS365ServiceRequestConfig(): Promise>; static createSPServiceRequestConfig(authorityUrl: string): Promise>; /** * Creates an AxiosRequestConfig with provided headers for calling Omnia Token Enabled API * Passing the CTX in the accept header to avoid CORS preflight i.e. OPTIONS request. * * You can call this inside your own method returning a Promise e.g. overriding with own cfg: * Or create your own cfg from scratch. * * public static myServicesRequestConfig = (): Promise => { * * return new Promise((resolveConfig, rejectConfig) => { * HttpClient.createOmniaContextRequestConfig(omniaCtx.environment.omniaUrl).then((cfg) => { * * cfg.baseURL = "https://mydomain/service/api"; * * //+Other cfg modifications * * resolveConfig(cfg); * * }).catch(rejectConfig); * }); * * } */ static createContextAwareRequestConfig: (baseUrl: string, acceptHeader?: string, skipDomainReplacement?: boolean) => Promise; private static getDomainRegex; private static createMSServiceContextAwareRequestConfig; private static get omniaBootstrapData(); private static get omniaApp(); private refreshAccessToken; } export declare function useOmniaClient(serviceId?: GuidValue): HttpClient;