import { Options } from 'async-retry'; import { AxiosInstance, AxiosError, AxiosRequestConfig, AxiosResponse } from 'axios'; import { IUser, Method } from './base'; import { IGroups } from './groups'; import { INamespaces } from './namespaces'; import { IProjects } from './projects'; import { IUsers } from './users'; export { AxiosError, AxiosRequestConfig, AxiosResponse }; export { Options as AsyncRetryOptions }; export type ITgitApiMaker = ( command: string, method: Method, ) => (opts: { [propertyName: string]: string }) => Promise; export interface ITgitApiCache { set(key: string, value: any): Promise; get(key: string): Promise; } export type ITGitRequestConfig = AxiosRequestConfig & { useCache?: boolean; }; export interface ITgitApi { namespaces: INamespaces; groups: IGroups; user: (requestOptions?: ITGitRequestConfig) => Promise; users: IUsers; projects: IProjects; maker: ITgitApiMaker; token?: string; onRequest?: (config: AxiosRequestConfig & { startTime: number }) => Promise; onSuccess?: ( config: AxiosRequestConfig & { startTime: number }, res: AxiosResponse & { useCache?: boolean }, ) => Promise; catch: (err: AxiosError, bail?: (error: Error) => void) => Promise; [customKey: string]: any; } export type ITgitApiFactory = ( token: string, config?: AxiosRequestConfig & { writeTimeout?: number }, retryOptions?: Options & { writeRetries?: number }, options?: { baseURL: string; cache?: ITgitApiCache; axiosInstance?: AxiosInstance; }, ) => ITgitApi; declare const TgitApi: ITgitApiFactory; export * from './base'; export default TgitApi;