123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- import * as R from "./Responses";
- import * as I from "./Interfaces";
-
- export type Visibility = "127.0.0.1" | "0.0.0.0"
- export type Any = any
- export type Arg = string
- export type Name = Arg
- export type Owner = Name
-
- export type SocketConf = {
- connectionHandler: (socket:I.Socket) => void
- errorHandler: (socket:I.Socket) => (error:any) => void
- closeHandler: (socket:I.Socket) => () => void
- visibility: Visibility
- }
-
- export type RPCType = 'Hook' | 'Unhook' | 'Call'
-
- export type BaseRPC = {
- type: RPCType
- name: Name
- }
-
- export type HookRPC = BaseRPC & {
- type: 'Hook'
- clbk: CallbackFunction
- unhook: UnhookFunction
- }
-
- export type UnhookRPC = BaseRPC & {
- type: 'Unhook'
- unhook: UnhookFunction
- }
-
- export type CallRPC = BaseRPC & {
- type: 'Call'
- call: AsyncFunction
- }
-
- export type RPC = CallRPC | UnhookRPC | HookRPC
-
- export type BaseInfo = {
- owner: Name,
- argNames: Name[],
- }
-
- export type HookInfo = BaseRPC & BaseInfo & {
- type: 'Hook',
- generator: (socket) => CallbackFunction
- unhook: UnhookFunction
- }
-
- export type UnhookInfo = BaseRPC & BaseInfo & {
- type: 'Unhook',
- unhook: UnhookFunction
- }
-
- export type CallInfo = BaseRPC & BaseInfo & {
- type: 'Call',
- call: AsyncFunction
- }
-
- export type RpcInfo = HookInfo | UnhookInfo | CallInfo
- export type ExtendedRpcInfo = RpcInfo & { uniqueName: string }
-
- export type OnFunction = (type: 'error' | 'close', f: (e?:any)=>void) => I.Socket
- export type UnhookFunction = (uid:string) => Promise<R.SuccessResponse | R.ErrorResponse>
- export type CallbackFunction = (...args) => Promise<R.SubscriptionResponse | R.ErrorResponse>
- export type AsyncFunction = (...args) => Promise<any>
|