2026-07-26 23:15:34 +02:00
|
|
|
"""Public contract for the report_generator plugin.
|
|
|
|
|
|
|
|
|
|
Exposes models and PDF generation functions for other plugins.
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from app.plugins.builtins.contracts import get_contract_registry
|
|
|
|
|
from app.plugins.builtins.report_generator.models import (
|
|
|
|
|
ReportInstance,
|
|
|
|
|
ReportTemplate,
|
|
|
|
|
)
|
|
|
|
|
from app.plugins.builtins.report_generator.pdf_generator import (
|
|
|
|
|
PRESET_META,
|
|
|
|
|
PRESET_TEMPLATES,
|
|
|
|
|
generate_pdf,
|
|
|
|
|
generate_pdf_from_template_content,
|
|
|
|
|
generate_preset_report,
|
|
|
|
|
generate_print_pdf,
|
|
|
|
|
get_preset_list,
|
|
|
|
|
render_template_file,
|
|
|
|
|
render_template_string,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ReportGeneratorContract:
|
|
|
|
|
"""Public API surface for the report_generator plugin."""
|
|
|
|
|
|
|
|
|
|
contract_name = "report_generator"
|
|
|
|
|
|
|
|
|
|
# ─── models ───
|
|
|
|
|
ReportTemplate = ReportTemplate
|
|
|
|
|
ReportInstance = ReportInstance
|
|
|
|
|
|
|
|
|
|
# ─── pdf_generator ───
|
|
|
|
|
generate_pdf = staticmethod(generate_pdf)
|
|
|
|
|
generate_print_pdf = staticmethod(generate_print_pdf)
|
|
|
|
|
generate_preset_report = staticmethod(generate_preset_report)
|
|
|
|
|
generate_pdf_from_template_content = staticmethod(generate_pdf_from_template_content)
|
|
|
|
|
render_template_file = staticmethod(render_template_file)
|
|
|
|
|
render_template_string = staticmethod(render_template_string)
|
|
|
|
|
get_preset_list = staticmethod(get_preset_list)
|
|
|
|
|
PRESET_META = PRESET_META
|
|
|
|
|
PRESET_TEMPLATES = PRESET_TEMPLATES
|
|
|
|
|
|
2026-09-01 23:23:15 +02:00
|
|
|
# ─── Workspace Scopes contribution (Phase N4) ───
|
|
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
|
def workspace_scopes() -> list[dict]:
|
|
|
|
|
"""Scope-Dimensionen des reports-Moduls: Vorlagen-Teilmengen (N4)."""
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
"module_key": "reports",
|
|
|
|
|
"dimensions": [
|
|
|
|
|
{
|
|
|
|
|
"key": "template_ids",
|
|
|
|
|
"label": "Vorlagen",
|
|
|
|
|
"control": "multiselect",
|
|
|
|
|
"options": [],
|
|
|
|
|
"value_source": {
|
|
|
|
|
"endpoint": "/api/v1/reports/print-templates",
|
|
|
|
|
"items_path": "items",
|
|
|
|
|
"value_key": "id",
|
|
|
|
|
"label_key": "name",
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
|
2026-07-26 23:15:34 +02:00
|
|
|
|
|
|
|
|
# ─── self-registration ───
|
|
|
|
|
|
|
|
|
|
_contract = ReportGeneratorContract()
|
|
|
|
|
get_contract_registry().register("report_generator", _contract)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
__all__ = [
|
|
|
|
|
"ReportGeneratorContract",
|
|
|
|
|
"ReportTemplate",
|
|
|
|
|
"ReportInstance",
|
|
|
|
|
]
|