import { HttpHeaders, HttpParams } from "@angular/common/http"; import { Type } from "@angular/core"; import { FaHttpErrorCallBackHook, FaHttpHook, FaHttpMessageHook } from "./http-adapter"; export declare type RequestMethod = 'POST' | 'GET' | 'DELETE' | 'PUT' | 'OPTIONS' | 'HEAD' | 'JSONP' | 'PATCH'; export declare type HttpObserve = 'body' | 'events' | 'response'; export interface FaHttpBaseConfig { /** * API 版本 */ API_VERSION?: string; /** * api 根路径 */ ROOT_URL?: string; /** * api 前缀 */ apiPrefix?: string; } export interface FaHttpMessageConfig { /** * 错误时的信息提示 */ errorMsg?: string; /** * 成功时的信息提示 */ successMsg?: string; /** * 执行时的信息提示 */ executeMsg?: string; } export interface FaHttpGlobal extends FaHttpBaseConfig, FaHttpMessageConfig { /** * 驱动凭证 */ driveToken?: string; } export interface HttpClientOptions { body?: T; headers?: HttpHeaders | { [header: string]: string | string[]; }; reportProgress?: boolean; observe?: HttpObserve; params?: HttpParams | { [param: string]: string | string[]; }; responseType?: 'arraybuffer' | 'blob' | 'json' | 'text'; withCredentials?: boolean; } export interface FaHttpDriveBody extends FaHttpMessageConfig, FaHttpBaseConfig { } export interface FaHttpDriveIn { driveToken: string; drive: FaHttpDriveBody; } export interface FaDecHttpConfig extends FaHttpDriveBody, HttpClientOptions { /** * 请求类型 默认GET */ type?: RequestMethod; /** * 设置超时时间 默认 60000 单位ms */ timeout?: number; /** * 重试次数 */ retry?: number; /** * 是否缓存 */ cache?: boolean; /** * TODO 尚未实现 */ /** * 是否仅仅获取成功的数据 */ onlyGetSuccessData?: boolean; /** * 是否自动订阅 */ autoSubscribe?: boolean; /** * 方法参数 */ context?: { [key: string]: any; }; /** * 是否显示提示信息 */ showMsg?: boolean; /** * 是否显示执行时的信息 */ showExecuteMsg?: boolean; /** * API */ api?: string; driveToken?: string; } export interface FaHttpClientOptions extends FaDecHttpConfig { urlParams?: { [key: string]: any; }; } export interface FaDecHttpAllConfig extends FaDecHttpConfig { } export interface ResponseMetadata { params: { [key: string]: any; }; apiUrl: string; success: boolean; method: RequestMethod; status: number; } export interface FaHttpModuleConfig { messageHook?: Type>; defaultConfigForHttp?: FaHttpGlobal; hookError?: Type; httpHook?: Type>; httpApiMap?: Type[]; } export interface ApiMethodValue { methodName: string; target: Object; oldMethod: Function; decConfig: FaDecHttpAllConfig; } export interface ApiGroupPool { target?: Function; apis?: { context: any; propertyKey: string; }[]; interceptors?: { context: any; methodName: string; }[]; }