# Copyright (c) 2025 Patrick Motsch
# All rights reserved.
"""ClickUp nodes — map to MethodClickup actions."""

from modules.shared.i18nRegistry import t

CLICKUP_NODES = [
    {
        "id": "clickup.searchTasks",
        "category": "clickup",
        "label": t("Aufgaben suchen"),
        "description": t("Aufgaben in einem Workspace suchen"),
        "parameters": [
            {"name": "connectionReference", "type": "string", "required": True, "frontendType": "userConnection",
             "description": t("ClickUp-Verbindung")},
            {"name": "teamId", "type": "string", "required": True, "frontendType": "text",
             "description": t("Team-/Workspace-ID")},
            {"name": "query", "type": "string", "required": True, "frontendType": "text",
             "description": t("Suchbegriff")},
            {"name": "page", "type": "number", "required": False, "frontendType": "number",
             "description": t("Seite"), "default": 0},
            {"name": "listId", "type": "string", "required": False, "frontendType": "clickupList",
             "frontendOptions": {"dependsOn": "connectionReference"},
             "description": t("In dieser Liste suchen")},
            {"name": "includeClosed", "type": "boolean", "required": False, "frontendType": "checkbox",
             "description": t("Erledigte einbeziehen"), "default": False},
            {"name": "fullTaskData", "type": "boolean", "required": False, "frontendType": "checkbox",
             "description": t("Vollständige Daten"), "default": False},
            {"name": "matchNameOnly", "type": "boolean", "required": False, "frontendType": "checkbox",
             "description": t("Nur Titel"), "default": True},
        ],
        "inputs": 1,
        "outputs": 1,
        "inputPorts": {0: {"accepts": ["Transit"]}},
        "outputPorts": {0: {"schema": "TaskList"}},
        "meta": {"icon": "mdi-magnify", "color": "#7B68EE"},
        "_method": "clickup",
        "_action": "searchTasks",
    },
    {
        "id": "clickup.listTasks",
        "category": "clickup",
        "label": t("Aufgaben auflisten"),
        "description": t("Aufgaben einer Liste auflisten"),
        "parameters": [
            {"name": "connectionReference", "type": "string", "required": True, "frontendType": "userConnection",
             "description": t("ClickUp-Verbindung")},
            {"name": "pathQuery", "type": "string", "required": True, "frontendType": "clickupList",
             "frontendOptions": {"dependsOn": "connectionReference"},
             "description": t("Pfad zur Liste")},
            {"name": "page", "type": "number", "required": False, "frontendType": "number",
             "description": t("Seite"), "default": 0},
            {"name": "includeClosed", "type": "boolean", "required": False, "frontendType": "checkbox",
             "description": t("Erledigte einbeziehen"), "default": False},
        ],
        "inputs": 1,
        "outputs": 1,
        "inputPorts": {0: {"accepts": ["Transit"]}},
        "outputPorts": {0: {"schema": "TaskList"}},
        "meta": {"icon": "mdi-format-list-bulleted", "color": "#7B68EE"},
        "_method": "clickup",
        "_action": "listTasks",
    },
    {
        "id": "clickup.getTask",
        "category": "clickup",
        "label": t("Aufgabe abrufen"),
        "description": t("Eine Aufgabe abrufen"),
        "parameters": [
            {"name": "connectionReference", "type": "string", "required": True, "frontendType": "userConnection",
             "description": t("ClickUp-Verbindung")},
            {"name": "taskId", "type": "string", "required": False, "frontendType": "text",
             "description": t("Task-ID")},
            {"name": "pathQuery", "type": "string", "required": False, "frontendType": "text",
             "description": t("Oder Pfad")},
        ],
        "inputs": 1,
        "outputs": 1,
        "inputPorts": {0: {"accepts": ["Transit"]}},
        "outputPorts": {0: {"schema": "TaskResult"}},
        "meta": {"icon": "mdi-file-document-outline", "color": "#7B68EE"},
        "_method": "clickup",
        "_action": "getTask",
    },
    {
        "id": "clickup.createTask",
        "category": "clickup",
        "label": t("Aufgabe erstellen"),
        "description": t("Aufgabe erstellen"),
        "parameters": [
            {"name": "connectionReference", "type": "string", "required": True, "frontendType": "userConnection",
             "description": t("ClickUp-Verbindung")},
            {"name": "teamId", "type": "string", "required": False, "frontendType": "text",
             "description": t("Workspace")},
            {"name": "pathQuery", "type": "string", "required": False, "frontendType": "clickupList",
             "frontendOptions": {"dependsOn": "connectionReference"},
             "description": t("Pfad zur Liste")},
            {"name": "listId", "type": "string", "required": False, "frontendType": "text",
             "description": t("Listen-ID")},
            {"name": "name", "type": "string", "required": True, "frontendType": "text",
             "description": t("Name")},
            {"name": "description", "type": "string", "required": False, "frontendType": "textarea",
             "description": t("Beschreibung")},
            {"name": "taskStatus", "type": "string", "required": False, "frontendType": "text",
             "description": t("Status")},
            {"name": "taskPriority", "type": "string", "required": False, "frontendType": "select",
             "frontendOptions": {"options": ["1", "2", "3", "4"]},
             "description": t("Priorität 1-4")},
            {"name": "taskDueDateMs", "type": "string", "required": False, "frontendType": "text",
             "description": t("Fälligkeit (ms)")},
            {"name": "taskAssigneeIds", "type": "object", "required": False, "frontendType": "json",
             "description": t("Zugewiesene")},
            {"name": "taskTimeEstimateMs", "type": "string", "required": False, "frontendType": "text",
             "description": t("Zeitschätzung (ms)")},
            {"name": "taskTimeEstimateHours", "type": "string", "required": False, "frontendType": "text",
             "description": t("Zeitschätzung (h)")},
            {"name": "customFieldValues", "type": "object", "required": False, "frontendType": "json",
             "description": t("Benutzerdefinierte Felder")},
            {"name": "taskFields", "type": "string", "required": False, "frontendType": "json",
             "description": t("Zusätzliches JSON")},
        ],
        "inputs": 1,
        "outputs": 1,
        "inputPorts": {0: {"accepts": ["Transit"]}},
        "outputPorts": {0: {"schema": "TaskResult"}},
        "meta": {"icon": "mdi-plus-circle-outline", "color": "#7B68EE"},
        "_method": "clickup",
        "_action": "createTask",
    },
    {
        "id": "clickup.updateTask",
        "category": "clickup",
        "label": t("Aufgabe aktualisieren"),
        "description": t("Felder der Aufgabe ändern"),
        "parameters": [
            {"name": "connectionReference", "type": "string", "required": True, "frontendType": "userConnection",
             "description": t("ClickUp-Verbindung")},
            {"name": "taskId", "type": "string", "required": False, "frontendType": "text",
             "description": t("Task-ID")},
            {"name": "path", "type": "string", "required": False, "frontendType": "text",
             "description": t("Oder Pfad")},
            {"name": "taskUpdateEntries", "type": "object", "required": False, "frontendType": "keyValueRows",
             "description": t("Zu ändernde Felder")},
            {"name": "taskUpdate", "type": "string", "required": False, "frontendType": "json",
             "description": t("JSON für API")},
        ],
        "inputs": 1,
        "outputs": 1,
        "inputPorts": {0: {"accepts": ["TaskResult", "Transit"]}},
        "outputPorts": {0: {"schema": "TaskResult"}},
        "meta": {"icon": "mdi-pencil-outline", "color": "#7B68EE"},
        "_method": "clickup",
        "_action": "updateTask",
    },
    {
        "id": "clickup.uploadAttachment",
        "category": "clickup",
        "label": t("Anhang hochladen"),
        "description": t("Datei an Task anhängen"),
        "parameters": [
            {"name": "connectionReference", "type": "string", "required": True, "frontendType": "userConnection",
             "description": t("ClickUp-Verbindung")},
            {"name": "taskId", "type": "string", "required": False, "frontendType": "text",
             "description": t("Task-ID")},
            {"name": "path", "type": "string", "required": False, "frontendType": "text",
             "description": t("Oder Pfad")},
            {"name": "fileName", "type": "string", "required": False, "frontendType": "text",
             "description": t("Dateiname")},
        ],
        "inputs": 1,
        "outputs": 1,
        "inputPorts": {0: {"accepts": ["DocumentList", "Transit"]}},
        "outputPorts": {0: {"schema": "ActionResult"}},
        "meta": {"icon": "mdi-attachment", "color": "#7B68EE"},
        "_method": "clickup",
        "_action": "uploadAttachment",
    },
]
