tools2fast-fastapi 0.1.3__tar.gz → 0.1.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.
- {tools2fast_fastapi-0.1.3/src/tools2fast_fastapi.egg-info → tools2fast_fastapi-0.1.4}/PKG-INFO +1 -1
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/pyproject.toml +1 -1
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi/__init__.py +2 -0
- tools2fast_fastapi-0.1.4/src/tools2fast_fastapi/__version__.py +1 -0
- tools2fast_fastapi-0.1.4/src/tools2fast_fastapi/utils/__init__.py +7 -0
- tools2fast_fastapi-0.1.4/src/tools2fast_fastapi/utils/routing.py +55 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4/src/tools2fast_fastapi.egg-info}/PKG-INFO +1 -1
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi.egg-info/SOURCES.txt +2 -0
- tools2fast_fastapi-0.1.3/src/tools2fast_fastapi/__version__.py +0 -1
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/LICENSE +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/MANIFEST.in +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/README.md +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/docs/guide.md +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/examples/example.py +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/setup.cfg +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi/models/__init__.py +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi/models/mixins.py +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi/schemas/__init__.py +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi/schemas/mixins.py +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi/schemas/response_schema.py +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi/services/__init__.py +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi/services/document_simple_revision_service.py +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi/services/document_with_items_revision_service.py +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi/services/number_service.py +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi/services/revision_service.py +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi/services/transaction_service.py +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi.egg-info/dependency_links.txt +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi.egg-info/requires.txt +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi.egg-info/top_level.txt +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/tests/test_initial.py +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/tests/test_revision_service.py +0 -0
- {tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/tests/test_schemas.py +0 -0
{tools2fast_fastapi-0.1.3/src/tools2fast_fastapi.egg-info → tools2fast_fastapi-0.1.4}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tools2fast-fastapi
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: Shared tools, mixins, and base services for FastAPI applications - Solautyc Team internal use
|
|
5
5
|
Author-email: Angel Daniel Sanchez Castillo <angeldaniel.sanchezcastillo@gmail.com>
|
|
6
6
|
License: MIT License
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "tools2fast-fastapi"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.4"
|
|
8
8
|
description = "Shared tools, mixins, and base services for FastAPI applications - Solautyc Team internal use"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from .models.mixins import AuditMixin, IdMixin, TimestampMixin, NumberUniqueMixin, RevisionMixin, NumberMixin
|
|
2
2
|
from .services import DocumentSimpleRevisionService, DocumentWithItemsRevisionService, TransactionService
|
|
3
3
|
from .schemas import APIResponse, BaseResponse, DataResponse, MessageResponse
|
|
4
|
+
from .utils import SafeRouter
|
|
4
5
|
from . import schemas
|
|
5
6
|
from .__version__ import __version__
|
|
6
7
|
|
|
@@ -15,6 +16,7 @@ __all__ = [
|
|
|
15
16
|
"BaseResponse",
|
|
16
17
|
"DataResponse",
|
|
17
18
|
"MessageResponse",
|
|
19
|
+
"SafeRouter",
|
|
18
20
|
"DocumentSimpleRevisionService",
|
|
19
21
|
"DocumentWithItemsRevisionService",
|
|
20
22
|
"TransactionService",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.4"
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Utilidades compartidas para los routers de tenant.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import functools
|
|
6
|
+
from typing import Any, Callable
|
|
7
|
+
|
|
8
|
+
from fastapi import APIRouter
|
|
9
|
+
from fastapi.responses import JSONResponse
|
|
10
|
+
from fastapi.types import DecoratedCallable
|
|
11
|
+
from .. import APIResponse
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def handle_exceptions(func: Callable) -> Callable:
|
|
15
|
+
"""
|
|
16
|
+
Decorator que envuelve un endpoint async y convierte cualquier excepción
|
|
17
|
+
en una ``JSONResponse`` estándar usando ``APIResponse.from_exception``.
|
|
18
|
+
|
|
19
|
+
Uso::
|
|
20
|
+
|
|
21
|
+
@router.get("/items/")
|
|
22
|
+
@handle_exceptions
|
|
23
|
+
async def list_items(session: AsyncSession = Depends(get_tenant_session)):
|
|
24
|
+
items = await service.list(session)
|
|
25
|
+
return APIResponse.ok(items)
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
@functools.wraps(func)
|
|
29
|
+
async def wrapper(*args, **kwargs) -> JSONResponse:
|
|
30
|
+
try:
|
|
31
|
+
return await func(*args, **kwargs)
|
|
32
|
+
except Exception as exc:
|
|
33
|
+
return APIResponse.from_exception(exc)
|
|
34
|
+
|
|
35
|
+
return wrapper
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class SafeRouter(APIRouter):
|
|
39
|
+
"""
|
|
40
|
+
``APIRouter`` que aplica ``handle_exceptions`` automáticamente a todos
|
|
41
|
+
los endpoints registrados, sin necesidad de decorar cada función.
|
|
42
|
+
|
|
43
|
+
Uso::
|
|
44
|
+
|
|
45
|
+
router = SafeRouter(prefix="/tenant/quotations", tags=["Quotations"])
|
|
46
|
+
|
|
47
|
+
@router.get("/items/")
|
|
48
|
+
async def list_items(...):
|
|
49
|
+
... # sin try/except, sin @handle_exceptions
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
def add_api_route(
|
|
53
|
+
self, path: str, endpoint: DecoratedCallable, **kwargs: Any
|
|
54
|
+
) -> None:
|
|
55
|
+
super().add_api_route(path, handle_exceptions(endpoint), **kwargs)
|
{tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4/src/tools2fast_fastapi.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tools2fast-fastapi
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: Shared tools, mixins, and base services for FastAPI applications - Solautyc Team internal use
|
|
5
5
|
Author-email: Angel Daniel Sanchez Castillo <angeldaniel.sanchezcastillo@gmail.com>
|
|
6
6
|
License: MIT License
|
{tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi.egg-info/SOURCES.txt
RENAMED
|
@@ -22,6 +22,8 @@ src/tools2fast_fastapi/services/document_with_items_revision_service.py
|
|
|
22
22
|
src/tools2fast_fastapi/services/number_service.py
|
|
23
23
|
src/tools2fast_fastapi/services/revision_service.py
|
|
24
24
|
src/tools2fast_fastapi/services/transaction_service.py
|
|
25
|
+
src/tools2fast_fastapi/utils/__init__.py
|
|
26
|
+
src/tools2fast_fastapi/utils/routing.py
|
|
25
27
|
tests/test_initial.py
|
|
26
28
|
tests/test_revision_service.py
|
|
27
29
|
tests/test_schemas.py
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.3"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi/models/__init__.py
RENAMED
|
File without changes
|
{tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi/models/mixins.py
RENAMED
|
File without changes
|
{tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi/schemas/__init__.py
RENAMED
|
File without changes
|
{tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi/schemas/mixins.py
RENAMED
|
File without changes
|
|
File without changes
|
{tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi/services/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi.egg-info/requires.txt
RENAMED
|
File without changes
|
{tools2fast_fastapi-0.1.3 → tools2fast_fastapi-0.1.4}/src/tools2fast_fastapi.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|