types.py
1 """ 2 Custom types and type aliases used throughout the application. 3 """ 4 5 from datetime import datetime 6 from typing import Any 7 8 from pydantic import BaseModel 9 10 # Basic type aliases 11 UserId = str 12 SessionId = str 13 MessageId = str 14 TaskId = str 15 AgentId = str 16 17 # Dictionary types 18 JsonDict = dict[str, Any] 19 Headers = dict[str, str] 20 QueryParams = dict[str, str | list[str]] 21 22 23 # Common data structures 24 class Timestamp(BaseModel): 25 """Standardized timestamp representation using epoch milliseconds.""" 26 27 created_time: int # Epoch milliseconds 28 updated_time: int | None = None # Epoch milliseconds 29 30 31 class LegacyTimestamp(BaseModel): 32 """Legacy timestamp representation (deprecated - use Timestamp instead).""" 33 34 created_at: datetime 35 updated_at: datetime | None = None 36 37 38 class SortInfo(BaseModel): 39 """Sorting information for list requests.""" 40 41 field: str 42 direction: str = "asc" # asc or desc 43 44 45 class FilterInfo(BaseModel): 46 """Filtering information for list requests.""" 47 48 field: str 49 operator: str # eq, ne, gt, lt, gte, lte, contains, in 50 value: Any