apexdevkit 1.20.3__tar.gz → 1.20.5__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.20.3 → apexdevkit-1.20.5}/PKG-INFO +1 -1
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/fastapi/__init__.py +2 -2
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/fastapi/builder.py +8 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/fastapi/dependable.py +10 -28
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/fastapi/router.py +0 -9
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/fastapi/service.py +2 -22
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/pyproject.toml +1 -1
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/LICENSE +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/README.md +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/__init__.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/annotation/__init__.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/annotation/deprecate.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/environment.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/error.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/fastapi/docs.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/fastapi/name.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/fastapi/request.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/fastapi/resource.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/fastapi/response.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/fastapi/schema.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/fluent.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/formatter.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/http/__init__.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/http/fake.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/http/fluent.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/http/httpx/__init__.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/http/httpx/client.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/http/httpx/hooks.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/http/json.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/http/url.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/id.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/key_fn.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/py.typed +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/query/__init__.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/query/generator.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/query/query.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/repository/__init__.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/repository/base.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/repository/connector.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/repository/database.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/repository/decorator.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/repository/in_memory.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/repository/interface.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/repository/mongo.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/repository/mssql.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/repository/sql.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/repository/sqlite.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/server.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/synchronization.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/testing/__init__.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/testing/database.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/testing/fake.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/testing/rest.py +0 -0
- {apexdevkit-1.20.3 → apexdevkit-1.20.5}/apexdevkit/value.py +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
from apexdevkit.fastapi.builder import FastApiBuilder, RestfulServiceBuilder
|
|
2
2
|
from apexdevkit.fastapi.dependable import inject
|
|
3
|
-
from apexdevkit.fastapi.service import
|
|
3
|
+
from apexdevkit.fastapi.service import RestfulRepository
|
|
4
4
|
|
|
5
5
|
__all__ = [
|
|
6
6
|
"FastApiBuilder",
|
|
7
7
|
"RestfulServiceBuilder",
|
|
8
8
|
"inject",
|
|
9
|
-
"
|
|
9
|
+
"RestfulRepository",
|
|
10
10
|
]
|
|
@@ -76,3 +76,11 @@ class RestfulServiceBuilder(ABC):
|
|
|
76
76
|
@abstractmethod
|
|
77
77
|
def build(self) -> RestfulService: # pragma: no cover
|
|
78
78
|
pass
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@dataclass
|
|
82
|
+
class PreBuilt(RestfulServiceBuilder): # pragma: no cover
|
|
83
|
+
service: RestfulService
|
|
84
|
+
|
|
85
|
+
def build(self) -> RestfulService:
|
|
86
|
+
return self.service
|
|
@@ -4,9 +4,9 @@ from typing import Annotated, Any, Callable, Protocol
|
|
|
4
4
|
from fastapi import Depends, Path
|
|
5
5
|
from fastapi.requests import Request
|
|
6
6
|
|
|
7
|
-
from apexdevkit.annotation import deprecated
|
|
8
7
|
from apexdevkit.error import ApiError, DoesNotExistError
|
|
9
8
|
from apexdevkit.fastapi import RestfulServiceBuilder
|
|
9
|
+
from apexdevkit.fastapi.builder import PreBuilt
|
|
10
10
|
from apexdevkit.fastapi.name import RestfulName
|
|
11
11
|
from apexdevkit.fastapi.response import RestfulResponse
|
|
12
12
|
from apexdevkit.fastapi.service import RestfulService
|
|
@@ -72,17 +72,6 @@ class UserDependency:
|
|
|
72
72
|
return Annotated[RestfulServiceBuilder, Depends(_)]
|
|
73
73
|
|
|
74
74
|
|
|
75
|
-
@dataclass(frozen=True)
|
|
76
|
-
class InfraDependency:
|
|
77
|
-
infra: RestfulServiceBuilder
|
|
78
|
-
|
|
79
|
-
def as_dependable(self) -> type[RestfulServiceBuilder]:
|
|
80
|
-
def _() -> RestfulServiceBuilder:
|
|
81
|
-
return self.infra
|
|
82
|
-
|
|
83
|
-
return Annotated[RestfulServiceBuilder, Depends(_)]
|
|
84
|
-
|
|
85
|
-
|
|
86
75
|
_BuilderCallable = Callable[..., RestfulServiceBuilder]
|
|
87
76
|
|
|
88
77
|
|
|
@@ -99,32 +88,25 @@ class BuilderCallableDependency:
|
|
|
99
88
|
|
|
100
89
|
@dataclass(frozen=True)
|
|
101
90
|
class DependableBuilder:
|
|
102
|
-
dependency: _Dependency
|
|
91
|
+
dependency: _Dependency
|
|
103
92
|
|
|
104
93
|
@classmethod
|
|
105
94
|
def from_callable(cls, value: _BuilderCallable) -> "DependableBuilder":
|
|
106
|
-
return
|
|
95
|
+
return cls(BuilderCallableDependency(value))
|
|
107
96
|
|
|
108
|
-
@
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
return DependableBuilder(InfraDependency(value))
|
|
97
|
+
@classmethod
|
|
98
|
+
def from_builder(cls, value: RestfulServiceBuilder) -> "DependableBuilder":
|
|
99
|
+
return cls(BuilderCallableDependency(lambda: value))
|
|
100
|
+
|
|
101
|
+
@classmethod
|
|
102
|
+
def from_service(cls, value: RestfulService) -> "DependableBuilder":
|
|
103
|
+
return cls(BuilderCallableDependency(lambda: PreBuilt(value)))
|
|
116
104
|
|
|
117
105
|
def with_parent(self, value: RestfulName) -> "DependableBuilder":
|
|
118
|
-
if self.dependency is None:
|
|
119
|
-
raise RuntimeError("RestfulServiceBuilder type not set")
|
|
120
106
|
return DependableBuilder(ParentDependency(value, self.dependency))
|
|
121
107
|
|
|
122
108
|
def with_user(self, extract_user: Callable[..., Any]) -> "DependableBuilder":
|
|
123
|
-
if self.dependency is None:
|
|
124
|
-
raise RuntimeError("RestfulServiceBuilder type not set")
|
|
125
109
|
return DependableBuilder(UserDependency(extract_user, self.dependency))
|
|
126
110
|
|
|
127
111
|
def as_dependable(self) -> type[RestfulService]:
|
|
128
|
-
if self.dependency is None:
|
|
129
|
-
raise RuntimeError("RestfulServiceBuilder type not set")
|
|
130
112
|
return ServiceDependency(self.dependency).as_dependable()
|
|
@@ -6,7 +6,6 @@ from typing import Annotated, Any, Protocol, Self, TypeVar
|
|
|
6
6
|
from fastapi import APIRouter, Depends, Path, Query
|
|
7
7
|
from fastapi.responses import JSONResponse
|
|
8
8
|
|
|
9
|
-
from apexdevkit.fastapi.builder import RestfulServiceBuilder
|
|
10
9
|
from apexdevkit.fastapi.name import RestfulName
|
|
11
10
|
from apexdevkit.fastapi.resource import RestfulResource, SummaryResponse
|
|
12
11
|
from apexdevkit.fastapi.response import RestfulResponse
|
|
@@ -24,14 +23,6 @@ class Dependency(Protocol): # pragma: no cover
|
|
|
24
23
|
pass
|
|
25
24
|
|
|
26
25
|
|
|
27
|
-
@dataclass
|
|
28
|
-
class PreBuiltRestfulService(RestfulServiceBuilder): # pragma: no cover
|
|
29
|
-
service: RestfulService
|
|
30
|
-
|
|
31
|
-
def build(self) -> RestfulService:
|
|
32
|
-
return self.service
|
|
33
|
-
|
|
34
|
-
|
|
35
26
|
@dataclass
|
|
36
27
|
class RestfulRouter:
|
|
37
28
|
router: APIRouter = field(default_factory=APIRouter)
|
|
@@ -63,30 +63,10 @@ ItemT = TypeVar("ItemT")
|
|
|
63
63
|
|
|
64
64
|
|
|
65
65
|
@dataclass(frozen=True)
|
|
66
|
-
class
|
|
67
|
-
|
|
68
|
-
repository: Repository[ItemT] | None = None
|
|
69
|
-
|
|
70
|
-
def with_formatter(
|
|
71
|
-
self, formatter: Formatter[Mapping[str, Any], ItemT]
|
|
72
|
-
) -> RestfulRepositoryBuilder[ItemT]:
|
|
73
|
-
return RestfulRepositoryBuilder[ItemT](formatter, self.repository)
|
|
74
|
-
|
|
75
|
-
def with_repository(
|
|
76
|
-
self, repository: Repository[ItemT]
|
|
77
|
-
) -> RestfulRepositoryBuilder[ItemT]:
|
|
78
|
-
return RestfulRepositoryBuilder[ItemT](self.formatter, repository)
|
|
79
|
-
|
|
80
|
-
def build(self) -> RestfulService:
|
|
81
|
-
if self.formatter is None or self.repository is None:
|
|
82
|
-
raise RuntimeError("Formatter or repository not provided.")
|
|
83
|
-
return _RestfulRepository(self.formatter, self.repository)
|
|
84
|
-
|
|
66
|
+
class RestfulRepository(RestfulService, Generic[ItemT]):
|
|
67
|
+
repository: Repository[ItemT]
|
|
85
68
|
|
|
86
|
-
@dataclass(frozen=True)
|
|
87
|
-
class _RestfulRepository(RestfulService, Generic[ItemT]):
|
|
88
69
|
formatter: Formatter[Mapping[str, Any], ItemT]
|
|
89
|
-
repository: Repository[ItemT]
|
|
90
70
|
|
|
91
71
|
def create_one(self, item: RawItem) -> RawItem:
|
|
92
72
|
return self.formatter.dump(self.repository.create(self.formatter.load(item)))
|
|
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
|
|
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
|