apexdevkit 2.1.1__tar.gz → 2.1.2__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-2.1.1 → apexdevkit-2.1.2}/PKG-INFO +1 -1
- apexdevkit-2.1.2/apexdevkit/__init__.py +7 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/fastapi/builder.py +51 -11
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/pyproject.toml +1 -1
- apexdevkit-2.1.1/apexdevkit/__init__.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/LICENSE +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/README.md +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/annotation/__init__.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/annotation/deprecate.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/date.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/error.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/fastapi/__init__.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/fastapi/dependable.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/fastapi/docs.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/fastapi/name.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/fastapi/resource.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/fastapi/response.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/fastapi/router.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/fastapi/schema.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/fastapi/service.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/formatter.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/key_fn.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/py.typed +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/query/__init__.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/query/generator.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/query/query.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/repository/__init__.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/repository/core/__init__.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/repository/core/database.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/repository/core/decorator.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/repository/core/interface.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/repository/core/mixin.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/repository/in_memory/__init__.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/repository/in_memory/mixin.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/repository/in_memory/repository.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/repository/in_memory/store.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/repository/sql/__init__.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/repository/sql/connector.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/repository/sql/field.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/repository/sql/mssql/__init__.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/repository/sql/mssql/repository.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/repository/sql/mssql/table.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/repository/sql/sqlite/__init__.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/repository/sql/sqlite/repository.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/repository/sql/sqlite/table.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/server.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/sync/__init__.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/sync/observer.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/sync/source.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/sync/sync.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/sync/target.py +0 -0
- {apexdevkit-2.1.1 → apexdevkit-2.1.2}/apexdevkit/testing.py +0 -0
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from abc import ABC, abstractmethod
|
|
4
|
-
from collections.abc import Mapping
|
|
4
|
+
from collections.abc import Mapping, MutableSet
|
|
5
5
|
from dataclasses import dataclass, field
|
|
6
|
-
from typing import Any, Self
|
|
6
|
+
from typing import Any, Protocol, Self
|
|
7
7
|
|
|
8
8
|
from fastapi import APIRouter, FastAPI
|
|
9
9
|
from fastapi.middleware.cors import CORSMiddleware
|
|
10
10
|
from fastapi.responses import JSONResponse
|
|
11
11
|
|
|
12
|
+
from apexdevkit.annotation import deprecated
|
|
12
13
|
from apexdevkit.error import ApiError
|
|
13
14
|
from apexdevkit.fastapi.dependable import DependableBuilder
|
|
14
15
|
from apexdevkit.fastapi.service import RestfulService
|
|
@@ -65,22 +66,61 @@ class FastApiBuilder:
|
|
|
65
66
|
|
|
66
67
|
return self
|
|
67
68
|
|
|
69
|
+
@deprecated(
|
|
70
|
+
warning="""
|
|
71
|
+
.with_frontend is deprecated
|
|
72
|
+
use .apply(CORSApplicator()) instead
|
|
73
|
+
"""
|
|
74
|
+
)
|
|
68
75
|
def with_frontend(self, origin: str) -> Self: # pragma: no cover
|
|
69
|
-
self.
|
|
70
|
-
CORSMiddleware,
|
|
71
|
-
allow_origins=[origin],
|
|
72
|
-
allow_credentials=True,
|
|
73
|
-
allow_methods=["*"],
|
|
74
|
-
allow_headers=["*"],
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
return self
|
|
76
|
+
return self.apply(CORSApplicator().with_origin(origin))
|
|
78
77
|
|
|
79
78
|
def with_swagger(self, **config: Any) -> Self: # pragma: no cover
|
|
80
79
|
self.app.swagger_ui_parameters = config
|
|
81
80
|
|
|
82
81
|
return self
|
|
83
82
|
|
|
83
|
+
def apply(self, applicator: Applicator) -> Self:
|
|
84
|
+
applicator.apply_to(self.app)
|
|
85
|
+
|
|
86
|
+
return self
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class Applicator(Protocol):
|
|
90
|
+
def apply_to(self, app: FastAPI) -> None:
|
|
91
|
+
pass
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@dataclass(frozen=True)
|
|
95
|
+
class CORSApplicator:
|
|
96
|
+
origins: MutableSet[str] = field(default_factory=set)
|
|
97
|
+
|
|
98
|
+
def and_origin(self, origin: str) -> Self:
|
|
99
|
+
return self.with_origin(origin)
|
|
100
|
+
|
|
101
|
+
def with_origin(self, origin: str) -> Self:
|
|
102
|
+
self.origins.add(origin)
|
|
103
|
+
|
|
104
|
+
return self
|
|
105
|
+
|
|
106
|
+
def and_localhost(self, port: int) -> Self:
|
|
107
|
+
return self.with_localhost(port)
|
|
108
|
+
|
|
109
|
+
def with_localhost(self, port: int) -> Self:
|
|
110
|
+
self.origins.add(f"http://localhost:{port}")
|
|
111
|
+
self.origins.add(f"http://127.0.0.1:{port}")
|
|
112
|
+
|
|
113
|
+
return self
|
|
114
|
+
|
|
115
|
+
def apply_to(self, app: FastAPI) -> None:
|
|
116
|
+
app.add_middleware(
|
|
117
|
+
CORSMiddleware,
|
|
118
|
+
allow_origins=list(self.origins),
|
|
119
|
+
allow_credentials=True,
|
|
120
|
+
allow_methods=["*"],
|
|
121
|
+
allow_headers=["*"],
|
|
122
|
+
)
|
|
123
|
+
|
|
84
124
|
|
|
85
125
|
@dataclass
|
|
86
126
|
class RestfulServiceBuilder(ABC):
|
|
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
|