# Copyright (c) 2025 Patrick Motsch
# Trustee node definitions - map to methodTrustee actions.

from modules.shared.i18nRegistry import t

TRUSTEE_NODES = [
    {
        "id": "trustee.refreshAccountingData",
        "category": "trustee",
        "label": t("Buchhaltungsdaten aktualisieren"),
        "description": t("Buchhaltungsdaten aus externem System importieren/aktualisieren."),
        "parameters": [
            {"name": "featureInstanceId", "type": "string", "required": True, "frontendType": "hidden",
             "description": t("Trustee Feature-Instanz-ID")},
            {"name": "forceRefresh", "type": "boolean", "required": False, "frontendType": "checkbox",
             "description": t("Import erzwingen"), "default": False},
            {"name": "dateFrom", "type": "string", "required": False, "frontendType": "date",
             "description": t("Startdatum"), "default": ""},
            {"name": "dateTo", "type": "string", "required": False, "frontendType": "date",
             "description": t("Enddatum"), "default": ""},
        ],
        "inputs": 1,
        "outputs": 1,
        "inputPorts": {0: {"accepts": ["Transit"]}},
        "outputPorts": {0: {"schema": "ActionResult"}},
        "meta": {"icon": "mdi-database-refresh", "color": "#4CAF50"},
        "_method": "trustee",
        "_action": "refreshAccountingData",
    },
    {
        "id": "trustee.extractFromFiles",
        "category": "trustee",
        "label": t("Dokumente extrahieren"),
        "description": t("Dokumenttyp und Daten aus PDF/JPG per AI extrahieren."),
        "parameters": [
            {"name": "connectionReference", "type": "string", "required": False, "frontendType": "userConnection",
             "description": t("SharePoint-Verbindung"), "default": ""},
            {"name": "sharepointFolder", "type": "string", "required": False, "frontendType": "sharepointFolder",
             "frontendOptions": {"dependsOn": "connectionReference"},
             "description": t("SharePoint-Ordnerpfad"), "default": ""},
            {"name": "featureInstanceId", "type": "string", "required": True, "frontendType": "hidden",
             "description": t("Trustee Feature-Instanz-ID")},
            {"name": "prompt", "type": "string", "required": False, "frontendType": "textarea",
             "description": t("AI-Prompt für Extraktion"), "default": ""},
        ],
        "inputs": 1,
        "outputs": 1,
        "inputPorts": {0: {"accepts": ["DocumentList", "Transit"]}},
        "outputPorts": {0: {"schema": "DocumentList"}},
        "meta": {"icon": "mdi-file-document-scan", "color": "#4CAF50"},
        "_method": "trustee",
        "_action": "extractFromFiles",
    },
    {
        "id": "trustee.processDocuments",
        "category": "trustee",
        "label": t("Dokumente verarbeiten"),
        "description": t("TrusteeDocument + TrusteePosition aus Extraktionsergebnis erstellen."),
        "parameters": [
            {"name": "documentList", "type": "string", "required": False, "frontendType": "hidden",
             "description": t("Automatisch via Wire-Verbindung befüllt")},
            {"name": "featureInstanceId", "type": "string", "required": True, "frontendType": "hidden",
             "description": t("Trustee Feature-Instanz-ID")},
        ],
        "inputs": 1,
        "outputs": 1,
        "inputPorts": {0: {"accepts": ["DocumentList", "Transit"]}},
        "outputPorts": {0: {"schema": "ActionResult"}},
        "meta": {"icon": "mdi-file-document-check", "color": "#4CAF50"},
        "_method": "trustee",
        "_action": "processDocuments",
    },
    {
        "id": "trustee.syncToAccounting",
        "category": "trustee",
        "label": t("In Buchhaltung synchronisieren"),
        "description": t("Trustee-Positionen in Buchhaltungssystem übertragen."),
        "parameters": [
            {"name": "documentList", "type": "string", "required": False, "frontendType": "hidden",
             "description": t("Automatisch via Wire-Verbindung befüllt")},
            {"name": "featureInstanceId", "type": "string", "required": True, "frontendType": "hidden",
             "description": t("Trustee Feature-Instanz-ID")},
        ],
        "inputs": 1,
        "outputs": 1,
        "inputPorts": {0: {"accepts": ["Transit"]}},
        "outputPorts": {0: {"schema": "ActionResult"}},
        "meta": {"icon": "mdi-calculator", "color": "#4CAF50"},
        "_method": "trustee",
        "_action": "syncToAccounting",
    },
]
