81 lines
3.5 KiB
Python
81 lines
3.5 KiB
Python
# Copyright (c) 2025 Patrick Motsch
|
|
# Data manipulation node definitions: aggregate, transform, filter.
|
|
|
|
from modules.shared.i18nRegistry import t
|
|
|
|
from modules.features.graphicalEditor.nodeDefinitions.ai import CONSOLIDATE_RESULT_DATA_PICK_OPTIONS
|
|
|
|
AGGREGATE_RESULT_DATA_PICK_OPTIONS = [
|
|
{
|
|
"path": ["items"],
|
|
"pickerLabel": t("Gesammelte Elemente"),
|
|
"detail": t("Alle aus der Schleife gesammelten Werte."),
|
|
"recommended": True,
|
|
"type": "List[Any]",
|
|
},
|
|
{
|
|
"path": ["count"],
|
|
"pickerLabel": t("Anzahl"),
|
|
"detail": t("Anzahl gesammelter Elemente."),
|
|
"recommended": False,
|
|
"type": "int",
|
|
},
|
|
]
|
|
|
|
DATA_NODES = [
|
|
{
|
|
"id": "data.aggregate",
|
|
"category": "data",
|
|
"label": t("Sammeln"),
|
|
"description": t("Ergebnisse aus Schleifen-Iterationen sammeln"),
|
|
"parameters": [
|
|
{"name": "mode", "type": "str", "required": False, "frontendType": "select",
|
|
"frontendOptions": {"options": ["collect", "concat", "sum", "count"]},
|
|
"description": t("Aggregationsmodus"), "default": "collect"},
|
|
],
|
|
"inputs": 1,
|
|
"outputs": 1,
|
|
"inputPorts": {0: {"accepts": ["Transit", "AiResult", "LoopItem"]}},
|
|
"outputPorts": {0: {"schema": "AggregateResult", "dataPickOptions": AGGREGATE_RESULT_DATA_PICK_OPTIONS}},
|
|
"executor": "data",
|
|
"meta": {"icon": "mdi-playlist-plus", "color": "#607D8B", "usesAi": False},
|
|
},
|
|
{
|
|
"id": "data.filter",
|
|
"category": "data",
|
|
"label": t("Filtern"),
|
|
"description": t("Elemente nach Bedingung filtern"),
|
|
"parameters": [
|
|
{"name": "condition", "type": "str", "required": True, "frontendType": "filterExpression",
|
|
"description": t("Filterbedingung")},
|
|
{"name": "udmContentType", "type": "str", "required": False, "frontendType": "select",
|
|
"frontendOptions": {"options": ["", "text", "image", "table", "code", "media", "link", "formula"]},
|
|
"description": t("UDM-ContentType-Filter (optional, leer = kein UDM-Filter)"), "default": ""},
|
|
],
|
|
"inputs": 1,
|
|
"outputs": 1,
|
|
"inputPorts": {0: {"accepts": ["AggregateResult", "FileList", "TaskList", "EmailList", "DocumentList", "UdmDocument", "UdmNodeList"]}},
|
|
"outputPorts": {0: {"schema": "Transit"}},
|
|
"executor": "data",
|
|
"meta": {"icon": "mdi-filter-outline", "color": "#607D8B", "usesAi": False},
|
|
},
|
|
{
|
|
"id": "data.consolidate",
|
|
"category": "data",
|
|
"label": t("Konsolidieren"),
|
|
"description": t("Gesammelte Ergebnisse deterministisch zusammenführen (Tabelle, CSV, Merge)"),
|
|
"parameters": [
|
|
{"name": "mode", "type": "str", "required": False, "frontendType": "select",
|
|
"frontendOptions": {"options": ["table", "concat", "merge", "csvJoin"]},
|
|
"description": t("Konsolidierungsmodus"), "default": "table"},
|
|
{"name": "separator", "type": "str", "required": False, "frontendType": "text",
|
|
"description": t("Trennzeichen (für concat/csvJoin)"), "default": "\n"},
|
|
],
|
|
"inputs": 1,
|
|
"outputs": 1,
|
|
"inputPorts": {0: {"accepts": ["AggregateResult", "Transit"]}},
|
|
"outputPorts": {0: {"schema": "ConsolidateResult", "dataPickOptions": CONSOLIDATE_RESULT_DATA_PICK_OPTIONS}},
|
|
"executor": "data",
|
|
"meta": {"icon": "mdi-table-merge-cells", "color": "#607D8B", "usesAi": False},
|
|
},
|
|
]
|