"""Request and response schemas for the Bookmark domain."""
from __future__ import annotations

from datetime import datetime

from pydantic import Field

from repo_core.base.schemas import BaseRequestSchema, BaseResponseSchema
from repo_core.domains.bookmark.model import BookmarkTargetType


class CreateBookmarkRequest(BaseRequestSchema):
    """Payload for bookmarking an event.

    Usage::

        payload = CreateBookmarkRequest(event_id="42")
    """

    event_id: str = Field(..., min_length=1, max_length=128)


class BookmarkResponse(BaseResponseSchema):
    """Serialised bookmark returned to API callers.

    Usage::

        response = BookmarkResponse.model_validate(orm_bookmark)
        data = response.to_dict()
    """

    id: int
    user_id: int
    target_type: BookmarkTargetType
    target_id: str
    created_at: datetime | None = None
    updated_at: datetime | None = None


class BookmarkCheckResponse(BaseResponseSchema):
    """Response indicating whether an event exists (DB or search fallback)."""

    exists: bool
    title: str | None = None
