from datetime import datetime from typing import Optional from pydantic import BaseModel, ConfigDict, EmailStr, Field class UserResponse(BaseModel): model_config = ConfigDict(from_attributes=True) id: int email: EmailStr full_name: str username: str bio: str location: str avatar_url: str role: str is_verified: bool created_at: datetime class RegisterRequest(BaseModel): email: EmailStr password: str = Field(min_length=6) full_name: str = Field(min_length=2, max_length=100) username: str = Field(min_length=3, max_length=50) role: str = Field(default="user") class LoginRequest(BaseModel): email: EmailStr password: str = Field(min_length=6) class AuthResponse(BaseModel): message: str user: UserResponse class ProfileUpdateRequest(BaseModel): full_name: Optional[str] = Field(default=None, min_length=2, max_length=100) bio: Optional[str] = Field(default=None, max_length=500) location: Optional[str] = Field(default=None, max_length=120) avatar_url: Optional[str] = Field(default=None, max_length=255) is_verified: Optional[bool] = None class PromptCreateRequest(BaseModel): title: str = Field(min_length=3, max_length=120) description: str = Field(min_length=10, max_length=500) content: str = Field(min_length=10) image_url: str = Field(max_length=255) category: str = Field(min_length=2, max_length=50) price: float = Field(ge=0) creator_id: int class PromptUpdateRequest(BaseModel): title: Optional[str] = Field(default=None, min_length=3, max_length=120) description: Optional[str] = Field(default=None, min_length=10, max_length=500) content: Optional[str] = Field(default=None, min_length=10) image_url: Optional[str] = Field(default=None, max_length=255) category: Optional[str] = Field(default=None, min_length=2, max_length=50) price: Optional[float] = Field(default=None, ge=0) class PromptResponse(BaseModel): model_config = ConfigDict(from_attributes=True) id: int title: str description: str content: str image_url: str category: str price: float creator_id: int created_at: datetime class CreatorDetailResponse(BaseModel): creator: UserResponse prompts: list[PromptResponse] class RatingCreateRequest(BaseModel): user_id: int score: int = Field(ge=1, le=5) comment: str = Field(default="", max_length=500) class RatingResponse(BaseModel): model_config = ConfigDict(from_attributes=True) id: int prompt_id: int user_id: int score: int comment: str created_at: datetime class FavoriteCreateRequest(BaseModel): prompt_id: int class FavoriteResponse(BaseModel): model_config = ConfigDict(from_attributes=True) id: int user_id: int prompt_id: int created_at: datetime class FollowResponse(BaseModel): model_config = ConfigDict(from_attributes=True) id: int follower_id: int creator_id: int created_at: datetime class ChatMessageCreateRequest(BaseModel): receiver_id: int content: str = Field(min_length=1, max_length=2000) class ChatMessageResponse(BaseModel): model_config = ConfigDict(from_attributes=True) id: int sender_id: int receiver_id: int content: str created_at: datetime