import { ProtocolError, TMessage, TNotification } from "../protocol"; export type SystemError = ProtocolError; export interface SystemMetricsStatus { cpu: { cores: number; used: number; configured: number; }; memory: { used: number; total: number; configured: number; }; storage: { used: number; total: number; configured: number; }; } export interface InitStatus { message: string; isError?: boolean; progress: number; nextProgress: number; stdout?: string; } export type SystemUpdate = TMessage<"system/update", Record, { result: Record; error: SystemError; }>; export type SystemHibernate = TMessage<"system/hibernate", Record, { result: null; error: SystemError; }>; export type SystemMetrics = TMessage<"system/metrics", Record, { result: SystemMetricsStatus; error: SystemError; }>; export type SystemMessage = SystemUpdate | SystemHibernate | SystemMetrics; export type SystemRequest = SystemMessage["request"]; export type SystemResponse = SystemMessage["response"]; export type HibernationNotification = TNotification<"system/hibernate", Record>; export type SystemMetricsNotification = TNotification<"system/metrics", SystemMetricsStatus>; /** * Allows clients to listen to the status of pitcher when it is Initializing * git clone, creating folders, setting up node, ... */ export type InitStatusNotification = TNotification<"system/initStatus", InitStatus>; export type SystemNotification = HibernationNotification | SystemMetricsNotification | InitStatusNotification;