fastapi-extra 0.1.6__tar.gz → 0.1.7__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.
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/PKG-INFO +1 -1
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra/__init__.py +1 -1
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra/cache/redis.py +2 -2
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra/database/driver.py +5 -3
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra/dependency.py +3 -3
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra/form.py +8 -1
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra/types.py +2 -1
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra.egg-info/PKG-INFO +1 -1
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/LICENSE +0 -0
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/README.rst +0 -0
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra/cache/__init__.py +0 -0
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra/database/__init__.py +0 -0
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra/database/model.py +0 -0
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra/database/service.py +0 -0
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra/database/session.py +0 -0
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra/native/cursor.pyx +0 -0
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra/native/routing.pyx +0 -0
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra/response.py +0 -0
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra/settings.py +0 -0
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra/utils.py +0 -0
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra.egg-info/SOURCES.txt +0 -0
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra.egg-info/dependency_links.txt +0 -0
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra.egg-info/requires.txt +0 -0
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/fastapi_extra.egg-info/top_level.txt +0 -0
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/pyproject.toml +0 -0
- {fastapi_extra-0.1.6 → fastapi_extra-0.1.7}/setup.cfg +0 -0
|
@@ -8,7 +8,7 @@ from fastapi.params import Depends
|
|
|
8
8
|
from pydantic import BaseModel, Field, RedisDsn
|
|
9
9
|
from redis.asyncio import ConnectionPool, Redis
|
|
10
10
|
|
|
11
|
-
from fastapi_extra.dependency import
|
|
11
|
+
from fastapi_extra.dependency import AbstractComponent
|
|
12
12
|
from fastapi_extra.settings import Settings
|
|
13
13
|
|
|
14
14
|
|
|
@@ -26,7 +26,7 @@ _settings = DefaultRedisSettings() # type: ignore
|
|
|
26
26
|
_loaded_pools: list[ConnectionPool] = []
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
class RedisCli(
|
|
29
|
+
class RedisCli(AbstractComponent):
|
|
30
30
|
default_config = _settings.redis
|
|
31
31
|
|
|
32
32
|
|
|
@@ -11,7 +11,7 @@ from sqlalchemy.util import _concurrency_py3k
|
|
|
11
11
|
from sqlmodel import Session, create_engine
|
|
12
12
|
from sqlmodel.ext.asyncio.session import AsyncSession
|
|
13
13
|
|
|
14
|
-
from fastapi_extra.dependency import
|
|
14
|
+
from fastapi_extra.dependency import AbstractComponent
|
|
15
15
|
from fastapi_extra.settings import Settings
|
|
16
16
|
|
|
17
17
|
|
|
@@ -37,7 +37,7 @@ _settings = DefaultDatabaseSettings() # type: ignore
|
|
|
37
37
|
_loaded_engines: list[Engine] = []
|
|
38
38
|
|
|
39
39
|
|
|
40
|
-
class DB(
|
|
40
|
+
class DB(AbstractComponent):
|
|
41
41
|
default_config = _settings.datasource
|
|
42
42
|
default_options = {}
|
|
43
43
|
|
|
@@ -65,7 +65,9 @@ class AsyncDB(DB):
|
|
|
65
65
|
|
|
66
66
|
@property
|
|
67
67
|
def engine(self) -> AsyncEngine:
|
|
68
|
-
|
|
68
|
+
if not self._engine:
|
|
69
|
+
self._engine = AsyncEngine(super().engine)
|
|
70
|
+
return self._engine
|
|
69
71
|
|
|
70
72
|
@property
|
|
71
73
|
def session(self) -> AsyncSession:
|
|
@@ -8,7 +8,7 @@ from typing import Annotated, Any, Self
|
|
|
8
8
|
from fastapi.params import Depends
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
class
|
|
11
|
+
class DependencyMetaClass(ABCMeta):
|
|
12
12
|
|
|
13
13
|
def __new__(
|
|
14
14
|
mcs,
|
|
@@ -23,11 +23,11 @@ class AnnotationMetaClass(ABCMeta):
|
|
|
23
23
|
return new_cls
|
|
24
24
|
|
|
25
25
|
|
|
26
|
-
class AbstractDependency(metaclass=
|
|
26
|
+
class AbstractDependency(metaclass=DependencyMetaClass, annotated=False):
|
|
27
27
|
__slot__ = ()
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
class
|
|
30
|
+
class AbstractComponent(AbstractDependency, annotated=False):
|
|
31
31
|
__slot__ = ()
|
|
32
32
|
__instance__: Any = None
|
|
33
33
|
|
|
@@ -6,7 +6,7 @@ from typing import Generic, Literal
|
|
|
6
6
|
|
|
7
7
|
from pydantic import BaseModel, Field, model_validator
|
|
8
8
|
|
|
9
|
-
from fastapi_extra.types import C, S
|
|
9
|
+
from fastapi_extra.types import C, S, Schema
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
class DataRange(BaseModel, Generic[C]):
|
|
@@ -28,3 +28,10 @@ class ColumnExpression(BaseModel, Generic[S]):
|
|
|
28
28
|
class WhereClause(BaseModel):
|
|
29
29
|
option: Literal["and", "or"] = Field(default="and", title="关系")
|
|
30
30
|
column_clauses: list[ColumnExpression | "WhereClause"]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class Page(BaseModel, Generic[Schema]):
|
|
34
|
+
items: list[Schema] = Field(default_factory=list, title="列表")
|
|
35
|
+
total: int = Field(default=0, title="总量")
|
|
36
|
+
page_num: int = Field(default=0, title="页码")
|
|
37
|
+
page_size: int = Field(default=0, title="单页大小")
|
|
@@ -6,7 +6,7 @@ import datetime
|
|
|
6
6
|
import decimal
|
|
7
7
|
from typing import Annotated, Any, TypeVar, Union
|
|
8
8
|
|
|
9
|
-
from pydantic import PlainSerializer
|
|
9
|
+
from pydantic import BaseModel, PlainSerializer
|
|
10
10
|
from sqlmodel import SQLModel
|
|
11
11
|
|
|
12
12
|
Comparable = Union[int, float, decimal.Decimal, datetime.datetime, datetime.date, datetime.time]
|
|
@@ -17,6 +17,7 @@ T = TypeVar("T", bound=Any)
|
|
|
17
17
|
E = TypeVar("E", bound=Exception)
|
|
18
18
|
C = TypeVar("C", bound=Comparable)
|
|
19
19
|
S = TypeVar("S", bound=Serializable)
|
|
20
|
+
Schema = TypeVar("Schema", bound=BaseModel)
|
|
20
21
|
Model = TypeVar("Model", bound=SQLModel)
|
|
21
22
|
|
|
22
23
|
Cursor = Annotated[
|
|
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
|