"""Abstract persistence API for in-app notifications.""" from __future__ import annotations from abc import ABC, abstractmethod from typing import Any class NotificationStore(ABC): @abstractmethod async def create(self, data: dict[str, Any]) -> dict[str, Any]: """Insert a notification record. ``data`` must include ``id``, ``user_id``, ``type``.""" raise NotImplementedError @abstractmethod async def list_for_user( self, user_id: str, *, unread_only: bool = False, limit: int = 50, ) -> list[dict[str, Any]]: """Return newest-first records for ``user_id``.""" raise NotImplementedError @abstractmethod async def unread_count(self, user_id: str) -> int: raise NotImplementedError @abstractmethod async def mark_read(self, notification_id: str, user_id: str) -> bool: """Mark a single notification as read; returns False if not owned by user.""" raise NotImplementedError @abstractmethod async def mark_all_read(self, user_id: str) -> int: """Mark every unread notification of ``user_id`` as read; returns count updated.""" raise NotImplementedError @abstractmethod async def delete(self, notification_id: str, user_id: str) -> bool: raise NotImplementedError