from __future__ import annotations from pydantic import BaseModel, Field, field_validator class SectionSubmit(BaseModel): answers: dict[str, str] = Field(default_factory=dict) recaptcha_token: str | None = None @field_validator("answers") @classmethod def no_honeypot(cls, v: dict[str, str]) -> dict[str, str]: if v.get("website"): raise ValueError("Honeypot triggered") return v class FinalSubmit(BaseModel): answers: dict[str, str] recaptcha_token: str | None = None @field_validator("answers") @classmethod def no_honeypot(cls, v: dict[str, str]) -> dict[str, str]: if v.get("website"): raise ValueError("Honeypot triggered") return v class FileUploadRequest(BaseModel): module_id: str filename: str byte_size: int content_type: str = "application/pdf" class ModuleSubField(BaseModel): key: str label: str required: bool = False class ModuleData(BaseModel): """Full module data for template rendering.""" id: str label: str mod_type: str options: list[str] | None = None content_html: str | None = None sub_fields: list[ModuleSubField] = Field(default_factory=list) helper_text: str | None = None metadata: dict | None = None required: bool = False class SectionDefinition(BaseModel): """Parsed section from Healthie form definition.""" id: int label: str modules: list[ModuleData] = Field(default_factory=list) conditional: dict | None = None is_agreement: bool = False class FormAnswer(BaseModel): custom_module_id: str mod_type: str answer: str | None = None