/*************** adapter ***************/ /**
 * Handles conversion between RPC format and transport layer format.
 */ export interface RpcTransportAdapter < RpcRequest , RpcResponse , TransportRequest , TransportResponse > { param request returns encodeRequest ( request ) : TransportRequest ; param response returns decodeResponse ( response ) : RpcResponse ; } /*************** rpc ***************/ /**
 * RpcClient handles requests to an RpcServer.
 */ export interface RpcClient { param method param params returns handle < T > ( method , params ? ) : Promise < T > ; } /**
 * Handles responses to an RpcClient.
 */ export interface RpcServer { param name param method register ( name , method ) : void ; /**
     * Starts the server.
     */ listen ( ) : Promise < void > ; } /*************** json-rpc-adapter ***************/ export type JsonRpcAdapter < TransportRequest , TransportResponse > = RpcTransportAdapter < JsonRpcRequest , JsonRpcResponse , TransportRequest , TransportResponse > ; /*************** json-rpc-message ***************/ export interface JsonRpcMessage { jsonrpc : '2.0' ; id : string | number | null ; } export interface JsonRpcRequest extends JsonRpcMessage { method : string ; params ? : any [ ] ; } export interface JsonRpcError { code : number ; message : string ; data ? : any ; } export interface JsonRpcErrorResponse extends JsonRpcMessage { error : JsonRpcError ; } export interface JsonRpcSuccessResponse extends JsonRpcMessage { result : any ; } export type JsonRpcResponse = JsonRpcSuccessResponse | JsonRpcErrorResponse ; /*************** transport ***************/ /**
 * Client sends some data to a server over a transport layer.
 */ export interface Client < Request , Response > { param data returns request ( data ) : Promise < Response > ; } /**
 * Server sends some data to a client over a transport layer.
 */ export interface Server { /**
     * Starts the server.
     */ listen ( ) : void ; } /*************** transport-http-message ***************/ export interface HttpRequest { url : string ; method : 'get' | 'GET' | 'head' | 'HEAD' | 'post' | 'POST' | 'put' | 'PUT' | 'delete' | 'DELETE' | 'options' | 'OPTIONS' | 'patch' | 'PATCH' ; headers ? : Record < any , any > ; params ? : Record < any , any > ; data ? : any ; timeout ? : number ; } export interface HttpResponse { status : number ; statusText : string ; headers ? : Record < any , any > ; data ? : any ; } /*************** transport-http-message ***************/ export type HttpClient = Client < HttpRequest , HttpResponse > ; export type HttpServer = Server ;