# Copyright (c) 2025 Patrick Motsch
# Data manipulation node definitions: aggregate, transform, filter.

from modules.shared.i18nRegistry import t

DATA_NODES = [
    {
        "id": "data.aggregate",
        "category": "data",
        "label": t("Sammeln"),
        "description": t("Ergebnisse aus Schleifen-Iterationen sammeln"),
        "parameters": [
            {"name": "mode", "type": "string", "required": False, "frontendType": "select",
             "frontendOptions": {"options": ["collect", "concat", "sum", "count"]},
             "description": t("Aggregationsmodus"), "default": "collect"},
        ],
        "inputs": 1,
        "outputs": 1,
        "inputPorts": {0: {"accepts": ["Transit"]}},
        "outputPorts": {0: {"schema": "AggregateResult"}},
        "executor": "data",
        "meta": {"icon": "mdi-playlist-plus", "color": "#607D8B"},
    },
    {
        "id": "data.transform",
        "category": "data",
        "label": t("Umwandeln"),
        "description": t("Daten umstrukturieren"),
        "parameters": [
            {"name": "mappings", "type": "json", "required": True, "frontendType": "mappingTable",
             "description": t("Feld-Zuordnungen"), "default": []},
        ],
        "inputs": 1,
        "outputs": 1,
        "inputPorts": {0: {"accepts": ["Transit"]}},
        "outputPorts": {0: {"schema": "ActionResult", "dynamic": True, "deriveFrom": "mappings"}},
        "executor": "data",
        "meta": {"icon": "mdi-swap-horizontal-bold", "color": "#607D8B"},
    },
    {
        "id": "data.filter",
        "category": "data",
        "label": t("Filtern"),
        "description": t("Elemente nach Bedingung filtern"),
        "parameters": [
            {"name": "condition", "type": "string", "required": True, "frontendType": "filterExpression",
             "description": t("Filterbedingung")},
        ],
        "inputs": 1,
        "outputs": 1,
        "inputPorts": {0: {"accepts": ["AggregateResult", "FileList", "TaskList", "EmailList", "DocumentList"]}},
        "outputPorts": {0: {"schema": "Transit"}},
        "executor": "data",
        "meta": {"icon": "mdi-filter-outline", "color": "#607D8B"},
    },
]
