File size: 927 Bytes
414dc55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
"""Wire DTOs for the public game API.

These are the exact shapes the Preact client exchanges with the server. The client
speaks camelCase; pydantic aliases map that to snake_case internally. The sealed
``CaseFile``/``Solution`` never appears here - only the public ``PlayerCaseView``
projection is ever returned before the verdict.
"""

from __future__ import annotations

from pydantic import BaseModel, ConfigDict, Field

from .public_view import PublicCase


class _CamelModel(BaseModel):
    """Base: accept snake_case or camelCase on input, emit camelCase on output."""

    model_config = ConfigDict(populate_by_name=True)


class NewCaseRequest(_CamelModel):
    seed: int | None = None
    case_id: str | None = Field(default=None, alias="caseId")
    difficulty: str | None = None


class CaseResponse(_CamelModel):
    case_id: str = Field(alias="caseId")
    run_id: str = Field(alias="runId")
    case: PublicCase