/**
 * Shared types for @bytelyst/devops.
 *
 * Consumed by both the server collector (@bytelyst/devops/server)
 * and the React UI (@bytelyst/devops/ui).
 */

/** Git build metadata baked at image build time. */
export interface BuildInfo {
  /** Short commit SHA (e.g. "a1b2c3d"). */
  commitSha: string | null;
  /** Full commit SHA. */
  commitShaFull: string | null;
  /** Git branch name at build time. */
  branch: string | null;
  /** ISO 8601 timestamp of the build. */
  builtAt: string | null;
  /** Author of the built commit. */
  commitAuthor: string | null;
  /** Commit message subject line. */
  commitMessage: string | null;
  /** Docker image name:tag. */
  dockerImage: string | null;
}

/** Runtime info (process + container). */
export interface RuntimeInfo {
  /** Uptime in seconds since process start. */
  uptimeSeconds: number;
  /** Human-friendly uptime (e.g. "2d 3h 14m"). */
  uptimeHuman: string;
  /** Node.js version. */
  nodeVersion: string;
  /** OS platform (linux, darwin, …). */
  platform: string;
  /** CPU architecture. */
  arch: string;
  /** PID. */
  pid: number;
  /** Container hostname (usually the container id short). */
  hostname: string;
  /** Resident set size in MB. */
  memoryMb: number;
  /** Heap used in MB. */
  heapMb: number;
  /** ISO timestamp of process start. */
  startedAt: string;
}

/** Configuration-level info (safe, non-secret). */
export interface ConfigInfo {
  /** Product identifier. */
  productId: string;
  /** Service name. */
  serviceName: string;
  /** Service version (from package.json). */
  serviceVersion: string;
  /** NODE_ENV. */
  nodeEnv: string;
  /** Non-secret env var summary (keys only). */
  envKeys: string[];
}

/** Dependency check result. */
export interface DependencyStatus {
  name: string;
  ok: boolean;
  latencyMs?: number;
  detail?: string;
}

/** Full devops info payload. */
export interface DevopsInfo {
  build: BuildInfo;
  runtime: RuntimeInfo;
  config: ConfigInfo;
  dependencies?: DependencyStatus[];
  /** Arbitrary extra info specific to the service. */
  extra?: Record<string, unknown>;
}
