a working product with ugly ui

This commit is contained in:
2025-12-12 20:15:27 +05:00
parent e6d04f986f
commit 4d3085623a
77 changed files with 8750 additions and 0 deletions

0
app/schemas/__init__.py Normal file
View File

19
app/schemas/auth.py Normal file
View File

@@ -0,0 +1,19 @@
from pydantic import BaseModel, EmailStr
class LoginRequest(BaseModel):
"""Request schema for user login."""
username: str
password: str
class TokenResponse(BaseModel):
"""Response schema for authentication tokens."""
access_token: str
refresh_token: str
token_type: str = "bearer"
class TokenData(BaseModel):
"""Schema for JWT token payload data."""
user_id: str

32
app/schemas/map.py Normal file
View File

@@ -0,0 +1,32 @@
from pydantic import BaseModel, ConfigDict
from typing import Optional
from datetime import datetime
from uuid import UUID
class MapBase(BaseModel):
"""Base map schema with common attributes."""
name: str
description: Optional[str] = None
class MapCreate(MapBase):
"""Schema for creating a new map."""
pass
class MapUpdate(BaseModel):
"""Schema for updating map information."""
name: Optional[str] = None
description: Optional[str] = None
class MapResponse(MapBase):
"""Response schema for map data."""
id: UUID
owner_id: UUID
is_default_public: bool
created_at: datetime
updated_at: datetime
model_config = ConfigDict(from_attributes=True)

35
app/schemas/map_item.py Normal file
View File

@@ -0,0 +1,35 @@
from pydantic import BaseModel, ConfigDict, Field
from typing import Optional, Dict, Any
from datetime import datetime
from uuid import UUID
class MapItemBase(BaseModel):
"""Base map item schema with common attributes."""
type: str = Field(..., description="Item type: cable, wireless_mesh, switch, indoor_ap, outdoor_ap")
geometry: Dict[str, Any] = Field(..., description="GeoJSON geometry (Point or LineString)")
properties: Dict[str, Any] = Field(default_factory=dict, description="Item-specific properties")
class MapItemCreate(MapItemBase):
"""Schema for creating a new map item."""
pass
class MapItemUpdate(BaseModel):
"""Schema for updating map item information."""
type: Optional[str] = None
geometry: Optional[Dict[str, Any]] = None
properties: Optional[Dict[str, Any]] = None
class MapItemResponse(MapItemBase):
"""Response schema for map item data."""
id: UUID
map_id: UUID
created_at: datetime
updated_at: datetime
created_by: Optional[UUID] = None
updated_by: Optional[UUID] = None
model_config = ConfigDict(from_attributes=True)

43
app/schemas/share.py Normal file
View File

@@ -0,0 +1,43 @@
from pydantic import BaseModel, ConfigDict
from typing import Optional
from datetime import datetime
from uuid import UUID
class ShareBase(BaseModel):
"""Base share schema with common attributes."""
access_level: str # 'read_only', 'edit', 'guest_read_only'
requires_auth: bool = True
expires_at: Optional[datetime] = None
class ShareCreate(ShareBase):
"""Schema for creating a new share link."""
pass
class ShareUpdate(BaseModel):
"""Schema for updating share information."""
access_level: Optional[str] = None
requires_auth: Optional[bool] = None
expires_at: Optional[datetime] = None
class ShareResponse(ShareBase):
"""Response schema for share data."""
id: UUID
map_id: UUID
share_token: str
created_at: datetime
created_by: Optional[UUID] = None
model_config = ConfigDict(from_attributes=True)
class ShareValidateResponse(BaseModel):
"""Response schema for share token validation."""
valid: bool
access_level: Optional[str] = None
map_id: Optional[UUID] = None
requires_auth: bool = False
expired: bool = False

39
app/schemas/user.py Normal file
View File

@@ -0,0 +1,39 @@
from pydantic import BaseModel, EmailStr, ConfigDict
from typing import Optional
from datetime import datetime
from uuid import UUID
class UserBase(BaseModel):
"""Base user schema with common attributes."""
username: str
email: EmailStr
class UserCreate(UserBase):
"""Schema for creating a new user."""
password: str
class UserUpdate(BaseModel):
"""Schema for updating user information."""
username: Optional[str] = None
email: Optional[EmailStr] = None
password: Optional[str] = None
class UserResponse(UserBase):
"""Response schema for user data (without sensitive info)."""
id: UUID
is_admin: bool
created_at: datetime
updated_at: datetime
model_config = ConfigDict(from_attributes=True)
class UserWithToken(UserResponse):
"""User response with authentication tokens."""
access_token: str
refresh_token: str
token_type: str = "bearer"