import { BaseQuery } from '@/types/base';

/**
 * 工作流模板及其实例信息
 */
export interface WorkflowTemplateWithInstances {
    id: number;
    name: string;
    businessKey: string;
    lastExecutionTime: string;
    lastExecutionStatus: string;
}

/**
 * 工作流实例查询参数
 */
export interface WorkflowTemplateWithInstancesQuery extends BaseQuery {
    businessKey?: string;
    status?: string;
}

/**
 * 工作流实例阶段
 */
export interface WorkflowInstanceStage {
    id: number | null;
    nodeId: string;
    nodeName: string;
    nodeType: string;
    status: string;
    startTime: string | null;
    endTime: string | null;
}

/**
 * 工作流图节点
 */
export interface WorkflowGraphNode {
    id: string;
    nodeCode: string;
    nodeType: string;
    nodeName: string;
    position: {
        x: number;
        y: number;
    };
    configs: Record<string, any>;
    inputMapping: Record<string, any>;
    outputs: any[];
}

/**
 * 工作流图边
 */
export interface WorkflowGraphEdge {
    id: string;
    from: string;
    to: string;
    name: string;
    config: {
        type: string;
        condition: {
            type: string;
            priority: number;
        };
    };
    vertices: any[];
}

/**
 * 工作流图
 */
export interface WorkflowGraph {
    nodes: WorkflowGraphNode[];
    edges: WorkflowGraphEdge[];
}

/**
 * 工作流历史实例
 */
export interface WorkflowHistoricalInstance {
    id: number;
    processInstanceId: string;
    processDefinitionId: string;
    businessKey: string;
    status: string;
    startTime: string;
    endTime: string | null;
    stages: WorkflowInstanceStage[];
    graph?: WorkflowGraph;
}

/**
 * 工作流历史实例查询参数
 */
export interface WorkflowHistoricalInstanceQuery extends BaseQuery {
    workflowDefinitionId?: number;
}
