40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
"""Abstract base class for regulatory event stores."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
|
|
class BaseEventStore(ABC):
|
|
"""Port interface for regulatory event persistence."""
|
|
|
|
@abstractmethod
|
|
def all(self) -> list[dict]:
|
|
"""Return all events, most-recent first."""
|
|
|
|
@abstractmethod
|
|
def get(self, event_id: str) -> dict | None:
|
|
"""Return a single event by ID, or None."""
|
|
|
|
@abstractmethod
|
|
def filter(
|
|
self,
|
|
*,
|
|
source: str | None = None,
|
|
impact_level: str | None = None,
|
|
limit: int = 50,
|
|
) -> list[dict]:
|
|
"""Return filtered events sorted by published_at descending."""
|
|
|
|
@abstractmethod
|
|
def stats(self) -> dict:
|
|
"""Return {total, high_impact, medium_impact, low_impact, recent_90d}."""
|
|
|
|
@abstractmethod
|
|
def upsert(self, event: dict) -> None:
|
|
"""Insert or update an event record."""
|
|
|
|
@abstractmethod
|
|
def get_by_standard_code(self, standard_code: str) -> dict | None:
|
|
"""Return the most-recent event with matching standard_code, or None."""
|