apexdevkit 1.25.2__tar.gz → 1.25.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.25.2 → apexdevkit-1.25.4}/PKG-INFO +1 -1
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/fastapi/builder.py +21 -4
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/fastapi/dependable.py +23 -18
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/pyproject.toml +1 -1
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/LICENSE +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/README.md +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/__init__.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/annotation/__init__.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/annotation/deprecate.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/date.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/environment.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/error.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/fastapi/__init__.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/fastapi/docs.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/fastapi/name.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/fastapi/resource.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/fastapi/response.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/fastapi/router.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/fastapi/schema.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/fastapi/service.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/fluent.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/formatter.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/http/__init__.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/http/fake.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/http/fluent.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/http/httpx/__init__.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/http/httpx/client.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/http/httpx/hooks.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/http/json.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/http/url.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/id.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/key_fn.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/py.typed +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/query/__init__.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/query/generator.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/query/query.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/repository/__init__.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/repository/base.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/repository/connector.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/repository/database.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/repository/decorator.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/repository/in_memory.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/repository/interface.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/repository/mssql.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/repository/repository.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/repository/sql.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/repository/sqlite.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/server.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/synchronization.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/testing/__init__.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/testing/database.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/testing/fake.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/testing/rest.py +0 -0
- {apexdevkit-1.25.2 → apexdevkit-1.25.4}/apexdevkit/value.py +0 -0
|
@@ -6,10 +6,11 @@ from dataclasses import dataclass, field
|
|
|
6
6
|
from typing import Any, Self
|
|
7
7
|
|
|
8
8
|
from fastapi import APIRouter, FastAPI
|
|
9
|
-
from
|
|
10
|
-
from
|
|
9
|
+
from fastapi.middleware.cors import CORSMiddleware
|
|
10
|
+
from fastapi.responses import JSONResponse
|
|
11
11
|
|
|
12
12
|
from apexdevkit.error import ApiError
|
|
13
|
+
from apexdevkit.fastapi.dependable import DependableBuilder
|
|
13
14
|
from apexdevkit.fastapi.service import RestfulService
|
|
14
15
|
|
|
15
16
|
|
|
@@ -51,14 +52,16 @@ class FastApiBuilder:
|
|
|
51
52
|
def with_routes(self, values: Mapping[str, APIRouter]) -> Self:
|
|
52
53
|
for key, value in values.items():
|
|
53
54
|
self.app.include_router(
|
|
54
|
-
value,
|
|
55
|
+
value,
|
|
56
|
+
prefix=_Endpoint(key).normilized(),
|
|
57
|
+
tags=value.tags or [key.title()],
|
|
55
58
|
)
|
|
56
59
|
|
|
57
60
|
return self
|
|
58
61
|
|
|
59
62
|
def with_mounted(self, **apps: FastAPI) -> Self:
|
|
60
63
|
for path, app in apps.items():
|
|
61
|
-
self.app.mount(
|
|
64
|
+
self.app.mount(_Endpoint(path).normilized(), app)
|
|
62
65
|
|
|
63
66
|
return self
|
|
64
67
|
|
|
@@ -84,6 +87,9 @@ class RestfulServiceBuilder(ABC):
|
|
|
84
87
|
parent_id: str = field(init=False)
|
|
85
88
|
user: Any = field(init=False)
|
|
86
89
|
|
|
90
|
+
def as_dependable(self) -> DependableBuilder:
|
|
91
|
+
return DependableBuilder.from_builder(self)
|
|
92
|
+
|
|
87
93
|
def with_user(self, user: Any) -> RestfulServiceBuilder:
|
|
88
94
|
self.user = user
|
|
89
95
|
|
|
@@ -105,3 +111,14 @@ class PreBuilt(RestfulServiceBuilder): # pragma: no cover
|
|
|
105
111
|
|
|
106
112
|
def build(self) -> RestfulService:
|
|
107
113
|
return self.service
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@dataclass(frozen=True)
|
|
117
|
+
class _Endpoint:
|
|
118
|
+
raw: str
|
|
119
|
+
|
|
120
|
+
def normilized(self) -> str:
|
|
121
|
+
return f"/{self.raw.replace('_', '-')}"
|
|
122
|
+
|
|
123
|
+
def __str__(self) -> str:
|
|
124
|
+
return self.normilized()
|
|
@@ -6,8 +6,6 @@ from fastapi import Depends, Path
|
|
|
6
6
|
from fastapi.requests import Request
|
|
7
7
|
|
|
8
8
|
from apexdevkit.error import ApiError, DoesNotExistError, ForbiddenError
|
|
9
|
-
from apexdevkit.fastapi import RestfulServiceBuilder
|
|
10
|
-
from apexdevkit.fastapi.builder import PreBuilt
|
|
11
9
|
from apexdevkit.fastapi.name import RestfulName
|
|
12
10
|
from apexdevkit.fastapi.response import RestfulResponse
|
|
13
11
|
from apexdevkit.fastapi.service import RestfulService
|
|
@@ -20,8 +18,19 @@ def inject(dependency: str) -> Any: # pragma: no cover
|
|
|
20
18
|
return Depends(get)
|
|
21
19
|
|
|
22
20
|
|
|
21
|
+
class _ServiceBuilder(Protocol):
|
|
22
|
+
def with_user(self, user: Any) -> "_ServiceBuilder":
|
|
23
|
+
pass
|
|
24
|
+
|
|
25
|
+
def with_parent(self, identity: str) -> "_ServiceBuilder":
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
def build(self) -> RestfulService: # pragma: no cover
|
|
29
|
+
pass
|
|
30
|
+
|
|
31
|
+
|
|
23
32
|
class _Dependency(Protocol):
|
|
24
|
-
def as_dependable(self) -> type[
|
|
33
|
+
def as_dependable(self) -> type[_ServiceBuilder]:
|
|
25
34
|
pass
|
|
26
35
|
|
|
27
36
|
|
|
@@ -48,19 +57,19 @@ class ParentDependency:
|
|
|
48
57
|
parent: RestfulName
|
|
49
58
|
dependency: _Dependency
|
|
50
59
|
|
|
51
|
-
def as_dependable(self) -> type[
|
|
60
|
+
def as_dependable(self) -> type[_ServiceBuilder]:
|
|
52
61
|
Builder = self.dependency.as_dependable()
|
|
53
62
|
ParentId = Annotated[
|
|
54
63
|
str, Path(alias=self.parent.singular.replace("-", "_") + "_id")
|
|
55
64
|
]
|
|
56
65
|
|
|
57
|
-
def _(builder: Builder, parent_id: ParentId) ->
|
|
66
|
+
def _(builder: Builder, parent_id: ParentId) -> _ServiceBuilder:
|
|
58
67
|
try:
|
|
59
68
|
return builder.with_parent(parent_id)
|
|
60
69
|
except DoesNotExistError as e:
|
|
61
70
|
raise ApiError(404, RestfulResponse(self.parent).not_found(e)) from e
|
|
62
71
|
|
|
63
|
-
return Annotated[
|
|
72
|
+
return Annotated[_ServiceBuilder, Depends(_)]
|
|
64
73
|
|
|
65
74
|
|
|
66
75
|
@dataclass(frozen=True)
|
|
@@ -68,28 +77,28 @@ class UserDependency:
|
|
|
68
77
|
extract_user: Callable[..., Any]
|
|
69
78
|
dependency: _Dependency
|
|
70
79
|
|
|
71
|
-
def as_dependable(self) -> type[
|
|
80
|
+
def as_dependable(self) -> type[_ServiceBuilder]:
|
|
72
81
|
Builder = self.dependency.as_dependable()
|
|
73
82
|
User = Annotated[Any, Depends(self.extract_user)]
|
|
74
83
|
|
|
75
|
-
def _(builder: Builder, user: User) ->
|
|
84
|
+
def _(builder: Builder, user: User) -> _ServiceBuilder:
|
|
76
85
|
return builder.with_user(user)
|
|
77
86
|
|
|
78
|
-
return Annotated[
|
|
87
|
+
return Annotated[_ServiceBuilder, Depends(_)]
|
|
79
88
|
|
|
80
89
|
|
|
81
|
-
_BuilderCallable = Callable[...,
|
|
90
|
+
_BuilderCallable = Callable[..., _ServiceBuilder]
|
|
82
91
|
|
|
83
92
|
|
|
84
93
|
@dataclass(frozen=True)
|
|
85
94
|
class BuilderCallableDependency:
|
|
86
95
|
create_builder: _BuilderCallable
|
|
87
96
|
|
|
88
|
-
def as_dependable(self) -> type[
|
|
89
|
-
def _() ->
|
|
97
|
+
def as_dependable(self) -> type[_ServiceBuilder]:
|
|
98
|
+
def _() -> _ServiceBuilder:
|
|
90
99
|
return self.create_builder()
|
|
91
100
|
|
|
92
|
-
return Annotated[
|
|
101
|
+
return Annotated[_ServiceBuilder, Depends(_)]
|
|
93
102
|
|
|
94
103
|
|
|
95
104
|
@dataclass(frozen=True)
|
|
@@ -101,13 +110,9 @@ class DependableBuilder:
|
|
|
101
110
|
return cls(BuilderCallableDependency(value))
|
|
102
111
|
|
|
103
112
|
@classmethod
|
|
104
|
-
def from_builder(cls, value:
|
|
113
|
+
def from_builder(cls, value: _ServiceBuilder) -> "DependableBuilder":
|
|
105
114
|
return cls(BuilderCallableDependency(lambda: value))
|
|
106
115
|
|
|
107
|
-
@classmethod
|
|
108
|
-
def from_service(cls, value: RestfulService) -> "DependableBuilder":
|
|
109
|
-
return cls(BuilderCallableDependency(lambda: PreBuilt(value)))
|
|
110
|
-
|
|
111
116
|
def with_parent(self, value: RestfulName) -> "DependableBuilder":
|
|
112
117
|
return DependableBuilder(ParentDependency(value, self.dependency))
|
|
113
118
|
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|