import { ExecutionType } from '../enums/execution-type.enum';
import { CompletionCriteria } from '../enums/completion-criteria.enum';
import { RejectionHandling } from '../enums/rejection-handling.enum';

export interface DepartmentApproval {
  departmentCode: string;
  departmentName: string;
  canDelegate: boolean;
  timeoutDays?: number;
}

export interface WorkflowStage {
  stageId: string;
  stageName: string;
  stageOrder: number;
  executionType: ExecutionType; // SEQUENTIAL or PARALLEL
  requiredApprovals: DepartmentApproval[];
  completionCriteria: CompletionCriteria; // ALL, ANY, or THRESHOLD
  threshold?: number; // Required if completionCriteria is THRESHOLD
  timeoutDays?: number; // Optional timeout for entire stage
  rejectionHandling: RejectionHandling; // How to handle rejection at this stage
  escalationDepartment?: string; // Department to escalate to if ESCALATE handling
  metadata?: Record<string, any>;
}

export interface WorkflowDefinition {
  workflowType: string;
  name: string;
  description?: string;
  version: number;
  stages: WorkflowStage[];
  onSuccessActions?: string[]; // Actions to trigger on completion
  onFailureActions?: string[]; // Actions to trigger on failure
  metadata?: Record<string, any>;
}

export interface ValidationResult {
  isValid: boolean;
  errors: string[];
  warnings: string[];
}
