sync: 鍚屾灞€鍩熺綉鏈€鏂颁唬鐮?(source master @ b69568e4)

This commit is contained in:
gozeros committed 2026-10-21 14:51:31 +08:00
1 parent 4f7f07504a
commit 8bc8b0e082
1651 files changed
+278599 -11416

No files matched your search

@@ -1,11 +1,11 @@
"""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.
The original ``menu_overrides`` document remains the administrator's default
layout. User layouts are stored as a separate, complete snapshot so that a
user can customise the menu without changing the default for anybody else.
The router overlays a user's snapshot on top of the default and lets default
rows for node ids not present in that snapshot flow through (new administrator
menus therefore appear for existing users).
"""
from __future__ import annotations
@@ -28,3 +28,24 @@ class MenuOverrideStore(ABC):
Returns the persisted rows.
"""
raise NotImplementedError
@abstractmethod
async def list_user_overrides(self, user_id: str) -> list[dict[str, Any]] | None:
"""Return one user's snapshot, or ``None`` when no snapshot exists."""
raise NotImplementedError
@abstractmethod
async def replace_user_overrides(
self,
user_id: str,
rows: list[dict[str, Any]],
*,
updated_by: str | None = None,
) -> list[dict[str, Any]] | None:
"""Replace one user's snapshot.
An empty list removes the snapshot and returns ``None``. This is the
reset-to-default operation and intentionally differs from the admin
``replace_all`` document, where an empty list means an empty default.
"""
raise NotImplementedError