import { AxiosInstance } from "axios"; import { ManagerOptions, Socket, SocketOptions } from "socket.io-client"; export declare const trimSlashes: (path: string, removeStartingSlash?: boolean, removeEndingSlash?: boolean) => string; export declare const isNumber: (num: any) => num is number; export type AsyncEmitOptions = { timeout?: number; sinceMins?: number; now?: boolean; quiet?: boolean; notScoped?: boolean; }; export interface ExtendedSocket extends Socket { destroyCurrentInstance: () => void; } export type Storage = { save: (key: string, value: T) => void | Promise; get: (key: string) => T | null | Promise; clear: () => Promise | void; }; export declare const createWebStorage: () => Storage; type BaseUrl = string; type GetToken = () => string | undefined; type AppHeader = string | undefined; type ChannellingPrefix = string | undefined; type SocketProps = { baseUrl: BaseUrl; storage?: Storage; channellingRequestTimeout?: number; beforeReconnect?: (options: Partial) => void | boolean; query?: any; scope?: string; noCaching?: () => boolean; getToken?: GetToken; autoConnect?: boolean; autoReconnect?: boolean; transports?: string[]; appHeader?: AppHeader; channellingPrefix?: ChannellingPrefix; }; export type RequestError = { statusCode: number; errors: { error: string; errors?: string[] | undefined; data?: any; }[]; }; export declare const extractApiError: (error: any) => RequestError | null; export declare const createSocketClient: (event: string, body?: any, options?: AsyncEmitOptions) => Promise, OnEvent = DefaultOnEvent>(props: SocketProps) => { reconnect: () => void; socket: () => ExtendedSocket; isConnected: () => boolean; asyncEmit: AsyncEmit; on: OnEvent; off: (event: string, cb: (...args: any[]) => any | Promise) => void; disconnect: () => void; removeListener: (event: string, cb: (...args: any[]) => any | Promise) => void; onDisconnect: (cb: () => any) => Promise<() => void>; performAsyncEmit: (event: string, body?: any, options?: AsyncEmitOptions) => Promise; _asyncEmit: (event: string, body?: any, options?: AsyncEmitOptions) => Promise; props: SocketProps; onConnect: (cb: () => any) => Promise<() => void>; onceConnect: (cb: () => any) => Promise; createEventFromRoute: (route: string, notScoped: boolean) => string; }; export type RequestConfig = { requestVia?: ("http" | "socket")[]; stream?: boolean; } & AsyncEmitOptions & { data?: D; params?: any; headers?: Record; }; export type Merge = T & Omit; export type AxiosApiInterface = { _post: Post; _put: Put; _delete: Delete; _get: Get; } & Merge<{ baseUrl?: string; post: Post; put: Put; delete: Delete; get: Get; }, AxiosInstance>; export type FetchApiInterface = { post: Post; put: Put; delete: Delete; get: Get; }; type HttpPrefix = string | undefined; type ApiScope = string | undefined; type onUnauthorized = () => void | Promise; export type ApiProps = { adapter?: "axios" | "fetch"; getToken?: GetToken; httpRequestTimeout?: number; appHeader?: AppHeader; noCaching?: () => boolean; baseUrl: BaseUrl; httpPrefix?: HttpPrefix; scope?: ApiScope; httpOnly?: () => boolean; storage?: Storage; onUnauthorized?: onUnauthorized; channelling?: { useChannelling: boolean; channellingRequestTimeout?: number; beforeReconnect?: (options: Partial) => void | boolean | Promise; query?: any; autoConnect?: boolean; autoReconnect?: boolean; transports?: string[]; channellingPrefix?: ChannellingPrefix; }; }; export type DefaultApiPost = (url: string, data?: D, config?: RequestConfig) => Promise<{ data: T; }>; export type DefaultApiPut = (url: string, data?: D, config?: RequestConfig) => Promise<{ data: T; }>; export type DefaultApiDelete = (url: string, config?: RequestConfig) => Promise<{ data: T; }>; export type DefaultApiGet = (url: string, config?: RequestConfig) => Promise<{ data: T; }>; type DefaultOnEvent = (event: string, cb: (body: any, cb?: (body?: any) => Promise) => any | Promise) => Promise<() => void>; export declare const createApiClientAxios: (event: string, body?: any, options?: AsyncEmitOptions) => Promise, OnEvent = DefaultOnEvent>(props: ApiProps) => { close: () => void; api: AxiosApiInterface; socket: { reconnect: () => void; socket: () => ExtendedSocket; isConnected: () => boolean; asyncEmit: AsyncEmit; on: OnEvent; off: (event: string, cb: (...args: any[]) => any | Promise) => void; disconnect: () => void; removeListener: (event: string, cb: (...args: any[]) => any | Promise) => void; onDisconnect: (cb: () => any) => Promise<() => void>; performAsyncEmit: (event: string, body?: any, options?: AsyncEmitOptions) => Promise; _asyncEmit: (event: string, body?: any, options?: AsyncEmitOptions) => Promise; props: SocketProps; onConnect: (cb: () => any) => Promise<() => void>; onceConnect: (cb: () => any) => Promise; createEventFromRoute: (route: string, notScoped: boolean) => string; }; reloadConfig: (updatedProps?: Partial) => void; reloadHttpInstance: () => void; reloadSocket: () => void; }; export declare const createApiClientFetch: (event: string, body?: any, options?: AsyncEmitOptions) => Promise, OnEvent = DefaultOnEvent>(props: ApiProps) => { close: () => void; api: FetchApiInterface; socket: { reconnect: () => void; socket: () => ExtendedSocket; isConnected: () => boolean; asyncEmit: AsyncEmit; on: OnEvent; off: (event: string, cb: (...args: any[]) => any | Promise) => void; disconnect: () => void; removeListener: (event: string, cb: (...args: any[]) => any | Promise) => void; onDisconnect: (cb: () => any) => Promise<() => void>; performAsyncEmit: (event: string, body?: any, options?: AsyncEmitOptions) => Promise; _asyncEmit: (event: string, body?: any, options?: AsyncEmitOptions) => Promise; props: SocketProps; onConnect: (cb: () => any) => Promise<() => void>; onceConnect: (cb: () => any) => Promise; createEventFromRoute: (route: string, notScoped: boolean) => string; }; reloadConfig: (updatedProps?: Partial) => void; reloadHttpInstance: () => void; reloadSocket: () => void; }; export declare const createApiClient: (event: string, body?: any, options?: AsyncEmitOptions) => Promise, OnEvent = DefaultOnEvent>(apiProps: Merge<{ adapter?: Adapter; }, ApiProps>) => Adapter extends "axios" ? ReturnType> : ReturnType>; export {};