/**
 * Type definitions for Server Recommendation API
 */

/**
 * Server requirements provided by user
 */
export interface ServerRequirements {
  cpu: string;           // e.g., "4 cores", "8 vCPU"
  memory: string;        // e.g., "16GB", "32GB RAM"
  storage: string;       // e.g., "500GB SSD", "1TB NVMe"
  network: string;       // e.g., "1Gbps", "10Gbps unmetered"
  availability: string;  // e.g., "99.9%", "enterprise SLA"
  budget: string;        // e.g., "$100/month", "under $200"
}

/**
 * Server recommendation returned by AI
 */
export interface ServerRecommendation {
  provider: string;      // Hosting provider name
  plan: string;          // Specific plan/product name
  cpu: string;           // CPU specifications
  memory: string;        // RAM specifications
  storage: string;       // Storage specifications
  network: string;       // Network specifications
  price: string;         // Monthly cost
  availability: string;  // SLA or uptime guarantee
  reason: string;        // Why this server was recommended
  matchScore: number;    // Match score (0-100)
}

/**
 * API request body for recommendations
 */
export interface RecommendationRequest {
  requirements: ServerRequirements;
}

/**
 * API response for recommendations
 */
export interface RecommendationResponse {
  recommendations: ServerRecommendation[];
  cached: boolean;
  timestamp: string;
}

/**
 * Error response structure
 */
export interface ErrorResponse {
  error: string;
  message: string;
  timestamp: string;
}

/**
 * Cloudflare Worker environment bindings
 */
export interface Env {
  AI: Ai;                // Workers AI binding
  DB: D1Database;        // D1 database binding
  CACHE?: KVNamespace;   // KV namespace binding (optional)
}

/**
 * D1 database row for server catalog
 */
export interface ServerCatalogRow {
  id: number;
  provider: string;
  plan: string;
  cpu: string;
  memory: string;
  storage: string;
  network: string;
  price: string;
  availability: string;
  features: string;      // JSON string of additional features
  created_at: string;
  updated_at: string;
}

/**
 * Cache entry structure
 */
export interface CacheEntry {
  recommendations: ServerRecommendation[];
  timestamp: string;
  ttl: number;
}
