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

export interface WorkflowDefinition extends BaseResponse {
    id: number;
    name: string;
    key: string;
    description?: string;
    flowVersion?: number;
    status?: string;
    category: string;
    triggers: string[];
    graph: {
        nodes: WorkflowDefinitionNode[];
        edges: any[];
    };
    formConfig: {
        formItems: any[];
    };
    formVariablesSchema?: {
        type: string;
        required?: string[];
        properties: {
            [key: string]: {
                type: string;
                title: string;
                description?: string;
                dataSource?: {
                    url: string;
                    type: string;
                    params?: Record<string, any>;
                    dependsOn?: string[];
                    labelField?: string;
                    valueField?: string;
                };
            };
        };
    };
    bpmnXml?: string;
}

export interface WorkflowDefinitionNode {
    id: number;
    nodeCode: string;
    nodeType: string;
    nodeName: string;
    uiVariables: JSON;
    panelVariables: JSON;
    localVariables: JSON;
}

export interface WorkflowDefinitionQuery extends BaseQuery {
    name?: string;
    key?: string;
    status?: string;
}

/**
 * 工作流触发器类型
 */
export interface WorkflowTrigger {
    code: string;
    label: string;
}

/**
 * 工作流分类
 */
export interface WorkflowCategory {
    code: string;
    label: string;
    description: string;
    supportedTriggers: WorkflowTrigger[];
}
