apexdevkit 1.25.1__tar.gz → 1.25.3__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.1 → apexdevkit-1.25.3}/PKG-INFO +1 -1
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/fastapi/builder.py +17 -4
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/fastapi/router.py +16 -2
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/fastapi/schema.py +6 -7
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/pyproject.toml +1 -1
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/LICENSE +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/README.md +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/__init__.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/annotation/__init__.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/annotation/deprecate.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/date.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/environment.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/error.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/fastapi/__init__.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/fastapi/dependable.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/fastapi/docs.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/fastapi/name.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/fastapi/resource.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/fastapi/response.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/fastapi/service.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/fluent.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/formatter.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/http/__init__.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/http/fake.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/http/fluent.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/http/httpx/__init__.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/http/httpx/client.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/http/httpx/hooks.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/http/json.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/http/url.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/id.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/key_fn.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/py.typed +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/query/__init__.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/query/generator.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/query/query.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/repository/__init__.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/repository/base.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/repository/connector.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/repository/database.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/repository/decorator.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/repository/in_memory.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/repository/interface.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/repository/mssql.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/repository/repository.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/repository/sql.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/repository/sqlite.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/server.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/synchronization.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/testing/__init__.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/testing/database.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/testing/fake.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/testing/rest.py +0 -0
- {apexdevkit-1.25.1 → apexdevkit-1.25.3}/apexdevkit/value.py +0 -0
|
@@ -6,8 +6,8 @@ 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
13
|
from apexdevkit.fastapi.service import RestfulService
|
|
@@ -51,14 +51,16 @@ class FastApiBuilder:
|
|
|
51
51
|
def with_routes(self, values: Mapping[str, APIRouter]) -> Self:
|
|
52
52
|
for key, value in values.items():
|
|
53
53
|
self.app.include_router(
|
|
54
|
-
value,
|
|
54
|
+
value,
|
|
55
|
+
prefix=_Endpoint(key).normilized(),
|
|
56
|
+
tags=value.tags or [key.title()],
|
|
55
57
|
)
|
|
56
58
|
|
|
57
59
|
return self
|
|
58
60
|
|
|
59
61
|
def with_mounted(self, **apps: FastAPI) -> Self:
|
|
60
62
|
for path, app in apps.items():
|
|
61
|
-
self.app.mount(
|
|
63
|
+
self.app.mount(_Endpoint(path).normilized(), app)
|
|
62
64
|
|
|
63
65
|
return self
|
|
64
66
|
|
|
@@ -105,3 +107,14 @@ class PreBuilt(RestfulServiceBuilder): # pragma: no cover
|
|
|
105
107
|
|
|
106
108
|
def build(self) -> RestfulService:
|
|
107
109
|
return self.service
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
@dataclass(frozen=True)
|
|
113
|
+
class _Endpoint:
|
|
114
|
+
raw: str
|
|
115
|
+
|
|
116
|
+
def normilized(self) -> str:
|
|
117
|
+
return f"/{self.raw.replace('_', '-')}"
|
|
118
|
+
|
|
119
|
+
def __str__(self) -> str:
|
|
120
|
+
return self.normilized()
|
|
@@ -60,10 +60,23 @@ class RestfulRouter:
|
|
|
60
60
|
return "/{" + self.id_alias + "}"
|
|
61
61
|
|
|
62
62
|
def with_fields(self, value: SchemaFields) -> Self:
|
|
63
|
-
self._schema = RestfulSchema(
|
|
63
|
+
self._schema = RestfulSchema(
|
|
64
|
+
name=self.name,
|
|
65
|
+
fields=value,
|
|
66
|
+
generator=self._schema_generator,
|
|
67
|
+
)
|
|
64
68
|
|
|
65
69
|
return self
|
|
66
70
|
|
|
71
|
+
@property
|
|
72
|
+
def _schema_generator(self) -> Schema:
|
|
73
|
+
if self.parent:
|
|
74
|
+
return Schema(
|
|
75
|
+
self.parent.singular.capitalize() + self.name.singular.capitalize()
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
return Schema(self.name.singular.capitalize())
|
|
79
|
+
|
|
67
80
|
def with_tag(self, value: list[str | Enum]) -> Self:
|
|
68
81
|
self.router.tags = value
|
|
69
82
|
|
|
@@ -157,7 +170,8 @@ class RestfulRouter:
|
|
|
157
170
|
self.resource.read_many(
|
|
158
171
|
Service=self._resolve(dependency),
|
|
159
172
|
QueryParams=Annotated[
|
|
160
|
-
Schema(self.name).optional_schema_for("ReadMany", query),
|
|
173
|
+
Schema(self.name.singular).optional_schema_for("ReadMany", query),
|
|
174
|
+
Query(),
|
|
161
175
|
],
|
|
162
176
|
),
|
|
163
177
|
methods=["GET"],
|
|
@@ -45,6 +45,7 @@ class SchemaFields(ABC):
|
|
|
45
45
|
class RestfulSchema:
|
|
46
46
|
name: RestfulName
|
|
47
47
|
fields: SchemaFields
|
|
48
|
+
generator: "Schema"
|
|
48
49
|
|
|
49
50
|
def __post_init__(self) -> None:
|
|
50
51
|
schema = self._schema_for("", self.fields.readable())
|
|
@@ -66,7 +67,7 @@ class RestfulSchema:
|
|
|
66
67
|
|
|
67
68
|
def _schema_for(self, action: str, fields: dict[str, Any]) -> type[BaseModel]:
|
|
68
69
|
if action not in self.schemas:
|
|
69
|
-
self.schemas[action] =
|
|
70
|
+
self.schemas[action] = self.generator.schema_for(action, fields)
|
|
70
71
|
|
|
71
72
|
return self.schemas[action]
|
|
72
73
|
|
|
@@ -177,16 +178,16 @@ class RestfulSchema:
|
|
|
177
178
|
|
|
178
179
|
@dataclass(frozen=True)
|
|
179
180
|
class Schema:
|
|
180
|
-
|
|
181
|
+
resource: str
|
|
181
182
|
|
|
182
183
|
def schema_for(self, action: str, fields: dict[str, Any]) -> type[BaseModel]:
|
|
183
|
-
return self._nested_schema_for(self.
|
|
184
|
+
return self._nested_schema_for(self.resource + action, fields)
|
|
184
185
|
|
|
185
186
|
def optional_schema_for(
|
|
186
187
|
self, action: str, fields: dict[str, Any]
|
|
187
188
|
) -> type[BaseModel]:
|
|
188
189
|
return create_model(
|
|
189
|
-
self.
|
|
190
|
+
self.resource + action,
|
|
190
191
|
**{
|
|
191
192
|
field_name: (field_type | None, None)
|
|
192
193
|
for field_name, field_type in fields.items()
|
|
@@ -199,9 +200,7 @@ class Schema:
|
|
|
199
200
|
for field_name, field_type in fields.items():
|
|
200
201
|
if isinstance(field_type, dict):
|
|
201
202
|
model_fields[field_name] = (
|
|
202
|
-
self._nested_schema_for(
|
|
203
|
-
name.capitalize() + field_name.capitalize(), field_type
|
|
204
|
-
),
|
|
203
|
+
self._nested_schema_for(name + field_name.capitalize(), field_type),
|
|
205
204
|
...,
|
|
206
205
|
)
|
|
207
206
|
else:
|
|
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
|