"""Write JSON Schemas to shared/schemas for the Laravel side (opis/json-schema)."""
import json, pathlib
from .extraction import ExtractionPage
from .scoring import ScriptFinding

OUT = pathlib.Path(__file__).resolve().parents[3] / "shared" / "schemas"

if __name__ == "__main__":
    OUT.mkdir(parents=True, exist_ok=True)
    for name, model in {"extraction_page": ExtractionPage, "scoring_script": ScriptFinding}.items():
        (OUT / f"{name}.schema.json").write_text(json.dumps(model.model_json_schema(), indent=2, ensure_ascii=False))
        print("wrote", name)
