/** * Feature Control Plane API Service * * Handles all API calls related to feature execution, status, * replay, restart, resume, and history. */ import { EnvType } from '../../types'; import { IRequestExtension } from '../../types/requests.types'; /** * Feature status response from API */ export interface IFeatureStatusResponse { feature_id: string; feature_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; }; } /** * Feature cancel response from API */ export interface IFeatureCancelResponse { cancelled: boolean; rolled_back_steps: string[]; failed_rollbacks?: Array<{ tag: string; error: string; }>; } /** * Feature history response from API */ export interface IFeatureHistoryResponse { feature_id: string; feature_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<{ feature_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 { features: string[]; input_diff: Record; step_diffs: Array<{ step: string; [feature_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 IFeatureApiService { 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(featureIds: string[], productTag: string, env: string, auth: IRequestExtension): Promise; } export declare class FeatureApiService implements IFeatureApiService { private environment; constructor(environment: EnvType); /** * Get the status of a feature execution */ getStatus(workflowId: string, productTag: string, env: string, auth: IRequestExtension): Promise; /** * Cancel a running feature */ cancel(workflowId: string, productTag: string, env: string, reason: string, auth: IRequestExtension): Promise; /** * Send a signal to a running feature */ sendSignal(workflowId: string, payload: ISignalRequestPayload, auth: IRequestExtension): Promise; /** * Get feature 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 feature with the same input */ replay(workflowId: string, payload: IReplayRequestPayload, auth: IRequestExtension): Promise; /** * Restart a feature with new or modified input */ restart(workflowId: string, payload: IRestartRequestPayload, auth: IRequestExtension): Promise; /** * Resume a paused or failed feature */ 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 feature executions */ compareExecutions(featureIds: string[], productTag: string, env: string, auth: IRequestExtension): Promise; }