/**
 * System status data shapes for Onebox
 */

import type { TPlatformServiceStatus, TPlatformServiceType } from './platform.js';
import type { IRuntimeObservation } from './runtime.js';

export interface IOneboxUpdateStatus {
  currentVersion: string;
  latestVersion: string | null;
  updateAvailable: boolean;
  checkedAt: number;
  releaseUrl: string;
  changelogUrl: string;
  error?: string;
}

export interface IOneboxUpgradeStartResult {
  accepted: boolean;
  currentVersion: string;
  targetVersion: string;
  message: string;
  pid?: number;
  unitName?: string;
  logPath?: string;
}

export interface ISystemStatus {
  onebox: {
    version: string;
    update: IOneboxUpdateStatus;
  };
  docker: {
    running: boolean;
    version: unknown;
    cpuUsage: number;
    memoryUsage: number;
    memoryTotal: number;
    networkIn: number;
    networkOut: number;
  };
  reverseProxy: IRuntimeObservation & {
    http: { running: boolean | null; port: number };
    https: { running: boolean | null; port: number; certificates: number };
    routes: number;
  };
  dns: { configured: boolean };
  ssl: { configured: boolean; certificateCount: number };
  services: { total: number; running: number; stopped: number };
  platformServices: Array<{
    type: TPlatformServiceType;
    displayName: string;
    status: TPlatformServiceStatus;
    resourceCount: number;
  }>;
  certificateHealth: {
    valid: number;
    expiringSoon: number;
    expired: number;
    expiringDomains: Array<{ domain: string; daysRemaining: number }>;
  };
}
