package com.qqchen.deploy.backend.workflow.dto.definition.node.panelVariables;

import com.qqchen.deploy.backend.workflow.annotation.CodeEditorConfig;
import com.qqchen.deploy.backend.workflow.annotation.SchemaProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * 脚本执行器配置
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class ScriptNodePanelVariables extends BaseNodePanelVariables {

    @SchemaProperty(
        title = "委派者",
        description = "委派者",
        defaultValue = "${shellNodeDelegate}",
        required = true,
        readOnly = true,
        order = 1
    )
    private String delegate;

    /**
     * 脚本语言
     */
    @SchemaProperty(
        title = "脚本语言",
        description = "脚本语言类型",
        required = true,
        enumValues = {"shell", "python", "javascript", "groovy"},
        enumNames = {"Shell脚本 (已支持)", "Python脚本 (开发中)", "JavaScript脚本 (开发中)", "Groovy脚本 (开发中)"},
        defaultValue = "shell",
        order = 10
    )
    private String language;

    @SchemaProperty(
        title = "脚本代码",
        description = "脚本代码",
        required = true,
        format = "monaco-editor",
        codeEditor = @CodeEditorConfig(
            language = "shell",
            theme = "vs-dark",
            minimap = false,
            lineNumbers = true,
            wordWrap = true,
            fontSize = 14,
            tabSize = 2,
            autoComplete = true,
            folding = true
        ),
        order = 20
    )
    private String script;

    @SchemaProperty(
        title = "解释器路径",
        description = "脚本解释器的路径，例如：/bin/bash, /usr/bin/python3",
        required = true,
        order = 30
    )
    private String interpreter;

    @SchemaProperty(
        title = "成功标识",
        description = "脚本执行成功时的标识",
        required = true,
        order = 40
    )
    private Integer successExitCode;

    /**
     * 支持的脚本语言列表
     */
    @SchemaProperty(
        title = "支持的脚本语言",
        enumValues = {"shell", "python", "javascript", "groovy"},
        enumNames = {"Shell脚本 (已支持)", "Python脚本 (开发中)", "JavaScript脚本 (开发中)", "Groovy脚本 (开发中)"},
        order = 50
    )
    private List<String> supportedLanguages;

}
