export type AutomationNodeType =
  | 'TRIGGER'
  | 'CONDITION'
  | 'ACTION'
  | 'WAIT'
  | 'BRANCH'
  | 'END';

export type AutomationChannel =
  | 'EMAIL'
  | 'WHATSAPP'
  | 'PUSH'
  | 'TASK'
  | 'WEBHOOK'
  | 'INTERNAL';

export type MessageChannel = 'EMAIL' | 'WHATSAPP' | 'PUSH';

export type AutomationLogStatus =
  | 'SUCCESS'
  | 'ERROR'
  | 'RETRY'
  | 'CANCELLED'
  | 'IGNORED'
  | 'WAITING'
  | 'PROCESSING';

export type AutomationRunStatus =
  | 'PENDING'
  | 'RUNNING'
  | 'WAITING'
  | 'SUCCESS'
  | 'FAILED'
  | 'CANCELLED'
  | 'SKIPPED';

export type AutomationStepStatus =
  | 'PENDING'
  | 'RUNNING'
  | 'WAITING'
  | 'SUCCESS'
  | 'FAILED'
  | 'CANCELLED'
  | 'SKIPPED';

export interface FlowNode {
  nodeKey: string;
  type: AutomationNodeType;
  label: string;
  description?: string;
  positionX: number;
  positionY: number;
  config: Record<string, unknown>;
  status?: 'valid' | 'invalid';
}

export interface FlowEdge {
  edgeKey: string;
  sourceNodeKey: string;
  targetNodeKey: string;
  label?: string | null;
  condition?: string | null;
}

export interface ValidationIssue {
  nodeKey?: string;
  code: string;
  message: string;
  severity: 'error' | 'warning';
}

export interface ValidationResult {
  valid: boolean;
  issues: ValidationIssue[];
}

export interface PublishedAutomationSummary {
  id: string;
  currentVersionId: string;
  triggerNodeKey?: string;
}

export interface PublishedAutomationDefinition {
  automation: {
    id: string;
    name: string;
    trigger: string;
    status: string;
    currentVersionId: string | null;
  };
  version: {
    id: string;
    versionNumber: number;
    status: string;
    publishedAt: string | null;
  };
  nodes: FlowNode[];
  edges: FlowEdge[];
}
