import { request } from '@umijs/max';
import { WorkflowTask } from '../pages/WorkflowOrchestrator/data';

/**
 * 获取工作流任务列表
 */
export async function queryWorkflowList(params?: any) {
    return request<{ data: WorkflowTask[]; total: number }>('/api/workflow/list', {
        method: 'GET',
        params,
    });
}

/**
 * 获取工作流详情
 */
export async function getWorkflowDetail(id: string) {
    return request<{ data: WorkflowTask }>(`/api/workflow/${id}`, {
        method: 'GET',
    });
}

/**
 * 控制工作流状态 (停止/重试/恢复)
 */
export async function controlWorkflow(id: string, action: 'stop' | 'retry' | 'resume') {
    return request(`/api/workflow/${id}/control`, {
        method: 'POST',
        data: { action },
    });
}
