diff --git a/lib/api/lit.ts b/lib/api/lit.ts index eed4fa8..e0c6711 100644 --- a/lib/api/lit.ts +++ b/lib/api/lit.ts @@ -1,4 +1,4 @@ -import { Autopilot, Firewall, Sessions } from '../types/proto/litrpc'; +import { Autopilot, Firewall, Sessions, Status } from '../types/proto/litrpc'; import { serviceNames as sn } from '../types/proto/schema'; /** @@ -8,11 +8,13 @@ class LitApi { autopilot: Autopilot; firewall: Firewall; sessions: Sessions; + status: Status; constructor(createRpc: Function, lnc: any) { this.autopilot = createRpc(sn.litrpc.Autopilot, lnc); this.firewall = createRpc(sn.litrpc.Firewall, lnc); this.sessions = createRpc(sn.litrpc.Sessions, lnc); + this.status = createRpc(sn.litrpc.Status, lnc); } } diff --git a/lib/types/proto/lit/lit-status.ts b/lib/types/proto/lit/lit-status.ts new file mode 100644 index 0000000..2a9de7b --- /dev/null +++ b/lib/types/proto/lit/lit-status.ts @@ -0,0 +1,53 @@ +/* eslint-disable */ +export interface SubServerStatusReq {} + +export interface SubServerStatusResp { + /** A map of sub-server names to their status. */ + subServers: { [key: string]: SubServerStatus }; +} + +export interface SubServerStatusResp_SubServersEntry { + key: string; + value: SubServerStatus | undefined; +} + +export interface SubServerStatus { + /** + * disabled is true if the sub-server is available in the LiT package but + * has explicitly been disabled. + */ + disabled: boolean; + /** running is true if the sub-server is currently running. */ + running: boolean; + /** + * error describes an error that might have resulted in the sub-server not + * starting up properly. + */ + error: string; +} + +/** The Status server can be used to query the state of various LiT sub-servers. */ +export interface Status { + subServerStatus( + request?: DeepPartial + ): Promise; +} + +type Builtin = + | Date + | Function + | Uint8Array + | string + | number + | boolean + | undefined; + +type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/lib/types/proto/litrpc.ts b/lib/types/proto/litrpc.ts index 9e2cfcd..eeacbb2 100644 --- a/lib/types/proto/litrpc.ts +++ b/lib/types/proto/litrpc.ts @@ -1,3 +1,4 @@ export * from './lit/firewall'; export * from './lit/lit-autopilot'; export * from './lit/lit-sessions'; +export * from './lit/lit-status'; diff --git a/lib/types/proto/schema.ts b/lib/types/proto/schema.ts index cfe6c69..041607c 100644 --- a/lib/types/proto/schema.ts +++ b/lib/types/proto/schema.ts @@ -8,7 +8,8 @@ export const serviceNames = { litrpc: { Firewall: 'litrpc.Firewall', Autopilot: 'litrpc.Autopilot', - Sessions: 'litrpc.Sessions' + Sessions: 'litrpc.Sessions', + Status: 'litrpc.Status' }, autopilotrpc: { Autopilot: 'autopilotrpc.Autopilot' }, chainrpc: { ChainNotifier: 'chainrpc.ChainNotifier' }, diff --git a/scripts/generate_types.sh b/scripts/generate_types.sh index a0ebfaa..bce1f4e 100644 --- a/scripts/generate_types.sh +++ b/scripts/generate_types.sh @@ -129,7 +129,8 @@ protoc/bin/protoc \ $TS_PROTO_OPTIONS \ firewall.proto \ lit-sessions.proto \ - lit-autopilot.proto + lit-autopilot.proto \ + lit-status.proto # Temporarily generate schema files in order to provide metadata # about the services and subscription methods to the api classes @@ -217,7 +218,8 @@ protoc/bin/protoc \ $SCHEMA_PROTO_OPTIONS \ firewall.proto \ lit-sessions.proto \ - lit-autopilot.proto + lit-autopilot.proto \ + lit-status.proto # Cleanup proto directory/files rm -rf *.proto protoc