"""Pydantic schemas for task results (#54 check OK/NOK, #55 note con campi).""" from typing import Literal, Optional from pydantic import BaseModel, ConfigDict, Field from src.backend.models.api.tipi import UtcDateTime class TaskResultAttachment(BaseModel): """Un allegato: `path` e' il percorso restituito da /api/files/upload.""" key: Optional[str] = Field(None, max_length=40) path: str = Field(..., min_length=1, max_length=500) name: str = Field(..., min_length=1, max_length=255) class TaskResultCreate(BaseModel): task_id: int = Field(..., gt=0) production_run_id: Optional[int] = Field(None, gt=0) outcome: Literal["ok", "nok", "done"] note: Optional[str] = None values: Optional[dict[str, str]] = None attachments: Optional[list[TaskResultAttachment]] = Field(None, max_length=50) class TaskResultResponse(BaseModel): model_config = ConfigDict(from_attributes=True) id: int task_id: int version_id: int production_run_id: Optional[int] = None user_id: int outcome: str note: Optional[str] = None values: Optional[dict[str, str]] = None attachments: Optional[list[TaskResultAttachment]] = None created_at: UtcDateTime