// ================================================================
// frontend/src/api/types/demo.ts
// ================================================================
/**
 * Demo Session Type Definitions
 *
 * Aligned with backend schema:
 * - services/demo_session/app/api/schemas.py
 *
 * Last Updated: 2025-10-05
 * Status: ✅ Complete - Zero drift with backend
 */

// ================================================================
// REQUEST TYPES
// ================================================================

/**
 * Create demo session request
 * Backend: services/demo_session/app/api/schemas.py:10-15 (DemoSessionCreate)
 */
export interface DemoSessionCreate {
  demo_account_type: string;  // professional or enterprise
  user_id?: string | null;  // Optional authenticated user ID
  ip_address?: string | null;
  user_agent?: string | null;
}

/**
 * Extend session request
 * Backend: services/demo_session/app/api/schemas.py:33-35 (DemoSessionExtend)
 */
export interface DemoSessionExtend {
  session_id: string;
}

/**
 * Destroy session request
 * Backend: services/demo_session/app/api/schemas.py:38-40 (DemoSessionDestroy)
 */
export interface DemoSessionDestroy {
  session_id: string;
}

/**
 * Request to clone tenant data
 * Backend: services/demo_session/app/api/schemas.py:64-68 (CloneDataRequest)
 */
export interface CloneDataRequest {
  base_tenant_id: string;
  virtual_tenant_id: string;
  session_id: string;
}

// ================================================================
// RESPONSE TYPES
// ================================================================

/**
 * Demo session response
 * Backend: services/demo_session/app/api/schemas.py:18-30 (DemoSessionResponse)
 */
/**
 * Demo user data returned in session response
 * Matches the structure of a real login user response
 */
export interface DemoUser {
  id: string;
  email: string;
  full_name: string;
  role: string;
  is_active: boolean;
  is_verified: boolean;
  tenant_id: string;
  created_at: string;
}

/**
 * Demo tenant data returned in session response
 * Matches the structure of a real tenant response
 */
export interface DemoTenant {
  id: string;
  name: string;
  subdomain: string;
  subscription_tier: string;
  tenant_type: string;
  business_type: string;
  business_model: string;
  description: string;
  is_active: boolean;
}

export interface DemoSessionResponse {
  session_id: string;
  virtual_tenant_id: string;
  demo_account_type: string;
  status: string;
  created_at: string;  // ISO datetime
  expires_at: string;  // ISO datetime
  demo_config: Record<string, any>;
  session_token: string;
  subscription_tier: string;
  is_enterprise: boolean;
  // Complete user and tenant data (like a real login response)
  user: DemoUser;
  tenant: DemoTenant;
}

/**
 * Demo session statistics
 * Backend: services/demo_session/app/api/schemas.py:43-50 (DemoSessionStats)
 */
export interface DemoSessionStats {
  total_sessions: number;
  active_sessions: number;
  expired_sessions: number;
  destroyed_sessions: number;
  avg_duration_minutes: number;
  total_requests: number;
}

/**
 * Public demo account information
 * Backend: services/demo_session/app/api/schemas.py:53-61 (DemoAccountInfo)
 */
export interface DemoAccountInfo {
  account_type: string;
  name: string;
  email: string;
  password: string;
  description: string;
  features: string[];
  business_model: string;
}

/**
 * Response from data cloning
 * Backend: services/demo_session/app/api/schemas.py:71-76 (CloneDataResponse)
 */
export interface CloneDataResponse {
  session_id: string;
  services_cloned: string[];
  total_records: number;
  redis_keys: number;
}
