from __future__ import annotations from typing import Optional from pydantic import BaseModel, EmailStr, Field class RegisterRequest(BaseModel): uuid: str = Field(..., pattern=r'^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$') name: str = Field(..., min_length=1, max_length=100) class RegisterResponse(BaseModel): user_id: int uuid: str api_key: str class GeoData(BaseModel): lat: float = Field(..., ge=-90.0, le=90.0) lon: float = Field(..., ge=-180.0, le=180.0) accuracy: float = Field(..., gt=0) class SignalRequest(BaseModel): user_id: Optional[str] = None # UUID for legacy api_key auth; omit for JWT auth timestamp: int = Field(..., gt=0) geo: Optional[GeoData] = None is_test: bool = False class SignalResponse(BaseModel): status: str signal_id: int class AdminCreateUserRequest(BaseModel): uuid: str = Field(..., min_length=1) name: str = Field(..., min_length=1, max_length=100) password: Optional[str] = None class AdminSetPasswordRequest(BaseModel): password: str = Field(..., min_length=1) class AdminBlockRequest(BaseModel): is_blocked: bool class PushSubscriptionKeys(BaseModel): p256dh: str auth: str class PushSubscription(BaseModel): endpoint: str keys: PushSubscriptionKeys class AuthRegisterRequest(BaseModel): email: EmailStr login: str = Field(..., min_length=3, max_length=30, pattern=r'^[a-zA-Z0-9_-]+$') password: str = Field(..., min_length=8, max_length=128) push_subscription: Optional[PushSubscription] = None class AuthRegisterResponse(BaseModel): status: str message: str class AuthLoginRequest(BaseModel): login_or_email: str = Field(..., min_length=1, max_length=255) password: str = Field(..., min_length=1, max_length=128) class AuthLoginResponse(BaseModel): token: str login: str