"""Export service — export job results as downloadable JSON.""" from __future__ import annotations import json from typing import Optional from storage.database import Database class ExportService: """Exports job results.""" def __init__(self, database: Database) -> None: self._db = database def export_job_json(self, job_id: str) -> Optional[dict]: """Returns a dict combining job metadata + result. None if not found.""" job = self._db.get_job(job_id) if not job: return None result = self._db.get_result(job_id) or {} return { "job": job, "result": result, } def export_job_json_str(self, job_id: str) -> Optional[str]: data = self.export_job_json(job_id) if data is None: return None return json.dumps(data, indent=2, default=str)