apexdevkit 1.5.2__tar.gz → 1.5.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/PKG-INFO +1 -1
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/fastapi/service.py +4 -10
- apexdevkit-1.5.4/apexdevkit/formatter.py +23 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/repository/__init__.py +4 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/repository/in_memory.py +3 -21
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/pyproject.toml +1 -1
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/LICENSE +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/README.md +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/__init__.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/annotation/__init__.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/annotation/deprecate.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/error.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/fastapi/__init__.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/fastapi/builder.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/fastapi/dependable.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/fastapi/docs.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/fastapi/response.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/fastapi/router.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/fastapi/schema.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/http/__init__.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/http/fake.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/http/fluent.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/http/httpx.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/http/json.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/http/url.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/py.typed +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/repository/base.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/repository/connector.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/repository/database.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/repository/interface.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/testing/__init__.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/testing/database.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/testing/fake.py +0 -0
- {apexdevkit-1.5.2 → apexdevkit-1.5.4}/apexdevkit/testing/rest.py +0 -0
|
@@ -45,18 +45,12 @@ class RestfulRepository(RestfulService):
|
|
|
45
45
|
repository: Repository[Any, Any]
|
|
46
46
|
|
|
47
47
|
def create_one(self, item: RawItem) -> RawItem:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
self.repository.create(result)
|
|
51
|
-
|
|
52
|
-
return _as_raw_item(result)
|
|
48
|
+
return _as_raw_item(self.repository.create(self.resource(**item)))
|
|
53
49
|
|
|
54
50
|
def create_many(self, items: RawCollection) -> RawCollection:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return _as_raw_collection(result)
|
|
51
|
+
return _as_raw_collection(
|
|
52
|
+
self.repository.create_many([self.resource(**fields) for fields in items])
|
|
53
|
+
)
|
|
60
54
|
|
|
61
55
|
def read_one(self, item_id: str) -> RawItem:
|
|
62
56
|
result = self.repository.read(item_id)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from dataclasses import asdict, dataclass
|
|
2
|
+
from typing import Any, Generic, Protocol, TypeVar
|
|
3
|
+
|
|
4
|
+
ItemT = TypeVar("ItemT")
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Formatter(Protocol[ItemT]):
|
|
8
|
+
def load(self, raw: dict[str, Any]) -> ItemT:
|
|
9
|
+
pass
|
|
10
|
+
|
|
11
|
+
def dump(self, item: ItemT) -> dict[str, Any]:
|
|
12
|
+
pass
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass
|
|
16
|
+
class DataclassFormatter(Generic[ItemT]):
|
|
17
|
+
resource: type[ItemT]
|
|
18
|
+
|
|
19
|
+
def load(self, raw: dict[str, Any]) -> ItemT:
|
|
20
|
+
return self.resource(**raw)
|
|
21
|
+
|
|
22
|
+
def dump(self, item: ItemT) -> dict[str, Any]:
|
|
23
|
+
return asdict(item) # type: ignore
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from apexdevkit.repository.base import RepositoryBase
|
|
1
2
|
from apexdevkit.repository.database import (
|
|
2
3
|
Connection,
|
|
3
4
|
Connector,
|
|
@@ -6,6 +7,7 @@ from apexdevkit.repository.database import (
|
|
|
6
7
|
DatabaseCommand,
|
|
7
8
|
)
|
|
8
9
|
from apexdevkit.repository.in_memory import InMemoryRepository
|
|
10
|
+
from apexdevkit.repository.interface import Repository
|
|
9
11
|
|
|
10
12
|
__all__ = [
|
|
11
13
|
"Connection",
|
|
@@ -14,4 +16,6 @@ __all__ = [
|
|
|
14
16
|
"Database",
|
|
15
17
|
"DatabaseCommand",
|
|
16
18
|
"InMemoryRepository",
|
|
19
|
+
"Repository",
|
|
20
|
+
"RepositoryBase",
|
|
17
21
|
]
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
from copy import deepcopy
|
|
2
|
-
from dataclasses import
|
|
2
|
+
from dataclasses import dataclass, field
|
|
3
3
|
from typing import Any, Generic, Iterable, Iterator, Protocol, Self, TypeVar
|
|
4
4
|
|
|
5
5
|
from apexdevkit.error import Criteria, DoesNotExistError, ExistsError
|
|
6
|
+
from apexdevkit.formatter import DataclassFormatter, Formatter
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
class _Item(Protocol):
|
|
@@ -14,28 +15,9 @@ class _Item(Protocol):
|
|
|
14
15
|
ItemT = TypeVar("ItemT", bound=_Item)
|
|
15
16
|
|
|
16
17
|
|
|
17
|
-
class _Formatter(Protocol[ItemT]):
|
|
18
|
-
def load(self, raw: dict[str, Any]) -> ItemT:
|
|
19
|
-
pass
|
|
20
|
-
|
|
21
|
-
def dump(self, item: ItemT) -> dict[str, Any]:
|
|
22
|
-
pass
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
@dataclass
|
|
26
|
-
class DataclassFormatter(Generic[ItemT]):
|
|
27
|
-
resource: type[ItemT]
|
|
28
|
-
|
|
29
|
-
def load(self, raw: dict[str, Any]) -> ItemT:
|
|
30
|
-
return self.resource(**raw)
|
|
31
|
-
|
|
32
|
-
def dump(self, item: ItemT) -> dict[str, Any]:
|
|
33
|
-
return asdict(item) # type: ignore
|
|
34
|
-
|
|
35
|
-
|
|
36
18
|
@dataclass
|
|
37
19
|
class InMemoryRepository(Generic[ItemT]):
|
|
38
|
-
formatter:
|
|
20
|
+
formatter: Formatter[ItemT]
|
|
39
21
|
items: dict[str, dict[str, Any]] = field(default_factory=dict)
|
|
40
22
|
|
|
41
23
|
_uniques: list[Criteria] = field(init=False, default_factory=list)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|