export interface IServerStatus {
  running: boolean;
  objstPort: number;
  uiPort: number;
  uptime: number;
  startedAt: number;
  bucketCount: number;
  totalObjectCount: number;
  totalStorageBytes: number;
  storageDirectory: string;
  region: string;
  authEnabled: boolean;
}

export interface IServerConfig {
  objstPort: number;
  uiPort: number;
  region: string;
  storageDirectory: string;
  authEnabled: boolean;
  corsEnabled: boolean;
  // Cluster
  clusterEnabled: boolean;
  clusterNodeId: string;
  clusterQuicPort: number;
  clusterSeedNodes: string[];
  // Erasure coding
  erasureDataShards: number;
  erasureParityShards: number;
  erasureChunkSizeBytes: number;
  // Multi-drive
  drivePaths: string[];
  // Cluster heartbeat
  clusterHeartbeatIntervalMs: number;
  clusterHeartbeatTimeoutMs: number;
}

export interface IObjstCredential {
  accessKeyId: string;
  secretAccessKey: string;
}

export interface IConnectionInfo {
  endpoint: string;
  port: number;
  useSsl: boolean;
  accessKey: string;
  region: string;
}

export interface IAuditEntry {
  timestamp: number;
  actorUserId: string;
  action: string;
  targetType: string;
  targetId?: string;
  success: boolean;
  message?: string;
  metadata?: Record<string, string | number | boolean>;
}

export interface IClusterPeerHealth {
  nodeId: string;
  status: 'online' | 'suspect' | 'offline';
  quicAddress?: string;
  s3Address?: string;
  driveCount?: number;
  lastHeartbeat?: number;
  missedHeartbeats?: number;
}

export interface IClusterDriveHealth {
  index: number;
  path: string;
  status: 'online' | 'degraded' | 'offline' | 'healing';
  totalBytes?: number;
  usedBytes?: number;
  availableBytes?: number;
  errorCount?: number;
  lastError?: string;
  lastCheck?: number;
  erasureSetId?: number;
}

export interface IClusterErasureHealth {
  dataShards: number;
  parityShards: number;
  chunkSizeBytes: number;
  totalShards: number;
  readQuorum: number;
  writeQuorum: number;
  erasureSetCount: number;
}

export interface IClusterRepairHealth {
  active: boolean;
  scanIntervalMs?: number;
  lastRunStartedAt?: number;
  lastRunCompletedAt?: number;
  lastDurationMs?: number;
  shardsChecked?: number;
  shardsHealed?: number;
  failed?: number;
  lastError?: string;
}

export interface IClusterHealth {
  enabled: boolean;
  nodeId?: string;
  quorumHealthy?: boolean;
  majorityHealthy?: boolean;
  peers?: IClusterPeerHealth[];
  drives?: IClusterDriveHealth[];
  erasure?: IClusterErasureHealth;
  repairs?: IClusterRepairHealth;
}
