apexdevkit 1.5.13__tar.gz → 1.5.15__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.13 → apexdevkit-1.5.15}/PKG-INFO +1 -1
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/annotation/deprecate.py +3 -1
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/fastapi/builder.py +1 -1
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/fastapi/dependable.py +1 -1
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/fastapi/router.py +8 -5
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/fastapi/schema.py +4 -2
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/fastapi/service.py +4 -2
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/repository/in_memory.py +1 -1
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/repository/interface.py +1 -1
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/testing/rest.py +12 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/pyproject.toml +1 -1
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/LICENSE +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/README.md +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/__init__.py +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/annotation/__init__.py +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/error.py +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/fastapi/__init__.py +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/fastapi/docs.py +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/fastapi/response.py +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/formatter.py +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/http/__init__.py +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/http/fake.py +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/http/fluent.py +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/http/httpx.py +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/http/json.py +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/http/url.py +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/py.typed +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/repository/__init__.py +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/repository/base.py +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/repository/connector.py +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/repository/database.py +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/testing/__init__.py +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/testing/database.py +0 -0
- {apexdevkit-1.5.13 → apexdevkit-1.5.15}/apexdevkit/testing/fake.py +0 -0
|
@@ -26,7 +26,9 @@ def deprecated(warning: str) -> Callable[[F], F]:
|
|
|
26
26
|
elif inspect.isclass(obj):
|
|
27
27
|
return cast(F, _deprecate_class(obj, warning))
|
|
28
28
|
else:
|
|
29
|
-
raise TypeError(
|
|
29
|
+
raise TypeError(
|
|
30
|
+
f"Unsupported type for deprecation: {type(obj)}"
|
|
31
|
+
) # pragma: no cover
|
|
30
32
|
|
|
31
33
|
return decorator
|
|
32
34
|
|
|
@@ -6,6 +6,7 @@ from typing import Annotated, Any, Callable, Iterable, Self, TypeVar
|
|
|
6
6
|
from fastapi import APIRouter, Depends, Path
|
|
7
7
|
from fastapi.responses import JSONResponse
|
|
8
8
|
|
|
9
|
+
from apexdevkit.annotation import deprecated
|
|
9
10
|
from apexdevkit.error import DoesNotExistError, ExistsError, ForbiddenError
|
|
10
11
|
from apexdevkit.fastapi.schema import DataclassFields, RestfulSchema, SchemaFields
|
|
11
12
|
from apexdevkit.fastapi.service import RawCollection, RawItem, RestfulService
|
|
@@ -95,12 +96,12 @@ class RestfulServiceBuilder(ABC):
|
|
|
95
96
|
return self
|
|
96
97
|
|
|
97
98
|
@abstractmethod
|
|
98
|
-
def build(self) -> RestfulService:
|
|
99
|
+
def build(self) -> RestfulService: # pragma: no cover
|
|
99
100
|
pass
|
|
100
101
|
|
|
101
102
|
|
|
102
103
|
@dataclass
|
|
103
|
-
class PreBuiltRestfulService(RestfulServiceBuilder):
|
|
104
|
+
class PreBuiltRestfulService(RestfulServiceBuilder): # pragma: no cover
|
|
104
105
|
service: RestfulService
|
|
105
106
|
|
|
106
107
|
def build(self) -> RestfulService:
|
|
@@ -123,7 +124,7 @@ class RestfulRouter:
|
|
|
123
124
|
|
|
124
125
|
parent: str = field(init=False, default="")
|
|
125
126
|
|
|
126
|
-
def __post_init__(self) -> None:
|
|
127
|
+
def __post_init__(self) -> None: # pragma: no cover
|
|
127
128
|
if self.service:
|
|
128
129
|
self.infra = PreBuiltRestfulService(self.service)
|
|
129
130
|
|
|
@@ -147,7 +148,8 @@ class RestfulRouter:
|
|
|
147
148
|
def item_path(self) -> str:
|
|
148
149
|
return "/{" + self.id_alias + "}"
|
|
149
150
|
|
|
150
|
-
|
|
151
|
+
@deprecated("Use with_name and with_fields instead")
|
|
152
|
+
def with_dataclass(self, value: Any) -> Self: # pragma: no cover
|
|
151
153
|
return self.with_name(RestfulName(value.__name__.lower())).with_fields(
|
|
152
154
|
DataclassFields(value)
|
|
153
155
|
)
|
|
@@ -167,7 +169,8 @@ class RestfulRouter:
|
|
|
167
169
|
|
|
168
170
|
return self
|
|
169
171
|
|
|
170
|
-
|
|
172
|
+
@deprecated("Use with_infra instead")
|
|
173
|
+
def with_service(self, value: RestfulService) -> Self: # pragma: no cover
|
|
171
174
|
self.infra = PreBuiltRestfulService(value)
|
|
172
175
|
|
|
173
176
|
return self
|
|
@@ -5,6 +5,7 @@ from typing import Any, Callable, Iterable, List
|
|
|
5
5
|
|
|
6
6
|
from pydantic import BaseModel, create_model
|
|
7
7
|
|
|
8
|
+
from apexdevkit.annotation import deprecated
|
|
8
9
|
from apexdevkit.http import JsonDict
|
|
9
10
|
from apexdevkit.testing import RestfulName
|
|
10
11
|
|
|
@@ -20,12 +21,13 @@ class SchemaFields(ABC):
|
|
|
20
21
|
return self.readable().drop("id")
|
|
21
22
|
|
|
22
23
|
@abstractmethod
|
|
23
|
-
def readable(self) -> JsonDict:
|
|
24
|
+
def readable(self) -> JsonDict: # pragma: no cover
|
|
24
25
|
pass
|
|
25
26
|
|
|
26
27
|
|
|
28
|
+
@deprecated("Use custom schema fields instead")
|
|
27
29
|
@dataclass
|
|
28
|
-
class DataclassFields(SchemaFields):
|
|
30
|
+
class DataclassFields(SchemaFields): # pragma: no cover
|
|
29
31
|
source: Any
|
|
30
32
|
|
|
31
33
|
def readable(self) -> JsonDict:
|
|
@@ -2,6 +2,7 @@ from abc import ABC
|
|
|
2
2
|
from dataclasses import dataclass, field
|
|
3
3
|
from typing import Any, Dict, Generic, Iterable, Self, TypeVar
|
|
4
4
|
|
|
5
|
+
from apexdevkit.annotation import deprecated
|
|
5
6
|
from apexdevkit.formatter import DataclassFormatter, Formatter
|
|
6
7
|
from apexdevkit.repository.interface import Repository
|
|
7
8
|
|
|
@@ -17,7 +18,7 @@ class _RawItemWithId(Dict[str, Any]):
|
|
|
17
18
|
RawCollectionWithId = Iterable[_RawItemWithId]
|
|
18
19
|
|
|
19
20
|
|
|
20
|
-
class RestfulService(ABC):
|
|
21
|
+
class RestfulService(ABC): # pragma: no cover
|
|
21
22
|
def create_one(self, item: RawItem) -> RawItem:
|
|
22
23
|
raise NotImplementedError(self.create_one.__name__)
|
|
23
24
|
|
|
@@ -49,6 +50,7 @@ class RestfulRepositoryBuilder(Generic[ItemT]):
|
|
|
49
50
|
formatter: Formatter[ItemT] | None = field(init=False, default=None)
|
|
50
51
|
repository: Repository[Any, ItemT] = field(init=False)
|
|
51
52
|
|
|
53
|
+
@deprecated("Pass formatter instead")
|
|
52
54
|
def with_resource(self, resource: type[ItemT]) -> Self:
|
|
53
55
|
self.resource = resource
|
|
54
56
|
|
|
@@ -66,7 +68,7 @@ class RestfulRepositoryBuilder(Generic[ItemT]):
|
|
|
66
68
|
|
|
67
69
|
def build(self) -> RestfulService:
|
|
68
70
|
if not self.formatter and self.resource:
|
|
69
|
-
self.
|
|
71
|
+
self.with_formatter(DataclassFormatter(self.resource))
|
|
70
72
|
|
|
71
73
|
assert self.formatter, "Must provide either resource or formatter"
|
|
72
74
|
|
|
@@ -79,6 +79,18 @@ def as_plural(singular: str) -> str:
|
|
|
79
79
|
if singular.endswith("y"):
|
|
80
80
|
return singular[:-1] + "ies"
|
|
81
81
|
|
|
82
|
+
if singular.endswith("ch") or singular.endswith("sh") or singular.endswith("ss"):
|
|
83
|
+
return singular[:-2] + "es"
|
|
84
|
+
|
|
85
|
+
if singular.endswith("s") or singular.endswith("z") or singular.endswith("x"):
|
|
86
|
+
return singular[:-1] + "es"
|
|
87
|
+
|
|
88
|
+
if singular.endswith("fe"):
|
|
89
|
+
return singular[:-2] + "ves"
|
|
90
|
+
|
|
91
|
+
if singular.endswith("f"):
|
|
92
|
+
return singular[:-1] + "ves"
|
|
93
|
+
|
|
82
94
|
return singular + "s"
|
|
83
95
|
|
|
84
96
|
|
|
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
|