apexdevkit 1.16.2__tar.gz → 1.16.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.16.2 → apexdevkit-1.16.4}/PKG-INFO +1 -1
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/fastapi/resource.py +9 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/fastapi/router.py +27 -2
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/fastapi/schema.py +15 -7
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/fastapi/service.py +3 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/repository/mssql.py +11 -11
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/testing/rest.py +7 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/pyproject.toml +1 -1
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/LICENSE +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/README.md +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/__init__.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/annotation/__init__.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/annotation/deprecate.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/environment.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/error.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/fastapi/__init__.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/fastapi/builder.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/fastapi/dependable.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/fastapi/docs.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/fastapi/name.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/fastapi/request.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/fastapi/response.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/fluent.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/formatter.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/http/__init__.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/http/fake.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/http/fluent.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/http/httpx.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/http/json.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/http/url.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/key_fn.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/py.typed +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/repository/__init__.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/repository/base.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/repository/connector.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/repository/database.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/repository/decorator.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/repository/in_memory.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/repository/interface.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/repository/mongo.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/repository/sqlite.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/server.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/synchronization.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/testing/__init__.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/testing/database.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/testing/fake.py +0 -0
- {apexdevkit-1.16.2 → apexdevkit-1.16.4}/apexdevkit/value.py +0 -0
|
@@ -49,6 +49,15 @@ class RestfulResource:
|
|
|
49
49
|
|
|
50
50
|
return endpoint
|
|
51
51
|
|
|
52
|
+
def read_many(self, Service, QueryParams) -> _Endpoint: # type: ignore
|
|
53
|
+
def endpoint(service: Service, params: QueryParams) -> _Response:
|
|
54
|
+
try:
|
|
55
|
+
return self.response.found_many(list(service.read_many(**dict(params))))
|
|
56
|
+
except ForbiddenError as e:
|
|
57
|
+
return JSONResponse(self.response.forbidden(e), 403)
|
|
58
|
+
|
|
59
|
+
return endpoint
|
|
60
|
+
|
|
52
61
|
def read_all(self, Service) -> _Endpoint: # type: ignore
|
|
53
62
|
def endpoint(service: Service) -> _Response:
|
|
54
63
|
try:
|
|
@@ -2,15 +2,16 @@ from dataclasses import dataclass, field
|
|
|
2
2
|
from functools import cached_property
|
|
3
3
|
from typing import Annotated, Any, Protocol, Self, TypeVar
|
|
4
4
|
|
|
5
|
-
from fastapi import APIRouter, Depends, Path
|
|
5
|
+
from fastapi import APIRouter, Depends, Path, Query
|
|
6
6
|
from fastapi.responses import JSONResponse
|
|
7
7
|
|
|
8
8
|
from apexdevkit.fastapi.builder import RestfulServiceBuilder
|
|
9
9
|
from apexdevkit.fastapi.name import RestfulName
|
|
10
10
|
from apexdevkit.fastapi.resource import RestfulResource
|
|
11
11
|
from apexdevkit.fastapi.response import RestfulResponse
|
|
12
|
-
from apexdevkit.fastapi.schema import RestfulSchema, SchemaFields
|
|
12
|
+
from apexdevkit.fastapi.schema import RestfulSchema, Schema, SchemaFields
|
|
13
13
|
from apexdevkit.fastapi.service import RawCollection, RawItem, RestfulService
|
|
14
|
+
from apexdevkit.fluent import FluentDict
|
|
14
15
|
|
|
15
16
|
_Response = JSONResponse | dict[str, Any]
|
|
16
17
|
|
|
@@ -135,6 +136,30 @@ class RestfulRouter:
|
|
|
135
136
|
|
|
136
137
|
return self
|
|
137
138
|
|
|
139
|
+
def with_read_many_endpoint(
|
|
140
|
+
self,
|
|
141
|
+
dependency: Dependency,
|
|
142
|
+
query: FluentDict[Any],
|
|
143
|
+
is_documented: bool = True,
|
|
144
|
+
) -> Self:
|
|
145
|
+
self.router.add_api_route(
|
|
146
|
+
"",
|
|
147
|
+
self.resource.read_many(
|
|
148
|
+
Service=dependency.as_dependable(),
|
|
149
|
+
QueryParams=Annotated[
|
|
150
|
+
Schema(self.name).schema_for("ReadMany", query), Query()
|
|
151
|
+
],
|
|
152
|
+
),
|
|
153
|
+
methods=["GET"],
|
|
154
|
+
status_code=200,
|
|
155
|
+
responses={},
|
|
156
|
+
response_model=self.schema.for_collection(),
|
|
157
|
+
include_in_schema=is_documented,
|
|
158
|
+
summary="Read Many",
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
return self
|
|
162
|
+
|
|
138
163
|
def with_read_all_endpoint(
|
|
139
164
|
self,
|
|
140
165
|
dependency: Dependency,
|
|
@@ -46,13 +46,7 @@ class RestfulSchema:
|
|
|
46
46
|
|
|
47
47
|
def _schema_for(self, action: str, fields: dict[str, Any]) -> type[BaseModel]:
|
|
48
48
|
if action not in self.schemas:
|
|
49
|
-
self.schemas[action] =
|
|
50
|
-
self.name.singular.capitalize() + action,
|
|
51
|
-
**{
|
|
52
|
-
field_name: (field_type, ...)
|
|
53
|
-
for field_name, field_type in fields.items()
|
|
54
|
-
},
|
|
55
|
-
)
|
|
49
|
+
self.schemas[action] = Schema(self.name).schema_for(action, fields)
|
|
56
50
|
|
|
57
51
|
return self.schemas[action]
|
|
58
52
|
|
|
@@ -134,3 +128,17 @@ class RestfulSchema:
|
|
|
134
128
|
return [dict(item) for item in request.model_dump()[self.name.plural]]
|
|
135
129
|
|
|
136
130
|
return _
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
@dataclass(frozen=True)
|
|
134
|
+
class Schema:
|
|
135
|
+
name: RestfulName
|
|
136
|
+
|
|
137
|
+
def schema_for(self, action: str, fields: dict[str, Any]) -> type[BaseModel]:
|
|
138
|
+
return create_model(
|
|
139
|
+
self.name.singular.capitalize() + action,
|
|
140
|
+
**{
|
|
141
|
+
field_name: (field_type, ...)
|
|
142
|
+
for field_name, field_type in fields.items()
|
|
143
|
+
},
|
|
144
|
+
)
|
|
@@ -30,6 +30,9 @@ class RestfulService(ABC): # pragma: no cover
|
|
|
30
30
|
def read_one(self, item_id: str) -> RawItem:
|
|
31
31
|
raise NotImplementedError(self.read_one.__name__)
|
|
32
32
|
|
|
33
|
+
def read_many(self, **params: Any) -> RawCollection:
|
|
34
|
+
raise NotImplementedError(self.read_many.__name__)
|
|
35
|
+
|
|
33
36
|
def read_all(self) -> RawCollection:
|
|
34
37
|
raise NotImplementedError(self.read_all.__name__)
|
|
35
38
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from dataclasses import dataclass
|
|
4
|
-
from typing import Any,
|
|
4
|
+
from typing import Any, Generic, Iterator, TypeVar
|
|
5
5
|
|
|
6
6
|
from pymssql.exceptions import DatabaseError
|
|
7
7
|
|
|
@@ -57,33 +57,33 @@ class MsSqlRepository(RepositoryBase[ItemT]):
|
|
|
57
57
|
self.db.execute(self.table.update(item)).fetch_none()
|
|
58
58
|
|
|
59
59
|
|
|
60
|
-
class SqlTable(
|
|
60
|
+
class SqlTable(Generic[ItemT]): # pragma: no cover
|
|
61
61
|
def count_all(self) -> DatabaseCommand:
|
|
62
|
-
|
|
62
|
+
raise NotImplementedError
|
|
63
63
|
|
|
64
64
|
def insert(self, item: ItemT) -> DatabaseCommand:
|
|
65
|
-
|
|
65
|
+
raise NotImplementedError
|
|
66
66
|
|
|
67
67
|
def select(self, item_id: str) -> DatabaseCommand:
|
|
68
|
-
|
|
68
|
+
raise NotImplementedError
|
|
69
69
|
|
|
70
70
|
def select_all(self) -> DatabaseCommand:
|
|
71
|
-
|
|
71
|
+
raise NotImplementedError
|
|
72
72
|
|
|
73
73
|
def delete(self, item_id: str) -> DatabaseCommand:
|
|
74
|
-
|
|
74
|
+
raise NotImplementedError
|
|
75
75
|
|
|
76
76
|
def delete_all(self) -> DatabaseCommand:
|
|
77
|
-
|
|
77
|
+
raise NotImplementedError
|
|
78
78
|
|
|
79
79
|
def update(self, item: ItemT) -> DatabaseCommand:
|
|
80
|
-
|
|
80
|
+
raise NotImplementedError
|
|
81
81
|
|
|
82
82
|
def load(self, data: dict[str, Any]) -> ItemT:
|
|
83
|
-
|
|
83
|
+
raise NotImplementedError
|
|
84
84
|
|
|
85
85
|
def exists(self, duplicate: ItemT) -> ExistsError:
|
|
86
|
-
|
|
86
|
+
raise NotImplementedError
|
|
87
87
|
|
|
88
88
|
|
|
89
89
|
@dataclass
|
|
@@ -42,6 +42,13 @@ class _RestResource:
|
|
|
42
42
|
),
|
|
43
43
|
)
|
|
44
44
|
|
|
45
|
+
def read_many(self, **params: Any) -> _TestRequest:
|
|
46
|
+
http = self.http.with_endpoint(self.name.plural)
|
|
47
|
+
for p, v in params.items():
|
|
48
|
+
http = http.with_param(p, v)
|
|
49
|
+
|
|
50
|
+
return _TestRequest(self.name, HttpRequest(HttpMethod.get, http))
|
|
51
|
+
|
|
45
52
|
def read_all(self) -> _TestRequest:
|
|
46
53
|
return _TestRequest(
|
|
47
54
|
self.name,
|
|
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
|