/** * Workflow API Service * * Handles all API calls related to workflow execution, status, * replay, restart, resume, and history. */ import { EnvType } from '../../types'; import { IRequestExtension } from '../../types/requests.types'; /** * Workflow status response from API */ export interface IWorkflowStatusResponse { workflow_id: string; workflow_tag: string; status: string; current_step?: string; completed_steps: string[]; state: Record; started_at: number; updated_at: number; input?: Record; output?: unknown; error?: { message: string; step?: string; code?: string; }; } /** * Workflow cancel response from API */ export interface IWorkflowCancelResponse { cancelled: boolean; rolled_back_steps: string[]; failed_rollbacks?: Array<{ tag: string; error: string; }>; } /** * Workflow history response from API */ export interface IWorkflowHistoryResponse { workflow_id: string; workflow_tag: string; status: string; events: Array<{ type: string; timestamp: number; data: Record; }>; checkpoints: Array<{ name: string; metadata?: Record; timestamp: number; }>; replays?: string[]; restarts?: string[]; } /** * Step detail response from API */ export interface IStepDetailResponse { tag: string; name?: string; status: string; input?: Record; output?: Record; error?: { message: string; code?: string; stack?: string; }; attempts: number; start_time?: number; end_time?: number; duration?: number; rollback_status?: string; rollback_error?: string; } /** * Related executions response from API */ export interface IRelatedExecutionsResponse { original: string; executions: Array<{ workflow_id: string; type: 'original' | 'replay' | 'restart' | 'resume'; status: string; created_at: number; replayed_from?: string; restarted_from?: string; resumed_from?: string; }>; } /** * Execution comparison response from API */ export interface IExecutionComparisonResponse { workflows: string[]; input_diff: Record; step_diffs: Array<{ step: string; [workflow_id: string]: unknown; }>; outcome_diff: Record; } /** * Replay/Restart/Resume request payloads */ export interface IReplayRequestPayload { product: string; env: string; reason?: string; options?: Record; idempotency_key?: string; } export interface IRestartRequestPayload { product: string; env: string; input?: Record; input_override?: Record; merge_input?: boolean; reason?: string; options?: Record; } export interface IResumeRequestPayload { product: string; env: string; from_checkpoint?: string; from_step?: string; skip_steps?: string[]; input?: Record; } export interface ISignalRequestPayload { product: string; env: string; signal: string; payload?: Record; } export interface IWorkflowApiService { getStatus(workflowId: string, productTag: string, env: string, auth: IRequestExtension): Promise; cancel(workflowId: string, productTag: string, env: string, reason: string, auth: IRequestExtension): Promise; sendSignal(workflowId: string, payload: ISignalRequestPayload, auth: IRequestExtension): Promise; getHistory(workflowId: string, productTag: string, env: string, auth: IRequestExtension): Promise; getStepDetail(workflowId: string, stepTag: string, productTag: string, env: string, auth: IRequestExtension): Promise; replay(workflowId: string, payload: IReplayRequestPayload, auth: IRequestExtension): Promise; restart(workflowId: string, payload: IRestartRequestPayload, auth: IRequestExtension): Promise; resume(workflowId: string, payload: IResumeRequestPayload, auth: IRequestExtension): Promise; getRelatedExecutions(workflowId: string, productTag: string, env: string, auth: IRequestExtension): Promise; compareExecutions(workflowIds: string[], productTag: string, env: string, auth: IRequestExtension): Promise; } export declare class WorkflowApiService implements IWorkflowApiService { private environment; constructor(environment: EnvType); /** * Get the status of a workflow execution */ getStatus(workflowId: string, productTag: string, env: string, auth: IRequestExtension): Promise; /** * Cancel a running workflow */ cancel(workflowId: string, productTag: string, env: string, reason: string, auth: IRequestExtension): Promise; /** * Send a signal to a running workflow */ sendSignal(workflowId: string, payload: ISignalRequestPayload, auth: IRequestExtension): Promise; /** * Get workflow execution history */ getHistory(workflowId: string, productTag: string, env: string, auth: IRequestExtension): Promise; /** * Get detailed information about a specific step */ getStepDetail(workflowId: string, stepTag: string, productTag: string, env: string, auth: IRequestExtension): Promise; /** * Replay a workflow with the same input */ replay(workflowId: string, payload: IReplayRequestPayload, auth: IRequestExtension): Promise; /** * Restart a workflow with new or modified input */ restart(workflowId: string, payload: IRestartRequestPayload, auth: IRequestExtension): Promise; /** * Resume a paused or failed workflow */ resume(workflowId: string, payload: IResumeRequestPayload, auth: IRequestExtension): Promise; /** * Get all related executions (replays, restarts, resumes) */ getRelatedExecutions(workflowId: string, productTag: string, env: string, auth: IRequestExtension): Promise; /** * Compare two workflow executions */ compareExecutions(workflowIds: string[], productTag: string, env: string, auth: IRequestExtension): Promise; }