deerflow-code/offline-backend-20260512/backend/packages/harness/deerflow/persistence/menu_overrides/base.py
2026-09-07 18:24:55 +08:00

31 lines
1.1 KiB
Python

"""Abstract sidebar-menu override persistence API.
Global / shared store: no ``user_id`` scoping. Reads are open to any caller; the
router gates writes behind admin. ``updated_by`` is audit-only.
The whole override set is treated as one document: the editor computes the full
desired layout and replaces every row atomically via :meth:`replace_all`, so the
stored set never drifts out of sync with what the admin sees.
"""
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import Any
class MenuOverrideStore(ABC):
@abstractmethod
async def list_overrides(self) -> list[dict[str, Any]]:
"""Return every stored override row (order unspecified)."""
raise NotImplementedError
@abstractmethod
async def replace_all(self, rows: list[dict[str, Any]], *, updated_by: str | None = None) -> list[dict[str, Any]]:
"""Atomically replace the entire override set with ``rows``.
Each row is ``{node_id, parent_id, sort_order, label, disabled}``.
Returns the persisted rows.
"""
raise NotImplementedError