/**
 * Workflow Step Status
 */
export type WorkflowStepStatus = "pending" | "in_progress" | "completed" | "failed" | "skipped";

/**
 * Represents a single step in a workflow
 */
export interface WorkflowStep {
  id: string;
  label: string;
  status: WorkflowStepStatus;
  startedAt?: Date | undefined;
  completedAt?: Date | undefined;
  error?: string | undefined;
}

/**
 * Configuration for defining a workflow step
 */
export interface WorkflowStepConfig {
  id: string;
  label: string;
  /** Whether this step should be included based on runtime conditions */
  condition?: boolean;
}

/**
 * Context for tracking workflow steps
 */
export interface WorkflowStepContext {
  /** All steps in the workflow */
  steps: WorkflowStep[];

  /**
   * Update the status of a step
   */
  updateStatus(stepId: string, status: WorkflowStepStatus, error?: string): void;

  /**
   * Wrap an async executor to automatically track step status
   * Returns a function that can be passed to distributed transaction steps
   */
  wrap<T>(stepId: string, executor: () => Promise<T>): () => Promise<T>;

  /**
   * Get the first failed step, if any
   */
  getFailedStep(): WorkflowStep | undefined;

  /**
   * Check if all steps completed successfully
   */
  isComplete(): boolean;

  /**
   * Mark a step as skipped
   */
  skip(stepId: string): void;
}
