// 节点设计相关类型定义

// 基础Schema接口
import {BaseQuery, BaseResponse} from "@/types/base";

export interface BaseSchema {
    type: string;
    properties: Record<string, any>;
    required?: string[];
}

// 节点变量Schema
export interface NodeVariablesSchema extends BaseSchema {
    title?: string;
    description?: string;
}

// UI配置中的大小接口
export interface NodeSize {
    width: number;
    height: number;
}

// 端口样式配置
export interface PortStyle {
    r: number;
    fill: string;
    stroke: string;
}

// 端口属性配置
export interface PortAttributes {
    circle: PortStyle;
}

// 端口位置类型
export type PortPosition = 'left' | 'right' | 'top' | 'bottom';

// 端口配置
export interface PortConfig {
    attrs: PortAttributes;
    position: PortPosition;
}

// 端口组配置
export interface PortGroups {
    in: PortConfig;
    out: PortConfig;
}

// 节点形状类型
export type NodeShape = 'rect' | 'circle' | 'diamond';

// 节点样式配置
export interface NodeStyle {
    fill: string;
    icon: string;
    stroke: string;
    iconColor: string;
    strokeWidth: number;
}

// UI变量配置
export interface UIVariables extends BaseSchema {
    size: NodeSize;
    ports: {
        groups: PortGroups;
    };
    shape: NodeShape;
    style: NodeStyle;
}

// 节点设计数据
export interface NodeDesignDataResponse extends BaseResponse {
    nodeCode: string;
    nodeName: string;
    nodeType: string;
    category: string;
    description: string;
    panelVariablesSchema: NodeVariablesSchema | null;
    localVariablesSchema: NodeVariablesSchema | null;
    formVariablesSchema: NodeVariablesSchema | null;
    uiVariables: UIVariables;
}

// 节点类型枚举
export enum NodeTypeEnum {
    START_EVENT = 'START_EVENT',
    END_EVENT = 'END_EVENT',
    SCRIPT_TASK = 'SCRIPT_TASK',
}

// 查询参数接口
export interface NodeDesignQuery extends BaseQuery {
    nodeCode?: string;
    nodeName?: string;
}

// 分页响应接口
export interface NodeDefinitionResponse extends BaseResponse {
    nodeCode: string;
    nodeName: string;
    nodeType: NodeTypeEnum;
    category: string;
    description: string;
    panelVariablesSchema: NodeVariablesSchema | null;
    uiVariables: UIVariables | null;
    localVariablesSchema: NodeVariablesSchema | null;
    panelVariables?: Record<string, any>;
    localVariables?: Record<string, any>;
}
