189 lines
8.1 KiB
Python
189 lines
8.1 KiB
Python
# Copyright (c) 2025 Patrick Motsch
|
|
# Input/Human node definitions - nodes that require user action.
|
|
|
|
from modules.shared.i18nRegistry import t
|
|
|
|
from modules.features.graphicalEditor.nodeDefinitions.ai import DOCUMENT_LIST_DATA_PICK_OPTIONS
|
|
|
|
BOOL_RESULT_DATA_PICK_OPTIONS = [
|
|
{
|
|
"path": ["result"],
|
|
"pickerLabel": t("Ergebnis"),
|
|
"detail": t("Boolesches Ergebnis (z. B. Genehmigung ja/nein)."),
|
|
"recommended": True,
|
|
"type": "bool",
|
|
},
|
|
{
|
|
"path": ["reason"],
|
|
"pickerLabel": t("Begründung"),
|
|
"detail": t("Optionale textuelle Begründung."),
|
|
"recommended": False,
|
|
"type": "str",
|
|
},
|
|
]
|
|
|
|
TEXT_RESULT_DATA_PICK_OPTIONS = [
|
|
{
|
|
"path": ["text"],
|
|
"pickerLabel": t("Text"),
|
|
"detail": t("Vom Benutzer eingegebener oder gewählter Text."),
|
|
"recommended": True,
|
|
"type": "str",
|
|
},
|
|
]
|
|
|
|
# Canonical form field types — single source of truth.
|
|
# portType maps to the PORT_TYPE_CATALOG primitive used by DataPicker / validateGraph.
|
|
FORM_FIELD_TYPES = [
|
|
{"id": "text", "label": "Text (einzeilig)", "portType": "str"},
|
|
{"id": "textarea", "label": "Text (mehrzeilig)", "portType": "str"},
|
|
{"id": "number", "label": "Zahl", "portType": "int"},
|
|
{"id": "boolean", "label": "Ja/Nein", "portType": "bool"},
|
|
{"id": "date", "label": "Datum", "portType": "str"},
|
|
{"id": "email", "label": "E-Mail", "portType": "str"},
|
|
{"id": "select", "label": "Auswahl", "portType": "str"},
|
|
]
|
|
|
|
INPUT_NODES = [
|
|
{
|
|
"id": "input.form",
|
|
"category": "input",
|
|
"label": t("Formular"),
|
|
"description": t("Benutzer füllt ein Formular aus"),
|
|
"parameters": [
|
|
{
|
|
"name": "fields",
|
|
"type": "json",
|
|
"required": True,
|
|
"frontendType": "fieldBuilder",
|
|
"description": t("Formularfelder"),
|
|
"default": [],
|
|
},
|
|
],
|
|
"inputs": 1,
|
|
"outputs": 1,
|
|
"inputPorts": {0: {"accepts": ["Transit"]}},
|
|
"outputPorts": {0: {"schema": {"kind": "fromGraph", "parameter": "fields"}}},
|
|
"executor": "input",
|
|
"meta": {"icon": "mdi-form-textbox", "color": "#9C27B0", "usesAi": False},
|
|
},
|
|
{
|
|
"id": "input.approval",
|
|
"category": "input",
|
|
"label": t("Genehmigung"),
|
|
"description": t("Benutzer genehmigt oder lehnt ab"),
|
|
"parameters": [
|
|
{"name": "title", "type": "str", "required": True, "frontendType": "text",
|
|
"description": t("Genehmigungstitel")},
|
|
{"name": "description", "type": "str", "required": False, "frontendType": "textarea",
|
|
"description": t("Was genehmigt werden soll")},
|
|
{"name": "approvalType", "type": "str", "required": False, "frontendType": "select",
|
|
"frontendOptions": {"options": ["generic", "document"]},
|
|
"description": t("Typ: document oder generic"), "default": "generic"},
|
|
],
|
|
"inputs": 1,
|
|
"outputs": 1,
|
|
"inputPorts": {0: {"accepts": ["Transit"]}},
|
|
"outputPorts": {0: {"schema": "BoolResult", "dataPickOptions": BOOL_RESULT_DATA_PICK_OPTIONS}},
|
|
"executor": "input",
|
|
"meta": {"icon": "mdi-check-decagram", "color": "#4CAF50", "usesAi": False},
|
|
},
|
|
{
|
|
"id": "input.upload",
|
|
"category": "input",
|
|
"label": t("Upload"),
|
|
"description": t("Benutzer lädt Datei(en) hoch"),
|
|
"parameters": [
|
|
{"name": "accept", "type": "str", "required": False, "frontendType": "text",
|
|
"description": t("Accept-String"), "default": ""},
|
|
{"name": "allowedTypes", "type": "json", "required": False, "frontendType": "multiselect",
|
|
"frontendOptions": {"options": ["pdf", "docx", "xlsx", "pptx", "txt", "csv", "jpg", "png", "gif"]},
|
|
"description": t("Ausgewählte Dateitypen"), "default": []},
|
|
{"name": "maxSize", "type": "int", "required": False, "frontendType": "number",
|
|
"description": t("Max. Dateigröße in MB"), "default": 10},
|
|
{"name": "multiple", "type": "bool", "required": False, "frontendType": "checkbox",
|
|
"description": t("Mehrere Dateien erlauben"), "default": False},
|
|
],
|
|
"inputs": 1,
|
|
"outputs": 1,
|
|
"inputPorts": {0: {"accepts": ["Transit"]}},
|
|
"outputPorts": {0: {"schema": "DocumentList", "dataPickOptions": DOCUMENT_LIST_DATA_PICK_OPTIONS}},
|
|
"executor": "input",
|
|
"meta": {"icon": "mdi-upload", "color": "#2196F3", "usesAi": False},
|
|
},
|
|
{
|
|
"id": "input.comment",
|
|
"category": "input",
|
|
"label": t("Kommentar"),
|
|
"description": t("Benutzer fügt einen Kommentar hinzu"),
|
|
"parameters": [
|
|
{"name": "placeholder", "type": "str", "required": False, "frontendType": "text",
|
|
"description": t("Platzhalter"), "default": ""},
|
|
{"name": "required", "type": "bool", "required": False, "frontendType": "checkbox",
|
|
"description": t("Kommentar erforderlich"), "default": True},
|
|
],
|
|
"inputs": 1,
|
|
"outputs": 1,
|
|
"inputPorts": {0: {"accepts": ["Transit"]}},
|
|
"outputPorts": {0: {"schema": "TextResult", "dataPickOptions": TEXT_RESULT_DATA_PICK_OPTIONS}},
|
|
"executor": "input",
|
|
"meta": {"icon": "mdi-comment-text", "color": "#FF9800", "usesAi": False},
|
|
},
|
|
{
|
|
"id": "input.review",
|
|
"category": "input",
|
|
"label": t("Prüfung"),
|
|
"description": t("Benutzer prüft Inhalt"),
|
|
"parameters": [
|
|
{"name": "contentRef", "type": "str", "required": True, "frontendType": "text",
|
|
"description": t("Referenz auf Inhalt")},
|
|
{"name": "reviewType", "type": "str", "required": False, "frontendType": "select",
|
|
"frontendOptions": {"options": ["generic", "document"]},
|
|
"description": t("Art der Prüfung"), "default": "generic"},
|
|
],
|
|
"inputs": 1,
|
|
"outputs": 1,
|
|
"inputPorts": {0: {"accepts": ["Transit"]}},
|
|
"outputPorts": {0: {"schema": "BoolResult", "dataPickOptions": BOOL_RESULT_DATA_PICK_OPTIONS}},
|
|
"executor": "input",
|
|
"meta": {"icon": "mdi-magnify-scan", "color": "#673AB7", "usesAi": False},
|
|
},
|
|
{
|
|
"id": "input.selection",
|
|
"category": "input",
|
|
"label": t("Auswahl"),
|
|
"description": t("Benutzer wählt aus Optionen"),
|
|
"parameters": [
|
|
{"name": "options", "type": "json", "required": True, "frontendType": "keyValueRows",
|
|
"description": t("Optionen"), "default": []},
|
|
{"name": "multiple", "type": "bool", "required": False, "frontendType": "checkbox",
|
|
"description": t("Mehrfachauswahl erlauben"), "default": False},
|
|
],
|
|
"inputs": 1,
|
|
"outputs": 1,
|
|
"inputPorts": {0: {"accepts": ["Transit"]}},
|
|
"outputPorts": {0: {"schema": "TextResult", "dataPickOptions": TEXT_RESULT_DATA_PICK_OPTIONS}},
|
|
"executor": "input",
|
|
"meta": {"icon": "mdi-format-list-checks", "color": "#009688", "usesAi": False},
|
|
},
|
|
{
|
|
"id": "input.confirmation",
|
|
"category": "input",
|
|
"label": t("Bestätigung"),
|
|
"description": t("Benutzer bestätigt Ja/Nein"),
|
|
"parameters": [
|
|
{"name": "question", "type": "str", "required": True, "frontendType": "text",
|
|
"description": t("Zu bestätigende Frage")},
|
|
{"name": "confirmLabel", "type": "str", "required": False, "frontendType": "text",
|
|
"description": t("Label für Bestätigen-Button"), "default": "Confirm"},
|
|
{"name": "rejectLabel", "type": "str", "required": False, "frontendType": "text",
|
|
"description": t("Label für Ablehnen-Button"), "default": "Reject"},
|
|
],
|
|
"inputs": 1,
|
|
"outputs": 1,
|
|
"inputPorts": {0: {"accepts": ["Transit"]}},
|
|
"outputPorts": {0: {"schema": "BoolResult", "dataPickOptions": BOOL_RESULT_DATA_PICK_OPTIONS}},
|
|
"executor": "input",
|
|
"meta": {"icon": "mdi-checkbox-marked-circle", "color": "#8BC34A", "usesAi": False},
|
|
},
|
|
]
|