"""اسکیماهای Plan، Feature و PlanFeature."""
from __future__ import annotations

from datetime import datetime
from uuid import UUID

from pydantic import BaseModel, Field

from app.models.enums import LimitPeriod
from app.schemas.common import ORMModel


# ---- Plan ----
class PlanCreate(BaseModel):
    code: str = Field(..., min_length=1, max_length=100)
    name: str = Field(..., min_length=1, max_length=255)
    description: str | None = None
    is_active: bool = True


class PlanRead(ORMModel):
    id: UUID
    code: str
    name: str
    description: str | None
    is_active: bool
    created_at: datetime


# ---- Feature ----
class FeatureCreate(BaseModel):
    feature_key: str = Field(..., min_length=1, max_length=150)
    name: str = Field(..., min_length=1, max_length=255)
    description: str | None = None
    service_key: str = Field(..., min_length=1, max_length=100)
    is_active: bool = True


class FeatureRead(ORMModel):
    id: UUID
    feature_key: str
    name: str
    description: str | None
    service_key: str
    is_active: bool


# ---- PlanFeature ----
class PlanFeatureCreate(BaseModel):
    feature_id: UUID
    limit_value: int | None = Field(default=None, ge=0)
    limit_period: LimitPeriod | None = None
    is_enabled: bool = True


class PlanFeatureRead(ORMModel):
    id: UUID
    plan_id: UUID
    feature_id: UUID
    limit_value: int | None
    limit_period: LimitPeriod | None
    is_enabled: bool
