/**
 * Workflow Types and Interfaces
 * Defines types for the workflow management system with tier-based access control
 */

export type WorkflowType =
  | 'ai_agent'
  | 'whatsapp'
  | 'appointments'
  | 'quotations'
  | 'crm'
  | 'integrations'
  | 'deposits'
  | 'voice_agent'
  | 'multi_staff'
  | 'recurring'
  | 'social_media'
  | 'ai_social'
  | 'lead_generation'
  | 'lead_scoring';

export type WorkflowStatus = 'active' | 'inactive' | 'error';

export interface UserWorkflow {
  id: string;
  userId: string;
  workflowType: WorkflowType;
  n8nWorkflowId?: string;
  status: WorkflowStatus;
  config: Record<string, any>;
  lastRunAt?: Date;
  lastRunStatus?: string;
  createdAt: Date;
  updatedAt: Date;
}

export interface CreateWorkflowRequest {
  workflowType: WorkflowType;
  n8nWorkflowId?: string;
  config: Record<string, any>;
}

export interface UpdateWorkflowRequest {
  config?: Record<string, any>;
  n8nWorkflowId?: string;
  status?: WorkflowStatus;
}

export interface WorkflowWithPermissions extends UserWorkflow {
  canActivate: boolean;
  canConfigure: boolean;
  requiresUpgrade: boolean;
  upgradeTier?: string;
}

export interface TierWorkflowMapping {
  tier: string;
  workflows: WorkflowType[];
  displayName: string;
}

export interface WorkflowActivationResult {
  success: boolean;
  workflowId: string;
  status: WorkflowStatus;
  message?: string;
}
