/**
 * Core Type Definitions
 * Re-exports from API generated types + additional UI types
 */

// ==================== Re-export API Models ====================
// Import from generated-orval (Orval-generated types)

export type {
  ClusterResponse,
  CreateClusterRequest,
  UpdateClusterRequest,
} from '@/api';

export type {
  RegistryResponse,
  CreateRegistryRequest,
  UpdateRegistryRequest,
} from '@/api';

export type {
  InstanceResponse,
  CreateInstanceRequest,
  UpdateInstanceRequest,
} from '@/api';

export type {
  ArtifactResponse,
  ArtifactListItem,
} from '@/api';

export type {
  ClusterMonitoring,
  MonitoringSummary,
} from '@/api';

// ==================== Type Aliases (for convenience) ====================
// These maintain compatibility with existing code

import type {
  ClusterResponse,
  RegistryResponse,
  InstanceResponse,
} from '@/api';

export type Cluster = ClusterResponse;
export type ClusterConfig = ClusterResponse;
export type Registry = RegistryResponse;
export type AppRegistry = RegistryResponse;
export type Instance = InstanceResponse;
export type AppInstance = InstanceResponse;

// ==================== UI-specific Types ====================

export interface HealthStatus {
  clusterId: string;
  status: string;
  message: string;
  checkedAt: string;
}

export interface RegistryHealthStatus {
  healthy: boolean;
  message?: string;
}

// ==================== Monitoring Extended Types ====================
// Extended types for monitoring features (includes API fields + UI fields)

import type { ClusterMonitoring, ClusterMonitoringStatus, NodeMetricsResponse } from '@/api';

export type NodeMetrics = NodeMetricsResponse;

export interface UserResourceUsage {
  userId?: string;
  userName?: string;
  username?: string;
  namespace?: string;
  cpuUsed?: string;
  usedCpu?: string;
  cpuRequest?: string;
  cpuLimit?: string;
  memoryUsed?: string;
  usedMemory?: string;
  memoryRequest?: string;
  memoryLimit?: string;
  gpuUsed?: number;
  usedGpu?: number;
  gpuAllocated?: number;
  gpuAllocation?: number;
  gpuMemoryUsed?: string | number;
  usedGpuMemory?: string | number;
  gpuMemUsed?: string | number;
  gpuMemoryAllocated?: string | number;
  gpuMemAllocated?: string | number;
  podCount?: number;
  instanceCount?: number;
  cpuRequests?: string;
  cpuLimits?: string;
  memoryRequests?: string;
  memoryLimits?: string;
  gpuRequests?: number;
  gpuLimits?: number;
  gpuMemoryRequestsMb?: number;
  gpuMemoryLimitsMb?: number;
}

export interface ClusterMetrics extends ClusterMonitoring {
  /** Internal UI identifier (legacy) */
  id?: string;
  nodes?: NodeMetrics[];
  status?: ClusterMonitoringStatus | 'warning' | 'error';
  allocatedGpu?: number;
  allocatedGpuMemoryMb?: number;
  allocatedGpuMemoryMB?: number;
  gpuMemoryRequestsMb?: number;
  gpuMemoryLimitsMb?: number;
  gpuAllocated?: number;
  gpuAllocation?: number;
  cpuRequests?: string;
  cpuLimits?: string;
  memoryRequests?: string;
  memoryLimits?: string;
  totalGpuMemory?: string | number;
  usedGpuMemory?: string | number;
  gpuMemoryUsed?: string | number;
  totalGpuMem?: string | number;
  usedGpuMem?: string | number;
  userResources?: UserResourceUsage[];
  resourceUsageByUser?: UserResourceUsage[];
  userResourceUsage?: UserResourceUsage[];
  resourcesByUser?: UserResourceUsage[];
  userResourceRows?: UserResourceUsage[];
}

// ==================== Common Types ====================

export interface SuccessResponse {
  message: string;
}

export interface ErrorResponse {
  error: string;
  message: string;
}
