import {ConfigurableNodeDefinition, NodeType, NodeCategory, defineNodeOutputs} from './types';
import { DataSourceType } from '@/domain/dataSource';

/**
 * 通知节点定义
 * 用于发送各种类型的通知（邮件、钉钉、企业微信等）
 */
export const NotificationNodeDefinition: ConfigurableNodeDefinition = {
    nodeCode: "NOTIFICATION",
    nodeName: "通知",
    nodeType: NodeType.NOTIFICATION,
    category: NodeCategory.TASK,
    description: "发送通知消息到指定渠道",

    // 渲染配置
    renderConfig: {
        shape: 'rounded-rect',
        size: {width: 120, height: 60},
        icon: {
            type: 'emoji',
            content: '🔔',
            size: 24
        },
        theme: {
            primary: '#f59e0b',
            secondary: '#d97706',
            selectedBorder: '#3b82f6',
            hoverBorder: '#f59e0b',
            gradient: ['#ffffff', '#fef3c7']
        },
        handles: {
            input: true,
            output: true
        },
        features: {
            showBadge: true,
            showHoverMenu: true
        }
    },

    // 基本配置Schema（仅业务配置，元数据已移至固定表单）
    inputMappingSchema: {
        type: "object",
        title: "输入",
        description: "当前节点所需数据配置",
        properties: {
            continueOnFailure: {
                type: "boolean",
                title: "失败后继续",
                description: "当节点执行失败时，是否继续执行后续节点。true: 节点失败时标记为 FAILURE，但流程继续执行后续节点；false: 节点失败时抛出 BpmnError，终止流程",
                default: true
            },
            // notificationType: {
            //     type: "string",
            //     title: "通知类型",
            //     description: "选择通知发送的渠道",
            //     enum: ["EMAIL", "DINGTALK", "WECHAT_WORK", "SMS"],
            //     enumNames: ["邮件", "钉钉", "企业微信", "短信"],
            //     default: "EMAIL"
            // },
            // notificationChannelType: {
            //     type: "string",
            //     title: "通知类型",
            //     description: "选择通知发送的渠道",
            //     'x-dataSource': DataSourceType.NOTIFICATION_CHANNEL_TYPES
            // },
            channelId: {
                type: "number",
                title: "通知渠道",
                description: "选择通知发送的渠道",
                "x-dataSource": DataSourceType.NOTIFICATION_CHANNELS,
                "x-allow-variable": true
            },
            notificationTemplateId: {
                type: "number",
                title: "通知模板",
                description: "选择通知模板，或输入动态值",
                "x-dataSource": DataSourceType.NOTIFICATION_TEMPLATES,
                "x-allow-variable": true,
                "x-depends-on": "channelId"
            }
        },
        required: ["channelId", "notificationTemplateId"]
    },
    outputs: defineNodeOutputs()
};

