"""Pydantic schemas mirroring anotation-frontend/src/types/*.""" from __future__ import annotations from typing import Literal from pydantic import BaseModel, Field TaskType = Literal["classification", "object_detection", "segmentation"] ProjectStatus = Literal["annotating", "pending_review", "completed", "draft"] ImageStatus = Literal["unassigned", "in_progress", "pending_review", "completed"] ShapeType = Literal["bbox", "polygon", "point"] ExportFormat = Literal["coco_json", "yolo_txt", "labelme_json", "mask_png"] class BBox(BaseModel): x: float y: float width: float height: float class Point2D(BaseModel): x: float y: float class AnnotationShape(BaseModel): id: str index: int = 0 type: ShapeType labelId: str labelName: str = "" color: str = "#888888" visible: bool = True groupId: int | None = None bbox: BBox | None = None points: list[Point2D] | None = None point: Point2D | None = None class Flags(BaseModel): blurryOrUncertain: bool = False needsRecheck: bool = False class AnnotationUpsert(BaseModel): classificationLabelId: str | None = None flags: Flags = Field(default_factory=Flags) shapes: list[AnnotationShape] = Field(default_factory=list) class LabelClassIn(BaseModel): name: str color: str = "#888888" shortcutKey: str | None = None class ProjectCreate(BaseModel): name: str slug: str description: str = "" taskType: TaskType class ImageConfirm(BaseModel): """After direct PUT to R2, client confirms so API creates metadata.""" fileName: str r2Key: str width: int = 0 height: int = 0 class PresignRequest(BaseModel): fileName: str contentType: str = "image/jpeg"