2026-07-25 21:03:46 +02:00
|
|
|
"""DMS plugin contract — public interface for cross-plugin access."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
2026-07-26 23:15:34 +02:00
|
|
|
from app.plugins.builtins.contracts import get_contract_registry
|
2026-08-16 01:17:18 +02:00
|
|
|
from app.plugins.builtins.dms.models import File as DmsFile
|
|
|
|
|
from app.plugins.builtins.dms.models import Folder
|
2026-07-25 21:03:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class DmsContract:
|
|
|
|
|
"""Public contract for the DMS plugin."""
|
|
|
|
|
|
2026-07-26 23:15:34 +02:00
|
|
|
contract_name = "dms"
|
|
|
|
|
|
2026-07-25 21:03:46 +02:00
|
|
|
DmsFile = DmsFile
|
|
|
|
|
Folder = Folder
|
|
|
|
|
|
2026-08-31 23:17:54 +02:00
|
|
|
@staticmethod
|
|
|
|
|
def workspace_scopes() -> list[dict]:
|
|
|
|
|
"""Scope-Dimensionen des dms-Moduls für den Workspace-Editor (N1)."""
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
"module_key": "dms",
|
|
|
|
|
"dimensions": [
|
|
|
|
|
{
|
|
|
|
|
"key": "folder_ids",
|
|
|
|
|
"label": "DMS-Ordner",
|
|
|
|
|
"control": "multiselect",
|
|
|
|
|
"value_source": {
|
|
|
|
|
"endpoint": "/api/v1/dms/folders",
|
|
|
|
|
"items_path": "",
|
|
|
|
|
"value_key": "id",
|
|
|
|
|
"label_key": "name",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"key": "file_types",
|
|
|
|
|
"label": "Datei-Typen",
|
|
|
|
|
"control": "multiselect",
|
|
|
|
|
"options": [
|
|
|
|
|
{"value": "application/pdf", "label": "PDF"},
|
|
|
|
|
{"value": "image/", "label": "Bilder"},
|
|
|
|
|
{"value": "spreadsheet", "label": "Tabellen"},
|
|
|
|
|
{"value": "word", "label": "Dokumente"},
|
|
|
|
|
{"value": "other", "label": "Sonstige"},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
|
2026-08-23 12:50:53 +02:00
|
|
|
@classmethod
|
|
|
|
|
def get_function(cls, name: str):
|
|
|
|
|
"""Return a callable exposed by this contract, or None if absent."""
|
|
|
|
|
return getattr(cls, name, None)
|
|
|
|
|
|
2026-07-25 21:03:46 +02:00
|
|
|
|
2026-07-26 23:15:34 +02:00
|
|
|
# ─── self-registration ───
|
|
|
|
|
|
|
|
|
|
_contract = DmsContract()
|
|
|
|
|
get_contract_registry().register("dms", _contract)
|
|
|
|
|
|
|
|
|
|
# Backward-compatible local accessor
|
2026-07-25 21:03:46 +02:00
|
|
|
_contract_instance: DmsContract | None = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_contract() -> DmsContract:
|
|
|
|
|
global _contract_instance
|
|
|
|
|
if _contract_instance is None:
|
|
|
|
|
_contract_instance = DmsContract()
|
|
|
|
|
return _contract_instance
|
2026-07-26 23:15:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
__all__ = ["DmsContract", "DmsFile", "Folder"]
|