From 2f7de330494ae73a64fbbedb4f4f51de3befe3bf Mon Sep 17 00:00:00 2001 From: Stommer Date: Sat, 24 Oct 2026 22:23:46 +0200 Subject: [PATCH] =?UTF-8?q?Ziehe=20die=20F=C3=A4higkeiten=20von=20Paperles?= =?UTF-8?q?s=20und=20IMAP=20in=20ihr=20Modul=20und=20entferne=20die=20unbe?= =?UTF-8?q?nutzte=20Filterliste.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- backend/app/sourceport.py | 79 +------------------ backend/app/sources.py | 64 +++++++++++++-- ...GU_CONNECTOR_ABSCHLUSSMATRIX_2026-10-19.md | 2 +- 3 files changed, 62 insertions(+), 83 deletions(-) diff --git a/backend/app/sourceport.py b/backend/app/sourceport.py index 38eb219..2024d18 100644 --- a/backend/app/sourceport.py +++ b/backend/app/sourceport.py @@ -1,86 +1,15 @@ -"""Declared source and editor capabilities. +"""Declared editor capabilities and the payloads that carry them. -A common contract does not invent abilities the adapter does not have. -A filter is offered only when that module implements it. +The capabilities of a source belong to its module. A filter is offered only when that module implements it. """ from __future__ import annotations -PAPERLESS_CAPABILITIES = { - "kind": "paperless", - "navigate": False, - "read_original": True, - "read_preview": True, - "read_attachment": False, - "edit_content": False, - "edit_metadata": False, - "search": { - "query": True, - "mode": True, - "title": True, - "correspondent": True, - "document_type": True, - "storage_path": True, - "tags": True, - "tag_mode": True, - "document_range": True, - "added_range": True, - "asn": True, - "custom_fields": True, - "sort": True, - "continuation": True, - "result_preview": True, - }, -} - -IMAP_CAPABILITIES = { - "kind": "imap", - "navigate": True, - "read_original": True, - "read_preview": True, - "read_attachment": True, - "edit_content": False, - "edit_metadata": False, - "search": { - "query": True, - "mode": False, - "title": False, - "correspondent": False, - "document_type": False, - "storage_path": False, - "tags": False, - "tag_mode": False, - "document_range": False, - "added_range": False, - "asn": False, - "custom_fields": False, - "sort": False, - "continuation": True, - "result_preview": False, - }, -} - -CAPABILITIES = { - "paperless": PAPERLESS_CAPABILITIES, - "imap": IMAP_CAPABILITIES, -} - EDITORS = { "note": True, "markdown_file": False, } -UNSUPPORTED_SEARCH = ( - "title", - "correspondent", - "document_type", - "tag", - "document_from", - "document_to", - "sort", - "cursor", -) - def capability_payload() -> dict: from app.sourceregistry import registered_sources @@ -105,10 +34,6 @@ def capability_payload() -> dict: } -def unsupported_filters(values: dict[str, str]) -> list[str]: - return [name for name in UNSUPPORTED_SEARCH if str(values.get(name) or "").strip()] - - def with_capabilities(kind: str, connector_id: str, payload: dict) -> dict: from app.sourceregistry import require_source diff --git a/backend/app/sources.py b/backend/app/sources.py index df619aa..babad41 100644 --- a/backend/app/sources.py +++ b/backend/app/sources.py @@ -48,7 +48,6 @@ from app.sourceaccess import ( connector_owner as _connector_owner, release_for_external, ) -from app.sourceport import CAPABILITIES from app.sourceregistry import ConfigField, SourceModule, get_source, parse_fields, register_source, require_source @@ -2050,11 +2049,66 @@ def _imap_bytes(conn, actor_id: UUID, element: dict, context: Ctx | None, ref) - return raw, "message/rfc822", "nachricht.eml" +PAPERLESS_CAPABILITIES = { + "kind": "paperless", + "navigate": False, + "read_original": True, + "read_preview": True, + "read_attachment": False, + "edit_content": False, + "edit_metadata": False, + "search": { + "query": True, + "mode": True, + "title": True, + "correspondent": True, + "document_type": True, + "storage_path": True, + "tags": True, + "tag_mode": True, + "document_range": True, + "added_range": True, + "asn": True, + "custom_fields": True, + "sort": True, + "continuation": True, + "result_preview": True, + }, +} + +IMAP_CAPABILITIES = { + "kind": "imap", + "navigate": True, + "read_original": True, + "read_preview": True, + "read_attachment": True, + "edit_content": False, + "edit_metadata": False, + "search": { + "query": True, + "mode": False, + "title": False, + "correspondent": False, + "document_type": False, + "storage_path": False, + "tags": False, + "tag_mode": False, + "document_range": False, + "added_range": False, + "asn": False, + "custom_fields": False, + "sort": False, + "continuation": True, + "result_preview": False, + }, +} + + class _PaperlessAdapter: kind = "paperless" def capabilities(self) -> dict: - return CAPABILITIES[self.kind] + return PAPERLESS_CAPABILITIES def probe(self, row) -> dict: count = _paperless_count(row["settings"]["base_url"], row["secret"]) @@ -2075,7 +2129,7 @@ class _ImapAdapter: kind = "imap" def capabilities(self) -> dict: - return CAPABILITIES[self.kind] + return IMAP_CAPABILITIES def probe(self, row) -> dict: _imap_login(row["settings"], row["secret"]) @@ -2098,7 +2152,7 @@ def _install_sources() -> None: kind="paperless", label="Paperless", representation="pdf", - capabilities=CAPABILITIES["paperless"], + capabilities=PAPERLESS_CAPABILITIES, config_fields=PAPERLESS_FIELDS, normalize_config=_paperless_normalize, probe=paperless.probe, @@ -2115,7 +2169,7 @@ def _install_sources() -> None: kind="imap", label="E-Mail", representation="email", - capabilities=CAPABILITIES["imap"], + capabilities=IMAP_CAPABILITIES, config_fields=IMAP_FIELDS, normalize_config=_imap_normalize, probe=imap.probe, diff --git a/docs/product/TSUMUGU_CONNECTOR_ABSCHLUSSMATRIX_2026-10-19.md b/docs/product/TSUMUGU_CONNECTOR_ABSCHLUSSMATRIX_2026-10-19.md index 6ebb10e..69fa1a1 100644 --- a/docs/product/TSUMUGU_CONNECTOR_ABSCHLUSSMATRIX_2026-10-19.md +++ b/docs/product/TSUMUGU_CONNECTOR_ABSCHLUSSMATRIX_2026-10-19.md @@ -106,7 +106,7 @@ Auf Wunsch des Nutzers erweitert über den Umfang von Abschnitt C des Nacharbeit **Verantwortung im Modul:** Die Filternamen eines Moduls deklariert `SourceModule.search_params` (Parametername auf Fähigkeitsflag). Die gemeinsame Suchroute kennt keinen Filternamen mehr. Sie reicht alle übrigen Abfrageparameter weiter und weist jeden ab, den das Modul nicht deklariert oder dessen Fähigkeit nicht wahr ist. Das gilt auch für unbekannte Parameter. Das Vorschaubild ist eine optionale Modulfähigkeit (`SourceModule.thumbnail`, Route `/api/v1/sources/{kind}/thumbnail`, Flag `search.result_preview`). Ein Modul ohne Deklaration lehnt es mit `422` ab. -**Verbleibende Quellkenntnis im allgemeinen Code (zulässig oder bekannt):** Die Kompatibilitätsrouten `/api/v1/sources/paperless/documents` und `.../preview` in `backend/app/api/sources.py` delegieren nur. Die Fähigkeitswörterbücher `PAPERLESS_CAPABILITIES` und `IMAP_CAPABILITIES` liegen weiterhin in `backend/app/sourceport.py`, ebenso die unbenutzte Liste `UNSUPPORTED_SEARCH`. Das war schon vor dieser Erweiterung so und ist nicht bereinigt. In der Oberfläche liegt der Paperless-Auswahldialog in `frontend/src/pages/Sources.jsx` und wird über `registerSourceModule` (`large: true`) eingehängt; Fachseiten und Modal kennen nur das allgemeine Flag. +**Verbleibende Quellkenntnis im allgemeinen Code (zulässig):** Die Kompatibilitätsrouten `/api/v1/sources/paperless/documents` und `.../preview` in `backend/app/api/sources.py` delegieren nur und tragen keine eigene Protokoll- oder Rechtelogik. Die Fähigkeiten von Paperless und IMAP stehen jetzt in `backend/app/sources.py` beim jeweiligen Modul; `backend/app/sourceport.py` enthält nur noch die Editorfähigkeiten und die Nutzlasten. Die unbenutzte Liste `UNSUPPORTED_SEARCH` und `unsupported_filters` sind entfernt. In der Oberfläche liegt der Paperless-Auswahldialog in `frontend/src/pages/Sources.jsx` und wird über `registerSourceModule` (`large: true`) eingehängt; Fachseiten und Modal kennen nur das allgemeine Flag. | Nachweis | Ergebnis | |---|---|