export type FabricCryptoStateOptions = { /** * '0': 状态关闭, '1': 标识 fabric_http.request 开启加密 * @default '1' */ state: "0" | "1"; }; export type FabricCryptoStateCallbackData = FabricCryptoStateOptions; export type FabricHttpSetCryptoStateApi = (options: FabricCryptoStateOptions) => boolean; export type FabricHttpCheckCryptoStateApi = () => FabricCryptoStateCallbackData; /** * 文件下载输入报文 */ export type FabricHttpFileDownloadOptions = { /** * 下载资源的 url */ url: string; /** * 指定文件下载后存储的路径 */ filePath?: string; /** * HTTP 请求的 Header,Header 中不能设置 Referer */ headers?: Record; /** * 超时时间,单位为毫秒 */ timeout?: number; }; /** * 文件下载输入报文 */ export type FabricHttpFileDownloadCallbackData = { /** * 用户文件路径 (本地路径)。传入 filePath 时会返回,跟传入的 filePath 一致 */ filePath: string; /** * 临时文件路径 (本地路径)。没传入 filePath 指定文件存储路径时会返回,下载后的文件会存储到一个临时文件 */ tempFilePath: string; /** * 开发者服务器返回的 HTTP 状态码 */ statusCode: number; /** * 上传进度0-1, 1:标识当前文件下载完成, * 此处一定会等于1, 并且==1的时候Native执行callback complete清理内存 */ progress: number; }; export type FabricHttpDownloadApi = (options: FabricHttpFileDownloadOptions) => Promise; /** * Indicates the Json types, incldue `undefind` cause of * Sometimes we allow some typing property is optional. */ export type Json = undefined | null | boolean | number | string | Json[] | { [prop: string]: Json; }; /** * 网络请求的输入报文 */ export type FabricHttpRequestOptions = { /** * 开发者服务器接口地址 */ url: string; /** * 请求的参数, object, GET请求, 则自动拼接到URL query, POST则post body发送服务器 */ data?: T; /** * HTTP 请求方法 * @default 'GET' */ method: "GET" | "POST"; /** * 设置请求的 header,header 中不能设置 Referer。content-type 默认为 application/json */ headers?: Record; /** * 超时时间,单位为秒second * @default 60 s */ timeout?: number; }; /** * 发送网络请求, 返回业务数据报文协议 */ export type FabricHttpRequestCallbackData = { /** * 开发者服务器返回的数据 */ data: T; /** * 开发者服务器返回的 HTTP Response Header */ headers: Record; /** * 开发者服务器返回的 HTTP 状态码 */ statusCode: number; }; export type FabricHttpRequestApi = = Record>(options: FabricHttpRequestOptions) => Promise>; declare class FabricError extends Error { code: string; message: string; data: any; protected constructor(code: string, message: string, data: any); toJSON: () => { name: any; code: any; data: any; message: any; description: any; number: any; fileName: any; lineNumber: any; columnNumber: any; stack: any; }; } /** * 文件上传输入报文 */ export type FabricHttpFileUploadOptions = { /** * 开发者服务器地址 */ url: string; /** * 文件对应的 key,开发者在服务端可以通过这个 key 获取文件的二进制内容 */ name: string; /** * 要上传文件资源的路径 (本地路径), 可以传多少张图 * http://temp/sfs23423042.png */ filePath: string[]; /** * HTTP 请求中其他额外的 form data */ formData?: Record; /** * HTTP 请求 Header,Header 中不能设置 Referer */ headers?: Record; /** * 超时时间,单位为毫秒 */ timeout?: number; }; /** * 文件上传接收报文 */ export type FabricHttpFileUploadCallbackData = { /** * 开发者服务器返回的数据, 只有在prgress = 100 的时候才有值 */ data?: T; /** * 发者服务器返回的 HTTP 状态码 */ statusCode?: number; /** * 上传进度0-100, 100:标识当前文件上传完成, * 此处一定会等于100, 并且==100的时候Native执行callback complete清理内存 */ progress: number; }; /** * 当前文件上传的状态 */ export type FabricHttpUploadFileStatus = "uploading" | "complete"; export type FabricHttpUploadFileApi = (options: FabricHttpFileUploadOptions, callback?: (err: FabricError | null, status: FabricHttpUploadFileStatus, result: FabricHttpFileUploadCallbackData) => void) => void; export type FabricHttpApi = { /** * 发送网络请求, 返回业务数据报文协议 */ request: FabricHttpRequestApi; /** * 下载网络文件到本地 */ downloadFile: FabricHttpDownloadApi; /** * 上传本地文件到网络服务器 */ uploadFile: FabricHttpUploadFileApi; /** * 置网络通道是否走全报文加密. */ setCryptoState: FabricHttpSetCryptoStateApi; /** * 获取网络通道是否走全报文加密的标识位. */ checkCryptoState: FabricHttpCheckCryptoStateApi; }; export declare const fabricHttp: FabricHttpApi; export {};