Coverage for src / lexigram / contracts / admin / repository.py: 100%

6 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-08-15 18:58 +0800

1"""AdminRepositoryProtocol — generic admin CRUD repository.""" 

2 

3from __future__ import annotations 

4 

5from typing import Any, Protocol, TypeVar, runtime_checkable 

6 

7T = TypeVar("T") 

8 

9 

10@runtime_checkable 

11class AdminRepositoryProtocol(Protocol[T]): 

12 """Protocol for admin repository operations.""" 

13 

14 async def find_many( 

15 self, 

16 *, 

17 offset: int = 0, 

18 limit: int = 20, 

19 order_by: list[tuple[str, str]] | None = None, 

20 filters: dict[str, Any] | None = None, 

21 search: str | None = None, 

22 search_fields: list[str] | None = None, 

23 load: list[str] | None = None, 

24 ) -> list[T]: ... 

25 

26 async def find_by_id(self, item_id: Any) -> T | None: ... 

27 

28 async def count( 

29 self, 

30 *, 

31 filters: dict[str, Any] | None = None, 

32 search: str | None = None, 

33 search_fields: list[str] | None = None, 

34 ) -> int: ... 

35 

36 async def create(self, data: dict[str, Any]) -> T: ... 

37 

38 async def update(self, item_id: Any, data: dict[str, Any]) -> T: ... 

39 

40 async def delete(self, item_id: Any) -> bool: ... 

41 

42 

43__all__ = ["AdminRepositoryProtocol"]