"""Domain model for the Bookmark entity.

A ``Bookmark`` record represents a user's saved/bookmarked target —
analogous to a Django ``EventSave`` but polymorphic by design.  Currently
only ``event`` targets are supported, but the ``target_type`` enum can be
extended for stories, people, etc. without schema changes.
"""
from __future__ import annotations

from datetime import datetime
from enum import Enum

from repo_core.base.models import DomainModel


class BookmarkTargetType(str, Enum):
    """Enum of bookmarkable target kinds — currently only ``event``.

    Using ``str, Enum`` keeps values as plain strings at the DB level
    while providing IDE autocompletion and type safety in Python.
    """

    EVENT = "event"


class Bookmark(DomainModel):
    """Links a user to a bookmarked target via ``(target_type, target_id)``.

    The ``target_type`` defaults to ``EVENT`` so callers only need to
    provide ``user_id`` and ``target_id`` for the common case.

    The ``(user_id, target_type, target_id)`` triplet is unique — enforced
    at the DB level (see migration) and by ``BookmarkRepository.save_bookmark()``.
    """

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