import { ProxyFactory } from './aop'; import { Dictionary, Type } from './base'; import { IRemoteClientAdapter } from "./remote"; export declare const SystemErrors: { [key: string]: Error; }; export declare const Errors: { [key: string]: JsonRpc2Error; }; /** * JsonRpc错误 * -32000到 - 32099 * 服务器端错误 * 保留给具体实现服务器端错误。 */ export declare class JsonRpc2Error { /** * 错误类型编号 */ code?: number; /** * 错误消息 */ message?: string; /** * 附加数据 */ data?: any; } /** * JsonRpc请求 */ export declare class JsonRpc2Request { jsonrpc?: '2.0'; method?: string; params?: any[]; id?: number; } /** * JsonRpc响应 */ export declare class JsonRpc2Response { jsonrpc?: '2.0'; result?: TResult; error?: JsonRpc2Error; id?: number; } export declare let rpc_id: number; /** * 远程调用错误 */ export declare class JsonRpcError extends Error { constructor(message: string); } /** * 远程调用 * @author pao * @param adapter 远程调用适配器 * @param returnType 返回值类型 * @param url 远程调用地址 * @param method 远程调用方法 * @returns 调用结果(Promise) */ export declare function jsonRpcCall(adapter: IRemoteClientAdapter, url: string, method: string, ...params: any[]): Promise; /** * Ajax方式的远程调用 * @author pao * @param adapter 远程调用适配器 * @param returnType 返回值类型 * @param url 远程调用地址 * @param method 远程调用方法 * @returns 调用结果(Promise) */ export declare function ajaxJsonRpcCall(url: string, method: string, ...params: any[]): Promise; /** * 远程调用Hook * @author pao * @param adapter 远程调用适配器 * @param returnType 返回值类型 * @param url 远程调用地址 * @param method 远程调用方法 * @returns 调用结果(Promise) */ export declare function useJsonRpcCall(initResult: TResult, url: string, method: string, params?: any[]): { state: import("./state").AsyncCallState; startCall: () => void; }; /** ---------------------以下是与JSONRPC服务有关的,可用于Mock和Express--------------------- */ export declare type RemoteFunc = (serviceName: string, functionName: string, args: any[]) => any; export declare function callRemoteFunc(req: any, remoteFunc: RemoteFunc): [TResult, any]; export declare function jsonRpcServiceFunc(req: any, res: any, remoteFunc: RemoteFunc): Promise; export declare const createJsonRpcServiceFunc: (serviceConfigs: ServiceConfigs) => RemoteFunc; export declare const createJsonRpcFuncByServiceDict: (serviceList?: Dictionary | undefined) => RemoteFunc; /** 服务配置 */ export interface ServiceConfig { [key: string]: (...params: any[]) => any; } /** 服务配置 */ export interface ServiceConfigs { [key: string]: ServiceConfig; } /** * Ajax JsonRpc工厂 * @author pao * @remark 通过Ajax对象进行远程调用的工厂 */ export declare class AjaxJsonRpcFactory extends ProxyFactory { url?: string | undefined; serviceName?: string | undefined; constructor(destObject?: Type | Object, url?: string | undefined, serviceName?: string | undefined); proxyMethod?(methodName: any, args: any): any; }