"""اسکیماهای Domain."""
from __future__ import annotations

from datetime import datetime
from uuid import UUID

from pydantic import BaseModel, Field, field_validator

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


class DomainCreate(BaseModel):
    domain: str = Field(..., min_length=1, max_length=255)
    domain_type: DomainType = DomainType.SUBDOMAIN

    @field_validator("domain")
    @classmethod
    def normalize_domain(cls, value: str) -> str:
        return value.strip().lower()


class DomainRead(ORMModel):
    id: UUID
    tenant_id: UUID
    domain: str
    domain_type: DomainType
    is_verified: bool
    verified_at: datetime | None
    created_at: datetime


class DomainResolveRequest(BaseModel):
    domain: str = Field(..., min_length=1, max_length=255)

    @field_validator("domain")
    @classmethod
    def normalize_domain(cls, value: str) -> str:
        return value.strip().lower()


class DomainResolveResponse(BaseModel):
    tenant_id: UUID
    tenant_slug: str
    domain: str
    is_verified: bool
